|
|
@@ -231,9 +231,6 @@ public class DistributorRechargeServiceImpl implements DistributorRechargeServic
|
|
|
int tradeType = 1;
|
|
|
//
|
|
|
String payType = distributorDO.getPayType();
|
|
|
- if (StringUtils.isBlank(payType)) {
|
|
|
-
|
|
|
- }
|
|
|
String[] payTypeArray = payType.split(",");
|
|
|
Stream<String> typeStream = Arrays.stream(payTypeArray);
|
|
|
if (ObjectUtil.equals(rechargeDO.getRechargeType(), DistributorTradeTypeEnum.BALANCE_RECHARGE.getType())) {
|
|
|
@@ -371,73 +368,42 @@ public class DistributorRechargeServiceImpl implements DistributorRechargeServic
|
|
|
AtomicBoolean isShareBalance = new AtomicBoolean(false);
|
|
|
AtomicReference<StoreRespDTO> storeRespDTO = new AtomicReference<>();
|
|
|
try{
|
|
|
- if (rechargeReqDTO.getStoreId() != null){
|
|
|
- isShareBalance.set(true);
|
|
|
- }else {
|
|
|
- isShareBalance.set(true);
|
|
|
- }
|
|
|
-
|
|
|
- if(isShareBalance.get()){
|
|
|
- Asserts.isTrue(afterBalance.compareTo(BigDecimal.ZERO)>=0,"平台余额不足额");
|
|
|
- tradeName = "消费金额:" + money + "元,消费后剩余余额" + afterBalance + "元;";
|
|
|
- flag = distributorService.subBalance(distributor.getId(), money);
|
|
|
- }else if(storeRespDTO.get()!=null){
|
|
|
- StoreRespDTO storeRsp = storeRespDTO.get();
|
|
|
- beforeBalance = storeRsp.getBeforeAmount();
|
|
|
- afterBalance = storeRsp.getAfterAmount();
|
|
|
- tradeName = "消费金额:" + money + "元,消费后门店账户剩余余额" + storeRsp.getAfterAmount() + "元;";
|
|
|
- flag = true;
|
|
|
- }
|
|
|
-
|
|
|
+ Asserts.isTrue(afterBalance.compareTo(BigDecimal.ZERO)>=0,"平台余额不足额");
|
|
|
+ tradeName = "消费金额:" + money + "元,消费后剩余余额" + afterBalance + "元;";
|
|
|
+ flag = distributorService.subBalance(distributor.getId(), money);
|
|
|
}catch (ServiceException e){
|
|
|
if(!canChangeToCredit){
|
|
|
throw e;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if(!flag){
|
|
|
- //尝试授信
|
|
|
-// tradeType = DistributorTradeTypeEnum.CREDIT_TRANS.getType();
|
|
|
- }
|
|
|
} else {
|
|
|
if (!canChangeToCredit) {
|
|
|
throw exception0(11_028, "分销商无预付款交易权限!");
|
|
|
}
|
|
|
-// tradeType = DistributorTradeTypeEnum.CREDIT_TRANS.getType();
|
|
|
- }
|
|
|
-
|
|
|
- if(tradeType == DistributorTradeTypeEnum.CREDIT_TRANS.getType()){
|
|
|
-
|
|
|
- rechargeReqDTO.setRechargeType(DistributorTradeTypeEnum.CREDIT_RECHARGE.getType());
|
|
|
- rechargeReqDTO.setTradeType(tradeType);
|
|
|
- return tradeRecharge(rechargeReqDTO);
|
|
|
}
|
|
|
-
|
|
|
break;
|
|
|
case 5:
|
|
|
-
|
|
|
+ //预付款退款 定向库存退款 导游代退失败回退预存款
|
|
|
+ beforeBalance = distributor.getBalance();
|
|
|
+ //交易后金额
|
|
|
+ afterBalance = beforeBalance.add(money);
|
|
|
+ AtomicBoolean isShareBalance;
|
|
|
+ tradeName ="余额退款金额:" + money + "元,退款到账后剩余余额" + afterBalance + "元";
|
|
|
+ //操作账户资金
|
|
|
+ flag = distributorService.addBalance(distributor.getId(), money);
|
|
|
+ break;
|
|
|
case 20:
|
|
|
//预付款退款 定向库存退款 导游代退失败回退预存款
|
|
|
beforeBalance = distributor.getBalance();
|
|
|
//交易后金额
|
|
|
afterBalance = beforeBalance.add(money);
|
|
|
- AtomicBoolean isShareBalance = new AtomicBoolean(false);
|
|
|
- AtomicReference<StoreRespDTO> storeRespDTO = new AtomicReference<>();
|
|
|
- if(true){
|
|
|
- tradeName =(tradeType==10?"定向库存":"")+"余额退款金额:" + money + "元,退款到账后剩余余额" + afterBalance + "元";
|
|
|
- //操作账户资金
|
|
|
- flag = distributorService.addBalance(distributor.getId(), money);
|
|
|
- }else if(storeRespDTO.get()!=null){
|
|
|
- StoreRespDTO storeRsp = storeRespDTO.get();
|
|
|
- beforeBalance = storeRsp.getBeforeAmount();
|
|
|
- afterBalance = storeRsp.getAfterAmount();
|
|
|
- tradeName = (tradeType==10?"定向库存":"")+"余额退款金额:" + money + "元,退款到账后门店账户剩余余额" + storeRsp.getAfterAmount() + "元;";
|
|
|
- flag = true;
|
|
|
- }
|
|
|
+ tradeName = "余额退款金额:" + money + "元,退款到账后剩余余额" + afterBalance + "元";
|
|
|
+ //操作账户资金
|
|
|
+ flag = distributorService.addBalance(distributor.getId(), money);
|
|
|
break;
|
|
|
case 2:
|
|
|
AtomicBoolean isShareCredit = new AtomicBoolean(false);
|
|
|
- storeRespDTO = new AtomicReference<>();
|
|
|
+ AtomicReference<StoreRespDTO> storeRespDTO = new AtomicReference<>();
|
|
|
if (rechargeReqDTO.getStoreId() != null){
|
|
|
//只充门店
|
|
|
StoreReqDTO reqDTO = this.convertStorePlatCredit(rechargeReqDTO.getStoreId(), tradeMode, money, Long.parseLong(rechargeReqDTO.getOrderId()), tradeType, rechargeReqDTO.getRefundId());
|
|
|
@@ -518,12 +484,6 @@ public class DistributorRechargeServiceImpl implements DistributorRechargeServic
|
|
|
flag = true;
|
|
|
}
|
|
|
|
|
|
- break;
|
|
|
- case 9:
|
|
|
- //交易前金额
|
|
|
- beforeBalance = distributor.getBalance();
|
|
|
- afterBalance = beforeBalance.subtract(money);
|
|
|
-
|
|
|
break;
|
|
|
case 14:
|
|
|
//营销政策充值
|
|
|
@@ -666,63 +626,27 @@ public class DistributorRechargeServiceImpl implements DistributorRechargeServic
|
|
|
|
|
|
tradeMode = 2;
|
|
|
//门店平台授信
|
|
|
- AtomicBoolean isShareCredit = new AtomicBoolean(false);
|
|
|
- AtomicReference<StoreRespDTO> storeRespDTO = new AtomicReference<>();
|
|
|
-// if (rechargeReqDTO.getStoreId() != null){
|
|
|
-// StoreReqDTO reqDTO = this.convertStorePlatCredit(rechargeReqDTO.getStoreId(), tradeMode, money, Long.parseLong(rechargeReqDTO.getOrderId()), tradeType, null);
|
|
|
-// TenantUtils.execute(distributor.getAccountTenantId(), () -> {
|
|
|
-// StoreInfoReqDTO storeData = storeApi.getStoreById(rechargeReqDTO.getStoreId()).getCheckedData();
|
|
|
-// if(ObjectUtil.equals(storeData.getCreditType(), StoreCreditTypeEnum.FIXED.getType())){
|
|
|
-// CommonResult<StoreRespDTO> storeResult = storeApi.storePlatTrade(reqDTO);
|
|
|
-// Asserts.isTrue(storeResult.isSuccess(), storeResult.getMsg());
|
|
|
-// storeRespDTO.set(storeResult.getCheckedData());
|
|
|
-// }else if(ObjectUtil.equals(storeData.getCreditType(), StoreCreditTypeEnum.SHARE.getType())){
|
|
|
-// isShareCredit.set(true);
|
|
|
-// }else {
|
|
|
-// Asserts.isTrue(true,"该门店禁用授信支付方式");
|
|
|
-// }
|
|
|
-//
|
|
|
-// });
|
|
|
-// }else{
|
|
|
-// isShareCredit.set(true);
|
|
|
-// }
|
|
|
- if(true){
|
|
|
- Asserts.isTrue(isUseCredit, "分销商无授信交易权限!");
|
|
|
- // 授信总额
|
|
|
- BigDecimal payCredit = distributor.getPayCredit();
|
|
|
- // 交易前已使用额度
|
|
|
- beforeBalance = distributor.getSurplus();
|
|
|
- // 交易后已使用额度
|
|
|
- afterBalance = beforeBalance.add(money);
|
|
|
- if (payCredit != null) {
|
|
|
-// if (afterBalance.compareTo(payCredit) > 0) {
|
|
|
-// if(originTradeType == DistributorTradeTypeEnum.BALANCE_TRANS.getType()){
|
|
|
-// throw exception0(11_028, "余额不足,交易失败!");
|
|
|
-// }else {
|
|
|
-// throw exception(CREDIT_INSUFFICIENT_FUNDS);
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
- BigDecimal creditRemained = payCredit.subtract(afterBalance);
|
|
|
- tradeName = "授信消费金额:" + money + "元,授信总额度" + payCredit + "元,消费后剩余额度" + creditRemained + "元;已用额度" + afterBalance + "元";
|
|
|
- } else {
|
|
|
- tradeName = "授信消费金额:" + money + "元,授信总额度不限,消费后剩余额度不限;已用额度" + afterBalance + "元";
|
|
|
- }
|
|
|
- distributorService.addSurplus(distributor.getId(), money);
|
|
|
- flag = true;
|
|
|
- }else if(storeRespDTO.get()!=null){
|
|
|
- StoreRespDTO storeRsp = storeRespDTO.get();
|
|
|
- beforeBalance = storeRsp.getBeforeAmount();
|
|
|
- afterBalance = storeRsp.getAfterAmount();
|
|
|
- tradeName = "授信支付金额:" + money + "元,支付后门店已使用授信从" + storeRsp.getBeforeAmount() + "元;变为"+ storeRsp.getAfterAmount();
|
|
|
- flag = true;
|
|
|
+ Asserts.isTrue(isUseCredit, "分销商无授信交易权限!");
|
|
|
+ // 授信总额
|
|
|
+ BigDecimal payCredit = distributor.getPayCredit();
|
|
|
+ // 交易前已使用额度
|
|
|
+ beforeBalance = distributor.getSurplus();
|
|
|
+ // 交易后已使用额度
|
|
|
+ afterBalance = beforeBalance.add(money);
|
|
|
+ if (payCredit != null) {
|
|
|
+ BigDecimal creditRemained = payCredit.subtract(afterBalance);
|
|
|
+ tradeName = "授信消费金额:" + money + "元,授信总额度" + payCredit + "元,消费后剩余额度" + creditRemained + "元;已用额度" + afterBalance + "元";
|
|
|
+ } else {
|
|
|
+ tradeName = "授信消费金额:" + money + "元,授信总额度不限,消费后剩余额度不限;已用额度" + afterBalance + "元";
|
|
|
}
|
|
|
+ distributorService.addSurplus(distributor.getId(), money);
|
|
|
+ flag = true;
|
|
|
}
|
|
|
|
|
|
respDTO = new DistributorRechargeRespDTO();
|
|
|
respDTO.setRechargeType(tradeType);
|
|
|
if (flag) {
|
|
|
-
|
|
|
+ log.error("advancePayTypeService.refund交易名称{}金额{}tradeType{}", tradeName, money,tradeType);
|
|
|
//添加ota消费记录数据
|
|
|
TradeLogDO logDO = new TradeLogDO();
|
|
|
logDO.setOperatorId(distributor.getId());
|
|
|
@@ -744,14 +668,16 @@ public class DistributorRechargeServiceImpl implements DistributorRechargeServic
|
|
|
respDTO.setTradeId(tradeId);
|
|
|
respDTO.setRechargeType(tradeType);
|
|
|
} else {
|
|
|
- if(!((tradeType == DistributorTradeTypeEnum.CREDIT_RECHARGE.getType() || tradeType == DistributorTradeTypeEnum.CREDIT_TRANS.getType() )&& rechargeReqDTO.getStoreId()!=null)){
|
|
|
- throw exception(DISTRIBUTOR_PAY_FAILED);
|
|
|
+ if(rechargeReqDTO.getStoreId()!=null){
|
|
|
+ if(!(tradeType == DistributorTradeTypeEnum.CREDIT_RECHARGE.getType())){
|
|
|
+ throw exception(DISTRIBUTOR_PAY_FAILED);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} catch (ServiceException e) {
|
|
|
- log.error("[分销商支付]{}", e);
|
|
|
+ log.error("[分销商支付]", e);
|
|
|
throw new ServiceException(e.getCode(), e.getMessage());
|
|
|
} catch (Exception e) {
|
|
|
log.error("[分销商支付]", e);
|