|
@@ -3,6 +3,8 @@ 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.lang.Snowflake;
|
|
|
|
|
+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 +41,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;
|
|
@@ -62,6 +66,7 @@ import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import static com.txz.mall.util.OrderUtils.getDateTime;
|
|
import static com.txz.mall.util.OrderUtils.getDateTime;
|
|
|
|
|
+import static org.springframework.data.jpa.domain.AbstractPersistable_.id;
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -86,6 +91,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() {
|
|
@@ -174,15 +181,20 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
// storeOrder.setPinkId(storePink.getId());
|
|
// storeOrder.setPinkId(storePink.getId());
|
|
|
// update(storeOrder);
|
|
// update(storeOrder);
|
|
|
// }
|
|
// }
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private DailySalesSummaryOfProductsService dailySalesSummaryOfProductsService;
|
|
|
@Override
|
|
@Override
|
|
|
public void goOpen(String orderId) {
|
|
public void goOpen(String orderId) {
|
|
|
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();
|
|
|
|
|
+ long storePinkId = IdUtil.getSnowflake(1, 3).nextId();
|
|
|
|
|
+ storePink.setId(storePinkId);
|
|
|
if (!ObjectUtils.isEmpty(user)) {
|
|
if (!ObjectUtils.isEmpty(user)) {
|
|
|
storePink.setAvatar(user.getHeadPic());
|
|
storePink.setAvatar(user.getHeadPic());
|
|
|
storePink.setNickname(user.getName());
|
|
storePink.setNickname(user.getName());
|
|
@@ -198,11 +210,12 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
storePink.setPid(storeCombination.getProductId());
|
|
storePink.setPid(storeCombination.getProductId());
|
|
|
storePink.setPeople(storeCombination.getPeople());
|
|
storePink.setPeople(storeCombination.getPeople());
|
|
|
storePink.setPrice(storeCombination.getPrice());
|
|
storePink.setPrice(storeCombination.getPrice());
|
|
|
- Date date = new Date();
|
|
|
|
|
|
|
+ Date date = storeOrder.getCreateTime();
|
|
|
Integer effectiveTime = storeCombination.getEffectiveTime();
|
|
Integer effectiveTime = storeCombination.getEffectiveTime();
|
|
|
storePink.setAddTime(date);
|
|
storePink.setAddTime(date);
|
|
|
storePink.setStopTime(DateUtils.addMinutes(date, effectiveTime));
|
|
storePink.setStopTime(DateUtils.addMinutes(date, effectiveTime));
|
|
|
storePink.setKId(0);
|
|
storePink.setKId(0);
|
|
|
|
|
+ storePink.setLId(0);
|
|
|
storePink.setUid(storeOrder.getUid());
|
|
storePink.setUid(storeOrder.getUid());
|
|
|
storePink.setIsRefund(0);
|
|
storePink.setIsRefund(0);
|
|
|
storePink.setStatus(1);
|
|
storePink.setStatus(1);
|
|
@@ -210,11 +223,16 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
|
|
|
|
|
// 插入拼团汇总表
|
|
// 插入拼团汇总表
|
|
|
StorePinkSummary storePinkSummary = new StorePinkSummary();
|
|
StorePinkSummary storePinkSummary = new StorePinkSummary();
|
|
|
|
|
+ long storePinkSummaryId = IdUtil.getSnowflake(1, 2).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 +243,36 @@ 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());
|
|
|
|
|
+ EasyToUseUtil.appCreateAssignment(date, storePink);
|
|
|
storePinkService.save(storePink);
|
|
storePinkService.save(storePink);
|
|
|
|
|
|
|
|
|
|
+ //插入每日统计表
|
|
|
|
|
+ dailySalesSummaryOfProductsService.saveDailySalesSummaryOfProducts(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
|
|
@@ -345,6 +381,8 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
StorePink storePink = new StorePink();
|
|
StorePink storePink = new StorePink();
|
|
|
BeanUtils.copyProperties(teamPink, storePink);
|
|
BeanUtils.copyProperties(teamPink, storePink);
|
|
|
storePink.setId(null);
|
|
storePink.setId(null);
|
|
|
|
|
+ long l = IdUtil.getSnowflake(1, 3).nextId();
|
|
|
|
|
+ storePink.setId(l);
|
|
|
storePink.setSpsId(dto.getSpsId());
|
|
storePink.setSpsId(dto.getSpsId());
|
|
|
storePink.setOrderId(dto.getOrderId());
|
|
storePink.setOrderId(dto.getOrderId());
|
|
|
storePink.setOrderIdKey(dto.getOrderIdKey());
|
|
storePink.setOrderIdKey(dto.getOrderIdKey());
|
|
@@ -353,6 +391,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());
|
|
@@ -362,15 +401,21 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
|
|
|
|
|
storePink.setCreateTime(date);
|
|
storePink.setCreateTime(date);
|
|
|
storePinkService.save(storePink);
|
|
storePinkService.save(storePink);
|
|
|
-
|
|
|
|
|
- Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(teamPink.getSpsId());
|
|
|
|
|
|
|
+ //插入每日统计表s
|
|
|
|
|
+ dailySalesSummaryOfProductsService.saveDailySalesSummaryOfProducts(storePink);
|
|
|
|
|
+ //**分库整改
|
|
|
|
|
+ Boolean b1 = storePinkSummaryService.maintainOrderNoSetOfTheStorePinkSummary(teamPink.getSpsCode(), dto.getOrderId());
|
|
|
|
|
+ Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(teamPink.getSpsCode());
|
|
|
|
|
|
|
|
StoreOrder storeOrder = new StoreOrder();
|
|
StoreOrder storeOrder = new StoreOrder();
|
|
|
- storeOrder.setId(dto.getOrderIdKey());
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // storeOrder.setId(dto.getOrderIdKey());
|
|
|
// 需要更新订单数据
|
|
// 需要更新订单数据
|
|
|
storeOrder.setPinkId(storePink.getId());
|
|
storeOrder.setPinkId(storePink.getId());
|
|
|
- update(storeOrder);
|
|
|
|
|
|
|
+ Condition storeOrderCondition = new Condition(StoreOrder.class);
|
|
|
|
|
+ storeOrderCondition.createCriteria().andEqualTo("orderId",dto.getOrderId());
|
|
|
|
|
+ storeOrderMapper.updateByConditionSelective(storeOrder,storeOrderCondition);
|
|
|
|
|
+ //**分库整改
|
|
|
|
|
+ // update(storeOrder);
|
|
|
// if(!b){
|
|
// if(!b){
|
|
|
// throw new ServiceException("拼团超员请选择新的拼团");
|
|
// throw new ServiceException("拼团超员请选择新的拼团");
|
|
|
// }
|
|
// }
|
|
@@ -410,15 +455,32 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
throw new ServiceException(I18nUtil.get("there.is.no.group.to.join.temporarily"));
|
|
throw new ServiceException(I18nUtil.get("there.is.no.group.to.join.temporarily"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ List<String> orderNoSetListStr = pinkSummaryList.stream().map(StorePinkSummary::getOrderNoSet).filter(orderNoSet ->!ObjectUtils.isEmpty(orderNoSet)).collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ List<String> allOrderNo = new ArrayList<>();
|
|
|
|
|
+ if(!ObjectUtils.isEmpty(orderNoSetListStr)){
|
|
|
|
|
+ for (String s : orderNoSetListStr) {
|
|
|
|
|
+ List<String> orderNoSet = JSONObject.parseArray(s, String.class);
|
|
|
|
|
+ allOrderNo.addAll(orderNoSet);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("allOrderNo:" + JSONObject.toJSONString(allOrderNo));
|
|
|
|
|
+ if(ObjectUtils.isEmpty(allOrderNo)){
|
|
|
|
|
+ throw new ServiceException(I18nUtil.get("cid.store.pink.summary.order.no.set.not.exist")+dto.getCid());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
List<Long> storePinkSummaryId = pinkSummaryList.stream().map(StorePinkSummary::getId).collect(Collectors.toList());
|
|
List<Long> storePinkSummaryId = pinkSummaryList.stream().map(StorePinkSummary::getId).collect(Collectors.toList());
|
|
|
log.info("storePinkSummaryId:" + storePinkSummaryId.toString());
|
|
log.info("storePinkSummaryId:" + storePinkSummaryId.toString());
|
|
|
Condition pinkCondition = new Condition(StorePink.class);
|
|
Condition pinkCondition = new Condition(StorePink.class);
|
|
|
Example.Criteria pinkCriteria = pinkCondition.createCriteria();
|
|
Example.Criteria pinkCriteria = pinkCondition.createCriteria();
|
|
|
pinkCriteria.andEqualTo("isDelete", 0);
|
|
pinkCriteria.andEqualTo("isDelete", 0);
|
|
|
- pinkCriteria.andEqualTo("cid", dto.getCid());
|
|
|
|
|
|
|
+ //这个条件应该是没啥用的,因为下面已经有spsId了
|
|
|
|
|
+ // pinkCriteria.andEqualTo("cid", dto.getCid());
|
|
|
List<Integer> orderStatusList = CollUtil.newArrayList(PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey(), PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey());
|
|
List<Integer> orderStatusList = CollUtil.newArrayList(PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey(), PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey());
|
|
|
|
|
+ pinkCriteria.andIn("orderId", allOrderNo);
|
|
|
pinkCriteria.andIn("orderStatus", orderStatusList);
|
|
pinkCriteria.andIn("orderStatus", orderStatusList);
|
|
|
- pinkCriteria.andIn("spsId", storePinkSummaryId);
|
|
|
|
|
|
|
+ //**分库整改
|
|
|
|
|
+ // pinkCriteria.andIn("spsId", storePinkSummaryId);
|
|
|
List<StorePink> pinkList = storePinkService.findByCondition(pinkCondition);
|
|
List<StorePink> pinkList = storePinkService.findByCondition(pinkCondition);
|
|
|
log.info("pinkList:" + pinkList.toString());
|
|
log.info("pinkList:" + pinkList.toString());
|
|
|
|
|
|
|
@@ -459,6 +521,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 +638,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();
|
|
@@ -583,7 +646,8 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
Example exampleStorePink = new Example(StorePink.class);
|
|
Example exampleStorePink = new Example(StorePink.class);
|
|
|
exampleStorePink.createCriteria().andEqualTo("orderId", storeOrder.getOrderId());
|
|
exampleStorePink.createCriteria().andEqualTo("orderId", storeOrder.getOrderId());
|
|
|
storePinkMapper.updateByConditionSelective(storePinkForUpdate, exampleStorePink);
|
|
storePinkMapper.updateByConditionSelective(storePinkForUpdate, exampleStorePink);
|
|
|
-
|
|
|
|
|
|
|
+ //维护每日统计表
|
|
|
|
|
+ dailySalesSummaryOfProductsService.updateDailySalesSummaryOfProducts(storeOrder.getOrderId(),storePinkForUpdate);
|
|
|
noticeService.addOrderNotice(NoticeEnum.ORDER_SHIPPED_SUCCESS, storeOrder.getOrderId(), storeOrder.getUid());
|
|
noticeService.addOrderNotice(NoticeEnum.ORDER_SHIPPED_SUCCESS, storeOrder.getOrderId(), storeOrder.getUid());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1315,13 +1379,19 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
Condition condition = new Condition(StoreOrder.class);
|
|
Condition condition = new Condition(StoreOrder.class);
|
|
|
Example.Criteria criteria = condition.createCriteria();
|
|
Example.Criteria criteria = condition.createCriteria();
|
|
|
criteria.andEqualTo("isDelete", 0);
|
|
criteria.andEqualTo("isDelete", 0);
|
|
|
- condition.setOrderByClause("create_time DESC");
|
|
|
|
|
criteria.andEqualTo("uid", dto.getUserId());
|
|
criteria.andEqualTo("uid", dto.getUserId());
|
|
|
|
|
+ // criteria.andBetween("createTime",)
|
|
|
|
|
+ criteria.andGreaterThanOrEqualTo("createTime",dto.getStartDate());
|
|
|
|
|
+ criteria.andLessThanOrEqualTo("createTime",dto.getEndDate());
|
|
|
|
|
+
|
|
|
|
|
+ condition.setOrderByClause("create_time DESC");
|
|
|
|
|
|
|
|
Condition pinkCondition = new Condition(StorePink.class);
|
|
Condition pinkCondition = new Condition(StorePink.class);
|
|
|
Example.Criteria pinkCriteria = pinkCondition.createCriteria();
|
|
Example.Criteria pinkCriteria = pinkCondition.createCriteria();
|
|
|
pinkCriteria.andEqualTo("isDelete", 0);
|
|
pinkCriteria.andEqualTo("isDelete", 0);
|
|
|
pinkCriteria.andEqualTo("uid", dto.getUserId());
|
|
pinkCriteria.andEqualTo("uid", dto.getUserId());
|
|
|
|
|
+ pinkCriteria.andGreaterThanOrEqualTo("createTime",dto.getStartDate());
|
|
|
|
|
+ pinkCriteria.andLessThanOrEqualTo("createTime",dto.getEndDate());
|
|
|
|
|
|
|
|
List<StorePink> pinkList = new ArrayList<>();
|
|
List<StorePink> pinkList = new ArrayList<>();
|
|
|
|
|
|
|
@@ -1344,7 +1414,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
pinkCriteria.andIn("orderStatus", Arrays.asList(PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey()));
|
|
pinkCriteria.andIn("orderStatus", Arrays.asList(PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey()));
|
|
|
pinkList = storePinkService.findByCondition(pinkCondition);
|
|
pinkList = storePinkService.findByCondition(pinkCondition);
|
|
|
if (CollUtil.isNotEmpty(pinkList)) {
|
|
if (CollUtil.isNotEmpty(pinkList)) {
|
|
|
- criteria.andIn("id", pinkList.stream().map(StorePink::getOrderIdKey).collect(Collectors.toList()));
|
|
|
|
|
|
|
+ criteria.andIn("orderId", pinkList.stream().map(StorePink::getOrderId).collect(Collectors.toList()));
|
|
|
list = findByCondition(condition);
|
|
list = findByCondition(condition);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
@@ -1354,7 +1424,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
// pinkCriteria.andIn("orderStatus", Arrays.asList(3));
|
|
// pinkCriteria.andIn("orderStatus", Arrays.asList(3));
|
|
|
pinkList = storePinkService.findByCondition(pinkCondition);
|
|
pinkList = storePinkService.findByCondition(pinkCondition);
|
|
|
if (CollUtil.isNotEmpty(pinkList)) {
|
|
if (CollUtil.isNotEmpty(pinkList)) {
|
|
|
- criteria.andIn("id", pinkList.stream().map(StorePink::getOrderIdKey).collect(Collectors.toList()));
|
|
|
|
|
|
|
+ criteria.andIn("orderId", pinkList.stream().map(StorePink::getOrderId).collect(Collectors.toList()));
|
|
|
list = findByCondition(condition);
|
|
list = findByCondition(condition);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
@@ -1363,7 +1433,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
pinkCriteria.andIn("orderStatus", Arrays.asList(PinkOrderStatusEnum.GROUP_ORDER_TO_SHIP.getKey(), PinkOrderStatusEnum.GROUP_ORDER_TO_RECEIVE.getKey(), PinkOrderStatusEnum.GROUP_ORDER_COMPLETED.getKey()));
|
|
pinkCriteria.andIn("orderStatus", Arrays.asList(PinkOrderStatusEnum.GROUP_ORDER_TO_SHIP.getKey(), PinkOrderStatusEnum.GROUP_ORDER_TO_RECEIVE.getKey(), PinkOrderStatusEnum.GROUP_ORDER_COMPLETED.getKey()));
|
|
|
pinkList = storePinkService.findByCondition(pinkCondition);
|
|
pinkList = storePinkService.findByCondition(pinkCondition);
|
|
|
if (CollUtil.isNotEmpty(pinkList)) {
|
|
if (CollUtil.isNotEmpty(pinkList)) {
|
|
|
- criteria.andIn("id", pinkList.stream().map(StorePink::getOrderIdKey).collect(Collectors.toList()));
|
|
|
|
|
|
|
+ criteria.andIn("orderId", pinkList.stream().map(StorePink::getOrderId).collect(Collectors.toList()));
|
|
|
list = findByCondition(condition);
|
|
list = findByCondition(condition);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
@@ -1379,12 +1449,12 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
Condition infoCondition = new Condition(StoreOrderInfo.class);
|
|
Condition infoCondition = new Condition(StoreOrderInfo.class);
|
|
|
Example.Criteria infoCriteria = infoCondition.createCriteria();
|
|
Example.Criteria infoCriteria = infoCondition.createCriteria();
|
|
|
infoCriteria.andEqualTo("isDelete", 0);
|
|
infoCriteria.andEqualTo("isDelete", 0);
|
|
|
- infoCriteria.andIn("orderId", list.stream().map(StoreOrder::getId).collect(Collectors.toList()));
|
|
|
|
|
|
|
+ infoCriteria.andIn("orderNo", list.stream().map(StoreOrder::getOrderId).collect(Collectors.toList()));
|
|
|
infoArrayList = storeOrderInfoService.findByCondition(infoCondition);
|
|
infoArrayList = storeOrderInfoService.findByCondition(infoCondition);
|
|
|
|
|
|
|
|
Condition statusCondition = new Condition(StoreOrderStatus.class);
|
|
Condition statusCondition = new Condition(StoreOrderStatus.class);
|
|
|
Example.Criteria statusCriteria = statusCondition.createCriteria();
|
|
Example.Criteria statusCriteria = statusCondition.createCriteria();
|
|
|
- statusCriteria.andIn("oid", list.stream().map(StoreOrder::getId).collect(Collectors.toList()));
|
|
|
|
|
|
|
+ statusCriteria.andIn("orderId", list.stream().map(StoreOrder::getOrderId).collect(Collectors.toList()));
|
|
|
statusList = storeOrderStatusService.findByCondition(statusCondition);
|
|
statusList = storeOrderStatusService.findByCondition(statusCondition);
|
|
|
|
|
|
|
|
Condition addressCondition = new Condition(UserAddress.class);
|
|
Condition addressCondition = new Condition(UserAddress.class);
|
|
@@ -1500,7 +1570,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 +1639,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 +1747,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 +1781,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 +1803,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) {
|
|
@@ -1767,9 +1860,9 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
if (!result1.getCode().equals("200")) {
|
|
if (!result1.getCode().equals("200")) {
|
|
|
throw new ServiceException(I18nUtil.get("payment.failed") + result1.getMessage());
|
|
throw new ServiceException(I18nUtil.get("payment.failed") + result1.getMessage());
|
|
|
}
|
|
}
|
|
|
- updateOrderStatus(storeOrder.getId(), pinkOrderStatusEnum.getKey());
|
|
|
|
|
|
|
+ updateOrderStatus(storeOrder.getOrderId(), pinkOrderStatusEnum.getKey());
|
|
|
log.info("pinkSuccess storeOrder1" + storeOrder);
|
|
log.info("pinkSuccess storeOrder1" + storeOrder);
|
|
|
- storePinkService.pinkSuccess(storeOrder.getPinkId(), storeOrder);
|
|
|
|
|
|
|
+ storePinkService.pinkSuccess(storeOrder.getOrderId(), storeOrder);
|
|
|
log.info("pinkSuccess storeOrder2" + storeOrder);
|
|
log.info("pinkSuccess storeOrder2" + storeOrder);
|
|
|
// goOpen(dto.getOrderId());
|
|
// goOpen(dto.getOrderId());
|
|
|
}
|
|
}
|
|
@@ -1787,9 +1880,9 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
if (!result1.getCode().equals("200")) {
|
|
if (!result1.getCode().equals("200")) {
|
|
|
throw new ServiceException(I18nUtil.get("payment.failed") + result1.getMessage());
|
|
throw new ServiceException(I18nUtil.get("payment.failed") + result1.getMessage());
|
|
|
}
|
|
}
|
|
|
- updateOrderStatus(storeOrder.getId(), pinkOrderStatusEnum.getKey());
|
|
|
|
|
|
|
+ updateOrderStatus(storeOrder.getOrderId(), pinkOrderStatusEnum.getKey());
|
|
|
log.info("storePinkService.pinkSuccess1 :" + storeOrder);
|
|
log.info("storePinkService.pinkSuccess1 :" + storeOrder);
|
|
|
- storePinkService.pinkSuccess(storeOrder.getPinkId(), storeOrder);
|
|
|
|
|
|
|
+ storePinkService.pinkSuccess(storeOrder.getOrderId(), storeOrder);
|
|
|
log.info("storePinkService.pinkSuccess2 :" + storeOrder);
|
|
log.info("storePinkService.pinkSuccess2 :" + storeOrder);
|
|
|
// goPink(dto);
|
|
// goPink(dto);
|
|
|
}
|
|
}
|
|
@@ -1855,7 +1948,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
if (!equals) {
|
|
if (!equals) {
|
|
|
throw new ServiceException(I18nUtil.get("refund.failed.please.initiate.again"));
|
|
throw new ServiceException(I18nUtil.get("refund.failed.please.initiate.again"));
|
|
|
}
|
|
}
|
|
|
- updateOrderStatus(storeOrder.getId(), pinkOrderStatusEnum.getKey());
|
|
|
|
|
|
|
+ updateOrderStatus(storeOrder.getOrderId(), pinkOrderStatusEnum.getKey());
|
|
|
// 订单状态回退
|
|
// 订单状态回退
|
|
|
// 拼团状态回退
|
|
// 拼团状态回退
|
|
|
|
|
|
|
@@ -1865,7 +1958,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
storePinkForUpdate.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
storePinkForUpdate.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
|
storePinkService.update(storePinkForUpdate);
|
|
storePinkService.update(storePinkForUpdate);
|
|
|
// 拼团汇总数量维护以及锁单标识维护
|
|
// 拼团汇总数量维护以及锁单标识维护
|
|
|
- Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(storePink.getSpsId());
|
|
|
|
|
|
|
+ Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(storePink.getSpsCode());
|
|
|
// 拼团商品数量以及m_store_combination
|
|
// 拼团商品数量以及m_store_combination
|
|
|
storeCombinationService.operationStock(storePink.getCid(), storePink.getTotalNum(), "add");
|
|
storeCombinationService.operationStock(storePink.getCid(), storePink.getTotalNum(), "add");
|
|
|
// 拼团商品规格扣库存
|
|
// 拼团商品规格扣库存
|
|
@@ -1880,7 +1973,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
|
|
|
|
|
// 关闭指系统层面的自动结束 如活动时间超时或者拼团超时由定时任务触发 不暴露给客户端
|
|
// 关闭指系统层面的自动结束 如活动时间超时或者拼团超时由定时任务触发 不暴露给客户端
|
|
|
@Override
|
|
@Override
|
|
|
- public void close(Long id) {
|
|
|
|
|
|
|
+ public void close(String orderNo) {
|
|
|
|
|
|
|
|
|
|
|
|
|
// PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_FAIL, null);
|
|
// PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_FAIL, null);
|
|
@@ -1890,9 +1983,9 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
|
|
|
- StoreOrder storeOrder = findById(id);
|
|
|
|
|
|
|
+ StoreOrder storeOrder = findBy("orderId",orderNo);
|
|
|
if (ObjectUtils.isEmpty(storeOrder)) {
|
|
if (ObjectUtils.isEmpty(storeOrder)) {
|
|
|
- throw new ServiceException("订单不存在id:" + id);
|
|
|
|
|
|
|
+ throw new ServiceException(I18nUtil.get("order.is.empty.orderid") + orderNo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey().equals(storeOrder.getStatus())) {
|
|
if (PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey().equals(storeOrder.getStatus())) {
|
|
@@ -1904,20 +1997,26 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
throw new ServiceException(I18nUtil.get("current.status.does.not.support.cancellation"));
|
|
throw new ServiceException(I18nUtil.get("current.status.does.not.support.cancellation"));
|
|
|
}
|
|
}
|
|
|
// 订单状态回退
|
|
// 订单状态回退
|
|
|
- updateOrderStatus(storeOrder.getId(), pinkOrderStatusEnum.getKey());
|
|
|
|
|
|
|
+ updateOrderStatus(storeOrder.getOrderId(), pinkOrderStatusEnum.getKey());
|
|
|
|
|
|
|
|
// 拼团状态回退
|
|
// 拼团状态回退
|
|
|
- StorePink storePink = storePinkService.findById(storeOrder.getPinkId());
|
|
|
|
|
|
|
+ StorePink storePink = storePinkService.findBy("orderId",orderNo);
|
|
|
if (ObjectUtils.isEmpty(storePink)) {
|
|
if (ObjectUtils.isEmpty(storePink)) {
|
|
|
- throw new ServiceException(I18nUtil.get("group.buying.information.does.not.exist.when.canceling.the.order.id") + storeOrder.getPinkId());
|
|
|
|
|
|
|
+ throw new ServiceException(I18nUtil.get("group.buying.information.does.not.exist.when.canceling.the.order.id") + orderNo);
|
|
|
}
|
|
}
|
|
|
StorePink storePinkForUpdate = new StorePink();
|
|
StorePink storePinkForUpdate = new StorePink();
|
|
|
- storePinkForUpdate.setId(storeOrder.getPinkId());
|
|
|
|
|
|
|
+ // storePinkForUpdate.setId(storeOrder.getPinkId());
|
|
|
storePinkForUpdate.setStatus(StorePinkStatusEnum.LOTTERY_FAILED.getKey());
|
|
storePinkForUpdate.setStatus(StorePinkStatusEnum.LOTTERY_FAILED.getKey());
|
|
|
storePinkForUpdate.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
storePinkForUpdate.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
|
- storePinkService.update(storePinkForUpdate);
|
|
|
|
|
|
|
+ Condition condition = new Condition(StorePink.class);
|
|
|
|
|
+ condition.createCriteria().andEqualTo("orderId",orderNo);
|
|
|
|
|
+ storePinkMapper.updateByConditionSelective(storePinkForUpdate,condition);
|
|
|
|
|
+ //维护每日统计表
|
|
|
|
|
+ dailySalesSummaryOfProductsService.updateDailySalesSummaryOfProducts(orderNo,storePinkForUpdate);
|
|
|
|
|
+ //**分库整改
|
|
|
|
|
+ //storePinkService.update(storePinkForUpdate);
|
|
|
// 拼团汇总数量维护以及锁单标识维护
|
|
// 拼团汇总数量维护以及锁单标识维护
|
|
|
- Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(storePink.getSpsId());
|
|
|
|
|
|
|
+ Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(storePink.getSpsCode());
|
|
|
// 拼团商品数量以及m_store_combination
|
|
// 拼团商品数量以及m_store_combination
|
|
|
storeCombinationService.operationStock(storePink.getCid(), storePink.getTotalNum(), "add");
|
|
storeCombinationService.operationStock(storePink.getCid(), storePink.getTotalNum(), "add");
|
|
|
// 拼团商品规格扣库存
|
|
// 拼团商品规格扣库存
|
|
@@ -1935,10 +2034,10 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
|
|
|
|
|
// 订单状态回退
|
|
// 订单状态回退
|
|
|
// 拼团状态回退
|
|
// 拼团状态回退
|
|
|
- StorePink storePink = storePinkService.findById(storeOrder.getPinkId());
|
|
|
|
|
|
|
+ StorePink storePink = storePinkService.findBy("orderId",orderNo);
|
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(storePink)) {
|
|
if (ObjectUtils.isEmpty(storePink)) {
|
|
|
- throw new ServiceException(I18nUtil.get("group.buying.information.does.not.exist.when.initiating.active.refund.id") + storeOrder.getPinkId());
|
|
|
|
|
|
|
+ throw new ServiceException(I18nUtil.get("group.buying.information.does.not.exist.when.initiating.active.refund.id") + orderNo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
@@ -1956,15 +2055,20 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
throw new ServiceException(I18nUtil.get("refund.failed.please.initiate.again.orderid") + storeOrder.getOrderId());
|
|
throw new ServiceException(I18nUtil.get("refund.failed.please.initiate.again.orderid") + storeOrder.getOrderId());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- updateOrderStatus(storeOrder.getId(), pinkOrderStatusEnum.getKey());
|
|
|
|
|
|
|
+ updateOrderStatus(storeOrder.getOrderId(), pinkOrderStatusEnum.getKey());
|
|
|
|
|
|
|
|
StorePink storePinkForUpdate = new StorePink();
|
|
StorePink storePinkForUpdate = new StorePink();
|
|
|
- storePinkForUpdate.setId(storeOrder.getPinkId());
|
|
|
|
|
|
|
+ //storePinkForUpdate.setId(storeOrder.getPinkId());
|
|
|
storePinkForUpdate.setStatus(StorePinkStatusEnum.LOTTERY_FAILED.getKey()); // 定时任务触发的拼团失败导致的订单退款需要设置这个状态为拼团失败状态
|
|
storePinkForUpdate.setStatus(StorePinkStatusEnum.LOTTERY_FAILED.getKey()); // 定时任务触发的拼团失败导致的订单退款需要设置这个状态为拼团失败状态
|
|
|
storePinkForUpdate.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
storePinkForUpdate.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
|
- storePinkService.update(storePinkForUpdate);
|
|
|
|
|
|
|
+ Condition condition = new Condition(StorePink.class);
|
|
|
|
|
+ condition.createCriteria().andEqualTo("orderId",orderNo);
|
|
|
|
|
+ storePinkMapper.updateByConditionSelective(storePinkForUpdate,condition);
|
|
|
|
|
+ //维护每日统计表
|
|
|
|
|
+ dailySalesSummaryOfProductsService.updateDailySalesSummaryOfProducts(orderNo,storePinkForUpdate);
|
|
|
|
|
+ //storePinkService.update(storePinkForUpdate);
|
|
|
// 拼团汇总数量维护以及锁单标识维护
|
|
// 拼团汇总数量维护以及锁单标识维护
|
|
|
- Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(storePink.getSpsId());
|
|
|
|
|
|
|
+ Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(storePink.getSpsCode());
|
|
|
// 拼团商品数量以及m_store_combination
|
|
// 拼团商品数量以及m_store_combination
|
|
|
storeCombinationService.operationStock(storePink.getCid(), storePink.getTotalNum(), "add");
|
|
storeCombinationService.operationStock(storePink.getCid(), storePink.getTotalNum(), "add");
|
|
|
// 拼团商品规格扣库存
|
|
// 拼团商品规格扣库存
|
|
@@ -1974,10 +2078,10 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
noticeService.addOrderNotice(NoticeEnum.ORDER_GROUP_BUY_FAIL, storeOrder.getOrderId(), storeOrder.getUid());
|
|
noticeService.addOrderNotice(NoticeEnum.ORDER_GROUP_BUY_FAIL, storeOrder.getOrderId(), storeOrder.getUid());
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
- throw new ServiceException(I18nUtil.get("current.status.does.not.support.refund.cancellationid") + id);
|
|
|
|
|
|
|
+ throw new ServiceException(I18nUtil.get("current.status.does.not.support.refund.cancellationid") + orderNo);
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.error(I18nUtil.get("scheduled.task.failed.to.close.the.order.order.id") + id, e);
|
|
|
|
|
|
|
+ log.error(I18nUtil.get("scheduled.task.failed.to.close.the.order.order.id") + orderNo, e);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 如果是已支付状态状态推到拼团失败退款状态
|
|
// 如果是已支付状态状态推到拼团失败退款状态
|
|
@@ -1997,7 +2101,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
public void scheduledTaskStorePinkSummaryClose() {
|
|
public void scheduledTaskStorePinkSummaryClose() {
|
|
|
|
|
|
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
|
- PageHelper.startPage(1, 10);
|
|
|
|
|
|
|
+ PageHelper.startPage(1, 50);
|
|
|
Condition pinkSummaryCondition = new Condition(StorePinkSummary.class);
|
|
Condition pinkSummaryCondition = new Condition(StorePinkSummary.class);
|
|
|
Example.Criteria pinkSummaryCriteria = pinkSummaryCondition.createCriteria();
|
|
Example.Criteria pinkSummaryCriteria = pinkSummaryCondition.createCriteria();
|
|
|
pinkSummaryCriteria.andEqualTo("isDelete", 0);
|
|
pinkSummaryCriteria.andEqualTo("isDelete", 0);
|
|
@@ -2009,34 +2113,45 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(byCondition)) {
|
|
if (!CollectionUtils.isEmpty(byCondition)) {
|
|
|
- List<Long> storePinkSummaryidList = byCondition.stream().map(StorePinkSummary::getId).collect(Collectors.toList());
|
|
|
|
|
-
|
|
|
|
|
- Condition condition = new Condition(StorePink.class);
|
|
|
|
|
- Example.Criteria criteria = condition.createCriteria();
|
|
|
|
|
- criteria.andIn("spsId", storePinkSummaryidList);
|
|
|
|
|
|
|
+ // List<Long> storePinkSummaryidList = byCondition.stream().map(StorePinkSummary::getId).collect(Collectors.toList());
|
|
|
|
|
+ List<String> getOrderNoSetList = byCondition.stream().map(StorePinkSummary::getOrderNoSet).filter(a -> !ObjectUtils.isEmpty(a)).collect(Collectors.toList());
|
|
|
|
|
+ if(!CollectionUtils.isEmpty(getOrderNoSetList)) {
|
|
|
|
|
+ for (String s : getOrderNoSetList) {
|
|
|
|
|
+ List<String> strings = JSONObject.parseArray(s, String.class);
|
|
|
|
|
+ if(!CollectionUtils.isEmpty(strings)) {
|
|
|
|
|
+ Condition condition = new Condition(StorePink.class);
|
|
|
|
|
+ Example.Criteria criteria = condition.createCriteria();
|
|
|
|
|
+ criteria.andIn("orderId", strings);
|
|
|
|
|
+
|
|
|
|
|
+ criteria.andEqualTo("isDelete", 0);
|
|
|
|
|
+ // 找出拼团待支付 和 拼团已支付的数据进行 关闭
|
|
|
|
|
+ List<Integer> statusList = CollUtil.newArrayList(
|
|
|
|
|
+ PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey()
|
|
|
|
|
+ , PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey()
|
|
|
|
|
+ );
|
|
|
|
|
+ criteria.andIn("orderStatus", statusList);
|
|
|
|
|
+
|
|
|
|
|
+ List<StorePink> storePinkListForUpdate = storePinkService.findByCondition(condition);
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(storePinkListForUpdate)) {
|
|
|
|
|
+ storePinkListForUpdate.forEach(a ->
|
|
|
|
|
+ close(a.getOrderId())
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- criteria.andEqualTo("isDelete", 0);
|
|
|
|
|
- // 找出拼团待支付 和 拼团已支付的数据进行 关闭
|
|
|
|
|
- List<Integer> statusList = CollUtil.newArrayList(
|
|
|
|
|
- PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey()
|
|
|
|
|
- , PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey()
|
|
|
|
|
- );
|
|
|
|
|
- criteria.andIn("orderStatus", statusList);
|
|
|
|
|
-
|
|
|
|
|
- List<StorePink> storePinkListForUpdate = storePinkService.findByCondition(condition);
|
|
|
|
|
- if (!CollectionUtils.isEmpty(storePinkListForUpdate)) {
|
|
|
|
|
- storePinkListForUpdate.forEach(a ->
|
|
|
|
|
- close(a.getOrderIdKey())
|
|
|
|
|
- );
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private StorePinkMapper storePinkMapper;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
- public void cancel(Long id) {
|
|
|
|
|
- StoreOrder storeOrder = findById(id);
|
|
|
|
|
|
|
+ public void cancel(String orderNo) {
|
|
|
|
|
+ StoreOrder storeOrder = findBy("orderId",orderNo);
|
|
|
if (ObjectUtils.isEmpty(storeOrder)) {
|
|
if (ObjectUtils.isEmpty(storeOrder)) {
|
|
|
throw new ServiceException(I18nUtil.get("order.does.not.exist.when.canceling.the.order.id") + id);
|
|
throw new ServiceException(I18nUtil.get("order.does.not.exist.when.canceling.the.order.id") + id);
|
|
|
}
|
|
}
|
|
@@ -2047,22 +2162,30 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 订单状态回退
|
|
// 订单状态回退
|
|
|
- updateOrderStatus(storeOrder.getId(), pinkOrderStatusEnum.getKey());
|
|
|
|
|
|
|
+ updateOrderStatus(storeOrder.getOrderId(), pinkOrderStatusEnum.getKey());
|
|
|
|
|
|
|
|
|
|
|
|
|
// 拼团状态回退
|
|
// 拼团状态回退
|
|
|
- StorePink storePink = storePinkService.findById(storeOrder.getPinkId());
|
|
|
|
|
|
|
+ StorePink storePink = storePinkService.findBy("orderId",storeOrder.getOrderId());
|
|
|
if (ObjectUtils.isEmpty(storePink)) {
|
|
if (ObjectUtils.isEmpty(storePink)) {
|
|
|
- throw new ServiceException(I18nUtil.get("group.buying.information.does.not.exist.when.canceling.the.order.id") + storeOrder.getPinkId());
|
|
|
|
|
|
|
+ throw new ServiceException(I18nUtil.get("group.buying.information.does.not.exist.when.canceling.the.order.id") + storeOrder.getOrderId());
|
|
|
}
|
|
}
|
|
|
StorePink storePinkForUpdate = new StorePink();
|
|
StorePink storePinkForUpdate = new StorePink();
|
|
|
- storePinkForUpdate.setId(storeOrder.getPinkId());
|
|
|
|
|
|
|
+ // storePinkForUpdate.setId(storeOrder.getPinkId());
|
|
|
storePinkForUpdate.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
storePinkForUpdate.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
|
- storePinkService.update(storePinkForUpdate);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ Condition storePinkCondition = new Condition(StorePink.class);
|
|
|
|
|
+ storePinkCondition.createCriteria().andEqualTo("orderId",storeOrder.getOrderId());
|
|
|
|
|
+ storePinkMapper.updateByConditionSelective(storePinkForUpdate,storePinkCondition);
|
|
|
|
|
+
|
|
|
|
|
+ //维护每日统计
|
|
|
|
|
+ dailySalesSummaryOfProductsService.updateDailySalesSummaryOfProducts(storeOrder.getOrderId(),storePinkForUpdate);
|
|
|
|
|
+
|
|
|
|
|
+ // storePinkService.update(storePinkForUpdate);
|
|
|
|
|
|
|
|
// 拼团汇总数量维护以及锁单标识维护
|
|
// 拼团汇总数量维护以及锁单标识维护
|
|
|
|
|
|
|
|
- Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(storePink.getSpsId());
|
|
|
|
|
|
|
+ Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(storePink.getSpsCode());
|
|
|
|
|
|
|
|
// 拼团商品数量以及m_store_combination
|
|
// 拼团商品数量以及m_store_combination
|
|
|
|
|
|
|
@@ -2107,7 +2230,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
if (!org.springframework.util.CollectionUtils.isEmpty(byCondition)) {
|
|
if (!org.springframework.util.CollectionUtils.isEmpty(byCondition)) {
|
|
|
try {
|
|
try {
|
|
|
for (StoreOrder storeOrder : byCondition) {
|
|
for (StoreOrder storeOrder : byCondition) {
|
|
|
- cancel(storeOrder.getId());
|
|
|
|
|
|
|
+ cancel(storeOrder.getOrderId());
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error(I18nUtil.get("failed.to.process.ordertimeoutautomaticcancel"), e);
|
|
log.error(I18nUtil.get("failed.to.process.ordertimeoutautomaticcancel"), e);
|
|
@@ -2232,19 +2355,31 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Resource
|
|
|
|
|
- private StorePinkMapper storePinkMapper;
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void updateOrderStatus(Long id, Integer status) {
|
|
|
|
|
- StoreOrder storeOrder = findById(id);
|
|
|
|
|
- storeOrder.setStatus(status);
|
|
|
|
|
|
|
+ public void updateOrderStatus(String orderNo, Integer status) {
|
|
|
|
|
+ //**分库整改
|
|
|
|
|
+ if(ObjectUtils.isEmpty(orderNo)){
|
|
|
|
|
+ throw new ServiceException(I18nUtil.get("order.code.is.empty")+orderNo);
|
|
|
|
|
+ }
|
|
|
|
|
+ StoreOrder storeOrderOri = findBy("orderId", orderNo);
|
|
|
|
|
+ if(ObjectUtils.isEmpty(storeOrderOri)){
|
|
|
|
|
+ throw new ServiceException(I18nUtil.get("order.does.not.exist")+orderNo);
|
|
|
|
|
+ }
|
|
|
|
|
+ StoreOrder storeOrderForUpdate = new StoreOrder();
|
|
|
|
|
+ storeOrderForUpdate.setStatus(status);
|
|
|
if (PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey().equals(status)) {
|
|
if (PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey().equals(status)) {
|
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
|
- storeOrder.setPayTime(date);
|
|
|
|
|
|
|
+ storeOrderForUpdate.setPayTime(date);
|
|
|
}
|
|
}
|
|
|
- update(storeOrder);
|
|
|
|
|
|
|
+ Condition storeOrderCondition = new Condition(StoreOrder.class);
|
|
|
|
|
+ storeOrderCondition.createCriteria().andEqualTo("orderId",orderNo);
|
|
|
|
|
+
|
|
|
|
|
+ int i = storeOrderMapper.updateByConditionSelective(storeOrderForUpdate, storeOrderCondition);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
// StorePink storePink = new StorePink();
|
|
// StorePink storePink = new StorePink();
|
|
|
// Example example = new Example(StorePink.class);
|
|
// Example example = new Example(StorePink.class);
|
|
@@ -2327,8 +2462,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
return recordList;
|
|
return recordList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Resource
|
|
|
|
|
- private StoreOrderMapper storeOrderMapper;
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -2349,11 +2483,11 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
|
|
|
|
|
Condition conditionStorePink = new Condition(StorePink.class);
|
|
Condition conditionStorePink = new Condition(StorePink.class);
|
|
|
Example.Criteria criteriaStorePink = conditionStorePink.createCriteria();
|
|
Example.Criteria criteriaStorePink = conditionStorePink.createCriteria();
|
|
|
- criteriaStorePink.andEqualTo("orderIdKey", storeOrderOri.getId());
|
|
|
|
|
|
|
+ criteriaStorePink.andEqualTo("orderId", storeOrderOri.getOrderId());
|
|
|
criteriaStorePink.andEqualTo("isDelete", 0);
|
|
criteriaStorePink.andEqualTo("isDelete", 0);
|
|
|
List<StorePink> storePinks = storePinkMapper.selectByCondition(conditionStorePink);
|
|
List<StorePink> storePinks = storePinkMapper.selectByCondition(conditionStorePink);
|
|
|
if (CollectionUtils.isEmpty(storePinks)) {
|
|
if (CollectionUtils.isEmpty(storePinks)) {
|
|
|
- throw new ServiceException(I18nUtil.get("group.buying.data.does.not.exist") + storeOrder.getId());
|
|
|
|
|
|
|
+ throw new ServiceException(I18nUtil.get("group.buying.data.does.not.exist") + storeOrderOri.getOrderId());
|
|
|
}
|
|
}
|
|
|
StorePink storePink = storePinks.get(0);
|
|
StorePink storePink = storePinks.get(0);
|
|
|
Integer winner = 1;
|
|
Integer winner = 1;
|
|
@@ -2362,14 +2496,19 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
if (equals1 && equals) {
|
|
if (equals1 && equals) {
|
|
|
PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrderOri, OrderEventsEnum.GROUP_PURCHASE_WIN, null);
|
|
PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrderOri, OrderEventsEnum.GROUP_PURCHASE_WIN, null);
|
|
|
if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
|
- throw new ServiceException(I18nUtil.get("current.order.status.does.not.allow.progression.to.pending.shipment.orderid") + storeOrder.getId());
|
|
|
|
|
|
|
+ throw new ServiceException(I18nUtil.get("current.order.status.does.not.allow.progression.to.pending.shipment.orderid") + storeOrder.getOrderId());
|
|
|
}
|
|
}
|
|
|
storeOrder.setStatus(pinkOrderStatusEnum.getKey());
|
|
storeOrder.setStatus(pinkOrderStatusEnum.getKey());
|
|
|
StorePink storePinkForUpdate = new StorePink();
|
|
StorePink storePinkForUpdate = new StorePink();
|
|
|
- storePinkForUpdate.setId(storePink.getId());
|
|
|
|
|
|
|
+ // storePinkForUpdate.setId(storePink.getId());
|
|
|
storePinkForUpdate.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
storePinkForUpdate.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
|
-
|
|
|
|
|
- storePinkMapper.updateByPrimaryKeySelective(storePinkForUpdate);
|
|
|
|
|
|
|
+ Condition storePinkUpdateCondition = new Condition(StorePink.class);
|
|
|
|
|
+ storePinkUpdateCondition.createCriteria().andEqualTo("orderId",storePink.getOrderId());
|
|
|
|
|
+ //**分库整改
|
|
|
|
|
+ storePinkMapper.updateByConditionSelective(storePinkForUpdate,storePinkUpdateCondition);
|
|
|
|
|
+ //维护每日统计
|
|
|
|
|
+ dailySalesSummaryOfProductsService.updateDailySalesSummaryOfProducts(storePink.getOrderId(),storePinkForUpdate);
|
|
|
|
|
+ // storePinkMapper.updateByPrimaryKeySelective(storePinkForUpdate);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2410,7 +2549,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();
|
|
@@ -2418,7 +2557,8 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
Example exampleStorePink = new Example(StorePink.class);
|
|
Example exampleStorePink = new Example(StorePink.class);
|
|
|
exampleStorePink.createCriteria().andEqualTo("orderId", storeOrder.getOrderId());
|
|
exampleStorePink.createCriteria().andEqualTo("orderId", storeOrder.getOrderId());
|
|
|
storePinkMapper.updateByConditionSelective(storePinkForUpdate, exampleStorePink);
|
|
storePinkMapper.updateByConditionSelective(storePinkForUpdate, exampleStorePink);
|
|
|
-
|
|
|
|
|
|
|
+ //维护每日统计表
|
|
|
|
|
+ dailySalesSummaryOfProductsService.updateDailySalesSummaryOfProducts(storeOrder.getOrderId(),storePinkForUpdate);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2490,4 +2630,6 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
|
|
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|