phpcjl
2024-12-04 49ca7e1625c1ede03fc8f1b1b52e6f0ed7cc1ecd
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java
@@ -99,7 +99,7 @@
        if (data==null){
            return  R.fail("当前优惠券不存在,请刷新后重试");
        }
        if (data.getSendType()!=1&&byId.getLavePoint().compareTo(data.getNeedPoint())==-1){
        if (data.getSendType()!=1&&byId.getLavePoint().compareTo(data.getNeedPoint().intValue())==-1){
           return  R.fail("当前积分不足,兑换失败");
        }
        //检验发放时间
@@ -112,12 +112,12 @@
            UserPoint userPoint = new UserPoint();
            userPoint.setType(4);
            userPoint.setHistoricalPoint(byId.getLavePoint());
            userPoint.setVariablePoint(data.getNeedPoint());
            userPoint.setVariablePoint(data.getNeedPoint().intValue());
            userPoint.setAppUserId(userid);
            userPoint.setObjectId(Long.valueOf(data.getId()));
            userPointService.save(userPoint);
            //扣除积分
            byId.setLavePoint(byId.getLavePoint().subtract(userPoint.getVariablePoint()));
            byId.setLavePoint(byId.getLavePoint() - userPoint.getVariablePoint());
            appUserService.updateById(byId);
        }
        //增加优惠券记录,根据时间类型设置开始结束时间
@@ -147,9 +147,24 @@
   @ResponseBody
   @PostMapping("/getPaymentUserCoupon")
   public R<List<PaymentUserCouponVo>> getPaymentUserCoupon(@RequestBody PaymentUserCoupon paymentUserCoupon){
      List<PaymentUserCouponVo> userCoupon = userCouponService.getUserCoupon(paymentUserCoupon.getUserId(), paymentUserCoupon.getOrderMoney(), paymentUserCoupon.getType());
      List<PaymentUserCouponVo> userCoupon = userCouponService.getUserCoupon(paymentUserCoupon.getUserId(), paymentUserCoupon.getType());
      return R.ok(userCoupon);
   }
    /**
     * 根据用户优惠券id获取优惠券详情
     * @param userCouponId
     * @return
     */
    @ResponseBody
    @PostMapping("/getCouponInfo")
    public R<CouponInfoVo> getCouponInfo(@RequestParam("userCouponId") Long userCouponId){
        UserCoupon userCoupon = userCouponService.getById(userCouponId);
        CouponInfo data = couponClient.detail(userCoupon.getCouponId()).getData();
        CouponInfoVo couponInfoVo = new CouponInfoVo();
        BeanUtils.copyProperties(data, couponInfoVo);
        return R.ok(couponInfoVo);
    }
}