|
|
@ -22,6 +22,7 @@ import com.bnyer.pay.bean.vo.ThirdUnifiedOrderVo; |
|
|
import com.bnyer.pay.constant.KSPayConstants; |
|
|
import com.bnyer.pay.constant.KSPayConstants; |
|
|
import com.bnyer.pay.enums.EnumPayChannel; |
|
|
import com.bnyer.pay.enums.EnumPayChannel; |
|
|
import com.bnyer.pay.enums.EnumPayConfigStatus; |
|
|
import com.bnyer.pay.enums.EnumPayConfigStatus; |
|
|
|
|
|
import com.bnyer.pay.exception.PayException; |
|
|
import com.bnyer.pay.manager.KsPayManager; |
|
|
import com.bnyer.pay.manager.KsPayManager; |
|
|
import com.bnyer.pay.mapper.KspayConfigMapper; |
|
|
import com.bnyer.pay.mapper.KspayConfigMapper; |
|
|
import com.bnyer.pay.service.PayInfoService; |
|
|
import com.bnyer.pay.service.PayInfoService; |
|
|
@ -53,8 +54,6 @@ public class KSPayStrategy extends AbstractPayStrategy{ |
|
|
|
|
|
|
|
|
private static KspayConfigMapper kspayConfigMapper; |
|
|
private static KspayConfigMapper kspayConfigMapper; |
|
|
|
|
|
|
|
|
private final static String failThirdCode = "-1"; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
public void setBean(KSPayUtil ksPayUtil, |
|
|
public void setBean(KSPayUtil ksPayUtil, |
|
|
PayInfoService payInfoService, KspayConfigMapper kspayConfigMapper) { |
|
|
PayInfoService payInfoService, KspayConfigMapper kspayConfigMapper) { |
|
|
@ -84,6 +83,8 @@ public class KSPayStrategy extends AbstractPayStrategy{ |
|
|
String appId = kspayConfig.getAppid(); |
|
|
String appId = kspayConfig.getAppid(); |
|
|
String backurl = kspayConfig.getBackurl(); |
|
|
String backurl = kspayConfig.getBackurl(); |
|
|
String secret = kspayConfig.getSecret(); |
|
|
String secret = kspayConfig.getSecret(); |
|
|
|
|
|
ThirdUnifiedOrderVo thirdUnifiedOrderVo = new ThirdUnifiedOrderVo(); |
|
|
|
|
|
thirdUnifiedOrderVo.setAppId(appId); |
|
|
try { |
|
|
try { |
|
|
//加签验签的参数需要排序
|
|
|
//加签验签的参数需要排序
|
|
|
Map<String, Object> params = new TreeMap<>(); |
|
|
Map<String, Object> params = new TreeMap<>(); |
|
|
@ -126,16 +127,10 @@ public class KSPayStrategy extends AbstractPayStrategy{ |
|
|
log.info("=================================="); |
|
|
log.info("=================================="); |
|
|
log.info("快手预下单result{}", result); |
|
|
log.info("快手预下单result{}", result); |
|
|
log.info("=================================="); |
|
|
log.info("=================================="); |
|
|
} catch (Exception e) { |
|
|
} catch (PayException e) { |
|
|
log.error("快手支付:支付异常,payId:{},error{}", bo.getPayId(), e.getMessage()); |
|
|
log.error("快手支付:支付异常,payId:{},error{}", bo.getPayId(), e); |
|
|
throw new ServiceException(ResponseEnum.PAY_FAILS); |
|
|
thirdUnifiedOrderVo.setThirdCode(e.getErrCode()); |
|
|
} |
|
|
thirdUnifiedOrderVo.setThirdMsg(StringUtils.isNoneBlank(e.getErrCodeDes())?e.getErrCodeDes():e.getCustomErrorMsg()); |
|
|
ThirdUnifiedOrderVo thirdUnifiedOrderVo = new ThirdUnifiedOrderVo(); |
|
|
|
|
|
thirdUnifiedOrderVo.setAppId(appId); |
|
|
|
|
|
if (StringUtils.isBlank(result) || !result.startsWith("{")){ |
|
|
|
|
|
log.error("快手支付:统一下单接口调用失败,payId:{},error{}", bo.getPayId(), "第三方返回格式有误!"); |
|
|
|
|
|
thirdUnifiedOrderVo.setThirdCode(failThirdCode); |
|
|
|
|
|
thirdUnifiedOrderVo.setThirdMsg("第三方返回格式有误!"); |
|
|
|
|
|
return thirdUnifiedOrderVo; |
|
|
return thirdUnifiedOrderVo; |
|
|
} |
|
|
} |
|
|
log.info("=================================="); |
|
|
log.info("=================================="); |
|
|
@ -144,12 +139,6 @@ public class KSPayStrategy extends AbstractPayStrategy{ |
|
|
JSONObject jsonObject = JSONObject.parseObject(result); |
|
|
JSONObject jsonObject = JSONObject.parseObject(result); |
|
|
String resultCode = jsonObject.getString("result"); |
|
|
String resultCode = jsonObject.getString("result"); |
|
|
String errorMsg = jsonObject.getString("error_msg"); |
|
|
String errorMsg = jsonObject.getString("error_msg"); |
|
|
if (!"1".equals(resultCode)) { |
|
|
|
|
|
log.error("快手支付:统一下单接口调用失败,payId:{},error{}", bo.getPayId(),errorMsg); |
|
|
|
|
|
thirdUnifiedOrderVo.setThirdCode(resultCode); |
|
|
|
|
|
thirdUnifiedOrderVo.setThirdMsg(errorMsg); |
|
|
|
|
|
return thirdUnifiedOrderVo; |
|
|
|
|
|
} |
|
|
|
|
|
JSONObject data = jsonObject.getJSONObject("order_info"); |
|
|
JSONObject data = jsonObject.getJSONObject("order_info"); |
|
|
String orderNo = data.getString("order_no"); |
|
|
String orderNo = data.getString("order_no"); |
|
|
String orderToken = data.getString("order_info_token"); |
|
|
String orderToken = data.getString("order_info_token"); |
|
|
|