|
@@ -36,6 +36,7 @@ public class OderHandleServiceImpl implements OrderHandleService {
|
|
|
private final AssetService assetService;
|
|
|
private final BalanceDetailService balanceDetailService;
|
|
|
private final CurrencyRecordService currencyRecordService;
|
|
|
+ private final IOmsOrderOperateHistoryService omsOrderOperateHistoryService;
|
|
|
|
|
|
@Override
|
|
|
public void orderPay(Long orderId) {
|
|
@@ -67,7 +68,6 @@ public class OderHandleServiceImpl implements OrderHandleService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- //@Transactional
|
|
|
public void handleOrder(OmsOrder omsOrder) {
|
|
|
omsOrder.setStatus(4);
|
|
|
omsOrder.setConfirmStatus(1);
|
|
@@ -112,29 +112,43 @@ public class OderHandleServiceImpl implements OrderHandleService {
|
|
|
}
|
|
|
//商家应得金额
|
|
|
BigDecimal operateAmount = payAmount.subtract(platformAmount);
|
|
|
- //记录商家余额明细
|
|
|
- BigDecimal surplusAmount = assetService.updateAsset(0, operateAmount, merchantId, 2);
|
|
|
- balanceDetailService.recordFlow(omsOrder.getId(), 2, merchantId, operateAmount, surplusAmount, 0, 1, userId);
|
|
|
//记录流水--------------------------
|
|
|
//商家流水
|
|
|
- BigDecimal MerchantDeduct = BigDecimal.ZERO; //扣税
|
|
|
- currencyRecordService.recordFlow(merchantId, 2, 0, orderId, userId, 0, operateAmount, MerchantDeduct, operateAmount);
|
|
|
+ BigDecimal merchantDeduct = BigDecimal.ZERO; //扣税
|
|
|
+ BigDecimal merchantRealityAmount = operateAmount.subtract(merchantDeduct);
|
|
|
+ BigDecimal surplusAmount = assetService.updateAsset(0, merchantRealityAmount, merchantId, 2, 1);
|
|
|
+ currencyRecordService.recordFlow(merchantId, 2, 0, orderId, userId, 0, operateAmount, merchantDeduct, merchantRealityAmount);
|
|
|
+ //记录商家余额明细
|
|
|
+ balanceDetailService.recordFlow(omsOrder.getId(), 2, merchantId, operateAmount, surplusAmount, 0, 1, userId);
|
|
|
//邀请用户---分得佣金
|
|
|
if (userAmount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
platformAmount = platformAmount.subtract(userAmount);
|
|
|
BigDecimal deduct = BigDecimal.ZERO; //扣税
|
|
|
- currencyRecordService.recordFlow(inviteUserId, 1, 0, orderId, userId, 1, userAmount, deduct, userAmount);
|
|
|
+ BigDecimal realityAmount = userAmount.subtract(deduct);
|
|
|
+ //更新用户资产
|
|
|
+ assetService.updateAsset(0, realityAmount, inviteUserId, 1, 1);
|
|
|
+ //邀请用户流水
|
|
|
+ currencyRecordService.recordFlow(inviteUserId, 1, 0, orderId, userId, 1, userAmount, deduct, realityAmount);
|
|
|
}
|
|
|
//邀请商家---分得佣金
|
|
|
if (merchantAmount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
platformAmount = platformAmount.subtract(merchantAmount);
|
|
|
BigDecimal deduct = BigDecimal.ZERO; //扣税
|
|
|
- currencyRecordService.recordFlow(inviteMerchantId, 1, 0, orderId, userId, 2, merchantAmount, deduct, merchantAmount);
|
|
|
+ BigDecimal realityAmount = merchantAmount.subtract(deduct);
|
|
|
+ //更新用户资产
|
|
|
+ assetService.updateAsset(0, realityAmount, inviteMerchantId, 1, 1);
|
|
|
+ //邀请商家流水
|
|
|
+ currencyRecordService.recordFlow(inviteMerchantId, 1, 0, orderId, userId, 2, merchantAmount, deduct, realityAmount);
|
|
|
}
|
|
|
//平台流水
|
|
|
BigDecimal deduct = BigDecimal.ZERO; //扣税
|
|
|
- currencyRecordService.recordFlow(1L, 0, 0, orderId, userId, 3, platformAmount, deduct, platformAmount);
|
|
|
+ BigDecimal platformRealityAmount = platformAmount.subtract(deduct);
|
|
|
+ //更新平台资产
|
|
|
+ assetService.updatePlatformAsset(platformRealityAmount, payAmount);
|
|
|
+ //平台流水
|
|
|
+ currencyRecordService.recordFlow(1L, 0, 0, orderId, userId, 3, platformAmount, deduct, platformRealityAmount);
|
|
|
|
|
|
+ omsOrderOperateHistoryService.insertOmsOrderOperateHistory(omsOrder.getId(), userId, omsOrder.getStatus());
|
|
|
/*BigDecimal platformSurplusAmount = assetService.updateAsset(1, operateAmount, 1L, 0);
|
|
|
balanceDetailService.recordFlow(omsOrder.getId(), 0, 1L, operateAmount, platformSurplusAmount, 1, 1,
|
|
|
merchantId);
|
|
@@ -159,12 +173,13 @@ public class OderHandleServiceImpl implements OrderHandleService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- //@Transactional
|
|
|
public void paySuccess(OmsOrder order) {
|
|
|
omsOrderMapper.updateById(order);
|
|
|
- BigDecimal surplusAmount = assetService.updateAsset(0, order.getPayAmount(), 1L, 0);
|
|
|
+ assetService.updateAsset(0, order.getPayAmount(), 1L, 0, 2);
|
|
|
+ omsOrderOperateHistoryService.insertOmsOrderOperateHistory(order.getId(), order.getUserId(), order.getStatus());
|
|
|
+ /* BigDecimal surplusAmount = assetService.updateAsset(0, order.getPayAmount(), 1L, 0);
|
|
|
balanceDetailService.recordFlow(order.getId(), 0, 1L, order.getPayAmount(), surplusAmount, 0, 1,
|
|
|
- order.getUserId());
|
|
|
+ order.getUserId());*/
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|