| | |
| | | } |
| | | return detailsVo; |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private UserCouponService userCouponService; |
| | | @PostMapping("/base/pointMerchars/getGoodDetails") |
| | | public ProductDetailsVo getGoodDetailsWithId(@RequestBody ProductDetailRequest detailRequest){ |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | |
| | | detailsVo.setBelongsScope(coupon.getUserPopulation()); |
| | | // int couponNums = upmseService.count(new QueryWrapper<UserPointsMerchandise>() |
| | | // .eq("pointsMerchandiseId",merchandise.getId() )); |
| | | detailsVo.setRedeemedNum(coupon.getPickUpQuantity()); |
| | | detailsVo.setResidueNum(Math.max(coupon.getQuantityIssued() - coupon.getPickUpQuantity(), 0)); |
| | | |
| | | |
| | | |
| | | int couponCounts = userCouponService.count(new QueryWrapper<UserCoupon>().eq("couponId", coupon.getId())); |
| | | // detailsVo.setRedeemedNum(coupon.getPickUpQuantity()); |
| | | detailsVo.setRedeemedNum(couponCounts); |
| | | |
| | | detailsVo.setResidueNum(Math.max(coupon.getQuantityIssued() - couponCounts, 0)); |
| | | |
| | | detailsVo.setPerLimit(coupon.getPickUpQuantity()); |
| | | detailsVo.setExchangeType(coupon.getRedemptionMethod()); |
| | | if (coupon.getRedemptionMethod() == 1){ |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | if (merchandise.getCardType()==1){ |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(pointsMerchandise.getInsertTime()); |
| | | calendar.add(Calendar.DAY_OF_MONTH, 1); |
| | | Date end = calendar.getTime(); |
| | | String startDate = dateFormat.format(pointsMerchandise.getInsertTime()); |
| | | String endDate = dateFormat.format(end); |
| | | detailsResponse.setStartTime(startDate); |
| | | detailsResponse.setEndTime(endDate); |
| | | |
| | | Date now = new Date(); |
| | | Calendar cal1 = Calendar.getInstance(); |
| | | cal1.setTime(pointsMerchandise.getInsertTime()); |
| | | |
| | | Calendar cal2 = Calendar.getInstance(); |
| | | cal2.setTime(now); |
| | | |
| | | // Compare the year, month, and day of the two Calendar instances |
| | | boolean isSameDate = cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && |
| | | cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH) && |
| | | cal1.get(Calendar.DAY_OF_MONTH) == cal2.get(Calendar.DAY_OF_MONTH); |
| | | |
| | | // Print the result |
| | | if (isSameDate) { |
| | | detailsResponse.setUseStatus(3); |
| | | } else { |
| | | System.out.println("The two dates do not have the same date."); |
| | | } |
| | | |
| | | |
| | | } else if (merchandise.getCardType()==2) { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(pointsMerchandise.getInsertTime()); |
| | | calendar.add(Calendar.DAY_OF_MONTH, 31); |
| | | Date end = calendar.getTime(); |
| | | String startDate = dateFormat.format(pointsMerchandise.getInsertTime()); |
| | | String endDate = dateFormat.format(end); |
| | | detailsResponse.setStartTime(startDate); |
| | | detailsResponse.setEndTime(endDate); |
| | | |
| | | Date now = new Date(); |
| | | if (now.after(end)){ |
| | | detailsResponse.setUseStatus(3); |
| | | } |
| | | |
| | | } else if (merchandise.getCardType()==3) { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(pointsMerchandise.getInsertTime()); |
| | | calendar.add(Calendar.DAY_OF_MONTH, 93); |
| | | Date end = calendar.getTime(); |
| | | String startDate = dateFormat.format(pointsMerchandise.getInsertTime()); |
| | | String endDate = dateFormat.format(end); |
| | | detailsResponse.setStartTime(startDate); |
| | | detailsResponse.setEndTime(endDate); |
| | | |
| | | Date now = new Date(); |
| | | if (now.after(end)){ |
| | | detailsResponse.setUseStatus(3); |
| | | } |
| | | |
| | | } else if (merchandise.getCardType()==4) { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(pointsMerchandise.getInsertTime()); |
| | | calendar.add(Calendar.DAY_OF_MONTH, 365); |
| | | Date end = calendar.getTime(); |
| | | String startDate = dateFormat.format(pointsMerchandise.getInsertTime()); |
| | | String endDate = dateFormat.format(end); |
| | | detailsResponse.setStartTime(startDate); |
| | | detailsResponse.setEndTime(endDate); |
| | | |
| | | Date now = new Date(); |
| | | if (now.after(end)){ |
| | | detailsResponse.setUseStatus(3); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | responses.add(detailsResponse); |
| | | } |