|
@@ -6,7 +6,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.yiqi.app.domain.AppCouponItem;
|
|
|
import com.yiqi.app.domain.AppCouponTypeApplyCloth;
|
|
|
+import com.yiqi.app.domain.dto.AppCouponItemQueryByAppUserIdDTO;
|
|
|
import com.yiqi.app.domain.dto.weapp.WeAppCouponItemQueryDTO;
|
|
|
+import com.yiqi.app.domain.vo.AppCouponItemVO;
|
|
|
+import com.yiqi.app.domain.vo.AppCouponTypeApplyClothVO;
|
|
|
import com.yiqi.app.domain.vo.weapp.AppCouponItemListVO;
|
|
|
import com.yiqi.app.service.IAppCouponItemService;
|
|
|
import com.yiqi.app.service.IAppCouponTypeApplyClothService;
|
|
@@ -17,6 +20,7 @@ import com.yiqi.common.core.domain.AuthHolder;
|
|
|
import com.yiqi.common.core.domain.R;
|
|
|
import com.yiqi.common.enums.DeleteStatus;
|
|
|
import com.yiqi.common.enums.SysBoolType;
|
|
|
+import com.yiqi.common.exception.ServiceException;
|
|
|
import com.yiqi.common.utils.DateUtils;
|
|
|
import com.yiqi.common.utils.StringUtils;
|
|
|
import com.yiqi.common.utils.bean.BeanUtils;
|
|
@@ -91,6 +95,43 @@ public class WeAppCouponItemController extends BaseController {
|
|
|
return R.ok(voList);
|
|
|
}
|
|
|
|
|
|
+ @PostMapping(value = "getlistByAppUserId")
|
|
|
+ @ApiOperation("下单选择客户可使用的优惠券")
|
|
|
+ public R<List<AppCouponItemVO>> getlistByAppUserId(@RequestBody @Valid AppCouponItemQueryByAppUserIdDTO appCouponItemQueryByAppUserIdDTO) throws Exception {
|
|
|
+ if (appCouponItemQueryByAppUserIdDTO.getClothIds() == null || appCouponItemQueryByAppUserIdDTO.getClothIds().size() == 0) {
|
|
|
+ throw new ServiceException("未选择衣服");
|
|
|
+ }
|
|
|
+ Map<Long, ClothItem> clothItemMap = clothItemService.list(new QueryWrapper<ClothItem>().lambda()
|
|
|
+ .in(ClothItem::getId, appCouponItemQueryByAppUserIdDTO.getClothIds())).stream()
|
|
|
+ .collect(Collectors.toMap(ClothItem::getId, ClothItem -> ClothItem));
|
|
|
+ appCouponItemQueryByAppUserIdDTO.setDiscountWay(null);
|
|
|
+ List<AppCouponItemVO> appCouponItemVOS = appCouponItemService.getlistByAppUserId(appCouponItemQueryByAppUserIdDTO);
|
|
|
+ if (appCouponItemVOS == null || appCouponItemVOS.size() == 0) {
|
|
|
+ return R.ok(appCouponItemVOS);
|
|
|
+ }
|
|
|
+ List<AppCouponTypeApplyCloth> appCouponTypeApplyCloths = appCouponTypeApplyClothService.list(
|
|
|
+ new QueryWrapper<AppCouponTypeApplyCloth>().lambda()
|
|
|
+ .in(AppCouponTypeApplyCloth::getCouponTypeId
|
|
|
+ , appCouponItemVOS.stream().map(AppCouponItemVO::getCouponTypeId).collect(Collectors.toSet()))
|
|
|
+ .in(AppCouponTypeApplyCloth::getClothItemId, appCouponItemQueryByAppUserIdDTO.getClothIds()));
|
|
|
+ List<AppCouponTypeApplyClothVO> appCouponTypeApplyClothVOS = new ArrayList<>();
|
|
|
+ for (AppCouponTypeApplyCloth appCouponTypeApplyCloth : appCouponTypeApplyCloths) {
|
|
|
+ AppCouponTypeApplyClothVO appCouponTypeApplyClothVO = new AppCouponTypeApplyClothVO();
|
|
|
+ org.springframework.beans.BeanUtils.copyProperties(appCouponTypeApplyCloth, appCouponTypeApplyClothVO);
|
|
|
+ appCouponTypeApplyClothVO.setClothItemName(clothItemMap.get(appCouponTypeApplyCloth.getClothItemId()).getName());
|
|
|
+ appCouponTypeApplyClothVOS.add(appCouponTypeApplyClothVO);
|
|
|
+ }
|
|
|
+ Map<Long, List<AppCouponTypeApplyClothVO>> appCouponTypeApplyClothMap = appCouponTypeApplyClothVOS.stream()
|
|
|
+ .collect(Collectors.groupingBy(AppCouponTypeApplyClothVO::getCouponTypeId));
|
|
|
+
|
|
|
+ for (AppCouponItemVO appCouponItemVO : appCouponItemVOS) {
|
|
|
+ if (appCouponItemVO.getUseScope().equals(2)) {
|
|
|
+ appCouponItemVO.setAppCouponTypeApplyClothVOS(appCouponTypeApplyClothMap.get(appCouponItemVO.getCouponTypeId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.ok(appCouponItemVOS);
|
|
|
+ }
|
|
|
+
|
|
|
private String getIsValidBy(AppCouponItem appCouponItem) {
|
|
|
if (appCouponItem == null) {
|
|
|
return SysBoolType.NO.getCode();
|