|
@@ -7,6 +7,8 @@ import com.fs.common.utils.StringUtils;
|
|
import com.fs.company.domain.CompanyRecharge;
|
|
import com.fs.company.domain.CompanyRecharge;
|
|
import com.fs.company.service.ICompanyRechargeService;
|
|
import com.fs.company.service.ICompanyRechargeService;
|
|
import com.fs.pay.bean.WxPayBean;
|
|
import com.fs.pay.bean.WxPayBean;
|
|
|
|
+import com.fs.wx.pay.config.WxPayProperties;
|
|
|
|
+import com.github.binarywang.wxpay.util.SignUtils;
|
|
import com.ijpay.core.enums.SignType;
|
|
import com.ijpay.core.enums.SignType;
|
|
import com.ijpay.core.enums.TradeType;
|
|
import com.ijpay.core.enums.TradeType;
|
|
import com.ijpay.core.kit.HttpKit;
|
|
import com.ijpay.core.kit.HttpKit;
|
|
@@ -45,6 +47,8 @@ public class WxPayController extends WxPayApiController {
|
|
@Autowired
|
|
@Autowired
|
|
ICompanyRechargeService rechargeService;
|
|
ICompanyRechargeService rechargeService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private WxPayProperties wxPayProperties;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -151,40 +155,28 @@ public class WxPayController extends WxPayApiController {
|
|
Map<String, String> params = WxPayKit.xmlToMap(xmlMsg);
|
|
Map<String, String> params = WxPayKit.xmlToMap(xmlMsg);
|
|
String returnCode = params.get("return_code");
|
|
String returnCode = params.get("return_code");
|
|
// 微信支付订单号
|
|
// 微信支付订单号
|
|
- String transaction_id = params.get("transaction_id");
|
|
|
|
|
|
+ String transaction_id = params.get("transaction_id");
|
|
// 商户订单号
|
|
// 商户订单号
|
|
- String out_trade_no = params.get("out_trade_no");
|
|
|
|
|
|
+ String out_trade_no = params.get("out_trade_no");
|
|
// 注意重复通知的情况,同一订单号可能收到多次通知,请注意一定先判断订单状态
|
|
// 注意重复通知的情况,同一订单号可能收到多次通知,请注意一定先判断订单状态
|
|
- // 注意此处签名方式需与统一下单的签名类型一致
|
|
|
|
- if (WxPayKit.verifyNotify(params, WxPayApiConfigKit.getWxPayApiConfig().getPartnerKey(), SignType.HMACSHA256)) {
|
|
|
|
|
|
+ // 注意此处签名方式需与统一下单的签名类型一致1
|
|
|
|
+ if (SignUtils.checkSign(params, String.valueOf(SignType.HMACSHA256), wxPayProperties.getMchKey())) {
|
|
if (WxPayKit.codeIsOk(returnCode)) {
|
|
if (WxPayKit.codeIsOk(returnCode)) {
|
|
// 更新订单信息
|
|
// 更新订单信息
|
|
// 发送通知等
|
|
// 发送通知等
|
|
String[] order=out_trade_no.split("-");
|
|
String[] order=out_trade_no.split("-");
|
|
R r;
|
|
R r;
|
|
- switch (order[0]){
|
|
|
|
- case "recharge":
|
|
|
|
- CompanyRecharge recharge=rechargeService.selectCompanyRechargeByNo(order[1]);
|
|
|
|
-
|
|
|
|
- if(recharge!=null&&recharge.getStatus()==1){
|
|
|
|
- Map<String, String> xml = new HashMap<String, String>(2);
|
|
|
|
- xml.put("return_code", "SUCCESS");
|
|
|
|
- xml.put("return_msg", "OK");
|
|
|
|
- return WxPayKit.toXml(xml);
|
|
|
|
- }
|
|
|
|
- recharge.setTradeNo(transaction_id);
|
|
|
|
- r= rechargeService.payNotify(recharge);
|
|
|
|
- if(r.get("code").equals(200)){
|
|
|
|
- Map<String, String> xml = new HashMap<String, String>(2);
|
|
|
|
- xml.put("return_code", "SUCCESS");
|
|
|
|
- xml.put("return_msg", "OK");
|
|
|
|
- return WxPayKit.toXml(xml);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ if (order[0].equals("recharge")) {
|
|
|
|
+ r = rechargeService.payNotify(order[1],transaction_id);
|
|
|
|
+ if (r.get("code").equals(200)) {
|
|
|
|
+ Map<String, String> xml = new HashMap<String, String>(2);
|
|
|
|
+ xml.put("return_code", "SUCCESS");
|
|
|
|
+ xml.put("return_msg", "OK");
|
|
|
|
+ return WxPayKit.toXml(xml);
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|