diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java index 96c09bc19..e4119c8fd 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java @@ -136,33 +136,6 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ return wxAppinfo; } -// private WxProfitShareAppInoDto getAppinfo(WxProfitSharingOrder wxProfitSharingOrder) { -// WxAppinfo appinfo; -// Integer payWay; -// if (wxProfitSharingOrder.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode()) -// || wxProfitSharingOrder.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE_FINISH.getCode())){ -// WxPayOrder wxPayOrder = wxPayOrderMapper.selectById(wxProfitSharingOrder.getOrderId(),wxProfitSharingOrder.getTenantId()); -// if (wxPayOrder == null) { -// throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND.getCode(),"wxProfitSharingOrder["+wxProfitSharingOrder.getId()+"] 没有payOrder信息."); -// } -// appinfo = getAppinfo(wxPayOrder.getTenantId(),wxPayOrder.getPayVendor()); -// payWay = wxPayOrder.getPayVendor(); -// } else if(wxProfitSharingOrder.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_MULTI.getCode()) -// || wxProfitSharingOrder.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_MULTI_FINISH.getCode())){ -// WxCardSpend wxCardSpend = wxCardSpendMapper.selectById(wxProfitSharingOrder.getOrderId()); -// if (wxCardSpend == null) -// throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND.getCode(),"wxProfitSharingOrder["+wxProfitSharingOrder.getId()+"] 没有WxCardSpend信息."); -// appinfo = getAppinfo(wxCardSpend.getTenantId(),EnumCardSpendFrom.getPayWay(wxCardSpend.getPayFrom()).getCode()); -// payWay = EnumCardSpendFrom.getPayWay(wxCardSpend.getPayFrom()).getCode(); -// } else { -// throw new MallinkException(ErrorCode.PROFIT_SHARING_QUERY_UNKNOWN_TYPE); -// } -// WxProfitShareAppInoDto rt = new WxProfitShareAppInoDto(); -// rt.setAppinfo(appinfo); -// rt.setPayWay(payWay); -// return rt; -// } - @Override @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) public ResultData redoSharingOrder(WxProfitSharingOrder sharingOrder,WxPayOrder payOrder) { @@ -260,106 +233,8 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ wxProfitSharingResultMapper.insert(result); } return new ResultData(shareResult.getData()); - - - -// final IdWorker idworker = IdWorker.get(); -// -// if (!sharingOrder.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode()) && -// !sharingOrder.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_MULTI.getCode())) { -// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); -// } -// -// WxProfitShareAppInoDto dto = getAppinfo(sharingOrder); -// WxAppinfo appInfo = dto.getAppinfo(); -// WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); -// -// List receivers; -// -// try { -// receivers = JSONArray.parseArray(sharingOrder.getReceivers(), JSONObject.class); -// if (receivers.size() <= 0) -// return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); -// } catch (Exception e) { -// return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); -// } -// -// final WxProfitSharingOrder frecord = sharingOrder; -// List resultList = new ArrayList(); -// try { -// receivers.stream().forEach(receiver -> { -// Date currentDate = new Date(); -// WxProfitSharingResult result = new WxProfitSharingResult(); -// result.setId(idworker.nextId()); -// result.updateTenantInfo(frecord); -// result.setMerchantId(frecord.getMerchantId()); -// result.setSharingOrderId(frecord.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) { -// return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); -// } -// -// -// PayShareResult shareResult = payServiceFactory.getPayShareAdapterService(dto.getPayWay(),payAccount.getPayVersion()).haveReciversShare(appInfo, payAccount,frecord, -// sharingOrder.getTransactionId(), JSONArray.parseArray(JSON.toJSONString(receivers)), EnumProfitSharingOrderType.getEnum(sharingOrder.getType())); -// WxProfitSharingOrder updSharingOrder = new WxProfitSharingOrder(); -// updSharingOrder.updateTenantInfo(sharingOrder); -// updSharingOrder.setId(sharingOrder.getId()); -// updSharingOrder.setOutSettleNo(frecord.getOutSettleNo()); -// if (!shareResult.isSuccess()) { -// updSharingOrder.setSharingStatus(shareResult.getCode()); -// updSharingOrder.setErrorMsg("REDO:"+shareResult.getMsg()); -// updSharingOrder.setUpdateTime(new Date()); -// wxProfitSharingOrderMapper.updateById(updSharingOrder); -// return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),updSharingOrder.getErrorMsg()); -// } -// updSharingOrder.setSharingOrderNo(shareResult.getShareOrderNo()); -// updSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_ACCEPTED.getCode()); -// updSharingOrder.setErrorMsg("REDO:重试分账成功"); -// updSharingOrder.setUpdateTime(new Date()); -// wxProfitSharingOrderMapper.updateById(updSharingOrder); -// for (WxProfitSharingResult result:resultList) { -// wxProfitSharingResultMapper.insert(result); -// } -// return new ResultData(shareResult.getData()); } -// @Override -// public ResultData redoFinishSharingOrder(WxProfitSharingOrder sharingOrder) { -// if (!sharingOrder.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE_FINISH.getCode())) { -// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); -// } -// WxProfitShareAppInoDto dto = getAppinfo(sharingOrder); -// WxAppinfo appInfo = dto.getAppinfo(); -// WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); -// -// PayShareResult shareResult = payServiceFactory.getPayShareAdapterService(dto.getPayWay(),payAccount.getPayVersion()).noReciverShare(appInfo,payAccount,sharingOrder,sharingOrder.getTransactionId(),sharingOrder.getPayAmount()); -// -// WxProfitSharingOrder updSharingOrder = new WxProfitSharingOrder(); -// updSharingOrder.updateTenantInfo(sharingOrder); -// updSharingOrder.setId(sharingOrder.getId()); -// updSharingOrder.setOutSettleNo(sharingOrder.getOutSettleNo()); -// if (!shareResult.isSuccess()) { -// updSharingOrder.setSharingStatus(shareResult.getCode()); -// updSharingOrder.setErrorMsg("REDO:"+shareResult.getMsg()); -// updSharingOrder.setUpdateTime(new Date()); -// wxProfitSharingOrderMapper.updateById(updSharingOrder); -// return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),updSharingOrder.getErrorMsg()); -// } -// updSharingOrder.setSharingOrderNo(shareResult.getShareOrderNo()); -// updSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_ACCEPTED.getCode()); -// updSharingOrder.setErrorMsg("REDO:重试分账成功"); -// updSharingOrder.setUpdateTime(new Date()); -// wxProfitSharingOrderMapper.updateById(updSharingOrder); -// return new ResultData(shareResult.getData()); -// } - @Override // @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) public ResultData createSharingOrder(WxSharingOrderDto sharingOrderDto,WxPayOrder payOrder) { @@ -477,68 +352,6 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ return new ResultData(payShareQueryResult.getData()); } - // 分账完结 -// @Override -// @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) -// public ResultData finishSharingOrder(WxPayOrder payOrder,WxSharingOrderDto sharingOrderDto,Integer payWay,Integer share) { -// final IdWorker idworker = IdWorker.get(); -// -// if ((EnumPayWay.PAY_WAY_WECHAT.getCode().equals(payWay) -// || EnumPayWay.PAY_WAY_WECHAT_MA.getCode().equals(payWay) -// || EnumPayWay.PAY_WAY_WECHAT_WAP.getCode().equals(payWay)) -// && EnumPayShare.NO.getCode().equals(share)){ -// logger.info("微信支付不分账模式下无需分账"); -// return new ResultData(); -// } -// -// if (!sharingOrderDto.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE_FINISH.getCode()) -// && !sharingOrderDto.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_MULTI_FINISH.getCode())){ -// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); -// } -// -// WxAppinfo appInfo = getAppinfo(sharingOrderDto.getTenantId(),payWay); -// WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); -// PayShareAdapterService payShareAdapterService = payServiceFactory.getPayShareAdapterService(payWay,payAccount.getPayVersion()); -// -// //分账检查是否已创建分账订单 -// WxProfitSharingOrder record = new WxProfitSharingOrder(); -// //创建分账订单 -// Date currentDate = new Date(); -// record.setId(idworker.nextId()); -// record.updateTenantInfo(payAccount); -// record.setTransactionId(sharingOrderDto.getTransactionId()); -// record.setPayAmount(sharingOrderDto.getPayAmount()); -// record.setMerchantId(sharingOrderDto.getMerchantId()); -// record.setOrderId(sharingOrderDto.getOrderId()); -// record.setSharingStatus(payShareAdapterService.getSharingOrderInitialStatus()); -// record.setCreateTime(currentDate); -// record.setUpdateTime(currentDate); -// record.setPayTimeStart(sharingOrderDto.getPayTimeStart()); -// record.setPayTimeEnd(sharingOrderDto.getPayTimeEnd()); -// record.setType(sharingOrderDto.getType()); -// wxProfitSharingOrderMapper.insert(record); -// -// //分账提交 -// PayShareResult shareResult = payShareAdapterService.noReciverShare(appInfo,payAccount,record,sharingOrderDto.getTransactionId(),sharingOrderDto.getShareAmount()); -// WxProfitSharingOrder updSharingOrder = new WxProfitSharingOrder(); -// updSharingOrder.updateTenantInfo(record); -// updSharingOrder.setId(record.getId()); -// updSharingOrder.setOutSettleNo(record.getOutSettleNo()); -// if (!shareResult.isSuccess()) { -// updSharingOrder.setSharingStatus(shareResult.getCode()); -// updSharingOrder.setErrorMsg(shareResult.getMsg()); -// updSharingOrder.setUpdateTime(new Date()); -// wxProfitSharingOrderMapper.updateById(updSharingOrder); -// return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),updSharingOrder.getErrorMsg()); -// } -// -// updSharingOrder.setSharingOrderNo(shareResult.getShareOrderNo()); -// updSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_ACCEPTED.getCode()); -// updSharingOrder.setUpdateTime(new Date()); -// wxProfitSharingOrderMapper.updateById(updSharingOrder); -// return new ResultData(shareResult.getData()); -// } - @Override public PageInfo listAsPage(WxProfitSharingOrderQueryVo order, Integer pageIndex, Integer pageSize) { return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxProfitSharingOrderMapper.findOrderList(order));