|
@@ -1,5 +1,6 @@
|
|
|
package com.txz.mall.service.impl;
|
|
|
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import com.txz.mall.core.AbstractService;
|
|
|
import com.txz.mall.core.ServiceException;
|
|
|
import com.txz.mall.dao.StoreCombinationMapper;
|
|
@@ -9,6 +10,8 @@ import com.txz.mall.service.StoreCombinationService;
|
|
|
import com.txz.mall.service.StoreFlashActivityService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import vo.GoPinkVO;
|
|
|
+import vo.StorePinkVO;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
@@ -34,4 +37,218 @@ public class StoreCombinationServiceImpl extends AbstractService<StoreCombinatio
|
|
|
}
|
|
|
save(list);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public GoPinkVO goPink(Integer pinkId) {
|
|
|
+ int isOk = 0;//判断拼团是否完成
|
|
|
+ int userBool = 0;//判断当前用户是否在团内 0未在 1在
|
|
|
+ int pinkBool = 0;//判断拼团是否成功 0未成功 1成功
|
|
|
+//
|
|
|
+// StorePink teamPink = storePinkService.getById(pinkId);
|
|
|
+// if (ObjectUtil.isNull(teamPink) || teamPink.getIsRefund()) throw new CrmebException("对应的拼团不存在");
|
|
|
+// StoreCombination storeCombination = getById(teamPink.getCid());
|
|
|
+// if (ObjectUtil.isNull(storeCombination) || storeCombination.getIsDel()) throw new CrmebException("对应拼团商品不存在");
|
|
|
+//
|
|
|
+// // 判断拼团活动时效
|
|
|
+// if (!storeCombination.getIsShow()) {
|
|
|
+// throw new ServiceException("拼团活动已结束");
|
|
|
+// }
|
|
|
+// if (System.currentTimeMillis() > storeCombination.getStopTime()) {
|
|
|
+// throw new ServiceException("拼团活动已结束");
|
|
|
+// }
|
|
|
+//
|
|
|
+// User user = userService.getInfo();
|
|
|
+//
|
|
|
+// GoPinkResponse goPinkResponse = new GoPinkResponse();
|
|
|
+// List<StorePink> pinkList;
|
|
|
+// if (teamPink.getKId().equals(0)) {
|
|
|
+// pinkList = storePinkService.getListByCidAndKid(teamPink.getCid(), teamPink.getId());
|
|
|
+// pinkList.add(teamPink);
|
|
|
+// } else {
|
|
|
+// pinkList = storePinkService.getListByCidAndKid(teamPink.getCid(), teamPink.getKId());
|
|
|
+// pinkList.add(storePinkService.getById(teamPink.getKId()));
|
|
|
+// }
|
|
|
+// //拼团剩余人数
|
|
|
+// int count = teamPink.getPeople() - ( CollUtil.isEmpty(pinkList) ? 0 : pinkList.size() );
|
|
|
+//
|
|
|
+// if (teamPink.getStatus() == 2) {//已完成
|
|
|
+// isOk = 1;
|
|
|
+// pinkBool = 1;
|
|
|
+// }
|
|
|
+// if (teamPink.getStatus() == 1) {//进行中
|
|
|
+// if (count < 1) {// 拼团已完成
|
|
|
+// isOk = 1;
|
|
|
+// pinkBool = 1;
|
|
|
+// // 拼团完成处理
|
|
|
+// storePinkService.pinkSuccess(teamPink.getId());
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<Integer> uidList = pinkList.stream().map(StorePink::getUid).collect(Collectors.toList());
|
|
|
+// uidList.add(teamPink.getUid());
|
|
|
+// if (uidList.contains(user.getUid())) {
|
|
|
+// userBool = 1;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 处理用户头像昵称
|
|
|
+// List<StorePinkResponse> pinkResponseList = CollUtil.newArrayList();
|
|
|
+// // 团长
|
|
|
+// StorePinkResponse storePinkTResponse = new StorePinkResponse();
|
|
|
+// for (StorePink pink : pinkList) {
|
|
|
+// if (pink.getKId().equals(0)) {
|
|
|
+// BeanUtils.copyProperties(pink, storePinkTResponse);
|
|
|
+// if (pink.getUid().equals(user.getUid())) {
|
|
|
+// storePinkTResponse.setNickname(user.getNickname());
|
|
|
+// storePinkTResponse.setAvatar(user.getAvatar());
|
|
|
+// } else {
|
|
|
+// User teamUser = userService.getById(pink.getUid());
|
|
|
+// storePinkTResponse.setNickname(teamUser.getNickname());
|
|
|
+// storePinkTResponse.setAvatar(teamUser.getAvatar());
|
|
|
+// }
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// StorePinkResponse storePinkResponse = new StorePinkResponse();
|
|
|
+// BeanUtils.copyProperties(pink, storePinkResponse);
|
|
|
+// User userOne = userService.getById(pink.getUid());
|
|
|
+// storePinkResponse.setNickname(userOne.getNickname());
|
|
|
+// storePinkResponse.setAvatar(userOne.getAvatar());
|
|
|
+// pinkResponseList.add(storePinkResponse);
|
|
|
+// }
|
|
|
+//
|
|
|
+// goPinkResponse.setCount(count);
|
|
|
+// goPinkResponse.setIsOk(isOk);
|
|
|
+// goPinkResponse.setPinkBool(pinkBool);
|
|
|
+// goPinkResponse.setUserBool(userBool);
|
|
|
+// if (userBool == 1) {
|
|
|
+// pinkList.forEach(e -> {
|
|
|
+// if (e.getUid().equals(user.getUid())) {
|
|
|
+// goPinkResponse.setCurrentPinkOrder(e.getOrderId());
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+// goPinkResponse.setPinkAll(pinkResponseList);
|
|
|
+// goPinkResponse.setPinkT(storePinkTResponse);
|
|
|
+// 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);
|
|
|
+// List<HashMap<String, Object>> skuAttrList = getSkuAttrList(attrList);
|
|
|
+// detailResponse.setProductAttr(skuAttrList);
|
|
|
+// if (CollUtil.isNotEmpty(attrList) && attrList.size() > 1) {
|
|
|
+// detailResponse.setSpecType(true);
|
|
|
+// }
|
|
|
+// // 单属性时讲attrValueId 赋值给外层方便前端使用
|
|
|
+// if (!detailResponse.getSpecType()) {
|
|
|
+// detailResponse.setAloneAttrValueId(attrList.get(0).getId());
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// StoreProductAttrValue spavValue = new StoreProductAttrValue();
|
|
|
+// spavValue.setProductId(storeCombination.getId());
|
|
|
+// spavValue.setType(Constants.PRODUCT_TYPE_PINGTUAN);
|
|
|
+// List<StoreProductAttrValue> valueList = storeProductAttrValueService.getByEntity(spavValue);
|
|
|
+// // H5 端用于生成skuList
|
|
|
+// List<StoreProductAttrValueResponse> sPAVResponses = new ArrayList<>();
|
|
|
+// for (StoreProductAttrValue storeProductAttrValue : valueList) {
|
|
|
+// StoreProductAttrValueResponse atr = new StoreProductAttrValueResponse();
|
|
|
+// BeanUtils.copyProperties(storeProductAttrValue, atr);
|
|
|
+// sPAVResponses.add(atr);
|
|
|
+// }
|
|
|
+// HashMap<String, Object> skuMap = new HashMap<>();
|
|
|
+// for (StoreProductAttrValueResponse attrValue : sPAVResponses) {
|
|
|
+// skuMap.put(attrValue.getSuk(), attrValue);
|
|
|
+// }
|
|
|
+//
|
|
|
+// detailResponse.setProductValue(skuMap);
|
|
|
+// goPinkResponse.setStoreCombination(detailResponse);
|
|
|
+// return goPinkResponse;
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<StoreCombination> getMore(Integer page, Integer size, Integer comId) {
|
|
|
+// Page<StoreCombination> combinationPage = PageHelper.startPage(page, size);
|
|
|
+// LambdaQueryWrapper<StoreCombination> lqw = new LambdaQueryWrapper<>();
|
|
|
+// if (ObjectUtil.isNotNull(comId)) {
|
|
|
+// lqw.ne(StoreCombination::getId, comId);
|
|
|
+// }
|
|
|
+// lqw.eq(StoreCombination::getIsDel, false);
|
|
|
+// lqw.eq(StoreCombination::getIsShow, true);
|
|
|
+// long millis = System.currentTimeMillis();
|
|
|
+// lqw.le(StoreCombination::getStartTime, millis);
|
|
|
+// lqw.ge(StoreCombination::getStopTime, millis);
|
|
|
+// lqw.orderByDesc(StoreCombination::getSort, StoreCombination::getId);
|
|
|
+// List<StoreCombination> storeCombinations = dao.selectList(lqw);
|
|
|
+// return CommonPage.copyPageInfo(combinationPage, storeCombinations);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 取消拼团
|
|
|
+ *
|
|
|
+ * @return 此处只是转为申请退款订单
|
|
|
+ * 自己是团长,取消后,顺位第一人变为团长
|
|
|
+ * 自己不是团长,直接取消
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean removePink(StorePinkVO storePinkRequest) {
|
|
|
+// StorePink userPink = storePinkService.getById(storePinkRequest.getId());
|
|
|
+// if (ObjectUtil.isNull(userPink)) throw new CrmebException("未查到拼团信息,无法取消");
|
|
|
+// if (userPink.getIsRefund()) throw new CrmebException("拼团订单已退款");
|
|
|
+// // 获取是否拼团成功
|
|
|
+// if (userPink.getStatus() == 2) {
|
|
|
+// throw new CrmebException("拼团已完成,无法取消");
|
|
|
+// }
|
|
|
+// Integer kid = userPink.getKId() > 0 ? userPink.getKId() : userPink.getId();
|
|
|
+// Integer count = storePinkService.getCountByKid(kid);
|
|
|
+// if (count.equals(userPink.getPeople())) {
|
|
|
+// // 拼团完成操作
|
|
|
+// storePinkService.pinkSuccess(kid);
|
|
|
+// throw new CrmebException("拼团已完成,无法取消");
|
|
|
+// }
|
|
|
+// if (userPink.getStatus() == 3) {
|
|
|
+// throw new CrmebException("拼团已申请取消");
|
|
|
+// }
|
|
|
+//
|
|
|
+// StoreOrder order = storeOrderService.getByOderId(userPink.getOrderId());
|
|
|
+// if (ObjectUtil.isNull(order) || order.getIsDel()) throw new CrmebException("拼团订单不存在");
|
|
|
+// if (order.getStatus() == -1 && order.getRefundStatus() != 0) {
|
|
|
+// throw new CrmebException("拼团订单已进入退款流程");
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 订单申请退款
|
|
|
+// OrderRefundApplyRequest refundRequest = new OrderRefundApplyRequest();
|
|
|
+// refundRequest.setId(order.getId());
|
|
|
+// refundRequest.setUni(order.getOrderId());
|
|
|
+// refundRequest.setText("拼团订单取消,申请退款");
|
|
|
+// refundRequest.setExplain("用户取消拼团订单,申请退款");
|
|
|
+// boolean apply = orderService.refundApply(refundRequest);
|
|
|
+// if (!apply) throw new CrmebException("订单申请退款失败");
|
|
|
+//
|
|
|
+// // 拼团改为未完成
|
|
|
+// userPink.setStatus(3).setStopTime(System.currentTimeMillis());
|
|
|
+// storePinkService.updateById(userPink);
|
|
|
+// if (userPink.getKId() == 0) {// 是团长
|
|
|
+// List<StorePink> pinkList = storePinkService.getListByCidAndKid(userPink.getCid(), userPink.getId());
|
|
|
+// if (CollUtil.isNotEmpty(pinkList)) {
|
|
|
+// // 团员更换团长
|
|
|
+// StorePink newHeadPink = pinkList.get(pinkList.size() - 1);
|
|
|
+// newHeadPink.setKId(0);
|
|
|
+// pinkList.remove(pinkList.size() - 1);
|
|
|
+// pinkList.forEach(i -> i.setKId(newHeadPink.getId()));
|
|
|
+// pinkList.add(newHeadPink);
|
|
|
+// storePinkService.updateBatchById(pinkList);
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|