nickchange
2023-11-02 2470d3215286123438478f045b43df9f352fa16b
cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java
@@ -690,6 +690,10 @@
    }
    @Autowired
    private ICouponService couponService;
    @ResponseBody
    @PostMapping("/base/pointMerchars/getDetailsOfExchange")
    public ExchangeDetailsVo getIntegralExchangeDetails(@RequestBody Integer appUserId){
@@ -698,6 +702,11 @@
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        List<UserPointsMerchandise> pointsMerchandises = upmseService.list(new QueryWrapper<UserPointsMerchandise>()
                .eq("userId",appUserId ));
        List<UserCoupon> userCoupons = userCouponService.list(new QueryWrapper<UserCoupon>().eq("userId", appUserId));
        if (pointsMerchandises.size() > 0 ){
            for (UserPointsMerchandise pointsMerchandise : pointsMerchandises) {
                PointsMerchandise merchandise = pmdsService.getById(pointsMerchandise.getPointsMerchandiseId());
@@ -843,6 +852,35 @@
                responses.add(detailsResponse);
            }
            detailsVo.setDetailsResponses(responses);
        }
        if (userCoupons.size()>0){
            for (UserCoupon userCoupon : userCoupons) {
                Coupon c = couponService.getById(userCoupon.getCouponId());
                if (c==null){
                    continue;
                }
                ExchangeDetailsResponse detailsResponse = new ExchangeDetailsResponse();
                detailsResponse.setDetailsId(Long.valueOf(c.getId()));
                detailsResponse.setGoodName(c.getName());
                if (c.getRedemptionMethod() == 1){
                    detailsResponse.setExchangeType(1);
                    detailsResponse.setIntegral(c.getIntegral().intValue());
                }else {
                    detailsResponse.setExchangeType(2);
                    detailsResponse.setIntegral(c.getIntegral().intValue());
                    detailsResponse.setCash(c.getCash());
                }
                detailsResponse.setStartTime(simpleDateFormat.format(c.getStartTime()));
                detailsResponse.setEndTime(simpleDateFormat.format(c.getEndTime()));
                detailsResponse.setUseStatus(userCoupon.getStatus() == 1 ? 2 : 1);
                detailsResponse.setGoodType(4);
                responses.add(detailsResponse);
            }
            detailsVo.setDetailsResponses(responses);
        }
        return detailsVo;
    }
@@ -1043,6 +1081,67 @@
                    break;
            }
            detailsVo.setContents(pmdsServiceById.getRedemptionInstructions());
        }else {
            Coupon coupon = iCouponService.getById(speMercharsId);
            detailsVo.setDetailsId(Long.valueOf(coupon.getId()));
            List<String> list3 = new ArrayList<>();
            list3.add(ToolUtil.isEmpty(coupon.getCover()) ? "" : coupon.getCover());
            if (ToolUtil.isNotEmpty(coupon.getProductImages())){
                list3.addAll(Arrays.asList(StrUtils.splitStr2StrArr(coupon.getProductImages(), ",")));
            }
            detailsVo.setPics(list3);
            Collections.sort(detailsVo.getPics(), (s1, s2) -> {
                if (s1.equals(coupon.getCover())) {
                    return -1; // s1排在前面
                } else if (s2.equals(coupon.getCover())) {
                    return 1; // s2排在前面
                } else {
                    return 0; // 保持原顺序
                }
            });
            detailsVo.setGoodName(coupon.getName());
//            detailsVo.setBelongsScope(coupon.getUserPopulation());
//                int couponNums = upmseService.count(new QueryWrapper<UserPointsMerchandise>()
//                        .eq("pointsMerchandiseId",merchandise.getId() ));
            int couponCounts = userCouponService.count(new QueryWrapper<UserCoupon>().eq("couponId", coupon.getId()));
//                detailsVo.setRedeemedNum(coupon.getPickUpQuantity());
//            detailsVo.setRedeemedNum(couponCounts);
//            detailsVo.setResidueNum(Math.max(coupon.getQuantityIssued() - couponCounts, 0));
//            detailsVo.setPerLimit(coupon.getPickUpQuantity());
            detailsVo.setExchangeType(coupon.getRedemptionMethod());
            if (coupon.getRedemptionMethod() == 1){
                detailsVo.setIntegral(coupon.getIntegral().intValue());
            }else {
                detailsVo.setIntegral(coupon.getIntegral().intValue());
                detailsVo.setCash(coupon.getCash());
            }
//            if (coupon.getUseScope() == 1){
//                detailsVo.setExchangeAddrType(1);
//                detailsVo.setBelongs("全国通用");
//            }else if (coupon.getUseScope() == 2){
//                detailsVo.setExchangeAddrType(2);
//                List<CouponCity> list = ccityService.list(new LambdaQueryWrapper<CouponCity>()
//                        .eq(CouponCity::getCouponId, coupon.getId()));
//                if (list.size() > 0){
//                    detailsVo.setBelongs(list.get(0).getProvince()+"|"+list.get(0).getCity() + "用户可用");
//                }
//            }else {
//                detailsVo.setExchangeAddrType(3);
//                List<CouponStore> list = cstoreService.list(new QueryWrapper<CouponStore>()
//                        .eq("couponId",coupon.getId() ));
//                StoreDetailOfCourse courseOfStore = stoClient.getCourseOfStore(list.get(0).getStoreId());
//                detailsVo.setBelongs(courseOfStore.getStoreName()+"可用");
//            }
//            detailsVo.setStartTime(format.format(coupon.getStartTime()));
//            detailsVo.setEndTime(format.format(coupon.getEndTime()));
            detailsVo.setContents(coupon.getIllustrate());
            detailsVo.setGoodType(4);
        }
        return detailsVo;
    }
@@ -1055,9 +1154,10 @@
    @PostMapping("/base/pointMerchars/saveDetailsUserPointMercase")
    public void saveDetailsUserPointMercase(@RequestBody UserPointsMerchandise merchandise){
    public Long saveDetailsUserPointMercase(@RequestBody UserPointsMerchandise merchandise){
        merchandise.setInsertTime(new Date());
        upmseService.save(merchandise);
        return merchandise.getId();
    }