From 08bc0a13c0c2e00658e5ea63839893e73902810f Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期五, 23 八月 2019 11:07:39 +0800 Subject: [PATCH] 金币任务 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java | 82 +++++++++++++++++++++++++++++++---------- 1 files changed, 62 insertions(+), 20 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java index 43b17bc..394ecf6 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java @@ -191,7 +191,7 @@ @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) { @@ -204,8 +204,12 @@ 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) { @@ -1809,6 +1813,7 @@ } } 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); @@ -1830,6 +1835,7 @@ tips = tips.replace("{APP鍚嶇О}", projectChineseName); } tips = tips.replace("{鍙d护}", tokenRecord.getToken()).replace("{涓嬭浇閾炬帴}", configService.get("app_down_link")); + userCouponVO.setGiveTips(tips); } Date endTimeGive = record.getEndTime(); @@ -1839,19 +1845,20 @@ 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); } @@ -1861,7 +1868,7 @@ @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, "璇ュ埜宸蹭笉瀛樺湪"); @@ -1875,11 +1882,8 @@ 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 ) @@ -1911,7 +1915,8 @@ tips = tips.replace("{APP鍚嶇О}", projectChineseName); } tips = tips.replace("{鍙d护}", tokenRecord.getToken()).replace("{涓嬭浇閾炬帴}", configService.get("app_down_link")); - return tips; + + return createUserCouponVOo(userSystemCoupon, systemCoupon, record, tips); } } @@ -1960,7 +1965,44 @@ tips = tips.replace("{APP鍚嶇О}", projectChineseName); } tips = tips.replace("{鍙d护}", 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; } @@ -2025,7 +2067,7 @@ // 閫�鍥炴秷鎭� 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() + "閫�鍥�"); -- Gitblit v1.8.0