using AllBase; using AllBase.Helper; using CefSharp.DevTools.FedCm; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; using Work._29Tools.BLL; namespace _29WxOrderWpf.Services; /// /// 礼物单服务 /// /// public class ShipGiftService { public enum GiftType { _155 = 2, _160 = 5 } public async Task Send(string orderId, GiftType giftType) { var item = GlobalConfig.lstFilterOrder.FirstOrDefault(a => a.order_id == orderId); if (item == null) return false; decimal giftAmount = 1.6m; if (giftType == GiftType._155) { giftAmount = 1.55m; } decimal amount = giftAmount + BaseClass.OemGiftAmount; string province = item.province_name; string city = item.city_name; if (city == "深圳市") { amount += 0.60m; } else if (city == "北京市") { amount += 1.00m; } else if (city == "上海市") { amount += 0.60m; } else if (province.Contains("新疆") || province.Contains("西藏")) { amount += 12.15m; } string data = JsonConvert.SerializeObject(new { platformCode = "WEISHOP", orderIds = new List { orderId }, userId = BaseClass.UserId, userName = BaseClass.UserName, giftOrderType = (int)giftType, amount = (int)(amount * 100), oemAmount = (int)(BaseClass.OemGiftAmount * 100) }); Debug.WriteLine($"礼品单:{data}"); string ret = await HttpResponseWXBLL.e57PostResponseAsync("https://po.e57.cn//prod-api/api/oms-api/gift/order/deliveryFor29Erp", data, ""); XmlDocument doc = new XmlDocument(); doc.LoadXml(ret); //使用 Newtonsoft.Json 进行转换 string jsonText = JsonConvert.SerializeXmlNode(doc); JObject jsonObject = JObject.Parse(jsonText); int code = jsonObject["AjaxResult"]?["code"]?.Value() ?? 0; string msg = jsonObject["AjaxResult"]?["msg"]?.Value() ?? ""; if (code == 200 && msg.ToUpper() == "SUCCESS") { return true; } return false; } }