33333333333
This commit is contained in:
@@ -304,12 +304,33 @@ public class PayController {
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = "/trd/notify/v8")
|
||||
@Operation(hidden = true)
|
||||
@Log(title = "第三方支付回调V8", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||
@SaIgnore
|
||||
public String trdNotifyUrlV8(HttpServletRequest request) {
|
||||
try {
|
||||
TrdPayTypeEnum trdPayTypeEnum = TrdPayTypeEnum.V8;
|
||||
Map<String, String> params = AliPayApi.toMap(request);
|
||||
log.info("收到第三方支付回调 {}:{}",trdPayTypeEnum.name(), JSON.toJSONString(params));
|
||||
NotifyResp notifyResp = trdPayManager.getNotifyResp(params, trdPayTypeEnum);
|
||||
if(!notifyResp.isSuccess()){
|
||||
return "failure";
|
||||
}
|
||||
payManager.callBack(notifyResp.getOrderNo(),notifyResp.getTrdOrderNo(),params,notifyResp.getPayTypeEnum().name(), PayTypeEnum.TRD);
|
||||
return trdPayTypeEnum.getNotifyResp();
|
||||
} catch (Exception e) {
|
||||
log.error("第三方支付回调失败! V8", e);
|
||||
return "failure";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/trd/notify/{type}")
|
||||
@Operation(hidden = true)
|
||||
@Log(title = "第三方支付回调", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||
@SaIgnore
|
||||
public String trdNotifyUrlV1(HttpServletRequest request,@PathVariable("type") String type) {
|
||||
public String trdNotifyUrl(HttpServletRequest request,@PathVariable("type") String type) {
|
||||
try {
|
||||
if(type == null){
|
||||
log.error("收到第三方支付回调,支付类型为空");
|
||||
|
||||
@@ -177,6 +177,9 @@ public class AccountChangeLogServiceImpl extends ServiceImpl<AccountChangeLogMap
|
||||
}else{
|
||||
vo.setMessage(record.getCateAdminName());
|
||||
}
|
||||
if(AccountCateEnum.GIFT.getCode().equals(record.getCateId())){
|
||||
vo.setImg(record.getTarImg());
|
||||
}
|
||||
if(AccountCateEnum.IM.getCode().equals(record.getCateId())
|
||||
|| AccountCateEnum.VIDEO.getCode().equals(record.getCateId())
|
||||
|| AccountCateEnum.GUARD.getCode().equals(record.getCateId())
|
||||
|
||||
@@ -90,7 +90,7 @@ public enum TrdPayTypeEnum {
|
||||
* 密钥:pswWIbqnwlTlBDbZUk4qTisKbjWl5D9e
|
||||
* https://31.bghyvwk.cn
|
||||
*/
|
||||
V8("https://31.bghyvwk.cn","/api/pay/create","/api/pay/query","/api/pay/trd/notify/v8","success"),
|
||||
V8("https://31.bghyvwk.cn","/mapi.php","/api/pay/query","/api/pay/trd/notify/v8","success"),
|
||||
;
|
||||
private final String gatewayUrl;
|
||||
private final String createOrderUrl;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.cai.trdpay.handle;
|
||||
|
||||
import cn.hutool.crypto.digest.DigestUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.cai.domain.PayTrdConfig;
|
||||
@@ -22,11 +23,15 @@ import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@@ -42,6 +47,22 @@ public class PayTrdV8Service implements PayTrdService {
|
||||
return TrdPayTypeEnum.V8;
|
||||
}
|
||||
|
||||
public static MultiValueMap<String,String> createParamsOfMap(Map<String, String> params, String key) {
|
||||
MultiValueMap<String, String> resp = new LinkedMultiValueMap<>();
|
||||
List<String> url = new ArrayList<>();
|
||||
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||
url.add(entry.getKey() + "=" + entry.getValue());
|
||||
resp.add(entry.getKey(), entry.getValue());
|
||||
}
|
||||
url = url.stream().sorted().collect(Collectors.toList());
|
||||
String stringSignTemp = StringUtils.join(url, "&") + key;
|
||||
String sign = DigestUtil.md5Hex(stringSignTemp).toLowerCase();
|
||||
url.add("sign=" + sign);
|
||||
resp.add("sign",sign);
|
||||
return resp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public PayReturnResp createOrderAli(PayOrderInfoDTO payOrderInfoDTO, PayTrdConfig payTrdConfig) {
|
||||
@@ -49,19 +70,15 @@ public class PayTrdV8Service implements PayTrdService {
|
||||
RestTemplate rest = RestTemplateUtil.getNoSSLRest();
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("pid", payTrdConfig.getMchId());
|
||||
params.put("method", "jump");
|
||||
params.put("device", "mobile");
|
||||
params.put("type", "alipay");
|
||||
params.put("out_trade_no", payOrderInfoDTO.getOrderNo());
|
||||
String notifyUrl = payTrdConfig.getNotifyUrl() + type.getNotifyPath();
|
||||
params.put("notify_url", notifyUrl);
|
||||
params.put("return_url", "");
|
||||
params.put("name", payOrderInfoDTO.getSubject());
|
||||
params.put("money", payOrderInfoDTO.getPriceYuanStr());
|
||||
params.put("clientip", ServletUtils.getClientIP());
|
||||
params.put("timestamp", System.currentTimeMillis()/1000 + "");
|
||||
MultiValueMap<String, String> map = PayMd5Util.createParamsOfMap(params, payTrdConfig.getSign());
|
||||
map.add("sign_type","MD5");
|
||||
MultiValueMap<String, String> map = createParamsOfMap(params, payTrdConfig.getSign());
|
||||
String gatewayUrl = type.getGatewayUrl();
|
||||
if (StringUtils.isNotBlank(payTrdConfig.getGatewayUrl())) {
|
||||
gatewayUrl = payTrdConfig.getGatewayUrl();
|
||||
@@ -77,18 +94,18 @@ public class PayTrdV8Service implements PayTrdService {
|
||||
log.error("第三方支付失败 V8 返回数据为空 url={} params={}",createOrderUrl,JSON.toJSONString(map));
|
||||
throw new ServiceException("调用支付失败");
|
||||
}
|
||||
if(!"0".equals(jsonObject.getString("code"))){
|
||||
if(!"1".equals(jsonObject.getString("code"))){
|
||||
log.info("第三方支付失败 V8 统一支付失败失败 url={} params={} body={}, payTrdConfig={}, typeEnum={}", createOrderUrl,JSON.toJSONString(map), body, JSON.toJSONString(payTrdConfig), JSON.toJSONString(jsonObject));
|
||||
throw new ServiceException("调用支付失败");
|
||||
}
|
||||
String payUrl = jsonObject.getString("pay_info");
|
||||
String payUrl = jsonObject.getString("payurl");
|
||||
return PayReturnResp.createH5(payUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotifyResp getNotifyResp(Map<String, String> sourceData) {
|
||||
String mchOrderNo = sourceData.get("out_trade_no");
|
||||
String payOrderId = sourceData.get("api_trade_no");
|
||||
String payOrderId = sourceData.get("trade_no");
|
||||
String status = sourceData.get("trade_status");
|
||||
NotifyResp resp = new NotifyResp();
|
||||
resp.setOrderNo(mchOrderNo);
|
||||
|
||||
Reference in New Issue
Block a user