|
@@ -23,6 +23,7 @@ import com.txz.mall.core.AbstractService;
|
|
|
import com.txz.mall.core.RedisUtil;
|
|
|
import com.txz.mall.core.ResultCode;
|
|
|
import com.txz.mall.core.ServiceException;
|
|
|
+import com.txz.mall.dao.StoreOrderMapper;
|
|
|
import com.txz.mall.dao.StorePinkMapper;
|
|
|
import com.txz.mall.dubbo.client.CifAccountDubboServiceClient;
|
|
|
import com.txz.mall.dubbo.client.CifUserDubboServiceClient;
|
|
@@ -35,6 +36,7 @@ import com.txz.mall.util.EasyToUseUtil;
|
|
|
import com.txz.mall.util.OrderStateMachine;
|
|
|
import com.txz.mall.util.OrderUtils;
|
|
|
import dto.*;
|
|
|
+import io.swagger.annotations.ApiModelProperty;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
@@ -43,6 +45,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.ibatis.session.RowBounds;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -113,6 +116,64 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
}
|
|
|
|
|
|
|
|
|
+// @Override
|
|
|
+// public void goOpen(String orderId) {
|
|
|
+// StoreOrder storeOrder = findBy("orderId", orderId);
|
|
|
+// if (storeOrder == null) {
|
|
|
+// throw new ServiceException("订单不存在");
|
|
|
+// }
|
|
|
+// StorePink storePink = new StorePink();
|
|
|
+//// storePink.setUid(user.getUid());
|
|
|
+//// storePink.setAvatar(user.getAvatar());
|
|
|
+//// storePink.setNickname(user.getNickname());
|
|
|
+// storePink.setOrderId(storeOrder.getOrderId());
|
|
|
+// storePink.setOrderIdKey(storeOrder.getId());
|
|
|
+// storePink.setTotalNum(storeOrder.getTotalNum());
|
|
|
+// storePink.setTotalPrice(storeOrder.getTotalPrice());
|
|
|
+// StoreCombination storeCombination = storeCombinationService.findById(storeOrder.getCombinationId());
|
|
|
+// storePink.setCid(storeCombination.getId());
|
|
|
+// storePink.setPid(storeCombination.getProductId());
|
|
|
+// storePink.setPeople(storeCombination.getPeople());
|
|
|
+// storePink.setPrice(storeCombination.getPrice());
|
|
|
+// Date date = new Date();
|
|
|
+// Integer effectiveTime = storeCombination.getEffectiveTime();
|
|
|
+// storePink.setAddTime(date);
|
|
|
+// storePink.setStopTime(DateUtils.addMinutes(date, effectiveTime));
|
|
|
+// storePink.setKId(0L);
|
|
|
+// storePink.setUid(storeOrder.getUid());
|
|
|
+// storePink.setIsRefund(0);
|
|
|
+// storePink.setStatus(1);
|
|
|
+// storePink.setOrderStatus(storeOrder.getStatus());
|
|
|
+//
|
|
|
+// //插入拼团汇总表
|
|
|
+// StorePinkSummary storePinkSummary = new StorePinkSummary();
|
|
|
+// storePinkSummary.setTotalPrice(storeOrder.getTotalPrice());
|
|
|
+// storePinkSummary.setCid(storeCombination.getId());
|
|
|
+// storePinkSummary.setPid(storeCombination.getProductId());
|
|
|
+// storePinkSummary.setPeople(storeCombination.getPeople());
|
|
|
+// storePinkSummary.setAddTime(date);
|
|
|
+// storePinkSummary.setStopTime(DateUtils.addMinutes(date, effectiveTime));
|
|
|
+// storePinkSummary.setIsRefund(0);
|
|
|
+// storePinkSummary.setPeopleCount(1);
|
|
|
+// storePinkSummary.setStatus(1);
|
|
|
+// // storePinkSummary.setlId();'//天选 默认0 1为天选',
|
|
|
+// // storePinkSummary.setkId(); // '团长id',
|
|
|
+// // storePinkSummary.setIsRefund(); //是否退款 0未退款 1已退款',
|
|
|
+// storePinkSummary.setIsRefund(0);
|
|
|
+//
|
|
|
+//
|
|
|
+// EasyToUseUtil.appCreateAssignment(date,storePinkSummary);
|
|
|
+// storePinkSummaryService.save(storePinkSummary);
|
|
|
+//
|
|
|
+// //插入拼团详情表
|
|
|
+// storePink.setSpsId(storePinkSummary.getId());
|
|
|
+// storePinkService.save(storePink);
|
|
|
+//
|
|
|
+// // 如果是开团,需要更新订单数据
|
|
|
+// storeOrder.setPinkId(storePink.getId());
|
|
|
+// update(storeOrder);
|
|
|
+// }
|
|
|
+
|
|
|
@Override
|
|
|
public void goOpen(String orderId) {
|
|
|
StoreOrder storeOrder = findBy("orderId", orderId);
|
|
@@ -136,12 +197,13 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
Integer effectiveTime = storeCombination.getEffectiveTime();
|
|
|
storePink.setAddTime(date);
|
|
|
storePink.setStopTime(DateUtils.addMinutes(date, effectiveTime));
|
|
|
- storePink.setKId(0L);
|
|
|
+ storePink.setKId(0);
|
|
|
storePink.setUid(storeOrder.getUid());
|
|
|
storePink.setIsRefund(0);
|
|
|
storePink.setStatus(1);
|
|
|
+ storePink.setOrderStatus(storeOrder.getStatus());
|
|
|
|
|
|
- //插入拼团汇总表
|
|
|
+ //插入拼团汇总表
|
|
|
StorePinkSummary storePinkSummary = new StorePinkSummary();
|
|
|
storePinkSummary.setTotalPrice(storeOrder.getTotalPrice());
|
|
|
storePinkSummary.setCid(storeCombination.getId());
|
|
@@ -152,13 +214,13 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
storePinkSummary.setIsRefund(0);
|
|
|
storePinkSummary.setPeopleCount(1);
|
|
|
storePinkSummary.setStatus(1);
|
|
|
- // storePinkSummary.setlId();'//天选 默认0 1为天选',
|
|
|
- // storePinkSummary.setkId(); // '团长id',
|
|
|
- // storePinkSummary.setIsRefund(); //是否退款 0未退款 1已退款',
|
|
|
+ // storePinkSummary.setlId();'//天选 默认0 1为天选',
|
|
|
+ // storePinkSummary.setkId(); // '团长id',
|
|
|
+ // storePinkSummary.setIsRefund(); //是否退款 0未退款 1已退款',
|
|
|
storePinkSummary.setIsRefund(0);
|
|
|
- storePinkSummary.setStatus(1);
|
|
|
|
|
|
- EasyToUseUtil.appCreateAssignment(date,storePinkSummary);
|
|
|
+
|
|
|
+ EasyToUseUtil.appCreateAssignment(date,storePinkSummary);
|
|
|
storePinkSummaryService.save(storePinkSummary);
|
|
|
|
|
|
//插入拼团详情表
|
|
@@ -170,6 +232,50 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
update(storeOrder);
|
|
|
}
|
|
|
|
|
|
+// @Override
|
|
|
+// public void goPink(GoPinkDTO dto) {
|
|
|
+// Date date = new Date();
|
|
|
+// if (dto.getPinkId() == null && dto.getCid() != null) {
|
|
|
+// automaticMatch(dto);
|
|
|
+// }
|
|
|
+// if (dto.getPinkId() != null) {
|
|
|
+// StorePink teamPink = storePinkService.findById(dto.getPinkId());
|
|
|
+// if (ObjectUtil.isNull(teamPink) || teamPink.getIsRefund().equals(1)) {
|
|
|
+// throw new ServiceException("对应的拼团不存在");
|
|
|
+// }
|
|
|
+// Condition condition = new Condition(StoreCombination.class);
|
|
|
+// Example.Criteria criteria = condition.createCriteria();
|
|
|
+// criteria.andEqualTo("isDelete", 0);
|
|
|
+// criteria.andEqualTo("isShow", 1);
|
|
|
+// criteria.andEqualTo("id", dto.getCid());
|
|
|
+// criteria.andLessThanOrEqualTo("startTime", date);
|
|
|
+// criteria.andGreaterThanOrEqualTo("stopTime", date);
|
|
|
+//
|
|
|
+// List<StoreCombination> combinationList = storeCombinationService.findByCondition(condition);
|
|
|
+// if (CollUtil.isEmpty(combinationList)) {
|
|
|
+// throw new ServiceException("拼团商品不存在或未开启");
|
|
|
+// }
|
|
|
+//
|
|
|
+// Condition pinkCondition = new Condition(StorePink.class);
|
|
|
+// Example.Criteria pinkCriteria = pinkCondition.createCriteria();
|
|
|
+// pinkCriteria.andEqualTo("isDelete", 0);
|
|
|
+// pinkCriteria.andEqualTo("spsId", dto.getSpsId());
|
|
|
+// pinkCriteria.andEqualTo("status", 1);
|
|
|
+// List<StorePink> pinkList = storePinkService.findByCondition(pinkCondition);
|
|
|
+// int count = teamPink.getPeople() - (CollUtil.isEmpty(pinkList) ? 0 : pinkList.size());
|
|
|
+// if (count < 1) {
|
|
|
+// throw new ServiceException("拼团已满");
|
|
|
+// }
|
|
|
+// List<Long> uidList = pinkList.stream().map(StorePink::getUid).collect(Collectors.toList());
|
|
|
+// if (uidList.contains(dto.getUserId())) {
|
|
|
+// throw new ServiceException("您已加入该拼团");
|
|
|
+// }
|
|
|
+// joinGroup(teamPink, dto, count,pinkList.size());
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public void goPink(GoPinkDTO dto) {
|
|
@@ -205,10 +311,12 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
if (count < 1) {
|
|
|
throw new ServiceException("拼团已满");
|
|
|
}
|
|
|
- List<Long> uidList = pinkList.stream().map(StorePink::getUid).collect(Collectors.toList());
|
|
|
- if (uidList.contains(dto.getUserId())) {
|
|
|
- throw new ServiceException("您已加入该拼团");
|
|
|
- }
|
|
|
+
|
|
|
+ //记得将重复拼团校验放开
|
|
|
+// List<Long> uidList = pinkList.stream().map(StorePink::getUid).collect(Collectors.toList());
|
|
|
+// if (uidList.contains(dto.getUserId())) {
|
|
|
+// throw new ServiceException("重复拼团");
|
|
|
+// }
|
|
|
joinGroup(teamPink, dto, count,pinkList.size());
|
|
|
}
|
|
|
}
|
|
@@ -217,38 +325,51 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
//拼团剩余人数
|
|
|
Date date = new Date();
|
|
|
|
|
|
- //修改拼团汇总表 这块得上分布式锁
|
|
|
- StorePinkSummary storePinkSummary = new StorePinkSummary();
|
|
|
-
|
|
|
- storePinkSummary.setPeopleCount(pinkSize+1);
|
|
|
- EasyToUseUtil.appCreateAssignment(date,storePinkSummary);
|
|
|
- if (count == 1) {
|
|
|
- storePinkSummary.setStatus(1);
|
|
|
- }
|
|
|
- storePinkSummaryService.update(storePinkSummary);
|
|
|
-
|
|
|
+ //修改拼团汇总表 这块得上分布式锁 这块不需要了,会去 maintainQuantityStatusOfTheStorePinkSummary幂等时时维护 汇总表的拼团状态和拼团数量的
|
|
|
+// StorePinkSummary storePinkSummary = new StorePinkSummary();
|
|
|
+// storePinkSummary.setId(dto.getSpsId());
|
|
|
+// storePinkSummary.setPeopleCount(pinkSize+1);
|
|
|
+// EasyToUseUtil.appCreateAssignment(date,storePinkSummary);
|
|
|
+// if (count == 1) {
|
|
|
+// storePinkSummary.setStatus(1);
|
|
|
+// }
|
|
|
+// storePinkSummaryService.update(storePinkSummary);
|
|
|
|
|
|
// 加入拼团
|
|
|
StorePink storePink = new StorePink();
|
|
|
BeanUtils.copyProperties(teamPink, storePink);
|
|
|
storePink.setId(null);
|
|
|
- storePink.setSpsId(storePinkSummary.getId());
|
|
|
-// storePink.setOrderId(null);
|
|
|
-// storePink.setOrderIdKey(null);
|
|
|
+ storePink.setSpsId(dto.getSpsId());
|
|
|
+ storePink.setOrderId(dto.getOrderId());
|
|
|
+ storePink.setOrderIdKey(dto.getOrderIdKey());
|
|
|
storePink.setUid(dto.getUserId());
|
|
|
+ storePink.setStatus(1);
|
|
|
+ storePink.setOrderStatus(PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey());
|
|
|
storePink.setIsRefund(0);
|
|
|
- storePink.setKId(1L);
|
|
|
+ storePink.setKId(1);
|
|
|
// storePink.setAvatar();
|
|
|
// storePink.setNickname();
|
|
|
storePink.setCreateTime(date);
|
|
|
storePinkService.save(storePink);
|
|
|
- if (count == 1) {
|
|
|
- storePinkService.pinkSuccess(teamPink.getId());
|
|
|
|
|
|
+ Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(teamPink.getSpsId());
|
|
|
+
|
|
|
+ StoreOrder storeOrder = new StoreOrder();
|
|
|
+ storeOrder.setId(dto.getOrderIdKey());
|
|
|
|
|
|
- // 考虑是否回写主订单
|
|
|
+ // 需要更新订单数据
|
|
|
+ storeOrder.setPinkId(storePink.getId());
|
|
|
+ update(storeOrder);
|
|
|
+// if(!b){
|
|
|
+// throw new ServiceException("拼团超员请选择新的拼团");
|
|
|
+// }
|
|
|
|
|
|
- }
|
|
|
+// if (count == 1) {
|
|
|
+// storePinkService.pinkSuccess(teamPink.getId());
|
|
|
+//
|
|
|
+// // 考虑是否回写主订单
|
|
|
+//
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -268,47 +389,69 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
pinkSummaryCriteria.andEqualTo("isDelete", 0);
|
|
|
pinkSummaryCriteria.andEqualTo("cid", dto.getCid());
|
|
|
pinkSummaryCriteria.andEqualTo("status", 1);
|
|
|
+ pinkSummaryCriteria.andEqualTo("isVirtual", 0);
|
|
|
pinkSummaryCondition.setOrderByClause("people_count DESC");
|
|
|
+
|
|
|
List<StorePinkSummary> pinkSummaryList = storePinkSummaryService.findByCondition(pinkSummaryCondition);
|
|
|
- List<StorePinkSummary> pinkSummaryListResult = ((Page<StorePinkSummary>) pinkSummaryList).getRecords();
|
|
|
|
|
|
- if (CollUtil.isEmpty(pinkSummaryListResult)) {
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(pinkSummaryList)) {
|
|
|
throw new ServiceException("暂时没有可加入的团");
|
|
|
}
|
|
|
|
|
|
- List<Long> storePinkSummaryId = pinkSummaryListResult.stream().map(StorePinkSummary::getId).collect(Collectors.toList());
|
|
|
+ List<Long> storePinkSummaryId = pinkSummaryList.stream().map(StorePinkSummary::getId).collect(Collectors.toList());
|
|
|
+ log.info("storePinkSummaryId:"+storePinkSummaryId.toString());
|
|
|
Condition pinkCondition = new Condition(StorePink.class);
|
|
|
Example.Criteria pinkCriteria = pinkCondition.createCriteria();
|
|
|
pinkCriteria.andEqualTo("isDelete", 0);
|
|
|
pinkCriteria.andEqualTo("cid", dto.getCid());
|
|
|
// pinkCriteria.andEqualTo("status", 1);
|
|
|
- pinkCriteria.andIn("sps_id",storePinkSummaryId);
|
|
|
+ pinkCriteria.andIn("spsId",storePinkSummaryId);
|
|
|
List<StorePink> pinkList = storePinkService.findByCondition(pinkCondition);
|
|
|
+ log.info("pinkList:"+pinkList.toString());
|
|
|
+
|
|
|
+ Map<Long, List<StorePink>> collect = pinkList.stream().collect(Collectors.groupingBy(StorePink::getSpsId));
|
|
|
+ log.info("collect:"+collect.toString());
|
|
|
+//记得将重复拼团校验放开
|
|
|
+// List<List<StorePink>> availableGroups = collect.values().stream()
|
|
|
+// .filter(list -> !list.stream().map(StorePink::getUid).collect(Collectors.toList()).contains(dto.getUserId()))
|
|
|
+// .collect(Collectors.toList());
|
|
|
+ List<List<StorePink>> availableGroups = collect.values().stream()
|
|
|
|
|
|
|
|
|
- Map<String, List<StorePink>> collect = pinkList.stream().collect(Collectors.groupingBy(StorePink::getOrderId));
|
|
|
-
|
|
|
- List<List<StorePink>> availableGroups = collect.values().stream()
|
|
|
- .filter(list -> !list.stream().map(StorePink::getUid).collect(Collectors.toList()).contains(dto.getUserId()))
|
|
|
+ .filter(list -> true)
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
+ log.info("availableGroups:"+availableGroups.toString());
|
|
|
// 如果没有用户未参与的拼团,直接返回,让调用方处理创建新团的逻辑
|
|
|
if (CollUtil.isEmpty(availableGroups)) {
|
|
|
- throw new ServiceException("所有团的均已参加");
|
|
|
+ throw new ServiceException("所有的团均已参加");
|
|
|
}
|
|
|
// 找出最多value对应的key
|
|
|
- List<StorePink> maxPinkList = availableGroups.stream()
|
|
|
- .max(Comparator.comparing(List::size))
|
|
|
- .orElse(Collections.emptyList());
|
|
|
+// List<StorePink> maxPinkList = availableGroups.stream()
|
|
|
+// .max(Comparator.comparing(List::size))
|
|
|
+// .orElse(Collections.emptyList());
|
|
|
+ //随机挑选一个拼团去参加
|
|
|
+ Random random = new Random();
|
|
|
+ int num = random.nextInt(availableGroups.size()) ; // 生成 可用列表随机下标的整数有效增加并发量
|
|
|
+ log.info("randomNum:"+num);
|
|
|
+ List<StorePink> maxPinkList = availableGroups.get(num);
|
|
|
+ log.info("maxPinkList:"+maxPinkList.toString());
|
|
|
if (CollectionUtils.isNotEmpty(maxPinkList)) {
|
|
|
List<Long> uidList = maxPinkList.stream().map(StorePink::getUid).collect(Collectors.toList());
|
|
|
- if (!uidList.contains(dto.getUserId())) {
|
|
|
- StorePink pink = maxPinkList.stream().filter(i -> i.getKId().equals(0L)).collect(Collectors.toList()).get(0);
|
|
|
- int count = pink.getPeople() - (CollUtil.isEmpty(pinkList) ? 0 : pinkList.size());
|
|
|
+ //记得将重复拼团校验放开
|
|
|
+ // if (!uidList.contains(dto.getUserId())) {
|
|
|
+ //团长
|
|
|
+ StorePink pink = maxPinkList.stream().filter(i -> i.getKId().equals(0)).collect(Collectors.toList()).get(0);
|
|
|
+ int count = pink.getPeople() - (CollUtil.isEmpty(maxPinkList) ? 0 : maxPinkList.size());
|
|
|
+ log.info("count:"+count);
|
|
|
if (count > 0) {
|
|
|
+ dto.setSpsId(pink.getSpsId()); //拼团汇总表id
|
|
|
joinGroup(pink, dto, count,pinkList.size());
|
|
|
+ }else{
|
|
|
+ throw new ServiceException("拼团人数超员请重新发起拼团 pinkid:"+pink.getId());
|
|
|
}
|
|
|
- }
|
|
|
+ // }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -725,7 +868,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
List<StoreOrder> userCombinationOrders = this.getUserCurrentCombinationOrders(userId, storeCombination.getId());
|
|
|
if (CollUtil.isNotEmpty(userCombinationOrders)) {
|
|
|
// 判断是否有待支付订单
|
|
|
- List<StoreOrder> unPayOrders = userCombinationOrders.stream().filter(e -> e.getPaid().equals(0)).collect(Collectors.toList());
|
|
|
+ List<StoreOrder> unPayOrders = userCombinationOrders.stream().filter(e -> e.getStatus().equals(PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey())).collect(Collectors.toList());
|
|
|
if (!unPayOrders.isEmpty()) {
|
|
|
throw new ServiceException("您有拼团待支付订单,请支付后再购买");
|
|
|
}
|
|
@@ -1049,7 +1192,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
case 2:
|
|
|
pinkCriteria.andEqualTo("status", 2);
|
|
|
pinkCriteria.andEqualTo("lId", 1);
|
|
|
- pinkCriteria.andIn("order_status", Arrays.asList(3));
|
|
|
+ pinkCriteria.andIn("orderStatus", Arrays.asList(3));
|
|
|
pinkList = storePinkService.findByCondition(pinkCondition);
|
|
|
if (CollUtil.isNotEmpty(pinkList)) {
|
|
|
criteria.andIn("id", pinkList.stream().map(StorePink::getOrderIdKey).collect(Collectors.toList()));
|
|
@@ -1058,7 +1201,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
case 3:
|
|
|
pinkCriteria.andEqualTo("status", 2);
|
|
|
pinkCriteria.andEqualTo("lId", 0);
|
|
|
- pinkCriteria.andIn("order_status", Arrays.asList(3));
|
|
|
+ pinkCriteria.andIn("orderStatus", Arrays.asList(3));
|
|
|
pinkList = storePinkService.findByCondition(pinkCondition);
|
|
|
if (CollUtil.isNotEmpty(pinkList)) {
|
|
|
criteria.andIn("id", pinkList.stream().map(StorePink::getOrderIdKey).collect(Collectors.toList()));
|
|
@@ -1066,7 +1209,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
break;
|
|
|
case 4:
|
|
|
pinkCriteria.andEqualTo("status", 2);
|
|
|
- pinkCriteria.andIn("order_status", Arrays.asList(5,7,8));
|
|
|
+ pinkCriteria.andIn("orderStatus", Arrays.asList(5,7,8));
|
|
|
pinkList = storePinkService.findByCondition(pinkCondition);
|
|
|
if (CollUtil.isNotEmpty(pinkList)) {
|
|
|
criteria.andIn("id", pinkList.stream().map(StorePink::getOrderIdKey).collect(Collectors.toList()));
|
|
@@ -1370,6 +1513,24 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
// }
|
|
|
// // 保存购物车商品详情
|
|
|
storeOrderInfoService.saveOrderInfos(storeOrderInfos);
|
|
|
+
|
|
|
+
|
|
|
+ if ("open".equals(request.getType())) {
|
|
|
+ goOpen(storeOrder.getOrderId());
|
|
|
+ }
|
|
|
+ if ("join".equals(request.getType())) {
|
|
|
+ GoPinkDTO goPinkDTO = new GoPinkDTO();
|
|
|
+ goPinkDTO.setCid(request.getCid()); //拼团商品id m_store_combination.id
|
|
|
+ goPinkDTO.setOrderId(storeOrder.getOrderId());
|
|
|
+ goPinkDTO.setOrderIdKey(storeOrder.getId());
|
|
|
+ goPinkDTO.setSpsId(request.getSpsId()); //拼团汇总表id
|
|
|
+ goPinkDTO.setPinkId(request.getPinkId());
|
|
|
+ goPinkDTO.setUserId(user.getId());
|
|
|
+ goPink(goPinkDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// // 生成订单日志
|
|
|
storeOrderStatusService.createLog(storeOrder.getId(), Constants.ORDER_STATUS_CREATE_ORDER, "订单生成");
|
|
|
//
|
|
@@ -1379,6 +1540,9 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
// }
|
|
|
// return Boolean.TRUE;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// 删除缓存订单
|
|
|
if (redisUtil.hasKey(key)) {
|
|
|
redisUtil.del(key);
|
|
@@ -1393,10 +1557,12 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED)
|
|
|
public Boolean goPay(GoPinkDTO dto) {
|
|
|
StoreOrder storeOrder = findBy("orderId", dto.getOrderId());
|
|
|
-
|
|
|
+ if(ObjectUtils.isEmpty(storeOrder)){
|
|
|
+ throw new ServiceException("订单为空orderId:"+dto.getOrderId());
|
|
|
+ }
|
|
|
// 检验余额够不够
|
|
|
Result result = accountDubboServiceClient.getWalletAccount(storeOrder.getUid());
|
|
|
if (result.getCode().equals(ResultCode.SUCCESS.getCode())) {
|
|
@@ -1407,7 +1573,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
} else {
|
|
|
throw new ServiceException("获取用户钱包账户失败");
|
|
|
}
|
|
|
- updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey());
|
|
|
+
|
|
|
|
|
|
if ("open".equals(dto.getType())) {
|
|
|
OpenParam openParam = new OpenParam();
|
|
@@ -1416,8 +1582,12 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
openParam.setUserId(storeOrder.getUid());
|
|
|
openParam.setAmount(storeOrder.getPayPrice());
|
|
|
openParam.setTransTime(new Date());
|
|
|
- accountDubboServiceClient.openGroup(openParam);
|
|
|
- goOpen(dto.getOrderId());
|
|
|
+
|
|
|
+ //
|
|
|
+ // accountDubboServiceClient.openGroup(openParam);
|
|
|
+ updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey());
|
|
|
+ storePinkService.pinkSuccess(storeOrder.getPinkId(),storeOrder);
|
|
|
+ // goOpen(dto.getOrderId());
|
|
|
}
|
|
|
if ("join".equals(dto.getType())) {
|
|
|
JoinParam joinParam = new JoinParam();
|
|
@@ -1426,8 +1596,10 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
joinParam.setUserId(storeOrder.getUid());
|
|
|
joinParam.setAmount(storeOrder.getPayPrice());
|
|
|
joinParam.setTransTime(new Date());
|
|
|
- accountDubboServiceClient.joinGroup(joinParam);
|
|
|
- goPink(dto);
|
|
|
+ // accountDubboServiceClient.joinGroup(joinParam);
|
|
|
+ updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey());
|
|
|
+ storePinkService.pinkSuccess(storeOrder.getPinkId(),storeOrder);
|
|
|
+ // goPink(dto);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -1537,11 +1709,11 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
storeOrder.setStatus(status);
|
|
|
update(storeOrder);
|
|
|
|
|
|
- StorePink storePink = new StorePink();
|
|
|
- Example example = new Example(StorePink.class);
|
|
|
- example.createCriteria().andEqualTo("orderIdKey",id);
|
|
|
- storePink.setOrderStatus(status);
|
|
|
- storePinkMapper.updateByConditionSelective(storePink,example);
|
|
|
+// StorePink storePink = new StorePink();
|
|
|
+// Example example = new Example(StorePink.class);
|
|
|
+// example.createCriteria().andEqualTo("orderIdKey",id);
|
|
|
+// storePink.setOrderStatus(status);
|
|
|
+// int i = storePinkMapper.updateByConditionSelective(storePink, example);
|
|
|
|
|
|
storeOrderStatusService.createLog(id, "", PinkOrderStatusEnum.getEnum(status).getValue());
|
|
|
|
|
@@ -1617,4 +1789,13 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
});
|
|
|
return recordList;
|
|
|
}
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private StoreOrderMapper storeOrderMapper;
|
|
|
+ @Override
|
|
|
+ public void bindingAddress(StoreOrder storeOrder) {
|
|
|
+ Example example = new Example(StoreOrder.class);
|
|
|
+ example.createCriteria().andEqualTo("orderId",storeOrder.getOrderId());
|
|
|
+ storeOrderMapper.updateByConditionSelective(storeOrder,example);
|
|
|
+ }
|
|
|
}
|