|
|
|
@@ -179,11 +179,14 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
|
|
|
|
@Override |
|
|
|
// @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) |
|
|
|
public ResultData redoSharingOrder(TenantEntity mallTenantEntity,WxProfitSharingOrder sharingOrder,WxPayOrder payOrder) { |
|
|
|
public ResultData redoSharingOrder(WxProfitSharingOrder sharingOrder,WxPayOrder payOrder) { |
|
|
|
|
|
|
|
if(!EnumProfitSharingOrderStatus.shareStatus().contains(sharingOrder.getSharingStatus())){ |
|
|
|
return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"分账状态不允许"); |
|
|
|
} |
|
|
|
|
|
|
|
WxMerchant merchant = wxMerchantService.getById(sharingOrder.getMerchantId()); |
|
|
|
|
|
|
|
Date currentDate = new Date(); |
|
|
|
if(EnumPayWay.PAY_WAY_WECHAT.getCode().equals(payOrder.getPayVendor()) |
|
|
|
&& DateUtils.daysBetween(payOrder.getCreateTime(),currentDate) > 30){ |
|
|
|
@@ -194,6 +197,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
updSharingOrder.setErrorMsg("微信支付超30天无法分账"); |
|
|
|
updSharingOrder.setUpdateTime(currentDate); |
|
|
|
wxProfitSharingOrderMapper.updateById(updSharingOrder); |
|
|
|
|
|
|
|
return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"微信支付超30天无法分账"); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -218,7 +222,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
EnumPayWay enumPayWay = EnumPayWay.getEnum(payOrder.getPayVendor()); |
|
|
|
EnumAppPlat enumPlat = enumPayWay.getPlat(); |
|
|
|
|
|
|
|
WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(mallTenantEntity, enumPlat); |
|
|
|
WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(sharingOrder, enumPlat); |
|
|
|
WxPayAccount payAccount = wxPayAccountMapper.selectById(cAppInfo.getPayId()); |
|
|
|
|
|
|
|
WxComposeChildOrderShare wxComposeChildOrderShare = null; |
|
|
|
@@ -244,13 +248,14 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
wxComposeChildOrderShare.setSellerAmount(sellerAmount); |
|
|
|
boolean isSeller = false; |
|
|
|
if(sellerAmount > 0){ |
|
|
|
WxProfitSharingReceiver receiver = getByMerchantAdmin(mallTenantEntity,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PRIVATE_SELL,payOrder.getTtPayWay(), payOrder.getMchType()); |
|
|
|
WxProfitSharingReceiver receiver = getByMerchantAdmin(sharingOrder,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PRIVATE_SELL,payOrder.getTtPayWay(), payOrder.getMchType()); |
|
|
|
if(receiver != null){ |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("type",payShareAdapterService.getShareAccount(receiver.getReceiverType()).getMessage()); |
|
|
|
jo.put("account",receiver.getReceiverAccount()); |
|
|
|
jo.put("amount", sellerAmount); |
|
|
|
jo.put("merchantId",receiver.getMerchantId()); |
|
|
|
jo.put("bTenantId",receiver.getTenantId()); |
|
|
|
jo.put("description",receiver.getId()); |
|
|
|
jo.put("isPrivate",EnumYesOrNo.YES.getCode()); |
|
|
|
receivers.add(jo); |
|
|
|
@@ -267,13 +272,14 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
} |
|
|
|
boolean isSystem = false; |
|
|
|
if(systemAmount > 0){ |
|
|
|
WxProfitSharingReceiver receiver = getByMerchantAdmin(mallTenantEntity,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PRIVATE_SYSTEM,payOrder.getTtPayWay(), payOrder.getMchType()); |
|
|
|
WxProfitSharingReceiver receiver = getByMerchantAdmin(sharingOrder,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PRIVATE_SYSTEM,payOrder.getTtPayWay(), payOrder.getMchType()); |
|
|
|
if(receiver != null){ |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("type",payShareAdapterService.getShareAccount(receiver.getReceiverType()).getMessage()); |
|
|
|
jo.put("account",receiver.getReceiverAccount()); |
|
|
|
jo.put("amount", systemAmount); |
|
|
|
jo.put("merchantId",receiver.getMerchantId()); |
|
|
|
jo.put("bTenantId",receiver.getTenantId()); |
|
|
|
jo.put("description",receiver.getId()); |
|
|
|
jo.put("isPrivate",EnumYesOrNo.YES.getCode()); |
|
|
|
receivers.add(jo); |
|
|
|
@@ -292,13 +298,14 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
} |
|
|
|
boolean isMall = false; |
|
|
|
if(mallAmount > 0){ |
|
|
|
WxProfitSharingReceiver receiver = getByMerchantAdmin(mallTenantEntity,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PUBLIC_ADMIN,payOrder.getTtPayWay(), payOrder.getMchType()); |
|
|
|
WxProfitSharingReceiver receiver = getByMerchantAdmin(sharingOrder,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PUBLIC_ADMIN,payOrder.getTtPayWay(), payOrder.getMchType()); |
|
|
|
if(receiver != null){ |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("type",payShareAdapterService.getShareAccount(receiver.getReceiverType()).getMessage()); |
|
|
|
jo.put("account",receiver.getReceiverAccount()); |
|
|
|
jo.put("amount", mallAmount); |
|
|
|
jo.put("merchantId",receiver.getMerchantId()); |
|
|
|
jo.put("bTenantId",receiver.getTenantId()); |
|
|
|
jo.put("description",receiver.getId()); |
|
|
|
jo.put("isPrivate",EnumYesOrNo.YES.getCode()); |
|
|
|
receivers.add(jo); |
|
|
|
@@ -315,13 +322,14 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
//商户所得 |
|
|
|
int shareAmount = wxComposeChildOrderShare.getShareAmount() + surplus; |
|
|
|
|
|
|
|
WxProfitSharingReceiver receiver = payShareAdapterService.getReceiver(mallTenantEntity,sharingOrder.getMerchantId(),payOrder.getTtPayWay(),payOrder.getMchType()); |
|
|
|
WxProfitSharingReceiver receiver = payShareAdapterService.getReceiver(merchant,sharingOrder.getMerchantId(),payOrder.getTtPayWay(),payOrder.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()); |
|
|
|
jo.put("amount", shareAmount); |
|
|
|
jo.put("merchantId",receiver.getMerchantId()); |
|
|
|
jo.put("bTenantId",receiver.getTenantId()); |
|
|
|
jo.put("description",receiver.getId()); |
|
|
|
receivers.add(jo); |
|
|
|
} |
|
|
|
@@ -363,6 +371,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
jo.put("account",payAccount.getSubMchId()); |
|
|
|
jo.put("amount", shareAmount); |
|
|
|
jo.put("merchantId",0); |
|
|
|
jo.put("bTenantId",payOrder.getTenantId()); |
|
|
|
jo.put("description",0); |
|
|
|
receivers.add(jo); |
|
|
|
}else if(EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType())){ |
|
|
|
@@ -372,6 +381,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
jo.put("account",receiver.getReceiverAccount()); |
|
|
|
jo.put("amount", shareAmount); |
|
|
|
jo.put("merchantId",receiver.getMerchantId()); |
|
|
|
jo.put("bTenantId",receiver.getTenantId()); |
|
|
|
jo.put("description",receiver.getId()); |
|
|
|
receivers.add(jo); |
|
|
|
} |
|
|
|
@@ -385,7 +395,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
result.setId(idworker.nextId()); |
|
|
|
result.updateTenantInfo(sharingOrder); |
|
|
|
result.setMerchantId(Long.valueOf(o.getString("merchantId"))); |
|
|
|
result.setBTenantId(mallTenantEntity.getTenantId()); |
|
|
|
result.setBTenantId(o.getString("bTenantId")); |
|
|
|
result.setSharingOrderId(sharingOrder.getId()); |
|
|
|
result.setSharingReceiverId(Long.valueOf(o.getString("description"))); |
|
|
|
result.setPayAmount(o.getInteger("amount")); |
|
|
|
@@ -397,7 +407,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
wxProfitSharingResultMapper.insert(result); |
|
|
|
}); |
|
|
|
}catch(Exception e){ |
|
|
|
logger.info("记账失败"+sharingOrder.getId()); |
|
|
|
logger.info("记录结果失败"+sharingOrder.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
return new ResultData(shareResult); |
|
|
|
@@ -461,7 +471,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
} |
|
|
|
|
|
|
|
//实际调用分账 |
|
|
|
ResultData resultData = redoSharingOrder(mallTenantEntity,record,payOrder); |
|
|
|
ResultData resultData = redoSharingOrder(record,payOrder); |
|
|
|
return resultData; |
|
|
|
} |
|
|
|
|
|
|
|
|