diff --git a/KJD_WebService/BLL/WXXD/WXProductManage.cs b/KJD_WebService/BLL/WXXD/WXProductManage.cs index 6f494cb..11dc465 100644 --- a/KJD_WebService/BLL/WXXD/WXProductManage.cs +++ b/KJD_WebService/BLL/WXXD/WXProductManage.cs @@ -30,6 +30,104 @@ namespace KJD_Web.BLL.WXXD return new BLL.BXX.BXXProductManage().GetHotProductList(inputData, isDetail); } + public string WXGetProductLatestBuyAmountList(string inputData, bool isDetail = false) + { + var timeCalc = DateTime.Now; + if (!string.IsNullOrEmpty(inputData)) + { + var sign = RegexUtils.GetStringQuery(ref inputData, "sign"); + if (!WXShopManage.GetTimeSign(sign)) + return "{\"code\":500,\"msg\":\"校验失败\"}"; + + var out_product_ids = RegexUtils.GetStringQuery(ref inputData, "out_product_ids")?.Replace("'", "\\'"); + out_product_ids = string.Join("','", out_product_ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)); + + string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; + MysqlUtils mySql = new MysqlUtils(conn); + + string sql = @" +SELECT * +FROM ( + SELECT oi.id,oi.shop_id,oi.order_id,oi.product_id,oi.sku_id,oi.sku_cnt,oi.sku_code,oi.out_product_id,oi.out_sku_id, + ROW_NUMBER() OVER (PARTITION BY out_product_id, out_sku_id ORDER BY id DESC) as rn,o.out_amount,o.create_time + FROM `erp`.`oms_wei_order_item` oi + LEFT JOIN `erp`.`oms_wei_order` o ON oi.order_id = o.order_id + WHERE oi.out_product_id IN ('" + out_product_ids + @"') AND oi.refund_status = 1 AND o.status > 20 AND o.gift_order_status = 0 +) r +WHERE r.rn <= 3; +"; + + DataTable dt = mySql.ExecuteDataTable(sql); + mySql.Close(); + + if (dt != null) + { + try + { + List prodOutAmountList = new List(); + foreach (DataRow row in dt.Rows) + { + ProductLatestOutAmountInfo prodOutAmount = new ProductLatestOutAmountInfo + { + order_id = row["order_id"].ParseToString(), + out_product_id = row["out_product_id"].ParseToString(), + out_sku_id = row["out_sku_id"].ParseToString(), + product_id = row["product_id"].ParseToString(), + shop_id = row["shop_id"].ParseToString(), + sku_cnt = row["sku_cnt"].ParseToInt(), + sku_code = row["sku_code"].ParseToString(), + sku_id = row["sku_id"].ParseToString(), + out_amount = row["out_amount"].ParseToInt(), + }; + prodOutAmountList.Add(prodOutAmount); + } + + var noOutAmountOrderIdLst = string.Join("','", prodOutAmountList.Where(p => p.out_amount == 0).Select(p => p.order_id)); + conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; + mySql = new MysqlUtils(conn); + sql = @" +SELECT * +FROM ( + SELECT id,order_no,order_sku_id,out_amount,ROW_NUMBER() OVER (PARTITION BY order_no ORDER BY id DESC) as rn + FROM `erp`.`oms_wei_external_procurement_log` + WHERE order_no IN ('" + noOutAmountOrderIdLst + @"') +) oi +WHERE oi.rn = 1;"; + DataTable transitDt = mySql.ExecuteDataTable(sql); + mySql.Close(); + if (mySql.Message.IsNullOrEmpty() && transitDt != null) + { + foreach (DataRow row in transitDt.Rows) + { + var outAmount = row["out_amount"].ParseToInt(); + var order_sku_id = row["order_sku_id"].ParseToString(); + var order_no = row["order_no"].ParseToString(); + if (prodOutAmountList.FirstOrDefault(p => p.sku_id == order_sku_id && p.order_id == order_no) is ProductLatestOutAmountInfo outAmountInfo) + { + if (outAmountInfo.out_amount == 0 && outAmount != 0) + outAmountInfo.out_amount = outAmount; + } + } + } + + JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; + var data = JsonUtils.SerializeObjectToString(prodOutAmountList, jsonSetting); + var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000"); + return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"seconds\":" + seconds + "}"; + } + catch (Exception ex) + { + return "{\"code\":500,\"msg\":\"" + ex.Message + "\",\"data\":[],\"count\":" + 0 + "}"; + } + } + else + { + return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}"; + } + } + return "{\"code\":19999,\"msg\":\"输入为空\"}"; + } + public string WXGetPDDProductGroups(string inputData) { if (!string.IsNullOrEmpty(inputData)) diff --git a/KJD_WebService/KJD_WebService.csproj b/KJD_WebService/KJD_WebService.csproj index d237422..1406c4e 100644 --- a/KJD_WebService/KJD_WebService.csproj +++ b/KJD_WebService/KJD_WebService.csproj @@ -1,4 +1,4 @@ - + @@ -155,6 +155,7 @@ + diff --git a/KJD_WebService/Model/WxModel/ProductLatestOutAmountInfo.cs b/KJD_WebService/Model/WxModel/ProductLatestOutAmountInfo.cs new file mode 100644 index 0000000..378ed78 --- /dev/null +++ b/KJD_WebService/Model/WxModel/ProductLatestOutAmountInfo.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace KJD_Web.Model.WxModel +{ + public class ProductLatestOutAmountInfo + { + public string order_id { get; set; } // 3739003536152355584 + + public string out_product_id { get; set; } // EC1960398929745-15938489009A + public string out_sku_id { get; set; } // BSEC18052272175281198712A + public int sku_cnt { get; set; } // 1 + + /// + /// 外采金额,单位分 + /// + public int out_amount { get; set; } // 1129 + + public string shop_id { get; set; } // 1960967267443629494 + public string product_id { get; set; } // 10001456670425 + public string sku_id { get; set; } // 26988803933 + public string sku_code { get; set; } // BSEC18052272175281198712A + } +} \ No newline at end of file diff --git a/KJD_WebService/WXProductService.asmx.cs b/KJD_WebService/WXProductService.asmx.cs index a443c5c..560088c 100644 --- a/KJD_WebService/WXProductService.asmx.cs +++ b/KJD_WebService/WXProductService.asmx.cs @@ -87,7 +87,7 @@ namespace KJD_Web } [WebMethod] - public void get_hot_detail_product_list() + public void get_hot_product_detail_list() { string jsontext = GetRequestJsonString(); @@ -99,6 +99,19 @@ namespace KJD_Web } + [WebMethod] + public void wx_get_product_latest_buy_amount_list() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new WXProductManage().WXGetProductLatestBuyAmountList(jsontext, true); + + Context.Response.Write(result); + Context.Response.End(); + } + + [WebMethod] public void get_pdd_product_list_random() {