| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dsh.activity.entity.Coupon; |
| | | import com.dsh.activity.entity.CouponCity; |
| | | import com.dsh.activity.entity.CouponStore; |
| | | import com.dsh.activity.entity.UserCoupon; |
| | | import com.dsh.activity.entity.*; |
| | | import com.dsh.activity.feignclient.account.AppUserClient; |
| | | import com.dsh.activity.feignclient.account.CityClient; |
| | | import com.dsh.activity.feignclient.account.StoreStaffClient; |
| | |
| | | import com.dsh.activity.feignclient.other.OperatorClient; |
| | | import com.dsh.activity.feignclient.other.RegionClient; |
| | | import com.dsh.activity.feignclient.other.StoreClient; |
| | | import com.dsh.activity.feignclient.other.VipClient; |
| | | import com.dsh.activity.feignclient.other.model.CityDataAndProvinceDataVo; |
| | | import com.dsh.activity.feignclient.other.model.Store; |
| | | import com.dsh.activity.feignclient.other.model.StoreInfoDto; |
| | | import com.dsh.activity.feignclient.other.model.TOperatorCity; |
| | | import com.dsh.activity.model.CouponListVo; |
| | | import com.dsh.activity.model.CouponRecordQuery; |
| | | import com.dsh.activity.model.request.CommodityRequest; |
| | | import com.dsh.activity.model.request.CouponDataVo; |
| | | import com.dsh.activity.model.request.CouponPackageReq; |
| | | import com.dsh.activity.model.VipDetailVO; |
| | | import com.dsh.activity.model.VipPaymentVO; |
| | | import com.dsh.activity.model.request.*; |
| | | import com.dsh.activity.model.response.CouponPackageResp; |
| | | import com.dsh.activity.service.CouponCityService; |
| | | import com.dsh.activity.service.CouponStoreService; |
| | | import com.dsh.activity.service.ICouponService; |
| | | import com.dsh.activity.service.UserCouponService; |
| | | import com.dsh.activity.service.*; |
| | | import com.dsh.activity.util.GDMapGeocodingUtil; |
| | | import com.dsh.activity.util.ResultUtil; |
| | | import com.dsh.activity.util.TokenUtil; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.models.auth.In; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | |
| | | @Autowired |
| | | private ICouponService couponService; |
| | | @Autowired |
| | | private VipDetailService vipDetailService; |
| | | |
| | | @Autowired |
| | | private TokenUtil tokenUtil; |
| | | @Autowired |
| | | private VipClient vipClient; |
| | | |
| | | @Autowired |
| | | private UserCouponService ucService; |
| | | |
| | | |
| | | @Autowired |
| | | private GDMapGeocodingUtil gdMapGeocodingUtil; |
| | |
| | | |
| | | @Resource |
| | | private StudentClient studentClient; |
| | | @Resource |
| | | private PointsMerchandiseService pointsMerchandiseService; |
| | | |
| | | |
| | | |
| | | |
| | | @PostMapping("/base/coupon/vipDetail") |
| | | @ResponseBody |
| | | List<VipDetailVO> vipDetail(@RequestBody VipDetailDto vipDetailDto){ |
| | | List<PointsMerchandise> pointsMerchandiseList = pointsMerchandiseService.list(); |
| | | List<VipDetailVO> vipDetailVOS = new ArrayList<>(); |
| | | List<VipDetail> list = vipDetailService.lambdaQuery() |
| | | .in(vipDetailDto.getVipIds()!=null&&!vipDetailDto.getVipIds().isEmpty(), VipDetail::getVipId, vipDetailDto.getVipIds()) |
| | | .in(vipDetailDto.getUserIds()!=null&&!vipDetailDto.getUserIds().isEmpty(), VipDetail::getAppUserId, vipDetailDto.getUserIds()) |
| | | .in(vipDetailDto.getStoreIds()!=null&&!vipDetailDto.getStoreIds().isEmpty(), VipDetail::getUseStoreId, vipDetailDto.getStoreIds()) |
| | | .ge(StringUtils.hasLength(vipDetailDto.getStartTime()), VipDetail::getInsertTime, vipDetailDto.getStartTime()) |
| | | .le(StringUtils.hasLength(vipDetailDto.getEndTime()), VipDetail::getInsertTime, vipDetailDto.getEndTime()) |
| | | .ge(StringUtils.hasLength(vipDetailDto.getUseStartTime()), VipDetail::getUseTime, vipDetailDto.getUseStartTime()) |
| | | .le(StringUtils.hasLength(vipDetailDto.getUseEndTime()), VipDetail::getUseTime, vipDetailDto.getUseEndTime()) |
| | | .eq(vipDetailDto.getOperatorId() != null, VipDetail::getOperatorId, vipDetailDto.getOperatorId()) |
| | | .eq(vipDetailDto.getType() != null, VipDetail::getType, vipDetailDto.getType()) |
| | | .eq(vipDetailDto.getStatus() != null, VipDetail::getStatus, vipDetailDto.getStatus()).list(); |
| | | |
| | | // 使用 Stream + 手动拷贝提升性能和可读性(或使用 MapStruct) |
| | | vipDetailVOS = list.stream().map(vipDetail -> { |
| | | VipDetailVO vo = new VipDetailVO(); |
| | | BeanUtils.copyProperties(vo, vipDetail); // 注意参数顺序是否正确 |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | | List<Coupon> coupons = couponService.list(); |
| | | for (VipDetailVO vipDetailVO : vipDetailVOS) { |
| | | if (vipDetailVO.getType()==1){ |
| | | Coupon coupon = coupons.stream().filter(coupon1 -> coupon1.getId().equals(vipDetailVO.getCouponId())).findFirst().orElse(null); |
| | | if (coupon!=null){ |
| | | vipDetailVO.setTicketName(coupon.getName()); |
| | | vipDetailVO.setGoodsName(coupon.getName()); |
| | | if (coupon.getType()==4){ |
| | | // 查询抵扣商品 |
| | | PointsMerchandise pointsMerchandise1 = pointsMerchandiseList.stream().filter(pointsMerchandise -> pointsMerchandise.getId().equals(coupon.getGoodsId())) |
| | | .findFirst().orElse(null); |
| | | if (pointsMerchandise1 != null){ |
| | | vipDetailVO.setGoodsName(pointsMerchandise1.getName()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | return vipDetailVOS; |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | @PostMapping("/api/coupon/queryCouponList") |
| | | @ApiOperation(value = "获取优惠券列表", tags = {"APP-成为会员", ""}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "1=积分购买,2=注册赠送", name = "distributionMethod", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "vipId", name = "vipId", dataType = "int", required = true), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<List<CouponListVo>> queryCouponList(Integer distributionMethod) { |
| | | if (null == distributionMethod) { |
| | | return ResultUtil.paranErr("distributionMethod"); |
| | | public ResultUtil<VipCouponTicketListResp> queryCouponList(Integer vipId) { |
| | | if (null == vipId) { |
| | | return ResultUtil.paranErr("vipId"); |
| | | } |
| | | VipCouponTicketListResp vipCouponTicketListResp = new VipCouponTicketListResp(); |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if (null == uid) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | List<CouponListVo> listVos = couponService.queryCouponList(uid, distributionMethod); |
| | | return ResultUtil.success(listVos); |
| | | List<Vip> vips = vipClient.listAll(); |
| | | Vip vip = vips.stream().filter(e -> e.getId().equals(vipId)).findFirst().orElse(null); |
| | | if (vip!=null){ |
| | | List<CouponVipResp> couponVipResps = new ArrayList<>(); |
| | | List<TicketVipResp> ticketVipResps = new ArrayList<>(); |
| | | List<CouponVipResp> couponList = vip.getCouponList(); |
| | | for (CouponVipResp couponVipResp : couponList) { |
| | | for (Integer i = 0; i < couponVipResp.getCount(); i++) { |
| | | couponVipResps.add(couponVipResp); |
| | | } |
| | | } |
| | | List<TicketVipResp> ticketList = vip.getTicketList(); |
| | | for (TicketVipResp ticketVipResp : ticketList) { |
| | | for (Integer i = 0; i < ticketVipResp.getCount(); i++) { |
| | | ticketVipResps.add(ticketVipResp); |
| | | } |
| | | } |
| | | vipCouponTicketListResp.setCouponVipRespList(couponVipResps); |
| | | vipCouponTicketListResp.setTicketVipRespList(ticketVipResps); |
| | | return ResultUtil.success(vipCouponTicketListResp); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtil.success(); |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | |
| | | stringObjectHashMap.put("experienceName", dataVo.getExperience()); |
| | | coupon.setContent(gson.toJson(stringObjectHashMap)); |
| | | break; |
| | | case 4: |
| | | coupon.setGoodsId(dataVo.getGoodsId()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | List<CouponCity> list = cityService.list(new LambdaQueryWrapper<CouponCity>()); |
| | | return list; |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/coupon/queryAllPointGoods") |
| | | public List<PointsMerchandise> queryAllPointGoods(){ |
| | | List<PointsMerchandise> pointsMerchandiseList = pointsMerchandiseService.list(); |
| | | return pointsMerchandiseList; |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/base/coupon/queryStore") |
| | | public List<Integer> queryStore(@RequestBody Integer id) { |