| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private UserConponClient userConponClient; |
| | | |
| | | @Autowired |
| | | private TAppUserService appUserService; |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public ResultUtil productRedemptionOperation(Integer userIdFormRedis, GoodsExchangeVo exchangeType) { |
| | | System.out.println("exchangeType:--->"); |
| | | |
| | | //如果是兑换优惠卷 |
| | | if (exchangeType.getGoodsType()==4){ |
| | | //查询优惠卷 |
| | | Coupon coupon = userConponClient.queryCouponById(exchangeType.getGoodId()); |
| | | //查询该优惠卷的数量够不够 |
| | | List<Integer> queryIds = new ArrayList<>(); |
| | | queryIds.add(coupon.getId()); |
| | | queryIds.add(userIdFormRedis); |
| | | Integer counts = userConponClient.queryCounts(queryIds); |
| | | if (coupon.getQuantityIssued()-counts == 0){ |
| | | return new ResultUtil(0,"当前数量不足"); |
| | | } |
| | | //查询该用户是否超出限领数量 |
| | | Integer usercounts = userConponClient.queryCounts1(queryIds); |
| | | |
| | | if (usercounts == coupon.getPickUpQuantity()){ |
| | | return new ResultUtil<>(0,"限领数量已达最大"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // userConponClient.queryCouponById(exchangeType.getGoodId()); |
| | | UserCoupon userCoupon = new UserCoupon(); |
| | | userCoupon.setCouponId(exchangeType.getGoodId()); |
| | | userCoupon.setUserId(userIdFormRedis); |
| | | userCoupon.setStatus(1); |
| | | userCoupon.setInsertTime(new Date()); |
| | | userConponClient.insertToAppuserCoupon(userCoupon); |
| | | |
| | | |
| | | //扣积分 |
| | | TAppUser user = appUserService.getById(userIdFormRedis); |
| | | if (user.getIntegral()<coupon.getIntegral().intValue()){ |
| | | return new ResultUtil<>(0,"当前用户积分不足"); |
| | | } |
| | | |
| | | user.setIntegral(user.getIntegral()-coupon.getIntegral().intValue()); |
| | | |
| | | appUserService.updateById(user); |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | System.out.println(exchangeType); |
| | | try { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |