@@ -176,10 +176,34 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
StringBuffer sb = new StringBuffer("[{").append("\"description\":").append(receiver.getId()).append(",\"amount\":").append(sharingOrder.getPayAmount());
recordJsonArray = JSONArray.parseArray(sb.toString());
}
List<WxProfitSharingResult> resultList = new ArrayList<WxProfitSharingResult>();
if(jsonArray == null || jsonArray.isEmpty()){
shareResult = payShareAdapterService.noReciverShare(cAppInfo, payAccount, sharingOrder);
}else{
if (null != recordJsonArray && recordJsonArray.size() > 0 ) {
final IdWorker idworker = IdWorker.get();
Date currentDate = new Date();
try {
recordJsonArray.stream().forEach(obj -> {
JSONObject receiver =(JSONObject) obj;
WxProfitSharingResult result = new WxProfitSharingResult();
result.setId(idworker.nextId());
result.updateTenantInfo(sharingOrder);
result.setMerchantId(sharingOrder.getMerchantId());
result.setSharingOrderId(sharingOrder.getId());
result.setSharingReceiverId(Long.valueOf(receiver.getString("description")));
result.setPayAmount(receiver.getInteger("amount"));
result.setCreateTime(currentDate);
result.setUpdateTime(currentDate);
result.setSharingStatus(EnumProfitSharingResultStatus.PROFIT_SHARING_RESULT_PENDING.getCode());
resultList.add(result);
});
}catch (Exception e) {
logger.error("分账详细信息为null",e);
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID);
}
}
shareResult = payShareAdapterService.haveReciversShare(cAppInfo, payAccount, sharingOrder, jsonArray, wxPayOrder.getMchType());
}
@@ -203,34 +227,10 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
updSharingOrder.setUpdateTime(new Date());
wxProfitSharingOrderMapper.updateById(updSharingOrder);
if (null == recordJsonArray || recordJsonArray.isEmpty()) {
return new ResultData(shareResult.getData());
}
List<WxProfitSharingResult> resultList = new ArrayList<WxProfitSharingResult>();
final IdWorker idworker = IdWorker.get();
Date currentDate = new Date();
try {
recordJsonArray.stream().forEach(obj -> {
JSONObject receiver =(JSONObject) obj;
WxProfitSharingResult result = new WxProfitSharingResult();
result.setId(idworker.nextId());
result.updateTenantInfo(sharingOrder);
result.setMerchantId(sharingOrder.getMerchantId());
result.setSharingOrderId(sharingOrder.getId());
result.setSharingReceiverId(Long.valueOf(receiver.getString("description")));
result.setPayAmount(receiver.getInteger("amount"));
result.setCreateTime(currentDate);
result.setUpdateTime(currentDate);
result.setSharingStatus(EnumProfitSharingResultStatus.PROFIT_SHARING_RESULT_PENDING.getCode());
resultList.add(result);
});
}catch (Exception e) {
logger.error("分账详细信息为null",e);
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID);
}
for (WxProfitSharingResult result:resultList) {
wxProfitSharingResultMapper.insert(result);
if (resultList.size() > 0 ) {
for (WxProfitSharingResult result:resultList) {
wxProfitSharingResultMapper.insert(result);
}
}
return new ResultData(shareResult.getData());
}