From 8b09cc2ba12c1e536bea4fb05cfe968b02da650a Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sun, 15 Oct 2023 20:04:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=AE=A2=E5=8D=95=E4=BC=98?= =?UTF-8?q?=E6=83=A0=E6=98=8E=E7=BB=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/OrderController.cs | 11 + BBWY.Server.Business/Order/OrderBusiness.cs | 78 +++++++ .../Order/OrderCouponDetailResponse.cs | 206 ++++++++++++++++++ 3 files changed, 295 insertions(+) create mode 100644 BBWY.Server.Model/Dto/Response/Order/OrderCouponDetailResponse.cs diff --git a/BBWY.Server.API/Controllers/OrderController.cs b/BBWY.Server.API/Controllers/OrderController.cs index 5d9bdb61..63efd0a8 100644 --- a/BBWY.Server.API/Controllers/OrderController.cs +++ b/BBWY.Server.API/Controllers/OrderController.cs @@ -166,5 +166,16 @@ namespace BBWY.Server.API.Controllers { return orderBusiness.ExportOrderSkuList(request); } + + /// + /// 查询订单优惠明细 + /// + /// + /// + [HttpPost] + public OrderCouponDetailResponse GetOrderCouponDetail([FromBody] QueryOrderCouponDetailRequest request) + { + return orderBusiness.GetOrderCouponDetail(request); + } } } diff --git a/BBWY.Server.Business/Order/OrderBusiness.cs b/BBWY.Server.Business/Order/OrderBusiness.cs index 862ca2cc..112ffd4c 100644 --- a/BBWY.Server.Business/Order/OrderBusiness.cs +++ b/BBWY.Server.Business/Order/OrderBusiness.cs @@ -1236,5 +1236,83 @@ namespace BBWY.Server.Business } return list; } + + public OrderCouponDetailResponse GetOrderCouponDetail(QueryOrderCouponDetailRequest request) + { + var relayAPIHost = GetPlatformRelayAPIHost(request.Platform); + var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetOrderCouponDetail", request, GetYunDingRequestHeader(), HttpMethod.Post); + if (sendResult.StatusCode != System.Net.HttpStatusCode.OK) + throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode }; + var response = JsonConvert.DeserializeObject>(sendResult.Content); + if (!response.Success) + throw new BusinessException(response.Msg) { Code = response.Code }; + + var jtoken = response.Data; + + var itemList = new List(); + var couponDetailVoJToken = jtoken["jingdong_pop_order_coupondetail_responce"]["couponDetailExternal"]["couponDetailVo"]; + var promotionTaskJArray = couponDetailVoJToken["promotionList"] as JArray; + itemList.AddRange(promotionTaskJArray.Select(j => new OrderCouponDetailGroupItemResponse() + { + Initiator = string.IsNullOrEmpty(j.Value("promotionName")) ? "平台" : "商家", + CouponOrPromotionType = j.Value("saleTypeDesc"), + PreferentialAmount = j.Value("salePrice"), + UndertakenByMerchantAmount = 0, + UndertakenByPlatformAmount = 0 + })); + + var couponJArray = couponDetailVoJToken["couponList"] as JArray; + itemList.AddRange(couponJArray.Select(j => new OrderCouponDetailGroupItemResponse() + { + Initiator = string.IsNullOrEmpty(j.Value("couponName")) ? "平台" : "商家", + CouponOrPromotionType = j.Value("couponTypeDesc"), + PreferentialAmount = j.Value("couponPrice"), + UndertakenByMerchantAmount = j.Value("venderDivideMoney"), + UndertakenByPlatformAmount = j.Value("jdDivideMoney") + })); + + var groups = itemList.GroupBy(x => x.Initiator); + + + return new OrderCouponDetailResponse() + { + GroupList = groups.Select(g => new OrderCouponDetailGroupResponse() + { + Initiator = g.Key, + ItemList = g.ToList() + }).ToList(), + TotalPreferentialAmount = itemList.Sum(x => x.PreferentialAmount ?? 0), + TotalUndertakenByMerchantAmount = itemList.Where(x => x.Initiator == "商家").Sum(x => x.PreferentialAmount ?? 0), + TotalUndertakenByPlatformAmount = itemList.Where(x => x.Initiator == "平台").Sum(x => x.PreferentialAmount ?? 0), + TotalBalance = couponDetailVoJToken.Value("totalBalance"), + TotalBaseDiscount = couponDetailVoJToken.Value("totalBaseDiscount"), + TotalBaseFee = couponDetailVoJToken.Value("totalBaseFee"), + TotalCoupon = couponDetailVoJToken.Value("totalCoupon"), + TotalDongQuan = couponDetailVoJToken.Value("totalDongQuan"), + TotalExpiryGiftDiscount = couponDetailVoJToken.Value("totalExpiryGiftDiscount"), + TotalGlobalGeneralIncludeTax = couponDetailVoJToken.Value("totalGlobalGeneralIncludeTax"), + TotalGlobalGeneralTax = couponDetailVoJToken.Value("totalGlobalGeneralTax"), + TotalItemPrice = couponDetailVoJToken.Value("totalItemPrice"), + TotalJdZhiFuYouHui = couponDetailVoJToken.Value("totalJdZhiFuYouHui"), + TotalJingDou = couponDetailVoJToken.Value("totalJingDou"), + TotalJingQuan = couponDetailVoJToken.Value("totalJingQuan"), + TotalJingXiangLiJin = couponDetailVoJToken.Value("totalJingXiangLiJin"), + TotalLiJinYouHui = couponDetailVoJToken.Value("totalLiJinYouHui"), + TotalLuoDiPeiService = couponDetailVoJToken.Value("totalLuoDiPeiService"), + TotalManJian = couponDetailVoJToken.Value("totalManJian"), + TotalPingTaiChengDanYouHuiQuan = couponDetailVoJToken.Value("totalPingTaiChengDanYouHuiQuan"), + TotalPlus95 = couponDetailVoJToken.Value("totalPlus95"), + TotalPromotionDiscount = couponDetailVoJToken.Value("totalPromotionDiscount"), + TotalRemoteFee = couponDetailVoJToken.Value("totalRemoteFee"), + TotalShouldPay = couponDetailVoJToken.Value("totalShouldPay"), + TotalSuperRedEnvelope = couponDetailVoJToken.Value("totalSuperRedEnvelope"), + TotalTaxFee = couponDetailVoJToken.Value("totalTaxFee"), + TotalTuiHuanHuoWuYou = couponDetailVoJToken.Value("totalTuiHuanHuoWuYou"), + TotalVenderFee = couponDetailVoJToken.Value("totalVenderFee"), + TotalXianPinLeiDongQuan = couponDetailVoJToken.Value("totalXianPinLeiDongQuan"), + TotalXianPinLeiJingQuan = couponDetailVoJToken.Value("totalXianPinLeiJingQuan"), + TotalZhiFuYingXiaoYouHui = couponDetailVoJToken.Value("totalZhiFuYingXiaoYouHui") + }; + } } } diff --git a/BBWY.Server.Model/Dto/Response/Order/OrderCouponDetailResponse.cs b/BBWY.Server.Model/Dto/Response/Order/OrderCouponDetailResponse.cs new file mode 100644 index 00000000..708b38fc --- /dev/null +++ b/BBWY.Server.Model/Dto/Response/Order/OrderCouponDetailResponse.cs @@ -0,0 +1,206 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BBWY.Server.Model.Dto +{ + public class OrderCouponDetailGroupItemResponse + { + /// + /// 发起方 + /// + public string Initiator { get; set; } + + /// + /// 优惠券或活动类型 + /// + public string CouponOrPromotionType { get; set; } + + /// + /// 优惠金额 + /// + public decimal? PreferentialAmount { get; set; } + + /// + /// 商家承担金额 + /// + public decimal? UndertakenByMerchantAmount { get; set; } + + /// + /// 平台承担金额 + /// + public decimal? UndertakenByPlatformAmount { get; set; } + } + + public class OrderCouponDetailGroupResponse + { + /// + /// 发起方 + /// + public string Initiator { get; set; } + + /// + /// 优惠明细集合 + /// + public IList ItemList { get; set; } + } + + public class OrderCouponDetailResponse + { /// + /// 合计优惠金额 + /// + public decimal TotalPreferentialAmount { get; set; } + + /// + /// 合计商家承担金额 + /// + public decimal? TotalUndertakenByMerchantAmount { get; set; } + + /// + /// 合计平台承担金额 + /// + public decimal? TotalUndertakenByPlatformAmount { get; set; } + + public IList GroupList { get; set; } + + /// + /// 合计单品金额 + /// + public decimal? TotalItemPrice { get; set; } + + /// + /// 合计基础优惠 + /// + public decimal? TotalBaseDiscount { get; set; } + + /// + /// 合计满减 + /// + public decimal? TotalManJian { get; set; } + + /// + /// 合计商家运费 + /// + public decimal? TotalVenderFee { get; set; } + + /// + /// 合计基础运费 + /// + public decimal? TotalBaseFee { get; set; } + + /// + /// 合计偏远运费 + /// + public decimal? TotalRemoteFee { get; set; } + + /// + /// 合计优惠券 + /// + public decimal? TotalCoupon { get; set; } + + /// + /// 合计京豆 + /// + public decimal? TotalJingDou { get; set; } + + /// + /// 合计余额 + /// + public decimal? TotalBalance { get; set; } + + /// + /// 合计超级红包 + /// + public decimal? TotalSuperRedEnvelope { get; set; } + + /// + /// 合计plus会员95折优惠 + /// + public decimal? TotalPlus95 { get; set; } + + /// + /// 合计退换货无忧 + /// + public decimal? TotalTuiHuanHuoWuYou { get; set; } + + /// + /// 合计全球购税费 + /// + public decimal? TotalTaxFee { get; set; } + + /// + /// 合计落地配服务 + /// + public decimal? TotalLuoDiPeiService { get; set; } + + /// + /// 合计应付金额 + /// + public decimal? TotalShouldPay { get; set; } + + /// + /// 合计京券 + /// + public decimal? TotalJingQuan { get; set; } + + /// + /// 合计东券 + /// + public decimal? TotalDongQuan { get; set; } + + /// + /// 合计限品类京券 + /// + public decimal? TotalXianPinLeiJingQuan { get; set; } + + /// + /// 合计限品类东券 + /// + public decimal? TotalXianPinLeiDongQuan { get; set; } + + /// + /// 合计按比例平台承担优惠券 + /// + public decimal? TotalPingTaiChengDanYouHuiQuan { get; set; } + + /// + /// 合计礼金优惠 + /// + public decimal? TotalLiJinYouHui { get; set; } + + /// + /// 合计支付营销优惠 + /// + public decimal? TotalZhiFuYingXiaoYouHui { get; set; } + + /// + /// 合计京东支付优惠 + /// + public decimal? TotalJdZhiFuYouHui { get; set; } + + /// + /// 合计全球购一般税 + /// + public decimal? TotalGlobalGeneralTax { get; set; } + + /// + /// 合计全球购一般包税 + /// + public decimal? TotalGlobalGeneralIncludeTax { get; set; } + + /// + /// 合计京享礼金 + /// + public decimal? TotalJingXiangLiJin { get; set; } + + /// + /// 合计跨店满减促销 + /// + public decimal? TotalPromotionDiscount { get; set; } + + /// + /// 合计满期赠促销 + /// + public decimal? TotalExpiryGiftDiscount { get; set; } + } +}