|
@@ -4,28 +4,27 @@ import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
|
+import com.txz.mall.constants.Constants;
|
|
import com.txz.mall.core.AbstractService;
|
|
import com.txz.mall.core.AbstractService;
|
|
import com.txz.mall.core.ServiceException;
|
|
import com.txz.mall.core.ServiceException;
|
|
import com.txz.mall.dao.StoreCombinationMapper;
|
|
import com.txz.mall.dao.StoreCombinationMapper;
|
|
-import com.txz.mall.model.StoreCombination;
|
|
|
|
-import com.txz.mall.model.StoreFlashActivity;
|
|
|
|
-import com.txz.mall.model.StoreOrder;
|
|
|
|
-import com.txz.mall.model.StorePink;
|
|
|
|
-import com.txz.mall.service.StoreCombinationService;
|
|
|
|
-import com.txz.mall.service.StoreFlashActivityService;
|
|
|
|
-import com.txz.mall.service.StoreOrderService;
|
|
|
|
-import com.txz.mall.service.StorePinkService;
|
|
|
|
|
|
+import com.txz.mall.model.*;
|
|
|
|
+import com.txz.mall.service.*;
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
import tk.mybatis.mapper.entity.Example;
|
|
import tk.mybatis.mapper.entity.Example;
|
|
-import vo.FlashActivityVO;
|
|
|
|
-import vo.GoPinkVO;
|
|
|
|
|
|
+import vo.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
+import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Set;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@@ -38,6 +37,9 @@ public class StoreCombinationServiceImpl extends AbstractService<StoreCombinatio
|
|
@Resource
|
|
@Resource
|
|
private StoreCombinationMapper storeCombinationMapper;
|
|
private StoreCombinationMapper storeCombinationMapper;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private StoreProductService storeProductService;
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
private StoreFlashActivityService storeFlashActivityService;
|
|
private StoreFlashActivityService storeFlashActivityService;
|
|
|
|
|
|
@@ -47,6 +49,12 @@ public class StoreCombinationServiceImpl extends AbstractService<StoreCombinatio
|
|
@Resource
|
|
@Resource
|
|
private StoreOrderService storeOrderService;
|
|
private StoreOrderService storeOrderService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private ProductAttrService productAttrService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private ProductAttrValueService productAttrValueService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void addActivityProduct(List<StoreCombination> list, Long activityId) {
|
|
public void addActivityProduct(List<StoreCombination> list, Long activityId) {
|
|
StoreFlashActivity flashActivity = storeFlashActivityService.findById(activityId);
|
|
StoreFlashActivity flashActivity = storeFlashActivityService.findById(activityId);
|
|
@@ -63,11 +71,63 @@ public class StoreCombinationServiceImpl extends AbstractService<StoreCombinatio
|
|
storeCombination.setPeople(activityVO.getGroupNumber());
|
|
storeCombination.setPeople(activityVO.getGroupNumber());
|
|
storeCombination.setEffectiveTime(activityVO.getCountdownTime());
|
|
storeCombination.setEffectiveTime(activityVO.getCountdownTime());
|
|
storeCombination.setStock(activityVO.getInventory());
|
|
storeCombination.setStock(activityVO.getInventory());
|
|
|
|
+ storeCombination.setActivityId(activityId);
|
|
|
|
+ }
|
|
|
|
+ // 直接进行覆盖
|
|
|
|
+ Condition condition = new Condition(StoreFlashActivity.class);
|
|
|
|
+ Example.Criteria criteria = condition.createCriteria();
|
|
|
|
+ criteria.andEqualTo("activityId", activityId);
|
|
|
|
+ criteria.andEqualTo("isDelete", 0);
|
|
|
|
+ List<StoreFlashActivity> activityList = storeFlashActivityService.findByCondition(condition);
|
|
|
|
+ if (CollUtil.isNotEmpty(activityList)) {
|
|
|
|
+ activityList.forEach(item -> {
|
|
|
|
+ item.setIsDelete(1);
|
|
|
|
+ storeFlashActivityService.update(item);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
- List<Long> productCollect = list.stream().map(StoreCombination::getProductId).collect(Collectors.toList());
|
|
|
|
|
|
+ save(list);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public PageInfo<ActivityProductVO> getActivityProduct(Long activityId, Integer page, Integer size) {
|
|
|
|
+ PageHelper.startPage(page, size);
|
|
|
|
+ PageInfo pageInfo = null;
|
|
|
|
+ Condition productCondition = new Condition(StoreProduct.class);
|
|
|
|
+ Example.Criteria productCriteria = productCondition.createCriteria();
|
|
|
|
+ productCriteria.andEqualTo("isDelete", 0);
|
|
|
|
+ List<StoreProduct> productList = storeProductService.findByCondition(productCondition);
|
|
|
|
+ List<Long> productCollect = productList.stream().map(StoreProduct::getId).collect(Collectors.toList());
|
|
|
|
|
|
- save(list);
|
|
|
|
|
|
+ Condition condition = new Condition(StoreCombination.class);
|
|
|
|
+ Example.Criteria criteria = condition.createCriteria();
|
|
|
|
+ criteria.andEqualTo("isDelete", 0);
|
|
|
|
+ criteria.andEqualTo("activityId", activityId);
|
|
|
|
+ List<StoreCombination> activityList = findByCondition(condition);
|
|
|
|
+ List<Long> combinationCollect = activityList.stream().map(StoreCombination::getProductId).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ Set<Long> combinationSet = new HashSet<>(combinationCollect);
|
|
|
|
+ Set<Long> productSet = new HashSet<>(productCollect);
|
|
|
|
+
|
|
|
|
+ // 交集
|
|
|
|
+ Set<Long> intersectionSet = new HashSet<>(productSet);
|
|
|
|
+ intersectionSet.retainAll(combinationSet);
|
|
|
|
+
|
|
|
|
+// List<ActivityProductVO> list = productList.stream()
|
|
|
|
+// .map(product -> {
|
|
|
|
+// ActivityProductVO vo = new ActivityProductVO();
|
|
|
|
+// BeanUtils.copyProperties(vo, product); // Spring BeanUtils
|
|
|
|
+// if (intersectionSet.contains(vo.getId())) {
|
|
|
|
+// vo.setIsExist(1);
|
|
|
|
+// } else {
|
|
|
|
+// vo.setIsExist(0);
|
|
|
|
+// }
|
|
|
|
+// return vo;
|
|
|
|
+// })
|
|
|
|
+// .collect(Collectors.toList());
|
|
|
|
+//
|
|
|
|
+// return new PageInfo(list);
|
|
|
|
+
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -102,7 +162,7 @@ public class StoreCombinationServiceImpl extends AbstractService<StoreCombinatio
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public GoPinkVO goPink(Long pinkId) {
|
|
|
|
|
|
+ public GoPinkResponse goPink(Long pinkId) {
|
|
//判断拼团是否完成
|
|
//判断拼团是否完成
|
|
int isOk = 0;
|
|
int isOk = 0;
|
|
//判断当前用户是否在团内 0未在 1在
|
|
//判断当前用户是否在团内 0未在 1在
|
|
@@ -130,7 +190,7 @@ public class StoreCombinationServiceImpl extends AbstractService<StoreCombinatio
|
|
//
|
|
//
|
|
// User user = userService.getInfo();
|
|
// User user = userService.getInfo();
|
|
//
|
|
//
|
|
-// GoPinkResponse goPinkResponse = new GoPinkResponse();
|
|
|
|
|
|
+ GoPinkResponse goPinkResponse = new GoPinkResponse();
|
|
List<StorePink> pinkList;
|
|
List<StorePink> pinkList;
|
|
if (teamPink.getKId().equals(0L)) {
|
|
if (teamPink.getKId().equals(0L)) {
|
|
pinkList = storePinkService.getListByCidAndKid(teamPink.getCid(), teamPink.getId());
|
|
pinkList = storePinkService.getListByCidAndKid(teamPink.getCid(), teamPink.getId());
|
|
@@ -166,12 +226,12 @@ public class StoreCombinationServiceImpl extends AbstractService<StoreCombinatio
|
|
// }
|
|
// }
|
|
//
|
|
//
|
|
// // 处理用户头像昵称
|
|
// // 处理用户头像昵称
|
|
-// List<StorePinkResponse> pinkResponseList = CollUtil.newArrayList();
|
|
|
|
-// // 团长
|
|
|
|
-// StorePinkResponse storePinkTResponse = new StorePinkResponse();
|
|
|
|
-// for (StorePink pink : pinkList) {
|
|
|
|
-// if (pink.getKId().equals(0)) {
|
|
|
|
-// BeanUtils.copyProperties(pink, storePinkTResponse);
|
|
|
|
|
|
+ List<StorePinkVO> pinkResponseList = CollUtil.newArrayList();
|
|
|
|
+ // 团长
|
|
|
|
+ StorePinkVO storePinkTResponse = new StorePinkVO();
|
|
|
|
+ for (StorePink pink : pinkList) {
|
|
|
|
+ if (pink.getKId().equals(0)) {
|
|
|
|
+ BeanUtils.copyProperties(pink, storePinkTResponse);
|
|
// if (pink.getUid().equals(user.getUid())) {
|
|
// if (pink.getUid().equals(user.getUid())) {
|
|
// storePinkTResponse.setNickname(user.getNickname());
|
|
// storePinkTResponse.setNickname(user.getNickname());
|
|
// storePinkTResponse.setAvatar(user.getAvatar());
|
|
// storePinkTResponse.setAvatar(user.getAvatar());
|
|
@@ -180,40 +240,40 @@ public class StoreCombinationServiceImpl extends AbstractService<StoreCombinatio
|
|
// storePinkTResponse.setNickname(teamUser.getNickname());
|
|
// storePinkTResponse.setNickname(teamUser.getNickname());
|
|
// storePinkTResponse.setAvatar(teamUser.getAvatar());
|
|
// storePinkTResponse.setAvatar(teamUser.getAvatar());
|
|
// }
|
|
// }
|
|
-// continue;
|
|
|
|
-// }
|
|
|
|
-// StorePinkResponse storePinkResponse = new StorePinkResponse();
|
|
|
|
-// BeanUtils.copyProperties(pink, storePinkResponse);
|
|
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ StorePinkVO storePinkResponse = new StorePinkVO();
|
|
|
|
+ BeanUtils.copyProperties(pink, storePinkResponse);
|
|
// User userOne = userService.getById(pink.getUid());
|
|
// User userOne = userService.getById(pink.getUid());
|
|
// storePinkResponse.setNickname(userOne.getNickname());
|
|
// storePinkResponse.setNickname(userOne.getNickname());
|
|
// storePinkResponse.setAvatar(userOne.getAvatar());
|
|
// storePinkResponse.setAvatar(userOne.getAvatar());
|
|
-// pinkResponseList.add(storePinkResponse);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// goPinkResponse.setCount(count);
|
|
|
|
-// goPinkResponse.setIsOk(isOk);
|
|
|
|
-// goPinkResponse.setPinkBool(pinkBool);
|
|
|
|
-// goPinkResponse.setUserBool(userBool);
|
|
|
|
-// if (userBool == 1) {
|
|
|
|
|
|
+ pinkResponseList.add(storePinkResponse);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ goPinkResponse.setCount(count);
|
|
|
|
+ goPinkResponse.setIsOk(isOk);
|
|
|
|
+ goPinkResponse.setPinkBool(pinkBool);
|
|
|
|
+ goPinkResponse.setUserBool(userBool);
|
|
|
|
+ if (userBool == 1) {
|
|
// pinkList.forEach(e -> {
|
|
// pinkList.forEach(e -> {
|
|
// if (e.getUid().equals(user.getUid())) {
|
|
// if (e.getUid().equals(user.getUid())) {
|
|
// goPinkResponse.setCurrentPinkOrder(e.getOrderId());
|
|
// goPinkResponse.setCurrentPinkOrder(e.getOrderId());
|
|
// }
|
|
// }
|
|
// });
|
|
// });
|
|
-// }
|
|
|
|
-// goPinkResponse.setPinkAll(pinkResponseList);
|
|
|
|
-// goPinkResponse.setPinkT(storePinkTResponse);
|
|
|
|
|
|
+ }
|
|
|
|
+ goPinkResponse.setPinkAll(pinkResponseList);
|
|
|
|
+ goPinkResponse.setPinkT(storePinkTResponse);
|
|
// goPinkResponse.setUserInfo(user);
|
|
// goPinkResponse.setUserInfo(user);
|
|
-//
|
|
|
|
-// // storeCombination部分
|
|
|
|
-// StoreCombinationResponse detailResponse = new StoreCombinationResponse();
|
|
|
|
-// BeanUtils.copyProperties(storeCombination, detailResponse);
|
|
|
|
-// detailResponse.setSpecType(false);
|
|
|
|
-// // sku部分
|
|
|
|
-// StoreProductAttr spavAttr = new StoreProductAttr();
|
|
|
|
-// spavAttr.setProductId(storeCombination.getId());
|
|
|
|
-// spavAttr.setType(Constants.PRODUCT_TYPE_PINGTUAN);
|
|
|
|
-// List<StoreProductAttr> attrList = storeProductAttrService.getByEntity(spavAttr);
|
|
|
|
|
|
+
|
|
|
|
+ // storeCombination部分
|
|
|
|
+ StoreCombinationVO detailResponse = new StoreCombinationVO();
|
|
|
|
+ BeanUtils.copyProperties(storeCombination, detailResponse);
|
|
|
|
+ detailResponse.setSpecType(false);
|
|
|
|
+ // sku部分
|
|
|
|
+ ProductAttr spavAttr = new ProductAttr();
|
|
|
|
+ spavAttr.setProductId(storeCombination.getId());
|
|
|
|
+ spavAttr.setType(Constants.PRODUCT_TYPE_PINGTUAN);
|
|
|
|
+// List<ProductAttr> attrList = productAttrService.getByEntity(spavAttr);
|
|
// List<HashMap<String, Object>> skuAttrList = getSkuAttrList(attrList);
|
|
// List<HashMap<String, Object>> skuAttrList = getSkuAttrList(attrList);
|
|
// detailResponse.setProductAttr(skuAttrList);
|
|
// detailResponse.setProductAttr(skuAttrList);
|
|
// if (CollUtil.isNotEmpty(attrList) && attrList.size() > 1) {
|
|
// if (CollUtil.isNotEmpty(attrList) && attrList.size() > 1) {
|
|
@@ -225,19 +285,19 @@ public class StoreCombinationServiceImpl extends AbstractService<StoreCombinatio
|
|
// }
|
|
// }
|
|
//
|
|
//
|
|
//
|
|
//
|
|
-// StoreProductAttrValue spavValue = new StoreProductAttrValue();
|
|
|
|
|
|
+// ProductAttrValue spavValue = new ProductAttrValue();
|
|
// spavValue.setProductId(storeCombination.getId());
|
|
// spavValue.setProductId(storeCombination.getId());
|
|
// spavValue.setType(Constants.PRODUCT_TYPE_PINGTUAN);
|
|
// spavValue.setType(Constants.PRODUCT_TYPE_PINGTUAN);
|
|
-// List<StoreProductAttrValue> valueList = storeProductAttrValueService.getByEntity(spavValue);
|
|
|
|
|
|
+// List<ProductAttrValue> valueList = productAttrValueService.getByEntity(spavValue);
|
|
// // H5 端用于生成skuList
|
|
// // H5 端用于生成skuList
|
|
-// List<StoreProductAttrValueResponse> sPAVResponses = new ArrayList<>();
|
|
|
|
-// for (StoreProductAttrValue storeProductAttrValue : valueList) {
|
|
|
|
-// StoreProductAttrValueResponse atr = new StoreProductAttrValueResponse();
|
|
|
|
|
|
+// List<StoreProductAttrValueVO> sPAVResponses = new ArrayList<>();
|
|
|
|
+// for (ProductAttrValue storeProductAttrValue : valueList) {
|
|
|
|
+// StoreProductAttrValueVO atr = new StoreProductAttrValueVO();
|
|
// BeanUtils.copyProperties(storeProductAttrValue, atr);
|
|
// BeanUtils.copyProperties(storeProductAttrValue, atr);
|
|
// sPAVResponses.add(atr);
|
|
// sPAVResponses.add(atr);
|
|
// }
|
|
// }
|
|
// HashMap<String, Object> skuMap = new HashMap<>();
|
|
// HashMap<String, Object> skuMap = new HashMap<>();
|
|
-// for (StoreProductAttrValueResponse attrValue : sPAVResponses) {
|
|
|
|
|
|
+// for (StoreProductAttrValueVO attrValue : sPAVResponses) {
|
|
// skuMap.put(attrValue.getSuk(), attrValue);
|
|
// skuMap.put(attrValue.getSuk(), attrValue);
|
|
// }
|
|
// }
|
|
//
|
|
//
|