feat 添加清空历史记录接口
This commit is contained in:
parent
1040898c3e
commit
ee4e6ce009
50
ARW.Model/Dto/Api/Pay/AddPayOrderDtoApi.cs
Normal file
50
ARW.Model/Dto/Api/Pay/AddPayOrderDtoApi.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using ARW.Model.Models.Business.Carts;
|
||||||
|
|
||||||
|
namespace ARW.Model.Dto.Api.Carts
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加下单订单信息Dto对象Api
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-09-24
|
||||||
|
/// </summary>
|
||||||
|
public class AddPayOrderDtoApi
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 客户Guid
|
||||||
|
/// </summary>
|
||||||
|
public long UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 支付类型
|
||||||
|
/// </summary>
|
||||||
|
public int PayType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 小程序用户OpenId
|
||||||
|
/// </summary>
|
||||||
|
public string OpenId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 核销前价格
|
||||||
|
/// </summary>
|
||||||
|
public decimal BeforeMoney { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 核销后价格/操作金额
|
||||||
|
/// </summary>
|
||||||
|
public decimal Money { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 留言
|
||||||
|
/// </summary>
|
||||||
|
public string Remark { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -15,32 +15,41 @@ namespace ARW.Model.Dto.Api.Carts
|
|||||||
public class CommitPayDtoApi
|
public class CommitPayDtoApi
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 客户guid
|
/// 客户Guid
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long CustomerGuid { get; set; }
|
public long UserId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 支付类型
|
/// 支付类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int type { get; set; }
|
public int PayType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 小程序用户OpenId
|
/// 小程序用户OpenId
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string openId { get; set; }
|
public string OpenId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 待结算的商品集合
|
/// 核销前价格
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string goodsRequestList { get; set; }
|
public decimal BeforeMoney { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 发票信息
|
/// 核销后价格/操作金额
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string invoiceRequest { get; set; }
|
public decimal Money { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 留言
|
||||||
|
/// </summary>
|
||||||
|
public string Remark { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 优惠券Id
|
||||||
|
/// </summary>
|
||||||
|
public int CouponId { get; set;}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,11 @@ using Senparc.CO2NET.HttpUtility;
|
|||||||
using ARW.Service.Api.IBusinessService.PayManage;
|
using ARW.Service.Api.IBusinessService.PayManage;
|
||||||
using ARW.Repository.Business.Payments;
|
using ARW.Repository.Business.Payments;
|
||||||
using ARW.Repository.Business.OrderManage.Orders;
|
using ARW.Repository.Business.OrderManage.Orders;
|
||||||
|
using ARW.Model.Models.Business.OrderManage.Orders;
|
||||||
|
using ARW.Model.Dto.Api.Carts;
|
||||||
|
using ARW.Repository.Business.Marketing.CouponManage.Coupons;
|
||||||
|
using Org.BouncyCastle.Crypto.Prng;
|
||||||
|
using Aliyun.Acs.Core.Logging;
|
||||||
|
|
||||||
namespace ARW.Service.Api.BusinessService.PaymentManage
|
namespace ARW.Service.Api.BusinessService.PaymentManage
|
||||||
{
|
{
|
||||||
@ -28,20 +33,24 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
|
|||||||
private readonly CustomerRepository _CustomerRepository;
|
private readonly CustomerRepository _CustomerRepository;
|
||||||
private readonly OrderRepository _OrderRepository;
|
private readonly OrderRepository _OrderRepository;
|
||||||
private readonly PaymentRepository _PaymentRepository;
|
private readonly PaymentRepository _PaymentRepository;
|
||||||
|
private readonly CouponRepository _CouponRepository;
|
||||||
private readonly SenparcHttpClient _httpClient;
|
private readonly SenparcHttpClient _httpClient;
|
||||||
|
|
||||||
|
|
||||||
public PayServiceApi(ShopRepository ShopRepository, GoodsCategoryRepository goodsCategoryRepository, CustomerRepository customerRepository)
|
public PayServiceApi(ShopRepository ShopRepository, GoodsCategoryRepository goodsCategoryRepository, CustomerRepository customerRepository, OrderRepository orderRepository, PaymentRepository paymentRepository, CouponRepository couponRepository)
|
||||||
{
|
{
|
||||||
this._ShopRepository = ShopRepository;
|
this._ShopRepository = ShopRepository;
|
||||||
_GoodsCategoryRepository = goodsCategoryRepository;
|
_GoodsCategoryRepository = goodsCategoryRepository;
|
||||||
_CustomerRepository = customerRepository;
|
_CustomerRepository = customerRepository;
|
||||||
|
_OrderRepository = orderRepository;
|
||||||
|
_PaymentRepository = paymentRepository;
|
||||||
|
_CouponRepository = couponRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Api接口代码
|
#region Api接口代码
|
||||||
|
|
||||||
|
|
||||||
public async Task<PayParams> HandelPrePay(PayDto parm)
|
public async Task<PayParams> HandelPrePay(CommitPayDtoApi parm)
|
||||||
{
|
{
|
||||||
// 获取金额
|
// 获取金额
|
||||||
var price = 1;//单位:分
|
var price = 1;//单位:分
|
||||||
@ -61,7 +70,9 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
|
|||||||
#region 业务处理
|
#region 业务处理
|
||||||
|
|
||||||
/* 添加订单流水 */
|
/* 添加订单流水 */
|
||||||
var paymentGuid = await AddPayment(parm.UserId, orderNo, parm.PayType, parm.BeforeMoney, parm.Money);
|
var paymentGuid = await AddPayment(parm, orderNo);
|
||||||
|
/* 添加业务订单 */
|
||||||
|
var orderGuid = await AddOrder(parm, orderNo, paymentGuid);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -83,26 +94,24 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
|
|||||||
|
|
||||||
|
|
||||||
#region 业务方法调用
|
#region 业务方法调用
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加订单流水
|
/// 添加订单流水
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userId">客户id</param>
|
/// <param name="parm">下单信息Dto对象</param>
|
||||||
/// <param name="orderNo">订单号</param>
|
/// <param name="orderNo">订单号</param>
|
||||||
/// <param name="payType">支付类型</param>
|
|
||||||
/// <param name="beforeMoney">核销前价格</param>
|
|
||||||
/// <param name="payType">核销后价格/操作金额</param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="CustomException"></exception>
|
/// <exception cref="CustomException"></exception>
|
||||||
public async Task<long> AddPayment(long userId, string orderNo, int payType, decimal beforeMoney, decimal money)
|
public async Task<long> AddPayment(CommitPayDtoApi parm, string orderNo)
|
||||||
{
|
{
|
||||||
// 添加订单流水
|
// 添加订单流水
|
||||||
Payment payment = new Payment
|
Payment payment = new()
|
||||||
{
|
{
|
||||||
CustomerGuid = userId,
|
CustomerGuid = parm.UserId,
|
||||||
PaymentNumber = orderNo,
|
PaymentNumber = orderNo,
|
||||||
PaymentBuytype = payType,
|
PaymentBuytype = parm.PayType,
|
||||||
PaymentBeforeMoney = beforeMoney,
|
PaymentBeforeMoney = parm.BeforeMoney,
|
||||||
PaymentMoney = money,
|
PaymentMoney = parm.Money,
|
||||||
PaymentStatus = 1
|
PaymentStatus = 1
|
||||||
};
|
};
|
||||||
var response = await _PaymentRepository.InsertReturnSnowflakeIdAsync(payment);
|
var response = await _PaymentRepository.InsertReturnSnowflakeIdAsync(payment);
|
||||||
@ -113,21 +122,58 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 添加业务订单
|
/// <summary>
|
||||||
public async Task<long> AddOrder(long userId, string orderNo, int payType, decimal beforeMoney, decimal money)
|
/// 添加业务订单
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm">下单信息Dto对象</param>
|
||||||
|
/// <param name="orderNo">订单号</param>
|
||||||
|
/// <param name="paymentGuid">支付订单流水guid</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="CustomException"></exception>
|
||||||
|
public async Task<long> AddOrder(CommitPayDtoApi parm, string orderNo, long paymentGuid)
|
||||||
{
|
{
|
||||||
Payment payment = new Payment
|
Order order = new()
|
||||||
{
|
{
|
||||||
CustomerGuid = userId,
|
PaymentGuid = paymentGuid,
|
||||||
PaymentNumber = orderNo,
|
CustomerGuid = parm.UserId,
|
||||||
PaymentBuytype = payType,
|
OrderNumber = orderNo,
|
||||||
PaymentBeforeMoney = beforeMoney,
|
GoodsTotalAmoun = parm.BeforeMoney,
|
||||||
PaymentMoney = money,
|
OrderAmount = parm.Money,
|
||||||
PaymentStatus = 1
|
PayPrice = parm.Money,
|
||||||
|
OrderRemark = parm.Remark,
|
||||||
|
PayType = parm.PayType,
|
||||||
|
PayStatus = 1,
|
||||||
};
|
};
|
||||||
var response = await _PaymentRepository.InsertReturnSnowflakeIdAsync(payment);
|
|
||||||
|
// 优惠券减免价格
|
||||||
|
if (parm.CouponId != 0)
|
||||||
|
{
|
||||||
|
var coupon = await _CouponRepository.GetFirstAsync(s => s.CouponId == parm.CouponId);
|
||||||
|
if (coupon != null)
|
||||||
|
{
|
||||||
|
order.CouponGuid = coupon.CouponGuid;
|
||||||
|
order.CouponMoney = coupon.CouponDeductionMoney;
|
||||||
|
|
||||||
|
order.PayPrice = order.OrderAmount - coupon.CouponDeductionMoney;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new CustomException($"优惠券Id为 {parm.CouponId} 找不到");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 运费计算
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO:余额支付
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var response = await _OrderRepository.InsertReturnSnowflakeIdAsync(order);
|
||||||
if (response == 0)
|
if (response == 0)
|
||||||
throw new CustomException("订单流水数据加入失败");
|
throw new CustomException("业务订单数据加入失败");
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using ARW.Model.Dto.Api.Carts;
|
||||||
using ARW.Model.Models.Business.Payments;
|
using ARW.Model.Models.Business.Payments;
|
||||||
using static Infrastructure.WeChat.TenPay.Pay;
|
using static Infrastructure.WeChat.TenPay.Pay;
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ namespace ARW.Service.Api.IBusinessService.PayManage
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm"></param>
|
/// <param name="parm"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<PayParams> HandelPrePay(PayDto parm);
|
Task<PayParams> HandelPrePay(CommitPayDtoApi parm);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ using Geocoding;
|
|||||||
using ARW.Model.Dto.Business.Custom.HistorySearchs;
|
using ARW.Model.Dto.Business.Custom.HistorySearchs;
|
||||||
using ARW.Service.Business.IBusinessService.Custom.HistorySearchs;
|
using ARW.Service.Business.IBusinessService.Custom.HistorySearchs;
|
||||||
using ARW.Admin.WebApi.Framework;
|
using ARW.Admin.WebApi.Framework;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace ARW.WebApi.Controllers.Api.Custom.HistorySearchs
|
namespace ARW.WebApi.Controllers.Api.Custom.HistorySearchs
|
||||||
{
|
{
|
||||||
@ -104,5 +105,18 @@ namespace ARW.WebApi.Controllers.Api.Custom.HistorySearchs
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清空历史搜索
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpDelete("deleteAll")]
|
||||||
|
[Log(Title = "历史搜索清空", BusinessType = BusinessType.DELETE)]
|
||||||
|
public IActionResult DeleteAll()
|
||||||
|
{
|
||||||
|
var user = JwtUtil.GetLoginUser(App.HttpContext);
|
||||||
|
var response = _HistorySearchServiceApi.DeleteAsync(s => s.CustomerGuid == user.UserId);
|
||||||
|
return SUCCESS("清空成功!");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ using Senparc.Weixin.WxOpen.AdvancedAPIs.WxApp;
|
|||||||
using ARW.Service.Business.IBusinessService.Custom.Customers;
|
using ARW.Service.Business.IBusinessService.Custom.Customers;
|
||||||
using ARW.Service.Api.IBusinessService.PayManage;
|
using ARW.Service.Api.IBusinessService.PayManage;
|
||||||
using ARW.Service.Api.BusinessService.PaymentManage;
|
using ARW.Service.Api.BusinessService.PaymentManage;
|
||||||
|
using ARW.Model.Dto.Api.Carts;
|
||||||
|
|
||||||
namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
|
namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
|
||||||
{
|
{
|
||||||
@ -44,7 +45,7 @@ namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
|
|||||||
/// <param name="parm"></param>
|
/// <param name="parm"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("wxPay")]
|
[HttpPost("wxPay")]
|
||||||
public async Task<IActionResult> WxPay([FromBody] PayDto parm)
|
public async Task<IActionResult> WxPay([FromBody] CommitPayDtoApi parm)
|
||||||
{
|
{
|
||||||
if (parm == null) { throw new CustomException("请求参数错误"); }
|
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||||
|
|
||||||
@ -67,13 +68,12 @@ namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.Info("进入微信支付回调!", "2134234234");
|
logger.Info("进入微信支付回调!");
|
||||||
Pay pay = new Pay(_httpClient);
|
Pay pay = new Pay(_httpClient);
|
||||||
var res = await pay.PayNotifyUrl();
|
var res = await pay.PayNotifyUrl();
|
||||||
|
|
||||||
if (res.trade_state == "SUCCESS")
|
if (res.trade_state == "SUCCESS")
|
||||||
{
|
{
|
||||||
logger.Info("微信支付回调之业务:", res.trade_state);
|
|
||||||
// 业务
|
// 业务
|
||||||
var respones = _PayServiceApi.UpdateAsync(f => new Payment
|
var respones = _PayServiceApi.UpdateAsync(f => new Payment
|
||||||
{
|
{
|
||||||
@ -86,11 +86,10 @@ namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return SUCCESS("66666");
|
return SUCCESS("");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
logger.Error("微信支付回调错误信息:", e);
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"conn_db": "server=47.242.159.172;Database=shop_template;Uid=shop_template;Pwd=tKFJjWwL2kxMYtJK;SslMode=none;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=true;",
|
"conn_db": "server=47.242.159.172;Database=shop_template;Uid=shop_template;Pwd=tKFJjWwL2kxMYtJK;SslMode=none;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=true;",
|
||||||
//"conn_db": "server=127.0.0.1;Database=shop;Uid=root;Pwd=root;SslMode=none;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=true;",
|
//"conn_db": "server=127.0.0.1;Database=shop;Uid=root;Pwd=root;SslMode=none;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=true;",
|
||||||
"conn_db_type": "0" //数据库类型 MySql = 0, SqlServer = 1
|
"conn_db_type": "8" //数据库类型 MySql = 0, SqlServer = 1
|
||||||
},
|
},
|
||||||
"urls": "http://localhost:8888", //项目启动url,如果改动端口前端对应devServer也需要进行修改
|
"urls": "http://localhost:8888", //项目启动url,如果改动端口前端对应devServer也需要进行修改
|
||||||
"corsUrls": "http://localhost:8887", //跨域地址(前端启动项目,前后端分离单独部署需要设置),多个用","隔开
|
"corsUrls": "http://localhost:8887", //跨域地址(前端启动项目,前后端分离单独部署需要设置),多个用","隔开
|
||||||
|
@ -401,6 +401,11 @@ namespace Infrastructure.WeChat.TenPay
|
|||||||
/// 核销后价格/操作金额
|
/// 核销后价格/操作金额
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal Money { get; set; }
|
public decimal Money { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 留言
|
||||||
|
/// </summary>
|
||||||
|
public string Remark { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user