|
|
|
@@ -3,6 +3,7 @@ package com.simple.service.impl; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
@@ -10,6 +11,7 @@ import com.simple.common.ErrorCode; |
|
|
|
import com.simple.common.ResultData; |
|
|
|
import com.simple.domain.po.*; |
|
|
|
import com.simple.enums.EnumPayDomain; |
|
|
|
import com.simple.enums.EnumProfitSharingReceiverType; |
|
|
|
import com.simple.enums.EnumProfitSharingStatus; |
|
|
|
import com.simple.exception.MallinkException; |
|
|
|
import com.simple.mapper.*; |
|
|
|
@@ -48,7 +50,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject errorMap = JSON.parseObject( |
|
|
|
final JSONObject errorMap = JSON.parseObject( |
|
|
|
"{\"SYSTEMERROR\":{\"detail\":\"接口返回错误\",\"reason\":\"系统超时\",\"resolution\":\"系统异常,请用相同参数重新调用\"}," + |
|
|
|
"\"AMOUNT_OVERDUE\":{\"detail\":\"分账金额超限\",\"reason\":\"分账金额大于可分金额 或大于分账最大比例 \",\"resolution\":\"请调整分账金额\"}," + |
|
|
|
"\"RECEIVER_INVALID\":{\"detail\":\"分账接收方非法 \",\"reason\":\"未配置分账接收方\",\"resolution\":\"分账接收方在分账之前需要进行添加\"}," + |
|
|
|
@@ -88,6 +90,14 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
wxProfitSharingOrderMapper.deleteByPrimaryKey(id); |
|
|
|
} |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxPayOrderMapper wxPayOrderMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void test() { |
|
|
|
createSharingOrder(wxAppinfoMapper.selectByPrimaryKey(new Long(1L)),wxPayOrderMapper.selectByPrimaryKey(new Long(190403470006681600L))); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultData createSharingOrder(WxAppinfo subAppInfo, WxPayOrder wxPayOrder) { |
|
|
|
final IdWorker idworker = IdWorker.get(); |
|
|
|
@@ -101,8 +111,10 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
if (record == null) { |
|
|
|
//创建分账订单 |
|
|
|
Date currentDate = new Date(); |
|
|
|
record = new WxProfitSharingOrder(); |
|
|
|
record.setId(idworker.nextId()); |
|
|
|
record.setTenantId(wxPayOrder.getTenantId()); |
|
|
|
record.setTransactionId(wxPayOrder.getTransactionId()); |
|
|
|
record.setOrderId(wxPayOrder.getId().toString()); |
|
|
|
record.setPayAmount(wxPayOrder.getPayAmount()); |
|
|
|
record.setMerchantId(wxOrder.getMerchantId().toString()); |
|
|
|
@@ -115,13 +127,15 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
} |
|
|
|
|
|
|
|
WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(subAppInfo.getPayId()); |
|
|
|
WxPayAccount mainPayAccount = wxPayAccountMapper.selectByPrimaryKey(EnumPayDomain.PAY_DOMAIN_MASTER_ACCOUNT_ID.getCode()); |
|
|
|
WxAppinfo mainAppInfo = wxAppinfoMapper.selectByPrimaryKey(EnumPayDomain.PAY_DOMAIN_MASTER_APPINFO_ID.getCode()); |
|
|
|
//WxPayAccount mainPayAccount = wxPayAccountMapper.selectByPrimaryKey(new Long(EnumPayDomain.PAY_DOMAIN_MASTER_ACCOUNT_ID.getCode())); |
|
|
|
//WxAppinfo mainAppInfo = wxAppinfoMapper.selectByPrimaryKey(new Long(EnumPayDomain.PAY_DOMAIN_MASTER_APPINFO_ID.getCode())); |
|
|
|
|
|
|
|
//分账提交 |
|
|
|
WxProfitSharingP wxProfitSharingP = new WxProfitSharingP(); |
|
|
|
wxProfitSharingP.setAppid(mainAppInfo.getAppId()); |
|
|
|
wxProfitSharingP.setMch_id(mainPayAccount.getMchId()); |
|
|
|
//wxProfitSharingP.setAppid(mainAppInfo.getAppId()); |
|
|
|
//wxProfitSharingP.setMch_id(mainPayAccount.getMchId()); |
|
|
|
wxProfitSharingP.setAppid(subAppInfo.getAppId()); |
|
|
|
wxProfitSharingP.setMch_id(payAccount.getMchId()); |
|
|
|
wxProfitSharingP.setSub_appid(subAppInfo.getAppId()); |
|
|
|
wxProfitSharingP.setSub_mch_id(payAccount.getMchId()); |
|
|
|
wxProfitSharingP.setNonce_str(Utility.generate32UUID()); |
|
|
|
@@ -136,15 +150,18 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
if (wxProfitSharingReceiverList.size()<=0 || wxProfitSharingReceiverList.size() > 50) { |
|
|
|
throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getMessage()); |
|
|
|
} |
|
|
|
JSONObject receivers = new JSONObject(); |
|
|
|
JSONArray receivers = new JSONArray(); |
|
|
|
List <WxProfitSharingResult> resultList = new ArrayList<WxProfitSharingResult>(); |
|
|
|
for (int i=0;i<=wxProfitSharingReceiverList.size();i++){ |
|
|
|
for (int i=0;i<wxProfitSharingReceiverList.size();i++){ |
|
|
|
WxProfitSharingReceiver receiver = wxProfitSharingReceiverList.get(i); |
|
|
|
Date currentDate = new Date(); |
|
|
|
receivers.put("type",receiver.getReceiverType()); |
|
|
|
receivers.put("acount",receiver.getReceiverAccount()); |
|
|
|
receivers.put("amount",record.getPayAmount()); //temp: sharing all money with only owner |
|
|
|
receivers.put("description",receiver.getReceiverComments()); |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("type",EnumProfitSharingReceiverType.getEnum(receiver.getReceiverType()).getMessage()); |
|
|
|
jo.put("acount",receiver.getReceiverAccount()); |
|
|
|
jo.put("amount",record.getPayAmount()); //temp: sharing all money with only owner |
|
|
|
jo.put("description",receiver.getReceiverComments()); |
|
|
|
receivers.add(jo); |
|
|
|
|
|
|
|
WxProfitSharingResult result = new WxProfitSharingResult(); |
|
|
|
|
|
|
|
result.setId(idworker.nextId()); |
|
|
|
|