admin
2019-02-27 309a22d0624e8fec46f4b6722ed6135fe0a2ea3d
免单商品的红包处理
6个文件已修改
108 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponRecordServiceImpl.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/OrderProcessService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponRecordService.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgOtherCouponContentDTOFactory.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java
@@ -31,7 +31,6 @@
import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail;
import com.yeshi.fanli.entity.bus.user.HongBao;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.Order;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.order.CommonOrder;
@@ -56,6 +55,8 @@
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserNotificationService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
@@ -124,6 +125,12 @@
    @Resource
    private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
    @Resource
    private UserSystemCouponService userSystemCouponService;
    @Resource
    private UserSystemCouponRecordService userSystemCouponRecordService;
    @Override
    public int insert(HongBaoV2 record) {
@@ -505,6 +512,23 @@
        if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
            BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
            // 免单处理
            boolean mianDan = false;
            if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK) {
                List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO,
                        commonOrder.getOrderNo());
                if (orderList != null && orderList.size() == 1) {// 只有1个订单才参与免单
                    BigDecimal payMent = commonOrder.getPayment();
                    if (commonOrder.getState() == CommonOrder.STATE_JS)
                        payMent = commonOrder.getSettlement();
                    if (payMent.compareTo(new BigDecimal(10)) < 0) {
                        mianDan = userSystemCouponRecordService.isSuccessMianDan(commonOrder.getOrderNo());
                        fanliRate = new BigDecimal(100);
                    }
                }
            }
            HongBaoV2 hongBao = new HongBaoV2(hongBaoOrder.getHongBaoV2().getId());
            hongBao.setUpdateTime(new Date());
            // 更改状态与资金
@@ -685,6 +709,34 @@
            throws HongBaoException {
        if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
            BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
            // 查询是否有免单计划
            boolean mianDan = false;
            if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK) {
                List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO,
                        commonOrder.getOrderNo());
                if (orderList != null && orderList.size() == 1) {// 只有1个订单才参与免单
                    BigDecimal payMent = commonOrder.getPayment();
                    if (commonOrder.getState() == CommonOrder.STATE_JS)
                        payMent = commonOrder.getSettlement();
                    CommonOrderGoods goods = commonOrderGoodsMapper
                            .selectByPrimaryKey(commonOrder.getCommonOrderGoods().getId());
                    if (goods != null) {
                        try {
                            mianDan = userSystemCouponService.updateCouponRecordUsed(commonOrder.getUserInfo().getId(),
                                    commonOrder.getOrderNo(), payMent, Long.parseLong(goods.getGoodsId()));
                            if (mianDan)
                                fanliRate = new BigDecimal(100);
                        } catch (NumberFormatException e) {
                            throw new HongBaoException(10, "免单商品处理出错");
                        } catch (Exception e) {
                            throw new HongBaoException(11, "免单商品处理出错");
                        }
                    }
                }
            }
            HongBaoV2 hongBao = new HongBaoV2();
            hongBao.setUserInfo(commonOrder.getUserInfo());
            hongBao.setCreateTime(new Date());
@@ -733,7 +785,7 @@
            }
            UserInfo boss = threeSaleSerivce.getBoss(user.getId());
            if (boss != null && hongBao.getState() != HongBaoV2.STATE_SHIXIAO) {// 1级BOSS存在且红包未失效
            if (boss != null && hongBao.getState() != HongBaoV2.STATE_SHIXIAO && !mianDan) {// 1级BOSS存在且红包未失效,免单不支持多级分销
                // 插入一级子红包
                BigDecimal firstRate = hongBaoManageService
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponRecordServiceImpl.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.service.impl.user;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
@@ -8,15 +9,15 @@
import com.yeshi.fanli.dao.mybatis.user.UserSystemCouponRecordMapper;
import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord;
import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
@Service
public class UserSystemCouponRecordServiceImpl implements UserSystemCouponRecordService {
    @Resource
    private UserSystemCouponRecordMapper userSystemCouponRecordMapper;
    @Override
    public int insertSelective(UserSystemCouponRecord record) {
        return userSystemCouponRecordMapper.insertSelective(record);
@@ -36,14 +37,14 @@
    public int updateByPrimaryKey(UserSystemCouponRecord record) {
        return userSystemCouponRecordMapper.updateByPrimaryKey(record);
    }
    @Override
    public List<UserSystemCouponRecord>  getRecordByState(Long uid, Integer state) {
    public List<UserSystemCouponRecord> getRecordByState(Long uid, Integer state) {
        return userSystemCouponRecordMapper.getRecordByState(uid, state);
    }
    @Override
    public UserSystemCouponRecord  getRecordByOrderNo(String orderNo, Integer state) {
    public UserSystemCouponRecord getRecordByOrderNo(String orderNo, Integer state) {
        return userSystemCouponRecordMapper.getRecordByOrderNo(orderNo, state);
    }
@@ -51,10 +52,26 @@
    public List<UserSystemCouponRecord> getRecordByOrderNoList(List<String> list) {
        return userSystemCouponRecordMapper.getRecordByOrderNoList(list);
    }
    @Override
    public List<UserSystemCouponRecord> getCouponByUsingTimeOut(Long uid, long seconds) {
        return userSystemCouponRecordMapper.getCouponByUsingTimeOut(uid, seconds);
    }
    @Override
    public boolean isSuccessMianDan(String orderId) {
        List<String> orderList = new ArrayList<>();
        orderList.add(orderId);
        List<UserSystemCouponRecord> list = getRecordByOrderNoList(orderList);
        for (UserSystemCouponRecord record : list) {
            if (record.getCouponType().equalsIgnoreCase(CouponTypeEnum.freeCoupon.name())
                    || record.getCouponType().equalsIgnoreCase(CouponTypeEnum.welfareFreeCoupon.name())) {
                if (record.getState() == UserSystemCouponRecord.STATE_FREE_ON
                        || record.getState() == UserSystemCouponRecord.STATE_SUCCESS)
                    return true;
            }
        }
        return false;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -1086,6 +1086,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 || 
fanli/src/main/java/com/yeshi/fanli/service/inter/order/OrderProcessService.java
@@ -3,7 +3,6 @@
import java.util.List;
import java.util.Map;
import com.yeshi.fanli.entity.bus.user.HongBao;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponRecordService.java
@@ -20,6 +20,7 @@
    /**
     * 查询正在使用中 超过时间仍未匹配到订单记录
     *
     * @param uid
     * @param seconds
     * @return
@@ -28,10 +29,19 @@
    /**
     * 查询状态
     *
     * @param uid
     * @param state
     * @return
     */
    public List<UserSystemCouponRecord> getRecordByState(Long uid, Integer state);
    /**
     * 订单号是否成功免单
     *
     * @param orderId
     * @return
     */
    public boolean isSuccessMianDan(String orderId);
}
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgOtherCouponContentDTOFactory.java
@@ -40,7 +40,7 @@
    }
    public static MsgOtherCouponContentDTO createWelfareCouponUsed(Integer leftDay, Date startTime, Date endTime) {
        MsgOtherCouponContentDTO dto = getGeneral(leftDay, "成功邀请1个队员", startTime, endTime);
        MsgOtherCouponContentDTO dto = getGeneral(null, "成功邀请1个队员", startTime, endTime);
        dto.setState("已被使用");
        return dto;
    }
@@ -82,7 +82,7 @@
    public static MsgOtherCouponContentDTO createCouponUsed(Integer leftDay, String source, Date startTime,
            Date endTime) {
        MsgOtherCouponContentDTO dto = getGeneral(leftDay, source, startTime, endTime);
        MsgOtherCouponContentDTO dto = getGeneral(null, source, startTime, endTime);
        dto.setState("已被使用");
        return dto;
    }
@@ -118,7 +118,7 @@
    public static MsgOtherCouponContentDTO createRewardCouponUsed(Integer leftDay, String source, Date startTime,
            Date endTime) {
        MsgOtherCouponContentDTO dto = getGeneral(leftDay, source, startTime, endTime);
        MsgOtherCouponContentDTO dto = getGeneral(null, source, startTime, endTime);
        dto.setState("已被使用");
        return dto;
    }