订单优化相关功能
This commit is contained in:
1 parent
2afe960b6c
commit
abdc09afa1
13 files changed
+1097
-808
No files matched your search
@@ -0,0 +1,268 @@
|
||||
using AllBase;
|
||||
using AllBase.Model.Result;
|
||||
using AllBase.Model.Result.WXResult;
|
||||
using NaiBa.Util.Extension;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TemuKJD.BaseForms;
|
||||
using TemuKJD.WXForms.ProductForms;
|
||||
|
||||
namespace TemuKJD.WXForms.OrderForms
|
||||
{
|
||||
public partial class WXOrderListOptimizeForm : BaseForms.BaseGeneralForm
|
||||
{
|
||||
public ShopLoginInfo shop;
|
||||
|
||||
public WXOrderListOptimizeForm(ShopLoginInfo _shop)
|
||||
{
|
||||
InitializeComponent();
|
||||
shop = _shop;
|
||||
this.TitleText = "店铺 " + shop.ShopAccount + " 优化订单";
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
public JObject prodObj = new JObject();
|
||||
public bool EditPriceSuccess { get; set; } = false;
|
||||
public bool SendGiftSuccess { get; set; } = false;
|
||||
public bool ClearStock { get; set; } = false;
|
||||
public bool IsDownProd { get; set; } = false;
|
||||
private void btnAddPrice_Click(object sender, EventArgs e)
|
||||
{
|
||||
EditPriceSuccess = false;
|
||||
|
||||
try
|
||||
{
|
||||
var spuId = lblSpuId.Text;
|
||||
int onSaleStatusCode = -1;
|
||||
int pageSize = 50;
|
||||
var getProdOnSaleRst = WXClearNoVisit.searchProduct(shop, 1, pageSize, spuId, onSaleStatusCode);
|
||||
if (!getProdOnSaleRst.Contains("\"success\":true"))
|
||||
{
|
||||
var error = BaseRegex.GetStringJsonByRegs(ref getProdOnSaleRst, getProdOnSaleRst, "err_msg", "error_msg", "errMsg", "errorMsg", "msg");
|
||||
BaseMsgForm.ShowInfo("改价失败" + error);
|
||||
}
|
||||
prodObj = JsonHelper.JObjectParse(getProdOnSaleRst)["productList"].FirstOrDefault() as JObject;
|
||||
if (prodObj != null)
|
||||
{
|
||||
var str = JsonHelper.SerializeObject(prodObj);
|
||||
}
|
||||
|
||||
//var rst = WXOrderList.EditPrice(shop, lblSpuId.Text, lblSkuId.Text, (numAddPrice.Value * 100).ParseToInt());
|
||||
|
||||
JObject changePriceObj = new JObject();
|
||||
JArray skuArr = new JArray();
|
||||
foreach (var sku in prodObj["skuList"])
|
||||
{
|
||||
JObject obj = new JObject();
|
||||
obj["spuId"] = spuId;
|
||||
obj["skuId"] = sku["skuId"];
|
||||
obj["salePrice"] = sku["price"].ParseToInt() + (numAddPrice.Value * 100).ParseToInt();
|
||||
skuArr.Add(obj);
|
||||
}
|
||||
changePriceObj["skuList"] = skuArr;
|
||||
changePriceObj["uploadSource"] = 6;
|
||||
|
||||
// string body = @"{""skuList"":[{""spuId"":" + spuId + @",""skuId"":""" + skuId + @""",""salePrice"":" + newPrice + @"}],""uploadSource"":6}";
|
||||
var rst = WXOrderList.EditPrice(shop, changePriceObj);
|
||||
|
||||
if (rst.Contains("\"code\":0"))
|
||||
{
|
||||
EditPriceSuccess = true;
|
||||
BaseMsgForm.ShowInfo("改价成功");
|
||||
this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
var error = BaseRegex.GetStringJsonByRegs(ref rst, rst, "err_msg", "error_msg", "errMsg", "errorMsg", "msg");
|
||||
BaseMsgForm.ShowError("改价失败:" + error);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void btnSendGift_Click(object sender, EventArgs e)
|
||||
{
|
||||
SendGiftSuccess = false;
|
||||
string orderId = lblOrderId.Text.Trim();
|
||||
string waybillId = txtGiftOrderWaybillId.Text.Trim();
|
||||
pbLoading.Visible = true;
|
||||
Task.Run(() =>
|
||||
{
|
||||
var rst = WXOrderList.initDeliveryInfo(shop, orderId);
|
||||
// {"code":0,"orderDetail":{"commonInfo":{"orderId":"3736582386601580032","orderType":0,"statusStr":"待发货","status":20,"originalStatus":11,"openid":"ow5ty7Kyik_dSqtrivr5hY2t4cwY","createTime":1779540820,"createTimeStr":"2026-05-23 20:53","isPayScoreOrder":false,"isPayDone":true,"isVirtualOrder":false,"isAuthorizedAccount":false,"giftOrderType":"","isInspectOrder":false,"isCommissionOrderDone":false,"isRechargeOrder":false,"isExpediteOrder":false,"isOverTimeOrder":2,"isMultiPackage":false,"inspectType":0,"isGiftOrder":false,"isBuyTogetherOrder":false,"isLotteryOrder":false,"isEducationOrder":false,"hideGiftOrderAddressInfo":false,"cosignmentFlag":1,"isNationalSubsidy":0,"isSameCityOrder":false,"isNationalSubsidyMerchant":false,"isSupplyOrder":false},"orderProducts":{"orderProductInfo":[{"productId":"10000863142394","thumbImg":"https://wst.wxapp.tc.qq.com/161/20304/snscosdownload/SH/reserved/6a092e3a000107862152a36aa881bc1e000000a100004f50","title":"脂砚斋评石头记(全三册) 烫金珍藏版 彩绘绣像 双色印刷","skuId":"15274875174","saleParam":["默认"],"productType":1,"productCnt":1,"salePrice":"3400","spuCode":"9787555418979","skuCode":"BSEC12302592708637555055A","isPreSale":false,"isIflashbuy":false,"isFreeGift":false,"canAfterSale":true,"realPrice":3350,"perRealPrice":3350,"tags":[{"class":"black","desc":"7天无理由","iconUrl":"","mainUrl":"","tagType":4},{"class":"black","desc":"运费险","iconUrl":"","mainUrl":"","tagType":5}],"icons":[],"perExchangeScore":"","productSource":{"show":false},"afterSaleInfo":{"afterId":"","canAfterSale":true,"canNotAfterSaleReason":"","jumpUrl":"","title":"","content":"","afterSaleDoneStr":"","afterSaleDoneAmountStr":"","afterSaleDoneAmount":0,"afterSaleDoneProductCnt":0,"afterSaleIngProductCnt":0,"isGuaranteeIng":false,"hasFakeOnePayFourDoneGuarantee":false},"changeProduct":0,"afterSaleDoneProductCnt":0,"afterSaleIngProductCnt":0,"supplyProductId":"","supplyNickName":"","supplyOrderId":"","supplyAppid":""}],"priceInfo":{"productPrice":"3400","orderPrice":"3350","freight":0,"originalOrderPrice":"3400","estimateProductPrice":"3350","handingFee":"0","maxUnsplitAmount":"3350","totalDiscountedPrice":"50","merchantReceievePrice":"3350","platformActivityMerchantDiscountedPrice":"50"},"activityInfo":{},"presentFee":{}},"acceptInfo":{"decodeSensitiveTime":0,"editAddrInfo":{"applyEditAddrStatus":0,"applyEditAddrAuditStaff":"","applyEditAddrAuditTimeText":"","negotiationEditTextForB":"","negotiationEditTextForA":"","negotiationEditStatus":0,"negotiationEditHistory":[],"canNegotiation":true,"hasUnResolvedRequest":0,"hasHistoryMerchantEditAddr":0,"editHistory":[]},"customerNotes":"","merchantNotes":"","presentNotes":"","addressInfo":{"cityName":"宝鸡市","countyName":"眉县","provinceName":"陕西省","userName":"刘**","telNumber":"187****9569","detailInfo":"****","virtualOrderTelNumber":""},"virtualNumberInfo":{},"quota":{"code":0,"limit":10,"used":10,"hideSensitiveInfo":true},"rechargeData":{"label":"","content":"","deliverMethod":0},"addressErrType":0},"expressInfo":{"phone":"9569","deliveryProductInfo":[],"orderProductCnt":1,"deliveryCnt":0,"isIntracityOrder":false,"intracityTracking":null,"formatUnshippedProductList":[{"productId":"10000863142394","thumbImg":"https://wst.wxapp.tc.qq.com/161/20304/snscosdownload/SH/reserved/6a092e3a000107862152a36aa881bc1e000000a100004f50","title":"脂砚斋评石头记(全三册) 烫金珍藏版 彩绘绣像 双色印刷","skuId":"15274875174","saleParam":["默认"],"productType":1,"productCnt":1,"salePrice":"3400","spuCode":"9787555418979","skuCode":"BSEC12302592708637555055A","isPreSale":false,"isIflashbuy":false,"isFreeGift":false,"canAfterSale":true,"realPrice":3350,"perRealPrice":3350,"tags":[{"class":"black","desc":"7天无理由","iconUrl":"","mainUrl":"","tagType":4},{"class":"black","desc":"运费险","iconUrl":"","mainUrl":"","tagType":5}],"icons":[],"perExchangeScore":"","productSource":1,"afterSaleInfo":{"afterId":"","canAfterSale":true,"canNotAfterSaleReason":"","jumpUrl":"","title":"","content":"","afterSaleDoneStr":"","afterSaleDoneAmountStr":"","afterSaleDoneAmount":0,"afterSaleDoneProductCnt":0,"afterSaleIngProductCnt":0,"isGuaranteeIng":false,"hasFakeOnePayFourDoneGuarantee":false},"changeProduct":0,"afterSaleDoneProductCnt":0,"afterSaleIngProductCnt":0,"supplyProductId":"","supplyNickName":"","supplyOrderId":"","supplyAppid":""}],"product2Img":{"15274875174":"https://wst.wxapp.tc.qq.com/161/20304/snscosdownload/SH/reserved/6a092e3a000107862152a36aa881bc1e000000a100004f50"}},"ewaybillInfo":{"isAllPrintOne":false,"isOpen":false,"deliveryId":"","deliveryName":"","waybillId":""}},"sendAddressInfo":{"userName":"陈图书","postalCode":"","provinceName":"安徽省","cityName":"合肥市","countyName":"肥西县","detailInfo":"上派镇中盟电子产业园8栋一单元(东电梯3楼快递指定存放点)","telNumber":"13023098035","lat":0,"lng":0},"deliveryCompanyOptions":[{"labeLine truncated
|
||||
if (!rst.Contains("\"code\":0"))
|
||||
{
|
||||
var error = BaseRegex.GetStringJsonByRegs(ref rst, rst, "err_msg", "error_msg", "errMsg", "errorMsg", "msg");
|
||||
BaseMsgForm.ShowInfo("发送礼物单失败 " + error);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
pbLoading.Visible = false;
|
||||
}));
|
||||
return;
|
||||
}
|
||||
var statusStr = BaseRegex.GetStringJson(ref rst, "statusStr");
|
||||
if (statusStr == "待发货")
|
||||
{
|
||||
//{"orderId":"3736580679658008320","deliveryProduct":{"deliveryId":"YUNDA","waybillId":"313023381086999","isAllProduct":true,"deliverType":1}}
|
||||
//{"code":0,"errcode":0,"errmsg":"ok"}
|
||||
rst = WXOrderList.orderSendOut(shop, orderId, waybillId);
|
||||
if (!rst.Contains("\"code\":0"))
|
||||
{
|
||||
var error = BaseRegex.GetStringJsonByRegs(ref rst, rst, "err_msg", "error_msg", "errMsg", "errorMsg", "msg");
|
||||
BaseMsgForm.ShowInfo("发送礼物单失败 " + error);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
pbLoading.Visible = false;
|
||||
}));
|
||||
return;
|
||||
}
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
SendGiftSuccess = true;
|
||||
BaseMsgForm.ShowInfo("发送礼物单成功");
|
||||
pbLoading.Visible = false;
|
||||
this.Close();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
//{"orderId":"3736580679658008320","changeInfo":[{"old":{"deliveryId":"YUNDA","waybillId":"313023381086999","productInfos":[{"productId":"10000875072190","skuId":"15516018429","productCnt":1}]},"new":{"deliveryId":"OTHER","waybillId":"772064082455686","productInfos":[{"productId":"10000875072190","skuId":"15516018429","productCnt":1}]}}]}
|
||||
//{"code":0,"errcode":0,"errmsg":""}
|
||||
var orderExpressInfoObj = JsonHelper.JObjectParse(rst)["orderDetail"]["expressInfo"];
|
||||
var orderExpressInfo = JsonHelper.DeserializeJsonToObject<WxOrderExpressInfo>(JsonHelper.SerializeObject(orderExpressInfoObj));
|
||||
UpdateDeliverInfoParam param = new UpdateDeliverInfoParam();
|
||||
param.orderId = orderId;
|
||||
param.changeInfo = new List<Dictionary<string, UpdateDeliverChangeInfo>>();
|
||||
|
||||
foreach (var deliveryProductInfo in orderExpressInfo.deliveryProductInfo)
|
||||
{
|
||||
Dictionary<string, UpdateDeliverChangeInfo> dicChange = new Dictionary<string, UpdateDeliverChangeInfo>();
|
||||
dicChange["old"] = new UpdateDeliverChangeInfo();
|
||||
dicChange["old"].deliveryId = deliveryProductInfo.deliveryId;
|
||||
dicChange["old"].waybillId = deliveryProductInfo.waybillId;
|
||||
dicChange["old"].productInfos = new List<UpdateDeliverProductInfo>();
|
||||
dicChange["new"] = new UpdateDeliverChangeInfo();
|
||||
dicChange["new"].deliveryId = "OTHER";
|
||||
dicChange["new"].waybillId = waybillId;
|
||||
dicChange["new"].productInfos = new List<UpdateDeliverProductInfo>();
|
||||
foreach (var prod in deliveryProductInfo.productInfos)
|
||||
{
|
||||
dicChange["old"].productInfos.Add(new UpdateDeliverProductInfo() { productCnt = prod.productCnt, productId = prod.productId, skuId = prod.skuId });
|
||||
dicChange["new"].productInfos.Add(new UpdateDeliverProductInfo() { productCnt = prod.productCnt, productId = prod.productId, skuId = prod.skuId });
|
||||
}
|
||||
param.changeInfo.Add(dicChange);
|
||||
}
|
||||
rst = WXOrderList.updateDeliveryInfo(shop, param);
|
||||
var str = JsonHelper.SerializeObject(param);
|
||||
if (!rst.Contains("\"code\":0"))
|
||||
{
|
||||
var error = BaseRegex.GetStringJsonByRegs(ref rst, rst, "err_msg", "error_msg", "errMsg", "errorMsg", "msg");
|
||||
BaseMsgForm.ShowInfo("变更发送礼物单失败 " + error);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
pbLoading.Visible = false;
|
||||
}));
|
||||
return;
|
||||
}
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
SendGiftSuccess = true;
|
||||
BaseMsgForm.ShowInfo("变更发送礼物单成功");
|
||||
pbLoading.Visible = false;
|
||||
this.Close();
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void btnClearStock_Click(object sender, EventArgs e)
|
||||
{
|
||||
ClearStock = false;
|
||||
string spuId = lblSpuId.Text.Trim();
|
||||
string skuId = lblSkuId.Text.Trim();
|
||||
string num = txtCurrentStock.Text.Trim();
|
||||
var rst = WXOrderList.batchUpdateStock(shop, spuId, skuId, num);
|
||||
if (!rst.Contains("\"code\":0"))
|
||||
{
|
||||
var error = BaseRegex.GetStringJsonByRegs(ref rst, rst, "err_msg", "error_msg", "errMsg", "errorMsg", "msg");
|
||||
BaseMsgForm.ShowInfo("清除库存失败 " + error);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
pbLoading.Visible = false;
|
||||
}));
|
||||
return;
|
||||
}
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
ClearStock = true;
|
||||
BaseMsgForm.ShowInfo("清除库存成功");
|
||||
pbLoading.Visible = false;
|
||||
this.Close();
|
||||
}));
|
||||
}
|
||||
|
||||
private void btnDownProduct_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (BaseMsgForm.ShowConfirm("确定下架吗?重新上架需要消耗提审次数").DialogResult != DialogResult.OK)
|
||||
return;
|
||||
|
||||
IsDownProd = false;
|
||||
string spuId = lblSpuId.Text.Trim();
|
||||
string skuId = lblSkuId.Text.Trim();
|
||||
string num = txtCurrentStock.Text.Trim();
|
||||
var rst = WXPreSale.DownProd(shop, spuId);
|
||||
if (!rst.Contains("\"code\":0"))
|
||||
{
|
||||
var error = BaseRegex.GetStringJsonByRegs(ref rst, rst, "err_msg", "error_msg", "errMsg", "errorMsg", "msg");
|
||||
BaseMsgForm.ShowInfo("商品下架失败 " + error);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
pbLoading.Visible = false;
|
||||
}));
|
||||
return;
|
||||
}
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
IsDownProd = true;
|
||||
BaseMsgForm.ShowInfo("商品下架成功");
|
||||
pbLoading.Visible = false;
|
||||
this.Close();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public class UpdateDeliverInfoParam
|
||||
{
|
||||
public string orderId { get; set; } // "3736580679658008320",
|
||||
public List<Dictionary<string, UpdateDeliverChangeInfo>> changeInfo { get; set; }
|
||||
}
|
||||
public class UpdateDeliverChangeInfo
|
||||
{
|
||||
public string deliveryId { get; set; } // "OTHER",
|
||||
public string waybillId { get; set; } // "772064082455686",
|
||||
public List<UpdateDeliverProductInfo> productInfos { get; set; } = new List<UpdateDeliverProductInfo>(); // [ { "productId": "10000875072190", "skuId": "15516018429", "productCnt": 1 } ]
|
||||
}
|
||||
|
||||
public class UpdateDeliverProductInfo
|
||||
{
|
||||
public string productId { get; set; } // "10000875072190",
|
||||
public string skuId { get; set; } // "15516018429",
|
||||
public int? productCnt { get; set; } // 1
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user