admin
2020-04-15 2cde53516c1689efab451aef72c1db5e13b825a3
团队订单金额消息加入补贴
6个文件已修改
205 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/InviteOrderSubsidyMapper.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/InviteOrderSubsidyMapper.xml 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/HongBaoV2ServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/InviteOrderSubsidyServiceImplV2.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/InviteOrderSubsidyService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/manger/order/HongBaoV2AddManager.java 109 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/InviteOrderSubsidyMapper.java
@@ -49,37 +49,35 @@
     * @return
     */
    List<InviteOrderSubsidy> listByOrderNoAndType(@Param("orderNo") String orderNo, @Param("type") Integer type);
    List<InviteOrderSubsidy> listByOrderNoAndTypeAndUid(@Param("orderNo") String orderNo, @Param("type") Integer type,
            Long uid);
    InviteOrderSubsidy selectByPrimaryKeyForUpdate(Long id);
    /**
     * 统计用户已到账金额
     * @param uid
     * @return
     */
    BigDecimal sumRecievedMoneyByUid(@Param("uid") long uid, @Param("level") Integer level);
    /**
     * 统计用户有效金额
     * @param uid
     * @param day 1今日 2昨日 3本月  4上月
     * @return
     */
    BigDecimal sumValidMoneyByUidAndDate(@Param("uid") long uid, @Param("day") Integer day,  @Param("level") Integer level);
    BigDecimal sumValidMoneyByUidAndDate(@Param("uid") long uid, @Param("day") Integer day,
            @Param("level") Integer level);
    /**
     * 统计用户有效金额
     * @param uid
     * @param day 1今日 2昨日 3本月  4上月
     * @return
     */
    BigDecimal sumMoneyByUidAndDateAndState(@Param("uid") long uid, @Param("day") Integer day,
    BigDecimal sumMoneyByUidAndDateAndState(@Param("uid") long uid, @Param("day") Integer day,
            @Param("level") Integer level, @Param("state") Integer state);
}
fanli/src/main/java/com/yeshi/fanli/mapping/order/InviteOrderSubsidyMapper.xml
@@ -42,6 +42,15 @@
        from yeshi_ec_invite_order_subsidy where os_order_no = #{orderNo} AND
        os_source_type = #{type}
    </select>
    <select id="listByOrderNoAndTypeAndUid" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_invite_order_subsidy where os_order_no = #{orderNo} AND
        os_source_type = #{type} and os_uid=#{uid}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_invite_order_subsidy where os_id = #{id,jdbcType=BIGINT}
    </delete>
@@ -126,19 +135,22 @@
    </update>
    <select id="getByOrderNoAndType" resultMap="BaseResultMap">SELECT * FROM
        yeshi_ec_invite_order_subsidy WHERE os_uid = #{uid} AND os_order_no =
        #{orderNo} AND os_source_type = #{type} LIMIT 1</select>
        #{orderNo} AND os_source_type = #{type} LIMIT 1
    </select>
    <select id="getByOrderNoAndTypeForUpdate" resultMap="BaseResultMap">SELECT *
        FROM yeshi_ec_invite_order_subsidy WHERE os_uid = #{uid} AND
        os_order_no = #{orderNo} AND os_source_type = #{type} for update
    </select>
    <select id="countByOrderNoAndType" resultType="java.lang.Long">SELECT count(*)
        FROM yeshi_ec_invite_order_subsidy WHERE os_order_no = #{orderNo} AND
        os_source_type = #{type}</select>
        os_source_type = #{type}
    </select>
    <select id="sumValidMoneyByUidAndDate" resultType="BigDecimal">
        SELECT SUM(d.`os_money`) FROM yeshi_ec_invite_order_subsidy d
        WHERE d.`os_uid` = #{uid} AND (d.`os_state` = 1 OR d.`os_state` = 3)
        WHERE
        d.`os_uid` = #{uid} AND (d.`os_state` = 1 OR d.`os_state` = 3)
        <if test="level != null">
            AND d.os_level = #{level}
        </if>
@@ -149,17 +161,21 @@
            AND TO_DAYS(NOW()) - TO_DAYS(d.`os_valid_time`) = 1
        </if>
        <if test="day == 3"> <!-- 本月 -->
            AND DATE_FORMAT(d.`os_valid_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
            AND DATE_FORMAT(d.`os_valid_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day == 4"> <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(),'%Y%m'),DATE_FORMAT(d.`os_valid_time`, '%Y%m')) = 1
            AND
            PERIOD_DIFF(DATE_FORMAT(NOW(),'%Y%m'),DATE_FORMAT(d.`os_valid_time`,
            '%Y%m')) = 1
        </if>
    </select>
    </select>
    <select id="sumMoneyByUidAndDateAndState" resultType="BigDecimal">
        SELECT SUM(d.`os_money`) FROM yeshi_ec_invite_order_subsidy d
        WHERE d.`os_uid` = #{uid} AND d.`os_state` = #{state}
        WHERE
        d.`os_uid` = #{uid} AND d.`os_state` = #{state}
        <if test="level != null">
            AND d.os_level = #{level}
        </if>
@@ -170,20 +186,24 @@
            AND TO_DAYS(NOW()) - TO_DAYS(d.`os_valid_time`) = 1
        </if>
        <if test="day == 3"> <!-- 本月 -->
            AND DATE_FORMAT(d.`os_valid_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
            AND DATE_FORMAT(d.`os_valid_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day == 4"> <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(),'%Y%m'),DATE_FORMAT(d.`os_valid_time`, '%Y%m')) = 1
            AND
            PERIOD_DIFF(DATE_FORMAT(NOW(),'%Y%m'),DATE_FORMAT(d.`os_valid_time`,
            '%Y%m')) = 1
        </if>
    </select>
    </select>
    <select id="sumRecievedMoneyByUid" resultType="BigDecimal">
        SELECT SUM(d.`os_money`) FROM yeshi_ec_invite_order_subsidy d
        WHERE d.`os_uid` = #{uid} AND d.`os_state` = 3
        WHERE
        d.`os_uid` = #{uid} AND d.`os_state` = 3
        <if test="level != null">
            AND d.os_level = #{level}
        </if>
    </select>
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/order/HongBaoV2ServiceImpl.java
@@ -204,21 +204,21 @@
                        break;
                    case HongBaoV2.TYPE_YIJI:
                        userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
                                commonOrder.getPayment(), money,new BigDecimal(0), goodsCount, commonOrder.getState(),
                                commonOrder.getThirdCreateTime());
                        break;
                    case HongBaoV2.TYPE_ERJI:
                        userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,     commonOrder.getPayment(), money,
                        userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,     commonOrder.getPayment(), money,new BigDecimal(0),
                                goodsCount,  commonOrder.getState(), commonOrder.getThirdCreateTime());
                        break;
                    case HongBaoV2.TYPE_SHARE_YIJI:
                        userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
                                commonOrder.getPayment(), money,new BigDecimal(0), goodsCount, commonOrder.getState(),
                                commonOrder.getThirdCreateTime());
                        
                    case HongBaoV2.TYPE_SHARE_ERJI:
                        userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,     commonOrder.getPayment(), money,
                        userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,     commonOrder.getPayment(), money,new BigDecimal(0),
                                goodsCount,  commonOrder.getState(), commonOrder.getThirdCreateTime());
                        break;
                    }
fanli/src/main/java/com/yeshi/fanli/service/impl/order/InviteOrderSubsidyServiceImplV2.java
@@ -311,4 +311,9 @@
        return money;
    }
    @Override
    public List<InviteOrderSubsidy> listByOrderNoAndTypeAndUid(String orderNo, Integer type, Long uid) {
        return inviteOrderSubsidyMapper.listByOrderNoAndTypeAndUid(orderNo, type, uid);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/order/InviteOrderSubsidyService.java
@@ -21,6 +21,9 @@
    
    
    public List<InviteOrderSubsidy> listByOrderNoAndType(String orderNo, Integer type);
    public List<InviteOrderSubsidy> listByOrderNoAndTypeAndUid(String orderNo, Integer type,Long uid);
    /**
     * 查询补贴(加锁)
fanli/src/main/java/com/yeshi/fanli/service/manger/order/HongBaoV2AddManager.java
@@ -26,6 +26,7 @@
import com.yeshi.fanli.entity.order.CommonOrder;
import com.yeshi.fanli.entity.order.CommonOrderGoods;
import com.yeshi.fanli.entity.order.HongBaoOrder;
import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
import com.yeshi.fanli.exception.order.CommonOrderException;
import com.yeshi.fanli.exception.order.HongBaoException;
import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
@@ -171,59 +172,69 @@
             * 通知用户的返利情况
             */
//            if (!Constant.IS_TEST) {
                if (hasAdd) {
                    Iterator<Integer> its = notificationMap.keySet().iterator();
                    while (its.hasNext()) {
                        Integer t = its.next();
                        HongBaoV2 notify = notificationMap.get(t).getHongBaoV2();
                        CommonOrder commonOrder = notificationMap.get(t).getCommonOrder();
                        Long uid = notify.getUserInfo().getId();
                        BigDecimal money = notify.getMoney();
                        switch (t) {
                        case HongBaoV2.TYPE_ZIGOU:
                            userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, orderType,
                                    commonOrder.getPayment(), money, goodsCount, state,
                                    commonOrder.getThirdCreateTime());
            // if (!Constant.IS_TEST) {
            if (hasAdd) {
                // 获取订单补贴
                            break;
                        case HongBaoV2.TYPE_SHARE_GOODS:
                Iterator<Integer> its = notificationMap.keySet().iterator();
                while (its.hasNext()) {
                    Integer t = its.next();
                    HongBaoV2 notify = notificationMap.get(t).getHongBaoV2();
                    CommonOrder commonOrder = notificationMap.get(t).getCommonOrder();
                    Long uid = notify.getUserInfo().getId();
                            userOrderMsgNotificationService.orderShareStatistic(uid, orderId, orderType,
                                    commonOrder.getPayment(), money, goodsCount, state,
                                    commonOrder.getThirdCreateTime());
                            break;
                        case HongBaoV2.TYPE_YIJI:
                            userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                    commonOrder.getPayment(), money, goodsCount, state,
                                    commonOrder.getThirdCreateTime());
                            break;
                        case HongBaoV2.TYPE_ERJI:
                            userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                    commonOrder.getPayment(), money, goodsCount, state,
                                    commonOrder.getThirdCreateTime());
                            break;
                        case HongBaoV2.TYPE_SHARE_YIJI:
                            userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                    commonOrder.getPayment(), money, goodsCount, state,
                                    commonOrder.getThirdCreateTime());
                            break;
                        case HongBaoV2.TYPE_SHARE_ERJI:
                            userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                    commonOrder.getPayment(), money, goodsCount, state,
                                    commonOrder.getThirdCreateTime());
                            break;
                    List<InviteOrderSubsidy> subsidyList = inviteOrderSubsidyService.listByOrderNoAndTypeAndUid(orderId,
                            orderType, uid);
                    BigDecimal subsidy = new BigDecimal(0);
                    if (subsidyList != null)
                        for (InviteOrderSubsidy s : subsidyList) {
                            if (s.getState() != InviteOrderSubsidy.STATE_INVALID)
                                subsidy = subsidy.add(s.getOriginalMoney());
                        }
                    BigDecimal money = notify.getMoney();
                    switch (t) {
                    case HongBaoV2.TYPE_ZIGOU:
                        userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, orderType,
                                commonOrder.getPayment(), money, goodsCount, state, commonOrder.getThirdCreateTime());
                        break;
                    case HongBaoV2.TYPE_SHARE_GOODS:
                        userOrderMsgNotificationService.orderShareStatistic(uid, orderId, orderType,
                                commonOrder.getPayment(), money, goodsCount, state, commonOrder.getThirdCreateTime());
                        break;
                    case HongBaoV2.TYPE_YIJI:
                        userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                commonOrder.getPayment(), money, subsidy, goodsCount, state,
                                commonOrder.getThirdCreateTime());
                        break;
                    case HongBaoV2.TYPE_ERJI:
                        userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                commonOrder.getPayment(), money, subsidy, goodsCount, state,
                                commonOrder.getThirdCreateTime());
                        break;
                    case HongBaoV2.TYPE_SHARE_YIJI:
                        userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                commonOrder.getPayment(), money, subsidy, goodsCount, state,
                                commonOrder.getThirdCreateTime());
                        break;
                    case HongBaoV2.TYPE_SHARE_ERJI:
                        userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                commonOrder.getPayment(), money, subsidy, goodsCount, state,
                                commonOrder.getThirdCreateTime());
                        break;
                    }
//                }
                }
                // }
            }
            int resultCode = 0;