|
@@ -3,6 +3,7 @@ package com.txz.mall.service.impl;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.poi.excel.ExcelUtil;
|
|
import cn.hutool.poi.excel.ExcelUtil;
|
|
@@ -39,6 +40,8 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
|
import org.apache.commons.lang3.StringEscapeUtils;
|
|
import org.apache.commons.lang3.StringEscapeUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.apache.ibatis.annotations.SelectKey;
|
|
|
|
|
+import org.apache.ibatis.session.ExecutorType;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
@@ -86,6 +89,8 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
private final StoreOrderStatusService storeOrderStatusService;
|
|
private final StoreOrderStatusService storeOrderStatusService;
|
|
|
private RedisUtil redisUtil;
|
|
private RedisUtil redisUtil;
|
|
|
private final CifAccountDubboServiceClient accountDubboServiceClient;
|
|
private final CifAccountDubboServiceClient accountDubboServiceClient;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private StoreOrderMapper storeOrderMapper;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public StoreOrderCountItemVO getOrderStatusNum() {
|
|
public StoreOrderCountItemVO getOrderStatusNum() {
|
|
@@ -179,7 +184,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
StoreOrder storeOrder = findBy("orderId", orderId);
|
|
StoreOrder storeOrder = findBy("orderId", orderId);
|
|
|
if (storeOrder == null) {
|
|
if (storeOrder == null) {
|
|
|
String s = I18nUtil.get("order.does.not.exist");
|
|
String s = I18nUtil.get("order.does.not.exist");
|
|
|
- throw new ServiceException(s);
|
|
|
|
|
|
|
+ throw new ServiceException(s+orderId);
|
|
|
}
|
|
}
|
|
|
UserDTO user = userDubboServiceClient.getUser(storeOrder.getUid());
|
|
UserDTO user = userDubboServiceClient.getUser(storeOrder.getUid());
|
|
|
StorePink storePink = new StorePink();
|
|
StorePink storePink = new StorePink();
|
|
@@ -210,11 +215,16 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
|
|
|
|
|
// 插入拼团汇总表
|
|
// 插入拼团汇总表
|
|
|
StorePinkSummary storePinkSummary = new StorePinkSummary();
|
|
StorePinkSummary storePinkSummary = new StorePinkSummary();
|
|
|
|
|
+ long storePinkSummaryId = IdUtil.getSnowflake(1, 1).nextId();
|
|
|
|
|
+ storePinkSummary.setId(storePinkSummaryId);
|
|
|
storePinkSummary.setTotalPrice(storeOrder.getTotalPrice());
|
|
storePinkSummary.setTotalPrice(storeOrder.getTotalPrice());
|
|
|
storePinkSummary.setCid(storeCombination.getId());
|
|
storePinkSummary.setCid(storeCombination.getId());
|
|
|
storePinkSummary.setPid(storeCombination.getProductId());
|
|
storePinkSummary.setPid(storeCombination.getProductId());
|
|
|
|
|
|
|
|
- String tgCode = OrderUtils.getTGCode();
|
|
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
|
|
|
|
|
+ String formatted = sdf.format(date);
|
|
|
|
|
+ String tgCode = OrderUtils.getTGCode(formatted);
|
|
|
|
|
+
|
|
|
storePinkSummary.setCode(tgCode);
|
|
storePinkSummary.setCode(tgCode);
|
|
|
storePinkSummary.setPeople(storeCombination.getPeople());
|
|
storePinkSummary.setPeople(storeCombination.getPeople());
|
|
|
storePinkSummary.setAddTime(date);
|
|
storePinkSummary.setAddTime(date);
|
|
@@ -225,18 +235,33 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
storePinkSummary.setIsVirtual(Boolean.TRUE); // 初始化时直接锁定,防止团长还没支付这个团就暴露出来了。等团长支付时会重新计算是否锁定
|
|
storePinkSummary.setIsVirtual(Boolean.TRUE); // 初始化时直接锁定,防止团长还没支付这个团就暴露出来了。等团长支付时会重新计算是否锁定
|
|
|
storePinkSummary.setPeopleCount(1);
|
|
storePinkSummary.setPeopleCount(1);
|
|
|
storePinkSummary.setStatus(1);
|
|
storePinkSummary.setStatus(1);
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ List<String> orderNoSet = new ArrayList<>();
|
|
|
|
|
+ orderNoSet.add(orderId);
|
|
|
|
|
+ String orderNoSetStr = JSONObject.toJSONString(orderNoSet);
|
|
|
|
|
+ storePinkSummary.setOrderNoSet(orderNoSetStr);
|
|
|
EasyToUseUtil.appCreateAssignment(date, storePinkSummary);
|
|
EasyToUseUtil.appCreateAssignment(date, storePinkSummary);
|
|
|
storePinkSummaryService.save(storePinkSummary);
|
|
storePinkSummaryService.save(storePinkSummary);
|
|
|
|
|
|
|
|
// 插入拼团详情表
|
|
// 插入拼团详情表
|
|
|
storePink.setSpsId(storePinkSummary.getId());
|
|
storePink.setSpsId(storePinkSummary.getId());
|
|
|
|
|
+ storePink.setSpsCode(storePinkSummary.getCode());
|
|
|
storePinkService.save(storePink);
|
|
storePinkService.save(storePink);
|
|
|
|
|
|
|
|
// 如果是开团,需要更新订单数据
|
|
// 如果是开团,需要更新订单数据
|
|
|
storeOrder.setPinkId(storePink.getId());
|
|
storeOrder.setPinkId(storePink.getId());
|
|
|
- update(storeOrder);
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Example exampleStoreOrder = new Example(StoreOrder.class);
|
|
|
|
|
+ exampleStoreOrder.createCriteria().andEqualTo("orderId", orderId);
|
|
|
|
|
+ storeOrder.setOrderId(null);
|
|
|
|
|
+ storeOrder.setCreateTime(null);
|
|
|
|
|
+ storeOrder.setUid(null);
|
|
|
|
|
+
|
|
|
|
|
+ storeOrderMapper.updateByConditionSelective(storeOrder,exampleStoreOrder);
|
|
|
|
|
+ //先清空分片建再设置回去传递到后面,因为分片建不允许更新
|
|
|
|
|
+ storeOrder.setOrderId(orderId);
|
|
|
|
|
+ //分库分表后下面的修改方式已经不合适了换上上面的方式
|
|
|
|
|
+ // update(storeOrder);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// @Override
|
|
// @Override
|
|
@@ -353,6 +378,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
storePink.setOrderStatus(PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey());
|
|
storePink.setOrderStatus(PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey());
|
|
|
storePink.setIsRefund(0);
|
|
storePink.setIsRefund(0);
|
|
|
storePink.setKId(1);
|
|
storePink.setKId(1);
|
|
|
|
|
+ storePink.setSpsCode(dto.getSpsCode());
|
|
|
UserDTO user = userDubboServiceClient.getUser(dto.getUserId());
|
|
UserDTO user = userDubboServiceClient.getUser(dto.getUserId());
|
|
|
if (!ObjectUtils.isEmpty(user)) {
|
|
if (!ObjectUtils.isEmpty(user)) {
|
|
|
storePink.setUid(dto.getUserId());
|
|
storePink.setUid(dto.getUserId());
|
|
@@ -459,6 +485,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
log.info("count:" + count);
|
|
log.info("count:" + count);
|
|
|
if (count > 0) {
|
|
if (count > 0) {
|
|
|
dto.setSpsId(pink.getSpsId()); // 拼团汇总表id
|
|
dto.setSpsId(pink.getSpsId()); // 拼团汇总表id
|
|
|
|
|
+ dto.setSpsCode(pink.getSpsCode()); //拼团汇总表code
|
|
|
joinGroup(pink, dto, count, pinkList.size());
|
|
joinGroup(pink, dto, count, pinkList.size());
|
|
|
} else {
|
|
} else {
|
|
|
throw new ServiceException(I18nUtil.get("the.number.of.group.buying.participants.exceeds.the.limit.please.initiate.group.buying.again.pinkid") + pink.getId());
|
|
throw new ServiceException(I18nUtil.get("the.number.of.group.buying.participants.exceeds.the.limit.please.initiate.group.buying.again.pinkid") + pink.getId());
|
|
@@ -575,7 +602,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
Example example = new Example(StoreOrder.class);
|
|
Example example = new Example(StoreOrder.class);
|
|
|
example.createCriteria().andEqualTo("orderId", storeOrder.getOrderId());
|
|
example.createCriteria().andEqualTo("orderId", storeOrder.getOrderId());
|
|
|
storeOrderMapper.updateByConditionSelective(storeOrderForUpdate, example);
|
|
storeOrderMapper.updateByConditionSelective(storeOrderForUpdate, example);
|
|
|
- storeOrderStatusService.createLog(storeOrder.getId(), Constants.ORDER_STATUS_DELIVERY_ORDER, "订单发货");
|
|
|
|
|
|
|
+ storeOrderStatusService.createLog(storeOrder.getId(),storeOrder.getOrderId(), Constants.ORDER_STATUS_DELIVERY_ORDER, "订单发货");
|
|
|
|
|
|
|
|
// 维护拼团订单状态
|
|
// 维护拼团订单状态
|
|
|
StorePink storePinkForUpdate = new StorePink();
|
|
StorePink storePinkForUpdate = new StorePink();
|
|
@@ -1500,7 +1527,21 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
@Resource
|
|
@Resource
|
|
|
private CreateSequenceService createSequenceService;
|
|
private CreateSequenceService createSequenceService;
|
|
|
|
|
|
|
|
|
|
+ private String getLastFourDigitsOfTheUserId(Long userId){
|
|
|
|
|
+ String result = "0000";
|
|
|
|
|
+ if(!ObjectUtils.isEmpty(userId)){
|
|
|
|
|
+ String userIdStr = userId.toString();
|
|
|
|
|
+ if(userIdStr.length()<4){
|
|
|
|
|
+ String aa = "0000"+userIdStr;
|
|
|
|
|
+ result = aa.substring(aa.length() - 4);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public MyRecord createOrder(CreateOrderRequest request) {
|
|
public MyRecord createOrder(CreateOrderRequest request) {
|
|
|
UserDTO user = userDubboServiceClient.getUser(request.getUserId());
|
|
UserDTO user = userDubboServiceClient.getUser(request.getUserId());
|
|
|
// 通过缓存获取预下单对象
|
|
// 通过缓存获取预下单对象
|
|
@@ -1555,11 +1596,13 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
CreateSequence createSequence = new CreateSequence();
|
|
CreateSequence createSequence = new CreateSequence();
|
|
|
createSequenceService.save(createSequence);
|
|
createSequenceService.save(createSequence);
|
|
|
|
|
|
|
|
|
|
+ Long userId = request.getUserId();
|
|
|
|
|
+ String lastFourDigitsOfTheUserId = getLastFourDigitsOfTheUserId(userId);
|
|
|
|
|
|
|
|
Long id = createSequence.getId();
|
|
Long id = createSequence.getId();
|
|
|
|
|
|
|
|
// 生成订单号
|
|
// 生成订单号
|
|
|
- String orderNo = OrderUtils.getOrderCode()+ id;
|
|
|
|
|
|
|
+ String orderNo = OrderUtils.getOrderCode()+ id +lastFourDigitsOfTheUserId;
|
|
|
|
|
|
|
|
// 购买赠送的积分
|
|
// 购买赠送的积分
|
|
|
List<StoreOrderInfo> storeOrderInfos = new ArrayList<>();
|
|
List<StoreOrderInfo> storeOrderInfos = new ArrayList<>();
|
|
@@ -1661,8 +1704,11 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
//** productAttrValueService.operationStock(skuRecord.getInt("attrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_NORMAL);
|
|
//** productAttrValueService.operationStock(skuRecord.getInt("attrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_NORMAL);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ Long snowflakeId = IdUtil.getSnowflake(1,1).nextId();
|
|
|
|
|
+ storeOrder.setId(snowflakeId);
|
|
|
save(storeOrder);
|
|
save(storeOrder);
|
|
|
|
|
+ //SELECT LAST_INSERT_ID() 被路由到默认库去了,只能通过下面到方式解决
|
|
|
|
|
+ // storeOrder = findBy("orderId", storeOrder.getOrderId());
|
|
|
for (StoreOrderInfo storeOrderInfo : storeOrderInfos) {
|
|
for (StoreOrderInfo storeOrderInfo : storeOrderInfos) {
|
|
|
storeOrderInfo.setOrderId(storeOrder.getId());
|
|
storeOrderInfo.setOrderId(storeOrder.getId());
|
|
|
storeOrderInfo.setIsDelete(0);
|
|
storeOrderInfo.setIsDelete(0);
|
|
@@ -1692,7 +1738,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
|
|
|
|
|
|
|
|
|
|
// // 生成订单日志
|
|
// // 生成订单日志
|
|
|
- storeOrderStatusService.createLog(storeOrder.getId(), Constants.ORDER_STATUS_CREATE_ORDER, "订单生成");
|
|
|
|
|
|
|
+ storeOrderStatusService.createLog(storeOrder.getId(),storeOrder.getOrderId(), Constants.ORDER_STATUS_CREATE_ORDER, "订单生成");
|
|
|
//
|
|
//
|
|
|
// // 清除购物车数据
|
|
// // 清除购物车数据
|
|
|
// if (CollUtil.isNotEmpty(orderInfoVo.getCartIdList())) {
|
|
// if (CollUtil.isNotEmpty(orderInfoVo.getCartIdList())) {
|
|
@@ -1714,6 +1760,10 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
return record;
|
|
return record;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
|
|
public com.txz.mall.core.Result goPay(GoPinkDTO dto) {
|
|
public com.txz.mall.core.Result goPay(GoPinkDTO dto) {
|
|
@@ -2327,8 +2377,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
return recordList;
|
|
return recordList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Resource
|
|
|
|
|
- private StoreOrderMapper storeOrderMapper;
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -2410,7 +2459,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
storeOrderMapper.updateByConditionSelective(storeOrderForUpdate, example);
|
|
storeOrderMapper.updateByConditionSelective(storeOrderForUpdate, example);
|
|
|
|
|
|
|
|
|
|
|
|
|
- storeOrderStatusService.createLog(storeOrder.getId(), Constants.ORDER_STATUS_RECEIVE_ORDER, I18nUtil.get("automatic.order.receipt.confirmation"));
|
|
|
|
|
|
|
+ storeOrderStatusService.createLog(storeOrder.getId(),storeOrder.getOrderId(), Constants.ORDER_STATUS_RECEIVE_ORDER, I18nUtil.get("automatic.order.receipt.confirmation"));
|
|
|
|
|
|
|
|
//维护拼团订单状态
|
|
//维护拼团订单状态
|
|
|
StorePink storePinkForUpdate = new StorePink();
|
|
StorePink storePinkForUpdate = new StorePink();
|
|
@@ -2490,4 +2539,6 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
|
|
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|