无关风月
2025-01-16 ec7528bb6cc65d3bce1c33d59e48ea5bc81c7782
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java
@@ -22,6 +22,7 @@
import com.ruoyi.other.api.domain.PointSetting;
import com.ruoyi.other.api.feignClient.GoodsClient;
import com.ruoyi.other.api.feignClient.PointSettingClient;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -97,7 +98,9 @@
                    List<Goods> data1 = goodsClient.getAllGoods().getData();
                    List<String> collect = data1.stream().map(Goods::getName).collect(Collectors.toList());
                    goodNames.addAll(collect);
                }else{
                }else if(StringUtils.isEmpty(data.getForGoodIds())){
                    goodNames.addAll(JSON.parseArray(data.getGoodsNameJson(), String.class));
                }else {
                    String[] split = vo.getForGoodIds().split(",");
                    R<List<Goods>> goodsById = goodsClient.getGoodsById(split);
                    if (goodsById.getData()!=null){
@@ -105,8 +108,8 @@
                            goodNames.add(datum.getName());
                        }
                    }
                    vo.setGoodNames(goodNames);
                }
                vo.setGoodNames(goodNames);
            }
            record.setCouponInfoVo(vo);
@@ -131,19 +134,34 @@
    @ApiOperation(value = "已领取列表", tags = {"管理后台-优惠劵"})
    public R<Page<UserCoupon>> list1(@RequestParam Integer pageNum,
                                     @RequestParam Integer pageSize,
                                     String userName,
                                     @ApiParam("1未使用2已使用3已过期") Integer status,
                                     String phone,
                                     Integer id) {
        AppUser appUser1 = appUserService.getOne(new LambdaQueryWrapper<AppUser>()
                .eq(AppUser::getPhone, phone));
        LambdaQueryWrapper<AppUser> queryWrapper = new LambdaQueryWrapper<>();
        Long appUserId = appUser1.getId();
        if (!StringUtils.isEmpty(phone)) {
            queryWrapper.like(AppUser::getPhone, phone);
        }
        if (!StringUtils.isEmpty(userName)) {
            queryWrapper.like(AppUser::getName, userName);
        }
        List<AppUser> appUserList = appUserService.list(queryWrapper);
        if (CollectionUtils.isEmpty(appUserList)) {
            return R.ok(Page.of(pageNum, pageSize));
        }
        List<Long> appUserIds = appUserList.stream().map(AppUser::getId).distinct().collect(Collectors.toList());
        Page<UserCoupon> page = userCouponService.lambdaQuery()
                .isNull(status!=null&&(status==1||status==3),UserCoupon::getUseTime)
                .isNotNull(status!=null&&status==2,UserCoupon::getUseTime)
                .eq(UserCoupon::getCouponId, id)
                .eq(appUserId != null,UserCoupon::getAppUserId, appUserId)
                .in(!CollectionUtils.isEmpty(appUserIds),UserCoupon::getAppUserId, appUserIds)
                .lt(status!=null&&status==3,UserCoupon::getEndTime, LocalDateTime.now()).page(Page.of(pageNum-1, pageSize));
        for (UserCoupon record : page.getRecords()) {
            record.setIdStr(record.getId().toString());
@@ -226,7 +244,7 @@
            appUserService.updateById(byId);
            
            UserPoint userPoint = new UserPoint();
            userPoint.setType(11);
            userPoint.setType(15);
            userPoint.setHistoricalPoint(lavePoint);
            userPoint.setVariablePoint(point);
            userPoint.setBalance(byId.getLavePoint());
@@ -369,5 +387,18 @@
        userCouponService.updateById(userCoupon);
        return R.ok();
    }
    /**
     * 编辑用户优惠券使用时间
     * @param userCoupon
     * @return
     */
    @PostMapping("/editReturnUse")
    public R editReturnUse(@RequestBody UserCoupon userCoupon){
        userCouponService.update(new LambdaUpdateWrapper<UserCoupon>().eq(UserCoupon::getId, userCoupon.getId())
                .set(UserCoupon::getUseTime, userCoupon.getUseTime()));
        return R.ok();
    }
}