fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
@@ -623,6 +623,7 @@ private void searchJDGoods(String key, Integer page, String filter, Integer order, PrintWriter out) { JDSearchResult result = null; boolean hasCoupon = false; String way = configService.get("jd_api_search_key"); if ("1".equals(way)) { JDFilter filterAPI = new JDFilter(); @@ -658,6 +659,7 @@ JSONObject jsonfilter = JSONObject.fromObject(filter); Boolean coupon = jsonfilter.optBoolean("coupon"); if (coupon != null && coupon) { hasCoupon = true; filterAPI.setIsCoupon(1); // 有券 } @@ -713,6 +715,7 @@ JSONObject jsonfilter = JSONObject.fromObject(filter); Boolean coupon = jsonfilter.optBoolean("coupon"); if (coupon != null && coupon) { hasCoupon = true; jdfilter.setHasCoupon(1); // 有券 } @@ -765,7 +768,13 @@ .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); for (JDGoods goods : goodsList) { GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, fanLiRate, shareRate); array.add(gson.toJson(goodsDetailVO)); if (hasCoupon) { if (goodsDetailVO.isHasCoupon()) { array.add(gson.toJson(goodsDetailVO)); } } else { array.add(gson.toJson(goodsDetailVO)); } } } } fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponMapper.java
@@ -10,7 +10,6 @@ public interface UserSystemCouponMapper extends BaseMapper<UserSystemCoupon> { List<UserSystemCoupon> getUserCouponList(@Param("start") long start, @Param("count") int count, @Param("uid") Long uid); @@ -96,4 +95,12 @@ */ List<UserSystemCouponVO> getIncludeNotExchange(@Param("uid") Long uid,@Param("num") int num, @Param("type") String type); /** * 查询正在使用中 超过时间仍未匹配到订单记录 * @param uid * @param seconds * @return */ List<UserSystemCoupon> getCouponByUsingTimeOut(@Param("uid") Long uid,@Param("list") List<Long> list, @Param("number") Long number); } fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponRecordMapper.java
@@ -39,15 +39,6 @@ /** * 查询正在使用中 超过时间仍未匹配到订单记录 * @param uid * @param seconds * @return */ List<UserSystemCouponRecord> getCouponByUsingTimeOut(@Param("uid") Long uid, @Param("number") Long number); /** * 查询最近使用记录 * @param userCouponId * @return fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponMapper.xml
@@ -195,4 +195,15 @@ WHERE t.usc_state = 1 AND t.usc_state_activate = 1 AND t.usc_uid = #{uid} AND c.`sc_percent` <![CDATA[<>]]> #{num} AND c.`sc_type`= #{type} </select> <select id="getCouponByUsingTimeOut" resultMap="BaseResultMap"> SELECT * FROM `yeshi_ec_user_system_coupon` cp WHERE cp.`usc_uid` = #{uid} AND cp.`usc_state` = 2 AND (cp.usc_give = 0 or cp.usc_give is null) AND (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(cp.`usc_use_time`)) <![CDATA[>]]> #{number} AND cp.usc_coupon_id in <foreach collection="list" item="item" open="(" close=")" separator=",">#{item}</foreach> </select> </mapper> fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponRecordMapper.xml
@@ -87,15 +87,6 @@ separator=",">#{item}</foreach> </select> <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 = 0 or cp.usc_give is null) AND (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(cp.`usc_use_time`)) <![CDATA[>]]> #{number}; </select> <select id="getNearByUserCouponId" resultMap="BaseResultMap"> SELECT * FROM `yeshi_ec_user_system_coupon_record` WHERE ucr_user_coupon_id = #{userCouponId} fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java
@@ -58,6 +58,7 @@ private UserInfoService userInfoService; @Resource @Lazy private UserSystemCouponService userSystemCouponService; @Resource fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponRecordServiceImpl.java
@@ -54,11 +54,6 @@ } @Override public List<UserSystemCouponRecord> getCouponByUsingTimeOut(Long uid, Long seconds) { return userSystemCouponRecordMapper.getCouponByUsingTimeOut(uid, seconds); } @Override public boolean isSuccessMianDan(Integer source, String orderId) { List<String> orderList = new ArrayList<>(); orderList.add(orderId); fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -10,7 +10,9 @@ import javax.annotation.Resource; import org.springframework.context.annotation.Lazy; import org.springframework.core.task.TaskExecutor; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.yeshi.utils.DateUtil; @@ -105,6 +107,7 @@ private UserSystemCouponRecordService userSystemCouponRecordService; @Resource @Lazy private HongBaoV2Service hongBaoV2Service; @Resource @@ -141,6 +144,7 @@ private CommonOrderCountService commonOrderCountService; @Resource @Lazy private PushCouponService pushCouponService; @Resource @@ -2147,16 +2151,10 @@ userSystemCoupon.setUseTime(null); userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE); userSystemCoupon.setUpdateTime(new Date()); userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon); userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon); // 使用记录 if (record != null) { UserSystemCouponRecord useRecordUpdate = new UserSystemCouponRecord(); useRecordUpdate.setId(record.getId()); useRecordUpdate.setState(UserSystemCouponRecord.STATE_WAIT_TIME_OUT); useRecordUpdate.setUpdateTime(new Date()); userSystemCouponRecordService.updateByPrimaryKeySelective(useRecordUpdate); if (CouponTypeEnum.welfareFreeCoupon.name().equals(record.getCouponType())) { userOtherMsgNotificationService.welfareCouponDrawBack(userSystemCoupon, record.getOrderNo()); } else if (CouponTypeEnum.freeCoupon.name().equals(record.getCouponType())) { @@ -2168,27 +2166,44 @@ } @Async() @Transactional @Override public void sendBackTimeOutCoupon(Long uid) { // 超过10分钟 未被匹配的券 List<UserSystemCouponRecord> list = userSystemCouponRecordService.getCouponByUsingTimeOut(uid, 600L); if (list == null || list.size() == 0) { // 商品相关的券 List<SystemCoupon> couponList = systemCouponService.getGoodsCouponList(); if (couponList == null || couponList.size() == 0) { return; } for (UserSystemCouponRecord couponRecord : list) { // 更新状态:匹配超时 couponRecord.setState(UserSystemCouponRecord.STATE_WAIT_TIME_OUT); couponRecord.setUpdateTime(new Date()); userSystemCouponRecordService.updateByPrimaryKeySelective(couponRecord); List<Long> list = new ArrayList<Long>(); for (SystemCoupon systemCoupon: couponList) { list.add(systemCoupon.getId()); } // 超过10分钟 未被匹配的免单券 List<UserSystemCoupon> listUserCoupon = userSystemCouponMapper.getCouponByUsingTimeOut(uid, list, 600L); if (listUserCoupon == null || listUserCoupon.size() == 0) { return; } for (UserSystemCoupon userCoupon : listUserCoupon) { // 状态初始化 UserSystemCoupon userSystemCoupon = couponRecord.getUserSystemCoupon(); UserSystemCoupon userSystemCoupon = new UserSystemCoupon(); userSystemCoupon.setId(userCoupon.getId()); userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE); userSystemCoupon.setUseTime(null); userSystemCoupon.setUpdateTime(new Date()); userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon); userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon); UserSystemCouponRecord record = userSystemCouponRecordService.getNearByUserCouponId(userCoupon.getId()); if (record != null) { UserSystemCouponRecord couponRecord = new UserSystemCouponRecord(); couponRecord.setId(record.getId()); couponRecord.setUpdateTime(new Date()); couponRecord.setState(UserSystemCouponRecord.STATE_WAIT_TIME_OUT); userSystemCouponRecordService.updateByPrimaryKeySelective(couponRecord); } } } @@ -2243,7 +2258,7 @@ userSystemCoupon.setUseTime(null); userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE); userSystemCoupon.setUpdateTime(new Date()); userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon); userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon); // 使用记录 UserSystemCouponRecord useRecord = userSystemCouponRecordService.getNearByUserCouponId(couponId); fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponRecordService.java
@@ -18,14 +18,6 @@ public List<UserSystemCouponRecord> getRecordByOrderNoList(Integer source, List<String> list); /** * 查询正在使用中 超过时间仍未匹配到订单记录 * * @param uid * @param seconds * @return */ public List<UserSystemCouponRecord> getCouponByUsingTimeOut(Long uid, Long seconds); /** * 查询状态