yujian
2019-09-25 fb5823c1408e5c06592350722f6b9e117580ca9a
2.0.1需求
14个文件已修改
1361 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java 165 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HongBaoV2CountMapper.java 286 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/homemodule/SpecialMapper.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/homemodule/Special.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/homemodule/SpecialMapper.xml 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2CountMapper.xml 602 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/count/HongBaoV2CountServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/count/HongBaoV2CountService.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/SpecialService.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/VersionUtil.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/jd/JDUtil.java 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java
@@ -21,12 +21,17 @@
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
import com.yeshi.fanli.entity.bus.homemodule.Special;
import com.yeshi.fanli.entity.dynamic.DynamicInfo;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService;
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
import com.yeshi.fanli.service.inter.homemodule.SpecialService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
import net.sf.json.JSONObject;
@@ -52,6 +57,9 @@
    @Resource
    private DynamicInfoService dynamicInfoService;
    @Resource
    private SpecialService specialService;
    /**
     * 动态商品列表
@@ -68,12 +76,20 @@
            return;
        }
        if (cid != null && cid == 5) {
            // 活动主题
            getSpecialList(acceptData, page, subId, out);
            return;
        }
        long count = 0;
        
        int platform = 1;
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
            platform = 2;
        }
        int version = Integer.parseInt(acceptData.getVersion());
        List<DynamicInfo> list = dynamicInfoService.queryV2(platform, version, (page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, cid,
                subId);
@@ -88,6 +104,155 @@
        data.put("list", getGson().toJson(list));
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     *  活动列表
     * @param acceptData
     * @param out
     */
    private void getSpecialList(AcceptData acceptData, Integer page, Long subId, PrintWriter out) {
        if (subId == null) {
            out.print(JsonUtil.loadFalseResult("分类id不能为空"));
            return;
        }
        // 平台区分
        int platformCode = Constant.getPlatformCode(acceptData.getPlatform());
        List<String> listKey = new ArrayList<String>();
        if (subId == 1) { // 淘宝
            listKey.add("special_channel_tb");
        } else if (subId == 2) { // 京东
            listKey.add("special_channel_jd");
        } else if (subId == 3) { // 拼多多
            listKey.add("special_channel_pdd");
        } else { // 全部
            listKey.add("special_channel_tb");
            listKey.add("special_channel_jd");
            listKey.add("special_channel_pdd");
        }
        List<Special> list = specialService.listByPlaceKeyList((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, listKey, platformCode,
                Integer.parseInt(acceptData.getVersion()));
        long time = System.currentTimeMillis();
        // 删除尚未启用的过期的
        for (int i = 0; i < list.size(); i++) {
            Special special = list.get(i);
            if (special.getState() == 1L) {
                list.remove(i--);
            } else {
                if (special.getStartTime() != null && special.getEndTime() != null)
                    special.setTimeTask(true);
                else
                    special.setTimeTask(false);
                if (special.isTimeTask()) {
                    if (time < special.getStartTime().getTime() || time > special.getEndTime().getTime()) {
                        list.remove(i--);
                    } else// 设置倒计时
                    {
                        special.setCountDownTime((special.getEndTime().getTime() - time) / 1000);
                    }
                }
                if (Constant.IS_TEST) {// 测试标签
                     List<ClientTextStyleVO> labels = new ArrayList<>();
                     labels.add(new ClientTextStyleVO("文章标签", "#FE0014"));
                     labels.add(new ClientTextStyleVO("标签内容", "#FE0014"));
                     special.setLabels(labels);
                }
            }
        }
        long count = specialService.countByPlaceKeyList( listKey, platformCode,    Integer.parseInt(acceptData.getVersion()));
        GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
        Gson gson = gsonBuilder.create();
        JSONObject data = new JSONObject();
        data.put("count", count);
        data.put("list", gson.toJson(list));
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 查询顶部分类
     *
     * @param acceptData
     * @param page
     * @param cid
     * @param out
     */
    @RequestMapping(value = "getClass", method = RequestMethod.POST)
    public void getClass(AcceptData acceptData, Integer cid, PrintWriter out) {
        // ios 只返回子集分类
        if (cid != null) {
            List<GoodsClass> list = new ArrayList<GoodsClass>();
            switch (cid) {
            case 1:
                list.add(new GoodsClass(0L, "今日单品"));
                list.addAll(DaTaoKeUtil.goodsClasses);
                break;
            case 2:
                break;
            case 3:
                break;
            case 4:
                break;
            case 5:
                break;
            default:
                break;
            }
            JSONObject data = new JSONObject();
            data.put("list", JsonUtil.getApiCommonGson().toJson(list));
            out.print(JsonUtil.loadTrueResult(data));
            return;
        }
        // Android 返回分类以及顶部数据
        List<GoodsClass> listSub = new ArrayList<GoodsClass>();
        listSub.add(new GoodsClass(0L, "今日单品"));
        listSub.addAll(DaTaoKeUtil.goodsClasses);
        GoodsClass menu1 = new GoodsClass(1L, "热销");
        menu1.setListSub(listSub);
        GoodsClass menu2 = new GoodsClass(2L, "推荐");
        menu2.setListSub(new ArrayList<GoodsClass>());
        GoodsClass menu3 = new GoodsClass(3L, "好店");
        menu3.setListSub(new ArrayList<GoodsClass>());
        GoodsClass menu4 = new GoodsClass(4L, "邀请");
        menu4.setListSub(new ArrayList<GoodsClass>());
        GoodsClass menu5 = new GoodsClass(5L, "活动");
        List<GoodsClass> sub5 = new ArrayList<GoodsClass>();
        sub5.add(new GoodsClass(0L, "全部"));
        sub5.add(new GoodsClass(1L, "淘宝"));
        sub5.add(new GoodsClass(2L, "京东"));
        sub5.add(new GoodsClass(3L, "拼多多"));
        menu5.setListSub(sub5);
        List<GoodsClass> list = new ArrayList<GoodsClass>();
        list.add(menu1);
        list.add(menu5);
        list.add(menu2);
        list.add(menu3);
        list.add(menu4);
        JSONObject data = new JSONObject();
        data.put("list", JsonUtil.getApiCommonGson().toJson(list));
        out.print(JsonUtil.loadTrueResult(data));
    }
    
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java
@@ -31,6 +31,7 @@
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
import com.yeshi.fanli.service.inter.goods.recommend.HomeRecommendGoodsService;
import com.yeshi.fanli.service.inter.goods.recommend.RecommendGoodsDeleteHistoryService;
import com.yeshi.fanli.service.inter.homemodule.DeviceSexService;
@@ -125,6 +126,11 @@
    @Resource
    private DaTaoKeGoodsService daTaoKeGoodsService;
    @Resource
    private HongBaoV2CountService hongBaoV2CountService;
    /**
     * 新版推荐专题管理(1.5.3)
@@ -761,4 +767,44 @@
            out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 获取专题渠道活动
     *
     * @param acceptData
     * @param uid
     * @param callback
     * @param out
     */
    @RequestMapping(value = "getGuide")
    public void getGuide(AcceptData acceptData, Long uid, PrintWriter out) {
        String tips = null;
        if (uid == null || uid <= 0) {
            tips = configService.get("tip_guide_new_user");
        } else {
            long rebateOrder = hongBaoV2CountService.countRebateOrder(uid);
            long shareOrInviteOrder = hongBaoV2CountService.countShareOrInviteOrder(uid);
            if (rebateOrder <= 0 && shareOrInviteOrder <= 0) {
                // 新人版
                tips = configService.get("tip_guide_new_user");
            } else if (rebateOrder > 0 && shareOrInviteOrder <= 0) {
                // 省钱版
                tips = configService.get("tip_guide_save_money");
            } else if (shareOrInviteOrder > 0) {
                // 赚钱版
                tips = configService.get("tip_guide_share_invite");
            } else {
                // 熟客版
            }
        }
        if (StringUtil.isNullOrEmpty(tips)) {
            out.print(JsonUtil.loadFalseResult("暂无提示"));
            return;
        }
        JSONObject data = JSONObject.fromObject(tips);
        out.print(JsonUtil.loadTrueResult(data));
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HongBaoV2CountMapper.java
@@ -1,137 +1,151 @@
package com.yeshi.fanli.dao.mybatis;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.vo.order.HongBaoV2VO;
public interface HongBaoV2CountMapper {
    /**
     * 统计历史总到账金额
     * @param uid
     * @param state
     * @return
     */
    BigDecimal countMoneyByUidAndState(@Param("uid")Long uid, @Param("state") Integer state);
    /**
     * 统计历史红包数量
     * @param uid
     * @param state
     * @return
     */
    Integer countNumberByUidAndState(@Param("uid")Long uid, @Param("state") Integer state);
    /**
     * 统计用户总的红包数量
     * @param uid
     * @return
     */
    Long countNumberByUid(@Param("uid")Long uid);
    /**
     * 统计总金额
     * @param channel 渠道
     * @param type
     * @param state
     * @param years
     * @param startTime
     * @param endTime
     * @return
     */
    List<Map<String, Object>> countHongBaoMoney(@Param("channel")String channel, @Param("dateType")Integer dateType,
            @Param("state") Integer state, @Param("year") String year,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
    /**
     * 统计总个数
     * @param channel 渠道
     * @param type
     * @param state
     * @param years
     * @param startTime
     * @param endTime
     * @return
     */
    List<Map<String, Object>> countHongBaoNum(@Param("channel")String channel, @Param("dateType")Integer dateType,
            @Param("state") Integer state, @Param("year") String year,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
    /**
     * 统计总个数
     * @param channel 渠道
     * @param type
     * @param state
     * @param years
     * @param startTime
     * @param endTime
     * @return
     */
    List<Map<String, Object>> countHongBaoType(@Param("dateType")Integer dateType,
            @Param("type") Integer type, @Param("year") String year,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
    /**
     * 统计总个数
     * @param channel 渠道
     * @param type
     * @param state
     * @param years
     * @param startTime
     * @param endTime
     * @return
     */
    List<Map<String, Object>> countHongBaoTotalNum(@Param("dateType")Integer dateType, @Param("year") String year,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
    // 累计提成订单数量(包含无效订单)
    int getTotalTiChengCount(Long uid);
    /**
     * 统计未失效订单数量
     * @param uid
     * @param dateType
     * @return
     */
    long countValidNumberByUid(@Param("uid") Long uid, @Param("dateType")Integer dateType);
    /**
     * 统计未到账
     * @param uid
     * @return
     */
    BigDecimal countWillGetMoneyByUid(@Param("uid") Long uid);
    Date getLastHongBaoTime(@Param("uid") Long uid);
    /**
     * 根据渠道 统计新增用户24小时内产生的订单数量
     *
     * @param channel
     * @return
     */
    List<Map<String, Object>> count24HOderByChannel(@Param("channel") String channel, @Param("type") Integer type,
            @Param("years") String years, @Param("startTime") String startTime, @Param("endTime") String endTime);
    List<HongBaoV2VO> listShareAndInviteMoney(@Param("start") long start, @Param("count") int count,
            @Param("date") String date);
    /**
     * 统计奖励券总金额
     * @return
     */
    BigDecimal countRebateCouponMoney();
package com.yeshi.fanli.dao.mybatis;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.vo.order.HongBaoV2VO;
public interface HongBaoV2CountMapper {
    /**
     * 统计历史总到账金额
     * @param uid
     * @param state
     * @return
     */
    BigDecimal countMoneyByUidAndState(@Param("uid")Long uid, @Param("state") Integer state);
    /**
     * 统计历史红包数量
     * @param uid
     * @param state
     * @return
     */
    Integer countNumberByUidAndState(@Param("uid")Long uid, @Param("state") Integer state);
    /**
     * 统计用户总的红包数量
     * @param uid
     * @return
     */
    Long countNumberByUid(@Param("uid")Long uid);
    /**
     * 统计总金额
     * @param channel 渠道
     * @param type
     * @param state
     * @param years
     * @param startTime
     * @param endTime
     * @return
     */
    List<Map<String, Object>> countHongBaoMoney(@Param("channel")String channel, @Param("dateType")Integer dateType,
            @Param("state") Integer state, @Param("year") String year,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
    /**
     * 统计总个数
     * @param channel 渠道
     * @param type
     * @param state
     * @param years
     * @param startTime
     * @param endTime
     * @return
     */
    List<Map<String, Object>> countHongBaoNum(@Param("channel")String channel, @Param("dateType")Integer dateType,
            @Param("state") Integer state, @Param("year") String year,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
    /**
     * 统计总个数
     * @param channel 渠道
     * @param type
     * @param state
     * @param years
     * @param startTime
     * @param endTime
     * @return
     */
    List<Map<String, Object>> countHongBaoType(@Param("dateType")Integer dateType,
            @Param("type") Integer type, @Param("year") String year,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
    /**
     * 统计总个数
     * @param channel 渠道
     * @param type
     * @param state
     * @param years
     * @param startTime
     * @param endTime
     * @return
     */
    List<Map<String, Object>> countHongBaoTotalNum(@Param("dateType")Integer dateType, @Param("year") String year,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
    // 累计提成订单数量(包含无效订单)
    int getTotalTiChengCount(Long uid);
    /**
     * 统计未失效订单数量
     * @param uid
     * @param dateType
     * @return
     */
    long countValidNumberByUid(@Param("uid") Long uid, @Param("dateType")Integer dateType);
    /**
     * 统计未到账
     * @param uid
     * @return
     */
    BigDecimal countWillGetMoneyByUid(@Param("uid") Long uid);
    Date getLastHongBaoTime(@Param("uid") Long uid);
    /**
     * 根据渠道 统计新增用户24小时内产生的订单数量
     *
     * @param channel
     * @return
     */
    List<Map<String, Object>> count24HOderByChannel(@Param("channel") String channel, @Param("type") Integer type,
            @Param("years") String years, @Param("startTime") String startTime, @Param("endTime") String endTime);
    List<HongBaoV2VO> listShareAndInviteMoney(@Param("start") long start, @Param("count") int count,
            @Param("date") String date);
    /**
     * 统计奖励券总金额
     * @return
     */
    BigDecimal countRebateCouponMoney();
    /**
     * 统计返利订单
     * @param uid
     * @return
     */
    long countRebateOrder(@Param("uid") Long uid);
    /**
     * 统计分享和邀请订单
     * @param uid
     * @return
     */
    long countShareOrInviteOrder(@Param("uid") Long uid);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/homemodule/SpecialMapper.java
@@ -113,4 +113,19 @@
    List<Special> listByPlaceKey(@Param("placeKey") String placeKey, @Param("sex")Integer sex
            , @Param("platform") Integer platform, @Param("versionCode") Integer versionCode);
    
    /**
     * 根据多个位置标识查询
     * @param list
     * @param sex
     * @param platform
     * @param versionCode
     * @return
     */
    List<Special> listByPlaceKeyList(@Param("start")long start, @Param("count")int count,@Param("list") List<String> list, @Param("sex")Integer sex
            , @Param("platform") Integer platform, @Param("versionCode") Integer versionCode);
    long countByPlaceKeyList(@Param("list") List<String> list, @Param("sex")Integer sex
            , @Param("platform") Integer platform, @Param("versionCode") Integer versionCode);
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/homemodule/Special.java
@@ -2,12 +2,14 @@
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
import com.google.gson.annotations.Expose;
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
/**
 * 专题管理
@@ -161,6 +163,10 @@
    @Expose
    private long countDownTime;//倒计时
    @Expose
    private List<ClientTextStyleVO> labels; //标签
    public long getCountDownTime() {
        return countDownTime;
    }
@@ -425,5 +431,13 @@
    public void setEndTime_str(String endTime_str) {
        this.endTime_str = endTime_str;
    }
    public List<ClientTextStyleVO> getLabels() {
        return labels;
    }
    public void setLabels(List<ClientTextStyleVO> labels) {
        this.labels = labels;
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/homemodule/SpecialMapper.xml
@@ -377,7 +377,66 @@
            <if test="platform == 2">
              AND IF(sp.`b_min_ios_version_code` IS NOT NULL, #{versionCode}<![CDATA[>=]]> sp.b_min_ios_version_code,TRUE)
            </if>
        <include refid="Sex_Screen" />
            <include refid="Sex_Screen" />
        <if test="sex == null"> ORDER BY sp.`b_orderby`</if>
    </select>
    <select id="listByPlaceKeyList" resultMap="BaseResultMap">
        SELECT sp.*,c.`cd_bottom_picture` FROM `yeshi_ec_special` sp
        RIGHT JOIN
        (SELECT c.* FROM yeshi_ec_special_card c
        LEFT JOIN
        `yeshi_ec_special_place` pc ON pc.`sp_id` = c.`cd_place_id`
        WHERE
        c.`cd_state` = 0
        AND IF(c.`cd_start_time` IS NULL,TRUE,
        c.`cd_start_time`<![CDATA[<=]]>NOW())
        AND IF(c.`cd_end_time` IS NULL,TRUE,c.`cd_end_time`<![CDATA[>=]]>NOW())
        AND pc.`sp_key` in
            <foreach collection="list" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        )c ON sp.`b_card_id` = c.`cd_id`
        WHERE sp.`b_state` = 0
            AND IF(sp.b_start_time IS NULL,TRUE, sp.b_start_time<![CDATA[<=]]> NOW())
              AND IF(sp.b_end_time IS NULL,TRUE, sp.b_end_time <![CDATA[>=]]> NOW())
              <if test="platform == 1">
              AND IF(sp.`b_min_android_version_code` IS NOT NULL, #{versionCode}<![CDATA[>=]]> sp.b_min_android_version_code,TRUE)
            </if>
            <if test="platform == 2">
              AND IF(sp.`b_min_ios_version_code` IS NOT NULL, #{versionCode}<![CDATA[>=]]> sp.b_min_ios_version_code,TRUE)
            </if>
            <include refid="Sex_Screen" />
        <if test="sex == null"> ORDER BY sp.`b_orderby`</if>
        LIMIT ${start},${count}
    </select>
    <select id="countByPlaceKeyList"  resultType="Long">
        SELECT IFNULL(COUNT(sp.`b_id`),0) FROM `yeshi_ec_special` sp
        RIGHT JOIN
        (SELECT c.* FROM yeshi_ec_special_card c
        LEFT JOIN
        `yeshi_ec_special_place` pc ON pc.`sp_id` = c.`cd_place_id`
        WHERE
        c.`cd_state` = 0
        AND IF(c.`cd_start_time` IS NULL,TRUE,
        c.`cd_start_time`<![CDATA[<=]]>NOW())
        AND IF(c.`cd_end_time` IS NULL,TRUE,c.`cd_end_time`<![CDATA[>=]]>NOW())
        AND pc.`sp_key` in
            <foreach collection="list" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        )c ON sp.`b_card_id` = c.`cd_id`
        WHERE sp.`b_state` = 0
            AND IF(sp.b_start_time IS NULL,TRUE, sp.b_start_time<![CDATA[<=]]> NOW())
              AND IF(sp.b_end_time IS NULL,TRUE, sp.b_end_time <![CDATA[>=]]> NOW())
              <if test="platform == 1">
              AND IF(sp.`b_min_android_version_code` IS NOT NULL, #{versionCode}<![CDATA[>=]]> sp.b_min_android_version_code,TRUE)
            </if>
            <if test="platform == 2">
              AND IF(sp.`b_min_ios_version_code` IS NOT NULL, #{versionCode}<![CDATA[>=]]> sp.b_min_ios_version_code,TRUE)
            </if>
            <include refid="Sex_Screen" />
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2CountMapper.xml
@@ -1,295 +1,307 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.HongBaoV2CountMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.vo.order.HongBaoV2VO">
        <id column="hb_id" property="id" jdbcType="BIGINT" />
        <result column="hb_urank" property="urank" jdbcType="INTEGER" />
        <result column="hb_money" property="money" jdbcType="DECIMAL" />
        <result column="hb_type" property="type" jdbcType="INTEGER" />
        <result column="hb_state" property="state" jdbcType="INTEGER" />
        <result column="hb_version" property="version" jdbcType="INTEGER" />
        <result column="hb_beizhu" property="beizhu" jdbcType="VARCHAR" />
        <result column="hb_pre_get_time" property="preGetTime" jdbcType="TIMESTAMP" />
        <result column="hb_get_time" property="getTime" jdbcType="TIMESTAMP" />
        <result column="hb_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="hb_update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="totalMoney" property="totalMoney" jdbcType="DECIMAL" />
        <association property="userInfo" column="hb_uid"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="hb_uid" property="id" jdbcType="BIGINT" />
        </association>
        <association property="parent" column="hb_pid"
            javaType="com.yeshi.fanli.entity.bus.user.HongBaoV2">
            <id column="hb_pid" property="id" jdbcType="BIGINT" />
        </association>
    </resultMap>
    <sql id="Column_DateType">
        <if test="dateType == 1">
            DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d') AS 'showDate'
        </if>
        <if test="dateType == 2">
            DATE_FORMAT(t.`hb_create_time`,'%m') AS 'showDate'
        </if>
        <if test="dateType == 3">
            DATE_FORMAT(t.`hb_create_time`,'%Y') AS 'showDate'
        </if>
    </sql>
    <sql id="Count_Select_DateType">
        <if test="startTime != null and startTime != '' ">
            AND DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
        </if>
        <if test="endTime != null and endTime != '' ">
            AND DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
        </if>
        <if test="year != null and year != '' ">
            AND DATE_FORMAT(t.`hb_create_time`,'%Y') = '${year}'
        </if>
    </sql>
    <sql id="Count_Group_DateType">
        <if test="dateType == 1">
            GROUP BY DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d')
        </if>
        <if test="dateType == 2">
            GROUP BY DATE_FORMAT(t.`hb_create_time`,'%Y-%m')
        </if>
        <if test="dateType == 3">
            GROUP BY DATE_FORMAT(t.`hb_create_time`,'%Y')
        </if>
    </sql>
    <sql id="Count_Select_State">
        <if test="state != null and state == 1">  <!-- 未到账 -->
            AND (t.hb_state = 1 or t.hb_state = 2)
        </if>
        <if test="state != null and state == 2"> <!-- 已到账 -->
            AND t.hb_state = 3
        </if>
        <if test="state != null and state == 3">  <!-- 红包已失效 -->
            AND t.hb_state =4
        </if>
    </sql>
    <sql id="Count_Select_Type">
        <if test="type != null and type == 1"> <!-- 自购订单 -->
            AND (t.hb_type =1 or t.hb_type =2)
        </if>
        <if test="type != null and type == 2"> <!-- 分享订单 -->
            AND t.`hb_type` = 20
        </if>
        <if test="type != null and type == 3"> <!-- 邀请订单 -->
            AND (t.`hb_type` = 5 OR t.`hb_type` = 6 OR t.`hb_type` = 7 OR
            t.`hb_type` = 21 OR t.`hb_type` = 22)
        </if>
    </sql>
    <select id="countHongBaoMoney" resultType="java.util.HashMap">
        SELECT CAST(SUM(t.`hb_money`)AS DECIMAL(19,2)) AS showValue,
        <include refid="Column_DateType" />
        FROM yeshi_ec_hongbao_v2 t
        <if test="channel != null and  channel != 'all' ">
            LEFT JOIN (SELECT a.`lua_uid` AS uid FROM
            `yeshi_ec_log_user_active` a WHERE a.`lua_channel`='${channel}' GROUP
            BY a.`lua_uid`) a ON t.`hb_uid`=a.uid
        </if>
        WHERE t.`hb_uid` IS NOT NULL AND (t.`hb_type`=1 OR t.`hb_type`=20)
        <include refid="Count_Select_DateType" />
        <include refid="Count_Select_State" />
        <if test="channel != null and  channel != 'all' ">
            AND a.uid is not null
        </if>
        <include refid="Count_Group_DateType" />
        ORDER BY t.`hb_create_time`
    </select>
    <select id="countHongBaoNum" resultType="java.util.HashMap">
        SELECT COUNT(t.`hb_id`)AS showValue,
        <include refid="Column_DateType" />
        FROM yeshi_ec_hongbao_v2 t
        <if test="channel != null and  channel != 'all' ">
            LEFT JOIN (SELECT a.`lua_uid` AS uid FROM
            `yeshi_ec_log_user_active` a WHERE a.`lua_channel`='${channel}' GROUP
            BY a.`lua_uid`) a ON t.`hb_uid`=a.uid
        </if>
        WHERE t.`hb_uid` IS NOT NULL AND (t.`hb_type`=1 OR t.`hb_type`=20)
        <include refid="Count_Select_DateType" />
        <include refid="Count_Select_State" />
        <if test="channel != null and  channel != 'all' ">
            AND a.uid is not null
        </if>
        <include refid="Count_Group_DateType" />
        ORDER BY t.`hb_create_time`
    </select>
    <select id="countNumberByUid" resultType="java.lang.Long">
        select count(hb_id) from yeshi_ec_hongbao_v2 where hb_uid=#{0}
    </select>
    <select id="countHongBaoType" resultType="java.util.HashMap">
        SELECT COUNT(t.`hb_id`)AS showValue,
        <include refid="Column_DateType" />
        FROM yeshi_ec_hongbao_v2 t
        WHERE t.`hb_uid` IS NOT NULL
        <include refid="Count_Select_DateType" />
        <include refid="Count_Select_Type" />
        <include refid="Count_Group_DateType" />
        ORDER BY t.`hb_create_time`
    </select>
    <select id="countHongBaoTotalNum" resultType="java.util.HashMap">
        SELECT COUNT(t.`hb_id`)AS showValue,
        <include refid="Column_DateType" />
        FROM yeshi_ec_hongbao_v2 t
        WHERE t.`hb_uid` IS NOT NULL AND t.`hb_type` not in(1,3,4)
        <include refid="Count_Select_DateType" />
        <include refid="Count_Group_DateType" />
        ORDER BY t.`hb_create_time`
    </select>
    <select id="countMoneyByUidAndState" resultType="java.math.BigDecimal">
        SELECT CAST(SUM(hb.`hb_money`)AS DECIMAL(19,2))
        FROM `yeshi_ec_hongbao_v2` hb
        WHERE hb.`hb_uid` = #{uid}
        <if test="state != null">
            AND hb.`hb_state` = #{state}
        </if>
    </select>
    <select id="countNumberByUidAndState" resultType="java.lang.Integer">
        SELECT COALESCE(count(hb_id),0) FROM yeshi_ec_hongbao_v2
        WHERE hb_uid =
        #{uid}
        <if test="state != null">
            AND hb_state = #{state}
        </if>
    </select>
    <select id="getTotalTiChengCount" resultType="java.lang.Integer"
        parameterType="java.lang.Long">
        SELECT count(*) FROM `yeshi_ec_hongbao_v2` h
        WHERE
        h.`hb_uid`=#{0}
        AND (h.`hb_type`=20 OR h.`hb_type`=21 OR h.`hb_type`=22 OR h.`hb_type`=6
        OR h.`hb_type`=7)
    </select>
    <select id="countValidNumberByUid" resultType="java.lang.Long">
        <!--统计有效订单数量 -->
        SELECT COALESCE(count(hb.hb_id),0) FROM `yeshi_ec_hongbao_v2` hb
        WHERE
        hb.hb_uid =#{uid}
        AND hb.hb_type not in (3,4)
        AND <![CDATA[hb.hb_state <> 4]]>
        <if test="dateType != null and dateType == 1">
            AND TO_DAYS(FROM_UNIXTIME(hb.`hb_create_time`/1000)) =
            TO_DAYS(NOW())
        </if>
        <if test="dateType != null and dateType == 2">
            AND DATE_FORMAT(
            FROM_UNIXTIME(hb.`hb_create_time`/1000),'%Y%m' ) =
            DATE_FORMAT( CURDATE( ) , '%Y%m' )
        </if>
    </select>
    <select id="countWillGetMoneyByUid" resultType="java.math.BigDecimal">
        SELECT CAST(SUM(hb.`hb_money`)AS DECIMAL(19,2))
        FROM `yeshi_ec_hongbao_v2` hb
        WHERE hb.`hb_uid` = #{uid} AND hb.`hb_state`
        in (1,2)
    </select>
    <select id="getLastHongBaoTime" resultType="java.util.Date">
        <!-- 最近一次下单时间 -->
        SELECT h.`hb_create_time` FROM yeshi_ec_hongbao_v2 h WHERE h.`hb_type`
        IN(1,2) <![CDATA[AND h.hb_state <>4]]>
        AND h.`hb_uid` = #{uid}
        ORDER BY h.`hb_create_time` DESC
        LIMIT 1;
    </select>
    <select id="count24HOderByChannel" resultType="java.util.HashMap">
        SELECT <!-- COALESCE(SUM(b.money*2),0) AS 'commision', -->
        COALESCE(COUNT(b.hb_id),0) AS 'showValue',
        <!-- COALESCE(SUM(b.payMoney),0) AS 'payMoney', -->
        <if test="type == 1">
            FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS
            'showDate'
        </if>
        <if test="type == 2">
            FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'showDate'
        </if>
        <if test="type == 3">
            FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'showDate'
        </if>
        FROM
        (
        SELECT h.* FROM yeshi_ec_hongbao_v2 h
        LEFT JOIN (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active` a
        WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a
        ON a.uid=h.`hb_uid` WHERE a.uid IS NOT NULL AND (h.`hb_type`=1 OR
        h.`hb_type`=20)
        ) b
        LEFT JOIN yeshi_ec_user u ON u.`id`=b.hb_uid
        WHERE <![CDATA[ b.hb_create_time<FROM_UNIXTIME((u.`createtime`+1000*60*60*24)/1000,'%Y-%m-%d %h:%m:%s')]]>
        <if test="startTime != null and startTime != '' ">
            AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
        </if>
        <if test="endTime != null and endTime != '' ">
            AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]>
            '${endTime}'
        </if>
        <if test="years != null and years != '' ">
            AND FROM_UNIXTIME(u.`createtime`/1000,'%Y') = '${years}'
        </if>
        <if test="type == 1">
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')
        </if>
        <if test="type == 2">
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m')
        </if>
        <if test="type == 3">
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y')
        </if>
        ORDER BY u.`createtime`
    </select>
    <select id="listShareAndInviteMoney" resultMap="BaseResultMap">
        SELECT IFNULL(SUM(h.`hb_money`),0) as totalMoney,h.*
        FROM
        `yeshi_ec_hongbao_v2` h
        WHERE h.hb_state <![CDATA[<>]]>4
        AND DATE_FORMAT(h.hb_create_time, '%Y-%m-%d' )= #{date}
        AND (
        h.`hb_type` =5 OR h.`hb_type` =6 OR h.`hb_type` =7 OR h.`hb_type` =20
        OR h.`hb_type` =21 OR h.`hb_type` =22 )
        GROUP BY h.`hb_uid`
        ORDER BY
        totalMoney DESC
        LIMIT ${start},${count}
    </select>
    <select id="countRebateCouponMoney" resultType="java.math.BigDecimal">
        SELECT IFNULL(SUM(h.`hb_money`),0) FROM `yeshi_ec_hongbao_v2` h
        where h.`hb_type` = 10
    </select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.HongBaoV2CountMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.vo.order.HongBaoV2VO">
        <id column="hb_id" property="id" jdbcType="BIGINT" />
        <result column="hb_urank" property="urank" jdbcType="INTEGER" />
        <result column="hb_money" property="money" jdbcType="DECIMAL" />
        <result column="hb_type" property="type" jdbcType="INTEGER" />
        <result column="hb_state" property="state" jdbcType="INTEGER" />
        <result column="hb_version" property="version" jdbcType="INTEGER" />
        <result column="hb_beizhu" property="beizhu" jdbcType="VARCHAR" />
        <result column="hb_pre_get_time" property="preGetTime" jdbcType="TIMESTAMP" />
        <result column="hb_get_time" property="getTime" jdbcType="TIMESTAMP" />
        <result column="hb_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="hb_update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="totalMoney" property="totalMoney" jdbcType="DECIMAL" />
        <association property="userInfo" column="hb_uid"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="hb_uid" property="id" jdbcType="BIGINT" />
        </association>
        <association property="parent" column="hb_pid"
            javaType="com.yeshi.fanli.entity.bus.user.HongBaoV2">
            <id column="hb_pid" property="id" jdbcType="BIGINT" />
        </association>
    </resultMap>
    <sql id="Column_DateType">
        <if test="dateType == 1">
            DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d') AS 'showDate'
        </if>
        <if test="dateType == 2">
            DATE_FORMAT(t.`hb_create_time`,'%m') AS 'showDate'
        </if>
        <if test="dateType == 3">
            DATE_FORMAT(t.`hb_create_time`,'%Y') AS 'showDate'
        </if>
    </sql>
    <sql id="Count_Select_DateType">
        <if test="startTime != null and startTime != '' ">
            AND DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
        </if>
        <if test="endTime != null and endTime != '' ">
            AND DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
        </if>
        <if test="year != null and year != '' ">
            AND DATE_FORMAT(t.`hb_create_time`,'%Y') = '${year}'
        </if>
    </sql>
    <sql id="Count_Group_DateType">
        <if test="dateType == 1">
            GROUP BY DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d')
        </if>
        <if test="dateType == 2">
            GROUP BY DATE_FORMAT(t.`hb_create_time`,'%Y-%m')
        </if>
        <if test="dateType == 3">
            GROUP BY DATE_FORMAT(t.`hb_create_time`,'%Y')
        </if>
    </sql>
    <sql id="Count_Select_State">
        <if test="state != null and state == 1">  <!-- 未到账 -->
            AND (t.hb_state = 1 or t.hb_state = 2)
        </if>
        <if test="state != null and state == 2"> <!-- 已到账 -->
            AND t.hb_state = 3
        </if>
        <if test="state != null and state == 3">  <!-- 红包已失效 -->
            AND t.hb_state =4
        </if>
    </sql>
    <sql id="Count_Select_Type">
        <if test="type != null and type == 1"> <!-- 自购订单 -->
            AND (t.hb_type =1 or t.hb_type =2)
        </if>
        <if test="type != null and type == 2"> <!-- 分享订单 -->
            AND t.`hb_type` = 20
        </if>
        <if test="type != null and type == 3"> <!-- 邀请订单 -->
            AND (t.`hb_type` = 5 OR t.`hb_type` = 6 OR t.`hb_type` = 7 OR
            t.`hb_type` = 21 OR t.`hb_type` = 22)
        </if>
    </sql>
    <select id="countHongBaoMoney" resultType="java.util.HashMap">
        SELECT CAST(SUM(t.`hb_money`)AS DECIMAL(19,2)) AS showValue,
        <include refid="Column_DateType" />
        FROM yeshi_ec_hongbao_v2 t
        <if test="channel != null and  channel != 'all' ">
            LEFT JOIN (SELECT a.`lua_uid` AS uid FROM
            `yeshi_ec_log_user_active` a WHERE a.`lua_channel`='${channel}' GROUP
            BY a.`lua_uid`) a ON t.`hb_uid`=a.uid
        </if>
        WHERE t.`hb_uid` IS NOT NULL AND (t.`hb_type`=1 OR t.`hb_type`=20)
        <include refid="Count_Select_DateType" />
        <include refid="Count_Select_State" />
        <if test="channel != null and  channel != 'all' ">
            AND a.uid is not null
        </if>
        <include refid="Count_Group_DateType" />
        ORDER BY t.`hb_create_time`
    </select>
    <select id="countHongBaoNum" resultType="java.util.HashMap">
        SELECT COUNT(t.`hb_id`)AS showValue,
        <include refid="Column_DateType" />
        FROM yeshi_ec_hongbao_v2 t
        <if test="channel != null and  channel != 'all' ">
            LEFT JOIN (SELECT a.`lua_uid` AS uid FROM
            `yeshi_ec_log_user_active` a WHERE a.`lua_channel`='${channel}' GROUP
            BY a.`lua_uid`) a ON t.`hb_uid`=a.uid
        </if>
        WHERE t.`hb_uid` IS NOT NULL AND (t.`hb_type`=1 OR t.`hb_type`=20)
        <include refid="Count_Select_DateType" />
        <include refid="Count_Select_State" />
        <if test="channel != null and  channel != 'all' ">
            AND a.uid is not null
        </if>
        <include refid="Count_Group_DateType" />
        ORDER BY t.`hb_create_time`
    </select>
    <select id="countNumberByUid" resultType="java.lang.Long">
        select count(hb_id) from yeshi_ec_hongbao_v2 where hb_uid=#{0}
    </select>
    <select id="countHongBaoType" resultType="java.util.HashMap">
        SELECT COUNT(t.`hb_id`)AS showValue,
        <include refid="Column_DateType" />
        FROM yeshi_ec_hongbao_v2 t
        WHERE t.`hb_uid` IS NOT NULL
        <include refid="Count_Select_DateType" />
        <include refid="Count_Select_Type" />
        <include refid="Count_Group_DateType" />
        ORDER BY t.`hb_create_time`
    </select>
    <select id="countHongBaoTotalNum" resultType="java.util.HashMap">
        SELECT COUNT(t.`hb_id`)AS showValue,
        <include refid="Column_DateType" />
        FROM yeshi_ec_hongbao_v2 t
        WHERE t.`hb_uid` IS NOT NULL AND t.`hb_type` not in(1,3,4)
        <include refid="Count_Select_DateType" />
        <include refid="Count_Group_DateType" />
        ORDER BY t.`hb_create_time`
    </select>
    <select id="countMoneyByUidAndState" resultType="java.math.BigDecimal">
        SELECT CAST(SUM(hb.`hb_money`)AS DECIMAL(19,2))
        FROM `yeshi_ec_hongbao_v2` hb
        WHERE hb.`hb_uid` = #{uid}
        <if test="state != null">
            AND hb.`hb_state` = #{state}
        </if>
    </select>
    <select id="countNumberByUidAndState" resultType="java.lang.Integer">
        SELECT COALESCE(count(hb_id),0) FROM yeshi_ec_hongbao_v2
        WHERE hb_uid =
        #{uid}
        <if test="state != null">
            AND hb_state = #{state}
        </if>
    </select>
    <select id="getTotalTiChengCount" resultType="java.lang.Integer"
        parameterType="java.lang.Long">
        SELECT count(*) FROM `yeshi_ec_hongbao_v2` h
        WHERE
        h.`hb_uid`=#{0}
        AND (h.`hb_type`=20 OR h.`hb_type`=21 OR h.`hb_type`=22 OR h.`hb_type`=6
        OR h.`hb_type`=7)
    </select>
    <select id="countValidNumberByUid" resultType="java.lang.Long">
        <!--统计有效订单数量 -->
        SELECT COALESCE(count(hb.hb_id),0) FROM `yeshi_ec_hongbao_v2` hb
        WHERE
        hb.hb_uid =#{uid}
        AND hb.hb_type not in (3,4)
        AND <![CDATA[hb.hb_state <> 4]]>
        <if test="dateType != null and dateType == 1">
            AND TO_DAYS(FROM_UNIXTIME(hb.`hb_create_time`/1000)) =
            TO_DAYS(NOW())
        </if>
        <if test="dateType != null and dateType == 2">
            AND DATE_FORMAT(
            FROM_UNIXTIME(hb.`hb_create_time`/1000),'%Y%m' ) =
            DATE_FORMAT( CURDATE( ) , '%Y%m' )
        </if>
    </select>
    <select id="countWillGetMoneyByUid" resultType="java.math.BigDecimal">
        SELECT CAST(SUM(hb.`hb_money`)AS DECIMAL(19,2))
        FROM `yeshi_ec_hongbao_v2` hb
        WHERE hb.`hb_uid` = #{uid} AND hb.`hb_state`
        in (1,2)
    </select>
    <select id="getLastHongBaoTime" resultType="java.util.Date">
        <!-- 最近一次下单时间 -->
        SELECT h.`hb_create_time` FROM yeshi_ec_hongbao_v2 h WHERE h.`hb_type`
        IN(1,2) <![CDATA[AND h.hb_state <>4]]>
        AND h.`hb_uid` = #{uid}
        ORDER BY h.`hb_create_time` DESC
        LIMIT 1;
    </select>
    <select id="count24HOderByChannel" resultType="java.util.HashMap">
        SELECT <!-- COALESCE(SUM(b.money*2),0) AS 'commision', -->
        COALESCE(COUNT(b.hb_id),0) AS 'showValue',
        <!-- COALESCE(SUM(b.payMoney),0) AS 'payMoney', -->
        <if test="type == 1">
            FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS
            'showDate'
        </if>
        <if test="type == 2">
            FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'showDate'
        </if>
        <if test="type == 3">
            FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'showDate'
        </if>
        FROM
        (
        SELECT h.* FROM yeshi_ec_hongbao_v2 h
        LEFT JOIN (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active` a
        WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a
        ON a.uid=h.`hb_uid` WHERE a.uid IS NOT NULL AND (h.`hb_type`=1 OR
        h.`hb_type`=20)
        ) b
        LEFT JOIN yeshi_ec_user u ON u.`id`=b.hb_uid
        WHERE <![CDATA[ b.hb_create_time<FROM_UNIXTIME((u.`createtime`+1000*60*60*24)/1000,'%Y-%m-%d %h:%m:%s')]]>
        <if test="startTime != null and startTime != '' ">
            AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
        </if>
        <if test="endTime != null and endTime != '' ">
            AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]>
            '${endTime}'
        </if>
        <if test="years != null and years != '' ">
            AND FROM_UNIXTIME(u.`createtime`/1000,'%Y') = '${years}'
        </if>
        <if test="type == 1">
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')
        </if>
        <if test="type == 2">
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m')
        </if>
        <if test="type == 3">
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y')
        </if>
        ORDER BY u.`createtime`
    </select>
    <select id="listShareAndInviteMoney" resultMap="BaseResultMap">
        SELECT IFNULL(SUM(h.`hb_money`),0) as totalMoney,h.*
        FROM
        `yeshi_ec_hongbao_v2` h
        WHERE h.hb_state <![CDATA[<>]]>4
        AND DATE_FORMAT(h.hb_create_time, '%Y-%m-%d' )= #{date}
        AND (
        h.`hb_type` =5 OR h.`hb_type` =6 OR h.`hb_type` =7 OR h.`hb_type` =20
        OR h.`hb_type` =21 OR h.`hb_type` =22 )
        GROUP BY h.`hb_uid`
        ORDER BY
        totalMoney DESC
        LIMIT ${start},${count}
    </select>
    <select id="countRebateCouponMoney" resultType="java.math.BigDecimal">
        SELECT IFNULL(SUM(h.`hb_money`),0) FROM `yeshi_ec_hongbao_v2` h
        where h.`hb_type` = 10
    </select>
    <select id="countRebateOrder" resultType="Long">
        SELECT IFNULL(COUNT(hb_id),0) FROM `yeshi_ec_hongbao_v2`
        WHERE hb_uid = #{uid} AND (hb_type =1 OR hb_type =2)
    </select>
    <select id="countShareOrInviteOrder" resultType="Long">
        SELECT IFNULL(COUNT(hb_id),0) FROM `yeshi_ec_hongbao_v2`
        WHERE hb_uid = #{uid}
                AND (`hb_type` =5 OR `hb_type` =6 OR `hb_type` =7 OR `hb_type` =20 OR `hb_type`=21 OR `hb_type` =22 )
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/count/HongBaoV2CountServiceImpl.java
@@ -295,5 +295,17 @@
    public BigDecimal countRebateCouponMoney() {
        return hongBaoV2CountMapper.countRebateCouponMoney();
    }
    @Override
    public long countRebateOrder(Long uid) {
        return hongBaoV2CountMapper.countRebateOrder(uid);
    }
    @Override
    public long countShareOrInviteOrder(Long uid) {
        return hongBaoV2CountMapper.countShareOrInviteOrder(uid);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java
@@ -570,6 +570,18 @@
    public List<Special> listByPlaceKey(String placeKey, Integer platform, Integer versionCode) {
        return specialMapper.listByPlaceKey(placeKey, null, platform, versionCode);
    }
    @Override
    public List<Special> listByPlaceKeyList(long start, int count, List<String> list, Integer platform, Integer versionCode) {
        return specialMapper.listByPlaceKeyList(start, count, list, null, platform, versionCode);
    }
    @Override
    public long countByPlaceKeyList(List<String> list, Integer platform, Integer versionCode) {
        return specialMapper.countByPlaceKeyList(list, null, platform, versionCode);
    }
    /**
     * 处理 数据
fanli/src/main/java/com/yeshi/fanli/service/inter/count/HongBaoV2CountService.java
@@ -155,4 +155,18 @@
     */
    public BigDecimal countRebateCouponMoney();
    /**
     * 统计返利订单
     * @param uid
     * @return
     */
    public long countRebateOrder(Long uid);
    /**
     * 统计分享+ 邀请订单
     * @param uid
     * @return
     */
    public long countShareOrInviteOrder(Long uid);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/SpecialService.java
@@ -109,4 +109,17 @@
     */
    public List<Special> listByVersion(long start, int count, String card, Integer platform, Integer versionCode);
    /**
     * 专题版本区分 传递多个位置
     * @param list
     * @param platform
     * @param versionCode
     * @return
     */
    public List<Special> listByPlaceKeyList(long start, int count, List<String> list, Integer platform, Integer versionCode);
    public long countByPlaceKeyList(List<String> list, Integer platform, Integer versionCode);
}
fanli/src/main/java/com/yeshi/fanli/util/VersionUtil.java
@@ -61,6 +61,15 @@
            return false;
    }
    public static boolean greaterThan_2_0_1(String platform, String versionCode) {
        if ((("android".equalsIgnoreCase(platform) && Integer.parseInt(versionCode) >= 50))
                || (("ios".equalsIgnoreCase(platform) && Integer.parseInt(versionCode) >= 67)))
            return true;
        else
            return false;
    }
    public static boolean smallerThan_1_5_1(String platform, String versionCode) {
        if ((("android".equalsIgnoreCase(platform) && Integer.parseInt(versionCode) < 36))
fanli/src/main/java/com/yeshi/fanli/util/jd/JDUtil.java
@@ -18,6 +18,7 @@
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
@@ -32,6 +33,7 @@
import com.yeshi.fanli.dto.jd.JDSearchResult;
import com.yeshi.fanli.dto.jd.JDShopInfo;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
@@ -41,6 +43,9 @@
public class JDUtil {
    public static final String TM_PHONE_URL = "https://item.m.jd.com/product/%s.html";
    public void test() {
        Map<String, String> systemParams = new HashMap<>();
        systemParams.put("method", "");
@@ -569,5 +574,60 @@
        }
        return null;
    }
    /**
     * 查询天猫商品图片、标题
     * @param auctionId
     * @return
     */
    public static JDGoods getSimpleGoodsInfo(String goodsId) {
        JDGoods jdGoods = null;
        try {
            Connection connect = Jsoup.connect(String.format(TM_PHONE_URL, goodsId));
            Document document = connect.get();
            Elements elements = document.getElementsByTag("script");
            if (elements.size() >= 0) {
                for (int i = 0; i < elements.size(); i++) {
                    String content = elements.get(i).toString();
                    if (content.contains("window._itemOnly")) {
                        System.out.println("存在");
                        content = content.replace("<script>", "");
                        content = content.replace("</script>", "");
                        int indexOf = content.indexOf("window._isLogin");
                        content = content.substring(0,indexOf);
                        int indexItem = content.indexOf("\"item\":");
                        content = content.substring(indexItem,content.length() - 1);
                        content = content.replace("\"item\":", "var item =");
                        content = content.replace("});", "").trim();
                        content+=";function getData() {return item;}";
                        ScriptEngineManager manager = new ScriptEngineManager();
                        ScriptEngine engine = manager.getEngineByName("javascript");
                        engine.eval(content);
                        if (engine instanceof Invocable) {
                            Invocable in = (Invocable) engine;
                            JSONObject json = JSONObject.fromObject(in.invokeFunction("getData"));
                            jdGoods = new JDGoods();
                            jdGoods.setSkuName(json.getString("skuName"));
                            JSONObject jsonImage = json.getJSONObject("image");
                            if (jsonImage != null && jsonImage.size() > 0) {
                                String picUrl = jsonImage.getString("0");
                                jdGoods.setPicUrl("http://m.360buyimg.com/mobilecms/s750x750_" + picUrl);
                            }
                        }
                        break;
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return jdGoods;
    }
}
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java
@@ -14,6 +14,9 @@
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -1918,10 +1921,47 @@
        return true;
    }
    public static void main(String[] args) {
        String s = channelMap.get("3");
        System.out.println(s);
    /**
     * 查询天猫商品图片、标题
     * @param auctionId
     * @return
     */
    public static TaoBaoGoodsBrief getTmallGoodsInfo(String auctionId) {
        TaoBaoGoodsBrief taoBaoGoodsBrief = null;
        try {
            Connection connect = Jsoup.connect(String.format(TM_PHONE_URL, auctionId));
            Document document = connect.get();
            Elements elements = document.getElementsByTag("script");
            if (elements.size() >= 0) {
                for (int i = 0; i < elements.size(); i++) {
                    String content = elements.get(i).toString();
                    if (content.contains("var _DATA_Mdskip")) {
                        content = content.replace("<script>", "");
                        content = content.replace("</script>", "");
                        content+=";function getData(){ var json={title:_DATA_Mdskip.item.title,pictUrl:_DATA_Mdskip.item.videoDetail.videoThumbnailURL};   return JSON.stringify(json);}";
                        ScriptEngineManager manager = new ScriptEngineManager();
                        ScriptEngine engine = manager.getEngineByName("javascript");
                        engine.eval(content);
                        if (engine instanceof Invocable) {
                            Invocable in = (Invocable) engine;
                            JSONObject json = JSONObject.fromObject(in.invokeFunction("getData"));
                            Object title = json.get("title");
                            Object pictUrl = json.get("pictUrl");
                            taoBaoGoodsBrief = new TaoBaoGoodsBrief();
                            taoBaoGoodsBrief.setTitle(title.toString());
                            taoBaoGoodsBrief.setPictUrl(pictUrl.toString());
                        }
                        break;
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return taoBaoGoodsBrief;
    }
}