|
@@ -16,6 +16,7 @@ import com.github.pagehelper.PageInfo;
|
|
import com.txz.cif.dto.AccountDTO;
|
|
import com.txz.cif.dto.AccountDTO;
|
|
import com.txz.cif.dto.Result;
|
|
import com.txz.cif.dto.Result;
|
|
import com.txz.cif.dto.UserDTO;
|
|
import com.txz.cif.dto.UserDTO;
|
|
|
|
+import com.txz.cif.param.AccomplishParam;
|
|
import com.txz.cif.param.JoinParam;
|
|
import com.txz.cif.param.JoinParam;
|
|
import com.txz.cif.param.OpenParam;
|
|
import com.txz.cif.param.OpenParam;
|
|
import com.txz.mall.constants.Constants;
|
|
import com.txz.mall.constants.Constants;
|
|
@@ -25,10 +26,12 @@ import com.txz.mall.core.ResultCode;
|
|
import com.txz.mall.core.ServiceException;
|
|
import com.txz.mall.core.ServiceException;
|
|
import com.txz.mall.dao.StoreOrderMapper;
|
|
import com.txz.mall.dao.StoreOrderMapper;
|
|
import com.txz.mall.dao.StorePinkMapper;
|
|
import com.txz.mall.dao.StorePinkMapper;
|
|
|
|
+import com.txz.mall.dao.StorePinkSummaryMapper;
|
|
import com.txz.mall.dubbo.client.CifAccountDubboServiceClient;
|
|
import com.txz.mall.dubbo.client.CifAccountDubboServiceClient;
|
|
import com.txz.mall.dubbo.client.CifUserDubboServiceClient;
|
|
import com.txz.mall.dubbo.client.CifUserDubboServiceClient;
|
|
import com.txz.mall.enums.OrderEventsEnum;
|
|
import com.txz.mall.enums.OrderEventsEnum;
|
|
import com.txz.mall.enums.PinkOrderStatusEnum;
|
|
import com.txz.mall.enums.PinkOrderStatusEnum;
|
|
|
|
+import com.txz.mall.enums.StorePinkStatusEnum;
|
|
import com.txz.mall.model.*;
|
|
import com.txz.mall.model.*;
|
|
import com.txz.mall.service.*;
|
|
import com.txz.mall.service.*;
|
|
import com.txz.mall.util.EasyExcelUtil;
|
|
import com.txz.mall.util.EasyExcelUtil;
|
|
@@ -38,6 +41,7 @@ import com.txz.mall.util.OrderUtils;
|
|
import dto.*;
|
|
import dto.*;
|
|
import io.swagger.annotations.ApiModelProperty;
|
|
import io.swagger.annotations.ApiModelProperty;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
|
+import lombok.Data;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
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;
|
|
@@ -220,7 +224,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
storePinkSummary.setIsRefund(0);
|
|
storePinkSummary.setIsRefund(0);
|
|
|
|
|
|
|
|
|
|
- EasyToUseUtil.appCreateAssignment(date,storePinkSummary);
|
|
|
|
|
|
+ EasyToUseUtil.appCreateAssignment(date, storePinkSummary);
|
|
storePinkSummaryService.save(storePinkSummary);
|
|
storePinkSummaryService.save(storePinkSummary);
|
|
|
|
|
|
//插入拼团详情表
|
|
//插入拼团详情表
|
|
@@ -275,8 +279,6 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public void goPink(GoPinkDTO dto) {
|
|
public void goPink(GoPinkDTO dto) {
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
@@ -317,11 +319,11 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
// if (uidList.contains(dto.getUserId())) {
|
|
// if (uidList.contains(dto.getUserId())) {
|
|
// throw new ServiceException("重复拼团");
|
|
// throw new ServiceException("重复拼团");
|
|
// }
|
|
// }
|
|
- joinGroup(teamPink, dto, count,pinkList.size());
|
|
|
|
|
|
+ joinGroup(teamPink, dto, count, pinkList.size());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void joinGroup(StorePink teamPink, GoPinkDTO dto, int count,int pinkSize) {
|
|
|
|
|
|
+ private void joinGroup(StorePink teamPink, GoPinkDTO dto, int count, int pinkSize) {
|
|
//拼团剩余人数
|
|
//拼团剩余人数
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
|
|
|
|
@@ -340,8 +342,8 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
BeanUtils.copyProperties(teamPink, storePink);
|
|
BeanUtils.copyProperties(teamPink, storePink);
|
|
storePink.setId(null);
|
|
storePink.setId(null);
|
|
storePink.setSpsId(dto.getSpsId());
|
|
storePink.setSpsId(dto.getSpsId());
|
|
- storePink.setOrderId(dto.getOrderId());
|
|
|
|
- storePink.setOrderIdKey(dto.getOrderIdKey());
|
|
|
|
|
|
+ storePink.setOrderId(dto.getOrderId());
|
|
|
|
+ storePink.setOrderIdKey(dto.getOrderIdKey());
|
|
storePink.setUid(dto.getUserId());
|
|
storePink.setUid(dto.getUserId());
|
|
storePink.setStatus(1);
|
|
storePink.setStatus(1);
|
|
storePink.setOrderStatus(PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey());
|
|
storePink.setOrderStatus(PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey());
|
|
@@ -400,18 +402,19 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
}
|
|
}
|
|
|
|
|
|
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());
|
|
pinkCriteria.andEqualTo("cid", dto.getCid());
|
|
-// pinkCriteria.andEqualTo("status", 1);
|
|
|
|
- pinkCriteria.andIn("spsId",storePinkSummaryId);
|
|
|
|
|
|
+ List<Integer> orderStatusList = CollUtil.newArrayList(PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey(), PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey());
|
|
|
|
+ pinkCriteria.andIn("orderStatus", orderStatusList);
|
|
|
|
+ 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());
|
|
|
|
|
|
Map<Long, List<StorePink>> collect = pinkList.stream().collect(Collectors.groupingBy(StorePink::getSpsId));
|
|
Map<Long, List<StorePink>> collect = pinkList.stream().collect(Collectors.groupingBy(StorePink::getSpsId));
|
|
- log.info("collect:"+collect.toString());
|
|
|
|
|
|
+ log.info("collect:" + collect.toString());
|
|
//记得将重复拼团校验放开
|
|
//记得将重复拼团校验放开
|
|
// List<List<StorePink>> availableGroups = collect.values().stream()
|
|
// List<List<StorePink>> availableGroups = collect.values().stream()
|
|
// .filter(list -> !list.stream().map(StorePink::getUid).collect(Collectors.toList()).contains(dto.getUserId()))
|
|
// .filter(list -> !list.stream().map(StorePink::getUid).collect(Collectors.toList()).contains(dto.getUserId()))
|
|
@@ -422,7 +425,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
.filter(list -> true)
|
|
.filter(list -> true)
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
- log.info("availableGroups:"+availableGroups.toString());
|
|
|
|
|
|
+ log.info("availableGroups:" + availableGroups.toString());
|
|
// 如果没有用户未参与的拼团,直接返回,让调用方处理创建新团的逻辑
|
|
// 如果没有用户未参与的拼团,直接返回,让调用方处理创建新团的逻辑
|
|
if (CollUtil.isEmpty(availableGroups)) {
|
|
if (CollUtil.isEmpty(availableGroups)) {
|
|
throw new ServiceException("所有的团均已参加");
|
|
throw new ServiceException("所有的团均已参加");
|
|
@@ -433,25 +436,25 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
// .orElse(Collections.emptyList());
|
|
// .orElse(Collections.emptyList());
|
|
//随机挑选一个拼团去参加
|
|
//随机挑选一个拼团去参加
|
|
Random random = new Random();
|
|
Random random = new Random();
|
|
- int num = random.nextInt(availableGroups.size()) ; // 生成 可用列表随机下标的整数有效增加并发量
|
|
|
|
- log.info("randomNum:"+num);
|
|
|
|
|
|
+ int num = random.nextInt(availableGroups.size()); // 生成 可用列表随机下标的整数有效增加并发量
|
|
|
|
+ log.info("randomNum:" + num);
|
|
List<StorePink> maxPinkList = availableGroups.get(num);
|
|
List<StorePink> maxPinkList = availableGroups.get(num);
|
|
- log.info("maxPinkList:"+maxPinkList.toString());
|
|
|
|
|
|
+ log.info("maxPinkList:" + maxPinkList.toString());
|
|
if (CollectionUtils.isNotEmpty(maxPinkList)) {
|
|
if (CollectionUtils.isNotEmpty(maxPinkList)) {
|
|
List<Long> uidList = maxPinkList.stream().map(StorePink::getUid).collect(Collectors.toList());
|
|
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(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());
|
|
|
|
- }
|
|
|
|
- // }
|
|
|
|
|
|
+ // 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());
|
|
|
|
+ }
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -517,8 +520,58 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 山哥说批量发货要能支持5000条数据这块得设计成异步处理,不然性能扛不住
|
|
|
|
+ */
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void batchDelivery(List<StoreOrderDeliveryDTO> dto) {
|
|
public void batchDelivery(List<StoreOrderDeliveryDTO> dto) {
|
|
|
|
+ if(CollectionUtils.isEmpty(dto)){
|
|
|
|
+ throw new ServiceException("批量发货入参为空dto:"+dto);
|
|
|
|
+ }
|
|
|
|
+ List<String> orderIdList = dto.stream().map(StoreOrderDeliveryDTO::getOrderId).collect(Collectors.toList());
|
|
|
|
+ if(CollectionUtils.isEmpty(orderIdList)){
|
|
|
|
+ throw new ServiceException("批量发货订单orderid为空orderIdList:"+orderIdList);
|
|
|
|
+ }
|
|
|
|
+ if(dto.size()>500){
|
|
|
|
+ throw new ServiceException("1次批量发货订单不要超过500条");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Condition condition = new Condition(StoreOrder.class);
|
|
|
|
+ Example.Criteria criteria = condition.createCriteria();
|
|
|
|
+ criteria.andIn("orderId", orderIdList);
|
|
|
|
+ criteria.andEqualTo("isDelete", 0);
|
|
|
|
+ List<StoreOrder> storeOrderList = findByCondition(condition);
|
|
|
|
+ if(CollectionUtils.isEmpty(storeOrderList)){
|
|
|
|
+ throw new ServiceException("批量发货订单订单列表不存在:"+storeOrderList);
|
|
|
|
+ }
|
|
|
|
+ Map<String, StoreOrderDeliveryDTO> storeOrderDeliveryMap = dto.stream().collect(Collectors.toMap(StoreOrderDeliveryDTO::getOrderId, a -> a, (b, c) -> b));
|
|
|
|
+ for (StoreOrder storeOrder : storeOrderList) {
|
|
|
|
+ StoreOrderDeliveryDTO storeOrderDeliveryDTO = storeOrderDeliveryMap.get(storeOrder.getOrderId());
|
|
|
|
+ PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_DELIVER, null);
|
|
|
|
+ if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
|
|
+ throw new ServiceException("当前状态不支持发货storeOrder:"+storeOrder.toString());
|
|
|
|
+ }
|
|
|
|
+ Date date = DateUtil.date();
|
|
|
|
+ StoreOrder storeOrderForUpdate = new StoreOrder();
|
|
|
|
+ storeOrderForUpdate.setStatus(pinkOrderStatusEnum.getKey());
|
|
|
|
+ storeOrderForUpdate.setDeliveryName(storeOrderDeliveryDTO.getDeliveryName());
|
|
|
|
+ storeOrderForUpdate.setDeliveryCode(storeOrderDeliveryDTO.getDeliveryNo());
|
|
|
|
+ storeOrderForUpdate.setDeliveryTime(date);
|
|
|
|
+
|
|
|
|
+ Example example = new Example(StoreOrder.class);
|
|
|
|
+ example.createCriteria().andEqualTo("orderId",storeOrder.getOrderId());
|
|
|
|
+ storeOrderMapper.updateByConditionSelective(storeOrderForUpdate,example);
|
|
|
|
+ storeOrderStatusService.createLog(storeOrder.getId(), Constants.ORDER_STATUS_DELIVERY_ORDER, "订单发货");
|
|
|
|
+
|
|
|
|
+ //维护拼团订单状态
|
|
|
|
+ StorePink storePinkForUpdate = new StorePink();
|
|
|
|
+ storePinkForUpdate.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
|
|
+ Example exampleStorePink = new Example(StorePink.class);
|
|
|
|
+ exampleStorePink.createCriteria().andEqualTo("orderId",storeOrder.getOrderId());
|
|
|
|
+ storePinkMapper.updateByConditionSelective(storePinkForUpdate,exampleStorePink);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1132,7 +1185,10 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
Condition addressCondition = new Condition(UserAddress.class);
|
|
Condition addressCondition = new Condition(UserAddress.class);
|
|
Example.Criteria addressCriteria = addressCondition.createCriteria();
|
|
Example.Criteria addressCriteria = addressCondition.createCriteria();
|
|
addressCriteria.andEqualTo("isDelete", 0);
|
|
addressCriteria.andEqualTo("isDelete", 0);
|
|
- addressCriteria.andIn("id", list.stream().map(StoreOrder::getAddressId).filter(Objects::nonNull).collect(Collectors.toList()));
|
|
|
|
|
|
+ List<Long> collect = list.stream().map(StoreOrder::getAddressId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
|
+ if(!org.springframework.util.CollectionUtils.isEmpty(collect)){
|
|
|
|
+ addressCriteria.andIn("id", collect);
|
|
|
|
+ }
|
|
addressList = userAddressService.findByCondition(addressCondition);
|
|
addressList = userAddressService.findByCondition(addressCondition);
|
|
}
|
|
}
|
|
List<StoreOrderInfo> finalInfoArrayList = infoArrayList;
|
|
List<StoreOrderInfo> finalInfoArrayList = infoArrayList;
|
|
@@ -1152,10 +1208,10 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @ApiModelProperty(value = "类型 0-全部all 1-待支付topay 2-拼团成功success 3-拼团失败failed 4-拼团奖励reward")
|
|
|
|
- * private Integer type;
|
|
|
|
- * ****************************
|
|
|
|
- *GROUP_ORDER_TO_PAY(1, "拼团待支付"),
|
|
|
|
|
|
+ * @ApiModelProperty(value = "类型 0-全部all 1-待支付topay 2-拼团成功success 3-拼团失败failed 4-拼团奖励reward")
|
|
|
|
+ * private Integer type;
|
|
|
|
+ * ****************************
|
|
|
|
+ * GROUP_ORDER_TO_PAY(1, "拼团待支付"),
|
|
* GROUP_ORDER_CANCELLATION(2, "拼团订单取消"),
|
|
* GROUP_ORDER_CANCELLATION(2, "拼团订单取消"),
|
|
* GROUP_ORDER_PAID(3, "拼团已支付"),
|
|
* GROUP_ORDER_PAID(3, "拼团已支付"),
|
|
* GROUP_ORDER_REFUND(4, "拼团失败已退款"),
|
|
* GROUP_ORDER_REFUND(4, "拼团失败已退款"),
|
|
@@ -1163,8 +1219,8 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
* GROUP_ORDER_TO_CLOSED(6, "拼团未中奖关闭"),
|
|
* GROUP_ORDER_TO_CLOSED(6, "拼团未中奖关闭"),
|
|
* GROUP_ORDER_TO_RECEVIE(7, "拼团待收货"),
|
|
* GROUP_ORDER_TO_RECEVIE(7, "拼团待收货"),
|
|
* GROUP_ORDER_COMPLETED(8, "拼团订单完成")
|
|
* GROUP_ORDER_COMPLETED(8, "拼团订单完成")
|
|
- * *****************************
|
|
|
|
- * `status` tinyint unsigned NOT NULL DEFAULT '1' COMMENT '状态 1进行中 2已完成 3未完成',
|
|
|
|
|
|
+ * *****************************
|
|
|
|
+ * `status` tinyint unsigned NOT NULL DEFAULT '1' COMMENT '状态 1进行中 2已完成 3未完成',
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public List<StoreOrderVO> appList(StoreOrderAppDTO dto) {
|
|
public List<StoreOrderVO> appList(StoreOrderAppDTO dto) {
|
|
@@ -1209,7 +1265,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
break;
|
|
break;
|
|
case 4:
|
|
case 4:
|
|
pinkCriteria.andEqualTo("status", 2);
|
|
pinkCriteria.andEqualTo("status", 2);
|
|
- pinkCriteria.andIn("orderStatus", Arrays.asList(5,7,8));
|
|
|
|
|
|
+ pinkCriteria.andIn("orderStatus", Arrays.asList(5, 7, 8));
|
|
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("id", pinkList.stream().map(StorePink::getOrderIdKey).collect(Collectors.toList()));
|
|
@@ -1462,7 +1518,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
storeOrder.setMark(StringEscapeUtils.escapeHtml4(request.getMark()));
|
|
storeOrder.setMark(StringEscapeUtils.escapeHtml4(request.getMark()));
|
|
storeOrder.setCombinationId(orderInfoVo.getCombinationId());
|
|
storeOrder.setCombinationId(orderInfoVo.getCombinationId());
|
|
storeOrder.setPinkId(orderInfoVo.getPinkId());
|
|
storeOrder.setPinkId(orderInfoVo.getPinkId());
|
|
- // storeOrder.setBargainUserId(orderInfoVo.getBargainUserId());
|
|
|
|
|
|
+ // storeOrder.setBargainUserId(orderInfoVo.getBargainUserId());
|
|
storeOrder.setCreateTime(new Date());
|
|
storeOrder.setCreateTime(new Date());
|
|
storeOrder.setShippingType(request.getShippingType());
|
|
storeOrder.setShippingType(request.getShippingType());
|
|
storeOrder.setIsChannel(isChannel);
|
|
storeOrder.setIsChannel(isChannel);
|
|
@@ -1487,17 +1543,17 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
// 拼团商品扣库存
|
|
// 拼团商品扣库存
|
|
storeCombinationService.operationStock(skuRecord.getLong("activityId"), skuRecord.getInt("num"), "sub");
|
|
storeCombinationService.operationStock(skuRecord.getLong("activityId"), skuRecord.getInt("num"), "sub");
|
|
// 拼团商品规格扣库存
|
|
// 拼团商品规格扣库存
|
|
- //** productAttrValueService.operationStock(skuRecord.getInt("activityAttrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_PINGTUAN);
|
|
|
|
|
|
+ // productAttrValueService.operationStock(skuRecord.getInt("activityAttrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_PINGTUAN);
|
|
// 普通商品口库存
|
|
// 普通商品口库存
|
|
- storeProductService.operationStock(skuRecord.getInt("productId"), skuRecord.getInt("num"), "sub");
|
|
|
|
|
|
+ storeProductService.operationStock(skuRecord.getLong("productId"), skuRecord.getInt("num"), "sub");
|
|
// 普通商品规格扣库存
|
|
// 普通商品规格扣库存
|
|
- //** 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);
|
|
} else { // 普通商品
|
|
} else { // 普通商品
|
|
for (MyRecord skuRecord : skuRecordList) {
|
|
for (MyRecord skuRecord : skuRecordList) {
|
|
// 普通商品口库存
|
|
// 普通商品口库存
|
|
- storeProductService.operationStock(skuRecord.getInt("productId"), skuRecord.getInt("num"), "sub");
|
|
|
|
|
|
+ storeProductService.operationStock(skuRecord.getLong("productId"), skuRecord.getInt("num"), "sub");
|
|
// 普通商品规格扣库存
|
|
// 普通商品规格扣库存
|
|
- //** 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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1530,7 +1586,6 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
// // 生成订单日志
|
|
// // 生成订单日志
|
|
storeOrderStatusService.createLog(storeOrder.getId(), Constants.ORDER_STATUS_CREATE_ORDER, "订单生成");
|
|
storeOrderStatusService.createLog(storeOrder.getId(), Constants.ORDER_STATUS_CREATE_ORDER, "订单生成");
|
|
//
|
|
//
|
|
@@ -1541,8 +1596,6 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
// return Boolean.TRUE;
|
|
// return Boolean.TRUE;
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
// 删除缓存订单
|
|
// 删除缓存订单
|
|
if (redisUtil.hasKey(key)) {
|
|
if (redisUtil.hasKey(key)) {
|
|
redisUtil.del(key);
|
|
redisUtil.del(key);
|
|
@@ -1560,9 +1613,20 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
|
public Boolean goPay(GoPinkDTO dto) {
|
|
public Boolean goPay(GoPinkDTO dto) {
|
|
StoreOrder storeOrder = findBy("orderId", dto.getOrderId());
|
|
StoreOrder storeOrder = findBy("orderId", dto.getOrderId());
|
|
- if(ObjectUtils.isEmpty(storeOrder)){
|
|
|
|
- throw new ServiceException("订单为空orderId:"+dto.getOrderId());
|
|
|
|
|
|
+ if (ObjectUtils.isEmpty(storeOrder)) {
|
|
|
|
+ throw new ServiceException("订单为空orderId:" + dto.getOrderId());
|
|
}
|
|
}
|
|
|
|
+ if (storeOrder.getStatus().equals(PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey())) {
|
|
|
|
+ throw new ServiceException("订单已支付orderId:" + dto.getOrderId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_PAY, null);
|
|
|
|
+
|
|
|
|
+ if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
|
|
+ throw new ServiceException("当前状态不支持去支持去支付orderId:" + dto.getOrderId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
// 检验余额够不够
|
|
// 检验余额够不够
|
|
Result result = accountDubboServiceClient.getWalletAccount(storeOrder.getUid());
|
|
Result result = accountDubboServiceClient.getWalletAccount(storeOrder.getUid());
|
|
if (result.getCode().equals(ResultCode.SUCCESS.getCode())) {
|
|
if (result.getCode().equals(ResultCode.SUCCESS.getCode())) {
|
|
@@ -1584,10 +1648,10 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
openParam.setTransTime(new Date());
|
|
openParam.setTransTime(new Date());
|
|
|
|
|
|
//
|
|
//
|
|
- // accountDubboServiceClient.openGroup(openParam);
|
|
|
|
- updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey());
|
|
|
|
- storePinkService.pinkSuccess(storeOrder.getPinkId(),storeOrder);
|
|
|
|
- // goOpen(dto.getOrderId());
|
|
|
|
|
|
+ // accountDubboServiceClient.openGroup(openParam);
|
|
|
|
+ updateOrderStatus(storeOrder.getId(), pinkOrderStatusEnum.getKey());
|
|
|
|
+ storePinkService.pinkSuccess(storeOrder.getPinkId(), storeOrder);
|
|
|
|
+ // goOpen(dto.getOrderId());
|
|
}
|
|
}
|
|
if ("join".equals(dto.getType())) {
|
|
if ("join".equals(dto.getType())) {
|
|
JoinParam joinParam = new JoinParam();
|
|
JoinParam joinParam = new JoinParam();
|
|
@@ -1596,45 +1660,190 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
joinParam.setUserId(storeOrder.getUid());
|
|
joinParam.setUserId(storeOrder.getUid());
|
|
joinParam.setAmount(storeOrder.getPayPrice());
|
|
joinParam.setAmount(storeOrder.getPayPrice());
|
|
joinParam.setTransTime(new Date());
|
|
joinParam.setTransTime(new Date());
|
|
- // accountDubboServiceClient.joinGroup(joinParam);
|
|
|
|
- updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey());
|
|
|
|
- storePinkService.pinkSuccess(storeOrder.getPinkId(),storeOrder);
|
|
|
|
- // goPink(dto);
|
|
|
|
|
|
+ // accountDubboServiceClient.joinGroup(joinParam);
|
|
|
|
+ updateOrderStatus(storeOrder.getId(), pinkOrderStatusEnum.getKey());
|
|
|
|
+ storePinkService.pinkSuccess(storeOrder.getPinkId(), storeOrder);
|
|
|
|
+ // goPink(dto);
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ //这是由pc端发起端针对个人的主动退款 不是定时任务扫描活动超时导致的退款,所以这个退款是不影响其他拼团成员的。拼团汇总表也不会上锁,拼团状态仍然是进行中
|
|
@Override
|
|
@Override
|
|
public void refund(Long id) {
|
|
public void refund(Long id) {
|
|
StoreOrder storeOrder = findById(id);
|
|
StoreOrder storeOrder = findById(id);
|
|
-// if (storeOrder.getPaid().equals(Constants.ORDER_STATUS_H5_UNPAID)) {
|
|
|
|
|
|
+//// if (storeOrder.getPaid().equals(Constants.ORDER_STATUS_H5_UNPAID)) {
|
|
|
|
+//// throw new ServiceException("当前状态不支持退款");
|
|
|
|
+//// }
|
|
|
|
+//
|
|
|
|
+// PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_APPLY_REFUND, null);
|
|
|
|
+//
|
|
|
|
+// if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
// throw new ServiceException("当前状态不支持退款");
|
|
// throw new ServiceException("当前状态不支持退款");
|
|
// }
|
|
// }
|
|
|
|
+// updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.GROUP_ORDER_REFUND.getKey());
|
|
|
|
+//
|
|
|
|
+// // 归还用户余额
|
|
|
|
+ // accountDubboServiceClient.refund(id.toString(), storeOrder.getOrderId(), storeOrder.getPayPrice());
|
|
|
|
+// // 库存增加
|
|
|
|
+// storeCombinationService.operationStock(storeOrder.getCombinationId(), storeOrder.getTotalNum(), "add");
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+ if (ObjectUtils.isEmpty(storeOrder)) {
|
|
|
|
+ throw new ServiceException("订单主动退款时订单不存在id:" + id);
|
|
|
|
+ }
|
|
|
|
|
|
- PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_APPLY_REFUND, null);
|
|
|
|
-
|
|
|
|
|
|
+ PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_FAIL, null);
|
|
if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
- throw new ServiceException("当前状态不支持退款");
|
|
|
|
|
|
+ throw new ServiceException("当前状态不支持退款关闭id:"+id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ StorePink storePink = storePinkService.findById(storeOrder.getPinkId());
|
|
|
|
+ // 批量退款接口调用 这块要前置,退款成功后再去改状态
|
|
|
|
+ if (ObjectUtils.isEmpty(storePink)) {
|
|
|
|
+ throw new ServiceException("拼团时间过期关闭时时拼团信息不存在ID:" + storeOrder.getPinkId());
|
|
}
|
|
}
|
|
- updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.GROUP_ORDER_REFUND.getKey());
|
|
|
|
|
|
|
|
- // 归还用户余额
|
|
|
|
-// accountDubboServiceClient.refund(id.toString(), storeOrder.getOrderId(), storeOrder.getPayPrice());
|
|
|
|
- // 库存增加
|
|
|
|
- storeCombinationService.operationStock(storeOrder.getCombinationId(), storeOrder.getTotalNum(), "add");
|
|
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ //主动退款
|
|
|
|
+ AccomplishParam param = new AccomplishParam();
|
|
|
|
+ param.setBizNo(storeOrder.getOrderId());
|
|
|
|
+ param.setBizId(storeOrder.getId().toString());
|
|
|
|
+ List<Long> userIds = CollUtil.newArrayList();
|
|
|
|
+ param.setUserIds(userIds);
|
|
|
|
+ param.setAmount(storePink.getTotalPrice());
|
|
|
|
+ param.setTransTime(date);
|
|
|
|
+// Result result = accountDubboServiceClient.accomplishGroup(param);
|
|
|
|
+// boolean equals = result.getCode().equals("200");
|
|
|
|
+// if(!equals){
|
|
|
|
+// throw new ServiceException("退款失败请重新发起");
|
|
|
|
+// }
|
|
|
|
+ updateOrderStatus(storeOrder.getId(), pinkOrderStatusEnum.getKey());
|
|
|
|
+ //订单状态回退
|
|
|
|
+ //拼团状态回退
|
|
|
|
+
|
|
|
|
+ StorePink storePinkForUpdate = new StorePink();
|
|
|
|
+ storePinkForUpdate.setId(storeOrder.getPinkId());
|
|
|
|
+ // storePinkForUpdate.setStatus(StorePinkStatusEnum.LOTTERY_FAILED.getKey()); //定时任务触发的拼团失败导致的订单退款需要设置这个状态为拼团失败状态
|
|
|
|
+ storePinkForUpdate.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
|
|
+ storePinkService.update(storePinkForUpdate);
|
|
|
|
+ //拼团汇总数量维护以及锁单标识维护
|
|
|
|
+ Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(storePink.getSpsId());
|
|
|
|
+ //拼团商品数量以及m_store_combination
|
|
|
|
+ storeCombinationService.operationStock(storePink.getCid(), storePink.getTotalNum(), "add");
|
|
|
|
+ // 拼团商品规格扣库存
|
|
|
|
+ // productAttrValueService.operationStock(skuRecord.getInt("activityAttrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_PINGTUAN);
|
|
|
|
+ // 普通商品口库存
|
|
|
|
+ storeProductService.operationStock(storePink.getPid(), storePink.getTotalNum(), "add");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- // 中奖回收状态逻辑还没加 关闭指系统层面的自动结束 如活动时间超时或者拼团超时由定时任务触发
|
|
|
|
|
|
+ // 关闭指系统层面的自动结束 如活动时间超时或者拼团超时由定时任务触发 不暴露给客户端
|
|
@Override
|
|
@Override
|
|
public void close(Long id) {
|
|
public void close(Long id) {
|
|
- StoreOrder storeOrder = findById(id);
|
|
|
|
- PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_NOT_WIN, null);
|
|
|
|
|
|
|
|
- if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
|
|
- throw new ServiceException("当前状态不支持关闭");
|
|
|
|
|
|
+
|
|
|
|
+ // PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_FAIL, null);
|
|
|
|
+// if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
|
|
+// throw new ServiceException("当前状态不支持关闭");
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ StoreOrder storeOrder = findById(id);
|
|
|
|
+ if (ObjectUtils.isEmpty(storeOrder)) {
|
|
|
|
+ throw new ServiceException("订单不存在id:" + id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey().equals(storeOrder.getStatus())) {
|
|
|
|
+ //如果是待支付状态 状态推到取消状态
|
|
|
|
+ // cancel(id);
|
|
|
|
+ PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_CANCEL, null);
|
|
|
|
+
|
|
|
|
+ if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
|
|
+ throw new ServiceException("当前状态不支持取消");
|
|
|
|
+ }
|
|
|
|
+ //订单状态回退
|
|
|
|
+ updateOrderStatus(storeOrder.getId(), pinkOrderStatusEnum.getKey());
|
|
|
|
+
|
|
|
|
+ //拼团状态回退
|
|
|
|
+ StorePink storePink = storePinkService.findById(storeOrder.getPinkId());
|
|
|
|
+ if (ObjectUtils.isEmpty(storePink)) {
|
|
|
|
+ throw new ServiceException("订单取消时拼团信息不存在ID:" + storeOrder.getPinkId());
|
|
|
|
+ }
|
|
|
|
+ StorePink storePinkForUpdate = new StorePink();
|
|
|
|
+ storePinkForUpdate.setId(storeOrder.getPinkId());
|
|
|
|
+ storePinkForUpdate.setStatus(StorePinkStatusEnum.LOTTERY_FAILED.getKey());
|
|
|
|
+ storePinkForUpdate.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
|
|
+ storePinkService.update(storePinkForUpdate);
|
|
|
|
+ //拼团汇总数量维护以及锁单标识维护
|
|
|
|
+ Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(storePink.getSpsId());
|
|
|
|
+ //拼团商品数量以及m_store_combination
|
|
|
|
+ storeCombinationService.operationStock(storePink.getCid(), storePink.getTotalNum(), "add");
|
|
|
|
+ // 拼团商品规格扣库存
|
|
|
|
+ // productAttrValueService.operationStock(skuRecord.getInt("activityAttrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_PINGTUAN);
|
|
|
|
+ // 普通商品口库存
|
|
|
|
+ storeProductService.operationStock(storePink.getPid(), storePink.getTotalNum(), "add");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ } else if (PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey().equals(storeOrder.getStatus())) {
|
|
|
|
+
|
|
|
|
+ PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_FAIL, null);
|
|
|
|
+ if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
|
|
+ throw new ServiceException("当前状态不支持退款关闭");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //订单状态回退
|
|
|
|
+ //拼团状态回退
|
|
|
|
+ StorePink storePink = storePinkService.findById(storeOrder.getPinkId());
|
|
|
|
+
|
|
|
|
+ if (ObjectUtils.isEmpty(storePink)) {
|
|
|
|
+ throw new ServiceException("主动发起退款时拼团信息不存在ID:" + storeOrder.getPinkId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ //主动退款
|
|
|
|
+ AccomplishParam param = new AccomplishParam();
|
|
|
|
+ param.setBizNo(storeOrder.getOrderId());
|
|
|
|
+ param.setBizId(storeOrder.getId().toString());
|
|
|
|
+ List<Long> userIds = CollUtil.newArrayList();
|
|
|
|
+ param.setUserIds(userIds);
|
|
|
|
+ param.setAmount(storePink.getTotalPrice());
|
|
|
|
+ param.setTransTime(date);
|
|
|
|
+// Result result = accountDubboServiceClient.accomplishGroup(param);
|
|
|
|
+// boolean equals = result.getCode().equals("200");
|
|
|
|
+// if(!equals){
|
|
|
|
+// throw new ServiceException("退款失败请重新发起");
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ updateOrderStatus(storeOrder.getId(), pinkOrderStatusEnum.getKey());
|
|
|
|
+
|
|
|
|
+ StorePink storePinkForUpdate = new StorePink();
|
|
|
|
+ storePinkForUpdate.setId(storeOrder.getPinkId());
|
|
|
|
+ storePinkForUpdate.setStatus(StorePinkStatusEnum.LOTTERY_FAILED.getKey()); //定时任务触发的拼团失败导致的订单退款需要设置这个状态为拼团失败状态
|
|
|
|
+ storePinkForUpdate.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
|
|
+ storePinkService.update(storePinkForUpdate);
|
|
|
|
+ //拼团汇总数量维护以及锁单标识维护
|
|
|
|
+ Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(storePink.getSpsId());
|
|
|
|
+ //拼团商品数量以及m_store_combination
|
|
|
|
+ storeCombinationService.operationStock(storePink.getCid(), storePink.getTotalNum(), "add");
|
|
|
|
+ // 拼团商品规格扣库存
|
|
|
|
+ // productAttrValueService.operationStock(skuRecord.getInt("activityAttrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_PINGTUAN);
|
|
|
|
+ // 普通商品口库存
|
|
|
|
+ storeProductService.operationStock(storePink.getPid(), storePink.getTotalNum(), "add");
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ throw new ServiceException("当前状态不支持退款关闭:id"+id);
|
|
|
|
+ }
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.error("定时任务关单处理失败订单id:"+id,e);
|
|
}
|
|
}
|
|
- updateOrderStatus(storeOrder.getId(), pinkOrderStatusEnum.getKey());
|
|
|
|
|
|
+
|
|
|
|
+ //如果是已支付状态状态推到拼团失败退款状态
|
|
|
|
|
|
|
|
|
|
// if (storeOrder.getStatus().equals(Constants.ORDER_STATUS_H5_COMPLETE)) {
|
|
// if (storeOrder.getStatus().equals(Constants.ORDER_STATUS_H5_COMPLETE)) {
|
|
@@ -1644,15 +1853,87 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private StorePinkSummaryMapper storePinkSummaryMapper;
|
|
|
|
+ @Override
|
|
|
|
+ public void scheduledTaskClose() {
|
|
|
|
+
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ PageHelper.startPage(1, 10);
|
|
|
|
+ Condition pinkSummaryCondition = new Condition(StorePinkSummary.class);
|
|
|
|
+ Example.Criteria pinkSummaryCriteria = pinkSummaryCondition.createCriteria();
|
|
|
|
+ pinkSummaryCriteria.andEqualTo("isDelete", 0);
|
|
|
|
+ pinkSummaryCriteria.andEqualTo("status", StorePinkStatusEnum.NOT_DRAWN.getKey());
|
|
|
|
+ pinkSummaryCriteria.andLessThanOrEqualTo("stopTime",date);
|
|
|
|
+ List<StorePinkSummary> byCondition = storePinkSummaryService.findByCondition(pinkSummaryCondition);
|
|
|
|
+ //先锁定汇总表防止有新的成员加入进来,
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+ 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())
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void cancel(Long id) {
|
|
public void cancel(Long id) {
|
|
StoreOrder storeOrder = findById(id);
|
|
StoreOrder storeOrder = findById(id);
|
|
|
|
+ if (ObjectUtils.isEmpty(storeOrder)) {
|
|
|
|
+ throw new ServiceException("订单取消时订单不存在id:" + id);
|
|
|
|
+ }
|
|
PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_CANCEL, null);
|
|
PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_CANCEL, null);
|
|
|
|
|
|
if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
throw new ServiceException("当前状态不支持取消");
|
|
throw new ServiceException("当前状态不支持取消");
|
|
}
|
|
}
|
|
- updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.GROUP_ORDER_CANCELLATION.getKey());
|
|
|
|
|
|
+
|
|
|
|
+ //订单状态回退
|
|
|
|
+ updateOrderStatus(storeOrder.getId(), pinkOrderStatusEnum.getKey());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //拼团状态回退
|
|
|
|
+ StorePink storePink = storePinkService.findById(storeOrder.getPinkId());
|
|
|
|
+ if (ObjectUtils.isEmpty(storePink)) {
|
|
|
|
+ throw new ServiceException("订单取消时拼团信息不存在ID:" + storeOrder.getPinkId());
|
|
|
|
+ }
|
|
|
|
+ StorePink storePinkForUpdate = new StorePink();
|
|
|
|
+ storePinkForUpdate.setId(storeOrder.getPinkId());
|
|
|
|
+ storePinkForUpdate.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
|
|
+ storePinkService.update(storePinkForUpdate);
|
|
|
|
+
|
|
|
|
+ //拼团汇总数量维护以及锁单标识维护
|
|
|
|
+
|
|
|
|
+ Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(storePink.getSpsId());
|
|
|
|
+
|
|
|
|
+ //拼团商品数量以及m_store_combination
|
|
|
|
+
|
|
|
|
+ storeCombinationService.operationStock(storePink.getCid(), storePink.getTotalNum(), "add");
|
|
|
|
+ // 拼团商品规格扣库存
|
|
|
|
+ // productAttrValueService.operationStock(skuRecord.getInt("activityAttrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_PINGTUAN);
|
|
|
|
+ // 普通商品口库存
|
|
|
|
+ storeProductService.operationStock(storePink.getPid(), storePink.getTotalNum(), "add");
|
|
|
|
+
|
|
|
|
+ //库存数量回退
|
|
|
|
|
|
// if (storeOrder.getPaid().equals(0)) {
|
|
// if (storeOrder.getPaid().equals(0)) {
|
|
// updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.CANCEL.getKey());
|
|
// updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.CANCEL.getKey());
|
|
@@ -1693,8 +1974,8 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
storeOrder.setDeliveryId(po.getDeliveryId());
|
|
storeOrder.setDeliveryId(po.getDeliveryId());
|
|
storeOrder.setDeliveryName(po.getDeliveryName());
|
|
storeOrder.setDeliveryName(po.getDeliveryName());
|
|
update(storeOrder);
|
|
update(storeOrder);
|
|
- // updateOrderStatus(po.getId(), PinkOrderStatusEnum.WAIT_RECEIVER.getKey());
|
|
|
|
- updateOrderStatus(po.getId(), PinkOrderStatusEnum.GROUP_ORDER_TO_RECEVIE.getKey());
|
|
|
|
|
|
+ // updateOrderStatus(po.getId(), PinkOrderStatusEnum.WAIT_RECEIVER.getKey());
|
|
|
|
+ updateOrderStatus(po.getId(), PinkOrderStatusEnum.GROUP_ORDER_TO_RECEVIE.getKey());
|
|
}
|
|
}
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
@@ -1703,6 +1984,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private StorePinkMapper storePinkMapper;
|
|
private StorePinkMapper storePinkMapper;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void updateOrderStatus(Long id, Integer status) {
|
|
public void updateOrderStatus(Long id, Integer status) {
|
|
StoreOrder storeOrder = findById(id);
|
|
StoreOrder storeOrder = findById(id);
|
|
@@ -1715,12 +1997,11 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
// storePink.setOrderStatus(status);
|
|
// storePink.setOrderStatus(status);
|
|
// int i = storePinkMapper.updateByConditionSelective(storePink, example);
|
|
// int i = storePinkMapper.updateByConditionSelective(storePink, example);
|
|
|
|
|
|
- storeOrderStatusService.createLog(id, "", PinkOrderStatusEnum.getEnum(status).getValue());
|
|
|
|
|
|
+ // storeOrderStatusService.createLog(id, "", PinkOrderStatusEnum.getEnum(status).getValue());
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 校验商品库存(生成订单)
|
|
* 校验商品库存(生成订单)
|
|
*
|
|
*
|
|
@@ -1792,10 +2073,63 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private StoreOrderMapper storeOrderMapper;
|
|
private StoreOrderMapper storeOrderMapper;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void bindingAddress(StoreOrder storeOrder) {
|
|
public void bindingAddress(StoreOrder storeOrder) {
|
|
Example example = new Example(StoreOrder.class);
|
|
Example example = new Example(StoreOrder.class);
|
|
- example.createCriteria().andEqualTo("orderId",storeOrder.getOrderId());
|
|
|
|
- storeOrderMapper.updateByConditionSelective(storeOrder,example);
|
|
|
|
|
|
+ example.createCriteria().andEqualTo("orderId", storeOrder.getOrderId());
|
|
|
|
+ storeOrderMapper.updateByConditionSelective(storeOrder, example);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void batchSigning() {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ try{
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ Date settleTime = DateUtil.offsetDay(date,-1);
|
|
|
|
+
|
|
|
|
+ PageHelper.startPage(1, 100);
|
|
|
|
+ Condition condition = new Condition(StoreOrder.class);
|
|
|
|
+ Example.Criteria criteria = condition.createCriteria();
|
|
|
|
+ criteria.andEqualTo("isDelete", 0);
|
|
|
|
+ criteria.andEqualTo("status", PinkOrderStatusEnum.GROUP_ORDER_TO_RECEVIE.getKey());
|
|
|
|
+ criteria.andLessThanOrEqualTo("deliveryTime", settleTime);
|
|
|
|
+ List<StoreOrder> storeOrderList = findByCondition(condition);
|
|
|
|
+ if(!CollectionUtils.isEmpty(storeOrderList)){
|
|
|
|
+ for (StoreOrder storeOrder : storeOrderList) {
|
|
|
|
+ PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_CONFIRM_RECEIPT, null);
|
|
|
|
+ if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
|
|
+ throw new ServiceException("当前状态不支持签收storeOrder:"+storeOrder.toString());
|
|
|
|
+ }
|
|
|
|
+ StoreOrder storeOrderForUpdate = new StoreOrder();
|
|
|
|
+ storeOrderForUpdate.setStatus(pinkOrderStatusEnum.getKey());
|
|
|
|
+ storeOrderForUpdate.setSigningTime(date);
|
|
|
|
+ Example example = new Example(StoreOrder.class);
|
|
|
|
+ example.createCriteria().andEqualTo("orderId",storeOrder.getOrderId());
|
|
|
|
+ storeOrderMapper.updateByConditionSelective(storeOrderForUpdate,example);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ storeOrderStatusService.createLog(storeOrder.getId(), Constants.ORDER_STATUS_RECEIVE_ORDER, "订单自动签收");
|
|
|
|
+
|
|
|
|
+ //维护拼团订单状态
|
|
|
|
+ StorePink storePinkForUpdate = new StorePink();
|
|
|
|
+ storePinkForUpdate.setOrderStatus(pinkOrderStatusEnum.getKey());
|
|
|
|
+ Example exampleStorePink = new Example(StorePink.class);
|
|
|
|
+ exampleStorePink.createCriteria().andEqualTo("orderId",storeOrder.getOrderId());
|
|
|
|
+ storePinkMapper.updateByConditionSelective(storePinkForUpdate,exampleStorePink);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }catch(Exception e){
|
|
|
|
+ log.error("定时任务自动签收异常",e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|