| | |
| | | @PostMapping("/userCoupon/queryUserCouponById") |
| | | public UserCoupon queryUserCouponById(@RequestBody QueryUserCouponByIdAndUserId userCouponByIdAndUserId){ |
| | | try { |
| | | UserCoupon userCoupon = userCouponService.getOne(new LambdaQueryWrapper<UserCoupon>().eq(UserCoupon::getCouponId,userCouponByIdAndUserId.getId()).eq(UserCoupon::getUserId,userCouponByIdAndUserId.getUserId())); |
| | | UserCoupon userCoupon = userCouponService.getOne(new LambdaQueryWrapper<UserCoupon>().eq(UserCoupon::getId,userCouponByIdAndUserId.getId()).eq(UserCoupon::getUserId,userCouponByIdAndUserId.getUserId())); |
| | | return userCoupon; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/userCoupon/queryUserCouponById1") |
| | | public UserCoupon queryUserCouponById1(@RequestBody Long id){ |
| | | try { |
| | | UserCoupon userCoupon = userCouponService.getOne(new LambdaQueryWrapper<UserCoupon>().eq(UserCoupon::getId,id)); |
| | | return userCoupon; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | @Autowired |
| | | private ICouponService couponService; |
| | | |
| | | @PostMapping("/userCoupon/edit") |
| | | public void edit(@RequestBody UserCoupon userCoupon) { |
| | | userCoupon.setUserId(null); |
| | | userCouponService.updateById(userCoupon); |
| | | |
| | | } |
| | | |
| | | @PostMapping("/userCoupon/sendUserCoupon") |
| | | public void sendUserCoupon(@RequestBody SendCouponReq sendCouponReq){ |
| | | try { |
| | | String couponIds = sendCouponReq.getCouponIds(); |
| | | for (String s : couponIds.split(",")) { |
| | | Coupon coupon = couponService.getById(s); |
| | | if (new Date().before(coupon.getStartTime())&&new Date().after(coupon.getEndTime())){ |
| | | continue; |
| | | } |
| | | //查询该优惠卷的数量够不够 |
| | | List<Integer> queryIds = new ArrayList<>(); |
| | | queryIds.add(coupon.getId()); |
| | | int counts = userCouponService.count(new QueryWrapper<UserCoupon>().eq("couponId", s)); |
| | | if (coupon.getQuantityIssued()<=counts){ |
| | | continue; |
| | | } |
| | | |
| | | UserCoupon userCoupon = new UserCoupon(); |
| | | userCoupon.setCouponId(Integer.valueOf(s)); |
| | | userCoupon.setUserId(sendCouponReq.getUserId()); |
| | |
| | | @PostMapping("/userCoupon/updateUserCoupon") |
| | | public void updateUserCoupon(@RequestBody UserCoupon userCoupon){ |
| | | try { |
| | | userCoupon.setUserId(null); |
| | | userCouponService.updateById(userCoupon); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | if (list.size() > 0 ){ |
| | | storeIds = list.stream().map(CouponStore::getStoreId).collect(Collectors.toList()); |
| | | } |
| | | if(storeIds.size()==0){ |
| | | storeIds.add(-1); |
| | | } |
| | | return storeIds; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/userCoupon/queryCounts") |
| | | public Integer queryCounts(@RequestBody List<Integer> queryIds){ |
| | | return userCouponService.count(new QueryWrapper<UserCoupon>().eq("couponId",queryIds.get(0))); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/userCoupon/queryCounts1") |
| | | public Integer queryCounts1(@RequestBody List<Integer> queryIds){ |
| | | return userCouponService.count(new QueryWrapper<UserCoupon>().eq("couponId",queryIds.get(0)).eq("userId",queryIds.get(1))); |
| | | |
| | | |
| | | } |
| | | |
| | | } |