Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
d83566a416
|
|
@ -171,9 +171,9 @@ public class OrderPayController {
|
|||
String status = orderService.queryChain().select(OrderInfo::getStatus).eq(OrderInfo::getId, orderId).oneAs(String.class);
|
||||
result.setData(status);
|
||||
switch (status) {
|
||||
case "unpaid" -> result.setData("等待用户付款");
|
||||
case "done" -> result.setData("支付完成");
|
||||
case "cancelled" -> result.setData("订单已取消");
|
||||
case "unpaid" -> result.setMsg("等待用户付款");
|
||||
case "done" -> result.setMsg("支付完成");
|
||||
case "cancelled" -> result.setMsg("订单已取消");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
|
@ -247,11 +249,13 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
redisService.set(RedisCst.classKeyExpired.EXPIRED_ORDER + param.getOrderId(), "", 60 * 15);
|
||||
} else {
|
||||
if (!orderInfo.getStatus().equals(OrderStatusEnums.CANCELLED.getCode())) {
|
||||
updateChain()
|
||||
.set(OrderInfo::getStatus, OrderStatusEnums.CANCELLED.getCode())
|
||||
.eq(OrderInfo::getId, param.getOrderId())
|
||||
.update();
|
||||
rabbitPublisher.sendOrderCancelMsg(orderInfo.getId().toString());
|
||||
ThreadUtil.execAsync(() -> {
|
||||
updateChain()
|
||||
.set(OrderInfo::getStatus, OrderStatusEnums.CANCELLED.getCode())
|
||||
.eq(OrderInfo::getId, param.getOrderId())
|
||||
.update();
|
||||
rabbitPublisher.sendOrderCancelMsg(orderInfo.getId().toString());
|
||||
});
|
||||
}
|
||||
throw new ValidateException("订单已过期,请重新下单");
|
||||
}
|
||||
|
|
@ -482,7 +486,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
if (userAllPack != null) {
|
||||
if (userAllPack.equals(1)) {
|
||||
orderDetail.setPackNumber(orderDetail.getNum().subtract(orderDetail.getReturnNum()));
|
||||
if("weight".equals(orderDetail.getProductType())){
|
||||
if ("weight".equals(orderDetail.getProductType())) {
|
||||
orderDetail.setPackNumber(BigDecimal.ONE);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -561,6 +565,9 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
public void payCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson) {
|
||||
CzgPayNotifyDTO czgCallBackDto = JSONObject.parseObject(resultJson.toString(), CzgPayNotifyDTO.class);
|
||||
OrderPayment payment = paymentService.queryChain().eq(OrderPayment::getOrderNo, orderNo).one();
|
||||
if (payment == null) {
|
||||
log.error("订单支付回调失败,支付记录不存在,payment:{}", payment);
|
||||
}
|
||||
if (StrUtil.isNotBlank(payment.getTradeNumber())) {
|
||||
log.info("订单处理过,payment id:{}", payment.getId());
|
||||
return;
|
||||
|
|
@ -813,8 +820,11 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
} else {
|
||||
orderInfo.setDiscountRatio(BigDecimal.ZERO);
|
||||
}
|
||||
//0元按照现金支付处理
|
||||
if (orderInfo.getOrderAmount().compareTo(BigDecimal.ZERO) == 0) {
|
||||
orderInfo.setStatus(OrderStatusEnums.DONE.getCode());
|
||||
orderInfo.setPayType(PayEnums.CASH_PAY.getValue());
|
||||
orderInfo.setPaidTime(LocalDateTime.now());
|
||||
}
|
||||
saveOrUpdate(orderInfo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,6 +104,8 @@ public class PayServiceImpl implements PayService {
|
|||
private OrderInfo checkPay(CheckOrderPay checkOrderPay) {
|
||||
OrderInfo orderInfo = orderInfoService.checkOrderPay(checkOrderPay);
|
||||
if (orderInfo.getOrderAmount().compareTo(BigDecimal.ZERO) == 0) {
|
||||
//发送打票信息
|
||||
rabbitPublisher.sendOrderPrintMsg(orderInfo.getId().toString());
|
||||
throw new PaySuccessException();
|
||||
}
|
||||
return orderInfo;
|
||||
|
|
@ -300,9 +302,14 @@ public class PayServiceImpl implements PayService {
|
|||
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
||||
"order", payOrderNo, payParam.getAuthCode(), orderInfo.getOrderAmount()));
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.BACK_SCAN, paymentId);
|
||||
return microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(),
|
||||
// upOrderPayInfo(orderInfo.getId(), PayEnums.BACK_SCAN, paymentId);
|
||||
CzgResult<Map<String, Object>> mapCzgResult = microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(),
|
||||
"点餐支付", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
|
||||
if (mapCzgResult.getCode() == 200) {
|
||||
orderInfoService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
||||
LocalDateTime.now(), paymentId, PayEnums.BACK_SCAN);
|
||||
}
|
||||
return mapCzgResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue