| | |
| | | private TCouponReceiveService couponReceiveService; |
| | | @Autowired |
| | | private LoginInfoUtil loginInfoUtil; |
| | | @ApiOperation(value = "扫码获取优惠券") |
| | | @GetMapping(value = "/scanCode") |
| | | public ApiResult scanCode(Integer id) { |
| | | TCoupon coupon = couponService.getById(id); |
| | | if (coupon==null){ |
| | | return ApiResult.failed("优惠券已失效"); |
| | | } |
| | | TCouponReceive tCouponReceive = new TCouponReceive(); |
| | | tCouponReceive.setCouponId(coupon.getId()); |
| | | tCouponReceive.setUserId(loginInfoUtil.getUserId()); |
| | | tCouponReceive.setType(4); |
| | | tCouponReceive.setAmount(coupon.getAmount()); |
| | | tCouponReceive.setStoreId(coupon.getStoreId()); |
| | | if (coupon.getTime()!=0){ |
| | | tCouponReceive.setEndTime(LocalDateTime.now().plusDays(coupon.getTime())); |
| | | } |
| | | tCouponReceive.setAmountCondition(coupon.getAmountCondition()); |
| | | tCouponReceive.setStatus(1); |
| | | couponReceiveService.save(tCouponReceive); |
| | | return ApiResult.success(); |
| | | } |
| | | // @ApiOperation(value = "扫码获取优惠券") |
| | | // @GetMapping(value = "/scanCode") |
| | | // public ApiResult scanCode(Integer id) { |
| | | // TCoupon coupon = couponService.getById(id); |
| | | // if (coupon==null){ |
| | | // return ApiResult.failed("优惠券已失效"); |
| | | // } |
| | | // TCouponReceive tCouponReceive = new TCouponReceive(); |
| | | // tCouponReceive.setCouponId(coupon.getId()); |
| | | // tCouponReceive.setUserId(loginInfoUtil.getUserId()); |
| | | // tCouponReceive.setType(4); |
| | | // tCouponReceive.setAmount(coupon.getAmount()); |
| | | // tCouponReceive.setStoreId(coupon.getStoreId()); |
| | | // if (coupon.getTime()!=0){ |
| | | // tCouponReceive.setEndTime(LocalDateTime.now().plusDays(coupon.getTime())); |
| | | // } |
| | | // tCouponReceive.setAmountCondition(coupon.getAmountCondition()); |
| | | // tCouponReceive.setStatus(1); |
| | | // couponReceiveService.save(tCouponReceive); |
| | | // return ApiResult.success(); |
| | | // } |
| | | } |
| | | |