|
@@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.txz.cif.dto.AccountDTO;
|
|
|
+import com.txz.cif.dto.ConfigMemberDTO;
|
|
|
import com.txz.cif.dto.Result;
|
|
|
import com.txz.cif.dto.UserDTO;
|
|
|
import com.txz.cif.param.AccomplishParam;
|
|
@@ -599,9 +600,12 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
if (userId == null) {
|
|
|
throw new ServiceException("用户id不能为空");
|
|
|
}
|
|
|
- // UserDTO user = userDubboServiceClient.getUser(userId);
|
|
|
+ UserDTO user = userDubboServiceClient.getUser(userId);
|
|
|
+ if(ObjectUtils.isEmpty(user)){
|
|
|
+ throw new ServiceException("用户为空userId:"+userId);
|
|
|
+ }
|
|
|
// 校验预下单商品信息
|
|
|
- OrderInfoVO orderInfoVo = validatePreOrderRequest(request, userId);
|
|
|
+ OrderInfoVO orderInfoVo = validatePreOrderRequest(request, user);
|
|
|
// 商品总计金额
|
|
|
BigDecimal totalPrice;
|
|
|
if (orderInfoVo.getOrderDetailList().get(0).getProductType().equals(Constants.PRODUCT_TYPE_NORMAL)) {
|
|
@@ -762,7 +766,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
*
|
|
|
* @return OrderInfoVo
|
|
|
*/
|
|
|
- private OrderInfoVO validatePreOrderRequest(PreOrderRequest request, Long userId) {
|
|
|
+ private OrderInfoVO validatePreOrderRequest(PreOrderRequest request, UserDTO user) {
|
|
|
OrderInfoVO orderInfoVo = new OrderInfoVO();
|
|
|
List<OrderInfoDetailVO> detailVoList = CollUtil.newArrayList();
|
|
|
// if ("shoppingCart".equals(request.getPreOrderType())) {
|
|
@@ -787,7 +791,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
// } else
|
|
|
if (detailRequest.getCId() > 0) {
|
|
|
// 拼团
|
|
|
- detailVoList.add(validatePreOrderCombination(detailRequest, userId));
|
|
|
+ detailVoList.add(validatePreOrderCombination(detailRequest, user));
|
|
|
orderInfoVo.setCombinationId(detailRequest.getCId());
|
|
|
orderInfoVo.setPinkId(detailRequest.getPinkId());
|
|
|
} else {
|
|
@@ -863,7 +867,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
*
|
|
|
* @return OrderInfoDetailVo
|
|
|
*/
|
|
|
- private OrderInfoDetailVO validatePreOrderCombination(PreOrderDetailRequest detailRequest, Long userId) {
|
|
|
+ private OrderInfoDetailVO validatePreOrderCombination(PreOrderDetailRequest detailRequest, UserDTO user) {
|
|
|
// 拼团部分判断
|
|
|
Long combinationId = detailRequest.getCId();
|
|
|
StoreCombination storeCombination = storeCombinationService.getByIdException(combinationId);
|
|
@@ -874,7 +878,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
if (ObjectUtil.isNull(combinationAttrValue)) {
|
|
|
throw new ServiceException("拼团商品规格不存在");
|
|
|
}
|
|
|
- commonValidateCombination(storeCombination, combinationAttrValue, userId, detailRequest.getProductNum());
|
|
|
+ commonValidateCombination(storeCombination, combinationAttrValue, user, detailRequest.getProductNum());
|
|
|
|
|
|
OrderInfoDetailVO detailVo = new OrderInfoDetailVO();
|
|
|
detailVo.setProductId(storeCombination.getProductId());
|
|
@@ -901,7 +905,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
*
|
|
|
* @return MyRecord
|
|
|
*/
|
|
|
- private MyRecord commonValidateCombination(StoreCombination storeCombination, ProductAttrValue combinationAttrValue, Long userId, Integer productNum) {
|
|
|
+ private MyRecord commonValidateCombination(StoreCombination storeCombination, ProductAttrValue combinationAttrValue, UserDTO user, Integer productNum) {
|
|
|
// 判断拼团时间段
|
|
|
Date date = new Date();
|
|
|
if (date.before(storeCombination.getStartTime())) {
|
|
@@ -936,21 +940,52 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
}
|
|
|
|
|
|
// 用户参与活动的次数
|
|
|
- // List<StoreOrder> userCombinationOrders = this.getUserCurrentCombinationOrders(userId, storeCombination.getId());
|
|
|
- // if (CollUtil.isNotEmpty(userCombinationOrders)) {
|
|
|
+ // List<StoreOrder> userCombinationOrders = this.getUserCurrentCombinationOrders(user.getId(), storeCombination.getId());
|
|
|
+ Condition conditionStoreOrder = new Condition(StoreOrder.class);
|
|
|
+ Example.Criteria criteriaStoreOrder = conditionStoreOrder.createCriteria();
|
|
|
+ criteriaStoreOrder.andEqualTo("uid",user.getId());
|
|
|
+ criteriaStoreOrder.andEqualTo("isDelete",0);
|
|
|
+ List<Integer> list = Arrays.asList(
|
|
|
+ PinkOrderStatusEnum.GROUP_ORDER_TO_SHIP.getKey(),
|
|
|
+ PinkOrderStatusEnum.GROUP_ORDER_TO_RECEVIE.getKey(),
|
|
|
+ PinkOrderStatusEnum.GROUP_ORDER_COMPLETED.getKey(),
|
|
|
+ PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey(),
|
|
|
+ PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey()
|
|
|
+ );
|
|
|
+ criteriaStoreOrder.andIn("status",list);
|
|
|
+
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.set(Calendar.HOUR_OF_DAY, 0); // 小时设为0
|
|
|
+ calendar.set(Calendar.MINUTE, 0); // 分钟设为0
|
|
|
+ calendar.set(Calendar.SECOND, 0); // 秒设为0
|
|
|
+ calendar.set(Calendar.MILLISECOND, 0); // 毫秒设为0
|
|
|
+ Date todayStart = calendar.getTime();
|
|
|
+ criteriaStoreOrder.andGreaterThanOrEqualTo("createTime",todayStart);
|
|
|
+
|
|
|
+ List<StoreOrder> storeOrderList = storeOrderMapper.selectByCondition(conditionStoreOrder);
|
|
|
+ if(ObjectUtils.isEmpty(user.getVipLevel())){
|
|
|
+ user.setVipLevel(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ ConfigMemberDTO configByLevel = userDubboServiceClient.getConfigByLevel(user.getVipLevel());
|
|
|
+ if(ObjectUtils.isEmpty(configByLevel)){
|
|
|
+ throw new ServiceException("用户等级对应的购买次数配置不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollUtil.isNotEmpty(storeOrderList)) {
|
|
|
// 判断是否有待支付订单
|
|
|
// 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("您有拼团待支付订单,请支付后再购买");
|
|
|
// }
|
|
|
-// int payNum = userCombinationOrders.stream().mapToInt(StoreOrder::getTotalNum).sum();
|
|
|
-// if (storeCombination.getNum() <= payNum) {
|
|
|
-// throw new ServiceException("您已达到该商品拼团活动上限");
|
|
|
-// }
|
|
|
+ int payNum = storeOrderList.stream().mapToInt(StoreOrder::getTotalNum).sum();
|
|
|
+ if (configByLevel.getJoinedGroupsNo() < payNum) {
|
|
|
+ throw new ServiceException("您已达到该商品拼团活动上限");
|
|
|
+ }
|
|
|
// if ((payNum + productNum) > storeCombination.getNum()) {
|
|
|
// throw new ServiceException("超过该商品拼团活动您的购买上限");
|
|
|
// }
|
|
|
- // }
|
|
|
+ }
|
|
|
|
|
|
MyRecord record = new MyRecord();
|
|
|
record.set("productAttrValue", productAttrValue);
|
|
@@ -2193,7 +2228,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
if (ObjectUtil.isNull(combinationAttrValue)) {
|
|
|
throw new ServiceException("拼团商品规格不存在");
|
|
|
}
|
|
|
- MyRecord combinationRecord = commonValidateCombination(storeCombination, combinationAttrValue, user.getId(), detailVo.getPayNum());
|
|
|
+ MyRecord combinationRecord = commonValidateCombination(storeCombination, combinationAttrValue, user, detailVo.getPayNum());
|
|
|
ProductAttrValue productAttrValue = combinationRecord.get("productAttrValue");
|
|
|
|
|
|
MyRecord record = new MyRecord();
|