支付状态
This commit is contained in:
parent
34e8d39e3b
commit
49f2aa85f9
|
|
@ -177,9 +177,4 @@ public class OrderPayController {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/queryOrderPay")
|
|
||||||
public CzgResult<Map<String, Object>> queryOrderPay(Long orderId) {
|
|
||||||
return payService.queryPayOrder(orderId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ package com.czg.controller;
|
||||||
|
|
||||||
import com.czg.annotation.Debounce;
|
import com.czg.annotation.Debounce;
|
||||||
import com.czg.annotation.SaStaffCheckPermission;
|
import com.czg.annotation.SaStaffCheckPermission;
|
||||||
|
import com.czg.entity.resp.CzgBaseResp;
|
||||||
|
import com.czg.order.entity.OrderInfo;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.service.order.dto.VipPayParamDTO;
|
import com.czg.service.order.dto.VipPayParamDTO;
|
||||||
import com.czg.service.order.dto.VipRefundDTO;
|
import com.czg.service.order.dto.VipRefundDTO;
|
||||||
|
|
@ -11,10 +13,7 @@ import com.czg.utils.ServletUtil;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
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.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -128,4 +127,30 @@ public class VipPayController {
|
||||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(request, "platformType"));
|
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(request, "platformType"));
|
||||||
return payService.refundVip(payParam);
|
return payService.refundVip(payParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取支付状态
|
||||||
|
*/
|
||||||
|
@GetMapping("/queryPayStatus")
|
||||||
|
public CzgResult<String> queryOrderStatus(Long shopId, String payOrderNo) {
|
||||||
|
AssertUtil.isNull(shopId, "店铺id不能为空");
|
||||||
|
AssertUtil.isBlank(payOrderNo, "支付单号不能为空");
|
||||||
|
CzgResult<String> result = CzgResult.success();
|
||||||
|
CzgResult<CzgBaseResp> queryPayOrder = payService.queryPayOrder(shopId, payOrderNo, null);
|
||||||
|
if (queryPayOrder.getCode() == 200 && queryPayOrder.getData() != null) {
|
||||||
|
String state = queryPayOrder.getData().getState();
|
||||||
|
result.setData(state);
|
||||||
|
switch (state) {
|
||||||
|
case "TRADE_AWAIT" -> result.setMsg("等待用户付款");
|
||||||
|
case "TRADE_SUCCESS" -> result.setMsg("支付成功");
|
||||||
|
case "TRADE_FAIL" -> result.setMsg("支付失败");
|
||||||
|
case "TRADE_CANCEL" -> result.setMsg("交易取消");
|
||||||
|
case "REFUND_ING" -> result.setMsg("退款中");
|
||||||
|
case "TRADE_CLOSE" -> result.setMsg("订单关闭");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return CzgResult.failure(queryPayOrder.getMsg());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,9 +104,6 @@ public interface PayService {
|
||||||
*/
|
*/
|
||||||
void refundOrder(Long shopId, Long orderId, Long payOrderId, String refPayOrderNo, String refundReason, BigDecimal refundAmount);
|
void refundOrder(Long shopId, Long orderId, Long payOrderId, String refPayOrderNo, String refundReason, BigDecimal refundAmount);
|
||||||
|
|
||||||
|
|
||||||
CzgResult<Map<String, Object>> queryPayOrder(@NonNull Long orderId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付查询
|
* 支付查询
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -328,7 +328,11 @@ public class PayServiceImpl implements PayService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (shopUser.getIsVip().equals(0)) {
|
if (shopUser.getIsVip().equals(0)) {
|
||||||
UpdateChain.of(ShopUser.class).set(ShopUser::getIsVip, 1).eq(ShopUser::getId, payParam.getShopUserId()).update();
|
UpdateChain.of(ShopUser.class)
|
||||||
|
.set(ShopUser::getIsVip, 1)
|
||||||
|
.set(ShopUser::getJoinTime, LocalDateTime.now())
|
||||||
|
.eq(ShopUser::getId, payParam.getShopUserId())
|
||||||
|
.update();
|
||||||
}
|
}
|
||||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
|
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
|
||||||
.setId(shopUser.getId())
|
.setId(shopUser.getId())
|
||||||
|
|
@ -406,8 +410,10 @@ public class PayServiceImpl implements PayService {
|
||||||
String payOrderNo = payParam.getPlatformType() + IdUtil.getSnowflakeNextId();
|
String payOrderNo = payParam.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||||
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), isFree ? "free" : "memberIn", payOrderNo,
|
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), isFree ? "free" : "memberIn", payOrderNo,
|
||||||
payParam.getAuthCode(), payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
payParam.getAuthCode(), payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
||||||
return microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, payParam.getAmount().multiply(MONEY_RATE).longValue(),
|
CzgResult<Map<String, Object>> mapCzgResult = microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, payParam.getAmount().multiply(MONEY_RATE).longValue(),
|
||||||
"会员充值", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
|
"会员充值", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
|
||||||
|
mapCzgResult.setData(Map.of("payOrderNo", payOrderNo));
|
||||||
|
return mapCzgResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -642,26 +648,6 @@ public class PayServiceImpl implements PayService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public CzgResult<Map<String, Object>> queryPayOrder(@NonNull Long orderId) {
|
|
||||||
OrderInfo orderInfo = orderInfoService.getById(orderId);
|
|
||||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
|
||||||
OrderPayment payment = paymentService.getById(orderInfo.getPayOrderId());
|
|
||||||
AssertUtil.isNull(payment, "订单不存在");
|
|
||||||
CzgResult<CzgBaseResp> res = queryPayOrder(orderInfo.getShopId(), payment.getOrderNo(), null);
|
|
||||||
CzgResult<Map<String, Object>> result = CzgResult.success();
|
|
||||||
if (res.getCode() != 200 || res.getData() == null) {
|
|
||||||
result.setCode(500);
|
|
||||||
result.setMsg(res.getMsg());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
|
||||||
map.put("payOrderId", payment.getOrderNo());
|
|
||||||
result.setData(map);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public CzgResult<CzgBaseResp> queryPayOrder(@NonNull Long shopId, String payOrderId, String mchOrderNo) {
|
public CzgResult<CzgBaseResp> queryPayOrder(@NonNull Long shopId, String payOrderId, String mchOrderNo) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue