mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 16:13:26 +08:00
升级自定义交易组件常用商品接口,spu接口,品牌接口,订单接口,物流接口。
This commit is contained in:
@@ -67,6 +67,15 @@ namespace CoreCms.Net.WeChat.Service.Configuration
|
||||
/// 品牌审核结果
|
||||
/// </summary>
|
||||
public const string OpenProductBrandAudit = "open_product_brand_audit";
|
||||
/// <summary>
|
||||
/// 自定义交易组件支付回调
|
||||
/// </summary>
|
||||
public const string OpenProductOrderPay = "open_product_order_pay";
|
||||
/// <summary>
|
||||
/// 自定义交易组件用户确认收货
|
||||
/// </summary>
|
||||
public const string OpenProductOrderConfirm = "open_product_order_confirm";
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CoreCms.Net.IServices\CoreCms.Net.IServices.csproj" />
|
||||
<ProjectReference Include="..\CoreCms.Net.Loging\CoreCms.Net.Loging.csproj" />
|
||||
<ProjectReference Include="..\CoreCms.Net.Utility\CoreCms.Net.Utility.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/***********************************************************************
|
||||
* 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
|
||||
{
|
||||
/// <summary>
|
||||
/// 表示 TEXT 事件的数据
|
||||
/// </summary>
|
||||
public class OpenProductOrderConfirmEventCommand : IRequest<WeChatApiCallBack>
|
||||
{
|
||||
public OpenProductOrderConfirmEvent EventObj { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户确认收货事件回调。
|
||||
/// </summary>
|
||||
public class OpenProductOrderConfirmEventCommandHandler : IRequestHandler<OpenProductOrderConfirmEventCommand, WeChatApiCallBack>
|
||||
{
|
||||
private readonly ICoreCmsOrderServices _orderServices;
|
||||
|
||||
|
||||
|
||||
public OpenProductOrderConfirmEventCommandHandler(ICoreCmsOrderServices orderServices)
|
||||
{
|
||||
_orderServices = orderServices;
|
||||
}
|
||||
|
||||
public async Task<WeChatApiCallBack> Handle(OpenProductOrderConfirmEventCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var jm = new WeChatApiCallBack() { Status = true };
|
||||
if (request.EventObj != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
await _orderServices.CompleteOrder(request.EventObj.Order.OutOrderId, 0, "微信消息推送事件", "wxpost");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
NLogUtil.WriteFileLog(NLog.LogLevel.Info, LogType.WxPost, "接收服务器推送", "用户确认收货事件回调异常", e);
|
||||
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(jm);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/***********************************************************************
|
||||
* 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
|
||||
{
|
||||
/// <summary>
|
||||
/// 表示 TEXT 事件的数据
|
||||
/// </summary>
|
||||
public class OpenProductOrderPayEventCommand : IRequest<WeChatApiCallBack>
|
||||
{
|
||||
public OpenProductOrderPayEvent EventObj { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 订单支付回调
|
||||
/// </summary>
|
||||
public class OpenProductOrderPayEventCommandHandler : IRequestHandler<OpenProductOrderPayEventCommand, WeChatApiCallBack>
|
||||
{
|
||||
private readonly ICoreCmsOrderServices _orderServices;
|
||||
private readonly ICoreCmsBillPaymentsServices _billPaymentsServices;
|
||||
private readonly IWeChatTransactionComponentOrderServices _transactionComponentOrderServices;
|
||||
|
||||
|
||||
|
||||
public OpenProductOrderPayEventCommandHandler(ICoreCmsOrderServices orderServices, ICoreCmsBillPaymentsServices billPaymentsServices, IWeChatTransactionComponentOrderServices transactionComponentOrderServices)
|
||||
{
|
||||
_orderServices = orderServices;
|
||||
_billPaymentsServices = billPaymentsServices;
|
||||
_transactionComponentOrderServices = transactionComponentOrderServices;
|
||||
}
|
||||
|
||||
public async Task<WeChatApiCallBack> Handle(OpenProductOrderPayEventCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var jm = new WeChatApiCallBack() { Status = true };
|
||||
if (request.EventObj != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var tcOrder = await _transactionComponentOrderServices.QueryByClauseAsync(p => p.orderId == request.EventObj.Order.OrderId && p.outOrderId == request.EventObj.Order.OutOrderId);
|
||||
var order = await _orderServices.QueryByClauseAsync(p => p.orderId == tcOrder.outOrderId);
|
||||
|
||||
await _billPaymentsServices.ToUpdate(tcOrder.paymentId,
|
||||
(int)GlobalEnumVars.BillPaymentsStatus.Payed,
|
||||
GlobalEnumVars.PaymentsTypes.wechatpay.ToString(), order.orderAmount, JsonConvert.SerializeObject(request),
|
||||
request.EventObj.Order.TransactionId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
NLogUtil.WriteFileLog(NLog.LogLevel.Info, LogType.WxPost, "接收服务器推送", "订单支付回调异常", e);
|
||||
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(jm);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/7/9 1:59:13
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CoreCms.Net.WeChat.Service.TransactionComponent.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单详情
|
||||
/// </summary>
|
||||
public class OrderInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public string create_time { get; set; }
|
||||
/// <summary>
|
||||
/// 非必填,默认为0。0:普通场景, 1:合单支付
|
||||
/// </summary>
|
||||
public int type { get; set; }
|
||||
/// <summary>
|
||||
/// 商家自定义订单ID
|
||||
/// </summary>
|
||||
public string out_order_id { get; set; }
|
||||
/// <summary>
|
||||
/// 用户的openid
|
||||
/// </summary>
|
||||
public string openid { get; set; }
|
||||
/// <summary>
|
||||
/// 商家小程序该订单的页面path,用于微信侧订单中心跳转
|
||||
/// </summary>
|
||||
public string path { get; set; }
|
||||
/// <summary>
|
||||
/// 商家小程序该订单的用户id
|
||||
/// </summary>
|
||||
public string out_user_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单详情
|
||||
/// </summary>
|
||||
public OrderDetail order_detail { get; set; } = new OrderDetail();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public DeliveryDetail delivery_detail { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public AddressInfo address_info { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 货品明细
|
||||
/// </summary>
|
||||
public class ProductInfoItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 商家自定义商品ID
|
||||
/// </summary>
|
||||
public string out_product_id { get; set; }
|
||||
/// <summary>
|
||||
/// 商家自定义商品skuID,可填空字符串(如果这个product_id下没有sku)
|
||||
/// </summary>
|
||||
public string out_sku_id { get; set; }
|
||||
/// <summary>
|
||||
/// 购买的数量
|
||||
/// </summary>
|
||||
public int product_cnt { get; set; }
|
||||
/// <summary>
|
||||
/// 生成订单时商品的售卖价(单位:分),可以跟上传商品接口的价格不一致
|
||||
/// </summary>
|
||||
public int sale_price { get; set; }
|
||||
/// <summary>
|
||||
/// 绑定的小程序商品路径
|
||||
/// </summary>
|
||||
public string path { get; set; }
|
||||
/// <summary>
|
||||
/// 生成订单时商品的标题
|
||||
/// </summary>
|
||||
public string title { get; set; }
|
||||
/// <summary>
|
||||
/// 生成订单时商品的头图
|
||||
/// </summary>
|
||||
public string head_img { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 支付情况
|
||||
/// </summary>
|
||||
public class PayInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 微信支付
|
||||
/// </summary>
|
||||
public string pay_method { get; set; }
|
||||
/// <summary>
|
||||
/// 预支付ID
|
||||
/// </summary>
|
||||
public string prepay_id { get; set; }
|
||||
/// <summary>
|
||||
/// 预付款时间(拿到prepay_id的时间)
|
||||
/// </summary>
|
||||
public string prepay_time { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 价格体系
|
||||
/// </summary>
|
||||
public class PriceInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 该订单最终的金额(单位:分)
|
||||
/// </summary>
|
||||
public int order_price { get; set; }
|
||||
/// <summary>
|
||||
/// 运费(单位:分)
|
||||
/// </summary>
|
||||
public int freight { get; set; }
|
||||
/// <summary>
|
||||
/// 优惠金额(单位:分)
|
||||
/// </summary>
|
||||
public int discounted_price { get; set; }
|
||||
/// <summary>
|
||||
/// 附加金额(单位:分)
|
||||
/// </summary>
|
||||
public int additional_price { get; set; }
|
||||
/// <summary>
|
||||
/// 附加金额备注
|
||||
/// </summary>
|
||||
public string additional_remarks { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 订单详情
|
||||
/// </summary>
|
||||
public class OrderDetail
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品列表
|
||||
/// </summary>
|
||||
public List<ProductInfoItem> product_infos { get; set; }
|
||||
/// <summary>
|
||||
/// 支付情况
|
||||
/// </summary>
|
||||
public PayInfo pay_info { get; set; }
|
||||
/// <summary>
|
||||
/// 价格体系
|
||||
/// </summary>
|
||||
public PriceInfo price_info { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发货情况
|
||||
/// </summary>
|
||||
public class DeliveryDetail
|
||||
{
|
||||
/// <summary>
|
||||
/// 1: 正常快递, 2: 无需快递, 3: 线下配送, 4: 用户自提
|
||||
/// </summary>
|
||||
public int delivery_type { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 地址情况
|
||||
/// </summary>
|
||||
public class AddressInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 收货人姓名
|
||||
/// </summary>
|
||||
public string receiver_name { get; set; }
|
||||
/// <summary>
|
||||
/// 详细收货地址信息
|
||||
/// </summary>
|
||||
public string detailed_address { get; set; }
|
||||
/// <summary>
|
||||
/// 收货人手机号码
|
||||
/// </summary>
|
||||
public string tel_number { get; set; }
|
||||
/// <summary>
|
||||
/// 国家,选填
|
||||
/// </summary>
|
||||
public string country { get; set; }
|
||||
/// <summary>
|
||||
/// 省份,选填
|
||||
/// </summary>
|
||||
public string province { get; set; }
|
||||
/// <summary>
|
||||
/// 城市,选填
|
||||
/// </summary>
|
||||
public string city { get; set; }
|
||||
/// <summary>
|
||||
/// 乡镇,选填
|
||||
/// </summary>
|
||||
public string town { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user