33333333333
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
package com.ruoyi.cai.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "duanxinbao.sms")
|
||||||
|
public class DuanXinBaoSmsProperties {
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private String content;
|
||||||
|
}
|
||||||
@@ -1,8 +1,16 @@
|
|||||||
package com.ruoyi.cai.kit;
|
package com.ruoyi.cai.kit;
|
||||||
|
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import com.github.houbb.heaven.annotation.CommonEager;
|
||||||
|
import com.ruoyi.cai.config.AliSmsProperties;
|
||||||
|
import com.ruoyi.cai.config.DuanXinBaoSmsProperties;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
@@ -14,6 +22,7 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Component
|
||||||
public class DuanXinBaoSmsKit {
|
public class DuanXinBaoSmsKit {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@@ -21,9 +30,26 @@ public class DuanXinBaoSmsKit {
|
|||||||
log.info(s+"");
|
log.info(s+"");
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static String USER_NAME = "huaxiang5201";
|
@Autowired
|
||||||
private final static String TEST_PASSWORD = "qwe8848.";
|
@Setter
|
||||||
private final static String CONTENT = "【花香app】您的验证码是%s。如非本人操作,请忽略本短信";
|
private DuanXinBaoSmsProperties config;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
if(StringUtils.isNotBlank(config.getPassword())){
|
||||||
|
TEST_PASSWORD = config.getPassword();
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotBlank(config.getUsername())){
|
||||||
|
USER_NAME = config.getUsername();
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotBlank(config.getContent())){
|
||||||
|
CONTENT = config.getContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String USER_NAME = "huaxiang5201";
|
||||||
|
private static String TEST_PASSWORD = "qwe8848.";
|
||||||
|
private static String CONTENT = "【花香app】您的验证码是%s。如非本人操作,请忽略本短信";
|
||||||
|
|
||||||
private final static String HTTP_URL = "http://api.smsbao.com/sms";
|
private final static String HTTP_URL = "http://api.smsbao.com/sms";
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,13 @@ public enum TrdPayTypeEnum {
|
|||||||
* [回调IP]: 142.171.122.90
|
* [回调IP]: 142.171.122.90
|
||||||
*/
|
*/
|
||||||
V7("https://baihe.lhsifang.com","/api/pay/create","/api/pay/query","/api/pay/trd/notify/v7","success"),
|
V7("https://baihe.lhsifang.com","/api/pay/create","/api/pay/query","/api/pay/trd/notify/v7","success"),
|
||||||
|
/**
|
||||||
|
* 信息
|
||||||
|
* 添加商户成功!商户ID:1013
|
||||||
|
* 密钥:pswWIbqnwlTlBDbZUk4qTisKbjWl5D9e
|
||||||
|
* https://31.bghyvwk.cn
|
||||||
|
*/
|
||||||
|
V8("https://31.bghyvwk.cn","/api/pay/create","/api/pay/query","/api/pay/trd/notify/v8","success"),
|
||||||
;
|
;
|
||||||
private final String gatewayUrl;
|
private final String gatewayUrl;
|
||||||
private final String createOrderUrl;
|
private final String createOrderUrl;
|
||||||
|
|||||||
@@ -0,0 +1,150 @@
|
|||||||
|
package com.ruoyi.cai.trdpay.handle;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.ruoyi.cai.domain.PayTrdConfig;
|
||||||
|
import com.ruoyi.cai.pay.PayManager;
|
||||||
|
import com.ruoyi.cai.pay.PayOrderInfoDTO;
|
||||||
|
import com.ruoyi.cai.pay.PayReturnResp;
|
||||||
|
import com.ruoyi.cai.service.OrderLogsService;
|
||||||
|
import com.ruoyi.cai.trdpay.PayMd5Util;
|
||||||
|
import com.ruoyi.cai.trdpay.PayTrdService;
|
||||||
|
import com.ruoyi.cai.trdpay.TrdPayTypeEnum;
|
||||||
|
import com.ruoyi.cai.trdpay.dto.NotifyResp;
|
||||||
|
import com.ruoyi.cai.util.RestTemplateUtil;
|
||||||
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
|
import com.ruoyi.system.domain.SysOperLog;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.MultiValueMap;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class PayTrdV8Service implements PayTrdService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderLogsService orderLogsService;
|
||||||
|
@Autowired
|
||||||
|
private PayManager payManager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TrdPayTypeEnum getType() {
|
||||||
|
return TrdPayTypeEnum.V8;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PayReturnResp createOrderAli(PayOrderInfoDTO payOrderInfoDTO, PayTrdConfig payTrdConfig) {
|
||||||
|
TrdPayTypeEnum type = getType();
|
||||||
|
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");
|
||||||
|
String gatewayUrl = type.getGatewayUrl();
|
||||||
|
if (StringUtils.isNotBlank(payTrdConfig.getGatewayUrl())) {
|
||||||
|
gatewayUrl = payTrdConfig.getGatewayUrl();
|
||||||
|
}
|
||||||
|
String createOrderUrl = gatewayUrl + type.getCreateOrderUrl();
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||||
|
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(map, headers);
|
||||||
|
String body = rest.postForObject(createOrderUrl, request, String.class);
|
||||||
|
JSONObject jsonObject = JSON.parseObject(body);
|
||||||
|
orderLogsService.createAliPayLogs(payOrderInfoDTO.getOrderNo(), createOrderUrl+JSON.toJSONString(map), jsonObject, type);
|
||||||
|
if(jsonObject == null){
|
||||||
|
log.error("第三方支付失败 V8 返回数据为空 url={} params={}",createOrderUrl,JSON.toJSONString(map));
|
||||||
|
throw new ServiceException("调用支付失败");
|
||||||
|
}
|
||||||
|
if(!"0".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");
|
||||||
|
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 status = sourceData.get("trade_status");
|
||||||
|
NotifyResp resp = new NotifyResp();
|
||||||
|
resp.setOrderNo(mchOrderNo);
|
||||||
|
resp.setTrdOrderNo(payOrderId);
|
||||||
|
resp.setPayTypeEnum(getType());
|
||||||
|
resp.setSourceData(sourceData);
|
||||||
|
resp.setSuccess("TRADE_SUCCESS".equals(status));
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject queryOrder(String orderNo, PayTrdConfig payTrdConfig) {
|
||||||
|
throw new ServiceException("V8不支持订单查询");
|
||||||
|
/*TrdPayTypeEnum type = getType();
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("merchantId", payTrdConfig.getMchId());
|
||||||
|
params.put("merchantPayNo", orderNo);
|
||||||
|
String para = PayMd5Util.createParams(params,payTrdConfig.getSign());
|
||||||
|
String gatewayUrl = type.getGatewayUrl();
|
||||||
|
if(StringUtils.isNotBlank(payTrdConfig.getGatewayUrl())){
|
||||||
|
gatewayUrl = payTrdConfig.getGatewayUrl();
|
||||||
|
}
|
||||||
|
String queryOrderUrl = gatewayUrl + type.getQueryOrderUrl();
|
||||||
|
String url = queryOrderUrl + "?" + para;
|
||||||
|
String body = RestTemplateUtil.getRest().getForEntity(url, String.class).getBody();
|
||||||
|
JSONObject jsonObject = JSON.parseObject(body);
|
||||||
|
if(jsonObject == null){
|
||||||
|
log.error("第三方支付查询失败 返回数据为空 URL={}",url);
|
||||||
|
throw new ServiceException("调用支付失败");
|
||||||
|
}
|
||||||
|
log.info("第三方支付查询成功 V8 URL={}, body={}",url, body);
|
||||||
|
return jsonObject;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject resetOrder(String orderNo, PayTrdConfig payTrdConfig, boolean updateData) {
|
||||||
|
throw new ServiceException("V8不支持订单查询");
|
||||||
|
/*JSONObject jsonObject = this.queryOrder(orderNo,payTrdConfig);
|
||||||
|
if(!"SUCCESS".equals(jsonObject.getString("retCode"))){
|
||||||
|
log.info("第三方支付失败 V8统一支付失败失败 orderNo={}, payTrdConfig={}", orderNo, JSON.toJSONString(payTrdConfig));
|
||||||
|
throw new ServiceException("调用支付失败");
|
||||||
|
}
|
||||||
|
Integer status = jsonObject.getInteger("status");
|
||||||
|
if(status != null && status.equals(1)){
|
||||||
|
String mchOrderNo = jsonObject.getString("mchOrderNo");
|
||||||
|
String payOrderId = jsonObject.getString("payOrderId");
|
||||||
|
String productId = jsonObject.getString("productId");
|
||||||
|
Map<String,String> objectJson = new HashMap<>();
|
||||||
|
for (String key : jsonObject.keySet()) {
|
||||||
|
objectJson.put(key, jsonObject.getString(key));
|
||||||
|
}
|
||||||
|
if(updateData){
|
||||||
|
payManager.callBack(mchOrderNo,payOrderId,objectJson,"V8", PayTypeEnum.TRD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return jsonObject;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user