Просмотр исходного кода

fix pay v3 中文

release_toaliyun_real
zhengfangyuan 3 лет назад
Родитель
Сommit
1a4a16908d
10 измененных файлов: 56 добавлений и 59 удалений
  1. +7
    -0
      mallinkService/src/main/java/com/iformall/pay/WxPayV3.java
  2. +1
    -1
      mallinkService/src/main/java/com/iformall/service/pay/service/cashout/wx/sft/WxCashOutSFTAdapterService.java
  3. +1
    -1
      mallinkService/src/main/java/com/iformall/service/pay/service/cashout/wx/v2/WxCashOutAdapterService.java
  4. +8
    -1
      mallinkService/src/main/java/com/iformall/service/pay/service/pay/wx/sft/entity/SFTCombineItemOrder.java
  5. +5
    -1
      mallinkService/src/main/java/com/iformall/service/pay/service/pay/wx/sft/miniApp/appPay/WxMiniAppPaySFTAdapterService.java
  6. +1
    -49
      mallinkService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/BaseWxPayV3AdapterService.java
  7. +8
    -1
      mallinkService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/entity/V3CombineItemOrder.java
  8. +7
    -2
      mallinkService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/miniApp/appPay/WxMiniAppPayV3AdapterService.java
  9. +12
    -2
      mallinkService/src/main/java/com/iformall/service/pay/service/refund/wx/v3/WxRefundV3AdapterService.java
  10. +6
    -1
      mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v3/WxPayShareV3Service.java

+ 7
- 0
mallinkService/src/main/java/com/iformall/pay/WxPayV3.java Просмотреть файл

@@ -1,6 +1,7 @@
package com.iformall.pay;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.GeneralSecurityException;
import java.security.cert.X509Certificate;
import java.util.HashMap;
@@ -65,6 +66,12 @@ public class WxPayV3 {
private WxPayV3() {
}

//处理中文
public static String handleChinese(String content) throws UnsupportedEncodingException {
//中文必须要这样,否则会双方签名失败
return new String(content.getBytes("ISO-8859-1"), "UTF-8");
}
//敏感信息加密
public static String entry(WxPayService payService,String content) throws IllegalBlockSizeException {
X509Certificate certificate = payService.getConfig().getVerifier().getValidCertificate();


+ 1
- 1
mallinkService/src/main/java/com/iformall/service/pay/service/cashout/wx/sft/WxCashOutSFTAdapterService.java Просмотреть файл

@@ -242,7 +242,7 @@ public class WxCashOutSFTAdapterService implements CashOutAdapterService{
StringBuffer bn = new StringBuffer(cashOut.getMerchantName()).append("提现");
try {
wxCashOutPv3.setBatch_name(new String(bn.toString().getBytes("ISO-8859-1"), "UTF-8"));
wxCashOutPv3.setBatch_name(WxPayV3.handleChinese(bn.toString()));
} catch (UnsupportedEncodingException e) {
wxCashOutPv3.setBatch_name("tixian");
}


+ 1
- 1
mallinkService/src/main/java/com/iformall/service/pay/service/cashout/wx/v2/WxCashOutAdapterService.java Просмотреть файл

@@ -248,7 +248,7 @@ public class WxCashOutAdapterService implements CashOutAdapterService{
StringBuffer bn = new StringBuffer(cashOut.getMerchantName()).append("提现");
try {
wxCashOutPv3.setBatch_name(new String(bn.toString().getBytes("ISO-8859-1"), "UTF-8"));
wxCashOutPv3.setBatch_name(WxPayV3.handleChinese(bn.toString()));
} catch (UnsupportedEncodingException e) {
wxCashOutPv3.setBatch_name("tixian");
}


+ 8
- 1
mallinkService/src/main/java/com/iformall/service/pay/service/pay/wx/sft/entity/SFTCombineItemOrder.java Просмотреть файл

@@ -1,8 +1,11 @@
package com.iformall.service.pay.service.pay.wx.sft.entity;

import java.io.UnsupportedEncodingException;

import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxOrder;
import com.iformall.domain.po.WxPayAccount;
import com.iformall.pay.WxPayV3;

import lombok.Data;

@@ -25,7 +28,11 @@ public class SFTCombineItemOrder {
this.setAmount(amount);
this.out_trade_no = String.valueOf(order.getId());
this.sub_mchid = subMchId;
this.description = appInfo.getName()+"-"+productName;
try {
this.description = WxPayV3.handleChinese(appInfo.getName()+"-"+productName);
} catch (UnsupportedEncodingException e) {
this.description = "weixin miniApp product";
}
SFTPaySettleReq settle = new SFTPaySettleReq();
settle.setProfit_sharing(true);
this.setSettle_info(settle);


+ 5
- 1
mallinkService/src/main/java/com/iformall/service/pay/service/pay/wx/sft/miniApp/appPay/WxMiniAppPaySFTAdapterService.java Просмотреть файл

@@ -70,7 +70,11 @@ public class WxMiniAppPaySFTAdapterService extends BaseWxPaySFTAdapterService i
req.setSp_appid(String.valueOf(appInfo.getId()));
req.setSp_mchid(payAccount.getMchId());
req.setSub_mchid(getMerchantUid(record,composeOrder.getSingleOrder()));
req.setDescription(appInfo.getName()+"-"+productName);
try {
req.setDescription(WxPayV3.handleChinese(appInfo.getName()+"-"+productName));
}catch(Exception e) {
req.setDescription("weixin miniApp product");
}
req.setOut_trade_no(String.valueOf(composeOrder.getMainOrderId()));
req.setNotify_url(payAccount.getPayNotifyV3Url());


+ 1
- 49
mallinkService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/BaseWxPayV3AdapterService.java Просмотреть файл

@@ -1,56 +1,8 @@
package com.iformall.service.pay.service.pay.wx.v3;

import java.io.File;
import java.util.Date;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.PosCouponOrderVerify;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxBatchOrder;
import com.iformall.domain.po.WxCouponOrder;
import com.iformall.domain.po.WxOrder;
import com.iformall.domain.po.WxPayAccount;
import com.iformall.domain.po.WxPayOrder;
import com.iformall.enums.EnumCouponOrderStatus;
import com.iformall.enums.EnumOrderFrom;
import com.iformall.enums.EnumOrderStatus;
import com.iformall.enums.EnumOrderType;
import com.iformall.enums.EnumPayMode;
import com.iformall.enums.EnumPayStatus;
import com.iformall.exception.MallinkException;
import com.iformall.pay.WxPay;
import com.iformall.pay.WxPayOrderQ;
import com.iformall.pay.WxPayOrderSQ;
import com.iformall.pay.WxPayment;
import com.iformall.service.QrCodeService;
import com.iformall.service.helper.WxPayOrderServiceHelper;
import com.iformall.service.pay.service.pay.PayAdapterService;
import com.iformall.service.pay.service.pay.entity.PayAdapterResult;
import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult;
import java.io.UnsupportedEncodingException;
import com.iformall.service.pay.service.pay.wx.BaseWxPayAdapterService;
import com.iformall.utils.BeanUtils;
import com.iformall.utils.MaUtil;
import com.iformall.utils.QRCodeUtils;
import com.iformall.utils.Utility;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaCodeLineColor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.open.api.WxOpenService;

@Slf4j
public class BaseWxPayV3AdapterService extends BaseWxPayAdapterService{


}

+ 8
- 1
mallinkService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/entity/V3CombineItemOrder.java Просмотреть файл

@@ -1,8 +1,11 @@
package com.iformall.service.pay.service.pay.wx.v3.entity;

import java.io.UnsupportedEncodingException;

import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxOrder;
import com.iformall.domain.po.WxPayAccount;
import com.iformall.pay.WxPayV3;

import lombok.Data;

@@ -25,7 +28,11 @@ public class V3CombineItemOrder {
this.setAmount(amount);
this.out_trade_no = String.valueOf(order.getId());
this.sub_mchid = subMchId;
this.description = appInfo.getName()+"-"+productName;
try {
this.description = WxPayV3.handleChinese(appInfo.getName()+"-"+productName);
} catch (UnsupportedEncodingException e) {
this.description = "weixin miniApp product";
}
V3PaySettleReq settle = new V3PaySettleReq();
settle.setProfit_sharing(true);
this.setSettle_info(settle);


+ 7
- 2
mallinkService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/miniApp/appPay/WxMiniAppPayV3AdapterService.java Просмотреть файл

@@ -1,6 +1,7 @@
package com.iformall.service.pay.service.pay.wx.v3.miniApp.appPay;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -83,8 +84,12 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl
}else {
throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"当前支付模式非法");
}
//req.setDescription(appInfo.getName()+"-"+productName);
req.setDescription("product");
try {
//中文必须要这样,否则会双方签名失败
req.setDescription(WxPayV3.handleChinese(appInfo.getName()+"-"+productName));
} catch (UnsupportedEncodingException e) {
req.setDescription("weixin miniApp product");
}
req.setOut_trade_no(record.getPayOrderNo());
req.setNotify_url(payAccount.getPayNotifyV3Url());


+ 12
- 2
mallinkService/src/main/java/com/iformall/service/pay/service/refund/wx/v3/WxRefundV3AdapterService.java Просмотреть файл

@@ -1,5 +1,6 @@
package com.iformall.service.pay.service.refund.wx.v3;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -73,6 +74,7 @@ public class WxRefundV3AdapterService implements RefundPayAdapterService{
private V3PayRefundReq getReq(WxPayAccount payAccount,WxAppinfo appInfo,WxRefundOrder record,WxPayOrder payOrder,Long orderId,EnumPayType payType) {
V3PayRefundReq req = new V3PayRefundReq();
//直连
if (payAccount.getMchType() == EnumPayMchType.DIRECT.getCode()) {
WxComposeChildOrderShare share = payOrder.getChildOrderShare(orderId);
req.setSub_mchid(share.getMerchantUid());
@@ -84,7 +86,11 @@ public class WxRefundV3AdapterService implements RefundPayAdapterService{
}
req.setOut_trade_no(payOrder.getPayOrderNo());
req.setOut_refund_no(String.valueOf(record.getId()));
req.setReason(payType.getMessage());
try {
req.setReason(WxPayV3.handleChinese(payType.getMessage()));
} catch (UnsupportedEncodingException e) {
req.setReason(payType.getCode().toString());
}
req.setNotify_url(payAccount.getRefundNotifyV3Url());
V3PayRefundAmountReq amount = new V3PayRefundAmountReq();
amount.setRefund(record.getRefundFee());
@@ -93,7 +99,11 @@ public class WxRefundV3AdapterService implements RefundPayAdapterService{
List<V3PayRefundGoodsReq> goods = new ArrayList<V3PayRefundGoodsReq>();
WxOrder order = wxOrderService.getById(orderId, payAccount.getTenantId());
V3PayRefundGoodsReq gr = new V3PayRefundGoodsReq();
gr.setGoods_name("商品"+order.getProductId());
try {
gr.setGoods_name(WxPayV3.handleChinese("商品"+order.getProductId()));
} catch (UnsupportedEncodingException e) {
gr.setGoods_name("product:"+order.getProductId());
}
gr.setMerchant_goods_id(order.getProductId().toString());
gr.setRefund_amount(record.getRefundFee());
gr.setRefund_quantity(order.getCouponNumber());


+ 6
- 1
mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v3/WxPayShareV3Service.java Просмотреть файл

@@ -1,6 +1,7 @@
package com.iformall.service.pay.service.share.wx.v3;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.GeneralSecurityException;
import java.text.ParseException;
import java.util.*;
@@ -142,7 +143,11 @@ public class WxPayShareV3Service extends PayShareBaseAdapterService{
}
req.setTransaction_id(transcationId);
req.setOut_order_no(String.valueOf(record.getOrderId()));
req.setDescription(appInfo.getName()+"支付订单:"+record.getOrderId());
try {
req.setDescription(WxPayV3.handleChinese(appInfo.getName()+"支付订单:"+record.getOrderId()));
} catch (UnsupportedEncodingException e1) {
req.setDescription("weixin miniApp orderId:"+record.getOrderId());
}
WxPayService payService = maUtil.getWxPayService(appInfo, payAccount);
String response = null;;


Загрузка…
Отмена
Сохранить