|
|
|
@@ -140,13 +140,13 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) |
|
|
|
public ResultData redoSharingOrder(WxProfitSharingOrder sharingOrder) { |
|
|
|
public ResultData redoSharingOrder(WxProfitSharingOrder sharingOrder,WxPayOrder payOrder) { |
|
|
|
|
|
|
|
if(!EnumProfitSharingOrderStatus.shareStatus().contains(sharingOrder.getSharingStatus())){ |
|
|
|
return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"分账状态不允许"); |
|
|
|
} |
|
|
|
|
|
|
|
PayShareAdapterService payShareAdapterService = payServiceFactory.getPayShareAdapterService(sharingOrder.getPayVendor(),sharingOrder.getPayVersion()); |
|
|
|
PayShareAdapterService payShareAdapterService = payServiceFactory.getPayShareAdapterService(payOrder.getPayVendor(),payOrder.getPayVersion()); |
|
|
|
Date currentDate = new Date(); |
|
|
|
PayShareResult shareResult = null; |
|
|
|
|
|
|
|
@@ -157,7 +157,13 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"未获取到达人佣金"); |
|
|
|
} |
|
|
|
|
|
|
|
WxComposeChildOrderShare wxComposeChildOrderShare = JSONObject.parseObject(sharingOrder.getPointDeduction(), WxComposeChildOrderShare.class); |
|
|
|
WxComposeChildOrderShare wxComposeChildOrderShare = null; |
|
|
|
if(sharingOrder.getSingleOrderId() != null){ |
|
|
|
wxComposeChildOrderShare = payOrder.getChildOrderShare(sharingOrder.getSingleOrderId()); |
|
|
|
}else{ |
|
|
|
wxComposeChildOrderShare = payOrder.getSingleChildOrderShare(); |
|
|
|
} |
|
|
|
|
|
|
|
wxComposeChildOrderShare.setCpsCommission(cpsCommission); |
|
|
|
//添加分账账号: 系统抽点,销售提成,商场扣点,平台(微信,抖音)抽佣 |
|
|
|
int systemAmount = wxComposeChildOrderShare.getSystemAmount();//系统抽点 |
|
|
|
@@ -170,6 +176,9 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
|
|
|
|
JSONArray receivers = new JSONArray();//分账参数json |
|
|
|
//todo |
|
|
|
// 1.总分模式下 不分账(只分给各个抽成方)如果各个抽成方为0 则直接解冻 |
|
|
|
// 2.总分模式下 分账 (分账给商家及各个抽成方) |
|
|
|
// 3.直连模式下 不分账和分账一样(只分账给各个抽成方)如果各种抽成金额为0 则直接解冻 |
|
|
|
if(systemAmount > 0){ |
|
|
|
//todo 查询系统抽点到账帐号 jsonArray.add() |
|
|
|
} |
|
|
|
@@ -181,7 +190,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
//需要判断当前订单收款帐号非商场抽点到账帐号 |
|
|
|
} |
|
|
|
WxProfitSharingReceiver receiver = payShareAdapterService.getReceiver(sharingOrder,sharingOrder.getMerchantId(),null,sharingOrder.getMchType()); |
|
|
|
if(EnumPayMchType.TOTAL.getCode().equals(sharingOrder.getMchType())){ |
|
|
|
if(EnumPayMchType.TOTAL.getCode().equals(payOrder.getMchType()) && EnumPayShare.YES.getCode().equals(payOrder.getShare())){ |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("type",payShareAdapterService.getShareAccount(receiver.getReceiverType()).getMessage()); |
|
|
|
jo.put("account",receiver.getReceiverAccount()); |
|
|
|
@@ -191,7 +200,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
receivers.add(jo); |
|
|
|
} |
|
|
|
|
|
|
|
EnumPayWay enumPayWay = EnumPayWay.getEnum(sharingOrder.getPayVendor()); |
|
|
|
EnumPayWay enumPayWay = EnumPayWay.getEnum(payOrder.getPayVendor()); |
|
|
|
EnumAppPlat enumPlat = enumPayWay.getPlat(); |
|
|
|
|
|
|
|
WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(sharingOrder, enumPlat); |
|
|
|
@@ -226,14 +235,14 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
updSharingOrder.setUpdateTime(currentDate); |
|
|
|
wxProfitSharingOrderMapper.updateById(updSharingOrder); |
|
|
|
|
|
|
|
if(EnumPayMchType.DIRECT.getCode().equals(sharingOrder.getMchType())){ |
|
|
|
if(EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType()) || EnumPayShare.NO.getCode().equals(payOrder.getShare())){ |
|
|
|
//如果是直连 把分给商户的钱记录下来 |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("type",payShareAdapterService.getShareAccount(receiver.getReceiverType()).getMessage()); |
|
|
|
jo.put("account",receiver.getReceiverAccount()); |
|
|
|
jo.put("amount", receiver.getSharingAmount()); |
|
|
|
jo.put("merchantId",receiver.getMerchantId()); |
|
|
|
jo.put("description",receiver.getId().toString()); //为重试做准备 |
|
|
|
jo.put("description",receiver.getId().toString()); |
|
|
|
receivers.add(jo); |
|
|
|
} |
|
|
|
try{ |
|
|
|
@@ -314,7 +323,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
} |
|
|
|
|
|
|
|
//实际调用分账 |
|
|
|
ResultData resultData = redoSharingOrder(record); |
|
|
|
ResultData resultData = redoSharingOrder(record,payOrder); |
|
|
|
return resultData; |
|
|
|
} |
|
|
|
|
|
|
|
|