|
@@ -4,10 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.chelvc.cloud.vehicle.client.constant.PlatformConstant;
|
|
|
import com.chelvc.cloud.vehicle.server.dao.OmsOrderMapper;
|
|
|
+import com.chelvc.cloud.vehicle.server.entity.MerchantRelation;
|
|
|
import com.chelvc.cloud.vehicle.server.entity.OmsOrder;
|
|
|
import com.chelvc.cloud.vehicle.server.service.*;
|
|
|
import com.chelvc.framework.common.exception.ResourceUnavailableException;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -36,6 +38,7 @@ public class OderHandleServiceImpl implements OrderHandleService {
|
|
|
private final AssetService assetService;
|
|
|
private final BalanceDetailService balanceDetailService;
|
|
|
private final OmsOrderOperateHistoryService omsOrderOperateHistoryService;
|
|
|
+ private final MerchantRelationService merchantRelationService;
|
|
|
|
|
|
@Override
|
|
|
public void orderPay(Long orderId) {
|
|
@@ -126,23 +129,31 @@ public class OderHandleServiceImpl implements OrderHandleService {
|
|
|
balanceDetailService.recordFlow(orderId, 2, merchantId, operateAmount, merchantDeduct,
|
|
|
merchantRealityAmount, surplusAmount, 0, 0, userId);
|
|
|
//给商家转账
|
|
|
- assetService.transfer(0L, merchantId, 2, merchantRealityAmount);
|
|
|
+ assetService.transfer(0L, merchantId, 2, merchantRealityAmount, "");
|
|
|
//邀请用户---分得佣金
|
|
|
if (userAmount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
platformAmount = platformAmount.subtract(userAmount);
|
|
|
BigDecimal deduct = BigDecimal.ZERO; //扣税
|
|
|
BigDecimal realityAmount = userAmount.subtract(deduct);
|
|
|
- //更新用户资产
|
|
|
- BigDecimal userTotal = assetService.updateAsset(0, realityAmount, inviteUserId, 1, 1);
|
|
|
- //邀请用户余额明细
|
|
|
- balanceDetailService.recordFlow(orderId, 1, inviteUserId, userAmount, deduct,
|
|
|
- realityAmount, userTotal, 0, 1, userId);
|
|
|
- //currencyRecordService.recordFlow(inviteUserId, 1, 0, orderId, userId, 1, userAmount, deduct, realityAmount);
|
|
|
- //用户资产记录到平台名下
|
|
|
- BigDecimal platformTotal = assetService.updateAsset(0, realityAmount, 0L, 0, 1);
|
|
|
- //用户佣金记录到平台余额名下
|
|
|
- balanceDetailService.recordFlow(orderId, 0, 0L, userAmount, deduct,
|
|
|
- realityAmount, platformTotal, 0, 1, userId);
|
|
|
+ MerchantRelation relation = merchantRelationService.queryByUserIdAndType(inviteUserId, 1);
|
|
|
+ if(relation != null && StringUtils.isNotBlank(relation.getSxyMerchantId())){
|
|
|
+ //开通商户号,转账操作
|
|
|
+ assetService.transfer(0L, inviteUserId, 1, realityAmount, "");
|
|
|
+ //记录用户余额明细
|
|
|
+ balanceDetailService.recordFlow(orderId, 1, inviteUserId, userAmount, deduct,
|
|
|
+ realityAmount, surplusAmount, 0, 1, userId);
|
|
|
+ } else {
|
|
|
+ //更新用户资产
|
|
|
+ BigDecimal userTotal = assetService.updateAsset(0, realityAmount, inviteUserId, 1, 1);
|
|
|
+ //邀请用户余额明细
|
|
|
+ balanceDetailService.recordFlow(orderId, 1, inviteUserId, userAmount, deduct,
|
|
|
+ realityAmount, userTotal, 0, 1, userId);
|
|
|
+ //用户资产记录到平台名下
|
|
|
+ BigDecimal platformTotal = assetService.updateAsset(0, realityAmount, 0L, 0, 1);
|
|
|
+ //用户佣金记录到平台余额名下
|
|
|
+ balanceDetailService.recordFlow(orderId, 0, 0L, userAmount, deduct,
|
|
|
+ realityAmount, platformTotal, 0, 1, userId);
|
|
|
+ }
|
|
|
}
|
|
|
//邀请商家---分得佣金
|
|
|
if (merchantAmount.compareTo(BigDecimal.ZERO) > 0) {
|
|
@@ -154,10 +165,8 @@ public class OderHandleServiceImpl implements OrderHandleService {
|
|
|
//记录商户分佣余额明细
|
|
|
balanceDetailService.recordFlow(omsOrder.getId(), 2, inviteMerchantId, merchantAmount, deduct,
|
|
|
realityAmount, merchantTotal, 0, 2, userId);
|
|
|
- //邀请商家流水
|
|
|
- //currencyRecordService.recordFlow(inviteMerchantId, 1, 0, orderId, userId, 2, merchantAmount, deduct, realityAmount);
|
|
|
//商家佣金转账
|
|
|
- assetService.transfer(0L, inviteMerchantId, 2, realityAmount);
|
|
|
+ assetService.transfer(0L, inviteMerchantId, 2, realityAmount, "");
|
|
|
}
|
|
|
//平台流水
|
|
|
BigDecimal deduct = BigDecimal.ZERO; //扣税
|
|
@@ -167,7 +176,6 @@ public class OderHandleServiceImpl implements OrderHandleService {
|
|
|
//记录平台抽成余额明细
|
|
|
balanceDetailService.recordFlow(omsOrder.getId(), 0, 0L, platformAmount, deduct,
|
|
|
platformRealityAmount, platformTotal, 0, 2, userId);
|
|
|
-
|
|
|
omsOrderOperateHistoryService.insertOmsOrderOperateHistory(omsOrder.getId(), userId, omsOrder.getStatus());
|
|
|
//以下注释为以前逻辑,先不用管
|
|
|
/*BigDecimal platformSurplusAmount = assetService.updateAsset(1, operateAmount, 0L, 0);
|