admin
2019-03-06 3245e47e12d352c9cd8ba8ee7429e649a6d257c1
券使用前验证
1个文件已修改
52 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java 52 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -27,7 +27,6 @@
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
import com.yeshi.fanli.entity.order.CommonOrder;
import com.yeshi.fanli.entity.push.PushCoupon;
import com.yeshi.fanli.entity.system.SystemCoupon;
import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -164,7 +163,8 @@
    @Override
    @Transactional
    public void insertUserCoupon(Long uid, String couponType, String source)throws UserSystemCouponException,Exception{
    public void insertUserCoupon(Long uid, String couponType, String source)
            throws UserSystemCouponException, Exception {
        
        if (couponType == null || uid == null) {
            throw new UserSystemCouponException(1, "参数不正确");
@@ -215,7 +215,6 @@
                        userInfoExtra.setCouponNews(userInfoExtra.getCouponNews() + 1);
                    }
                    
                    try {
                        userInfoExtraService.saveUserInfoExtra(userInfoExtra);
                    } catch (UserInfoExtraException e) {
@@ -244,7 +243,6 @@
            }
        }
    }
    
    @Transactional
    @Override
@@ -321,14 +319,15 @@
                jumpBtn = new HashMap<String, Object>();
                
                // 邀请队员界面
                /*
                 * Map<String, Object> jumpLink = new HashMap<String, Object>();
                 *UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
                 * if (userInfoExtra != null && userInfoExtra.getInviteCode() != null &&
                 * userInfoExtra.getInviteCode().trim().length() > 0) { // 邀请激活成功界面
                 * jumpLink.put("url", configService.get("invite_activation_success_url") +
                 * UserInfoExtra userInfoExtra =
                 * userInfoExtraService.getUserInfoExtra(uid); if (userInfoExtra
                 * != null && userInfoExtra.getInviteCode() != null &&
                 * userInfoExtra.getInviteCode().trim().length() > 0) { //
                 * 邀请激活成功界面 jumpLink.put("url",
                 * configService.get("invite_activation_success_url") +
                 * "?alert=true"); } else { // 激活邀请码界面 jumpLink.put("url",
                 * configService.get("invite_activation_url")); }
                 *    jumpBtn.put("params", jumpLink);
@@ -440,7 +439,6 @@
            userCouponVO.setCouponRule(systemCoupon.getRule());
            userCouponVO.setCouponPictureInvalid(systemCoupon.getPictureInvalid());
            int differentDays = 0;
            String couponTerm = "有效期:";
            Date startTime = userCouponVO.getStartTime();
@@ -531,7 +529,8 @@
    @Transactional
    @Override
    public List<UserSystemCouponVO> getGoodsCouponList(Long uid, Long auctionId) throws UserSystemCouponException, Exception {
    public List<UserSystemCouponVO> getGoodsCouponList(Long uid, Long auctionId)
            throws UserSystemCouponException, Exception {
        
        if (uid == null) {
            throw new UserSystemCouponException(1, "用户未登录");
@@ -597,12 +596,15 @@
            throw new UserSystemCouponException(1, "券数据不正确");
        }
        
        if (userSystemCoupon.getUid().longValue() != uid) {
            throw new UserSystemCouponException(1, "不属于该用户的券");
        }
        Integer state = userSystemCoupon.getState();
        Integer stateActivated = userSystemCoupon.getStateActivated();
        if (UserSystemCoupon.STATE_CAN_USE != state || 1 != stateActivated) {
            throw new UserSystemCouponException(1, "该券不能被使用");
        }
        Long couponUid = userSystemCoupon.getUid();
        if (!uid.equals(couponUid)) {
@@ -667,6 +669,10 @@
            throw new UserSystemCouponException(1, "券信息不存在");
        }
        
        if (userSystemCoupon.getUid().longValue() != uid) {
            throw new UserSystemCouponException(1, "不属于该用户的券");
        }
        Integer state = userSystemCoupon.getState();
        Integer stateActivated = userSystemCoupon.getStateActivated();
        if (UserSystemCoupon.STATE_CAN_USE != state || 1 != stateActivated) {
@@ -686,7 +692,6 @@
            throw new UserSystemCouponException(1, "券类型不匹配");
        }
        if (orderNo == null || orderNo.trim().length() == 0) {
            throw new UserSystemCouponException(1, "订单号不存在");
        }
@@ -696,7 +701,6 @@
        if (orderVO == null) {
            throw new UserSystemCouponException(1, "订单信息获取失败");
        }
        BigDecimal hongBao = orderVO.getHongBao();
        // 红包状态
@@ -809,8 +813,8 @@
        Long uid = userSystemCoupon.getUid();
        
        CommonOrderVO commonOrderVO= commonOrderService.getCommonOrderByOrderNo(userSystemCoupon.getUid(),
                orderNo, CommonOrder.STATE_JS);
        CommonOrderVO commonOrderVO = commonOrderService.getCommonOrderByOrderNo(userSystemCoupon.getUid(), orderNo,
                CommonOrder.STATE_JS);
        
        if (commonOrderVO == null) {
            throw new UserSystemCouponException(1, "订单信息获取失败");
@@ -850,7 +854,6 @@
        return userRecordVO;
    }
    
    @Override
    public UserSystemCouponRecordVO getFreeCouponRecord(String orderNo) throws UserSystemCouponException, Exception {
@@ -1053,7 +1056,6 @@
        return userRecordVO;
    }
    
    @Transactional
    @Override
    public void activatedWelfareFreeCoupon(Long uid, String fromNickName) {
@@ -1248,18 +1250,18 @@
    
    @Transactional
    @Override
    public boolean updateCouponRecordUsed(Long uid, String orderNo, BigDecimal payment,
            Long auctionId) throws  Exception{
    public boolean updateCouponRecordUsed(Long uid, String orderNo, BigDecimal payment, Long auctionId)
            throws Exception {
        
        boolean isfree = false;
        
        if (uid == null || payment == null || auctionId == null || orderNo == null ||
                orderNo.trim().length() == 0 ) {
        if (uid == null || payment == null || auctionId == null || orderNo == null || orderNo.trim().length() == 0) {
            throw new Exception("传递参数不能为空");
        }
        
        // 查询等待匹配的券记录
        List<UserSystemCouponRecord> list = userSystemCouponRecordService.getRecordByState(uid, UserSystemCouponRecord.STATE_WAIT);
        List<UserSystemCouponRecord> list = userSystemCouponRecordService.getRecordByState(uid,
                UserSystemCouponRecord.STATE_WAIT);
        if (list == null || list.size() == 0) {
            return  isfree;
        }
@@ -1324,6 +1326,7 @@
    
    /**
     * 退回券 初始数据
     *
     * @param userSystemCoupon
     */
    public void sendBackCoupon(UserSystemCoupon userSystemCoupon, UserSystemCouponRecord record) throws Exception{
@@ -1356,14 +1359,12 @@
        
        userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
        
        if (CouponTypeEnum.welfareFreeCoupon.name().equals(record.getCouponType())) {
            userOtherMsgNotificationService.welfareCouponDrawBack(userSystemCoupon, record.getOrderNo());
        } else if (CouponTypeEnum.freeCoupon.name().equals(record.getCouponType())) {
            userOtherMsgNotificationService.freeSheetCouponDrawBack(userSystemCoupon, record.getOrderNo());
        } 
    }
    
    @Override
    @Transactional
@@ -1476,4 +1477,3 @@
    }
    
}