From 9eeda0d3049b71877c373c04d65533939b5582ef Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期一, 02 九月 2019 09:55:55 +0800 Subject: [PATCH] getBoss方法只查询有效上级信息 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java | 76 ++++++++++++++++++++++++++----------- 1 files changed, 53 insertions(+), 23 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 d3ef45b..4e8fee4 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 @@ -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 @@ -245,7 +249,10 @@ // 缁撴潫鏃ユ湡 // 浠婂ぉ鍦ㄥ唴 鍑忓幓涓�澶� String endDay = DateUtil.plusDay(expiryDay - 1, new Date()); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (endDay != null && endDay.trim().length() > 0) { + endDay += " 23:59:59"; + } Date endTime = format.parse(endDay); UserSystemCoupon userCoupon = new UserSystemCoupon(); @@ -1374,7 +1381,10 @@ // 缁撴潫鏃ユ湡 // 浠婂ぉ鍦ㄥ唴 鍑忓幓涓�澶� String endDay = DateUtil.plusDay(systemCoupon.getExpiryDay() - 1, new Date()); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (endDay != null && endDay.trim().length() > 0) { + endDay += " 23:59:59"; + } Date endTime = format.parse(endDay); UserSystemCoupon userCoupon = new UserSystemCoupon(); @@ -1449,7 +1459,10 @@ // 缁撴潫鏃ユ湡 浠婂ぉ鍦ㄥ唴 鍑忓幓涓�澶� String endDay = DateUtil.plusDay(systemCoupon.getExpiryDay() - 1, new Date()); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (endDay != null && endDay.trim().length() > 0) { + endDay += " 23:59:59"; + } Date endTime = format.parse(endDay); UserSystemCoupon userCoupon = new UserSystemCoupon(); @@ -1586,7 +1599,10 @@ // 璁$畻缁撴潫鏃ユ湡锛氫粖澶╁湪鍐� 鍑忓幓涓�澶� String endDay = DateUtil.plusDay(expiryDay - 1, new Date()); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (endDay != null && endDay.trim().length() > 0) { + endDay += " 23:59:59"; + } Date endTime = format.parse(endDay); UserSystemCoupon userCoupon = new UserSystemCoupon(); @@ -2021,7 +2037,10 @@ try { Integer expiryDay = systemCoupon.getExpiryDay(); String endDay = DateUtil.plusDay(expiryDay - 1, nowDate); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (endDay != null && endDay.trim().length() > 0) { + endDay += " 23:59:59"; + } Date endTime = format.parse(endDay); UserSystemCoupon userCoupon = new UserSystemCoupon(); @@ -2147,16 +2166,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 +2181,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 +2273,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); -- Gitblit v1.8.0