Преглед изворни кода

[支付][新增]:删除分账账户接口

release_toaliyun_real
hupeng пре 7 година
родитељ
комит
5b1e60b071
4 измењених фајлова са 87 додато и 15 уклоњено
  1. +1
    -1
      mallinkService/src/main/java/com/simple/common/ErrorCode.java
  2. +1
    -1
      mallinkService/src/main/java/com/simple/enums/EnumProfitSharingType.java
  3. +4
    -6
      mallinkService/src/main/java/com/simple/service/impl/WxProfitSharingOrderServiceImpl.java
  4. +81
    -7
      mallinkService/src/main/java/com/simple/service/impl/WxProfitSharingReceiverServiceImpl.java

+ 1
- 1
mallinkService/src/main/java/com/simple/common/ErrorCode.java Прегледај датотеку

@@ -158,7 +158,7 @@ public enum ErrorCode{
PROFIT_SHARING_QUERY_APPLY_FAILED(12035, "分账查询业务失败"), PROFIT_SHARING_QUERY_APPLY_FAILED(12035, "分账查询业务失败"),
PROFIT_SHARING_QUERY_RETURN_INVALID(12036, "分账查询返回校验失败"), PROFIT_SHARING_QUERY_RETURN_INVALID(12036, "分账查询返回校验失败"),
PROFIT_SHARING_RECEIVER_ADD_FAILED(12037, "分账账户添加失败"), PROFIT_SHARING_RECEIVER_ADD_FAILED(12037, "分账账户添加失败"),
PROFIT_SHARING_RECEIVER_DEL_FAILED(12037, "分账账户删除失败"),
/** /**
* 核销 * 核销
*/ */


+ 1
- 1
mallinkService/src/main/java/com/simple/enums/EnumProfitSharingType.java Прегледај датотеку

@@ -4,7 +4,7 @@ package com.simple.enums;
* Created by Stormeye on 2018/08/09. * Created by Stormeye on 2018/08/09.
*/ */
public enum EnumProfitSharingType { public enum EnumProfitSharingType {
PROFIT_SHARING_TYPE_WEICHAT(1, "MERCHANT_ID"),
PROFIT_SHARING_TYPE_WECHAT(1, "MERCHANT_ID"),
PROFIT_SHARING_TYPE_BANK(2, "PERSONAL_WECHATID"), PROFIT_SHARING_TYPE_BANK(2, "PERSONAL_WECHATID"),
; ;




+ 4
- 6
mallinkService/src/main/java/com/simple/service/impl/WxProfitSharingOrderServiceImpl.java Прегледај датотеку

@@ -186,7 +186,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
//添加分账接受方 //添加分账接受方
WxProfitSharingReceiver wxProfitSharingReceiver = new WxProfitSharingReceiver(); WxProfitSharingReceiver wxProfitSharingReceiver = new WxProfitSharingReceiver();
wxProfitSharingReceiver.setMerchantId(wxOrder.getMerchantId().toString()); wxProfitSharingReceiver.setMerchantId(wxOrder.getMerchantId().toString());
wxProfitSharingReceiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WEICHAT.getCode());
wxProfitSharingReceiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode());
List<WxProfitSharingReceiver> wxProfitSharingReceiverList = wxProfitSharingReceiverMapper.findList(wxProfitSharingReceiver); List<WxProfitSharingReceiver> wxProfitSharingReceiverList = wxProfitSharingReceiverMapper.findList(wxProfitSharingReceiver);
if (wxProfitSharingReceiverList.size()<=0 || wxProfitSharingReceiverList.size() > 50) { if (wxProfitSharingReceiverList.size()<=0 || wxProfitSharingReceiverList.size() > 50) {
throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getMessage()); throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getMessage());
@@ -198,14 +198,14 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
Date currentDate = new Date(); Date currentDate = new Date();
JSONObject jo = new JSONObject(); JSONObject jo = new JSONObject();
jo.put("type",EnumProfitSharingReceiverType.getEnum(receiver.getReceiverType()).getMessage()); jo.put("type",EnumProfitSharingReceiverType.getEnum(receiver.getReceiverType()).getMessage());
jo.put("acount",receiver.getReceiverAccount());
jo.put("account",receiver.getReceiverAccount());
jo.put("amount",record.getPayAmount()); //temp: sharing all money with only owner jo.put("amount",record.getPayAmount()); //temp: sharing all money with only owner
jo.put("description",receiver.getReceiverComments()); jo.put("description",receiver.getReceiverComments());
receivers.add(jo); receivers.add(jo);


WxProfitSharingResult result = new WxProfitSharingResult(); WxProfitSharingResult result = new WxProfitSharingResult();


result.setId(idworker.nextId());
result.setId(idworker.nextId());7
result.setSharingOrderId(record.getSharingOrderId()); result.setSharingOrderId(record.getSharingOrderId());
result.setSharingReceiverId(receiver.getId().toString()); result.setSharingReceiverId(receiver.getId().toString());
result.setCreateTime(currentDate); result.setCreateTime(currentDate);
@@ -340,9 +340,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ


return new ResultData(returnMap); return new ResultData(returnMap);


} catch (RuntimeException e) {
throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage());
} catch (Exception e) {
}catch (Exception e) {
throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage());
} }
} }


+ 81
- 7
mallinkService/src/main/java/com/simple/service/impl/WxProfitSharingReceiverServiceImpl.java Прегледај датотеку

@@ -2,6 +2,7 @@ package com.simple.service.impl;


import java.util.*; import java.util.*;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
@@ -29,10 +30,23 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.simple.common.IdWorker; import com.simple.common.IdWorker;




@Service @Service
public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiverService { public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiverService {
@Autowired

final JSONObject errorMap = JSON.parseObject("{" +
"\"SYSTEMERROR\":{\"detail\":\"接口返回错误\",\"reason\":\"系统超时\",\"resolution\":\"系统异常,请用相同参数重新调用\"}," +
"\"PARAM_ERROR\":{\"detail\":\"参数错误\\t\",\"reason\":\"请求参数未按指引进行填写\",\"resolution\":\"请求参数错误,请重新检查再调用分账接口\"}," +
"\"INVALID_REQUEST\":{\"detail\":\"请求不合法\",\"reason\":\"参数中APPID或MCHID不存在等 \",\"resolution\":\"请重新检查再调用分账接口\"}," +
"\"OPENID_MISMATCH \":{\"detail\":\"OPENID错误\",\"reason\":\"OPENID与APPID不匹配\",\"resolution\":\"请检查OPENID是否正确\"}," +
"\"FREQUENCY_LIMITED \":{\"detail\":\"频率限制\",\"reason\":\"请求过多被频率限制\",\"resolution\":\"该笔请求未受理,请降低频率后原单重试\"}," +
"\"NOAUTH \":{\"detail\":\"无分账权限\",\"reason\":\"未开通分账权限\",\"resolution\":\"请先开通分账\"}," +
"\"USER_NOTEXIST\":{\"detail\":\"分账接受方不存在\",\"reason\":\"分账接受方不存在\",\"resolution\":\"请确认分账接收方类型或者账号无误后重试\"}}");



@Autowired
WxProfitSharingReceiverMapper wxProfitSharingReceiverMapper; WxProfitSharingReceiverMapper wxProfitSharingReceiverMapper;
@Autowired @Autowired
WxAppinfoMapper wxAppinfoMapper; WxAppinfoMapper wxAppinfoMapper;
@@ -83,7 +97,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv


WxProfitSharingReceiver receiver = new WxProfitSharingReceiver(); WxProfitSharingReceiver receiver = new WxProfitSharingReceiver();
receiver.setMerchantId(merchant.getId().toString()); receiver.setMerchantId(merchant.getId().toString());
receiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WEICHAT.getCode());
receiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode());
receiver.setId(IdWorker.get().nextId()); receiver.setId(IdWorker.get().nextId());
receiver.setCreateTime(new Date()); receiver.setCreateTime(new Date());
receiver.setUpdateTime(new Date()); receiver.setUpdateTime(new Date());
@@ -92,7 +106,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
receiver.setReceiverType(EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_MERCHANT_ID.getCode()); receiver.setReceiverType(EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_MERCHANT_ID.getCode());
receiver.setTrueName(merchant.getName()); receiver.setTrueName(merchant.getName());


//分账提交
//添加分账账户
WxProfitSharingReceiverP wxProfitSharingReceiverP = new WxProfitSharingReceiverP(); WxProfitSharingReceiverP wxProfitSharingReceiverP = new WxProfitSharingReceiverP();
//wxProfitSharingP.setAppid(mainAppInfo.getAppId()); //wxProfitSharingP.setAppid(mainAppInfo.getAppId());
//wxProfitSharingP.setMch_id(mainPayAccount.getMchId()); //wxProfitSharingP.setMch_id(mainPayAccount.getMchId());
@@ -105,7 +119,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv


JSONObject receiverJSON = new JSONObject(); JSONObject receiverJSON = new JSONObject();
receiverJSON.put("type",EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_MERCHANT_ID.getMessage()); receiverJSON.put("type",EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_MERCHANT_ID.getMessage());
receiverJSON.put("acount",merchant.getReceiverAccount());
receiverJSON.put("account",merchant.getReceiverAccount());
receiverJSON.put("name",merchant.getName()); receiverJSON.put("name",merchant.getName());


wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString()); wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString());
@@ -123,7 +137,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
} }


if (!WxPayment.verifyNotify(returnMap,payAccount.getApiKey())){ if (!WxPayment.verifyNotify(returnMap,payAccount.getApiKey())){
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), ErrorCode.PROFIT_SHARING_RETURN_INVALID.getMessage());
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getMessage());
} }


String result_code = returnMap.get("result_code"); String result_code = returnMap.get("result_code");
@@ -137,7 +151,67 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv


@Override @Override
public ResultData delReceiver(WxMerchant merchant) { public ResultData delReceiver(WxMerchant merchant) {
return new ResultData();
WxAppinfo subAppInfo = new WxAppinfo();
subAppInfo.setTenantId(merchant.getTenantId());
subAppInfo.setType(EnumAppType.C.getCode());

subAppInfo = wxAppinfoMapper.findList(subAppInfo).get(0);
WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(subAppInfo.getPayId());
//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()));


WxProfitSharingReceiver receiver = new WxProfitSharingReceiver();
receiver.setMerchantId(merchant.getId().toString());
receiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode());
receiver.setReceiverAccount(merchant.getReceiverAccount().toString());
receiver.setReceiverType(EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_MERCHANT_ID.getCode());

receiver = wxProfitSharingReceiverMapper.selectOne(receiver);

if (receiver == null)
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage());

//删除分账账户
WxProfitSharingReceiverP wxProfitSharingReceiverP = new WxProfitSharingReceiverP();
//wxProfitSharingP.setAppid(mainAppInfo.getAppId());
//wxProfitSharingP.setMch_id(mainPayAccount.getMchId());
wxProfitSharingReceiverP.setAppid(subAppInfo.getAppId());
wxProfitSharingReceiverP.setMch_id(payAccount.getMchId());
wxProfitSharingReceiverP.setSub_appid(subAppInfo.getAppId());
wxProfitSharingReceiverP.setSub_mch_id(payAccount.getMchId());
wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID());


JSONObject receiverJSON = new JSONObject();
receiverJSON.put("type",EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_MERCHANT_ID.getMessage());
receiverJSON.put("account",merchant.getReceiverAccount());

wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString());
String response;
try {
wxProfitSharingReceiverP.setSign(WxPayment.createSign(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey()));
response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP));
}catch (Exception e) {
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED, e.getMessage());
}
Map<String, String> returnMap = WxPayment.xmlToMap(response);
String return_code = returnMap.get("return_code");
if (!"SUCCESS".equals(return_code)) {
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("return_msg"));
}

if (!WxPayment.verifyNotify(returnMap,payAccount.getApiKey())){
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage());
}

String result_code = returnMap.get("result_code");
if (!"SUCCESS".equals(result_code)) {
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("result_msg"));
}

wxProfitSharingReceiverMapper.deleteByPrimaryKey(receiver);
return new ResultData(returnMap);
} }




Loading…
Откажи
Сачувај