无关风月
7 小时以前 b1fb83530b7105e4aa73e4101727dea945eb01c2
cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java
@@ -20,6 +20,7 @@
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;
@@ -68,9 +69,12 @@
    @Autowired
    private TokenUtil tokenUtil;
    @Autowired
    private VipClient vipClient;
    @Autowired
    private UserCouponService ucService;
    @Autowired
    private GDMapGeocodingUtil gdMapGeocodingUtil;
@@ -121,12 +125,15 @@
                .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();
                .eq(vipDetailDto.getStatus() != null, VipDetail::getStatus, vipDetailDto.getStatus())
                .orderByDesc(VipDetail::getInsertTime)
                .list();
        // 使用 Stream + 手动拷贝提升性能和可读性(或使用 MapStruct)
        vipDetailVOS = list.stream().map(vipDetail -> {
            VipDetailVO vo = new VipDetailVO();
            BeanUtils.copyProperties(vo, vipDetail); // 注意参数顺序是否正确
            BeanUtils.copyProperties(vipDetail, vo); // 注意参数顺序是否正确
            return vo;
        }).collect(Collectors.toList());
        List<Coupon> coupons = couponService.list();
@@ -195,24 +202,45 @@
    @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();
    }
@@ -894,7 +922,12 @@
        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) {
@@ -917,5 +950,32 @@
    @PostMapping("/base/coupon/updateType")
    public void updateType(@RequestBody Long id) {
        couponService.updateType(id);
        UserCoupon userCoupon = userCouponService.getById(id);
        if (userCoupon.getIsVipGrant()!=null&& userCoupon.getIsVipGrant()==1){
            VipDetail vipDetailServiceById = vipDetailService.getById(userCoupon.getVipDetailId());
            vipDetailServiceById.setUseTime(new Date());
            vipDetailServiceById.setStatus(2);
            vipDetailServiceById.setOperatorId(0);
            vipDetailService.updateById(vipDetailServiceById);
        }
    }
    @GetMapping("/base/coupon/updateTypeOther/{id}/{operatorId}/{storeId}/{siteId}")
    void updateTypeOther(@PathVariable("id")Long id,@PathVariable("operatorId")Integer operatorId,
                         @PathVariable("storeId")Integer storeId,@PathVariable("siteId")Integer siteId){
        couponService.updateType(id);
        UserCoupon userCoupon = userCouponService.getById(id);
        if (userCoupon.getIsVipGrant()!=null&& userCoupon.getIsVipGrant()==1){
            VipDetail vipDetailServiceById = vipDetailService.getById(userCoupon.getVipDetailId());
            vipDetailServiceById.setUseTime(new Date());
            vipDetailServiceById.setStatus(2);
            vipDetailServiceById.setOperatorId(operatorId);
            vipDetailServiceById.setUseStoreId(storeId);
            if (siteId!=0){
                vipDetailServiceById.setUseSiteId(siteId);
            }
            vipDetailService.updateById(vipDetailServiceById);
        }
    }
}