Compare commits
No commits in common. "295275b3dc6f3be5f5084b838542e3c85e64252f" and "a53ccaadc7ea8d59ea46f06784aad5be4739de8a" have entirely different histories.
295275b3dc
...
a53ccaadc7
@ -2,7 +2,6 @@ package com.suisung.mall.shop.number.service;
|
|||||||
|
|
||||||
import com.suisung.mall.common.modules.number.ShopNumberSeq;
|
import com.suisung.mall.common.modules.number.ShopNumberSeq;
|
||||||
import com.suisung.mall.core.web.service.IBaseService;
|
import com.suisung.mall.core.web.service.IBaseService;
|
||||||
import org.springframework.data.util.Pair;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -18,14 +17,6 @@ public interface ShopNumberSeqService extends IBaseService<ShopNumberSeq> {
|
|||||||
|
|
||||||
String createNextSeq(String prefix);
|
String createNextSeq(String prefix);
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建下一个编号(键值对)
|
|
||||||
*
|
|
||||||
* @param prefix 前缀
|
|
||||||
* @return 序号和完整编号
|
|
||||||
*/
|
|
||||||
Pair<Long, String> createNextSeqPair(String prefix);
|
|
||||||
|
|
||||||
Long createNextNo(String prefix);
|
Long createNextNo(String prefix);
|
||||||
|
|
||||||
List<Long> batchCreateNextNo(String seqName, int batchSize);
|
List<Long> batchCreateNextNo(String seqName, int batchSize);
|
||||||
|
|||||||
@ -27,7 +27,6 @@ import org.redisson.api.RLock;
|
|||||||
import org.redisson.api.RedissonClient;
|
import org.redisson.api.RedissonClient;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.data.util.Pair;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -126,44 +125,6 @@ public class ShopNumberSeqServiceImpl extends BaseServiceImpl<ShopNumberSeqMappe
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 得到下一个编号键值对
|
|
||||||
* 方法走到这里会产生串行化,集群部署这里不能使用单机锁
|
|
||||||
*
|
|
||||||
* @param prefix
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
|
||||||
@DistributedLock(
|
|
||||||
key = "CREATENEXTSEQ_LOCK", // 锁的key
|
|
||||||
waitTime = 3, // 等待3秒
|
|
||||||
leaseTime = 10, // 锁持有10秒
|
|
||||||
errorMsg = "生成ID繁忙,请稍后重试" // 自定义错误消息
|
|
||||||
)
|
|
||||||
public synchronized Pair<Long, String> createNextSeqPair(String prefix) {
|
|
||||||
String ymd = DateUtil.format(new Date(), "yyyyMMdd");
|
|
||||||
String id = String.format("%s_%s_", prefix, ymd);
|
|
||||||
ShopNumberSeq shopNumberSeq = this.baseMapper.selectById(id);
|
|
||||||
if (shopNumberSeq == null) {
|
|
||||||
shopNumberSeq = new ShopNumberSeq();
|
|
||||||
shopNumberSeq.setPrefix(id);
|
|
||||||
shopNumberSeq.setNumber(1L);
|
|
||||||
if (!save(shopNumberSeq)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String order_id = String.format("%s_%s_%s", prefix, ymd, shopNumberSeq.getNumber());
|
|
||||||
shopNumberSeq.setPrefix(id);
|
|
||||||
boolean flag = edit(shopNumberSeq);
|
|
||||||
if (flag) {
|
|
||||||
return Pair.of(shopNumberSeq.getNumber(), order_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 得到下一个Id
|
* 得到下一个Id
|
||||||
*
|
*
|
||||||
@ -576,4 +537,5 @@ public class ShopNumberSeqServiceImpl extends BaseServiceImpl<ShopNumberSeqMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5289,17 +5289,17 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
throw new ApiException(I18nUtil._("无符合取消条件的订单!"));
|
throw new ApiException(I18nUtil._("无符合取消条件的订单!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
ShopOrderBase shopOrderBaseUpd = new ShopOrderBase();
|
ShopOrderBase shopOrderBase = new ShopOrderBase();
|
||||||
shopOrderBaseUpd.setOrder_id(order_id);
|
shopOrderBase.setOrder_id(order_id);
|
||||||
shopOrderBaseUpd.setOrder_state_id(StateCode.ORDER_STATE_CANCEL);
|
shopOrderBase.setOrder_state_id(StateCode.ORDER_STATE_CANCEL);
|
||||||
if (!shopOrderBaseService.edit(shopOrderBaseUpd)) {
|
if (!shopOrderBaseService.edit(shopOrderBase)) {
|
||||||
throw new ApiException(ResultCode.FAILED);
|
throw new ApiException(ResultCode.FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShopOrderInfo orderInfoUpd = new ShopOrderInfo();
|
ShopOrderInfo orderInfo = new ShopOrderInfo();
|
||||||
orderInfoUpd.setOrder_id(order_id);
|
orderInfo.setOrder_id(order_id);
|
||||||
orderInfoUpd.setOrder_state_id(StateCode.ORDER_STATE_CANCEL);
|
orderInfo.setOrder_state_id(StateCode.ORDER_STATE_CANCEL);
|
||||||
if (!shopOrderInfoService.edit(orderInfoUpd)) {
|
if (!shopOrderInfoService.edit(orderInfo)) {
|
||||||
throw new ApiException(ResultCode.FAILED);
|
throw new ApiException(ResultCode.FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5319,7 +5319,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
if (shopOrderInfo.getDelivery_type_id() != null
|
if (shopOrderInfo.getDelivery_type_id() != null
|
||||||
&& StateCode.DELIVERY_TYPE_SAME_CITY == shopOrderInfo.getDelivery_type_id().intValue()) {
|
&& StateCode.DELIVERY_TYPE_SAME_CITY == shopOrderInfo.getDelivery_type_id().intValue()) {
|
||||||
try {
|
try {
|
||||||
logger.warn("开始取消顺丰同城配送订单,orderId: {}, delivery_type_id: {}", order_id, shopOrderInfo.getDelivery_type_id());
|
logger.info("开始取消顺丰同城配送订单,orderId: {}, delivery_type_id: {}", order_id, shopOrderInfo.getDelivery_type_id());
|
||||||
ThirdApiRes sfResult = sfExpressApiService.cancelOrder(order_id, 313, "用户或商家取消订单。");
|
ThirdApiRes sfResult = sfExpressApiService.cancelOrder(order_id, 313, "用户或商家取消订单。");
|
||||||
if (sfResult != null && !sfResult.getError_code().equals(0)) {
|
if (sfResult != null && !sfResult.getError_code().equals(0)) {
|
||||||
log.error("顺丰同城取消订单返回错误,orderId: {}, errorCode: {}, errorMsg: {}",
|
log.error("顺丰同城取消订单返回错误,orderId: {}, errorCode: {}, errorMsg: {}",
|
||||||
@ -6421,9 +6421,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
type_code = StrUtil.isBlank(type_code) ? "DD" : type_code;
|
type_code = StrUtil.isBlank(type_code) ? "DD" : type_code;
|
||||||
String xid = RootContext.getXID();
|
String xid = RootContext.getXID();
|
||||||
RootContext.unbind();
|
RootContext.unbind();
|
||||||
Pair<Long, String> seqPair = shopNumberSeqService.createNextSeqPair(type_code);// 位数的序号: DD_20251205_1 2025-12-05 1
|
String order_id = shopNumberSeqService.createNextSeq(type_code);
|
||||||
String order_id = seqPair.getSecond();
|
|
||||||
Long seqNo = seqPair.getFirst(); // 序号: DD_20251205_1 得出 1
|
|
||||||
RootContext.bind(xid);
|
RootContext.bind(xid);
|
||||||
|
|
||||||
List<ShopOrderItem> item_rows = new ArrayList();
|
List<ShopOrderItem> item_rows = new ArrayList();
|
||||||
@ -6668,7 +6666,6 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
info_row.setOrder_id(order_id);
|
info_row.setOrder_id(order_id);
|
||||||
info_row.setOrder_pickup_num(seqNo); //重要:配送员的取单号
|
|
||||||
info_row.setOrder_title(product_item_name); // 订单标题
|
info_row.setOrder_title(product_item_name); // 订单标题
|
||||||
if (fixOrderVo != null && fixOrderVo.isFix_price() && StrUtil.isNotEmpty(fixOrderVo.getOrder_title())) {
|
if (fixOrderVo != null && fixOrderVo.isFix_price() && StrUtil.isNotEmpty(fixOrderVo.getOrder_title())) {
|
||||||
info_row.setOrder_title(fixOrderVo.getOrder_title()); // 订单标题
|
info_row.setOrder_title(fixOrderVo.getOrder_title()); // 订单标题
|
||||||
|
|||||||
@ -372,8 +372,8 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
|||||||
/**
|
/**
|
||||||
* 已支付的订单,生成取单号,打票机并打印订单
|
* 已支付的订单,生成取单号,打票机并打印订单
|
||||||
*
|
*
|
||||||
* @param storeId 商家ID
|
* @param storeId
|
||||||
* @param orderId 订单ID
|
* @param orderId
|
||||||
* @return 取货单号
|
* @return 取货单号
|
||||||
*/
|
*/
|
||||||
// @Transactional
|
// @Transactional
|
||||||
@ -403,22 +403,11 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 生成取单号(废弃)
|
// 生成取单号
|
||||||
// Long orderPickupNum = genTodayPickupNum(storeId);
|
Long orderPickupNum = genTodayPickupNum(storeId);
|
||||||
// if (orderPickupNum == null || orderPickupNum <= 0) {
|
if (orderPickupNum == null || orderPickupNum <= 0) {
|
||||||
// logger.error("生成取单号失败: storeId={}", storeId);
|
logger.error("生成取单号失败: storeId={}", storeId);
|
||||||
// return 0L;
|
return 0L;
|
||||||
// }
|
|
||||||
|
|
||||||
Long orderPickupNum = 0L;
|
|
||||||
// 如果订单中尚未设置取单号,则从订单ID中提取
|
|
||||||
if (CheckUtil.isEmpty(orderInfoOld.getOrder_pickup_num())) {
|
|
||||||
// 从订单ID中提取最后的数字部分作为取单号
|
|
||||||
// 例如订单ID为 DD_20250510_11,则提取出 11 作为取单号
|
|
||||||
orderPickupNum = Convert.toLong(StrUtil.subAfter(orderId, "_", true));
|
|
||||||
} else {
|
|
||||||
// 如果已有取单号,则使用现有的
|
|
||||||
orderPickupNum = orderInfoOld.getOrder_pickup_num();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新订单信息
|
// 更新订单信息
|
||||||
@ -443,7 +432,6 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据订单Id、订单状态、配送方式、退款状态 获取订单的数量
|
* 根据订单Id、订单状态、配送方式、退款状态 获取订单的数量
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user