|
@@ -4,12 +4,15 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.qs.mp.admin.domain.Coupon;
|
|
|
import com.qs.mp.admin.domain.CouponChannel;
|
|
|
import com.qs.mp.admin.domain.Ticket;
|
|
|
import com.qs.mp.admin.domain.vo.TicketListVO;
|
|
|
import com.qs.mp.admin.service.ICouponChannelService;
|
|
|
+import com.qs.mp.admin.service.ICouponService;
|
|
|
import com.qs.mp.admin.service.IGoodsService;
|
|
|
import com.qs.mp.channel.domain.Channel;
|
|
|
+import com.qs.mp.channel.service.IChannelService;
|
|
|
import com.qs.mp.common.core.domain.AjaxResult;
|
|
|
import com.qs.mp.common.core.page.TableDataInfo;
|
|
|
import com.qs.mp.common.enums.*;
|
|
@@ -84,6 +87,12 @@ public class UserMineController extends BaseApiController {
|
|
|
@Autowired
|
|
|
private ICouponChannelService couponChannelService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ICouponService couponService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IChannelService channelService;
|
|
|
+
|
|
|
/**
|
|
|
* 我的票包
|
|
|
*/
|
|
@@ -143,9 +152,21 @@ public class UserMineController extends BaseApiController {
|
|
|
.eq("t1.user_id", userId));
|
|
|
if (!CollectionUtils.isEmpty(userCouponVOList)) {
|
|
|
UserCouponVO userCouponVO = userCouponVOList.get(0);
|
|
|
- int channelTotal = couponChannelService.count(new LambdaQueryWrapper<CouponChannel>()
|
|
|
- .eq(CouponChannel::getCouponId, userCouponVO.getCouponId()));
|
|
|
- userCouponVO.setChannelTotal(channelTotal);
|
|
|
+
|
|
|
+ Coupon coupon = couponService.getById(userCouponVO.getCouponId());
|
|
|
+ if (CouponTypeEnum.SITE_CONSUME.equals(coupon.getType())) {
|
|
|
+ if (CouponUseAreaEnum.COMMON.equals(coupon.getUseArea())) {
|
|
|
+ // 所有门店
|
|
|
+ int channelTotal = channelService.count(new LambdaQueryWrapper<Channel>().eq(Channel::getLevel, 0));
|
|
|
+ userCouponVO.setChannelTotal(channelTotal);
|
|
|
+
|
|
|
+ }else if (CouponUseAreaEnum.PRE_SCOPE.equals(coupon.getUseArea())) {
|
|
|
+ // 指定门店
|
|
|
+ int channelTotal = couponChannelService.count(new LambdaQueryWrapper<CouponChannel>()
|
|
|
+ .eq(CouponChannel::getCouponId, userCouponVO.getCouponId()));
|
|
|
+ userCouponVO.setChannelTotal(channelTotal);
|
|
|
+ }
|
|
|
+ }
|
|
|
return AjaxResult.success(userCouponVO);
|
|
|
}
|
|
|
return AjaxResult.error("优惠券不存在");
|
|
@@ -162,16 +183,30 @@ public class UserMineController extends BaseApiController {
|
|
|
if (param.getCouponId() == null) {
|
|
|
return getErrorDataTable("优惠券id不能为空");
|
|
|
}
|
|
|
- startPage();
|
|
|
- QueryWrapper<CouponChannel> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("t1.coupon_id", param.getCouponId());
|
|
|
-
|
|
|
- queryWrapper.eq(null != param.getProvinceId(), "t2.province_id", param.getProvinceId());
|
|
|
- queryWrapper.eq(null != param.getCityId(), "t2.city_id", param.getCityId());
|
|
|
- queryWrapper.eq(null != param.getAreaId(), "t2.area_id", param.getAreaId());
|
|
|
|
|
|
- List<Channel> channelList = couponChannelService.listCouponChannelByQueryWrapper(queryWrapper);
|
|
|
+ Coupon coupon = couponService.getById(param.getCouponId());
|
|
|
+ if (coupon == null) {
|
|
|
+ return getErrorDataTable("优惠券信息不存在");
|
|
|
+ }
|
|
|
|
|
|
+ List<Channel> channelList = new ArrayList<>();
|
|
|
+ LambdaQueryWrapper<Channel> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(null != param.getProvinceId(), Channel::getProvinceId, param.getProvinceId());
|
|
|
+ queryWrapper.eq(null != param.getCityId(), Channel::getCityId, param.getCityId());
|
|
|
+ queryWrapper.eq(null != param.getAreaId(), Channel::getAreaId, param.getAreaId());
|
|
|
+
|
|
|
+ if (CouponUseAreaEnum.PRE_SCOPE.equals(coupon.getUseArea())) {
|
|
|
+ List<CouponChannel> couponChannelList = couponChannelService.list(
|
|
|
+ new LambdaQueryWrapper<CouponChannel>().eq(CouponChannel::getCouponId, coupon.getCouponId()));
|
|
|
+ if (CollectionUtils.isEmpty(couponChannelList)) {
|
|
|
+ return getDataTable(channelList);
|
|
|
+ }
|
|
|
+ List<Long> channelIds = couponChannelList.stream().map(CouponChannel::getChannelId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ queryWrapper.in(Channel::getChannelId, channelIds);
|
|
|
+ }
|
|
|
+ startPage();
|
|
|
+ channelList = channelService.list(queryWrapper);
|
|
|
return getDataTable(channelList);
|
|
|
}
|
|
|
|