支付相关
This commit is contained in:
@@ -24,6 +24,8 @@ public class OrderDto implements Dto {
|
|||||||
private String name;
|
private String name;
|
||||||
@ApiModelProperty("过期时间:以分钟为单位")
|
@ApiModelProperty("过期时间:以分钟为单位")
|
||||||
private int timeRemarks;
|
private int timeRemarks;
|
||||||
|
@ApiModelProperty("回调地址")
|
||||||
|
private String returnUrl;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.yxt.pay.api.order;
|
package com.yxt.pay.api.order;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.yxt.common.base.utils.StringRandom;
|
import com.yxt.common.base.utils.StringRandom;
|
||||||
import com.yxt.common.core.domain.BaseEntity;
|
import com.yxt.common.core.domain.BaseEntity;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@@ -25,21 +24,14 @@ public class PayOrder extends BaseEntity {
|
|||||||
@ApiModelProperty("支付方式:wxPay微信")
|
@ApiModelProperty("支付方式:wxPay微信")
|
||||||
private String payType;
|
private String payType;
|
||||||
private String payTypeValue;
|
private String payTypeValue;
|
||||||
|
@ApiModelProperty("商品名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
@ApiModelProperty("openId")
|
||||||
private String openId;
|
private String openId;
|
||||||
@ApiModelProperty("过期时间描述:以分钟为单位,例如:5")
|
@ApiModelProperty("过期时间描述:以分钟为单位,例如:5")
|
||||||
private int timeRemarks;
|
private int timeRemarks;
|
||||||
|
|
||||||
/*@TableField(exist = false)
|
private String returnUrl;
|
||||||
private String appId;
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String mchId;
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String secret;
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String remark;*/
|
|
||||||
|
|
||||||
|
|
||||||
public String getTime() {
|
public String getTime() {
|
||||||
@@ -51,9 +43,6 @@ public class PayOrder extends BaseEntity {
|
|||||||
String Randomstr = StringRandom.getRandomString(15);
|
String Randomstr = StringRandom.getRandomString(15);
|
||||||
if (source == 0) {//云菜窖
|
if (source == 0) {//云菜窖
|
||||||
outTradeNo = "YCJ" + getTime() + Randomstr;
|
outTradeNo = "YCJ" + getTime() + Randomstr;
|
||||||
/* appId = "wx4724e3a3c27f36b5";
|
|
||||||
mchId = "1664882765";
|
|
||||||
secret = "yxtcxjshbyxgs1234567898765432101";*/
|
|
||||||
|
|
||||||
} else if (source == 1) {
|
} else if (source == 1) {
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import java.io.IOException;
|
|||||||
* @date: 2024/1/6
|
* @date: 2024/1/6
|
||||||
**/
|
**/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/order")
|
@RequestMapping("order")
|
||||||
public class OrderRest extends ApiBaseAction {
|
public class OrderRest extends ApiBaseAction {
|
||||||
//9370ec84-2723-40ee-bb6f-680fce6a25a2
|
//9370ec84-2723-40ee-bb6f-680fce6a25a2
|
||||||
//05ba58d6-f1f0-4f68-9bcc-62ceeaf4c088
|
//05ba58d6-f1f0-4f68-9bcc-62ceeaf4c088
|
||||||
@@ -32,7 +32,7 @@ public class OrderRest extends ApiBaseAction {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private OrderService orderService;
|
private OrderService orderService;
|
||||||
|
|
||||||
@PostMapping("createOrder")
|
@PostMapping("/createOrder")
|
||||||
ResultBean<PayOrderVo> createOrder(@RequestBody OrderDto dto) {
|
ResultBean<PayOrderVo> createOrder(@RequestBody OrderDto dto) {
|
||||||
return orderService.createOrder(dto);
|
return orderService.createOrder(dto);
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ public class OrderRest extends ApiBaseAction {
|
|||||||
return orderService.selectOrder(query);
|
return orderService.selectOrder(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("orderQuery")
|
@PostMapping("/orderQuery")
|
||||||
ResultBean orderQuery(OrderQuery query) {
|
ResultBean orderQuery(OrderQuery query) {
|
||||||
return orderService.orderQuery(query);
|
return orderService.orderQuery(query);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,72 +46,13 @@ public class OrderService extends MybatisBaseService<OrderMapper, PayOrder> {
|
|||||||
order.setName(dto.getName());
|
order.setName(dto.getName());
|
||||||
order.setCreateBySid(dto.getUserSid());
|
order.setCreateBySid(dto.getUserSid());
|
||||||
order.setOpenId(dto.getOpenId());
|
order.setOpenId(dto.getOpenId());
|
||||||
|
order.setReturnUrl(dto.getReturnUrl());
|
||||||
baseMapper.insert(order);
|
baseMapper.insert(order);
|
||||||
payOrderVo.setCreateTime(DateUtils.format(order.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
|
payOrderVo.setCreateTime(DateUtils.format(order.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
|
||||||
payOrderVo.setGoods(order.getName());
|
payOrderVo.setGoods(order.getName());
|
||||||
payOrderVo.setMainSid(order.getSid());
|
payOrderVo.setMainSid(order.getSid());
|
||||||
payOrderVo.setOutTradeNo(order.getOutTradeNo());
|
payOrderVo.setOutTradeNo(order.getOutTradeNo());
|
||||||
payOrderVo.setPrice(order.getTotalTee());
|
payOrderVo.setPrice(order.getTotalTee());
|
||||||
/* OrderVo orderVo = new OrderVo();
|
|
||||||
Map<Object, Object> resultObj = new TreeMap();
|
|
||||||
if (dto.getPayType() == 0) {//支付宝
|
|
||||||
return rb.setMsg("暂不支持支付宝支付");
|
|
||||||
} else if (dto.getPayType() == 1) {
|
|
||||||
try {
|
|
||||||
Map<Object, Object> parame = new TreeMap<Object, Object>();
|
|
||||||
parame.put("appid", order.getAppId());
|
|
||||||
// 商家账号。
|
|
||||||
parame.put("mch_id", order.getMchId());
|
|
||||||
String randomStr = CharUtil.getRandomNum(18).toUpperCase();
|
|
||||||
// 随机字符串
|
|
||||||
parame.put("nonce_str", randomStr);
|
|
||||||
// 商户订单编号
|
|
||||||
parame.put("out_trade_no", order.getOutTradeNo());
|
|
||||||
|
|
||||||
// 商品描述
|
|
||||||
parame.put("body", order.getRemark());
|
|
||||||
|
|
||||||
//支付金额
|
|
||||||
parame.put("total_fee", new BigDecimal(dto.getTotalTee()).multiply(new BigDecimal(100)).intValue());
|
|
||||||
// 回调地址
|
|
||||||
parame.put("notify_url", "http://192.168.0.111:7777/wxPay/payNotify");
|
|
||||||
// 交易类型APP
|
|
||||||
parame.put("trade_type", tradeType);
|
|
||||||
parame.put("spbill_create_ip", ip);
|
|
||||||
parame.put("openid", dto.getOpenId());
|
|
||||||
String sign = WechatUtil.arraySign(parame, order.getSecret());
|
|
||||||
// 数字签证
|
|
||||||
parame.put("sign", sign);
|
|
||||||
String xml = MapUtils.convertMap2Xml(parame);
|
|
||||||
log.info("xml:" + xml);
|
|
||||||
Map<String, Object> resultUn = XmlUtil.xmlStrToMap(WechatUtil.requestOnce(uniformorder, xml));
|
|
||||||
// 响应报文
|
|
||||||
String return_code = MapUtils.getString("return_code", resultUn);
|
|
||||||
String return_msg = MapUtils.getString("return_msg", resultUn);
|
|
||||||
if (return_code.equalsIgnoreCase("FAIL")) {
|
|
||||||
return rb.setMsg("支付失败," + return_msg);
|
|
||||||
} else if (return_code.equalsIgnoreCase("SUCCESS")) {
|
|
||||||
String prepay_id = MapUtils.getString("prepay_id", resultUn);
|
|
||||||
// 先生成paySign 参考https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_7&index=5
|
|
||||||
resultObj.put("appId", order.getAppId());
|
|
||||||
resultObj.put("timeStamp", DateUtils.timeToStr(System.currentTimeMillis() / 1000, DateUtils.DATE_TIME_PATTERN));
|
|
||||||
resultObj.put("nonceStr", nonceStr);
|
|
||||||
// resultObj.put("package", "prepay_id=" + prepay_id);
|
|
||||||
resultObj.put("package", "Sign=WXPay");
|
|
||||||
resultObj.put("partnerid", order.getMchId());
|
|
||||||
resultObj.put("signType", "MD5");
|
|
||||||
resultObj.put("prepayid", prepay_id);
|
|
||||||
String paySign = WechatUtil.arraySign(resultObj, order.getSecret());
|
|
||||||
// resultObj.put("paySign", paySign);
|
|
||||||
resultObj.put("sign", paySign);
|
|
||||||
return rb.success().setData(orderVo);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return rb.setMsg("支付失败,error=" + e.getMessage());
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return rb.success().setData(payOrderVo);
|
return rb.success().setData(payOrderVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +104,7 @@ public class OrderService extends MybatisBaseService<OrderMapper, PayOrder> {
|
|||||||
parame.put("trade_type", tradeType);
|
parame.put("trade_type", tradeType);
|
||||||
parame.put("spbill_create_ip", ip);
|
parame.put("spbill_create_ip", ip);
|
||||||
parame.put("openid", payOrder.getOpenId());
|
parame.put("openid", payOrder.getOpenId());
|
||||||
parame.put("sign_type","MD5");
|
parame.put("sign_type", "MD5");
|
||||||
String sign = WechatUtil.arraySign(parame, wxPayVo.getSecret());
|
String sign = WechatUtil.arraySign(parame, wxPayVo.getSecret());
|
||||||
// 数字签证
|
// 数字签证
|
||||||
parame.put("sign", sign);
|
parame.put("sign", sign);
|
||||||
@@ -179,9 +120,9 @@ public class OrderService extends MybatisBaseService<OrderMapper, PayOrder> {
|
|||||||
// 返回数据
|
// 返回数据
|
||||||
String result_code = MapUtils.getString("result_code", resultUn);
|
String result_code = MapUtils.getString("result_code", resultUn);
|
||||||
String err_code_des = MapUtils.getString("err_code_des", resultUn);
|
String err_code_des = MapUtils.getString("err_code_des", resultUn);
|
||||||
if(result_code.equalsIgnoreCase("FAIL")){
|
if (result_code.equalsIgnoreCase("FAIL")) {
|
||||||
return rb.setMsg("支付失败," + err_code_des);
|
return rb.setMsg("支付失败," + err_code_des);
|
||||||
}else if (result_code.equalsIgnoreCase("SUCCESS")) {
|
} else if (result_code.equalsIgnoreCase("SUCCESS")) {
|
||||||
String prepay_id = MapUtils.getString("prepay_id", resultUn);
|
String prepay_id = MapUtils.getString("prepay_id", resultUn);
|
||||||
// sign = MapUtils.getString("sign", resultUn);
|
// sign = MapUtils.getString("sign", resultUn);
|
||||||
// 先生成paySign 参考https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_7&index=5
|
// 先生成paySign 参考https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_7&index=5
|
||||||
|
|||||||
@@ -21,10 +21,5 @@ spring:
|
|||||||
port: 6379
|
port: 6379
|
||||||
timeout: 0 # 连接超时时间(毫秒)
|
timeout: 0 # 连接超时时间(毫秒)
|
||||||
|
|
||||||
image:
|
|
||||||
upload:
|
|
||||||
path: D:\\pay\\upload\\
|
|
||||||
url:
|
|
||||||
prefix: http://192.168.1.120:8111/upload/
|
|
||||||
domain:
|
domain:
|
||||||
urlPrex: http://192.168.2.110:7777
|
urlPrex: http://192.168.2.110:7777/
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
url: jdbc:mysql://127.0.0.1:3306/yxt_pay?serverTimezone=GMT%2B8&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
|
||||||
|
username: root
|
||||||
|
password: 1LAiGz$t1*Iw
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
server-addr: 127.0.0.1:8848
|
||||||
|
redis:
|
||||||
|
database: 3 # Redis数据库索引(默认为0)
|
||||||
|
host: 127.0.0.1
|
||||||
|
jedis:
|
||||||
|
pool:
|
||||||
|
max-active: -1 #连接池最大连接数(使用负值表示没有限制)
|
||||||
|
max-idle: 8 #连接池中的最大空闲连接
|
||||||
|
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||||
|
min-idle: 0 # 连接池中的最小空闲连接
|
||||||
|
password: 123456
|
||||||
|
port: 6379
|
||||||
|
timeout: 0 # 连接超时时间(毫秒)
|
||||||
|
|
||||||
|
domain:
|
||||||
|
urlPrex: https://supervise.yxtsoft.com/wxPay/
|
||||||
Reference in New Issue
Block a user