diff --git a/CoreCms.Net.Configuration/GlobalEnumVars.cs b/CoreCms.Net.Configuration/GlobalEnumVars.cs index 425837a3..280aad97 100644 --- a/CoreCms.Net.Configuration/GlobalEnumVars.cs +++ b/CoreCms.Net.Configuration/GlobalEnumVars.cs @@ -1107,7 +1107,12 @@ namespace CoreCms.Net.Configuration /// 审核拒绝 /// [Description("审核拒绝")] - Refuse = 3 + Refuse = 3, + /// + /// 用户取消 + /// + [Description("用户取消")] + Cancel = 4 } /// diff --git a/CoreCms.Net.RedisMQ/Subscribe/TCOrderAfterSaleCreateSyncSubscribe.cs b/CoreCms.Net.RedisMQ/Subscribe/TCOrderAfterSaleCreateSyncSubscribe.cs index fd984cdc..4567b336 100644 --- a/CoreCms.Net.RedisMQ/Subscribe/TCOrderAfterSaleCreateSyncSubscribe.cs +++ b/CoreCms.Net.RedisMQ/Subscribe/TCOrderAfterSaleCreateSyncSubscribe.cs @@ -17,6 +17,7 @@ using CoreCms.Net.Configuration; using CoreCms.Net.IServices; using CoreCms.Net.Loging; using CoreCms.Net.Model.Entities; +using CoreCms.Net.WeChat.Service.Enums; using CoreCms.Net.WeChat.Service.HttpClients; using InitQ.Abstractions; using InitQ.Attributes; @@ -88,47 +89,54 @@ namespace CoreCms.Net.RedisMQ.Subscribe var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken(); var client = _weChatApiHttpClientFactory.CreateWxOpenClient(); - var request = new ShopAftersaleAddRequest(); + var request = new ShopECAftersaleAddRequest(); request.AccessToken = accessToken; request.OutOrderId = orderModel.orderId; request.OutAftersaleOrderId = orderModel.billAftersalesId; - request.PagePath = "pages/member/afterSales/detail/detail?aftersalesId=" + orderModel.billAftersalesId; - request.RefundFee = Convert.ToInt32(aftersale.refundAmount * 100); request.OpenId = tcOrderModel.openid; + //request.PagePath = "pages/member/afterSales/detail/detail?aftersalesId=" + orderModel.billAftersalesId; + request.RefundAmount = Convert.ToInt32(aftersale.refundAmount * 100); + if (aftersale.refundAmount > 0 && aftersale.type == (int)GlobalEnumVars.BillAftersalesIsReceive.Refund) { - request.Type = (int)GlobalEnumVars.ShopAftersaleAddType.退款; + request.Type = (int)AfterSalesEnum.AfterSaleType.仅退款; } else if (aftersale.refundAmount > 0 && aftersale.type == (int)GlobalEnumVars.BillAftersalesIsReceive.Reship) { - request.Type = (int)GlobalEnumVars.ShopAftersaleAddType.退款退货; + request.Type = (int)AfterSalesEnum.AfterSaleType.退货退款; } else if (Convert.ToInt32(aftersale.refundAmount) == 0 && aftersale.type == (int)GlobalEnumVars.BillAftersalesIsReceive.Reship) { - request.Type = (int)GlobalEnumVars.ShopAftersaleAddType.退款退货; + request.Type = (int)AfterSalesEnum.AfterSaleType.退货退款; } else if (Convert.ToInt32(aftersale.refundAmount) == 0 && aftersale.type == (int)GlobalEnumVars.BillAftersalesIsReceive.Refund) { - request.Type = (int)GlobalEnumVars.ShopAftersaleAddType.退款; + request.Type = (int)AfterSalesEnum.AfterSaleType.仅退款; } - request.Status = 0; - request.CreateTime = aftersale.createTime; - request.IsFinishAll = false; + request.RefundReasonType = (int)AfterSalesEnum.AfterSalesReasonType.不想要了; + request.RefundReason = aftersale.reason; - request.ProductList = new List(); - aftersaleItems.ForEach(p => + //新自定义交易组件,只能申请一个商品售后。 + request.Product = new ShopECAftersaleAddRequest.Types.Product() { - var product = new ShopAftersaleAddRequest.Types.Product(); - product.Count = p.nums; - product.OutProductId = p.goodsId.ToString(); - product.OutSKUId = p.productId.ToString(); - request.ProductList.Add(product); - }); + Count = aftersaleItems[0].nums, + OutProductId = aftersaleItems[0].goodsId.ToString(), + OutSKUId = aftersaleItems[0].productId.ToString() + }; - var response = await client.ExecuteShopAftersaleAddAsync(request); + //aftersaleItems.ForEach(p => + //{ + // var product = new ShopECAftersaleAddRequest.Types.Product(); + // product.Count = p.nums; + // product.OutProductId = p.goodsId.ToString(); + // product.OutSKUId = p.productId.ToString(); + // request.Product.Add(product); + //}); + + var response = await client.ExecuteShopECAftersaleAddAsync(request); NLogUtil.WriteAll(response.IsSuccessful() ? NLog.LogLevel.Info : NLog.LogLevel.Error, LogType.RedisMessageQueue, "自定义交易组件-同步创建售后单", JsonConvert.SerializeObject(response)); diff --git a/CoreCms.Net.WeChat.Service/Configuration/EventType.cs b/CoreCms.Net.WeChat.Service/Configuration/EventType.cs index 458c50d7..10750fee 100644 --- a/CoreCms.Net.WeChat.Service/Configuration/EventType.cs +++ b/CoreCms.Net.WeChat.Service/Configuration/EventType.cs @@ -75,6 +75,10 @@ namespace CoreCms.Net.WeChat.Service.Configuration /// 自定义交易组件用户确认收货 /// public const string OpenProductOrderConfirm = "open_product_order_confirm"; + /// + /// 用户取消售后申请 + /// + public const string AfterSaleUserCancel = "aftersale_user_cancel"; #endregion diff --git a/CoreCms.Net.WeChat.Service/Enums/AfterSalesEnum.cs b/CoreCms.Net.WeChat.Service/Enums/AfterSalesEnum.cs new file mode 100644 index 00000000..4ca24729 --- /dev/null +++ b/CoreCms.Net.WeChat.Service/Enums/AfterSalesEnum.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CoreCms.Net.WeChat.Service.Enums +{ + public class AfterSalesEnum + { + + /// + /// 售后类型 + /// + public enum AfterSaleType + { + 仅退款 = 1, + 退货退款 = 2, + } + + /// + /// 售后描述说明 + /// + public enum AfterSalesReasonType + { + 商品无货 = 1, + 发货时间问题 = 2, + 不想要了 = 3, + 地址信息填写错误 = 5, + 买多买错不想要了 = 6, + 商品损坏包装脏污 = 7, + 少错商品与页面描述不符 = 8, + 无效的物流单号 = 9, + 物流超72小时停滞 = 10, + 快递无法送到指定地点 = 11, + 显示签收但未收到商品 = 12, + 质量问题 = 14, + 其他 = 15 + + } + + + /// + /// 售后状态 + /// + public enum AfterSalesState + { + + 用户取消售后申请 = 1, + 商家处理退款申请中 = 2, + 商家拒绝退款 = 4, + 商家拒绝退货 = 5, + 待用户退货 = 6, + 售后单关闭 = 7, + 待商家收货 = 8, + 平台退款中 = 11, + 退款成功 = 13, + 平台处理退款申请中 = 21, + 废弃 = 22, + 商家处理退货申请中 = 23, + 平台处理退货申请中 = 24, + 平台退款失败 = 25 + } + } +} diff --git a/CoreCms.Net.WeChat.Service/Mediator/TransactionComponent/AftersaleUserCancelEventCommandHandler.cs b/CoreCms.Net.WeChat.Service/Mediator/TransactionComponent/AftersaleUserCancelEventCommandHandler.cs new file mode 100644 index 00000000..48c86823 --- /dev/null +++ b/CoreCms.Net.WeChat.Service/Mediator/TransactionComponent/AftersaleUserCancelEventCommandHandler.cs @@ -0,0 +1,74 @@ +/*********************************************************************** + * Project: CoreCms.Net * + * Web: https://CoreCms.Net * + * ProjectName: 核心内容管理系统 * + * Author: 大灰灰 * + * Email: JianWeie@163.com * + * CreateTime: 2020-08-13 23:57:23 + * Description: 暂无 + ***********************************************************************/ + + +using System; +using System.Threading; +using System.Threading.Tasks; +using CoreCms.Net.Configuration; +using CoreCms.Net.IServices; +using CoreCms.Net.Loging; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Utility.Helper; +using CoreCms.Net.WeChat.Service.HttpClients; +using CoreCms.Net.WeChat.Service.Models; +using MediatR; +using Newtonsoft.Json; +using SKIT.FlurlHttpClient.Wechat.Api; +using SKIT.FlurlHttpClient.Wechat.Api.Events; + +namespace CoreCms.Net.WeChat.Service.Mediator +{ + /// + /// 表示 TEXT 事件的数据 + /// + public class AftersaleUserCancelEventCommand : IRequest + { + public AftersaleUserCancelEvent EventObj { get; set; } + } + + /// + /// 用户取消售后申请 + /// + public class AftersaleUserCancelEventCommandHandler : IRequestHandler + { + private readonly ICoreCmsBillAftersalesServices _aftersalesServices; + + + + public AftersaleUserCancelEventCommandHandler(ICoreCmsBillAftersalesServices aftersalesServices) + { + _aftersalesServices = aftersalesServices; + } + + public async Task Handle(AftersaleUserCancelEventCommand request, CancellationToken cancellationToken) + { + var jm = new WeChatApiCallBack() { Status = true }; + if (request.EventObj != null) + { + try + { + await _aftersalesServices.UpdateAsync(p => new CoreCmsBillAftersales() + { + status = (int)GlobalEnumVars.BillAftersalesStatus.Cancel + }, + p => p.aftersalesId == request.EventObj.AftersaleOrder.OutAftersaleOrderId); + } + catch (Exception e) + { + NLogUtil.WriteFileLog(NLog.LogLevel.Info, LogType.WxPost, "接收服务器推送", "用户取消售后申请", e); + + } + } + return await Task.FromResult(jm); + } + } + +} diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/order/billaftersales/index.html b/CoreCms.Net.Web.Admin/wwwroot/views/order/billaftersales/index.html index 8d0d2d45..15179e1b 100644 --- a/CoreCms.Net.Web.Admin/wwwroot/views/order/billaftersales/index.html +++ b/CoreCms.Net.Web.Admin/wwwroot/views/order/billaftersales/index.html @@ -47,6 +47,7 @@ + diff --git a/CoreCms.Net.Web.WebApi/Controllers/WeChatOAuth/WxOpenController.cs b/CoreCms.Net.Web.WebApi/Controllers/WeChatOAuth/WxOpenController.cs index bf6a0af0..d7b15613 100644 --- a/CoreCms.Net.Web.WebApi/Controllers/WeChatOAuth/WxOpenController.cs +++ b/CoreCms.Net.Web.WebApi/Controllers/WeChatOAuth/WxOpenController.cs @@ -223,6 +223,11 @@ namespace CoreCms.Net.Web.WebApi.Controllers.WeChatOAuth var openProductOrderConfirmEvent = client.DeserializeEventFromXml(msgXml); callBack = await _mediator.Send(new OpenProductOrderConfirmEventCommand() { EventObj = openProductOrderConfirmEvent }); break; + //自定义交易组件-用户取消售后申请 + case EventType.AfterSaleUserCancel: + var aftersaleUserCancelEvent = client.DeserializeEventFromXml(msgXml); + callBack = await _mediator.Send(new AftersaleUserCancelEventCommand() { EventObj = aftersaleUserCancelEvent }); + break; default: NLogUtil.WriteFileLog(LogLevel.Info, LogType.WxPost, "接收服务器推送(处理xml内容/Event无匹配)", JsonConvert.SerializeObject(sourceXml));