| | |
| | | }) |
| | | .GetPageResult(input.PageModel); |
| | | |
| | | var totalRakePrice = await _lifePayChannlesRakeRepository.Where(x => x.IsDeleted == false).SumAsync(x => x.ChannlesRakePrice); |
| | | var totalRakePrice = await _lifePayChannlesRakeRepository.Where(x => x.IsDeleted == false) |
| | | .WhereIf(input.ChannelId.IsNotNullOrEmpty(), x => x.ChannelId == input.ChannelId) |
| | | .WhereIf(input.CreationTimeBegin.HasValue, x => x.CreationTime >= input.CreationTimeBegin) |
| | | .WhereIf(input.CreationTimeEnd.HasValue, x => x.CreationTime <= input.CreationTimeEnd) |
| | | .WhereIf(input.FinishTimeBegin.HasValue, x => x.FinishTime >= input.FinishTimeBegin) |
| | | .WhereIf(input.FinishTimeEnd.HasValue, x => x.FinishTime <= input.FinishTimeEnd) |
| | | .SumAsync(x => x.ChannlesRakePrice); |
| | | |
| | | LifePayLifePayChannlesRakeStatistics objectData = new LifePayLifePayChannlesRakeStatistics(); |
| | | objectData.TotalRakePrice = totalRakePrice; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 统计所有消费流水 |
| | | /// </summary> |
| | |
| | | var orderList = await _lifePayOrderRepository.Where(x => x.PayStatus == LifePayStatusEnum.已支付).ToListAsync(); |
| | | foreach (var item in orderList) |
| | | { |
| | | LifePayConsumption lifePayConsumption = new LifePayConsumption() |
| | | { |
| | | OrderNo = item.OrderNo, |
| | | AcoolyOrderNo = item.ACOOLYOrderNo, |
| | | Amount = item.PlatformDeductionAmount.HasValue? item.PlatformDeductionAmount.Value : 0, |
| | | ChannelId = item.ChannelId, |
| | | }; |
| | | |
| | | if (item.ACOOLYStatus != null) |
| | | { |
| | | switch (item.ACOOLYStatus) |
| | | { |
| | | case ACOOLYStatusEnum.充值中: |
| | | await CreatLifePayConsumption(ACOOLYStatusEnum.充值中, item, lifePayConsumption); |
| | | await CreatLifePayConsumption(ACOOLYStatusEnum.充值中, item.OrderNo, item.ACOOLYOrderNo, |
| | | item.PlatformDeductionAmount ?? 0, item.ChannelId, item.CreationTime, item.FinishTime); |
| | | break; |
| | | case ACOOLYStatusEnum.充值成功: |
| | | await CreatLifePayConsumption(ACOOLYStatusEnum.充值中, item, lifePayConsumption); |
| | | await CreatLifePayConsumption(ACOOLYStatusEnum.充值成功, item, lifePayConsumption); |
| | | await CreatLifePayConsumption(ACOOLYStatusEnum.充值中, item.OrderNo, item.ACOOLYOrderNo, |
| | | item.PlatformDeductionAmount ?? 0, item.ChannelId, item.CreationTime, item.FinishTime); |
| | | await CreatLifePayConsumption(ACOOLYStatusEnum.充值成功, item.OrderNo, item.ACOOLYOrderNo, |
| | | item.PlatformDeductionAmount ?? 0, item.ChannelId, item.CreationTime, item.FinishTime); |
| | | break; |
| | | case ACOOLYStatusEnum.已完成: |
| | | await CreatLifePayConsumption(ACOOLYStatusEnum.充值中, item, lifePayConsumption); |
| | | await CreatLifePayConsumption(ACOOLYStatusEnum.已完成, item, lifePayConsumption); |
| | | await CreatLifePayConsumption(ACOOLYStatusEnum.充值中, item.OrderNo, item.ACOOLYOrderNo, |
| | | item.PlatformDeductionAmount ?? 0, item.ChannelId, item.CreationTime, item.FinishTime); |
| | | await CreatLifePayConsumption(ACOOLYStatusEnum.已完成, item.OrderNo, item.ACOOLYOrderNo, |
| | | item.PlatformDeductionAmount ?? 0, item.ChannelId, item.CreationTime, item.FinishTime); |
| | | break; |
| | | case ACOOLYStatusEnum.充值失败: |
| | | await CreatLifePayConsumption(ACOOLYStatusEnum.充值中, item, lifePayConsumption); |
| | | await CreatLifePayConsumption(ACOOLYStatusEnum.充值失败, item, lifePayConsumption); |
| | | await CreatLifePayConsumption(ACOOLYStatusEnum.充值中, item.OrderNo, item.ACOOLYOrderNo, |
| | | item.PlatformDeductionAmount ?? 0, item.ChannelId, item.CreationTime, item.FinishTime); |
| | | await CreatLifePayConsumption(ACOOLYStatusEnum.充值失败, item.OrderNo, item.ACOOLYOrderNo, |
| | | item.PlatformDeductionAmount ?? 0, item.ChannelId, item.CreationTime, item.FinishTime); |
| | | break; |
| | | default: break; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 统计所有收支流水 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public async Task GetAllLifePayExpensesReceipts() |
| | | { |
| | | var orderlist = await (from a in _lifePayOrderRepository.Where(x => x.PayStatus >= LifePayStatusEnum.已支付) |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取全部渠道分佣 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public async Task GetAllChannlesRake() |
| | | { |
| | | var orderlist = await _lifePayOrderRepository.Where(x => x.IsDeleted == false && x.PayStatus == LifePayStatusEnum.已支付 && x.LifePayOrderStatus == LifePayOrderStatusEnum.已完成).ToListAsync(); |
| | |
| | | /// 毛利 |
| | | var grossProfit = item.RechargeAmount * (item.ChannleRate - item.PlatformRate) / 100; |
| | | /// 渠道佣金 ((充值面额 * 渠道折扣比例)-(充值面额 * 平台折扣比例))* 佣金比例 |
| | | var channlesRakePrice = grossProfit * (item.ChannlesRakeRate) / 100; |
| | | var channlesRakePrice = grossProfit * item.ChannlesRakeRate / 100; |
| | | |
| | | if (channlesRakePrice.HasValue) |
| | | { |
| | | LifePayChannlesRake lifePayChannlesRake = new LifePayChannlesRake() |
| | | { |
| | | OrderNo = item.OrderNo, |
| | | PayAmount = item.PayAmount.Value, |
| | | ChannlesRakeRate = item.ChannlesRakeRate.Value, |
| | | ChannlesRakePrice = channlesRakePrice.Value, |
| | | PayAmount = item.RechargeAmount ?? 0, |
| | | ChannlesRakeRate = item.ChannlesRakeRate ?? 0, |
| | | ChannlesRakePrice = channlesRakePrice ?? 0, |
| | | FinishTime = item.FinishTime.Value, |
| | | ChannelId = item.ChannelId, |
| | | }; |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region 私有 |
| | | #region 方法 |
| | | public async Task CreatLifePayConsumption(ACOOLYStatusEnum status, string orderNo, string aCOOLYOrderNo, |
| | | decimal platformDeductionAmount, string channelId, DateTime orderCreationTime, DateTime? orderFinishTime) |
| | | { |
| | | LifePayConsumption lifePayConsumption = new LifePayConsumption() |
| | | { |
| | | OrderNo = orderNo, |
| | | AcoolyOrderNo = aCOOLYOrderNo, |
| | | Amount = platformDeductionAmount, |
| | | ChannelId = channelId, |
| | | }; |
| | | LifePayConsumption repeat = new LifePayConsumption(); |
| | | switch (status) |
| | | { |
| | | case ACOOLYStatusEnum.充值中: |
| | | lifePayConsumption.FinishTime = orderCreationTime; |
| | | lifePayConsumption.ACOOLYStatus = ACOOLYStatusEnum.充值中; |
| | | lifePayConsumption.FrozenStatus = ConsumptionFrozenStatusEnum.Frozen; |
| | | lifePayConsumption.Flow = ConsumptionFlowEnum.Unchanged; |
| | | lifePayConsumption.DeductionAmount = 0; |
| | | lifePayConsumption.FrozenAmount = lifePayConsumption.Amount; |
| | | |
| | | repeat = await _lifePayConsumption.Where(x => x.OrderNo == lifePayConsumption.OrderNo |
| | | && x.ACOOLYStatus == lifePayConsumption.ACOOLYStatus && x.Flow == lifePayConsumption.Flow).FirstOrDefaultAsync(); |
| | | if (repeat == null) |
| | | { |
| | | await _lifePayConsumption.InsertAsync(lifePayConsumption); |
| | | } |
| | | |
| | | break; |
| | | case ACOOLYStatusEnum.已完成: |
| | | lifePayConsumption.FinishTime = orderFinishTime.Value; |
| | | lifePayConsumption.ACOOLYStatus = ACOOLYStatusEnum.已完成; |
| | | lifePayConsumption.FrozenStatus = ConsumptionFrozenStatusEnum.Thaw; |
| | | lifePayConsumption.Flow = ConsumptionFlowEnum.Out; |
| | | lifePayConsumption.DeductionAmount = lifePayConsumption.Amount; |
| | | lifePayConsumption.FrozenAmount = 0; |
| | | |
| | | repeat = await _lifePayConsumption.Where(x => x.OrderNo == lifePayConsumption.OrderNo |
| | | && x.ACOOLYStatus == lifePayConsumption.ACOOLYStatus && x.Flow == lifePayConsumption.Flow).FirstOrDefaultAsync(); |
| | | if (repeat == null) |
| | | { |
| | | await _lifePayConsumption.InsertAsync(lifePayConsumption); |
| | | } |
| | | |
| | | break; |
| | | case ACOOLYStatusEnum.充值失败: |
| | | lifePayConsumption.FinishTime = orderCreationTime; |
| | | lifePayConsumption.ACOOLYStatus = ACOOLYStatusEnum.充值失败; |
| | | lifePayConsumption.FrozenStatus = ConsumptionFrozenStatusEnum.Frozen; |
| | | lifePayConsumption.Flow = ConsumptionFlowEnum.Unchanged; |
| | | lifePayConsumption.DeductionAmount = 0; |
| | | lifePayConsumption.FrozenAmount = lifePayConsumption.Amount; |
| | | |
| | | repeat = await _lifePayConsumption.Where(x => x.OrderNo == lifePayConsumption.OrderNo |
| | | && x.ACOOLYStatus == lifePayConsumption.ACOOLYStatus && x.Flow == lifePayConsumption.Flow).FirstOrDefaultAsync(); |
| | | if (repeat == null) |
| | | { |
| | | await _lifePayConsumption.InsertAsync(lifePayConsumption); |
| | | } |
| | | |
| | | break; |
| | | case ACOOLYStatusEnum.已退款: |
| | | lifePayConsumption.FinishTime = orderFinishTime.Value; |
| | | lifePayConsumption.ACOOLYStatus = ACOOLYStatusEnum.已退款; |
| | | lifePayConsumption.FrozenStatus = ConsumptionFrozenStatusEnum.Thaw; |
| | | lifePayConsumption.Flow = ConsumptionFlowEnum.Unchanged; |
| | | lifePayConsumption.DeductionAmount = 0; |
| | | lifePayConsumption.FrozenAmount = 0; |
| | | |
| | | repeat = await _lifePayConsumption.Where(x => x.OrderNo == lifePayConsumption.OrderNo |
| | | && x.ACOOLYStatus == lifePayConsumption.ACOOLYStatus && x.Flow == lifePayConsumption.Flow).FirstOrDefaultAsync(); |
| | | if (repeat == null) |
| | | { |
| | | await _lifePayConsumption.InsertAsync(lifePayConsumption); |
| | | } |
| | | |
| | | break; |
| | | |
| | | //case ACOOLYStatusEnum.部分充值成功: |
| | | // lifePayConsumption.FinishTime = orderCreationTime; |
| | | // lifePayConsumption.ACOOLYStatus = ACOOLYStatusEnum.部分充值成功; |
| | | // lifePayConsumption.FrozenStatus = ConsumptionFrozenStatusEnum.Thaw; |
| | | // lifePayConsumption.Flow = ConsumptionFlowEnum.Unchanged; |
| | | // lifePayConsumption.DeductionAmount = 0; |
| | | // lifePayConsumption.FrozenAmount = lifePayConsumption.Amount; |
| | | |
| | | // repeat = await _lifePayConsumption.Where(x => x.OrderNo == lifePayConsumption.OrderNo |
| | | // && x.ACOOLYStatus == lifePayConsumption.ACOOLYStatus && x.Flow == lifePayConsumption.Flow).FirstOrDefaultAsync(); |
| | | // if (repeat == null) |
| | | // { |
| | | // await _lifePayConsumption.InsertAsync(lifePayConsumption); |
| | | // } |
| | | |
| | | // break; |
| | | default: break; |
| | | } |
| | | } |
| | | |
| | | private async Task<IQueryable<LifePayChannlesRakeListOutput>> GetLifePayChannlesRakeListFilter(LifePayChannlesRakePageInput input) |
| | | { |
| | | var list = _lifePayChannlesRakeRepository.Where(x => x.IsDeleted == false) |
| | |
| | | return list; |
| | | } |
| | | |
| | | private async Task CreatLifePayConsumption(ACOOLYStatusEnum status, LifePayOrder order, LifePayConsumption lifePayConsumption) |
| | | { |
| | | LifePayConsumption repeat = new LifePayConsumption(); |
| | | switch (status) |
| | | { |
| | | case ACOOLYStatusEnum.充值中: |
| | | lifePayConsumption.FinishTime = order.CreationTime; |
| | | lifePayConsumption.ACOOLYStatus = ACOOLYStatusEnum.充值中; |
| | | lifePayConsumption.FrozenStatus = ConsumptionFrozenStatusEnum.Frozen; |
| | | lifePayConsumption.Flow = ConsumptionFlowEnum.Unchanged; |
| | | lifePayConsumption.DeductionAmount = 0; |
| | | lifePayConsumption.FrozenAmount = lifePayConsumption.Amount; |
| | | |
| | | repeat = await _lifePayConsumption.Where(x => x.OrderNo == lifePayConsumption.OrderNo |
| | | && x.ACOOLYStatus == lifePayConsumption.ACOOLYStatus && x.Flow == lifePayConsumption.Flow).FirstOrDefaultAsync(); |
| | | if (repeat == null) |
| | | { |
| | | await _lifePayConsumption.InsertAsync(lifePayConsumption); |
| | | } |
| | | |
| | | break; |
| | | case ACOOLYStatusEnum.已完成: |
| | | lifePayConsumption.FinishTime = order.FinishTime.Value; |
| | | lifePayConsumption.ACOOLYStatus = ACOOLYStatusEnum.已完成; |
| | | lifePayConsumption.FrozenStatus = ConsumptionFrozenStatusEnum.Thaw; |
| | | lifePayConsumption.Flow = ConsumptionFlowEnum.Out; |
| | | lifePayConsumption.DeductionAmount = lifePayConsumption.Amount; |
| | | lifePayConsumption.FrozenAmount = 0; |
| | | |
| | | repeat = await _lifePayConsumption.Where(x => x.OrderNo == lifePayConsumption.OrderNo |
| | | && x.ACOOLYStatus == lifePayConsumption.ACOOLYStatus && x.Flow == lifePayConsumption.Flow).FirstOrDefaultAsync(); |
| | | if (repeat == null) |
| | | { |
| | | await _lifePayConsumption.InsertAsync(lifePayConsumption); |
| | | } |
| | | |
| | | break; |
| | | case ACOOLYStatusEnum.充值失败: |
| | | lifePayConsumption.FinishTime = order.CreationTime; |
| | | lifePayConsumption.ACOOLYStatus = ACOOLYStatusEnum.充值失败; |
| | | lifePayConsumption.FrozenStatus = ConsumptionFrozenStatusEnum.Frozen; |
| | | lifePayConsumption.Flow = ConsumptionFlowEnum.Unchanged; |
| | | lifePayConsumption.DeductionAmount = 0; |
| | | lifePayConsumption.FrozenAmount = lifePayConsumption.Amount; |
| | | |
| | | repeat = await _lifePayConsumption.Where(x => x.OrderNo == lifePayConsumption.OrderNo |
| | | && x.ACOOLYStatus == lifePayConsumption.ACOOLYStatus && x.Flow == lifePayConsumption.Flow).FirstOrDefaultAsync(); |
| | | if (repeat == null) |
| | | { |
| | | await _lifePayConsumption.InsertAsync(lifePayConsumption); |
| | | } |
| | | |
| | | break; |
| | | case ACOOLYStatusEnum.已退款: |
| | | lifePayConsumption.FinishTime = order.FinishTime.Value; |
| | | lifePayConsumption.ACOOLYStatus = ACOOLYStatusEnum.已退款; |
| | | lifePayConsumption.FrozenStatus = ConsumptionFrozenStatusEnum.Thaw; |
| | | lifePayConsumption.Flow = ConsumptionFlowEnum.Unchanged; |
| | | lifePayConsumption.DeductionAmount = 0; |
| | | lifePayConsumption.FrozenAmount = 0; |
| | | |
| | | repeat = await _lifePayConsumption.Where(x => x.OrderNo == lifePayConsumption.OrderNo |
| | | && x.ACOOLYStatus == lifePayConsumption.ACOOLYStatus && x.Flow == lifePayConsumption.Flow).FirstOrDefaultAsync(); |
| | | if (repeat == null) |
| | | { |
| | | await _lifePayConsumption.InsertAsync(lifePayConsumption); |
| | | } |
| | | |
| | | break; |
| | | |
| | | //case ACOOLYStatusEnum.部分充值成功: |
| | | // lifePayConsumption.FinishTime = order.CreationTime; |
| | | // lifePayConsumption.ACOOLYStatus = ACOOLYStatusEnum.部分充值成功; |
| | | // lifePayConsumption.FrozenStatus = ConsumptionFrozenStatusEnum.Thaw; |
| | | // lifePayConsumption.Flow = ConsumptionFlowEnum.Unchanged; |
| | | // lifePayConsumption.DeductionAmount = 0; |
| | | // lifePayConsumption.FrozenAmount = lifePayConsumption.Amount; |
| | | |
| | | // repeat = await _lifePayConsumption.Where(x => x.OrderNo == lifePayConsumption.OrderNo |
| | | // && x.ACOOLYStatus == lifePayConsumption.ACOOLYStatus && x.Flow == lifePayConsumption.Flow).FirstOrDefaultAsync(); |
| | | // if (repeat == null) |
| | | // { |
| | | // await _lifePayConsumption.InsertAsync(lifePayConsumption); |
| | | // } |
| | | |
| | | // break; |
| | | default: break; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | } |