修复优惠卷问题 修复售后订单问题
This commit is contained in:
@ -6,6 +6,9 @@ import co.yixiang.yshop.module.pay.strategy.PayFactory;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
@Getter
|
||||
public class PayContext {
|
||||
|
@ -15,7 +15,10 @@ public class WeChatPay implements Pay {
|
||||
@Override
|
||||
public Map<String, String> selectPayWay(String payCode, PayParam param) throws Exception {
|
||||
//根据微信type选择不同的支付 H5/APPLET/APP
|
||||
if (Objects.equals(param.getType(), PayTypeEnum.WEIXIN_H5.getValue())) {
|
||||
if (Objects.equals(param.getType(), PayTypeEnum.WEIXIN_H5.getValue()) ||
|
||||
Objects.equals(param.getType(), PayTypeEnum.WEIXIN_APP.getValue()) ||
|
||||
Objects.equals(param.getType(), PayTypeEnum.WEIXIN_APPLET.getValue())
|
||||
) {
|
||||
return new WxPayServiceUtils().gotoPay(param);
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
|
@ -15,6 +15,9 @@ import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
@Slf4j(topic = "WxPayServiceUtils")
|
||||
public class WxPayServiceUtils {
|
||||
@ -75,14 +78,14 @@ public class WxPayServiceUtils {
|
||||
//微信app分配的APPID
|
||||
//app_appid
|
||||
outTradeNo=param.getOrderId()+"-"+ RandomStringUtil.getRandomCode(3,0)+"APP";
|
||||
reqParams.put("appid", app_appid);
|
||||
reqParams.put("appid", param.getMerchantDetailsDO().getAppid());
|
||||
//交易类型
|
||||
reqParams.put("trade_type", "APP");
|
||||
}else if(PayTypeEnum.WEIXIN_APPLET.getValue().equals(param.getType())){
|
||||
//微信app分配的APPID
|
||||
//app_appid
|
||||
reqParams.put("openid",param.getOpenid());
|
||||
outTradeNo=param.getOrderId()+"-"+ RandomStringUtil.getRandomCode(3,0)+"APPLET";
|
||||
reqParams.put("appid", appid);
|
||||
reqParams.put("appid", param.getMerchantDetailsDO().getAppid());
|
||||
//交易类型
|
||||
reqParams.put("trade_type", "JSAPI");
|
||||
}
|
||||
@ -113,7 +116,7 @@ public class WxPayServiceUtils {
|
||||
调用支付定义下单API,返回预付单信息 prepay_id
|
||||
*/
|
||||
String xmlResult = PaymentApi.pushOrder(reqParams);
|
||||
log.info("微信下单成功:{}",xmlResult);
|
||||
log.info("微信下单信息:{}",xmlResult);
|
||||
Map<String, String> result = PaymentKit.xmlToMap(xmlResult);
|
||||
//预付单信息
|
||||
String prepay_id = result.get("prepay_id");
|
||||
@ -130,6 +133,7 @@ public class WxPayServiceUtils {
|
||||
String packageSign = WXPayUtil.generateSignature(packageParams, param.getMerchantDetailsDO().getKeyPrivate());
|
||||
packageParams.put("paySign", packageSign);
|
||||
packageParams.put("codeUrl", result.get("code_url"));
|
||||
packageParams.put("orderId", param.getOrderId());
|
||||
//将组合后的商户订单号返回
|
||||
packageParams.put("out_trade_no", outTradeNo);
|
||||
packageParams.put("merchant_id", param.getMerchantDetailsDO().getMchId());
|
||||
|
@ -81,7 +81,7 @@ public class WxPayServiceImpl implements WxPayService {
|
||||
//微信app分配的APPID
|
||||
//app_appid
|
||||
outTradeNo=orderId+"-"+ RandomStringUtil.getRandomCode(3,0)+"APP";
|
||||
reqParams.put("appid", app_appid);
|
||||
reqParams.put("appid", merchantDetailsDO.getAppid());
|
||||
//交易类型
|
||||
reqParams.put("trade_type", "APP");
|
||||
}else if(PayTypeEnum.WEIXIN_APPLET.getValue().equals(type)){
|
||||
|
Reference in New Issue
Block a user