查询商品最后几笔订单的外采金额
This commit is contained in:
1 parent
a34a0b4a78
commit
8ee4bf59b9
4 files changed
+140
-2
No files matched your search
@@ -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<ProductLatestOutAmountInfo> prodOutAmountList = new List<ProductLatestOutAmountInfo>();
|
||||
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))
|
||||
|
||||
Reference in new issue
Block a user