Parcourir la source

[支付][添加]:核销后进行分账操作

release_toaliyun_real
hupeng il y a 7 ans
Parent
révision
fb36635285
6 fichiers modifiés avec 65 ajouts et 26 suppressions
  1. +8
    -0
      mallinkService/src/main/java/com/simple/pay/WxProfitSharingP.java
  2. +8
    -0
      mallinkService/src/main/java/com/simple/pay/WxProfitSharingQueryP.java
  3. +9
    -0
      mallinkService/src/main/java/com/simple/pay/WxProfitSharingReceiverP.java
  4. +20
    -8
      mallinkService/src/main/java/com/simple/service/impl/WxCouponOrderServiceImpl.java
  5. +11
    -10
      mallinkService/src/main/java/com/simple/service/impl/WxProfitSharingOrderServiceImpl.java
  6. +9
    -8
      mallinkService/src/main/java/com/simple/service/impl/WxProfitSharingReceiverServiceImpl.java

+ 8
- 0
mallinkService/src/main/java/com/simple/pay/WxProfitSharingP.java Voir le fichier

@@ -14,6 +14,7 @@ public class WxProfitSharingP implements Serializable {
private String sub_appid; // 子公众账号ID private String sub_appid; // 子公众账号ID
private String nonce_str; // 随机字符串 private String nonce_str; // 随机字符串
private String sign; // 签名 private String sign; // 签名
private String sign_type; // 签名方法
private String transaction_id ; // 支付订单号 private String transaction_id ; // 支付订单号
private String out_trade_no; // 商户订单号 private String out_trade_no; // 商户订单号
private String receivers; // 分账接收方 private String receivers; // 分账接收方
@@ -64,6 +65,13 @@ public class WxProfitSharingP implements Serializable {
this.sign = sign; this.sign = sign;
} }


public String getSign_type() {
return sign_type;
}

public void setSign_type(String sign_type) {
this.sign_type = sign_type;
}
public String getTransaction_id() { public String getTransaction_id() {
return transaction_id; return transaction_id;
} }


+ 8
- 0
mallinkService/src/main/java/com/simple/pay/WxProfitSharingQueryP.java Voir le fichier

@@ -12,6 +12,7 @@ public class WxProfitSharingQueryP implements Serializable {
private String sub_mch_id; // 子商户号 private String sub_mch_id; // 子商户号
private String nonce_str; // 随机字符串 private String nonce_str; // 随机字符串
private String sign; // 签名 private String sign; // 签名
private String sign_type; // 签名方法
private String transaction_id ; // 支付订单号 private String transaction_id ; // 支付订单号
private String out_trade_no; // 商户分账单号 private String out_trade_no; // 商户分账单号


@@ -45,6 +46,13 @@ public class WxProfitSharingQueryP implements Serializable {
public void setSign(String sign) { public void setSign(String sign) {
this.sign = sign; this.sign = sign;
} }
public String getSign_type() {
return sign_type;
}

public void setSign_type(String sign_type) {
this.sign_type = sign_type;
}


public String getTransaction_id() { public String getTransaction_id() {
return transaction_id; return transaction_id;


+ 9
- 0
mallinkService/src/main/java/com/simple/pay/WxProfitSharingReceiverP.java Voir le fichier

@@ -14,6 +14,7 @@ public class WxProfitSharingReceiverP implements Serializable {
private String sub_appid; // 子公众账号ID private String sub_appid; // 子公众账号ID
private String nonce_str; // 随机字符串 private String nonce_str; // 随机字符串
private String sign; // 签名 private String sign; // 签名
private String sign_type; // 签名方法
private String receiver; // 分账接收方 private String receiver; // 分账接收方


public String getMch_id() { public String getMch_id() {
@@ -62,6 +63,14 @@ public class WxProfitSharingReceiverP implements Serializable {
this.sign = sign; this.sign = sign;
} }


public String getSign_type() {
return sign_type;
}

public void setSign_type(String sign_type) {
this.sign_type = sign_type;
}

public String getReceiver() { public String getReceiver() {
return receiver; return receiver;
} }


+ 20
- 8
mallinkService/src/main/java/com/simple/service/impl/WxCouponOrderServiceImpl.java Voir le fichier

@@ -14,11 +14,11 @@ import com.simple.domain.vo.WxCouponOrderCVo;
import com.simple.domain.vo.WxCouponOrderCarCVo; import com.simple.domain.vo.WxCouponOrderCarCVo;
import com.simple.enums.EnumCouponOrderStatus; import com.simple.enums.EnumCouponOrderStatus;
import com.simple.enums.EnumCouponSendType; import com.simple.enums.EnumCouponSendType;
import com.simple.enums.EnumPayShare;
import com.simple.enums.EnumPayStatus;
import com.simple.exception.MallinkException; import com.simple.exception.MallinkException;
import com.simple.mapper.*; import com.simple.mapper.*;
import com.simple.service.WxCouponOrderService;
import com.simple.service.WxCouponSendService;
import com.simple.service.WxOrderService;
import com.simple.service.*;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -58,6 +58,13 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
@Autowired @Autowired
WxCouponSendService wxCouponSendService; WxCouponSendService wxCouponSendService;


@Autowired
WxProfitSharingOrderService wxProfitSharingOrderService;

@Autowired
WxPayOrderMapper wxPayOrderMapper;


@Override @Override
public PageInfo<WxCouponOrder> listAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize) { public PageInfo<WxCouponOrder> listAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findList(record)); return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findList(record));
@@ -337,22 +344,27 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
// 核销发券 // 核销发券
wxCouponSendService.sendCouponToUser(wxMerchantBUser.getTenantId(), wxOrder.getCUserId(), EnumCouponSendType.COUPON_VERIFY.getCode()); wxCouponSendService.sendCouponToUser(wxMerchantBUser.getTenantId(), wxOrder.getCUserId(), EnumCouponSendType.COUPON_VERIFY.getCode());



// 微信分账
WxPayOrder wxPayOrder = new WxPayOrder();
wxPayOrder.setOrderId(wxCouponOrder.getOrderId());
wxPayOrder.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode());
wxPayOrder = wxPayOrderMapper.selectOne(wxPayOrder);
if (wxPayOrder == null)
throw new MallinkException(ErrorCode.PAY_ORDER_NOT_FOUND);
if (wxPayOrder.getShare() == EnumPayShare.YES.getCode())
wxProfitSharingOrderService.createSharingOrder(wxPayOrder);
return new ResultData(wxCouponOrder); return new ResultData(wxCouponOrder);
} }


@Override @Override
public List<CUserDateAmountVo> queryPriceTotalGroup(String tenantId, Date startTime, Date endTime) { public List<CUserDateAmountVo> queryPriceTotalGroup(String tenantId, Date startTime, Date endTime) {
return wxCouponOrderMapper.queryPriceTotalGroup(tenantId, startTime, endTime); return wxCouponOrderMapper.queryPriceTotalGroup(tenantId, startTime, endTime);
} }




@Override @Override
public int queryPriceTotal(String tenantId, Date startTime, Date endTime) { public int queryPriceTotal(String tenantId, Date startTime, Date endTime) {
return wxCouponOrderMapper.queryPriceTotal(tenantId, startTime, endTime); return wxCouponOrderMapper.queryPriceTotal(tenantId, startTime, endTime);
} }


} }

+ 11
- 10
mallinkService/src/main/java/com/simple/service/impl/WxProfitSharingOrderServiceImpl.java Voir le fichier

@@ -178,7 +178,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
wxProfitSharingP.setNonce_str(Utility.generate32UUID()); wxProfitSharingP.setNonce_str(Utility.generate32UUID());
wxProfitSharingP.setTransaction_id(wxPayOrder.getTransactionId()); wxProfitSharingP.setTransaction_id(wxPayOrder.getTransactionId());
wxProfitSharingP.setOut_trade_no(record.getId().toString()); wxProfitSharingP.setOut_trade_no(record.getId().toString());
wxProfitSharingP.setSign_type("HMAC-SHA256");
//添加分账接受方 //添加分账接受方
WxProfitSharingReceiver wxProfitSharingReceiver = new WxProfitSharingReceiver(); WxProfitSharingReceiver wxProfitSharingReceiver = new WxProfitSharingReceiver();
wxProfitSharingReceiver.setMerchantId(wxOrder.getMerchantId()); wxProfitSharingReceiver.setMerchantId(wxOrder.getMerchantId());
@@ -211,7 +211,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ


wxProfitSharingP.setReceivers(receivers.toJSONString()); wxProfitSharingP.setReceivers(receivers.toJSONString());


wxProfitSharingP.setSign(WxPayment.createSign(BeanUtils.toStringMap(wxProfitSharingP), payAccount.getApiKey()));
wxProfitSharingP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingP), payAccount.getApiKey()));
String response = WxProfitSharing.pushOrder(BeanUtils.toStringMap(wxProfitSharingP)); String response = WxProfitSharing.pushOrder(BeanUtils.toStringMap(wxProfitSharingP));


Map<String, String> returnMap = WxPayment.xmlToMap(response); Map<String, String> returnMap = WxPayment.xmlToMap(response);
@@ -220,11 +220,11 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
record.setSharingStatus(EnumProfitSharingStatus.PROFIT_SHARING_REQ_FAILED.getCode()); record.setSharingStatus(EnumProfitSharingStatus.PROFIT_SHARING_REQ_FAILED.getCode());
record.setUpdateTime(new Date()); record.setUpdateTime(new Date());
wxProfitSharingOrderMapper.updateByPrimaryKey(record); wxProfitSharingOrderMapper.updateByPrimaryKey(record);
return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(), returnMap.get("return_msg"));
throw new MallinkException(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(), returnMap.get("return_msg"));
} }


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


String result_code = returnMap.get("result_code"); String result_code = returnMap.get("result_code");
@@ -232,7 +232,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
record.setSharingStatus(EnumProfitSharingStatus.PROFIT_SHARING_APPLY_FAILED.getCode()); record.setSharingStatus(EnumProfitSharingStatus.PROFIT_SHARING_APPLY_FAILED.getCode());
record.setUpdateTime(new Date()); record.setUpdateTime(new Date());
wxProfitSharingOrderMapper.updateByPrimaryKey(record); wxProfitSharingOrderMapper.updateByPrimaryKey(record);
return new ResultData(ErrorCode.PROFIT_SHARING_APPLY_FAILED.getCode(), returnMap.get("result_msg"));
throw new MallinkException(ErrorCode.PROFIT_SHARING_APPLY_FAILED.getCode(), returnMap.get("result_msg"));
} }


record.setSharingOrderNo(returnMap.get("order_id")); record.setSharingOrderNo(returnMap.get("order_id"));
@@ -268,28 +268,29 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
wxProfitSharingQueryP.setNonce_str(Utility.generate32UUID()); wxProfitSharingQueryP.setNonce_str(Utility.generate32UUID());
wxProfitSharingQueryP.setTransaction_id(wxPayOrder.getTransactionId()); wxProfitSharingQueryP.setTransaction_id(wxPayOrder.getTransactionId());
wxProfitSharingQueryP.setOut_trade_no(record.getId().toString()); wxProfitSharingQueryP.setOut_trade_no(record.getId().toString());
wxProfitSharingQueryP.setSign_type("HMAC-SHA256");


wxProfitSharingQueryP.setSign(WxPayment.createSign(BeanUtils.toStringMap(wxProfitSharingQueryP), payAccount.getApiKey()));
wxProfitSharingQueryP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingQueryP), payAccount.getApiKey()));
String response = WxProfitSharing.pushOrder(BeanUtils.toStringMap(wxProfitSharingQueryP)); String response = WxProfitSharing.pushOrder(BeanUtils.toStringMap(wxProfitSharingQueryP));


Map<String, String> returnMap = WxPayment.xmlToMap(response); Map<String, String> returnMap = WxPayment.xmlToMap(response);
String return_code = returnMap.get("return_code"); String return_code = returnMap.get("return_code");
if (!"SUCCESS".equals(return_code)) { if (!"SUCCESS".equals(return_code)) {
return new ResultData(ErrorCode.PROFIT_SHARING_QUERY_REQUEST_FAILED.getCode(), returnMap.get("return_msg"));
throw new MallinkException(ErrorCode.PROFIT_SHARING_QUERY_REQUEST_FAILED.getCode(), returnMap.get("return_msg"));
} }


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


String out_order_no = returnMap.get("out_order_no"); String out_order_no = returnMap.get("out_order_no");
if (!out_order_no.equals(record.getId().toString())){ if (!out_order_no.equals(record.getId().toString())){
return new ResultData(ErrorCode.PROFIT_SHARING_QUERY_RETURN_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RETURN_INVALID.getMessage());
throw new MallinkException(ErrorCode.PROFIT_SHARING_QUERY_RETURN_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RETURN_INVALID.getMessage());
} }


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


record.setSharingStatus((Integer) statusMap.get(returnMap.get("status"))); record.setSharingStatus((Integer) statusMap.get(returnMap.get("status")));


+ 9
- 8
mallinkService/src/main/java/com/simple/service/impl/WxProfitSharingReceiverServiceImpl.java Voir le fichier

@@ -111,6 +111,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId()); wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId());
wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId()); wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId());
wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID()); wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID());
wxProfitSharingReceiverP.setSign_type("HMAC-SHA256");




JSONObject receiverJSON = new JSONObject(); JSONObject receiverJSON = new JSONObject();
@@ -121,7 +122,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString()); wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString());
String response; String response;
try { try {
wxProfitSharingReceiverP.setSign(WxPayment.createSign(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey()));
wxProfitSharingReceiverP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey()));
response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP)); response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP));
}catch (Exception e) { }catch (Exception e) {
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED, e.getMessage()); return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED, e.getMessage());
@@ -132,13 +133,13 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), returnMap.get("return_msg")); return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), returnMap.get("return_msg"));
} }


if (!WxPayment.verifyNotify(returnMap,payAccount.getApiKey())){
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");
if (!"SUCCESS".equals(result_code)) { if (!"SUCCESS".equals(result_code)) {
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), returnMap.get("result_msg"));
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), returnMap.get("err_code_des"));
}

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


wxProfitSharingReceiverMapper.insertSelective(receiver); wxProfitSharingReceiverMapper.insertSelective(receiver);
@@ -171,7 +172,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId()); wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId());
wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId()); wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId());
wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID()); wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID());
wxProfitSharingReceiverP.setSign_type("HMAC-SHA256");


JSONObject receiverJSON = new JSONObject(); JSONObject receiverJSON = new JSONObject();
receiverJSON.put("type",EnumProfitSharingReceiverType.getEnum(receiver.getReceiverType()).getMessage()); receiverJSON.put("type",EnumProfitSharingReceiverType.getEnum(receiver.getReceiverType()).getMessage());
@@ -180,7 +181,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString()); wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString());
String response; String response;
try { try {
wxProfitSharingReceiverP.setSign(WxPayment.createSign(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey()));
wxProfitSharingReceiverP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey()));
response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP)); response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP));
}catch (Exception e) { }catch (Exception e) {
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED, e.getMessage()); return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED, e.getMessage());


Chargement…
Annuler
Enregistrer