fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponMapper.java
@@ -59,6 +59,13 @@ List<UserSystemCoupon> getCounponNowInvalid(@Param("count")int count); /** * 获取已经过期但状态未改变的券 * @param uid * @return */ List<UserSystemCoupon> getCounponNowInvalidByUid(@Param("uid")Long uid); /** * 根据状态查询券 * @param uid * @param source fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponMapper.xml
@@ -161,6 +161,13 @@ LIMIT #{count} </select> <select id="getCounponNowInvalidByUid" resultMap="BaseResultMap"> SELECT * FROM `yeshi_ec_user_system_coupon` cp WHERE cp.`usc_uid` = #{uid} AND <![CDATA[cp.`usc_state` <> 3 AND cp.`usc_state` <> 4]]> AND DATE_FORMAT(CURDATE(),'%Y%m%d') <![CDATA[>]]> DATE_FORMAT(cp.`usc_end_time`,'%Y%m%d') </select> <select id="getCouponByState" resultMap="BaseResultMap"> SELECT * FROM `yeshi_ec_user_system_coupon` cp WHERE cp.`usc_uid` = #{uid} fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponRecordMapper.xml
@@ -90,7 +90,8 @@ <select id="getCouponByUsingTimeOut" resultMap="BaseResultMap"> SELECT * FROM `yeshi_ec_user_system_coupon` cp LEFT JOIN `yeshi_ec_user_system_coupon_record` rd ON rd.`ucr_user_coupon_id` = cp.`usc_id` WHERE cp.`usc_uid` = #{uid} AND cp.`usc_state` = 2 AND rd.`ucr_state` = 0 AND cp.usc_give = 1 WHERE cp.`usc_uid` = #{uid} AND cp.`usc_state` = 2 AND rd.`ucr_state` = 0 AND (cp.usc_give = 0 or cp.usc_give is null) AND (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(cp.`usc_use_time`)) <![CDATA[>]]> #{number}; </select> fanli/src/main/java/com/yeshi/fanli/service/impl/msg/UserOtherMsgNotificationServiceImpl.java
@@ -235,7 +235,7 @@ coupon.getSource(), coupon.getStartTime(), coupon.getEndTime()); try { msgOtherDetailService.addMsgOtherDetail(MsgOtherDetailFactory.createCouponMsg(coupon.getUid(), coupon.getId(), dto, MsgTypeOtherTypeEnum.couponReward, "使用本券已到账的返利再返" + percent + "%")); coupon.getId(), dto, MsgTypeOtherTypeEnum.couponReward, "返利订单已到账再返" + percent + "%")); } catch (MsgOtherDetailException e) { e.printStackTrace(); } @@ -264,7 +264,7 @@ getLeftDay(coupon), coupon.getSource(), coupon.getStartTime(), coupon.getEndTime()); try { msgOtherDetailService.addMsgOtherDetail(MsgOtherDetailFactory.createCouponMsg(coupon.getUid(), coupon.getId(), dto, MsgTypeOtherTypeEnum.couponReward, "使用本券已到账的返利再返" + percent + "%")); coupon.getId(), dto, MsgTypeOtherTypeEnum.couponReward, "返利订单已到账再返" + percent + "%")); } catch (MsgOtherDetailException e) { e.printStackTrace(); } fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java
@@ -474,7 +474,7 @@ msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON); msgOther.setTitle("赠送奖励券"); msgOther.setGiveType("你赠送的奖励券被成功领取"); msgOther.setReceiveInfo("昵称: " + userName + " ID:" + uid); msgOther.setReceiveInfo("昵称: " + userName + " ID:" + uid); msgOther.setGiveTime(sd.format(giveRecord.getGiveTime())); msgOther.setReceiveTime(sd.format(new Date())); userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther); @@ -526,7 +526,7 @@ msgOther.setType(MsgOtherGiveContentDTO.TYEP_TLJ); msgOther.setTitle("赠送推广红包"); msgOther.setGiveType("你赠送的推广红包被成功领取"); msgOther.setReceiveInfo("昵称: " + userName + " ID:" + uid); msgOther.setReceiveInfo("昵称:" + userName + " ID:" + uid); msgOther.setGiveTime(sd.format(giveRecord.getGiveTime())); msgOther.setReceiveTime(sd.format(new Date())); userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther); fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -310,6 +310,9 @@ return null; } // 过期券 updateInvalidSate(uid); // 退回券 sendBackTimeOutCoupon(uid); @@ -573,6 +576,9 @@ throw new UserSystemCouponException(1, "用户未登录"); } // 过期券 updateInvalidSate(uid); // 退回券 sendBackTimeOutCoupon(uid); @@ -598,6 +604,9 @@ throw new UserSystemCouponException(1, "商品ID为空"); } // 过期券 updateInvalidSate(uid); // 退回券 sendBackTimeOutCoupon(uid); @@ -1224,10 +1233,7 @@ return userSystemCouponMapper.getCounponNowInvalid(count); } @Transactional @Override public boolean updateCouponRecordUsed(Long uid, String orderNo, BigDecimal payment, Long auctionId) @@ -1600,9 +1606,14 @@ @Override public List<UserSystemCouponVO> getCouponList(long start, int count, Long uid) throws UserSystemCouponException, Exception { // 过期券 updateInvalidSate(uid); // 退回券 sendBackTimeOutCoupon(uid); List<UserSystemCouponVO> listVO = userSystemCouponMapper.getUserCouponVOList(start, count, uid); if (listVO == null || listVO.size() == 0) { return listVO; @@ -1787,7 +1798,7 @@ Date useTime = userCouponVO.getUseTime(); if (useTime != null) { Map<String, Object> remainDays = new HashMap<String, Object>(); remainDays.put("content", "于" + sdf.format(useTime) + "成功赠送"); remainDays.put("content", "于" + sdf.format(useTime) + "赠送"); remainDays.put("fontColor", "#CCCCCC"); userCouponVO.setRemainDays(remainDays); } @@ -1795,7 +1806,7 @@ Date useTime = userCouponVO.getUseTime(); if (useTime != null) { Map<String, Object> remainDays = new HashMap<String, Object>(); remainDays.put("content", "于" + sdf.format(useTime) + "成功使用"); remainDays.put("content", "于" + sdf.format(useTime) + "使用"); remainDays.put("fontColor", "#CCCCCC"); userCouponVO.setRemainDays(remainDays); } @@ -1954,6 +1965,17 @@ } @Transactional @Override public void updateInvalidSate(Long uid) { List<UserSystemCoupon> list = userSystemCouponMapper.getCounponNowInvalidByUid(uid); if (list == null || list.size() == 0) { return; } updateCounponInvalid(list); } @Override public void updateCounponInvalid(List<UserSystemCoupon> list) { if (list == null || list.size() == 0) { @@ -1998,6 +2020,7 @@ } } } /** * 退回券 初始数据 @@ -2065,8 +2088,8 @@ couponRecord.setUpdateTime(new Date()); userSystemCouponRecordService.updateByPrimaryKeySelective(couponRecord); UserSystemCoupon userSystemCoupon = couponRecord.getUserSystemCoupon(); // 状态初始化 UserSystemCoupon userSystemCoupon = couponRecord.getUserSystemCoupon(); userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE); userSystemCoupon.setUseTime(null); userSystemCoupon.setUpdateTime(new Date()); @@ -2134,11 +2157,12 @@ if (systemCoupon == null) continue; // 退回消息 String couponName = systemCoupon.getName(); if (CouponTypeEnum.freeCouponGive == systemCoupon.getType()) couponName = "免单券"; // 退回消息 String beiZhu = "请到我的-福利中心查看"; SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm"); MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO(); @@ -2154,6 +2178,9 @@ @Override public boolean getIncludeExchange(Long uid) { // 过期券 updateInvalidSate(uid); String percent = configService.get("exchange_rebate_percent"); if (StringUtil.isNullOrEmpty(percent)) percent = "35"; @@ -2166,6 +2193,9 @@ @Override public boolean getIncludeNotExchange(Long uid) { // 过期券 updateInvalidSate(uid); String percent = configService.get("exchange_rebate_percent"); if (StringUtil.isNullOrEmpty(percent)) percent = "35"; @@ -2178,6 +2208,10 @@ @Override public List<UserSystemCouponVO> listIncludeNotExchange(Long uid) throws Exception{ // 过期券 updateInvalidSate(uid); // 退回券 sendBackTimeOutCoupon(uid); String percent = configService.get("exchange_rebate_percent"); fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponService.java
@@ -276,4 +276,10 @@ public long countCouponOld(Long uid); /** * 更新用户过期券 * @param uid */ public void updateInvalidSate(Long uid); }