From 1056fd1b866b5175f92fe6ce4a40be98202fd906 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期三, 27 二月 2019 16:29:02 +0800 Subject: [PATCH] 福利中心代码优化 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java | 67 ++++++++++++++++++++++++++++++++- 1 files changed, 64 insertions(+), 3 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 e9cff22..6e6b688 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 @@ -11,6 +11,7 @@ import javax.annotation.Resource; +import org.springframework.core.task.TaskExecutor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.yeshi.utils.DateUtil; @@ -27,6 +28,7 @@ import com.yeshi.fanli.entity.order.CommonOrder; import com.yeshi.fanli.entity.system.SystemCoupon; import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum; +import com.yeshi.fanli.exception.user.UserInfoExtraException; import com.yeshi.fanli.exception.user.UserSystemCouponException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.common.JumpDetailV2Service; @@ -58,6 +60,9 @@ @Service public class UserSystemCouponServiceImpl implements UserSystemCouponService { + @Resource(name = "taskExecutor") + private TaskExecutor executor; + @Resource private UserSystemCouponMapper userSystemCouponMapper; @@ -185,6 +190,22 @@ // 鎻掑叆鏁版嵁搴� insertSelective(userCoupon); + executor.execute(new Runnable() { + @Override + public void run() { + UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); + // 娣诲姞涓�鏉℃秷鎭� + if (userInfoExtra != null) { + userInfoExtra.setCouponNews(userInfoExtra.getCouponNews() + 1); + try { + userInfoExtraService.saveUserInfoExtra(userInfoExtra); + } catch (UserInfoExtraException e) { + e.printStackTrace(); + } + } + + } + }); // 娑堟伅鎺ㄩ�� try { @@ -990,10 +1011,46 @@ } } } - - } + @Override + public void updateStateByDrawback(String orderNo) throws Exception { + + if (orderNo == null || orderNo.trim().length() == 0) { + return; + } + + UserSystemCouponRecord record = userSystemCouponRecordService.getRecordByOrderNo(orderNo, null); + if (record == null) { + return; + } + + record.setOrderNo(orderNo); + record.setUpdateTime(new Date()); + record.setState(UserSystemCouponRecord.STATE_FAIL_DRAWBACK); + userSystemCouponRecordService.updateByPrimaryKeySelective(record); + + // 鍒搁��鍥� + sendBackCoupon(record.getUserSystemCoupon()); + } + + @Override + public void updateStateByArrivalAccount(String orderNo) throws Exception { + + if (orderNo == null || orderNo.trim().length() == 0) { + return; + } + + UserSystemCouponRecord record = userSystemCouponRecordService.getRecordByOrderNo(orderNo, 2); + if (record == null) { + return; + } + + record.setOrderNo(orderNo); + record.setUpdateTime(new Date()); + record.setState(UserSystemCouponRecord.STATE_SUCCESS); + userSystemCouponRecordService.updateByPrimaryKeySelective(record); + } @Override public void updateCounponInvalid(Long uid) { @@ -1040,7 +1097,7 @@ @Override public void sendBackTimeOutCoupon(Long uid) { // 瓒呰繃120绉� 鏈鍖归厤鐨勫埜 - List<UserSystemCouponRecord> list = userSystemCouponRecordService.getCouponByUsingTimeOut(uid, 120); + List<UserSystemCouponRecord> list = userSystemCouponRecordService.getCouponByUsingTimeOut(uid, 120L); if (list == null || list.size() == 0) { return; } @@ -1086,6 +1143,10 @@ public boolean updateCouponRecordUsed(Long uid, String orderNo, BigDecimal payment, Long auctionId) throws Exception{ + //鍙鐞嗕粯娆鹃噾棰濆皬浜�10鐨� + if(payment==null||payment.compareTo(new BigDecimal(10))<0) + return false; + boolean isfree = false; if (uid == null || payment == null || auctionId == null || orderNo == null || -- Gitblit v1.8.0