| | |
| | |
|
| | | 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;
|
| | |
| | | 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;
|
| | |
| | | @Service
|
| | | public class UserSystemCouponServiceImpl implements UserSystemCouponService {
|
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | | |
| | | @Resource
|
| | | private UserSystemCouponMapper userSystemCouponMapper;
|
| | |
|
| | |
| | | // 插入数据库
|
| | | 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 {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | }
|
| | |
|
| | | @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) {
|
| | |
| | | @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;
|
| | | }
|
| | |
| | | @Override
|
| | | 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;
|
| | |
|