|
@@ -34,6 +34,7 @@ import dto.ProductCarouselDTO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
import org.springframework.util.ObjectUtils;
|
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
@@ -42,6 +43,8 @@ import vo.StorePinkOngoingVO;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -52,25 +55,25 @@ import java.util.stream.Collectors;
|
|
|
@Transactional
|
|
@Transactional
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
public class StorePinkServiceImpl extends AbstractService<StorePink> implements StorePinkService {
|
|
public class StorePinkServiceImpl extends AbstractService<StorePink> implements StorePinkService {
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Resource
|
|
@Resource
|
|
|
private StorePinkMapper storePinkMapper;
|
|
private StorePinkMapper storePinkMapper;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Resource
|
|
@Resource
|
|
|
private CifAccountDubboServiceClient cifAccountDubboServiceClient;
|
|
private CifAccountDubboServiceClient cifAccountDubboServiceClient;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Resource
|
|
@Resource
|
|
|
private CifUserDubboServiceClient userDubboServiceClient;
|
|
private CifUserDubboServiceClient userDubboServiceClient;
|
|
|
@Resource
|
|
@Resource
|
|
|
private NoticeService noticeService;
|
|
private NoticeService noticeService;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Resource
|
|
@Resource
|
|
|
private StoreProductMapper storeProductMapper;
|
|
private StoreProductMapper storeProductMapper;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Resource
|
|
@Resource
|
|
|
private StoreCombinationMapper storeCombinationMapper;
|
|
private StoreCombinationMapper storeCombinationMapper;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public List<StorePink> getListByCidAndKid(Long cid, Long kid) {
|
|
public List<StorePink> getListByCidAndKid(Long cid, Long kid) {
|
|
|
Condition condition = new Condition(StorePink.class);
|
|
Condition condition = new Condition(StorePink.class);
|
|
@@ -81,18 +84,18 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
|
|
|
condition.setOrderByClause("id DESC");
|
|
condition.setOrderByClause("id DESC");
|
|
|
return findByCondition(condition);
|
|
return findByCondition(condition);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Resource
|
|
@Resource
|
|
|
private StorePinkSummaryService storePinkSummaryService;
|
|
private StorePinkSummaryService storePinkSummaryService;
|
|
|
@Resource
|
|
@Resource
|
|
|
private DailySalesSummaryOfProductsService dailySalesSummaryOfProductsService;
|
|
private DailySalesSummaryOfProductsService dailySalesSummaryOfProductsService;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public void pinkSuccess(String orderNo, StoreOrder storeOrder) {
|
|
public void pinkSuccess(String orderNo, StoreOrder storeOrder) {
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
// 现在这个方法每次支付的时候都会执行一次
|
|
// 现在这个方法每次支付的时候都会执行一次
|
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
|
if (ObjectUtil.isNull(orderNo)) {
|
|
if (ObjectUtil.isNull(orderNo)) {
|
|
@@ -107,21 +110,21 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
|
|
|
// storePink2.setStopTime(date);
|
|
// storePink2.setStopTime(date);
|
|
|
storePink2.setOrderStatus(PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey());
|
|
storePink2.setOrderStatus(PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey());
|
|
|
log.info("storePink2:" + storePink2);
|
|
log.info("storePink2:" + storePink2);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
Condition updateStorePinkCondition = new Condition(StorePink.class);
|
|
Condition updateStorePinkCondition = new Condition(StorePink.class);
|
|
|
updateStorePinkCondition.createCriteria().andEqualTo("orderId", orderNo);
|
|
updateStorePinkCondition.createCriteria().andEqualTo("orderId", orderNo);
|
|
|
storePinkMapper.updateByConditionSelective(storePink2, updateStorePinkCondition);
|
|
storePinkMapper.updateByConditionSelective(storePink2, updateStorePinkCondition);
|
|
|
dailySalesSummaryOfProductsService.updateDailySalesSummaryOfProducts(orderNo, storePink2);
|
|
dailySalesSummaryOfProductsService.updateDailySalesSummaryOfProducts(orderNo, storePink2);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
//**分库整改
|
|
//**分库整改
|
|
|
// update(storePink2);
|
|
// update(storePink2);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
storeOrderStatusService.createLog(storeOrder.getId(), storeOrder.getOrderId(), Constants.ORDER_LOG_PAY_SUCCESS, "支付成功");
|
|
storeOrderStatusService.createLog(storeOrder.getId(), storeOrder.getOrderId(), Constants.ORDER_LOG_PAY_SUCCESS, "支付成功");
|
|
|
noticeService.addOrderNotice(NoticeEnum.ORDER_GROUP_BUY_PAYMENT_SUCCESS, storeOrder.getOrderId(), storeOrder.getUid());
|
|
noticeService.addOrderNotice(NoticeEnum.ORDER_GROUP_BUY_PAYMENT_SUCCESS, storeOrder.getOrderId(), storeOrder.getUid());
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 累计虚拟销量,虚拟销量和下单数挂钩,和是否退款或者成团或者是否中奖都无关 只累加不扣减
|
|
// 累计虚拟销量,虚拟销量和下单数挂钩,和是否退款或者成团或者是否中奖都无关 只累加不扣减
|
|
|
Long pid = teamPink.getPid();
|
|
Long pid = teamPink.getPid();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
StoreProduct storeProduct = storeProductService.findById(pid);
|
|
StoreProduct storeProduct = storeProductService.findById(pid);
|
|
|
StoreProduct storeProductForUpdate = new StoreProduct();
|
|
StoreProduct storeProductForUpdate = new StoreProduct();
|
|
|
storeProductForUpdate.setFicti(storeProduct.getFicti() + teamPink.getTotalNum());
|
|
storeProductForUpdate.setFicti(storeProduct.getFicti() + teamPink.getTotalNum());
|
|
@@ -132,34 +135,34 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
|
|
|
if (i == 0) {
|
|
if (i == 0) {
|
|
|
throw new ServiceException(I18nUtil.get("failed.to.increase.virtual.sales.during.payment") + pid);
|
|
throw new ServiceException(I18nUtil.get("failed.to.increase.virtual.sales.during.payment") + pid);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 将虚拟销量维护到拼团商品表上防止连表查询
|
|
// 将虚拟销量维护到拼团商品表上防止连表查询
|
|
|
StoreCombination storeCombinationUpdate = new StoreCombination();
|
|
StoreCombination storeCombinationUpdate = new StoreCombination();
|
|
|
storeCombinationUpdate.setFicti(storeProduct.getFicti() + teamPink.getTotalNum());
|
|
storeCombinationUpdate.setFicti(storeProduct.getFicti() + teamPink.getTotalNum());
|
|
|
Example exampleStoreCombination = new Example(StoreCombination.class);
|
|
Example exampleStoreCombination = new Example(StoreCombination.class);
|
|
|
exampleStoreCombination.createCriteria().andEqualTo("productId", pid).andEqualTo("isDelete", 0);
|
|
exampleStoreCombination.createCriteria().andEqualTo("productId", pid).andEqualTo("isDelete", 0);
|
|
|
storeCombinationMapper.updateByConditionSelective(storeCombinationUpdate, exampleStoreCombination);
|
|
storeCombinationMapper.updateByConditionSelective(storeCombinationUpdate, exampleStoreCombination);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// memberList.add(teamPink);
|
|
// memberList.add(teamPink);
|
|
|
// memberList.forEach(i -> {
|
|
// memberList.forEach(i -> {
|
|
|
// i.setStatus(2);
|
|
// i.setStatus(2);
|
|
|
// i.setStopTime(date);
|
|
// i.setStopTime(date);
|
|
|
// update(i);
|
|
// update(i);
|
|
|
// });
|
|
// });
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 理论上在支付环节调用的时候不会出现拼团人数校验异常,所以这块调用这个方法的目的在于维护成团状态。 如果支付环节抛出了
|
|
// 理论上在支付环节调用的时候不会出现拼团人数校验异常,所以这块调用这个方法的目的在于维护成团状态。 如果支付环节抛出了
|
|
|
// 拼团校验异常则证明在 add时就有问题,没有挡住异常的拼团数据
|
|
// 拼团校验异常则证明在 add时就有问题,没有挡住异常的拼团数据
|
|
|
log.info("storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary SpsId" + teamPink.getSpsCode());
|
|
log.info("storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary SpsId" + teamPink.getSpsCode());
|
|
|
Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(teamPink.getSpsCode());
|
|
Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(teamPink.getSpsCode());
|
|
|
log.info("storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary b" + b);
|
|
log.info("storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary b" + b);
|
|
|
if (b) {
|
|
if (b) {
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 算出天选 同时推进订单状态到 代发货状态/订单关闭状态/未中奖成员退款
|
|
// 算出天选 同时推进订单状态到 代发货状态/订单关闭状态/未中奖成员退款
|
|
|
theSelection(teamPink.getSpsCode(), date);
|
|
theSelection(teamPink.getSpsCode(), date);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// @Override
|
|
// @Override
|
|
|
// public void theSelection(String orderId) {
|
|
// public void theSelection(String orderId) {
|
|
|
// // 假设只有1个用户是天选
|
|
// // 假设只有1个用户是天选
|
|
@@ -202,24 +205,18 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
|
|
|
@Lazy
|
|
@Lazy
|
|
|
@Resource
|
|
@Resource
|
|
|
private StoreProductService storeProductService;
|
|
private StoreProductService storeProductService;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Lazy
|
|
@Lazy
|
|
|
@Resource
|
|
@Resource
|
|
|
private StoreOrderStatusService storeOrderStatusService;
|
|
private StoreOrderStatusService storeOrderStatusService;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void theSelection(String spsCode, Date date) {
|
|
public void theSelection(String spsCode, Date date) {
|
|
|
log.info("theSelection:" + spsCode);
|
|
log.info("theSelection:" + spsCode);
|
|
|
- // 假设只有1个用户是天选
|
|
|
|
|
- long luckNum = 1;
|
|
|
|
|
-
|
|
|
|
|
StorePinkSummary storePinkSummary = storePinkSummaryService.findBy("code", spsCode);
|
|
StorePinkSummary storePinkSummary = storePinkSummaryService.findBy("code", spsCode);
|
|
|
- //**分库整改
|
|
|
|
|
- // StorePinkSummary storePinkSummary = storePinkSummaryService.findById(spsId);
|
|
|
|
|
if (ObjectUtils.isEmpty(storePinkSummary)) {
|
|
if (ObjectUtils.isEmpty(storePinkSummary)) {
|
|
|
throw new ServiceException(I18nUtil.get("no.group.buying.summary.records") + spsCode);
|
|
throw new ServiceException(I18nUtil.get("no.group.buying.summary.records") + spsCode);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
List<String> orderNoSetList = new ArrayList<>();
|
|
List<String> orderNoSetList = new ArrayList<>();
|
|
|
String orderNoSet = storePinkSummary.getOrderNoSet();
|
|
String orderNoSet = storePinkSummary.getOrderNoSet();
|
|
|
if (!ObjectUtils.isEmpty(orderNoSet)) {
|
|
if (!ObjectUtils.isEmpty(orderNoSet)) {
|
|
@@ -228,15 +225,10 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
|
|
|
if (ObjectUtils.isEmpty(orderNoSetList)) {
|
|
if (ObjectUtils.isEmpty(orderNoSetList)) {
|
|
|
throw new ServiceException(I18nUtil.get("store.pink.summary.order.no.set.not.exist") + spsCode);
|
|
throw new ServiceException(I18nUtil.get("store.pink.summary.order.no.set.not.exist") + spsCode);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
Condition condition = new Condition(StorePink.class);
|
|
Condition condition = new Condition(StorePink.class);
|
|
|
Example.Criteria criteria = condition.createCriteria();
|
|
Example.Criteria criteria = condition.createCriteria();
|
|
|
criteria.andEqualTo("isDelete", 0);
|
|
criteria.andEqualTo("isDelete", 0);
|
|
|
criteria.andIn("orderId", orderNoSetList);
|
|
criteria.andIn("orderId", orderNoSetList);
|
|
|
- //**分库整改
|
|
|
|
|
- // criteria.andEqualTo("spsId", spsId);
|
|
|
|
|
- // 排除团长
|
|
|
|
|
- // criteria.andEqualTo("kId", 1);
|
|
|
|
|
// 支付成功的
|
|
// 支付成功的
|
|
|
criteria.andEqualTo("orderStatus", PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey());
|
|
criteria.andEqualTo("orderStatus", PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey());
|
|
|
List<StorePink> list = findByCondition(condition);
|
|
List<StorePink> list = findByCondition(condition);
|
|
@@ -245,149 +237,208 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
|
|
|
throw new ServiceException(s + spsCode);
|
|
throw new ServiceException(s + spsCode);
|
|
|
}
|
|
}
|
|
|
long count = list.stream().filter(i -> i.getLId().equals(1)).count();
|
|
long count = list.stream().filter(i -> i.getLId().equals(1)).count();
|
|
|
- if (count >= luckNum) {
|
|
|
|
|
|
|
+ if (count >= 1) {
|
|
|
throw new ServiceException(I18nUtil.get("already.have.a.chosen.one") + spsCode);
|
|
throw new ServiceException(I18nUtil.get("already.have.a.chosen.one") + spsCode);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- Map<Long, StorePink> idStorePinkMap = list.stream().collect(Collectors.toMap(StorePink::getId, a -> a, (b, c) -> c));
|
|
|
|
|
-
|
|
|
|
|
- List<Long> idCollect = list.stream().map(StorePink::getId).collect(Collectors.toList());
|
|
|
|
|
- List<Long> randomIds = RandomUtil.uniqueRandom(idCollect, (int) luckNum);
|
|
|
|
|
-
|
|
|
|
|
AccomplishParam param = new AccomplishParam();
|
|
AccomplishParam param = new AccomplishParam();
|
|
|
-
|
|
|
|
|
param.setBizNo(storePinkSummary.getCode());
|
|
param.setBizNo(storePinkSummary.getCode());
|
|
|
param.setBizId(storePinkSummary.getId() + "");
|
|
param.setBizId(storePinkSummary.getId() + "");
|
|
|
List<OrderParam> orderParamList = new ArrayList<>();
|
|
List<OrderParam> orderParamList = new ArrayList<>();
|
|
|
-
|
|
|
|
|
- // 选出中奖单号 推进状态
|
|
|
|
|
- randomIds.forEach(i -> {
|
|
|
|
|
- StorePink luckPink = new StorePink();
|
|
|
|
|
- StorePink storePink = idStorePinkMap.get(i);
|
|
|
|
|
- StoreOrder storeOrder = storeOrderService.findBy("orderId", storePink.getOrderId());
|
|
|
|
|
- //**分库整改
|
|
|
|
|
- // StoreOrder storeOrder = storeOrderService.findById(storePink.getOrderIdKey());
|
|
|
|
|
- luckPink.setId(i);
|
|
|
|
|
- luckPink.setLId(1);
|
|
|
|
|
-
|
|
|
|
|
- luckPink.setStatus(StorePinkStatusEnum.RESULTS_ANNOUNCED.getKey());
|
|
|
|
|
- luckPink.setStopTime(date);
|
|
|
|
|
-
|
|
|
|
|
- PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_WIN, null);
|
|
|
|
|
- if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
|
|
|
- throw new ServiceException(I18nUtil.get("current.order.status.does.not.allow.progression.to.pending.shipment.orderid") + storePink.getOrderId());
|
|
|
|
|
- }
|
|
|
|
|
- if (!ObjectUtils.isEmpty(storeOrder.getAddressId())) {
|
|
|
|
|
- luckPink.setOrderStatus(PinkOrderStatusEnum.GROUP_ORDER_TO_SHIP.getKey());
|
|
|
|
|
- storeOrderService.updateOrderStatus(storePink.getOrderId(), pinkOrderStatusEnum.getKey());
|
|
|
|
|
- } else {
|
|
|
|
|
- noticeService.addOrderNotice(NoticeEnum.ORDER_PROVIDE_SHIPPING_ADDRESS, storeOrder.getOrderId(), storeOrder.getUid());
|
|
|
|
|
- }
|
|
|
|
|
- // 分库整改
|
|
|
|
|
- Condition storePinkUpdateCondition = new Condition(StorePink.class);
|
|
|
|
|
- storePinkUpdateCondition.createCriteria().andEqualTo("orderId", storePink.getOrderId());
|
|
|
|
|
- int i1 = storePinkMapper.updateByConditionSelective(luckPink, storePinkUpdateCondition);
|
|
|
|
|
- // 维护每日统计表
|
|
|
|
|
- dailySalesSummaryOfProductsService.updateDailySalesSummaryOfProducts(storePink.getOrderId(), luckPink);
|
|
|
|
|
-
|
|
|
|
|
- // update(luckPink);
|
|
|
|
|
- // 推进订单状态到待发货状态
|
|
|
|
|
-
|
|
|
|
|
- storeOrderStatusService.createLog(storeOrder.getId(), storeOrder.getOrderId(), Constants.ORDER_STATUS_PINK_SUCCESS_ORDER, "拼团成功");
|
|
|
|
|
- noticeService.addOrderNotice(NoticeEnum.ORDER_GROUP_BUY_SUCCESS_WIN, storeOrder.getOrderId(), storeOrder.getUid());
|
|
|
|
|
- // 中奖者
|
|
|
|
|
- param.setWinnerOrderNo(storeOrder.getOrderId());
|
|
|
|
|
- param.setWinnerUserId(storeOrder.getUid());
|
|
|
|
|
- Integer kId = storePink.getKId();
|
|
|
|
|
- Integer zero = 0;
|
|
|
|
|
- if (zero.equals(kId)) {
|
|
|
|
|
- param.setOpenGroupUserId(storeOrder.getUid());
|
|
|
|
|
- param.setOpenOrderNo(storeOrder.getOrderId());
|
|
|
|
|
- }
|
|
|
|
|
- // 获奖者的状态联动已经完成了所以把他从列表中移除
|
|
|
|
|
- list.remove(storePink);
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- param.setTransTime(date);
|
|
|
|
|
- // 将所有参团成员的status设置为 已开奖
|
|
|
|
|
- list.forEach(a -> {
|
|
|
|
|
- log.info("forEach a:" + JSONObject.toJSONString(a));
|
|
|
|
|
- StoreOrder storeOrder = storeOrderService.findBy("orderId", a.getOrderId());
|
|
|
|
|
- //**分库整改
|
|
|
|
|
- // StoreOrder storeOrder = storeOrderService.findById(a.getOrderIdKey());
|
|
|
|
|
- PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_NOT_WIN, null);
|
|
|
|
|
- if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
|
|
|
- throw new ServiceException(I18nUtil.get("the.current.order.status.does.not.allow.advancement.to.the.closed.status.of.unwinning.orders.orderid") + a.getOrderId());
|
|
|
|
|
- }
|
|
|
|
|
- // storePink2.setStopTime(date);
|
|
|
|
|
- StorePink unLuckPink = new StorePink();
|
|
|
|
|
- unLuckPink.setId(a.getId());
|
|
|
|
|
- unLuckPink.setStatus(StorePinkStatusEnum.RESULTS_ANNOUNCED.getKey());
|
|
|
|
|
- unLuckPink.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
|
|
|
- unLuckPink.setStopTime(date);
|
|
|
|
|
- Condition storePinkConditionForUpdate = new Condition(StorePink.class);
|
|
|
|
|
- storePinkConditionForUpdate.createCriteria().andEqualTo("orderId", a.getOrderId());
|
|
|
|
|
- int i = storePinkMapper.updateByConditionSelective(unLuckPink, storePinkConditionForUpdate);
|
|
|
|
|
- // 维护每日统计表
|
|
|
|
|
- dailySalesSummaryOfProductsService.updateDailySalesSummaryOfProducts(a.getOrderId(), unLuckPink);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- //**分库整改
|
|
|
|
|
- // update(unLuckPink);
|
|
|
|
|
-
|
|
|
|
|
- // 推进订单状态到未中奖关闭状态
|
|
|
|
|
- log.info("storeOrderService.updateOrderStatus" + JSONObject.toJSONString(a));
|
|
|
|
|
-
|
|
|
|
|
- storeOrderService.updateOrderStatus(a.getOrderId(), pinkOrderStatusEnum.getKey());
|
|
|
|
|
- storeOrderStatusService.createLog(storeOrder.getId(), storeOrder.getOrderId(), Constants.ORDER_STATUS_PINK_SUCCESS_ORDER, "拼团成功");
|
|
|
|
|
- noticeService.addOrderNotice(NoticeEnum.ORDER_GROUP_BUY_SUCCESS_LOSE, storeOrder.getOrderId(), storeOrder.getUid());
|
|
|
|
|
-
|
|
|
|
|
- // 库存回退
|
|
|
|
|
- // 拼团商品扣库存
|
|
|
|
|
- log.info("storeCombinationService.operationStock" + JSONObject.toJSONString(a));
|
|
|
|
|
- storeCombinationService.operationStock(a.getCid(), a.getTotalNum(), "add");
|
|
|
|
|
- // 拼团商品规格扣库存
|
|
|
|
|
- // productAttrValueService.operationStock(skuRecord.getInt("activityAttrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_PINGTUAN);
|
|
|
|
|
- // 普通商品口库存
|
|
|
|
|
- log.info("storeProductService.operationStock" + JSONObject.toJSONString(a));
|
|
|
|
|
- storeProductService.operationStock(a.getPid(), a.getTotalNum(), "add");
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // 非天选之子给他退款
|
|
|
|
|
- OrderParam orderParam = new OrderParam();
|
|
|
|
|
- orderParam.setOrderId(storeOrder.getId() + "");
|
|
|
|
|
- orderParam.setUserId(storeOrder.getUid());
|
|
|
|
|
- orderParam.setOrderNo(storeOrder.getOrderId());
|
|
|
|
|
-
|
|
|
|
|
- Integer kId = a.getKId();
|
|
|
|
|
- Integer zero = 0;
|
|
|
|
|
- if (zero.equals(kId)) {
|
|
|
|
|
- param.setOpenGroupUserId(storeOrder.getUid());
|
|
|
|
|
- param.setOpenOrderNo(storeOrder.getOrderId());
|
|
|
|
|
- }
|
|
|
|
|
- // 当前只能拼1个商品 所以理论上这个价格都是一样的,这边就循环覆盖即可
|
|
|
|
|
- param.setAmount(storeOrder.getPayPrice());
|
|
|
|
|
- orderParamList.add(orderParam);
|
|
|
|
|
-
|
|
|
|
|
- });
|
|
|
|
|
- log.info("orderParamList" + orderParamList);
|
|
|
|
|
- param.setUserIds(orderParamList);
|
|
|
|
|
- log.info("cifAccountDubboServiceClient.accomplishGroup" + JSONObject.toJSONString(param));
|
|
|
|
|
-
|
|
|
|
|
- Result result = cifAccountDubboServiceClient.accomplishGroup(param);
|
|
|
|
|
- log.info("cifAccountDubboServiceClient.accomplishGroup result" + result);
|
|
|
|
|
- if (!result.getCode().equals("200")) {
|
|
|
|
|
|
|
+ // 优化后:批量查询 StoreOrder
|
|
|
|
|
+ List<String> orderIds = list.stream()
|
|
|
|
|
+ .map(StorePink::getOrderId)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ Map<String, StoreOrder> orderMap = storeOrderService.findByOrderIds(orderIds)
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .collect(Collectors.toMap(StoreOrder::getOrderId, Function.identity()));
|
|
|
|
|
+ //1.随机筛选中奖者
|
|
|
|
|
+ List<StorePink> storePinks = selectWinners(list,1);
|
|
|
|
|
+ if(CollUtil.isNotEmpty(storePinks)){
|
|
|
|
|
+ StorePink winner = storePinks.get(0);
|
|
|
|
|
+ //2.中奖者
|
|
|
|
|
+ processWinner(orderMap, winner, param,date);
|
|
|
|
|
+ param.setTransTime(date);
|
|
|
|
|
+ //3.删除中奖者
|
|
|
|
|
+ list.removeIf(pink -> pink.getId().equals(winner.getId()));
|
|
|
|
|
+ //4.非中奖者处理
|
|
|
|
|
+ processLosers(orderMap, list, orderParamList, param, date);
|
|
|
|
|
+ log.info("orderParamList" + orderParamList);
|
|
|
|
|
+ param.setUserIds(orderParamList);
|
|
|
|
|
+ log.info("cifAccountDubboServiceClient.accomplishGroup" + JSONObject.toJSONString(param));
|
|
|
|
|
+ Result result = cifAccountDubboServiceClient.accomplishGroup(param);
|
|
|
|
|
+ log.info("cifAccountDubboServiceClient.accomplishGroup result" + result);
|
|
|
|
|
+ if (!result.getCode().equals("200")) {
|
|
|
throw new ServiceException(I18nUtil.get("refund.failed.for.users.who.did.not.win.the.group.buying.message") + result.getMessage());
|
|
throw new ServiceException(I18nUtil.get("refund.failed.for.users.who.did.not.win.the.group.buying.message") + result.getMessage());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 使用更高效的随机算法
|
|
|
|
|
+ private List<StorePink> selectWinners(List<StorePink> candidates, int winnerCount) {
|
|
|
|
|
+ if (CollectionUtils.isEmpty(candidates) || winnerCount <= 0) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+ // 如果候选者数量小于等于需要选择的数量,直接返回所有候选者
|
|
|
|
|
+ if (candidates.size() <= winnerCount) {
|
|
|
|
|
+ return new ArrayList<>(candidates);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // 使用Collections.shuffle进行随机打乱
|
|
|
|
|
+ List<StorePink> shuffled = new ArrayList<>(candidates);
|
|
|
|
|
+ Collections.shuffle(shuffled, new Random());
|
|
|
|
|
+ // 返回前winnerCount个作为中奖者
|
|
|
|
|
+ return shuffled.subList(0, winnerCount);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 将大事务拆分为多个小事务
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
|
+ public void processWinner(Map<String, StoreOrder> orderMap,
|
|
|
|
|
+ StorePink storePink, AccomplishParam param,Date date) {
|
|
|
|
|
+ // 处理单个中奖者
|
|
|
|
|
+ StorePink luckPink = new StorePink();
|
|
|
|
|
+ StoreOrder storeOrder = orderMap.get(storePink.getOrderId());
|
|
|
|
|
+ if(storeOrder == null){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ luckPink.setId(storePink.getId());
|
|
|
|
|
+ luckPink.setLId(1);
|
|
|
|
|
+ luckPink.setStatus(StorePinkStatusEnum.RESULTS_ANNOUNCED.getKey());
|
|
|
|
|
+ luckPink.setStopTime(date);
|
|
|
|
|
+
|
|
|
|
|
+ PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_WIN, null);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
|
|
|
+ throw new ServiceException(I18nUtil.get("current.order.status.does.not.allow.progression.to.pending.shipment.orderid") + storePink.getOrderId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!ObjectUtils.isEmpty(storeOrder.getAddressId())) {
|
|
|
|
|
+ luckPink.setOrderStatus(PinkOrderStatusEnum.GROUP_ORDER_TO_SHIP.getKey());
|
|
|
|
|
+ storeOrderService.updateOrderStatus(storePink.getOrderId(), pinkOrderStatusEnum.getKey());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ noticeService.addOrderNotice(NoticeEnum.ORDER_PROVIDE_SHIPPING_ADDRESS, storeOrder.getOrderId(), storeOrder.getUid());
|
|
|
|
|
+ }
|
|
|
|
|
+ Condition storePinkUpdateCondition = new Condition(StorePink.class);
|
|
|
|
|
+ storePinkUpdateCondition.createCriteria().andEqualTo("orderId", storePink.getOrderId());
|
|
|
|
|
+ storePinkMapper.updateByConditionSelective(luckPink, storePinkUpdateCondition);
|
|
|
|
|
+ // 维护每日统计表
|
|
|
|
|
+ dailySalesSummaryOfProductsService.updateDailySalesSummaryOfProducts(storePink.getOrderId(), luckPink);
|
|
|
|
|
+ //异步添加日志
|
|
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ storeOrderStatusService.createLog(storeOrder.getId(), storeOrder.getOrderId(), Constants.ORDER_STATUS_PINK_SUCCESS_ORDER, "拼团成功");
|
|
|
|
|
+ noticeService.addOrderNotice(NoticeEnum.ORDER_GROUP_BUY_SUCCESS_WIN, storeOrder.getOrderId(), storeOrder.getUid());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("异步处理订单后续操作异常,", e);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ // 中奖者
|
|
|
|
|
+ param.setWinnerOrderNo(storeOrder.getOrderId());
|
|
|
|
|
+ param.setWinnerUserId(storeOrder.getUid());
|
|
|
|
|
+ Integer kId = storePink.getKId();
|
|
|
|
|
+ Integer zero = 0;
|
|
|
|
|
+ if (zero.equals(kId)) {
|
|
|
|
|
+ param.setOpenGroupUserId(storeOrder.getUid());
|
|
|
|
|
+ param.setOpenOrderNo(storeOrder.getOrderId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
|
+ public void processLosers(Map<String, StoreOrder> orderMap,
|
|
|
|
|
+ List<StorePink> loserPinks,
|
|
|
|
|
+ List<OrderParam> orderParamList,
|
|
|
|
|
+ AccomplishParam param,
|
|
|
|
|
+ Date date) {
|
|
|
|
|
+ // 批量处理未中奖者
|
|
|
|
|
+ loserPinks.forEach(a -> {
|
|
|
|
|
+ log.info("forEach a:" + JSONObject.toJSONString(a));
|
|
|
|
|
+ StoreOrder storeOrder = orderMap.get(a.getOrderId());
|
|
|
|
|
+ if(storeOrder == null){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_NOT_WIN, null);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
|
|
|
+ throw new ServiceException(I18nUtil.get("the.current.order.status.does.not.allow.advancement.to.the.closed.status.of.unwinning.orders.orderid") + a.getOrderId());
|
|
|
|
|
+ }
|
|
|
|
|
+ StorePink unLuckPink = new StorePink();
|
|
|
|
|
+ unLuckPink.setId(a.getId());
|
|
|
|
|
+ unLuckPink.setStatus(StorePinkStatusEnum.RESULTS_ANNOUNCED.getKey());
|
|
|
|
|
+ unLuckPink.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
|
|
|
+ unLuckPink.setStopTime(date);
|
|
|
|
|
+ Condition storePinkConditionForUpdate = new Condition(StorePink.class);
|
|
|
|
|
+ storePinkConditionForUpdate.createCriteria().andEqualTo("orderId", a.getOrderId());
|
|
|
|
|
+ storePinkMapper.updateByConditionSelective(unLuckPink, storePinkConditionForUpdate);
|
|
|
|
|
+ // 维护每日统计表
|
|
|
|
|
+ dailySalesSummaryOfProductsService.updateDailySalesSummaryOfProducts(a.getOrderId(), unLuckPink);
|
|
|
|
|
+ // 推进订单状态到未中奖关闭状态
|
|
|
|
|
+ log.info("storeOrderService.updateOrderStatus" + JSONObject.toJSONString(a));
|
|
|
|
|
+ storeOrderService.updateOrderStatus(a.getOrderId(), pinkOrderStatusEnum.getKey());
|
|
|
|
|
+// storeOrderStatusService.createLog(storeOrder.getId(), storeOrder.getOrderId(), Constants.ORDER_STATUS_PINK_SUCCESS_ORDER, "拼团成功");
|
|
|
|
|
+// noticeService.addOrderNotice(NoticeEnum.ORDER_GROUP_BUY_SUCCESS_LOSE, storeOrder.getOrderId(), storeOrder.getUid());
|
|
|
|
|
+ // 库存回退
|
|
|
|
|
+// // 拼团商品扣库存
|
|
|
|
|
+// log.info("storeCombinationService.operationStock" + JSONObject.toJSONString(a));
|
|
|
|
|
+// storeCombinationService.operationStock(a.getCid(), a.getTotalNum(), "add");
|
|
|
|
|
+// // 普通商品口库存
|
|
|
|
|
+// log.info("storeProductService.operationStock" + JSONObject.toJSONString(a));
|
|
|
|
|
+// storeProductService.operationStock(a.getPid(), a.getTotalNum(), "add");
|
|
|
|
|
+ // 非天选之子给他退款
|
|
|
|
|
+ OrderParam orderParam = new OrderParam();
|
|
|
|
|
+ orderParam.setOrderId(storeOrder.getId() + "");
|
|
|
|
|
+ orderParam.setUserId(storeOrder.getUid());
|
|
|
|
|
+ orderParam.setOrderNo(storeOrder.getOrderId());
|
|
|
|
|
+ Integer kId = a.getKId();
|
|
|
|
|
+ Integer zero = 0;
|
|
|
|
|
+ if (zero.equals(kId)) {
|
|
|
|
|
+ param.setOpenGroupUserId(storeOrder.getUid());
|
|
|
|
|
+ param.setOpenOrderNo(storeOrder.getOrderId());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 当前只能拼1个商品 所以理论上这个价格都是一样的,这边就循环覆盖即可
|
|
|
|
|
+ param.setAmount(storeOrder.getPayPrice());
|
|
|
|
|
+ orderParamList.add(orderParam);
|
|
|
|
|
+ });
|
|
|
|
|
+ //1.库存处理
|
|
|
|
|
+ //实际买的sku 都是一样的。库存处理
|
|
|
|
|
+ // 批量处理库存回退
|
|
|
|
|
+ Map<Long, Integer> combinationStockMap = loserPinks.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
|
|
+ StorePink::getCid,
|
|
|
|
|
+ Collectors.summingInt(StorePink::getTotalNum)
|
|
|
|
|
+ ));
|
|
|
|
|
+ Map<Long, Integer> productStockMap = loserPinks.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
|
|
+ StorePink::getPid,
|
|
|
|
|
+ Collectors.summingInt(StorePink::getTotalNum)
|
|
|
|
|
+ ));
|
|
|
|
|
+ // 批量更新库存
|
|
|
|
|
+ combinationStockMap.forEach((cid, num) ->
|
|
|
|
|
+ storeCombinationService.operationStock(cid, num, "add"));
|
|
|
|
|
+ productStockMap.forEach((pid, num) ->
|
|
|
|
|
+ storeProductService.operationStock(pid, num, "add"));
|
|
|
|
|
+ //2.异步添加日志
|
|
|
|
|
+ asyncProcessOrder(orderMap,loserPinks);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 异步处理非关键业务逻辑
|
|
|
|
|
+ private void asyncProcessOrder(Map<String, StoreOrder> orderMap,
|
|
|
|
|
+ List<StorePink> loserPinks) {
|
|
|
|
|
+ // 使用线程池异步处理日志记录、通知等非关键业务
|
|
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ loserPinks.forEach(a -> {
|
|
|
|
|
+ StoreOrder storeOrder = orderMap.get(a.getOrderId());
|
|
|
|
|
+ if (storeOrder == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ storeOrderStatusService.createLog(storeOrder.getId(), storeOrder.getOrderId(), Constants.ORDER_STATUS_PINK_SUCCESS_ORDER, "拼团成功");
|
|
|
|
|
+ noticeService.addOrderNotice(NoticeEnum.ORDER_GROUP_BUY_SUCCESS_LOSE, storeOrder.getOrderId(), storeOrder.getUid());
|
|
|
|
|
+ });
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("异步处理订单后续操作异常,", e);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public List<StorePinkOngoingVO> ongoingList(StorePink storePink) {
|
|
public List<StorePinkOngoingVO> ongoingList(StorePink storePink) {
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
PageHelper.startPage(1, 3);
|
|
PageHelper.startPage(1, 3);
|
|
|
List<StorePinkOngoingVO> list = new ArrayList<>();
|
|
List<StorePinkOngoingVO> list = new ArrayList<>();
|
|
|
Condition storePinkSummarycondition = new Condition(StorePinkSummary.class);
|
|
Condition storePinkSummarycondition = new Condition(StorePinkSummary.class);
|
|
@@ -397,14 +448,14 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
|
|
|
storePinkSummarycriteria.andEqualTo("isVirtual", 0);
|
|
storePinkSummarycriteria.andEqualTo("isVirtual", 0);
|
|
|
storePinkSummarycondition.setOrderByClause("people_count DESC");
|
|
storePinkSummarycondition.setOrderByClause("people_count DESC");
|
|
|
List<StorePinkSummary> byCondition = storePinkSummaryService.findByCondition(storePinkSummarycondition);
|
|
List<StorePinkSummary> byCondition = storePinkSummaryService.findByCondition(storePinkSummarycondition);
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if (!CollectionUtils.isEmpty(byCondition)) {
|
|
if (!CollectionUtils.isEmpty(byCondition)) {
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
Map<Long, StorePinkSummary> storePinkSummaryMap = byCondition.stream().collect(Collectors.toMap(StorePinkSummary::getId, a -> a, (b, c) -> c));
|
|
Map<Long, StorePinkSummary> storePinkSummaryMap = byCondition.stream().collect(Collectors.toMap(StorePinkSummary::getId, a -> a, (b, c) -> c));
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
List<Long> spsIdList = byCondition.stream().map(StorePinkSummary::getId).collect(Collectors.toList());
|
|
List<Long> spsIdList = byCondition.stream().map(StorePinkSummary::getId).collect(Collectors.toList());
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
List<String> orderNoSetList = byCondition.stream().map(StorePinkSummary::getOrderNoSet).filter(a -> !ObjectUtils.isEmpty(a)).collect(Collectors.toList());
|
|
List<String> orderNoSetList = byCondition.stream().map(StorePinkSummary::getOrderNoSet).filter(a -> !ObjectUtils.isEmpty(a)).collect(Collectors.toList());
|
|
|
Set<String> orderNoSetForSearch = new HashSet<>();
|
|
Set<String> orderNoSetForSearch = new HashSet<>();
|
|
|
log.info("ongoingList.orderNoSetList:" + orderNoSetList);
|
|
log.info("ongoingList.orderNoSetList:" + orderNoSetList);
|
|
@@ -421,18 +472,18 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
|
|
|
// criteria.andEqualTo("cid", storePink.getCid());
|
|
// criteria.andEqualTo("cid", storePink.getCid());
|
|
|
criteria.andEqualTo("orderStatus", PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey());
|
|
criteria.andEqualTo("orderStatus", PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey());
|
|
|
// criteria.andEqualTo("kid", 0);
|
|
// criteria.andEqualTo("kid", 0);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!org.springframework.util.CollectionUtils.isEmpty(orderNoSetForSearch)) {
|
|
if (!org.springframework.util.CollectionUtils.isEmpty(orderNoSetForSearch)) {
|
|
|
criteria.andIn("orderId", orderNoSetForSearch);
|
|
criteria.andIn("orderId", orderNoSetForSearch);
|
|
|
} else {
|
|
} else {
|
|
|
criteria.andIn("spsId", spsIdList);
|
|
criteria.andIn("spsId", spsIdList);
|
|
|
}
|
|
}
|
|
|
List<StorePink> pinkList = findByCondition(condition);
|
|
List<StorePink> pinkList = findByCondition(condition);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
Map<Long, List<StorePink>> collect = pinkList.stream().collect(Collectors.groupingBy(StorePink::getSpsId));
|
|
Map<Long, List<StorePink>> collect = pinkList.stream().collect(Collectors.groupingBy(StorePink::getSpsId));
|
|
|
list = pinkList.stream().filter(a -> a.getKId().equals(0)).map(a -> {
|
|
list = pinkList.stream().filter(a -> a.getKId().equals(0)).map(a -> {
|
|
|
List<StorePink> storePinks = collect.get(a.getSpsId());
|
|
List<StorePink> storePinks = collect.get(a.getSpsId());
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
StorePinkOngoingVO pinkOngoingVO = new StorePinkOngoingVO();
|
|
StorePinkOngoingVO pinkOngoingVO = new StorePinkOngoingVO();
|
|
|
pinkOngoingVO.setId(a.getId());
|
|
pinkOngoingVO.setId(a.getId());
|
|
|
pinkOngoingVO.setOrderId(a.getOrderId());
|
|
pinkOngoingVO.setOrderId(a.getOrderId());
|
|
@@ -443,17 +494,17 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
|
|
|
pinkOngoingVO.setSuccessAvatar(storePinks.stream().map(StorePink::getAvatar).collect(Collectors.toList()));
|
|
pinkOngoingVO.setSuccessAvatar(storePinks.stream().map(StorePink::getAvatar).collect(Collectors.toList()));
|
|
|
return pinkOngoingVO;
|
|
return pinkOngoingVO;
|
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
list = list.stream().sorted(Comparator.comparing(StorePinkOngoingVO::getRemainNum).reversed()).collect(Collectors.toList());
|
|
list = list.stream().sorted(Comparator.comparing(StorePinkOngoingVO::getRemainNum).reversed()).collect(Collectors.toList());
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return list;
|
|
return list;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Resource
|
|
@Resource
|
|
|
private DailySalesSummaryOfProductsMapper dailySalesSummaryOfProductsMapper;
|
|
private DailySalesSummaryOfProductsMapper dailySalesSummaryOfProductsMapper;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public List<ProductCarouselVO> carousel(Long productId) {
|
|
public List<ProductCarouselVO> carousel(Long productId) {
|
|
|
List<ProductCarouselDTO> pinks = dailySalesSummaryOfProductsMapper.pinkByProductId(productId);
|
|
List<ProductCarouselDTO> pinks = dailySalesSummaryOfProductsMapper.pinkByProductId(productId);
|
|
@@ -471,7 +522,7 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
|
|
|
return new ArrayList<>();
|
|
return new ArrayList<>();
|
|
|
}
|
|
}
|
|
|
Map<Long, UserDTO> userMap = users.stream().collect(Collectors.toMap(UserDTO::getId, user -> user));
|
|
Map<Long, UserDTO> userMap = users.stream().collect(Collectors.toMap(UserDTO::getId, user -> user));
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
List<ProductCarouselVO> carousel = new ArrayList<>();
|
|
List<ProductCarouselVO> carousel = new ArrayList<>();
|
|
|
pinks.forEach(item -> {
|
|
pinks.forEach(item -> {
|
|
|
UserDTO user = userMap.get(item.getUid());
|
|
UserDTO user = userMap.get(item.getUid());
|
|
@@ -498,5 +549,5 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
|
|
|
});
|
|
});
|
|
|
return carousel;
|
|
return carousel;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|