admin
2019-04-01 273e3ebef2a30c931590f51257403eda566fafcf
订单统计BUG修复
6个文件已修改
181 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/ThreeSaleMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/hongbao/ThreeSaleSerivce.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/ThreeSaleMapper.java
@@ -221,5 +221,12 @@
     */
    ThreeSale getRelationshipByBossIdAndWorkerId(@Param("bossId") Long bossId, @Param("workerId") Long workerId);
    
    /**
     * 根据下级查询成功的邀请关系
     * @param workerId
     * @return
     */
    ThreeSale selectSuccessByWorkerId(Long workerId);
}
fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml
@@ -155,7 +155,8 @@
    <delete id="deleteExpireRecord" parameterType="java.lang.Long">
        DELETE FROM
        yeshi_ec_threesale
        WHERE expire = 1 AND boss_id = #{bossId} AND worker_id = #{workerId}
        WHERE expire = 1 AND boss_id = #{bossId} AND
        worker_id = #{workerId}
    </delete>
    <!-- 查询一度队员集合 -->
@@ -392,7 +393,8 @@
        SELECT * FROM
        `yeshi_ec_threesale` ts
        LEFT JOIN `yeshi_ec_threesale_extra_info` ff
        ON ts.`boss_id` = ff.`tf_boss_id` AND ts.`worker_id`=ff.`tf_worker_id`
        ON
        ts.`boss_id` = ff.`tf_boss_id` AND ts.`worker_id`=ff.`tf_worker_id`
        WHERE ts.`boss_id` = #{uid}
        ORDER BY ts.state DESC, ts.expire,
        ts.createTime DESC
@@ -411,16 +413,22 @@
    <select id="listSecondTeam" resultMap="AllResultMap">
        SELECT yet.* FROM (
        SELECT DISTINCT(ts.`id`) AS id FROM `yeshi_ec_threesale` ts
        LEFT JOIN yeshi_ec_threesale tf ON ts.`boss_id`=tf.`worker_id`
        WHERE tf.`boss_id` = #{uid})A
        SELECT
        DISTINCT(ts.`id`) AS id FROM `yeshi_ec_threesale` ts
        LEFT JOIN
        yeshi_ec_threesale tf ON ts.`boss_id`=tf.`worker_id`
        WHERE tf.`boss_id`
        = #{uid})A
        LEFT JOIN yeshi_ec_threesale yet ON yet.id =
        A.id
        LEFT JOIN `yeshi_ec_threesale_extra_info` ff
        LEFT JOIN
        `yeshi_ec_threesale_extra_info` ff
        ON yet.`boss_id` =
        ff.`tf_boss_id` AND yet.`worker_id` =ff.`tf_worker_id`
        ff.`tf_boss_id`
        AND yet.`worker_id` =ff.`tf_worker_id`
        ORDER BY
        yet.state DESC, yet.expire, yet.createTime DESC
        yet.state DESC,
        yet.expire, yet.createTime DESC
        LIMIT ${start},${count}
    </select>
@@ -456,19 +464,31 @@
    </select>
    <select id="getSuccessRelationshipNum" resultType="java.lang.Integer">
        SELECT IFNULL (COUNT(*),0) FROM `yeshi_ec_threesale` t
        WHERE t.`state` = 1 AND (t.`worker_id` =${uid} OR t.`boss_id` = ${uid})
        SELECT IFNULL
        (COUNT(*),0) FROM `yeshi_ec_threesale` t
        WHERE t.`state` = 1 AND
        (t.`worker_id` =${uid} OR t.`boss_id` = ${uid})
    </select>
    <select id="getRelationshipByBossIdAndWorkerId" resultMap="BaseResultMap">
        SELECT * FROM `yeshi_ec_threesale` t
        WHERE t.`boss_id` = ${bossId} AND t.`worker_id` = ${workerId}
        AND t.`state` = 0 AND (t.`expire` = 0 OR t.`expire`IS NULL)
        WHERE t.`boss_id` = ${bossId} AND
        t.`worker_id` = ${workerId}
        AND t.`state` = 0 AND (t.`expire` = 0 OR
        t.`expire`IS NULL)
        LIMIT 1
    </select>
    <select id="getExpireRecord" resultMap="BaseResultMap">
        SELECT * FROM `yeshi_ec_threesale`
        WHERE expire = 1 AND boss_id = #{bossId} AND worker_id = #{workerId}
        SELECT * FROM
        `yeshi_ec_threesale`
        WHERE expire = 1 AND boss_id = #{bossId} AND
        worker_id = #{workerId}
    </select>
    <select id="selectSuccessByWorkerId" resultMap="BaseResultMap" parameterType="java.lang.Long">
        SELECT * FROM `yeshi_ec_threesale`
        WHERE `state` = 1 AND worker_id = #{0}  order by id desc
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java
@@ -27,6 +27,7 @@
import com.yeshi.fanli.dto.HongBaoDTO;
import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.ThreeSale;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.order.CommonOrder;
@@ -337,7 +338,7 @@
            // 获取子红包
            List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
            if (children != null)
            if (children != null&&children.size()>0)
                for (HongBaoV2 child : children) {
                    HongBaoV2 childUpdate = new HongBaoV2(child.getId());
                    childUpdate.setState(hongBao.getState());
@@ -386,7 +387,110 @@
                    }
                }
            else {// 修复之前二级,三级订单未统计到的情况
                if (!mianDan) {
                    ThreeSale threeSale = threeSaleSerivce.selectByWorkerId(commonOrder.getUserInfo().getId());
                    if (threeSale.getSucceedTime() != null
                            && threeSale.getSucceedTime() <= commonOrder.getThirdCreateTime().getTime()) {
                        UserInfo boss = threeSaleSerivce.getBoss(commonOrder.getUserInfo().getId());
                        // 插入一级子红包
                        BigDecimal firstRate = hongBaoManageService
                                .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank());
                        if (firstRate.compareTo(new BigDecimal(0)) <= 0)
                            return;
                        HongBaoV2 firstHongbao = new HongBaoV2();
                        firstHongbao.setUserInfo(boss);
                        firstHongbao.setUrank(boss.getRank());
                        firstHongbao.setParent(hongBao);
                        firstHongbao.setCreateTime(new Date());
                        firstHongbao.setType(HongBaoV2.TYPE_YIJI);
                        firstHongbao.setVersion(2);
                        firstHongbao.setState(hongBao.getState());
                        if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
                            firstHongbao.setMoney(
                                    MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
                            Calendar calendar = Calendar.getInstance();
                            calendar.setTime(commonOrder.getSettleTime());
                            calendar.add(Calendar.MONTH, 1);
                            firstHongbao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                                    calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                                    "yyyy-M-dd")));
                        } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
                            firstHongbao.setMoney(
                                    MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
                        }
                        hongBaoV2Mapper.insertSelective(firstHongbao);
                        // 用户通知
                        if (notificationMap.get(HongBaoV2.TYPE_YIJI) == null) {
                            HongBaoV2 tempHongBao = new HongBaoV2(firstHongbao.getId());
                            tempHongBao.setUserInfo(firstHongbao.getUserInfo());
                            tempHongBao.setMoney(firstHongbao.getMoney());
                            CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                            tempCommonOrder.setPayment(commonOrder.getPayment());
                            notificationMap.put(HongBaoV2.TYPE_YIJI, new HongBaoOrder(tempCommonOrder, tempHongBao));
                        } else {
                            // 增加付款金额与资金
                            HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_YIJI);
                            tempHongBaoOrder.getCommonOrder().setPayment(
                                    tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                            tempHongBaoOrder.getHongBaoV2()
                                    .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(firstHongbao.getMoney()));
                            notificationMap.put(HongBaoV2.TYPE_YIJI, tempHongBaoOrder);
                        }
                        // 插入二级子红包
                        boss = threeSaleSerivce.getBoss(boss.getId());
                        if (boss != null) {// 二级BOSS存在
                            BigDecimal secondRate = hongBaoManageService
                                    .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank());
                            if (secondRate.compareTo(new BigDecimal(0)) <= 0)
                                return;
                            HongBaoV2 secondHongbao = new HongBaoV2();
                            secondHongbao.setUserInfo(boss);
                            secondHongbao.setUrank(boss.getRank());
                            secondHongbao.setParent(hongBao);
                            secondHongbao.setCreateTime(new Date());
                            secondHongbao.setType(HongBaoV2.TYPE_ERJI);
                            secondHongbao.setVersion(2);
                            secondHongbao.setState(hongBao.getState());
                            if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
                                secondHongbao.setMoney(MoneyBigDecimalUtil.mul(hongBao.getMoney(),
                                        secondRate.divide(new BigDecimal(100))));
                                Calendar calendar = Calendar.getInstance();
                                calendar.setTime(commonOrder.getSettleTime());
                                calendar.add(Calendar.MONTH, 1);
                                secondHongbao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                                        calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                                        "yyyy-M-dd")));
                            } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
                                secondHongbao.setMoney(MoneyBigDecimalUtil.mul(hongBao.getMoney(),
                                        secondRate.divide(new BigDecimal(100))));
                            }
                            hongBaoV2Mapper.insertSelective(secondHongbao);
                            // 用户通知
                            if (notificationMap.get(HongBaoV2.TYPE_ERJI) == null) {
                                HongBaoV2 tempHongBao = new HongBaoV2(secondHongbao.getId());
                                tempHongBao.setUserInfo(secondHongbao.getUserInfo());
                                tempHongBao.setMoney(secondHongbao.getMoney());
                                CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                                tempCommonOrder.setPayment(commonOrder.getPayment());
                                notificationMap.put(HongBaoV2.TYPE_ERJI,
                                        new HongBaoOrder(tempCommonOrder, tempHongBao));
                            } else {
                                // 增加付款金额与资金
                                HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_ERJI);
                                tempHongBaoOrder.getCommonOrder().setPayment(
                                        tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                                tempHongBaoOrder.getHongBaoV2().setMoney(
                                        tempHongBaoOrder.getHongBaoV2().getMoney().add(secondHongbao.getMoney()));
                                notificationMap.put(HongBaoV2.TYPE_ERJI, tempHongBaoOrder);
                            }
                        }
                    }
                }
            }
        } else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
            BigDecimal fanliRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime());
            List<ShareGoodsActivityOrder> list = shareGoodsActivityOrderService
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java
@@ -535,4 +535,9 @@
        return threeSaleMapper.countFirstTeam(uid, 1);
    }
    @Override
    public ThreeSale selectByWorkerId(Long workerId) {
        return threeSaleMapper.selectSuccessByWorkerId(workerId);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/hongbao/ThreeSaleSerivce.java
@@ -23,6 +23,7 @@
    /**
     * 邀请关系生效
     *
     * @param worker
     */
    void effective(UserInfo worker);
@@ -221,10 +222,10 @@
     * @return
     */
    public List<ThreeSale> listByWorkerId(Long workerId);
    /**
     * 获取成功邀请关系数量
     *
     * @param uid
     * @return
     */
@@ -232,6 +233,7 @@
    /**
     * 邀请码生成上下级关系
     *
     * @param invitee
     * @param inviter
     * @throws ThreeSaleException
@@ -240,9 +242,17 @@
    /**
     * 统计邀请成功队员数量
     *
     * @param uid
     * @return
     */
    public long countSuccessFirstTeam(Long uid);
    /**
     * 根据下级查找对象
     * @param workerId
     * @return
     */
    public ThreeSale selectByWorkerId(Long workerId);
}
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
@@ -1780,6 +1780,7 @@
        }
        goods.setReservePrice(new BigDecimal(0));
        goods.setTotalFee(new BigDecimal("0"));
        goods.setPictUrlWhite(item.optString("white_image"));
        return goods;
    }