| | |
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void insertUserCoupon(Long uid, String couponType, String source)
|
| | | public void insertUserCoupon(Long uid, String couponType, String source, BigDecimal percent)
|
| | | throws UserSystemCouponException, Exception {
|
| | |
|
| | | if (couponType == null || uid == null) {
|
| | |
| | | coupon = systemCouponService.getCouponByType(couponType);
|
| | | } else if (couponType.equals(CouponTypeEnum.rebatePercentCoupon.name())) {
|
| | | // 随机奖励券
|
| | | randomRewardCoupon(1, uid, source);
|
| | | return;
|
| | | if (percent == null || percent.compareTo(new BigDecimal(0)) > 0) {
|
| | | randomRewardCoupon(1, uid, source);
|
| | | return;
|
| | | } else {
|
| | | coupon = systemCouponService.getCouponByTypeAndPercent(couponType, percent);
|
| | | }
|
| | | }
|
| | |
|
| | | if (coupon == null) {
|
| | |
| | | }
|
| | | } else if (UserSystemCoupon.STATE_IN_USE == state && give) {
|
| | | userCouponVO.setCouponEffect("赠送中");
|
| | | userCouponVO.setCouponRule(systemCoupon.getRemark());
|
| | | String tips = null;
|
| | | if (CouponTypeEnum.freeCouponGive == type) {
|
| | | userCouponVO.setState(UserSystemCoupon.STATE_GIVE_IN);
|
| | |
| | | tips = tips.replace("{APP名称}", projectChineseName);
|
| | | }
|
| | | tips = tips.replace("{口令}", tokenRecord.getToken()).replace("{下载链接}", configService.get("app_down_link"));
|
| | | userCouponVO.setGiveTips(tips);
|
| | | }
|
| | |
|
| | | Date endTimeGive = record.getEndTime();
|
| | |
| | | remainDays.put("fontColor", "#F14242");
|
| | | userCouponVO.setRemainDays(remainDays);
|
| | | }
|
| | | }
|
| | | } else {
|
| | | tips = "";
|
| | | }
|
| | | userCouponVO.setGiveTips(tips);
|
| | | } else if (UserSystemCoupon.STATE_END_USE == state) {
|
| | | if (give && CouponTypeEnum.freeCouponGive == type) {
|
| | | } |
| | | } |
| | | |
| | | } else if (give && UserSystemCoupon.STATE_END_USE == state) {
|
| | | userCouponVO.setCouponRule(systemCoupon.getRemark());
|
| | | if (CouponTypeEnum.freeCouponGive == type) {
|
| | | userCouponVO.setState(UserSystemCoupon.STATE_GIVE_END);
|
| | | }
|
| | |
|
| | | if (give && CouponTypeEnum.rebatePercentCoupon == type) {
|
| | | if (CouponTypeEnum.rebatePercentCoupon == type) {
|
| | | userCouponVO.setState(UserSystemCoupon.STATE_GIVE_END);
|
| | | }
|
| | | }else if (give && UserSystemCoupon.STATE_OVERDUE == state) {
|
| | | userCouponVO.setCouponRule(systemCoupon.getRemark());
|
| | | }
|
| | | userCouponVO.setJumpBtn(jumpBtn);
|
| | | }
|
| | |
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public String giveCoupon(Long uid, Long id) throws UserSystemCouponException {
|
| | | public UserSystemCouponVO giveCoupon(Long uid, Long id) throws UserSystemCouponException {
|
| | | UserSystemCoupon userSystemCoupon = userSystemCouponMapper.selectByPrimaryKey(id);
|
| | | if (userSystemCoupon == null)
|
| | | throw new UserSystemCouponException(1, "该券已不存在");
|
| | |
| | | throw new UserSystemCouponException(1, "该券已失效");
|
| | |
|
| | | Integer state = userSystemCoupon.getState();
|
| | | if (state == UserSystemCoupon.STATE_OVERDUE) |
| | | throw new UserSystemCouponException(1, "该券已过期");
|
| | | |
| | | if (state == UserSystemCoupon.STATE_END_USE) |
| | | throw new UserSystemCouponException(1, "该券使用/赠送成功");
|
| | | if (state != UserSystemCoupon.STATE_CAN_USE) |
| | | throw new UserSystemCouponException(1, "该券已被使用或赠送");
|
| | |
|
| | | CouponTypeEnum type = systemCoupon.getType();
|
| | | if (type != CouponTypeEnum.freeCouponGive && type != CouponTypeEnum.rebatePercentCoupon )
|
| | |
| | | tips = tips.replace("{APP名称}", projectChineseName);
|
| | | }
|
| | | tips = tips.replace("{口令}", tokenRecord.getToken()).replace("{下载链接}", configService.get("app_down_link"));
|
| | | return tips;
|
| | | |
| | | return createUserCouponVOo(userSystemCoupon, systemCoupon, record, tips);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | tips = tips.replace("{APP名称}", projectChineseName);
|
| | | }
|
| | | tips = tips.replace("{口令}", token).replace("{下载链接}", configService.get("app_down_link"));
|
| | | return tips;
|
| | | |
| | | return createUserCouponVOo(userSystemCoupon, systemCoupon, giveRecord, tips);
|
| | | }
|
| | | |
| | | |
| | | private UserSystemCouponVO createUserCouponVOo(UserSystemCoupon userSystemCoupon, SystemCoupon systemCoupon, |
| | | UserSystemCouponGiveRecord record, String tips) {
|
| | | UserSystemCouponVO userCouponVO = new UserSystemCouponVO();
|
| | | userCouponVO.setId(userSystemCoupon.getId());
|
| | | userCouponVO.setUid(userSystemCoupon.getUid());
|
| | | userCouponVO.setSource("来源:" + userSystemCoupon.getSource());
|
| | | userCouponVO.setCouponName(systemCoupon.getName());
|
| | | userCouponVO.setCouponEffect("赠送中");
|
| | | userCouponVO.setState(UserSystemCoupon.STATE_GIVE_IN);
|
| | | userCouponVO.setCouponRule(systemCoupon.getRemark());
|
| | | userCouponVO.setCouponRuleLink(systemCoupon.getRuleLink());
|
| | | userCouponVO.setCouponPicture(systemCoupon.getPicture());
|
| | | userCouponVO.setGiveTips(tips);
|
| | | |
| | | String couponTerm = "有效期:";
|
| | | Date startTime = userCouponVO.getStartTime();
|
| | | Date endTime = userCouponVO.getEndTime();
|
| | | if (endTime != null && startTime != null) {
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
|
| | | couponTerm = couponTerm + sdf.format(startTime) + "-" + sdf.format(endTime);
|
| | | }
|
| | | userCouponVO.setCouponTerm(couponTerm);
|
| | | |
| | | Map<String, Object> remainDays = new HashMap<String, Object>();
|
| | | |
| | | try {
|
| | | remainDays.put("content", "剩余" + DateUtil.dateDiff2(new Date(), record.getGiveTime()) + "过期");
|
| | | } catch (Exception e) {
|
| | | }
|
| | | remainDays.put("fontColor", "#F14242");
|
| | | userCouponVO.setRemainDays(remainDays);
|
| | | |
| | | return userCouponVO;
|
| | | }
|
| | |
|
| | |
|
| | |
| | |
|
| | | // 退回消息
|
| | | String beiZhu = "请到我的-福利中心查看";
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH.mm");
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
| | | MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO();
|
| | | msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON);
|
| | | msgOther.setTitle("赠送" + systemCoupon.getName() + "退回");
|