From 71c956500ae05255428e4e5b2787df8e07d11647 Mon Sep 17 00:00:00 2001
From: zhengyuxuan <zhengyuxuan1995>
Date: 星期一, 31 三月 2025 14:38:28 +0800
Subject: [PATCH] fix:导出结果优化
---
LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 528 ++++++++++++++++++++++++++++++++++------------------------
1 files changed, 310 insertions(+), 218 deletions(-)
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index d9596c9..41fde74 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -27,6 +27,8 @@
using Volo.Abp.ObjectMapping;
using NPOI.SS.Formula.Functions;
using StackExchange.Redis;
+using static Volo.Abp.Identity.Settings.IdentitySettingNames;
+using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace LifePayment.Application;
@@ -44,12 +46,14 @@
private readonly IRepository<LifePayChannles, Guid> _lifePayChannlesRep;
private readonly IRepository<LifePayAccount, Guid> _lifePayAccount;
private readonly IRepository<OperateHistory, Guid> _operateHistory;
+ private readonly IRepository<LifePayChannlesRake, Guid> _lifePayChannlesRakeRepository;
private readonly IDataFilter dataFilter;
private readonly IChannelFilter _channelFilter;
private readonly IAliPayApi _aliPayApi;
private readonly IAlipayInterfaceManager _alipayInterfaceManager;
private readonly IWxPayApi _wxPayApi;
private readonly WxPayOption _wxPayOptions;
+ private readonly InitSetting _initSettingOptions;
private readonly IACOOLYManager _aCOOLYManager;
@@ -61,11 +65,13 @@
IRepository<LifePayUser, Guid> lifePayUserRepository,
IRepository<LifePayPremium, Guid> lifePayPremiumRepository,
IRepository<LifePayIntroInfo, Guid> lifePayIntroInfoRepository,
+ IRepository<LifePayChannlesRake, Guid> lifePayChannlesRakeRepository,
IRepository<OperateHistory, Guid> operateHistory,
IAliPayApi aliPayApi,
IAlipayInterfaceManager aliPayInterfaceManager,
IWxPayApi wxPayApi,
IOptions<WxPayOption> wxPayOptions,
+ IOptions<InitSetting> initSettingOptions,
IRepository<LifePayChannles, Guid> lifePayChannlesRep,
IRepository<LifePayAccount, Guid> lifePayAccount,
IDataFilter dataFilter,
@@ -76,12 +82,14 @@
_lifePayRateRepository = lifePayRateRepository;
_lifePayOrderRepository = lifePayOrderRepository;
_lifePayUserRepository = lifePayUserRepository;
+ _lifePayChannlesRakeRepository = lifePayChannlesRakeRepository;
_lifePayPremiumRepository = lifePayPremiumRepository;
_lifePayIntroInfoRepository = lifePayIntroInfoRepository;
_aliPayApi = aliPayApi;
_alipayInterfaceManager = aliPayInterfaceManager;
_wxPayApi = wxPayApi;
_wxPayOptions = wxPayOptions.Value;
+ _initSettingOptions = initSettingOptions.Value;
_distributedEventBus = distributedEventBus;
_lifePayChannlesRep = lifePayChannlesRep;
_lifePayAccount = lifePayAccount;
@@ -157,7 +165,7 @@
/// <returns></returns>
public async Task<ChannelRateOutput> GetChannelRate(ChannelsBaseInput input)
{
- return _lifePayChannlesRep.Where(x => x.IsDeleted == false && x.ChannlesNum == input.CheckChannelId).Select(x => new ChannelRateOutput() { ChannlesRate = x.ChannlesRate })
+ return _lifePayChannlesRep.Where(x => x.IsDeleted == false && x.ChannlesNum == input.CheckChannelId).Select(x => new ChannelRateOutput() { ChannlesRate = x.ChannlesRate })
.FirstOrDefault();
}
@@ -193,6 +201,8 @@
.WhereIf(!string.IsNullOrEmpty(input.QueryCondition), x => x.PhoneNumber.Contains(input.QueryCondition) || x.Name.Contains(input.QueryCondition))
.WhereIf(input.CreationTimeBegin.HasValue, x => x.CreationTime >= input.CreationTimeBegin)
.WhereIf(input.CreationTimeEnd.HasValue, x => x.CreationTime <= input.CreationTimeEnd)
+ .WhereIf(input.LoginTimeBegin.HasValue, x => x.LastLoginTime >= input.LoginTimeBegin)
+ .WhereIf(input.LoginTimeEnd.HasValue, x => x.LastLoginTime <= input.LoginTimeEnd)
.Select(x =>
new UserListOutput()
{
@@ -262,19 +272,19 @@
from b in temp.DefaultIfEmpty()
select new LifePayOrderListOutput
{
- DiscountAmount = a.DiscountAmount,
+ DiscountAmount = a.DiscountAmount ?? 0,
FinishTime = a.FinishTime,
Id = a.Id,
- LifePayOrderStatus = a.LifePayOrderStatus,
+ LifePayOrderStatus = a.LifePayOrderStatus?? 0,
LifePayOrderType = a.LifePayOrderType,
LifePayType = a.LifePayType,
OrderNo = a.OrderNo,
- PayAmount = a.PayAmount,
+ PayAmount = a.PayAmount ?? 0,
PhoneNumber = a.PhoneNumber,
- RechargeAmount = a.RechargeAmount,
+ RechargeAmount = a.RechargeAmount??0,
UserId = a.UserId,
OutOrderNo = a.OutOrderNo,
- PayStatus = a.PayStatus,
+ PayStatus = a.PayStatus?? 0,
PayTime = a.PayTime,
ACOOLYOrderNo = a.ACOOLYOrderNo,
RefundCredentialsImgUrl = a.RefundCredentialsImgUrl.GetOssPath(),
@@ -318,19 +328,19 @@
from b in temp.DefaultIfEmpty()
select new LifePayOrderListOutput
{
- DiscountAmount = a.DiscountAmount,
+ DiscountAmount = a.DiscountAmount ?? 0,
FinishTime = a.FinishTime,
Id = a.Id,
- LifePayOrderStatus = a.LifePayOrderStatus,
+ LifePayOrderStatus = a.LifePayOrderStatus ?? 0,
LifePayOrderType = a.LifePayOrderType,
LifePayType = a.LifePayType,
OrderNo = a.OrderNo,
- PayAmount = a.PayAmount,
+ PayAmount = a.PayAmount ?? 0,
PhoneNumber = a.PhoneNumber,
- RechargeAmount = a.RechargeAmount,
+ RechargeAmount = a.RechargeAmount ?? 0,
UserId = a.UserId,
OutOrderNo = a.OutOrderNo,
- PayStatus = a.PayStatus,
+ PayStatus = a.PayStatus ?? 0,
PayTime = a.PayTime,
ACOOLYOrderNo = a.ACOOLYOrderNo,
RefundCredentialsImgUrl = a.RefundCredentialsImgUrl.GetOssPath(),
@@ -389,7 +399,7 @@
s.PayAmountStr = s.PayAmount.ToString("F2");
s.LifePayTypeStr = s.LifePayType.GetDescription();
s.FinishTimeStr = !s.FinishTime.HasValue ? string.Empty : s.FinishTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm);
- s.RefundApplyTimeStr = !s.RefundApplyTime.HasValue? string.Empty:s.RefundApplyTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm);
+ s.RefundApplyTimeStr = !s.RefundApplyTime.HasValue ? string.Empty : s.RefundApplyTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm);
});
return result;
}
@@ -399,28 +409,27 @@
{
var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync();
var channle = await _lifePayChannlesRep.FirstOrDefaultAsync(r => r.ChannlesNum == order.ChannelId);
- CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
+ CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
var user = await _lifePayUserRepository.FirstOrDefaultAsync(x => x.Id == order.UserId);
- var channlesRakePrice = (order.PayAmount - (order.PlatformDeductionAmount == null ? 0 : order.PlatformDeductionAmount)) * channle.ChannlesRakeRate / 100;
- var orderpirce = await GetOrderPrice(order.RechargeAmount, order.PayAmount,order.PlatformRate, order.ChannleRate, order.ChannlesRakeRate,order.PremiumRate);
-
+ CheckExtensions.IfTrueThrowUserFriendlyException(user == null, "鐢ㄦ埛涓嶅瓨鍦�");
+ var orderpirce = await GetOrderPrice(order.RechargeAmount ?? 0, order.PayAmount ?? 0, order.PlatformRate ?? 0, order.ChannleRate ?? 0, order.ChannlesRakeRate ?? 0, order.PremiumRate ?? 0);
var result = new LifePayOrderOutput()
- {
+ {
UserName = user.Name,
UserPhoneNumber = user.PhoneNumber,
- DiscountAmount = order.DiscountAmount,
+ DiscountAmount = order.DiscountAmount ?? 0,
FinishTime = order.FinishTime,
Id = order.Id,
OutOrderNo = order.OutOrderNo,
LifePayChannle = channle.ChannlesName,
- Status = order.LifePayOrderStatus,
+ Status = order.LifePayOrderStatus ?? 0,
LifePayOrderType = order.LifePayOrderType,
LifePayType = order.LifePayType,
OrderNo = order.OrderNo,
- PayAmount = order.PayAmount,
- RechargeAmount = order.RechargeAmount,
- PayStatus = order.PayStatus,
+ PayAmount = order.PayAmount ?? 0,
+ RechargeAmount = order.RechargeAmount ?? 0,
+ PayStatus = order.PayStatus ?? 0,
PayTime = order.PayTime,
OrderParamDetailJsonStr = order.OrderParamDetailJsonStr,
RefundCredentialsImgUrl = order.RefundCredentialsImgUrl.GetOssPath(),
@@ -441,7 +450,8 @@
ChannlesRakePrice = orderpirce.ChannlesRakePrice,
PremiumRate = order.PremiumRate,
PremiumPrice = orderpirce.PremiumPrice,
- Profit = orderpirce.Profit
+ Profit = orderpirce.Profit,
+ RefundOrderNo = order.RefundOrderNo,
};
return result;
@@ -461,18 +471,18 @@
{
UserName = user.Name,
UserPhoneNumber = user.PhoneNumber,
- DiscountAmount = order.DiscountAmount,
+ DiscountAmount = order.DiscountAmount ?? 0,
FinishTime = order.FinishTime,
Id = order.Id,
OutOrderNo = order.OutOrderNo,
LifePayChannle = channle.ChannlesName,
- Status = order.LifePayOrderStatus,
+ Status = order.LifePayOrderStatus ?? 0,
LifePayOrderType = order.LifePayOrderType,
LifePayType = order.LifePayType,
OrderNo = order.OrderNo,
- PayAmount = order.PayAmount,
- RechargeAmount = order.RechargeAmount,
- PayStatus = order.PayStatus,
+ PayAmount = order.PayAmount ?? 0,
+ RechargeAmount = order.RechargeAmount ?? 0,
+ PayStatus = order.PayStatus ?? 0,
PayTime = order.PayTime,
RefundCredentialsImgUrl = order.RefundCredentialsImgUrl.GetOssPath(),
CreationTime = order.CreationTime,
@@ -517,16 +527,16 @@
.Select(x =>
new UserLifePayOrderOutput
{
- DiscountAmount = x.DiscountAmount,
+ DiscountAmount = x.DiscountAmount ?? 0,
FinishTime = x.FinishTime,
Id = x.Id,
- LifePayOrderStatus = x.LifePayOrderStatus,
+ LifePayOrderStatus = x.LifePayOrderStatus ?? 0,
LifePayOrderType = x.LifePayOrderType,
LifePayType = x.LifePayType,
OrderNo = x.OrderNo,
- PayAmount = x.PayAmount,
- RechargeAmount = x.RechargeAmount,
- PayStatus = x.PayStatus,
+ PayAmount = x.PayAmount ?? 0,
+ RechargeAmount = x.RechargeAmount ?? 0,
+ PayStatus = x.PayStatus ?? 0,
PayTime = x.PayTime,
OrderParamDetailJsonStr = x.OrderParamDetailJsonStr,
RefundCredentialsImgUrl = x.RefundCredentialsImgUrl.GetOssPath(),
@@ -548,16 +558,16 @@
.Select(x =>
new UserLifePayOrderOutput
{
- DiscountAmount = x.DiscountAmount,
+ DiscountAmount = x.DiscountAmount ?? 0,
FinishTime = x.FinishTime,
Id = x.Id,
- LifePayOrderStatus = x.LifePayOrderStatus,
+ LifePayOrderStatus = x.LifePayOrderStatus?? 0 ,
LifePayOrderType = x.LifePayOrderType,
LifePayType = x.LifePayType,
OrderNo = x.OrderNo,
- PayAmount = x.PayAmount,
- RechargeAmount = x.RechargeAmount,
- PayStatus = x.PayStatus,
+ PayAmount = x.PayAmount ?? 0,
+ RechargeAmount = x.RechargeAmount ?? 0,
+ PayStatus = x.PayStatus ?? 0,
PayTime = x.PayTime,
OrderParamDetailJsonStr = x.OrderParamDetailJsonStr,
RefundCredentialsImgUrl = x.RefundCredentialsImgUrl.GetOssPath(),
@@ -583,7 +593,7 @@
public async Task<LifePayStatusEnum> GetPayStatusByOrderNo(string orderNo)
{
return await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo)
- .Select(x => x.PayStatus)
+ .Select(x => x.PayStatus ?? 0)
.FirstOrDefaultAsync();
}
@@ -639,7 +649,7 @@
OrderNo = x.OrderNo,
RefundCheckRemark = x.RefundCheckRemark,
RefundApplyRemark = x.RefundApplyRemark,
- LifePayOrderStatus = x.LifePayOrderStatus,
+ LifePayOrderStatus = x.LifePayOrderStatus ?? 0,
}).FirstOrDefaultAsync();
CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "鏈壘鍒拌鍗曚俊鎭�");
@@ -728,7 +738,7 @@
{
DiscountAmount = x.DiscountAmount,
FinishTime = x.FinishTime,
- //LifePayOrderStatus = x.LifePayOrderStatus,
+ LifePayOrderStatus = x.LifePayOrderStatus,
LifePayOrderType = x.LifePayOrderType,
LifePayType = x.LifePayType,
OrderNo = x.OrderNo,
@@ -761,7 +771,7 @@
s.ActualRechargeAmountStr = s.ActualRechargeAmount.ToString("F2");
s.LifePayRefundStatusStr = s.LifePayRefundStatus == LifePayRefundStatusEnum.鏃犻渶閫�娆� ? "" : s.LifePayRefundStatus.GetDescription();
s.ACOOLYStatusStr = s.ACOOLYStatus.GetDescription();
- //s.LifePayOrderStatusStr = s.LifePayOrderStatus.GetDescription();
+ s.LifePayOrderStatusStr = s.LifePayOrderStatus.GetDescription();
s.FinishTimeStr = !s.FinishTime.HasValue ? string.Empty : s.FinishTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmmss);
});
return result;
@@ -814,6 +824,59 @@
return "";
}
}
+
+ /// <summary>
+ /// 鏌ヨ鏀粯瀹濇敮浠樿鍗曚俊鎭�
+ /// </summary>
+ /// <param name="input"></param>
+ /// <returns></returns>
+ public async Task<AlipayTradeQueryResponse> QueryAlipayTrade(OrderInQuiryInput input)
+ {
+ var result = await _aliPayApi.OrderInQuiry(input);
+
+ return result;
+ }
+
+ /// <summary>
+ /// 鏌ヨ鏀粯瀹濋��娆捐鍗曚俊鎭�
+ /// </summary>
+ /// <param name="input"></param>
+ /// <returns></returns>
+ public async Task<AlipayTradeFastpayRefundQueryResponse> QueryAlipayTradeRefund(OrderInQuiryInput input)
+ {
+ var result = await _aliPayApi.QueryAlipayTradeRefund(input);
+ var order = await _lifePayOrderRepository.Where(x => x.OrderNo == input.OutTradeNo).FirstOrDefaultAsync();
+ if (result.Code == AlipayResultCode.Success && result.RefundStatus == AlipayRefundStatus.Success)
+ {
+ order.LifePayOrderStatus = LifePayOrderStatusEnum.宸查��娆�;
+ order.LifePayRefundStatus = LifePayRefundStatusEnum.宸查��娆�;
+ }
+
+ return result;
+ }
+
+ /// <summary>
+ /// 鏌ヨ寰俊閫�娆捐鍗曚俊鎭�
+ /// </summary>
+ /// <param name="outTradeNo"></param>
+ /// <returns></returns>
+ public async Task<WxPayDomesticRefundsQueryReponse> WxPayDomesticRefundsQuery(string outTradeNo)
+ {
+ return await _wxPayApi.WxPayDomesticRefundsQuery(outTradeNo);
+ }
+
+ /// <summary>
+ /// 鏌ヨ寰俊璁㈠崟淇℃伅
+ /// </summary>
+ /// <param name="outTradeNo"></param>
+ /// <returns></returns>
+ public async Task<WxPayTradeQueryReponse> WxPayTradeQuery(string outTradeNo)
+ {
+ return await _wxPayApi.WxPayTradeQuery(outTradeNo);
+ }
+
+
+
#endregion
#region 鎿嶄綔
@@ -834,6 +897,11 @@
var channle = await GetLifePayChannlesDtoByNum(input.ChannelId);
CheckExtensions.IfTrueThrowUserFriendlyException(channle == null, "娓犻亾涓嶅瓨鍦�");
+ var repeatOrder = await _lifePayOrderRepository.Where(x => x.LifePayOrderType == LifePayOrderTypeEnum.PhoneOrder && x.PayStatus == LifePayStatusEnum.宸叉敮浠�
+ && x.LifePayOrderStatus == LifePayOrderStatusEnum.鍏呭�间腑
+ && x.OrderParamDetailJsonStr.Contains(input.ProductData.Phone)).ToListAsync();
+ CheckExtensions.IfTrueThrowUserFriendlyException(repeatOrder.Count() > 0, "鎮ㄦ湁鍚屾埛鍙疯鍗曟鍦ㄥ厖鍊间腑锛岃鍕块噸澶嶅厖鍊�");
+
//var rate = await GetRate();
//CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "鏈厤缃姌鎵�");
@@ -842,13 +910,13 @@
var amount = CalculateAmount(input.ProductData.ParValue, rate);
var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环);
-
+
var orderInput = new CreateLifePayOrderInput
{
OrderNo = channle.ChannlesNum + CreateOrderNo(),
LifePayOrderStatus = LifePayOrderStatusEnum.鍏呭�间腑,
- LifePayOrderType = LifePayOrderTypeEnum.璇濊垂璁㈠崟,
+ LifePayOrderType = LifePayOrderTypeEnum.PhoneOrder,
//LifePayType = input.LifePayType,
OrderParamDetailJsonStr = JsonConvert.SerializeObject(input.ProductData),
UserId = user.Id,
@@ -859,7 +927,7 @@
RechargeAmount = amount.RechargeAmount,
ChannelId = channle.ChannlesNum,
PlatformRate = platformRate.Rate,
- PlatformDeductionAmount = amount.RechargeAmount * platformRate.Rate /100,
+ PlatformDeductionAmount = amount.RechargeAmount * platformRate.Rate / 100,
ChannleRate = rate,
ChannlesRakeRate = channle.ChannlesRakeRate,
//ChannlesRakePrice = amount.RechargeAmount * (channle.ChannlesRate - platformRate.Rate) / 100 * channle.ChannlesRakeRate / 100
@@ -890,19 +958,21 @@
//var rate = await GetRate();
//CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "鏈厤缃姌鎵�");
+ var repeatOrder = await _lifePayOrderRepository.Where(x => x.LifePayOrderType == LifePayOrderTypeEnum.ElectricOrder && x.PayStatus == LifePayStatusEnum.宸叉敮浠�
+ && x.LifePayOrderStatus == LifePayOrderStatusEnum.鍏呭�间腑 && x.OrderParamDetailJsonStr.Contains(input.ProductData.ElectricType)
+ && x.OrderParamDetailJsonStr.Contains(input.ProductData.ElectricAccount)).ToListAsync();
+ CheckExtensions.IfTrueThrowUserFriendlyException(repeatOrder.Count() > 0, "鎮ㄦ湁鍚屾埛鍙疯鍗曟鍦ㄥ厖鍊间腑锛岃鍕块噸澶嶅厖鍊�");
var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.榛樿鐢佃垂鎶樻墸);
-
var amount = CalculateAmount(input.ProductData.ParValue, rate);
-
var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环);
var orderInput = new CreateLifePayOrderInput
{
OrderNo = channle.ChannlesNum + CreateOrderNo(),
LifePayOrderStatus = LifePayOrderStatusEnum.鍏呭�间腑,
- LifePayOrderType = LifePayOrderTypeEnum.鐢佃垂璁㈠崟,
+ LifePayOrderType = LifePayOrderTypeEnum.ElectricOrder,
// LifePayType = input.LifePayType,
OrderParamDetailJsonStr = JsonConvert.SerializeObject(input.ProductData),
UserId = user.Id,
@@ -942,6 +1012,10 @@
//var rate = await GetRate();
//CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "鏈厤缃姌鎵�");
+ var repeatOrder = await _lifePayOrderRepository.Where(x => x.LifePayOrderType == LifePayOrderTypeEnum.GasOrder && x.PayStatus == LifePayStatusEnum.宸叉敮浠�
+ && x.LifePayOrderStatus == LifePayOrderStatusEnum.鍏呭�间腑 && x.OrderParamDetailJsonStr.Contains(input.ProductData.GasOrgType)
+ && x.OrderParamDetailJsonStr.Contains(input.ProductData.GasAccount)).ToListAsync();
+ CheckExtensions.IfTrueThrowUserFriendlyException(repeatOrder.Count() > 0, "鎮ㄦ湁鍚屾埛鍙疯鍗曟鍦ㄥ厖鍊间腑锛岃鍕块噸澶嶅厖鍊�");
var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.榛樿鐕冩皵鎶樻墸);
@@ -954,7 +1028,7 @@
{
OrderNo = channle.ChannlesNum + CreateOrderNo(),
LifePayOrderStatus = LifePayOrderStatusEnum.鍏呭�间腑,
- LifePayOrderType = LifePayOrderTypeEnum.鐕冩皵璁㈠崟,
+ LifePayOrderType = LifePayOrderTypeEnum.GasOrder,
// LifePayType = input.LifePayType,
OrderParamDetailJsonStr = JsonConvert.SerializeObject(input.ProductData),
UserId = user.Id,
@@ -985,38 +1059,15 @@
/// <returns></returns>
public async Task<string> SetLifePayOrderPayType(SetLifePayOrderPayTypeInput input, string ip)
{
- var order = await _lifePayOrderRepository.Where(x => x.OrderNo == input.OrderNo).FirstOrDefaultAsync();
- CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
- CheckExtensions.IfTrueThrowUserFriendlyException(order.LifePayType.HasValue, "褰撳墠璁㈠崟宸查�夋嫨鏀粯绫诲瀷");
-
- order.LifePayType = input.LifePayType;
- var premium = await _lifePayPremiumRepository.Where(x => x.IsDeleted == false && x.PremiumType == order.LifePayType).FirstOrDefaultAsync();
- order.PremiumRate = premium == null ? 0 : premium.Rate;
- await _lifePayOrderRepository.UpdateAsync(order);
-
- var desc = "鐢熸椿缂磋垂-";
- switch (order.LifePayOrderType)
- {
- case LifePayOrderTypeEnum.璇濊垂璁㈠崟:
- desc += "璇濊垂";
- break;
- case LifePayOrderTypeEnum.鐢佃垂璁㈠崟:
- desc += "鐢佃垂";
- break;
- case LifePayOrderTypeEnum.鐕冩皵璁㈠崟:
- desc += "鐕冩皵";
- break;
- default:
- break;
- }
+ var res = await SetPayType(input.OrderNo, input.LifePayType, ip);
#if DEBUG
//var payUrl = await GetPayQRCode(order.LifePayType.Value, order.OrderNo, desc, 0.01m, ip, input.H5Type);
- var payUrl = await GetPayQRCode(order.LifePayType.Value, order.OrderNo, desc, order.PayAmount, ip, input.H5Type);
+ var payUrl = await GetPayQRCode(res.LifePayType, res.OrderNo, res.Desc, res.PayAmount, ip, input.H5Type);
#else
- //var payUrl = await GetPayQRCode(order.LifePayType.Value, order.OrderNo, desc, 0.01m, ip, input.H5Type);
- var payUrl = await GetPayQRCode(order.LifePayType.Value, order.OrderNo, desc, order.PayAmount, ip, input.H5Type);
+ //var payUrl = await GetPayQRCode(res.LifePayType, res.OrderNo, res.Desc, 0.01m, ip, input.H5Type);
+ var payUrl = await GetPayQRCode(res.LifePayType, res.OrderNo, res.Desc, res.PayAmount, ip, input.H5Type);
#endif
return payUrl;
@@ -1029,43 +1080,28 @@
/// <returns></returns>
public async Task<ModelPaymentMiniPay> GetPayOrderForJsAPI(GetPayOrderForJsAPIInput input, string ip)
{
- var order = await _lifePayOrderRepository.Where(x => x.OrderNo == input.OrderNo).FirstOrDefaultAsync();
+ var res = await SetPayType(input.OrderNo, input.LifePayType, ip);
+ var result = await PayTransactionsJsAPI(input.OpenId, input.PayAppId, input.Attach, res.PayAmount, input.OrderNo, res.Desc);
+ return result;
+ }
+
+ /// <summary>
+ /// 淇敼瀹為檯鍒拌处閲戦
+ /// </summary>
+ /// <param name="input"></param>
+ /// <returns></returns>
+ public async Task<int> UpdateLifePayOrderActualReceivedAmount(UpdateLifePayOrderInput input)
+ {
+ var order = await _lifePayOrderRepository.Where(x => x.Id == input.Id).FirstOrDefaultAsync();
+
CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
+ CheckExtensions.IfTrueThrowUserFriendlyException(order.ACOOLYStatus != ACOOLYStatusEnum.閮ㄥ垎鍏呭�兼垚鍔�, "璇ヨ鍗曟棤娉曚慨鏀瑰埌璐﹂噾棰�");
- CheckExtensions.IfTrueThrowUserFriendlyException(order.LifePayType.HasValue, "褰撳墠璁㈠崟宸查�夋嫨鏀粯绫诲瀷");
+ order.ActualReceivedAmount = input.ActualReceivedAmount;
- order.LifePayType = input.LifePayType;
- var premium = await _lifePayPremiumRepository.Where(x => x.IsDeleted == false && x.PremiumType == order.LifePayType).FirstOrDefaultAsync();
- order.PremiumRate = premium == null ? 0 : premium.Rate;
await _lifePayOrderRepository.UpdateAsync(order);
- var desc = "鐢熸椿缂磋垂-";
- switch (order.LifePayOrderType)
- {
- case LifePayOrderTypeEnum.璇濊垂璁㈠崟:
- desc += "璇濊垂";
- break;
- case LifePayOrderTypeEnum.鐢佃垂璁㈠崟:
- desc += "鐢佃垂";
- break;
- case LifePayOrderTypeEnum.鐕冩皵璁㈠崟:
- desc += "鐕冩皵";
- break;
- default:
- break;
- }
-
-
- //var result = await PayTransactionsJsAPI(input.OpenId, input.Attach, 0.01m, input.OrderNo, desc);
- //return result;
-
- // var result = await PayTransactionsJsAPI(input.OpenId, input.Attach, order.PayAmount, input.OrderNo, desc);
-
- var result = await PayTransactionsJsAPI(input.OpenId, input.PayAppId, input.Attach, order.PayAmount, input.OrderNo, desc);
- return result;
- //var payUrl = await GetPayQRCode(order.LifePayType.Value, order.OrderNo, desc, 0.01m, ip, input.H5Type);
- //var payUrl = await GetPayQRCode(order.LifePayType.Value, order.OrderNo, desc, order.PayAmount, ip, input.H5Type);
-
+ return Constant.SUCCESS;
}
/// <summary>
@@ -1075,8 +1111,6 @@
/// <returns></returns>
public async Task CreateLifePayOrder(CreateLifePayOrderInput input)
{
- CheckExtensions.IfTrueThrowUserFriendlyException(input.RechargeAmount < 0.01m || input.PayAmount < 0.01m || input.DiscountAmount < 0, "璁㈠崟閲戦閿欒");
-
var entity = ObjectMapper.Map<CreateLifePayOrderInput, LifePayOrder>(input);
await _lifePayOrderRepository.InsertAsync(entity);
}
@@ -1104,7 +1138,7 @@
#endif
CheckExtensions.IfTrueThrowUserFriendlyException(!result.Success || (result.Code != ACOOLYConstant.Code.SUCCESS && result.Code != ACOOLYConstant.Code.PROCESSING),
- "璋冪敤ACOOLY鎺ュ彛ConfirmElectricOrder杩斿洖閿欒:" + JsonConvert.SerializeObject(result));
+ result.Message);
return (result.Code, requestInput.RequestNo, result.PhoneChargeOrder.BusiOrderNo);
}
@@ -1135,7 +1169,7 @@
#endif
CheckExtensions.IfTrueThrowUserFriendlyException(!result.Success || (result.Code != ACOOLYConstant.Code.SUCCESS && result.Code != ACOOLYConstant.Code.PROCESSING),
- "璋冪敤ACOOLY鎺ュ彛ConfirmElectricOrder杩斿洖閿欒:" + JsonConvert.SerializeObject(result));
+ result.Message);
return (result.Code, requestInput.RequestNo, result.ElectricChargeOrder.BusiOrderNo);
}
@@ -1163,7 +1197,7 @@
#endif
CheckExtensions.IfTrueThrowUserFriendlyException(!result.Success || (result.Code != ACOOLYConstant.Code.SUCCESS && result.Code != ACOOLYConstant.Code.PROCESSING),
- "璋冪敤ACOOLY鎺ュ彛ConfirmElectricOrder杩斿洖閿欒:" + JsonConvert.SerializeObject(result));
+ result.Message);
return (result.Code, requestInput.RequestNo, result.GasChargeOrder.BusiOrderNo);
}
@@ -1257,13 +1291,13 @@
var result = (Code: "Fail", RequestNo: "", ACOOLYOrderNo: "");
switch (order.LifePayOrderType)
{
- case LifePayOrderTypeEnum.璇濊垂璁㈠崟:
+ case LifePayOrderTypeEnum.PhoneOrder:
result = await CreateACOOLYPhoneOrder(JsonConvert.DeserializeObject<LifePhoneData>(order.OrderParamDetailJsonStr), order.OrderNo);
break;
- case LifePayOrderTypeEnum.鐢佃垂璁㈠崟:
+ case LifePayOrderTypeEnum.ElectricOrder:
result = await CreateACOOLYElectricOrder(JsonConvert.DeserializeObject<LifeElectricData>(order.OrderParamDetailJsonStr), order.OrderNo);
break;
- case LifePayOrderTypeEnum.鐕冩皵璁㈠崟:
+ case LifePayOrderTypeEnum.GasOrder:
result = await CreateACOOLYGasOrder(JsonConvert.DeserializeObject<LifeGasData>(order.OrderParamDetailJsonStr), order.OrderNo);
break;
default:
@@ -1274,13 +1308,14 @@
order.LifePayOrderStatus = LifePayOrderStatusEnum.鍏呭�间腑;
//SetOrderStatus(order, result.Code);
order.OutRequestNo = result.RequestNo.IsNullOrEmpty() ? null : result.RequestNo;
- order.ACOOLYOrderNo = result.ACOOLYOrderNo.IsNullOrEmpty() ? null : result.ACOOLYOrderNo;
+ order.ACOOLYOrderNo = result.ACOOLYOrderNo;
}
catch (Exception ex)
{
_logger.LogError(ex, "澶勭悊鐢熸椿缂磋垂鏀粯鎴愬姛鍥炶皟鏃跺紓甯�");
order.LifePayOrderStatus = LifePayOrderStatusEnum.寰呴��娆�;
order.LifePayRefundStatus = LifePayRefundStatusEnum.寰呴��娆�;
+ order.RefundApplyRemark = ex.Message;
}
_logger.LogError("鐢熸椿缂磋垂璁㈠崟鐘舵�侊細" + order.LifePayOrderStatus.ToString());
await _lifePayOrderRepository.UpdateAsync(order);
@@ -1300,7 +1335,7 @@
case LifePayRefundStatusEnum.閫�娆句腑:
order.LifePayOrderStatus = LifePayOrderStatusEnum.閫�娆句腑;
break;
- default:break;
+ default: break;
}
}
@@ -1310,7 +1345,7 @@
/// <param name="orderNo"></param>
/// <param name="outOrderNo"></param>
/// <returns></returns>
- public async Task ACOOLYOrderNotifyHandler(string orderNo, string acoolyOrderNo, LifePayOrderStatusEnum status, ACOOLYStatusEnum acoolyStatus, decimal payAmount,string refundApplyRemark)
+ public async Task ACOOLYOrderNotifyHandler(string orderNo, string acoolyOrderNo, LifePayOrderStatusEnum status, ACOOLYStatusEnum acoolyStatus, decimal payAmount, string refundApplyRemark)
{
var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync();
CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
@@ -1340,6 +1375,27 @@
order.ACOOLYStatus = acoolyStatus;
order.FinishTime = DateTime.Now;
await _lifePayOrderRepository.UpdateAsync(order);
+
+ if (order.LifePayOrderStatus == LifePayOrderStatusEnum.宸插畬鎴�)
+ {
+ /// 姣涘埄
+ var grossProfit = order.RechargeAmount * (order.ChannleRate - order.PlatformRate) / 100;
+ /// 娓犻亾浣i噾 锛�(鍏呭�奸潰棰� * 娓犻亾鎶樻墸姣斾緥)-(鍏呭�奸潰棰� * 骞冲彴鎶樻墸姣斾緥)锛�* 浣i噾姣斾緥
+ var channlesRakePrice = grossProfit * (order.ChannlesRakeRate) / 100;
+ if (channlesRakePrice.HasValue)
+ {
+ LifePayChannlesRake lifePayChannlesRake = new LifePayChannlesRake()
+ {
+ OrderNo = order.OrderNo,
+ PayAmount = order.PayAmount.Value,
+ ChannlesRakeRate = order.ChannlesRakeRate.Value,
+ ChannlesRakePrice = channlesRakePrice.Value,
+ FinishTime = order.FinishTime.Value,
+ ChannelId = order.ChannelId,
+ };
+ await _lifePayChannlesRakeRepository.InsertAsync(lifePayChannlesRake);
+ }
+ }
}
/// <summary>
@@ -1365,7 +1421,7 @@
if (input.LifePayRefundType == LifePayRefundTypeEnum.鍏ㄩ閫�娆�)
{
- input.RefundPrice = order.PayAmount;
+ input.RefundPrice = order.PayAmount ?? 0;
}
if (order.LifePayOrderStatus != LifePayOrderStatusEnum.寰呴��娆� || order.PayStatus != LifePayStatusEnum.宸叉敮浠� || order.LifePayRefundStatus != LifePayRefundStatusEnum.寰呴��娆�)
@@ -1378,7 +1434,7 @@
switch (order.LifePayType)
{
case LifePayTypeEnum.WxPay:
- var wxRefundResult = await WxPayDomesticRefunds(order.OrderNo, outRefundNo,order.RefundApplyRemark, Convert.ToInt32(input.RefundPrice * 100), Convert.ToInt32(order.PayAmount * 100));
+ var wxRefundResult = await WxPayDomesticRefunds(order.OrderNo, outRefundNo, order.RefundApplyRemark, Convert.ToInt32(input.RefundPrice * 100), Convert.ToInt32(order.PayAmount * 100));
if (wxRefundResult.Status == "SUCCESS")
{
order.LifePayOrderStatus = LifePayOrderStatusEnum.宸查��娆�;
@@ -1389,11 +1445,6 @@
order.LifePayOrderStatus = LifePayOrderStatusEnum.閫�娆句腑;
order.LifePayRefundStatus = LifePayRefundStatusEnum.閫�娆句腑;
}
- else if (wxRefundResult.Message == "璁㈠崟宸插叏棰濋��娆�")
- {
- order.LifePayOrderStatus = LifePayOrderStatusEnum.宸查��娆�;
- order.LifePayRefundStatus = LifePayRefundStatusEnum.宸查��娆�;
- }
else
{
order.LifePayOrderStatus = LifePayOrderStatusEnum.寰呴��娆�;
@@ -1402,7 +1453,7 @@
break;
case LifePayTypeEnum.AliPay:
- var aliRefundResult = await AliTradeRefund(new AlipayTradeRefundRequest() { OutTradeNo = order.OrderNo, RefundAmount = input.RefundPrice.ToString() });
+ var aliRefundResult = await AliTradeRefund(new AlipayTradeRefundRequest() { OutTradeNo = order.OrderNo, OutRefundNo = outRefundNo, RefundAmount = input.RefundPrice.ToString() });
if (aliRefundResult.Code != AlipayResultCode.Success)
{
throw new UserFriendlyException("閫�娆惧け璐�:" + aliRefundResult.SubMsg);
@@ -1480,7 +1531,7 @@
/// <param name="total"></param>
/// <param name="currency"></param>
/// <returns></returns>
- public async Task<WxPayDomesticRefundsReponse> WxPayDomesticRefunds(string outTradeNo,string outRefundNo, string reason, int refund, int total, string currency = "CNY")
+ public async Task<WxPayDomesticRefundsReponse> WxPayDomesticRefunds(string outTradeNo, string outRefundNo, string reason, int refund, int total, string currency = "CNY")
{
WxPayDomesticRefundsRequest req = new WxPayDomesticRefundsRequest
{
@@ -1515,7 +1566,7 @@
var userAccount = await _lifePayAccount.Where(x => x.UserId == input.UserId && x.Id == input.Id)
.FirstOrDefaultAsync();
CheckExtensions.IfTrueThrowUserFriendlyException(userAccount == null, "鎴峰彿涓嶅瓨鍦�");
- var repeatAccountContent = await _lifePayAccount.Where(x => x.UserId == input.UserId && x.LifePayType == input.LifePayType && x.Content == input.Content && x.Id != input.Id)
+ var repeatAccountContent = await _lifePayAccount.Where(x => x.UserId == input.UserId && x.LifePayType == input.LifePayType && x.Content == input.Content && x.Id != input.Id && x.IsDeleted == false)
.FirstOrDefaultAsync();
CheckExtensions.IfTrueThrowUserFriendlyException(repeatAccountContent != null, "鎴峰彿宸插瓨鍦�");
@@ -1529,7 +1580,7 @@
}
else
{
- var repeatAccountContent = await _lifePayAccount.Where(x => x.UserId == input.UserId && x.LifePayType == input.LifePayType && x.Content == input.Content)
+ var repeatAccountContent = await _lifePayAccount.Where(x => x.UserId == input.UserId && x.LifePayType == input.LifePayType && x.Content == input.Content && x.IsDeleted == false)
.FirstOrDefaultAsync();
CheckExtensions.IfTrueThrowUserFriendlyException(repeatAccountContent != null, "鎴峰彿宸插瓨鍦�");
var userAccount = new LifePayAccount
@@ -1547,7 +1598,7 @@
await _lifePayAccount.InsertAsync(userAccount);
}
- if (input.LifePayType == LifePayOrderTypeEnum.璇濊垂璁㈠崟)
+ if (input.LifePayType == LifePayOrderTypeEnum.PhoneOrder)
{
var extraProperties = JsonConvert.DeserializeObject<Model_UserAccountExtraProperties>(input.ExtraProperties);
if (!string.IsNullOrEmpty(extraProperties.Name) && extraProperties.Phone == user.PhoneNumber)
@@ -1634,7 +1685,7 @@
dto.Status = input.Status;
#region 璁板綍鏃ュ織
- await PublishLifePayOrderHistoryEvent("娓犻亾绠$悊", "缂栬緫", input.Id.Value, TableType.LifePayChannles);
+ await LifePayOrderHistory("娓犻亾绠$悊", "缂栬緫", input.Id.Value, TableType.LifePayChannles);
#endregion
}
@@ -1647,7 +1698,7 @@
#region 璁板綍鏃ュ織
- await PublishLifePayOrderHistoryEvent("娓犻亾绠$悊", "鏂板", input.Id.Value, TableType.LifePayChannles);
+ await LifePayOrderHistory("娓犻亾绠$悊", "鏂板", input.Id.Value, TableType.LifePayChannles);
#endregion
}
@@ -1664,8 +1715,7 @@
#region 璁板綍鏃ュ織
- await PublishLifePayOrderHistoryEvent("娓犻亾绠$悊", status.GetDescription(), id, TableType.LifePayChannles);
-
+ await LifePayOrderHistory("娓犻亾绠$悊", status.GetDescription(), id, TableType.LifePayChannles);
#endregion
}
@@ -1778,15 +1828,21 @@
private (decimal PayAmont, decimal DiscountAmount, decimal RechargeAmount) CalculateAmount(decimal amount, decimal rate)
{
- /// 姝e父鏀粯
- //var payAmount = decimal.Round(amount * rate / 100, 2, MidpointRounding.AwayFromZero);
+ if (_initSettingOptions.OpenTheOnePennyTest)
+ {
+ /// 1鍒嗛挶鏀粯
+ decimal payAmount = 0.01m;
- /// 1鍒嗛挶鏀粯
- decimal payAmount = 0.01m;
+ CheckExtensions.IfTrueThrowUserFriendlyException(payAmount < 0.01m, "鏀粯閲戦閿欒");
- CheckExtensions.IfTrueThrowUserFriendlyException(payAmount < 0.01m, "鏀粯閲戦閿欒");
-
- return (payAmount, amount - payAmount, amount);
+ return (payAmount, amount - payAmount, amount);
+ }
+ else
+ {
+ /// 姝e父鏀粯
+ var payAmount = decimal.Round(amount * rate / 100, 2, MidpointRounding.AwayFromZero);
+ return (payAmount, amount - payAmount, amount);
+ }
}
private void SetOrderStatus(LifePayOrder order, string code)
@@ -1984,7 +2040,6 @@
return message;
}
-
private async Task<IQueryable<LifePayOrderListOutput>> GetLifePayOrderListFilter(QueryLifePayOrderListInput input)
{
var channles = await _lifePayChannlesRep.Where(x => x.ChannlesName.Contains(input.KeyWords)).Select(x => x.ChannlesNum).ToListAsync();
@@ -2001,39 +2056,39 @@
.WhereIf(input.LifePayOrderType.HasValue, x => x.LifePayOrderType == input.LifePayOrderType.Value)
.WhereIf(input.UserId.HasValue, x => x.UserId == input.UserId.Value)
.WhereIf(input.KeyWords.IsNotNullOrEmpty(), x => x.OrderNo.Contains(input.KeyWords) || x.OutOrderNo.Contains(input.KeyWords) || x.ACOOLYOrderNo.Contains(input.KeyWords) || channles.Contains(x.ChannelId))
- join b in _lifePayChannlesRep on a.ChannelId equals b.ChannlesNum into temp
- from b in temp.DefaultIfEmpty()
- select new LifePayOrderListOutput
- {
- DiscountAmount = a.DiscountAmount,
- FinishTime = a.FinishTime,
- Id = a.Id,
- LifePayOrderStatus = a.LifePayOrderStatus,
- LifePayOrderType = a.LifePayOrderType,
- LifePayType = a.LifePayType,
- OrderNo = a.OrderNo,
- PayAmount = a.PayAmount,
- PhoneNumber = a.PhoneNumber,
- RechargeAmount = a.RechargeAmount,
- UserId = a.UserId,
- OutOrderNo = a.OutOrderNo,
- PayStatus = a.PayStatus,
- PayTime = a.PayTime,
- ACOOLYOrderNo = a.ACOOLYOrderNo,
- RefundCredentialsImgUrl = a.RefundCredentialsImgUrl.GetOssPath(),
- RefundPrice = a.RefundPrice,
- CreationTime = a.CreationTime,
- RefundCheckRemark = a.RefundCheckRemark,
- RefundApplyRemark = a.RefundApplyRemark,
- RefundTime = a.RefundTime,
- ChannelName = b.ChannlesName,
- ActualRechargeAmount = a.ActualRechargeAmount,
- PlatformDeductionAmount = a.PlatformDeductionAmount,
- ACOOLYStatus = a.ACOOLYStatus,
- LifePayRefundStatus = a.LifePayRefundStatus,
- });
+ join b in _lifePayChannlesRep on a.ChannelId equals b.ChannlesNum into temp
+ from b in temp.DefaultIfEmpty()
+ select new LifePayOrderListOutput
+ {
+ DiscountAmount = a.DiscountAmount ?? 0,
+ FinishTime = a.FinishTime,
+ Id = a.Id,
+ LifePayOrderStatus = a.LifePayOrderStatus ?? 0,
+ LifePayOrderType = a.LifePayOrderType,
+ LifePayType = a.LifePayType,
+ OrderNo = a.OrderNo,
+ PayAmount = a.PayAmount ?? 0,
+ PhoneNumber = a.PhoneNumber,
+ RechargeAmount = a.RechargeAmount ?? 0,
+ UserId = a.UserId,
+ OutOrderNo = a.OutOrderNo,
+ PayStatus = a.PayStatus ?? 0,
+ PayTime = a.PayTime,
+ ACOOLYOrderNo = a.ACOOLYOrderNo,
+ RefundCredentialsImgUrl = a.RefundCredentialsImgUrl.GetOssPath(),
+ RefundPrice = a.RefundPrice,
+ CreationTime = a.CreationTime,
+ RefundCheckRemark = a.RefundCheckRemark,
+ RefundApplyRemark = a.RefundApplyRemark,
+ RefundTime = a.RefundTime,
+ ChannelName = b.ChannlesName,
+ ActualRechargeAmount = a.ActualRechargeAmount,
+ PlatformDeductionAmount = a.PlatformDeductionAmount,
+ ACOOLYStatus = a.ACOOLYStatus,
+ LifePayRefundStatus = a.LifePayRefundStatus,
+ });
-
+
return result;
}
@@ -2052,40 +2107,40 @@
.WhereIf(input.LifePayOrderType.HasValue, x => x.LifePayOrderType == input.LifePayOrderType.Value)
.WhereIf(input.UserId.HasValue, x => x.UserId == input.UserId.Value)
.WhereIf(input.KeyWords.IsNotNullOrEmpty(), x => x.PhoneNumber.Contains(input.KeyWords) || x.OrderNo.Contains(input.KeyWords) || x.OutOrderNo.Contains(input.KeyWords) || x.ACOOLYOrderNo.Contains(input.KeyWords))
- join b in _lifePayChannlesRep on a.ChannelId equals b.ChannlesNum into temp
- from b in temp.DefaultIfEmpty()
- select new LifePayOrderListOutput
- {
- DiscountAmount = a.DiscountAmount,
- FinishTime = a.FinishTime,
- Id = a.Id,
- LifePayOrderStatus = a.LifePayOrderStatus,
- LifePayOrderType = a.LifePayOrderType,
- LifePayType = a.LifePayType,
- OrderNo = a.OrderNo,
- PayAmount = a.PayAmount,
- PhoneNumber = a.PhoneNumber,
- RechargeAmount = a.RechargeAmount,
- UserId = a.UserId,
- OutOrderNo = a.OutOrderNo,
- PayStatus = a.PayStatus,
- PayTime = a.PayTime,
- ACOOLYOrderNo = a.ACOOLYOrderNo,
- RefundCredentialsImgUrl = a.RefundCredentialsImgUrl.GetOssPath(),
- CreationTime = a.CreationTime,
- RefundCheckRemark = a.RefundCheckRemark,
- RefundApplyRemark = a.RefundApplyRemark,
- RefundApplyTime = a.RefundApplyTime,
- RefundTime = a.RefundTime,
- RefundOrderNo = a.RefundOrderNo,
- RefundPrice = a.RefundPrice,
- ChannelName = b.ChannlesName,
- ActualRechargeAmount = a.ActualRechargeAmount,
- PlatformDeductionAmount = a.PlatformDeductionAmount,
- ACOOLYStatus = a.ACOOLYStatus,
- LifePayRefundStatus = a.LifePayRefundStatus,
- ActualReceivedAmount = a.ActualReceivedAmount.HasValue? a.ActualReceivedAmount.Value : 0
- });
+ join b in _lifePayChannlesRep on a.ChannelId equals b.ChannlesNum into temp
+ from b in temp.DefaultIfEmpty()
+ select new LifePayOrderListOutput
+ {
+ DiscountAmount = a.DiscountAmount ?? 0,
+ FinishTime = a.FinishTime,
+ Id = a.Id,
+ LifePayOrderStatus = a.LifePayOrderStatus ?? 0,
+ LifePayOrderType = a.LifePayOrderType,
+ LifePayType = a.LifePayType,
+ OrderNo = a.OrderNo,
+ PayAmount = a.PayAmount ?? 0,
+ PhoneNumber = a.PhoneNumber,
+ RechargeAmount = a.RechargeAmount ?? 0,
+ UserId = a.UserId,
+ OutOrderNo = a.OutOrderNo,
+ PayStatus = a.PayStatus ?? 0,
+ PayTime = a.PayTime,
+ ACOOLYOrderNo = a.ACOOLYOrderNo,
+ RefundCredentialsImgUrl = a.RefundCredentialsImgUrl.GetOssPath(),
+ CreationTime = a.CreationTime,
+ RefundCheckRemark = a.RefundCheckRemark,
+ RefundApplyRemark = a.RefundApplyRemark,
+ RefundApplyTime = a.RefundApplyTime,
+ RefundTime = a.RefundTime,
+ RefundOrderNo = a.RefundOrderNo,
+ RefundPrice = a.RefundPrice,
+ ChannelName = b.ChannlesName,
+ ActualRechargeAmount = a.ActualRechargeAmount,
+ PlatformDeductionAmount = a.PlatformDeductionAmount,
+ ACOOLYStatus = a.ACOOLYStatus,
+ LifePayRefundStatus = a.LifePayRefundStatus,
+ ActualReceivedAmount = a.ActualReceivedAmount.HasValue ? a.ActualReceivedAmount.Value : 0
+ });
return result;
}
private IQueryable<CreateEditPayChannelsInput> GetLifePayChannlesListFilter()
@@ -2104,8 +2159,8 @@
});
}
- public async Task<OrderPriceReturn> GetOrderPrice(decimal price, decimal priceAmount, decimal? platformRate,decimal? channleRate,
- decimal? channlesRakeRate,decimal? premiumRate)
+ public async Task<OrderPriceReturn> GetOrderPrice(decimal price, decimal priceAmount, decimal platformRate, decimal channleRate,
+ decimal channlesRakeRate, decimal premiumRate)
{
/// 姣涘埄
var grossProfit = price * (channleRate - platformRate) / 100;
@@ -2114,20 +2169,20 @@
var platformPrice = price * platformRate / 100;
/// 鎵嬬画璐�
- var premiumPrice = priceAmount * premiumRate / 100;
+ var premiumPrice = priceAmount * (premiumRate) / 100;
/// 娓犻亾浣i噾 锛�(鍏呭�奸潰棰� * 娓犻亾鎶樻墸姣斾緥)-(鍏呭�奸潰棰� * 骞冲彴鎶樻墸姣斾緥)锛�* 浣i噾姣斾緥
- var channlesRakePrice = grossProfit * channlesRakeRate / 100;
+ var channlesRakePrice = grossProfit * (channlesRakeRate) / 100;
/// 鍒╂鼎
- var profit = grossProfit - channlesRakePrice - premiumPrice;
+ var profit = grossProfit - channlesRakePrice - (premiumRate);
return new OrderPriceReturn()
{
- PlatformPrice = platformPrice.HasValue? platformPrice.Value :0,
- PremiumPrice = premiumPrice.HasValue ? premiumPrice.Value : 0,
- ChannlesRakePrice = channlesRakePrice.HasValue? channlesRakePrice.Value:0,
- Profit = profit.HasValue ? profit.Value : 0
+ PlatformPrice = platformPrice,
+ PremiumPrice = premiumPrice,
+ ChannlesRakePrice = channlesRakePrice,
+ Profit = profit
};
}
@@ -2146,5 +2201,42 @@
}
}
+ public async Task<SetPayTypeReturn> SetPayType(string orderNo, LifePayTypeEnum lifePayType, string ip)
+ {
+ var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync();
+ CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
+
+ CheckExtensions.IfTrueThrowUserFriendlyException(order.LifePayType.HasValue, "褰撳墠璁㈠崟宸查�夋嫨鏀粯绫诲瀷");
+
+ order.LifePayType = lifePayType;
+ var premium = await _lifePayPremiumRepository.Where(x => x.IsDeleted == false && x.PremiumType == order.LifePayType).FirstOrDefaultAsync();
+ order.PremiumRate = premium == null ? 0 : premium.Rate;
+ await _lifePayOrderRepository.UpdateAsync(order);
+
+ var desc = "鐢熸椿缂磋垂-";
+ switch (order.LifePayOrderType)
+ {
+ case LifePayOrderTypeEnum.PhoneOrder:
+ desc += "璇濊垂";
+ break;
+ case LifePayOrderTypeEnum.ElectricOrder:
+ desc += "鐢佃垂";
+ break;
+ case LifePayOrderTypeEnum.GasOrder:
+ desc += "鐕冩皵";
+ break;
+ default:
+ break;
+ }
+
+ return new SetPayTypeReturn()
+ {
+ Desc = desc,
+ OrderNo = order.OrderNo,
+ PayAmount = order.PayAmount.HasValue? order.PayAmount.Value : 0,
+ LifePayType = lifePayType,
+ };
+ }
+
#endregion
}
--
Gitblit v1.9.1