parent
ec32fc48f5
commit
8119c767f0
|
|
@ -14,14 +14,11 @@ import org.aspectj.lang.annotation.Pointcut;
|
||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
||||||
import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest;
|
|
||||||
|
|
||||||
import java.net.http.HttpResponse;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 方法调用统一切面处理
|
* 方法调用统一切面处理
|
||||||
|
*
|
||||||
* @author ww
|
* @author ww
|
||||||
*/
|
*/
|
||||||
@Aspect
|
@Aspect
|
||||||
|
|
@ -45,7 +42,7 @@ public class ControllerAspect {
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (int i = 0; i < args.length; i++) {
|
||||||
if (args[i] instanceof HttpServletRequest || args[i] instanceof HttpServletResponse) {
|
if (args[i] instanceof HttpServletRequest || args[i] instanceof HttpServletResponse) {
|
||||||
args[i] = null;
|
args[i] = null;
|
||||||
}else if (args[i] instanceof MultipartFile) {
|
} else if (args[i] instanceof MultipartFile) {
|
||||||
args[i] = "上传图片";
|
args[i] = "上传图片";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -63,16 +60,19 @@ public class ControllerAspect {
|
||||||
ThreadUtil.execAsync(() -> {
|
ThreadUtil.execAsync(() -> {
|
||||||
//请求的参数
|
//请求的参数
|
||||||
String resultJson = JSONObject.toJSONString(result);
|
String resultJson = JSONObject.toJSONString(result);
|
||||||
|
if (StrUtil.isNotBlank(resultJson) && resultJson.length() > 200) {
|
||||||
|
resultJson = resultJson.substring(0, 200);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (StrUtil.isNotBlank(resultJson) && !"null" .equals(resultJson)) {
|
if (StrUtil.isNotBlank(resultJson) && !"null".equals(resultJson)) {
|
||||||
log.info("""
|
log.info("""
|
||||||
|
|
||||||
>>>>>> {} {}
|
>>>>>> {} {}
|
||||||
>>>>>> IP: {}
|
>>>>>> IP: {}
|
||||||
>>>>>> execute time:{}ms
|
>>>>>> execute time:{}ms
|
||||||
>>>>>> Request: {}
|
>>>>>> Request: {}
|
||||||
>>>>>> Response: {}
|
>>>>>> Response: {}
|
||||||
""",
|
""",
|
||||||
method, requestUrl, requestIp, useTime,
|
method, requestUrl, requestIp, useTime,
|
||||||
params,
|
params,
|
||||||
resultJson
|
resultJson
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,11 @@ public class RabbitConfig {
|
||||||
return new Queue(activeProfile + "-" + RabbitConstants.Queue.PRODUCT_INFO_CHANGE_QUEUE, true);
|
return new Queue(activeProfile + "-" + RabbitConstants.Queue.PRODUCT_INFO_CHANGE_QUEUE, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Queue orderRefundQueue() {
|
||||||
|
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_REFUND_QUEUE, true);
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Primary
|
@Primary
|
||||||
public DirectExchange directExchange() {
|
public DirectExchange directExchange() {
|
||||||
|
|
@ -82,4 +87,9 @@ public class RabbitConfig {
|
||||||
public Binding bindingProductInfoChange(Queue productInfoChangeQueue, DirectExchange exchange) {
|
public Binding bindingProductInfoChange(Queue productInfoChangeQueue, DirectExchange exchange) {
|
||||||
return BindingBuilder.bind(productInfoChangeQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.PRODUCT_INFO_CHANGE_QUEUE);
|
return BindingBuilder.bind(productInfoChangeQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.PRODUCT_INFO_CHANGE_QUEUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Binding bindingOrderRefundExchange(Queue orderRefundQueue, DirectExchange exchange) {
|
||||||
|
return BindingBuilder.bind(orderRefundQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_REFUND_QUEUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ public interface RabbitConstants {
|
||||||
|
|
||||||
class Queue {
|
class Queue {
|
||||||
public static final String ORDER_STOCK_QUEUE = "order.stock.queue";
|
public static final String ORDER_STOCK_QUEUE = "order.stock.queue";
|
||||||
|
public static final String ORDER_REFUND_QUEUE = "order.refund.queue";
|
||||||
public static final String ORDER_CANCEL_QUEUE = "order.cancel.queue";
|
public static final String ORDER_CANCEL_QUEUE = "order.cancel.queue";
|
||||||
public static final String ORDER_PRINT_QUEUE = "order.print.queue";
|
public static final String ORDER_PRINT_QUEUE = "order.print.queue";
|
||||||
public static final String ORDER_MACHINE_PRINT_QUEUE = "order.machine.print.queue";
|
public static final String ORDER_MACHINE_PRINT_QUEUE = "order.machine.print.queue";
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,14 @@ public class RabbitPublisher {
|
||||||
sendMsg(RabbitConstants.Queue.ORDER_STOCK_QUEUE, orderId);
|
sendMsg(RabbitConstants.Queue.ORDER_STOCK_QUEUE, orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款库存回滚消息(未校验商品退款是否退回库存)
|
||||||
|
* @param refundMap Map <Long,BigDecimal> 商品Id,退单数量
|
||||||
|
*/
|
||||||
|
public void sendOrderRefundMsg(String refundMap) {
|
||||||
|
sendMsg(RabbitConstants.Queue.ORDER_STOCK_QUEUE, refundMap);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单打印消息
|
* 订单打印消息
|
||||||
* @param orderId 订单id
|
* @param orderId 订单id
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,19 @@ public class OrderDetail implements Serializable {
|
||||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否赠送 0否 1是
|
||||||
|
*/
|
||||||
|
@Column(ignore = true)
|
||||||
|
private Integer isGift = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public void initGift() {
|
||||||
|
if (price.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
isGift = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public BigDecimal getRefundNum() {
|
public BigDecimal getRefundNum() {
|
||||||
return refundNum == null ? BigDecimal.ZERO : refundNum;
|
return refundNum == null ? BigDecimal.ZERO : refundNum;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,10 +153,12 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||||
Map<String, List<OrderDetail>> resultMap = new HashMap<>();
|
Map<String, List<OrderDetail>> resultMap = new HashMap<>();
|
||||||
// 遍历订单详情列表
|
// 遍历订单详情列表
|
||||||
for (OrderDetail orderDetail : orderDetails) {
|
for (OrderDetail orderDetail : orderDetails) {
|
||||||
|
orderDetail.initGift();
|
||||||
// 获取当前订单详情的 placeNum
|
// 获取当前订单详情的 placeNum
|
||||||
Integer placeNum = orderDetail.getPlaceNum();
|
Integer placeNum = orderDetail.getPlaceNum();
|
||||||
// 检查 Map 中是否已经存在该 placeNum 对应的列表
|
// 检查 Map 中是否已经存在该 placeNum 对应的列表
|
||||||
resultMap.computeIfAbsent(placeNum.toString(), k -> new ArrayList<>()).add(orderDetail);
|
resultMap.computeIfAbsent(placeNum.toString(), k -> new ArrayList<>()).add(orderDetail);
|
||||||
|
|
||||||
}
|
}
|
||||||
historyOrderVo.setDetailMap(resultMap);
|
historyOrderVo.setDetailMap(resultMap);
|
||||||
return historyOrderVo;
|
return historyOrderVo;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||||
import com.czg.account.entity.*;
|
import com.czg.account.entity.*;
|
||||||
import com.czg.account.service.*;
|
import com.czg.account.service.*;
|
||||||
|
import com.czg.config.RabbitPublisher;
|
||||||
import com.czg.config.RedisCst;
|
import com.czg.config.RedisCst;
|
||||||
import com.czg.entity.req.*;
|
import com.czg.entity.req.*;
|
||||||
import com.czg.entity.resp.*;
|
import com.czg.entity.resp.*;
|
||||||
|
|
@ -44,6 +45,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -81,6 +83,8 @@ public class PayServiceImpl implements PayService {
|
||||||
private OrderPaymentService paymentService;
|
private OrderPaymentService paymentService;
|
||||||
@Resource
|
@Resource
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
@Resource
|
||||||
|
private RabbitPublisher rabbitPublisher;
|
||||||
|
|
||||||
private final BigDecimal MONEY_RATE = new BigDecimal("100");
|
private final BigDecimal MONEY_RATE = new BigDecimal("100");
|
||||||
|
|
||||||
|
|
@ -429,6 +433,7 @@ public class PayServiceImpl implements PayService {
|
||||||
BigDecimal refundAmountTotal = BigDecimal.ZERO;
|
BigDecimal refundAmountTotal = BigDecimal.ZERO;
|
||||||
//退优惠券数量 <商品id,数量>
|
//退优惠券数量 <商品id,数量>
|
||||||
Map<Long, Integer> returnCouponMap = new HashMap<>();
|
Map<Long, Integer> returnCouponMap = new HashMap<>();
|
||||||
|
Map<Long, BigDecimal> returnProMap = new HashMap<>();
|
||||||
boolean isPay = true;
|
boolean isPay = true;
|
||||||
String refPayOrderNo = "REFO" + IdUtil.getSnowflakeNextId();
|
String refPayOrderNo = "REFO" + IdUtil.getSnowflakeNextId();
|
||||||
if (orderInfo.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
|
if (orderInfo.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
|
||||||
|
|
@ -485,6 +490,7 @@ public class PayServiceImpl implements PayService {
|
||||||
|
|
||||||
}
|
}
|
||||||
orderDetailService.updateById(orderDetail);
|
orderDetailService.updateById(orderDetail);
|
||||||
|
returnProMap.put(orderDetail.getProductId(), refundDetail.getNum());
|
||||||
}
|
}
|
||||||
long count = orderDetailService.queryChain()
|
long count = orderDetailService.queryChain()
|
||||||
.eq(OrderDetail::getOrderId, orderInfo.getId())
|
.eq(OrderDetail::getOrderId, orderInfo.getId())
|
||||||
|
|
@ -497,20 +503,22 @@ public class PayServiceImpl implements PayService {
|
||||||
} else {
|
} else {
|
||||||
refundAmountTotal = param.getRefundAmount();
|
refundAmountTotal = param.getRefundAmount();
|
||||||
orderInfo.setStatus(OrderStatusEnums.REFUND.getCode());
|
orderInfo.setStatus(OrderStatusEnums.REFUND.getCode());
|
||||||
if (isPay) {
|
List<OrderDetail> orderDetails = orderDetailService.queryChain()
|
||||||
orderDetailService.updateChain()
|
.select(OrderDetail::getId, OrderDetail::getNum, OrderDetail::getReturnNum, OrderDetail::getReturnNum)
|
||||||
.eq(OrderDetail::getOrderId, param.getOrderId())
|
.eq(OrderDetail::getOrderId, orderInfo.getId())
|
||||||
.setRaw(OrderDetail::getRefundNum, "num-refund_num")
|
.list();
|
||||||
.setRaw(OrderDetail::getReturnAmount, "pay_amount")
|
for (OrderDetail orderDetail : orderDetails) {
|
||||||
.set(OrderDetail::getStatus, OrderStatusEnums.REFUND.getCode())
|
if (isPay) {
|
||||||
.update();
|
returnProMap.put(orderDetail.getProductId(), orderDetail.getNum().subtract(orderDetail.getReturnNum()).subtract(orderDetail.getRefundNum()));
|
||||||
} else {
|
orderDetail.setRefundNum(orderDetail.getNum().subtract(orderDetail.getReturnNum()));
|
||||||
orderDetailService.updateChain()
|
orderDetail.setReturnAmount(orderDetail.getPayAmount());
|
||||||
.eq(OrderDetail::getOrderId, param.getOrderId())
|
} else {
|
||||||
.setRaw(OrderDetail::getReturnNum, "num")
|
returnProMap.put(orderDetail.getProductId(), orderDetail.getNum().subtract(orderDetail.getReturnNum()));
|
||||||
.set(OrderDetail::getStatus, OrderStatusEnums.REFUND.getCode())
|
orderDetail.setReturnNum(orderDetail.getNum());
|
||||||
.update();
|
}
|
||||||
|
orderDetail.setStatus(OrderStatusEnums.REFUND.getCode());
|
||||||
}
|
}
|
||||||
|
orderDetailService.updateBatch(orderDetails);
|
||||||
}
|
}
|
||||||
//总退款金额
|
//总退款金额
|
||||||
//TODO 退款 券 未处理
|
//TODO 退款 券 未处理
|
||||||
|
|
@ -572,6 +580,8 @@ public class PayServiceImpl implements PayService {
|
||||||
}
|
}
|
||||||
orderInfo.setRefundRemark(orderInfo.getRefundRemark() + param.getRefundReason());
|
orderInfo.setRefundRemark(orderInfo.getRefundRemark() + param.getRefundReason());
|
||||||
orderInfoService.updateById(orderInfo);
|
orderInfoService.updateById(orderInfo);
|
||||||
|
//退款返还库存
|
||||||
|
rabbitPublisher.sendOrderRefundMsg(JSONObject.toJSONString(returnProMap));
|
||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue