支付
This commit is contained in:
@@ -114,6 +114,6 @@ public class PaymentTransaction extends BaseModel {
|
||||
|
||||
@Column
|
||||
@Comment("交易名单的主键id")
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String memberPaymentInfoId;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.v.nutz.base.payment.wxpay.controller;
|
||||
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.payment.wxpay.service.WxPayCommonService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
@@ -30,8 +29,14 @@ public class WxPayCommonController {
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@ViReturn
|
||||
public void notifyMessage(HttpServletRequest request, HttpServletResponse response){
|
||||
public void payNotify(HttpServletRequest request, HttpServletResponse response){
|
||||
wxPayCommonService.payNotify(request, response);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
public void refundNotify(HttpServletRequest request, HttpServletResponse response){
|
||||
wxPayCommonService.refundNotify(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
+18
-7
@@ -64,6 +64,8 @@ public class WxPayCommonServiceImpl implements WxPayCommonService {
|
||||
private final static int OK = 200;
|
||||
|
||||
// 1666930980 商户号
|
||||
// ww3eda050a1b5ad96e 企业微信
|
||||
// wxf12fa6175ec7c75f 微信服务号
|
||||
// 微信V3必要的支付参数,后期优化
|
||||
private final static WxPayV3Bean WX_PAY_V3_BEAN = new WxPayV3Bean(
|
||||
"ww3eda050a1b5ad96e",
|
||||
@@ -81,7 +83,8 @@ public class WxPayCommonServiceImpl implements WxPayCommonService {
|
||||
// 自定义参数,内容是统一的,但会被多次调用,直接声明
|
||||
private String serialNo;
|
||||
private String platSerialNo;
|
||||
private final String payNotifyUrl = WX_PAY_V3_BEAN.getDomain().concat("/wxPay/notifyMessage");
|
||||
private final String payNotifyUrl = WX_PAY_V3_BEAN.getDomain().concat("/wxPay/payNotify");
|
||||
private final String refundNotifyUrl = WX_PAY_V3_BEAN.getDomain().concat("/wxPay/refundNotify");
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
@@ -307,7 +310,7 @@ public class WxPayCommonServiceImpl implements WxPayCommonService {
|
||||
log.error("签名错误");
|
||||
}
|
||||
|
||||
// 支付回调,返回给微信,自己也接收不到结果,这里的返回完全没用
|
||||
// 支付回调,返回给微信,自己也接收不到结果,这里的返回没用
|
||||
response.setHeader("Content-type", ContentType.JSON.toString());
|
||||
response.getOutputStream().write(JSONUtil.toJsonStr(map).getBytes(StandardCharsets.UTF_8));
|
||||
response.flushBuffer();
|
||||
@@ -332,10 +335,11 @@ public class WxPayCommonServiceImpl implements WxPayCommonService {
|
||||
String outRefundNo = PayKit.generateStr();
|
||||
log.info("商户退款单号: {}", outRefundNo);
|
||||
|
||||
// 没用
|
||||
// List<RefundGoodsDetail> list = new ArrayList<>();
|
||||
// RefundGoodsDetail refundGoodsDetail = new RefundGoodsDetail()
|
||||
// .setMerchant_goods_id("123")
|
||||
// .setGoods_name("IJPay 测试")
|
||||
// .setGoods_name("测试")
|
||||
// .setUnit_price(1)
|
||||
// .setRefund_amount(1)
|
||||
// .setRefund_quantity(1);
|
||||
@@ -343,8 +347,8 @@ public class WxPayCommonServiceImpl implements WxPayCommonService {
|
||||
|
||||
RefundModel refundModel = new RefundModel()
|
||||
.setOut_refund_no(outRefundNo)
|
||||
.setReason("用户发起退款")
|
||||
.setNotify_url(payNotifyUrl)
|
||||
.setReason(transaction.getDescription() + "退款")
|
||||
.setNotify_url(refundNotifyUrl)
|
||||
.setAmount(new RefundAmount().setRefund(tradingAmount).setTotal(tradingAmount).setCurrency("CNY"));
|
||||
// .setGoods_detail(list);
|
||||
|
||||
@@ -379,7 +383,7 @@ public class WxPayCommonServiceImpl implements WxPayCommonService {
|
||||
record.setPaymentTransactionId(transaction.getId());
|
||||
record.setOutRefundTradeNo(outRefundNo);
|
||||
record.setRefundNo(null);
|
||||
record.setRefundState(RefundStateEnum.REFUNDING.getRefundStateName());
|
||||
record.setRefundState(RefundStateEnum.REFUNDING.name());
|
||||
record.setRefundAmount(tradingAmount);
|
||||
record.setTotal(tradingAmount);
|
||||
record.setResultJson(response.getBody());
|
||||
@@ -402,6 +406,7 @@ public class WxPayCommonServiceImpl implements WxPayCommonService {
|
||||
* @param response
|
||||
*/
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void refundNotify(HttpServletRequest request, HttpServletResponse response) {
|
||||
Map<String, String> map = new HashMap<>(12);
|
||||
try {
|
||||
@@ -427,9 +432,14 @@ public class WxPayCommonServiceImpl implements WxPayCommonService {
|
||||
if (StrUtil.isNotEmpty(plainText)) {
|
||||
// 取出明文,修改退款的结果
|
||||
JSONObject jsonObject = JSONUtil.parseObj(plainText);
|
||||
// 查询出退款记录
|
||||
// 查询出退款记录,存储关键信息并修改
|
||||
PaymentRefundRecord record = dao.fetch(PaymentRefundRecord.class, Cnd.where("outRefundTradeNo", "=", jsonObject.getStr("out_refund_no")));
|
||||
record.setRefundNo(jsonObject.getStr("refund_id"));
|
||||
record.setRefundState(RefundStateEnum.REFUND_SUCCESS.name());
|
||||
// 到此是退款成功了,还要去修改订单表的数据
|
||||
dao.update(PaymentTransaction.class, Chain.make("isRefund", true)
|
||||
.add("refundAmount", record.getRefundAmount()),
|
||||
Cnd.where("id", "=", record.getPaymentTransactionId()));
|
||||
|
||||
response.setStatus(200);
|
||||
map.put("code", "SUCCESS");
|
||||
@@ -439,6 +449,7 @@ public class WxPayCommonServiceImpl implements WxPayCommonService {
|
||||
map.put("code", "ERROR");
|
||||
map.put("message", "签名错误");
|
||||
}
|
||||
// 没用
|
||||
response.setHeader("Content-type", ContentType.JSON.toString());
|
||||
response.getOutputStream().write(JSONUtil.toJsonStr(map).getBytes(StandardCharsets.UTF_8));
|
||||
response.flushBuffer();
|
||||
|
||||
@@ -68,7 +68,7 @@ public class MemberPaymentTestController {
|
||||
@At
|
||||
@Ok("re")
|
||||
public String getCode(@Param("code") String code, @Param("state") String state){
|
||||
String openId = wxPayCommonService.getOpenId(code);
|
||||
// String openId = wxPayCommonService.getOpenId(code);
|
||||
// WxPayNeedParamVo paramVo = new WxPayNeedParamVo();
|
||||
// paramVo.setDescription("支付");
|
||||
// paramVo.setAttach("");
|
||||
|
||||
Reference in New Issue
Block a user