支付记录 状态

This commit is contained in:
2025-11-19 14:02:32 +08:00
parent 8d365b302a
commit 7aa1e4f215
3 changed files with 28 additions and 59 deletions

View File

@@ -2,30 +2,24 @@ package com.czg.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.thread.ThreadUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.CzgPayUtils;
import com.czg.entity.CzgBaseRespParams;
import com.czg.market.service.MkDistributionUserService;
import com.czg.market.service.TbMemberConfigService;
import com.czg.mq.PrintMqListener;
import com.czg.order.entity.OrderPayment;
import com.czg.order.service.OrderInfoService;
import com.czg.order.service.OrderPaymentService;
import com.czg.order.service.ShopTableOrderStatisticService;
import com.czg.service.market.service.impl.AppWxServiceImpl;
import com.czg.service.market.service.impl.WxServiceImpl;
import com.czg.task.StatisticTask;
import com.czg.utils.AssertUtil;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
/**
* 回调
@@ -41,32 +35,12 @@ public class NotifyController {
@Resource
private OrderInfoService orderInfoService;
@Resource
private StatisticTask statisticTask;
@Resource
private ShopTableOrderStatisticService shopTableOrderStatisticService;
@Resource
private AppWxServiceImpl wxService;
@Resource
private WxServiceImpl wxService2;
@Resource
private MkDistributionUserService distributionUserService;
@Resource
private OrderPaymentService paymentService;
@Resource
private TbMemberConfigService memberConfigService;
@GetMapping("testOpen")
public JSONObject test1(String code) throws Exception {
JSONObject czg = JSONObject.parseObject("{\"amount\":10,\"cashFee\":0,\"channelSendNo\":\"20251113110113130266202235210653\",\"channelTradeNo\":\"4200002932202511131794511090\",\"currency\":\"cny\",\"drType\":\"00\",\"ifCode\":\"lklspay\",\"mchOrderNo\":\"WX1988788559919120384\",\"mercNo\":\"B251107293903\",\"msgType\":\"sft.trade.notify\",\"note\":\"成功\",\"payOrderId\":\"2025111319887885609440501775VT\",\"payTime\":\"2025-11-13 09:58:44\",\"payType\":\"WECHAT\",\"refundAmt\":0,\"refundState\":0,\"settlementType\":\"D1\",\"state\":\"TRADE_SUCCESS\",\"storeId\":\"S2511077140\",\"subject\":\"万维时光的店铺\",\"tradeFee\":0,\"userId\":\"oVxsc1QNZRRsWdWDmTdwPJGT9BWc\"}");
AssertUtil.isNull(czg, "支付回调数据为空");
log.info("支付回调数据为:{}", czg);
orderInfoService.payCallBackOrder(czg.getString("mchOrderNo"), czg, 0);
return null;
}
@RequestMapping("/payCallBack")
@@ -92,7 +66,7 @@ public class NotifyController {
}catch (Exception e) {
log.warn("转账回调失败", e);
}
return "SUCCESS";
return SUCCESS;
}
@@ -116,21 +90,22 @@ public class NotifyController {
String outTradeNo = plainTextJson.getString("out_trade_no");
String tradeState = plainTextJson.getString("trade_state");
String transactionId = plainTextJson.getString("transaction_id");
OrderPayment payment = paymentService.getOne(new QueryWrapper().eq(OrderPayment::getOrderNo, outTradeNo));
payment.setPayStatus("fail");
if ("SUCCESS".equals(tradeState)) {
try {
OrderPayment payment = paymentService.getOne(new QueryWrapper().eq(OrderPayment::getOrderNo, outTradeNo));
payment.setTradeNumber(transactionId);
payment.setPayTime(DateUtil.date().toLocalDateTime());
payment.setRespJson(plainTextJson.toJSONString());
paymentService.updateById(payment);
payment.setPayStatus("success");
distributionUserService.rechargeCallBack(payment.getShopId(), payment.getAmount(), payment.getId());
}catch (Exception e) {
log.error("充值回调失败", e);
return "SUCCESS";
}
}
return "SUCCESS";
paymentService.updateById(payment);
return SUCCESS;
}
@@ -142,21 +117,4 @@ public class NotifyController {
orderInfoService.refundCallBackOrder(czg.getString("mchOrderNo"), czg);
return SUCCESS;
}
@Resource
private PrintMqListener printMqListener;
@RequestMapping("/test")
public void test(@RequestParam String id) {
shopTableOrderStatisticService.statistic(DateUtil.date());
}
@GetMapping("/anew/statistic/history/data")
public String statistic(@RequestParam String now) {
String format = DateUtil.format(new Date(), "yyyyMMddHHmm");
if (format.equals(now)) {
ThreadUtil.execAsync(() -> statisticTask.statisticHistoryData());
}
return SUCCESS;
}
}