yujian
2019-09-25 011d53f9f3d08af8cd622585ce40eb880f313aaf
Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div

# Conflicts:
# fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HongBaoV2CountMapper.java
# fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2CountMapper.xml
# fanli/src/main/java/com/yeshi/fanli/service/inter/count/HongBaoV2CountService.java
18个文件已修改
2463 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/aspect/SignValidateAspect.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java 53 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/TestController.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserAccountController.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserOrderController.java 147 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HongBaoV2CountMapper.java 322 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/taobao/TaoBaoOrder.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/order/taobao/UpdateTBRelationAndSpecialOrderJob.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2CountMapper.xml 666 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/push/DeviceTokenOPPOMapper.xml 260 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/taobao/TaoBaoOrderMapper.xml 886 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/count/HongBaoV2CountServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/tb/TaoBaoOrderServiceImpl.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceTokenOPPOServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/count/HongBaoV2CountService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/DeviceTokenOPPOService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeOrderApiUtil.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/aspect/SignValidateAspect.java
@@ -41,7 +41,7 @@
        KEY = Constant.systemCommonConfig.getSignKey();
    }
    @Around(EDP)
//    @Around(EDP)
    public Object testAround(ProceedingJoinPoint joinPoint) throws IOException {
        Object[] args = joinPoint.getArgs();
        PrintWriter out = null;
fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java
@@ -66,7 +66,6 @@
    @RequestMapping(value = "tb")
    public void tb(String code, String state, HttpServletRequest request, HttpServletResponse response) {
        LogHelper.test("淘宝授权回调:" + code + ":" + state);
        if (StringUtil.isNullOrEmpty(code) || StringUtil.isNullOrEmpty(state)) {
            LogHelper.error("淘宝授权回调出错");
@@ -77,6 +76,7 @@
            }
            return;
        }
        try {
            String key = StringUtil.Md5("taobao-code-" + code);
            if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(key)))
@@ -85,19 +85,40 @@
        } catch (Exception e) {
        }
        LogHelper.userErrorInfo("淘宝授权回调state:"+state);
        String stateStr = AESUtil.decrypt(state, Constant.UIDAESKEY);
        LogHelper.userErrorInfo("淘宝授权回调解密:"+stateStr);
        String stateStr = null;
        Long time = null;
        Long uid = null;
        String source = null;
        try {
            stateStr = AESUtil.decrypt(state, Constant.UIDAESKEY);
            JSONObject json = JSONObject.fromObject(stateStr);
            time = json.optLong("t");
            uid = json.optLong("u");
            source = json.optString("s");
        } catch (Exception e) {
            try {
                state = URLDecoder.decode(state, "UTF-8");
            } catch (UnsupportedEncodingException e1) {
                e1.printStackTrace();
            }
            stateStr = AESUtil.decrypt(state, Constant.UIDAESKEY);
            JSONObject json = JSONObject.fromObject(stateStr);
            time = json.optLong("t");
            uid = json.optLong("u");
            source = json.optString("s");
        }
        LogHelper.userErrorInfo("淘宝授权回调state:" + state);
        LogHelper.userErrorInfo("淘宝授权回调解密:" + stateStr);
        int errCode = 0;
        if (StringUtil.isNullOrEmpty(stateStr)) {
            // 解密错误
            errCode = 1;
        }
        JSONObject json = JSONObject.fromObject(stateStr);
        Long time = json.optLong("t");
        Long uid = json.optLong("u");
        String source = json.optString("s");
        if (System.currentTimeMillis() - time > 1000 * 60 * 10L) {
            // 过时
            errCode = 2;
@@ -146,6 +167,7 @@
                final String relationId2 = relationId;
                // 异步申请会员ID
                final Long fuid=uid;
                ThreadUtil.run(new Runnable() {
                    @Override
@@ -159,12 +181,12 @@
                        }
                        if (StringUtil.isNullOrEmpty(specialId))
                            LogHelper.test(uid + "会员备案失败");
                            LogHelper.test(fuid + "会员备案失败");
                        try {
                            userExtraTaoBaoInfoService.addSpecialId(uid, specialId, taoBaoUid, name, true);
                            userExtraTaoBaoInfoService.addSpecialId(fuid, specialId, taoBaoUid, name, true);
                            if (!StringUtil.isNullOrEmpty(specialId) && !StringUtil.isNullOrEmpty(relationId2))
                                userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindTaoBao, taoBaoUid);
                                userInfoModifyRecordService.addModifyRecord(fuid, ModifyTypeEnum.bindTaoBao, taoBaoUid);
                        } catch (UserExtraTaoBaoInfoException e) {
                            LogHelper.test(e.getMsg());
                        }
@@ -192,6 +214,7 @@
                    LogHelper.test(e.getMsg());
                    errCode = 5;
                }
                final Long fuid=uid;
                final String specialId2 = specialId;
                // 异步申请渠道ID
@@ -206,12 +229,12 @@
                        } catch (TaoBaoAuthException e1) {
                        } // 渠道ID
                        if (StringUtil.isNullOrEmpty(relationId))
                            LogHelper.test(uid + "渠道备案失败");
                            LogHelper.test(fuid + "渠道备案失败");
                        try {
                            userExtraTaoBaoInfoService.addRelationId(uid, relationId, taoBaoUid, name, true);
                            userExtraTaoBaoInfoService.addRelationId(fuid, relationId, taoBaoUid, name, true);
                            if (!StringUtil.isNullOrEmpty(specialId2) && !StringUtil.isNullOrEmpty(relationId))
                                userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindTaoBao, taoBaoUid);
                                userInfoModifyRecordService.addModifyRecord(fuid, ModifyTypeEnum.bindTaoBao, taoBaoUid);
                        } catch (UserExtraTaoBaoInfoException e) {
                            LogHelper.test(e.getMsg());
                        }
fanli/src/main/java/com/yeshi/fanli/controller/TestController.java
@@ -48,6 +48,7 @@
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
import com.yeshi.fanli.exception.ActivityException;
import com.yeshi.fanli.exception.push.PushException;
import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.log.LogHelper;
@@ -65,6 +66,7 @@
import com.yeshi.fanli.util.db.MongoDBManager;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.jd.JDApiUtil;
import com.yeshi.fanli.util.push.OPPOPushUtil;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import net.sf.json.JSONArray;
@@ -538,4 +540,39 @@
        }
        out.println(array.toString());
    }
    @RequestMapping(value = "pushOppo")
    public void pushOppo(String registerId, PrintWriter out) {
        List<String> registerIds = new ArrayList<>();
        registerIds.add(registerId);
        try {
            OPPOPushUtil.pushUrl(registerIds, "测试网页推送", "测试网页推送内容", "http://www.baidu.com");
        } catch (PushException e) {
            e.printStackTrace();
        }
        try {
            OPPOPushUtil.pushGoods(registerIds, "测试商品网页推送", "测试商品推送内容", 1, 577628549116L);
        } catch (PushException e) {
            e.printStackTrace();
        }
        try {
            OPPOPushUtil.pushUserSignInNotification(registerIds, "测试签到推送", "测试签到推送");
        } catch (PushException e) {
            e.printStackTrace();
        }
        try {
            OPPOPushUtil.pushWelfareCenter(registerIds, "测试福利中心推送", "测试福利中心推送");
        } catch (PushException e) {
            e.printStackTrace();
        }
        try {
            OPPOPushUtil.pushZNX(registerIds, "测试站内信推送", "测试站内信推送");
        } catch (PushException e) {
            e.printStackTrace();
        }
        out.print("success");
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserAccountController.java
@@ -262,6 +262,11 @@
                            platformType = 2;
                        }
                        userSystemCouponService.copyLotteryPrize(uuser.getId(), platformType, acceptData.getDevice());
                        // 绑定oppo推送
                        DeviceActive active = deviceActiveService.getFirstActiveInfo(acceptData.getDevice());
                        if (active != null) {
                            deviceTokenOPPOService.bindUid(uuser.getId(), active.getId());
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
@@ -1224,6 +1229,12 @@
                                e.printStackTrace();
                            }
                        }
                        // 绑定oppo推送
                        DeviceActive active = deviceActiveService.getFirstActiveInfo(acceptData.getDevice());
                        if (active != null) {
                            deviceTokenOPPOService.bindUid(uuser.getId(), active.getId());
                        }
                    }
                });
            }
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserOrderController.java
@@ -3,6 +3,9 @@
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -21,6 +24,7 @@
import com.yeshi.fanli.entity.AppVersionInfo;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.LostOrder;
import com.yeshi.fanli.entity.bus.user.Order;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
@@ -42,6 +46,7 @@
import com.yeshi.fanli.util.CMQManager;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.account.UserUtil;
import com.yeshi.fanli.vo.order.CommonOrderVO;
@@ -110,21 +115,22 @@
     */
    @RequestMapping(value = "getorder", method = RequestMethod.POST)
    public void getOrder(AcceptData acceptData, Integer page, Long uid, Integer state,
            @RequestParam(name = "type",required = false) String type1, Integer orderState, String orderNo, String startTime, String endTime,
            Integer slotTime, Boolean needCount, Integer dateType, Integer goodsType, PrintWriter out) {
            @RequestParam(name = "type", required = false) String type1, Integer orderState, String orderNo,
            String startTime, String endTime, Integer slotTime, Boolean needCount, Integer dateType, Integer goodsType,
            PrintWriter out) {
        Integer type = null;
        if (StringUtil.isNullOrEmpty(type1)) {
            type = null;
        } else {
            type = Integer.parseInt(type1);
        }
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        if (needCount == null)
            needCount = false;
@@ -147,20 +153,20 @@
            orderState = 2; // 已维权
            state = null; // 清空
        }
        if (type != null && type == 0) {
            type = null; // 所有类型订单
        }
        Integer tempState = state;
        // 转换状态
        if (state != null && orderState != null && (orderState == 2|| orderState == 3)) {
        if (state != null && orderState != null && (orderState == 2 || orderState == 3)) {
            state = null; // 清空
        }
        if (!VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) {
            goodsType = Constant.SOURCE_TYPE_TAOBAO;
        } else if (goodsType != null && goodsType == 0){
        } else if (goodsType != null && goodsType == 0) {
            goodsType = null; // 所有平台订单
        }
@@ -187,8 +193,8 @@
            BigDecimal todayMoney = null;
            // 查询列表
            List<CommonOrderVO> list = commonOrderService.getOrderByUid(acceptData, page, uid, state, type, orderState, orderNo,
                    startTime, endTime, dateType, goodsType);
            List<CommonOrderVO> list = commonOrderService.getOrderByUid(acceptData, page, uid, state, type, orderState,
                    orderNo, startTime, endTime, dateType, goodsType);
            if (list != null && list.size() > 0) {
                // 统计总数
@@ -199,21 +205,23 @@
            // 需要统计筛选信息 :未失效的总金额 以及订单
            if (needCount && page == 1) {
                todayMoney = commonOrderService.countBonusOrderMoney(uid, type, dateType, startTime, endTime, goodsType);
                todayMoney = commonOrderService.countBonusOrderMoney(uid, type, dateType, startTime, endTime,
                        goodsType);
                todayTotal = commonOrderService.countBonusOrderNumber(uid, type, dateType, startTime, endTime, goodsType);
                todayTotal = commonOrderService.countBonusOrderNumber(uid, type, dateType, startTime, endTime,
                        goodsType);
                // 有效订单
                totalValid = commonOrderService.countUserOrderToApp(uid, type, startTime,
                        endTime, dateType, goodsType, tempState, 1);
                totalValid = commonOrderService.countUserOrderToApp(uid, type, startTime, endTime, dateType, goodsType,
                        tempState, 1);
                // 维权订单
                totalProces = commonOrderService.countUserOrderToApp(uid, type, startTime,
                        endTime, dateType, goodsType, null, 2);
                totalProces = commonOrderService.countUserOrderToApp(uid, type, startTime, endTime, dateType, goodsType,
                        null, 2);
                // 失效订单
                totalInvite = commonOrderService.countUserOrderToApp(uid, type, startTime,
                        endTime, dateType, goodsType, null, 3);
                totalInvite = commonOrderService.countUserOrderToApp(uid, type, startTime, endTime, dateType, goodsType,
                        null, 3);
            }
            if (todayMoney == null) {
@@ -306,8 +314,8 @@
            Integer goodsType = null; // 版本区分
            if (!VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) {
                goodsType = Constant.SOURCE_TYPE_TAOBAO;
            }
            }
            /* 总订单统计 */
            Map<String, BigDecimal> countOrder = commonOrderService.countHistoryOrder(uid, null, goodsType);
            int self = 0;
@@ -392,10 +400,10 @@
            e.printStackTrace();
        }
    }
    /**
     * 统计各个平台数据
     *
     * @param acceptData
     * @param uid
     * @param goodsType
@@ -413,7 +421,7 @@
            out.print(JsonUtil.loadFalseResult(1, "平台类型缺失或不正确"));
            return;
        }
        /* 今日订单统计 */
        Map<String, BigDecimal> countToday = commonOrderService.countHistoryOrder(uid, 1, goodsType);
@@ -469,8 +477,7 @@
        data.put("yesterday", yesterdaydata);
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 统计奖金
     * 
@@ -480,50 +487,74 @@
     */
    @RequestMapping(value = "countBonus", method = RequestMethod.POST)
    public void countBonus(AcceptData acceptData, Long uid, Integer dateType, PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        try {
        long nowTime = System.currentTimeMillis();
        long recievedTime = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(nowTime, "yyyy-MM") + "-25 10",
                "yyyy-MM-dd HH");
        try {
            Object shareCount = 0;
            BigDecimal sharemoney = new BigDecimal(0.00);
            Object inviteCount = 0;
            BigDecimal inviteMoney = new BigDecimal(0.00);
            Integer goodsType = null; // 版本区分
            if (!VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) {
                goodsType = Constant.SOURCE_TYPE_TAOBAO;
            }
            Map<String, Object> shareMap = commonOrderService.countBonusOrderMoneyAndNumber(uid, 2, dateType, null,
                    null, goodsType);
            if (shareMap != null) {
                Object totalNum = shareMap.get("totalNum");
                if (totalNum != null) {
                    shareCount = totalNum;
            if (nowTime > recievedTime && dateType == 4) {// 实际到账
                List<Integer> inviteTypes = new ArrayList<>();
                inviteTypes.add(HongBaoV2.TYPE_YIJI);
                inviteTypes.add(HongBaoV2.TYPE_ERJI);
                inviteTypes.add(HongBaoV2.TYPE_SHARE_YIJI);
                inviteTypes.add(HongBaoV2.TYPE_SHARE_ERJI);
                List<Integer> shareTypes = new ArrayList<>();
                shareTypes.add(HongBaoV2.TYPE_SHARE_GOODS);
                Date minGetTime = new Date(
                        TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(nowTime, "yyyy-MM") + "-25", "yyyy-MM-dd"));
                Date maxGetTime = new Date(nowTime);
                inviteMoney = hongBaoV2CountService.sumAlreadyGetMoneyByUid(uid, inviteTypes, minGetTime, maxGetTime);
                inviteCount = hongBaoV2CountService.countAlreadyGetMoneyByUid(uid, inviteTypes, minGetTime, maxGetTime);
                sharemoney = hongBaoV2CountService.sumAlreadyGetMoneyByUid(uid, shareTypes, minGetTime, maxGetTime);
                shareCount = hongBaoV2CountService.countAlreadyGetMoneyByUid(uid, shareTypes, minGetTime, maxGetTime);
            } else {// 预估到账
                Integer goodsType = null; // 版本区分
                if (!VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) {
                    goodsType = Constant.SOURCE_TYPE_TAOBAO;
                }
                Map<String, Object> shareMap = commonOrderService.countBonusOrderMoneyAndNumber(uid, 2, dateType, null,
                        null, goodsType);
                if (shareMap != null) {
                    Object totalNum = shareMap.get("totalNum");
                    if (totalNum != null) {
                        shareCount = totalNum;
                    }
                    Object totalmoney = shareMap.get("totalmoney");
                    if (totalmoney != null) {
                        sharemoney = (BigDecimal) totalmoney;
                    }
                }
                Object totalmoney = shareMap.get("totalmoney");
                if (totalmoney != null) {
                    sharemoney = (BigDecimal) totalmoney;
                }
            }
                // 邀请统计
            // 邀请统计
            Map<String, Object> inviteMap = commonOrderService.countBonusOrderMoneyAndNumber(uid, 3, dateType, null,
                    null, goodsType);
            if (inviteMap != null) {
                Object totalNum = inviteMap.get("totalNum");
                if (totalNum != null) {
                    inviteCount = totalNum;
                }
                Map<String, Object> inviteMap = commonOrderService.countBonusOrderMoneyAndNumber(uid, 3, dateType, null,
                        null, goodsType);
                if (inviteMap != null) {
                    Object totalNum = inviteMap.get("totalNum");
                    if (totalNum != null) {
                        inviteCount = totalNum;
                    }
                Object totalmoney = inviteMap.get("totalmoney");
                if (totalmoney != null) {
                    inviteMoney = (BigDecimal) totalmoney;
                    Object totalmoney = inviteMap.get("totalmoney");
                    if (totalmoney != null) {
                        inviteMoney = (BigDecimal) totalmoney;
                    }
                }
            }
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HongBaoV2CountMapper.java
@@ -1,151 +1,173 @@
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);
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
     * @param typeList
     * @param minGetTime
     * @param maxGetTime
     * @return
     */
    BigDecimal sumAlreadyGetMoneyByUid(@Param("uid") Long uid, @Param("typeList") List<Integer> typeList,
            @Param("minGetTime") Date minGetTime, @Param("maxGetTime") Date maxGetTime);
    long countAlreadyGetMoneyByUid(@Param("uid") Long uid, @Param("typeList") List<Integer> typeList,
            @Param("minGetTime") Date minGetTime, @Param("maxGetTime") Date maxGetTime);
    /**
     * 统计返利订单
     * @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/entity/taobao/TaoBaoOrder.java
@@ -15,6 +15,8 @@
    private String createTime; // 创建时间
    @Column(name = "to_click_time")
    private String clickTime; // 点击时间
    @Column(name = "to_pay_time")
    private String payTime;// 支付时间
    @Column(name = "to_title")
    private String title; // 商品名称
    @Column(name = "to_auction_id")
@@ -82,7 +84,7 @@
    @Column(name = "to_relation_id")
    private String relationId;
    @Column(name = "to_trade_id")
    private String tradeId;//交易ID
    private String tradeId;// 交易ID
    public String getTradeId() {
        return tradeId;
@@ -380,4 +382,12 @@
        this.adPositionName = adPositionName;
    }
    public String getPayTime() {
        return payTime;
    }
    public void setPayTime(String payTime) {
        this.payTime = payTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/job/order/taobao/UpdateTBRelationAndSpecialOrderJob.java
@@ -44,8 +44,8 @@
     *            结束页码(每页100条数据)
     */
    public void updateRelationAndSpecialOrder(long startTime, long endTime) {
        List<TaoBaoOrder> list =TaoKeOrderApiUtil.getTaoBaoSpecialOrderList (startTime, endTime,1);
        List<TaoBaoOrder> list1 = TaoKeOrderApiUtil.getTaoBaoRelationOrderList (startTime, endTime,1);
        List<TaoBaoOrder> list = TaoKeOrderApiUtil.getTaoBaoSpecialOrderList(startTime, endTime, 1);
        List<TaoBaoOrder> list1 = TaoKeOrderApiUtil.getTaoBaoRelationOrderList(startTime, endTime, 1);
        if (list1 != null && list1.size() > 0)
            list.addAll(list1);
        // 爬取到的订单号
@@ -56,10 +56,10 @@
        addRelationAndSpecialOrder(list);
    }
    public void updateRelationAndSpecialSettleOrder(long startTime, long endTime) {
        List<TaoBaoOrder> list = TaoKeOrderApiUtil.getTaoBaoSpecialOrderList (startTime, endTime,3);
        List<TaoBaoOrder> list1 = TaoKeOrderApiUtil.getTaoBaoRelationOrderList (startTime, endTime,3);
        List<TaoBaoOrder> list = TaoKeOrderApiUtil.getTaoBaoSpecialOrderList(startTime, endTime, 3);
        List<TaoBaoOrder> list1 = TaoKeOrderApiUtil.getTaoBaoRelationOrderList(startTime, endTime, 3);
        if (list1 != null && list1.size() > 0)
            list.addAll(list1);
        // 爬取到的订单号
@@ -84,7 +84,8 @@
                while (its.hasNext()) {
                    String key = its.next();
                    List<TaoBaoOrder> orders = map.get(key);
                    String redisKey = "addorderqueue-" + TaoBaoOrderUtil.getOrderDataHashCode(orders);;
                    String redisKey = "addorderqueue-" + TaoBaoOrderUtil.getOrderDataHashCode(orders);
                    ;
                    // redis做频率限制
                    try {
                        if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(redisKey))) {
@@ -133,6 +134,7 @@
    public void doJob2() {
        if (!Constant.IS_TASK)
            return;
        LogHelper.orderInfo("爬单:5min爬取一次单");
        long endTime = System.currentTimeMillis();
        updateRelationAndSpecialOrder(endTime - 1000 * 60 * 60 * 24L, endTime);
        updateRelationAndSpecialSettleOrder(endTime - 1000 * 60 * 60 * 24L, endTime);
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2CountMapper.xml
@@ -1,307 +1,359 @@
<?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>
<?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="sumAlreadyGetMoneyByUid" resultType="java.math.BigDecimal">
        SELECT IFNULL(SUM(h.`hb_money`),0) FROM `yeshi_ec_hongbao_v2` h
        where h.`hb_uid` = #{uid}
        <if test="typeList!=null">
            <foreach collection="typeList" item="type" open=" and ("
                separator=" or " close=")">
                h.hb_type=#{type}
            </foreach>
        </if>
        <if test="minGetTime!=null">
            and h.hb_get_time>=#{minGetTime}
        </if>
        <if test="maxGetTime!=null">
            and #{maxGetTime}>h.hb_get_time
        </if>
    </select>
    <select id="countAlreadyGetMoneyByUid" resultType="java.lang.Long">
        SELECT count(h.hb_id) FROM `yeshi_ec_hongbao_v2` h
        where h.`hb_uid` = #{uid}
        <if test="typeList!=null">
            <foreach collection="typeList" item="type" open=" and ("
                separator=" or " close=")">
                h.hb_type=#{type}
            </foreach>
        </if>
        <if test="minGetTime!=null">
            and h.hb_get_time>=#{minGetTime}
        </if>
        <if test="maxGetTime!=null">
            and #{maxGetTime}>h.hb_get_time
        </if>
    </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/mapping/push/DeviceTokenOPPOMapper.xml
@@ -1,132 +1,128 @@
<?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.push.DeviceTokenOPPOMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.push.DeviceTokenOPPO">
        <id column="do_id" property="id" jdbcType="BIGINT" />
        <result column="do_device_id" property="deviceActiveId"
            jdbcType="BIGINT" />
        <result column="do_register_id" property="registerId" jdbcType="VARCHAR" />
        <result column="do_uid" property="uid" jdbcType="BIGINT" />
        <result column="do_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="do_update_time" property="updateTime" jdbcType="TIMESTAMP" />
    </resultMap>
    <sql id="Base_Column_List">do_id,do_device_id,do_register_id,do_uid,do_create_time,do_update_time
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_uid_devicetoken_oppo where do_id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByDeviceActiveId" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_uid_devicetoken_oppo where do_device_id = #{0}
    </select>
    <select id="countDeviceToken" resultType="java.lang.Long"
        parameterType="java.lang.Long">
        select
        count(do_id)
        from yeshi_ec_uid_devicetoken_oppo op left join
        yeshi_ec_device_active a on a.da_id=op.do_device_id
        <if test="versionList!=null">
            <foreach collection="versionList" open="where (" separator=" or "
                item="ver" close=")">
                da_version_code=#{ver}
            </foreach>
        </if>
    </select>
    <select id="listDeviceToken" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_uid_devicetoken_oppo
        left join
        yeshi_ec_device_active a on a.da_id=do_device_id
        <if test="versionList!=null">
            <foreach collection="versionList" open="where (" separator=" or "
                item="ver" close=")">
                da_version_code=#{ver}
            </foreach>
        </if>
         limit #{start},#{count}
    </select>
    <select id="listByUid" resultMap="BaseResultMap" parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_uid_devicetoken_oppo
        left join
        yeshi_ec_device_active a on a.da_id=do_device_id
        where do_uid=#{uid}
        <if test="versionList!=null">
            <foreach collection="versionList" open="and (" separator=" or "
                item="ver" close=")">
                da_version_code=#{ver}
            </foreach>
        </if>
    </select>
     List<Integer> verisonList
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_uid_devicetoken_oppo where do_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.push.DeviceTokenOPPO"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_uid_devicetoken_oppo
        (do_id,do_device_id,do_register_id,do_uid,do_create_time,do_update_time)
        values
        (#{id,jdbcType=BIGINT},#{deviceActiveId,jdbcType=BIGINT},#{registerId,jdbcType=VARCHAR},#{uid,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.push.DeviceTokenOPPO"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_uid_devicetoken_oppo
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">do_id,</if>
            <if test="deviceActiveId != null">do_device_id,</if>
            <if test="registerId != null">do_register_id,</if>
            <if test="uid != null">do_uid,</if>
            <if test="createTime != null">do_create_time,</if>
            <if test="updateTime != null">do_update_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="deviceActiveId != null">#{deviceActiveId,jdbcType=BIGINT},</if>
            <if test="registerId != null">#{registerId,jdbcType=VARCHAR},</if>
            <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.push.DeviceTokenOPPO">update
        yeshi_ec_uid_devicetoken_oppo set do_device_id =
        #{deviceActiveId,jdbcType=BIGINT},do_register_id =
        #{registerId,jdbcType=VARCHAR},do_uid =
        #{uid,jdbcType=BIGINT},do_create_time =
        #{createTime,jdbcType=TIMESTAMP},do_update_time =
        #{updateTime,jdbcType=TIMESTAMP} where do_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.push.DeviceTokenOPPO">
        update yeshi_ec_uid_devicetoken_oppo
        <set>
            <if test="deviceActiveId != null">do_device_id=#{deviceActiveId,jdbcType=BIGINT},</if>
            <if test="registerId != null">do_register_id=#{registerId,jdbcType=VARCHAR},</if>
            <if test="uid != null">do_uid=#{uid,jdbcType=BIGINT},</if>
            <if test="createTime != null">do_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">do_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where do_id = #{id,jdbcType=BIGINT}
    </update>
</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.push.DeviceTokenOPPOMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.push.DeviceTokenOPPO">
        <id column="do_id" property="id" jdbcType="BIGINT" />
        <result column="do_device_id" property="deviceActiveId"
            jdbcType="BIGINT" />
        <result column="do_register_id" property="registerId" jdbcType="VARCHAR" />
        <result column="do_uid" property="uid" jdbcType="BIGINT" />
        <result column="do_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="do_update_time" property="updateTime" jdbcType="TIMESTAMP" />
    </resultMap>
    <sql id="Base_Column_List">do_id,do_device_id,do_register_id,do_uid,do_create_time,do_update_time
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_uid_devicetoken_oppo where do_id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByDeviceActiveId" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_uid_devicetoken_oppo where do_device_id = #{0}
    </select>
    <select id="countDeviceToken" resultType="java.lang.Long"
        parameterType="java.lang.Long">
        select
        count(do_id)
        from yeshi_ec_uid_devicetoken_oppo op left join
        yeshi_ec_device_active a on a.da_id=op.do_device_id
        <if test="versionList!=null">
            <foreach collection="versionList" open="where (" separator=" or "
                item="ver" close=")">
                da_version_code=#{ver}
            </foreach>
        </if>
    </select>
    <select id="listDeviceToken" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_uid_devicetoken_oppo
        left join
        yeshi_ec_device_active a on a.da_id=do_device_id
        <if test="versionList!=null">
            <foreach collection="versionList" open="where (" separator=" or "
                item="ver" close=")">
                da_version_code=#{ver}
            </foreach>
        </if>
         limit #{start},#{count}
    </select>
    <select id="listByUid" resultMap="BaseResultMap" parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_uid_devicetoken_oppo
        left join
        yeshi_ec_device_active a on a.da_id=do_device_id
        where do_uid=#{uid}
        <if test="versionList!=null">
            <foreach collection="versionList" open="and (" separator=" or "
                item="ver" close=")">
                da_version_code=#{ver}
            </foreach>
        </if>
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_uid_devicetoken_oppo where do_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.push.DeviceTokenOPPO"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_uid_devicetoken_oppo
        (do_id,do_device_id,do_register_id,do_uid,do_create_time,do_update_time)
        values
        (#{id,jdbcType=BIGINT},#{deviceActiveId,jdbcType=BIGINT},#{registerId,jdbcType=VARCHAR},#{uid,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.push.DeviceTokenOPPO"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_uid_devicetoken_oppo
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">do_id,</if>
            <if test="deviceActiveId != null">do_device_id,</if>
            <if test="registerId != null">do_register_id,</if>
            <if test="uid != null">do_uid,</if>
            <if test="createTime != null">do_create_time,</if>
            <if test="updateTime != null">do_update_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="deviceActiveId != null">#{deviceActiveId,jdbcType=BIGINT},</if>
            <if test="registerId != null">#{registerId,jdbcType=VARCHAR},</if>
            <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.push.DeviceTokenOPPO">update
        yeshi_ec_uid_devicetoken_oppo set do_device_id =
        #{deviceActiveId,jdbcType=BIGINT},do_register_id =
        #{registerId,jdbcType=VARCHAR},do_uid =
        #{uid,jdbcType=BIGINT},do_create_time =
        #{createTime,jdbcType=TIMESTAMP},do_update_time =
        #{updateTime,jdbcType=TIMESTAMP} where do_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.push.DeviceTokenOPPO">
        update yeshi_ec_uid_devicetoken_oppo
        <set>
            <if test="deviceActiveId != null">do_device_id=#{deviceActiveId,jdbcType=BIGINT},</if>
            <if test="registerId != null">do_register_id=#{registerId,jdbcType=VARCHAR},</if>
            <if test="uid != null">do_uid=#{uid,jdbcType=BIGINT},</if>
            <if test="createTime != null">do_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">do_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where do_id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/taobao/TaoBaoOrderMapper.xml
@@ -1,440 +1,446 @@
<?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.taobao.TaoBaoOrderMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.taobao.TaoBaoOrder">
        <id column="to_id" property="id" jdbcType="BIGINT" />
        <result column="to_create_time" property="createTime" jdbcType="VARCHAR" />
        <result column="to_click_time" property="clickTime" jdbcType="VARCHAR" />
        <result column="to_title" property="title" jdbcType="VARCHAR" />
        <result column="to_auction_id" property="auctionId" jdbcType="BIGINT" />
        <result column="to_manager_wangwang" property="managerWangWang"
            jdbcType="VARCHAR" />
        <result column="to_shop" property="shop" jdbcType="VARCHAR" />
        <result column="to_count" property="count" jdbcType="INTEGER" />
        <result column="to_price" property="price" jdbcType="DECIMAL" />
        <result column="to_order_state" property="orderState" jdbcType="VARCHAR" />
        <result column="to_order_type" property="orderType" jdbcType="VARCHAR" />
        <result column="to_iratio" property="iRatio" jdbcType="DECIMAL" />
        <result column="to_sratio" property="sRatio" jdbcType="DECIMAL" />
        <result column="to_payment" property="payment" jdbcType="DECIMAL" />
        <result column="to_estimate" property="estimate" jdbcType="DECIMAL" />
        <result column="to_settlement" property="settlement" jdbcType="DECIMAL" />
        <result column="to_eIncome" property="eIncome" jdbcType="DECIMAL" />
        <result column="to_settlement_time" property="settlementTime"
            jdbcType="VARCHAR" />
        <result column="to_tk_rate" property="tkRate" jdbcType="DECIMAL" />
        <result column="to_tk_money" property="tkMoney" jdbcType="DECIMAL" />
        <result column="to_technology_support_percent" property="technologySupportPercent"
            jdbcType="DECIMAL" />
        <result column="to_subsidy_ratio" property="subsidyRatio"
            jdbcType="DECIMAL" />
        <result column="to_subsidy" property="subsidy" jdbcType="DECIMAL" />
        <result column="to_subsidy_type" property="subsidyType"
            jdbcType="VARCHAR" />
        <result column="to_transaction_platform" property="transactionPlatform"
            jdbcType="VARCHAR" />
        <result column="to_third_service" property="thirdService"
            jdbcType="VARCHAR" />
        <result column="to_order_id" property="orderId" jdbcType="VARCHAR" />
        <result column="to_class_name" property="className" jdbcType="VARCHAR" />
        <result column="to_source_media_id" property="sourceMediaId"
            jdbcType="VARCHAR" />
        <result column="to_source_media_name" property="sourceMediaName"
            jdbcType="VARCHAR" />
        <result column="to_ad_position_id" property="adPositionId"
            jdbcType="VARCHAR" />
        <result column="to_ad_position_name" property="adPositionName"
            jdbcType="VARCHAR" />
        <result column="to_latest_updatetime" property="latestUpdateTime"
            jdbcType="TIMESTAMP" />
        <result column="to_orderby" property="orderBy" jdbcType="INTEGER" />
        <result column="to_relation_id" property="relationId" jdbcType="VARCHAR" />
        <result column="to_special_id" property="specialId" jdbcType="VARCHAR" />
        <result column="to_trade_id" property="tradeId" jdbcType="VARCHAR" />
    </resultMap>
    <sql id="Base_Column_List">to_id,to_create_time,to_click_time,to_title,to_auction_id,to_manager_wangwang,to_shop,to_count,to_price,to_order_state,to_order_type,to_iratio,to_sratio,to_payment,to_estimate,to_settlement,to_eIncome,to_settlement_time,to_tk_rate,to_tk_money,to_technology_support_percent,to_subsidy_ratio,to_subsidy,to_subsidy_type,to_transaction_platform,to_third_service,to_order_id,to_class_name,to_source_media_id,to_source_media_name,to_ad_position_id,to_ad_position_name,to_latest_updatetime,to_orderby,to_relation_id,to_special_id,to_trade_id
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_order where to_id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectTaoBaoOrderByOrderId" resultMap="BaseResultMap"
        parameterType="java.lang.String">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_order where to_order_id = #{0} for update
    </select>
    <select id="selectLatestByAuctionId" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_order where to_auction_id = #{0} order by to_id
        desc limit 1
    </select>
    <select id="selectTaoBaoOrderByTradeId" resultMap="BaseResultMap"
        parameterType="java.lang.String">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_order where to_trade_id = #{0} for update
    </select>
    <select id="listLongTimeNoUpdateOrders" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_taobao_order t WHERE t.`to_order_state`='订单付款'
        AND UNIX_TIMESTAMP(t.`to_create_time`) <![CDATA[  <  ]]>
        UNIX_TIMESTAMP()-60*60*24*15 AND (t.`to_latest_updatetime` IS NULL OR
        UNIX_TIMESTAMP(t.`to_latest_updatetime`)<![CDATA[ < ]]>
        UNIX_TIMESTAMP()-60*60*24*2) ORDER BY t.`to_create_time` DESC limit
        #{start},#{count}
    </select>
    <select id="listByTradeId" resultMap="BaseResultMap"
        parameterType="java.lang.String">
        select * from yeshi_ec_taobao_order where
        to_trade_id=#{0}
    </select>
    <select id="listAllOrder" resultMap="BaseResultMap">
        select * from yeshi_ec_taobao_order
        <if test="orderNo!=null">
            where to_order_id=#{orderNo}
        </if>
        order by to_create_time desc
        limit #{start},#{count}
    </select>
    <select id="countAllOrder" resultType="java.lang.Long">
        select count(to_id) from yeshi_ec_taobao_order
        <if test="orderNo!=null">
            where to_order_id=#{orderNo}
        </if>
    </select>
    <select id="listBySettlementTime" resultMap="BaseResultMap">
        select * from yeshi_ec_taobao_order
        where 1=1
        <if test="minTime!=null">
          and UNIX_TIMESTAMP(to_settlement_time)*1000>=#{minTime}
        </if>
        <if test="maxTime!=null">
          and #{maxTime}>UNIX_TIMESTAMP(to_settlement_time)*1000
        </if>
        order by to_settlement_time desc
        limit #{start},#{count}
    </select>
    <select id="countBySettlementTime" resultType="java.lang.Long">
        select count(to_id) from yeshi_ec_taobao_order
        where 1=1
        <if test="minTime!=null">
          and UNIX_TIMESTAMP(to_settlement_time)*1000>=#{minTime}
        </if>
        <if test="maxTime!=null">
          and #{maxTime}>UNIX_TIMESTAMP(to_settlement_time)*1000
        </if>
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_taobao_order where to_id = #{id,jdbcType=BIGINT}
    </delete>
    <delete id="deleteByOrderId" parameterType="java.lang.String">delete from
        yeshi_ec_taobao_order where to_order_id = #{0}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoOrder"
        useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_taobao_order
        (to_id,to_create_time,to_click_time,to_title,to_auction_id,to_manager_wangwang,to_shop,to_count,to_price,to_order_state,to_order_type,to_iratio,to_sratio,to_payment,to_estimate,to_settlement,to_eIncome,to_settlement_time,to_tk_rate,to_tk_money,to_technology_support_percent,to_subsidy_ratio,to_subsidy,to_subsidy_type,to_transaction_platform,to_third_service,to_order_id,to_class_name,to_source_media_id,to_source_media_name,to_ad_position_id,to_ad_position_name,to_latest_updatetime,to_orderby,to_relation_id,to_special_id,to_trade_id)
        values
        (#{id,jdbcType=BIGINT},#{createTime,jdbcType=VARCHAR},#{clickTime,jdbcType=VARCHAR},#{title,jdbcType=VARCHAR},#{auctionId,jdbcType=BIGINT},#{managerWangWang,jdbcType=VARCHAR},#{shop,jdbcType=VARCHAR},#{count,jdbcType=INTEGER},#{price,jdbcType=DECIMAL},#{orderState,jdbcType=VARCHAR},#{orderType,jdbcType=VARCHAR},#{iRatio,jdbcType=DECIMAL},#{sRatio,jdbcType=DECIMAL},#{payment,jdbcType=DECIMAL},#{estimate,jdbcType=DECIMAL},#{settlement,jdbcType=DECIMAL},#{eIncome,jdbcType=DECIMAL},#{settlementTime,jdbcType=VARCHAR},#{tkRate,jdbcType=DECIMAL},#{tkMoney,jdbcType=DECIMAL},#{technologySupportPercent,jdbcType=DECIMAL},#{subsidyRatio,jdbcType=DECIMAL},#{subsidy,jdbcType=DECIMAL},#{subsidyType,jdbcType=VARCHAR},#{transactionPlatform,jdbcType=VARCHAR},#{thirdService,jdbcType=VARCHAR},#{orderId,jdbcType=VARCHAR},#{className,jdbcType=VARCHAR},#{sourceMediaId,jdbcType=VARCHAR},#{sourceMediaName,jdbcType=VARCHAR},#{adPositionId,jdbcType=VARCHAR},#{adPositionName,jdbcType=VARCHAR},
        #{latestUpdateTime,jdbcType=TIMESTAMP},#{orderBy,jdbcType=INTEGER},
        #{relationId,jdbcType=VARCHAR},#{specialId,jdbcType=VARCHAR}
        ,#{tradeId,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoOrder"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_taobao_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">to_id,</if>
            <if test="createTime != null">to_create_time,</if>
            <if test="clickTime != null">to_click_time,</if>
            <if test="title != null">to_title,</if>
            <if test="auctionId != null">to_auction_id,</if>
            <if test="managerWangWang != null">to_manager_wangwang,</if>
            <if test="shop != null">to_shop,</if>
            <if test="count != null">to_count,</if>
            <if test="price != null">to_price,</if>
            <if test="orderState != null">to_order_state,</if>
            <if test="orderType != null">to_order_type,</if>
            <if test="iRatio != null">to_iratio,</if>
            <if test="sRatio != null">to_sratio,</if>
            <if test="payment != null">to_payment,</if>
            <if test="estimate != null">to_estimate,</if>
            <if test="settlement != null">to_settlement,</if>
            <if test="eIncome != null">to_eIncome,</if>
            <if test="settlementTime != null">to_settlement_time,</if>
            <if test="tkRate != null">to_tk_rate,</if>
            <if test="tkMoney != null">to_tk_money,</if>
            <if test="technologySupportPercent != null">to_technology_support_percent,</if>
            <if test="subsidyRatio != null">to_subsidy_ratio,</if>
            <if test="subsidy != null">to_subsidy,</if>
            <if test="subsidyType != null">to_subsidy_type,</if>
            <if test="transactionPlatform != null">to_transaction_platform,</if>
            <if test="thirdService != null">to_third_service,</if>
            <if test="orderId != null">to_order_id,</if>
            <if test="className != null">to_class_name,</if>
            <if test="sourceMediaId != null">to_source_media_id,</if>
            <if test="sourceMediaName != null">to_source_media_name,</if>
            <if test="adPositionId != null">to_ad_position_id,</if>
            <if test="adPositionName != null">to_ad_position_name,</if>
            <if test="latestUpdateTime != null">to_latest_updatetime,</if>
            <if test="orderBy != null">to_orderby,</if>
            <if test="relationId != null">to_relation_id,</if>
            <if test="specialId != null">to_special_id,</if>
            <if test="tradeId != null">to_trade_id,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="createTime != null">#{createTime,jdbcType=VARCHAR},</if>
            <if test="clickTime != null">#{clickTime,jdbcType=VARCHAR},</if>
            <if test="title != null">#{title,jdbcType=VARCHAR},</if>
            <if test="auctionId != null">#{auctionId,jdbcType=BIGINT},</if>
            <if test="managerWangWang != null">#{managerWangWang,jdbcType=VARCHAR},</if>
            <if test="shop != null">#{shop,jdbcType=VARCHAR},</if>
            <if test="count != null">#{count,jdbcType=INTEGER},</if>
            <if test="price != null">#{price,jdbcType=DECIMAL},</if>
            <if test="orderState != null">#{orderState,jdbcType=VARCHAR},</if>
            <if test="orderType != null">#{orderType,jdbcType=VARCHAR},</if>
            <if test="iRatio != null">#{iRatio,jdbcType=DECIMAL},</if>
            <if test="sRatio != null">#{sRatio,jdbcType=DECIMAL},</if>
            <if test="payment != null">#{payment,jdbcType=DECIMAL},</if>
            <if test="estimate != null">#{estimate,jdbcType=DECIMAL},</if>
            <if test="settlement != null">#{settlement,jdbcType=DECIMAL},</if>
            <if test="eIncome != null">#{eIncome,jdbcType=DECIMAL},</if>
            <if test="settlementTime != null">#{settlementTime,jdbcType=VARCHAR},</if>
            <if test="tkRate != null">#{tkRate,jdbcType=DECIMAL},</if>
            <if test="tkMoney != null">#{tkMoney,jdbcType=DECIMAL},</if>
            <if test="technologySupportPercent != null">#{technologySupportPercent,jdbcType=DECIMAL},</if>
            <if test="subsidyRatio != null">#{subsidyRatio,jdbcType=DECIMAL},</if>
            <if test="subsidy != null">#{subsidy,jdbcType=DECIMAL},</if>
            <if test="subsidyType != null">#{subsidyType,jdbcType=VARCHAR},</if>
            <if test="transactionPlatform != null">#{transactionPlatform,jdbcType=VARCHAR},</if>
            <if test="thirdService != null">#{thirdService,jdbcType=VARCHAR},</if>
            <if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if>
            <if test="className != null">#{className,jdbcType=VARCHAR},</if>
            <if test="sourceMediaId != null">#{sourceMediaId,jdbcType=VARCHAR},</if>
            <if test="sourceMediaName != null">#{sourceMediaName,jdbcType=VARCHAR},</if>
            <if test="adPositionId != null">#{adPositionId,jdbcType=VARCHAR},</if>
            <if test="adPositionName != null">#{adPositionName,jdbcType=VARCHAR},</if>
            <if test="latestUpdateTime != null">#{latestUpdateTime,jdbcType=TIMESTAMP},</if>
            <if test="orderBy != null">#{orderBy,jdbcType=INTEGER},</if>
            <if test="relationId != null">#{relationId,jdbcType=VARCHAR},</if>
            <if test="specialId != null">#{specialId,jdbcType=VARCHAR},</if>
            <if test="tradeId != null">#{tradeId,jdbcType=VARCHAR}</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoOrder">update
        yeshi_ec_taobao_order set to_create_time =
        #{createTime,jdbcType=VARCHAR},to_click_time =
        #{clickTime,jdbcType=VARCHAR},to_title =
        #{title,jdbcType=VARCHAR},to_auction_id =
        #{auctionId,jdbcType=BIGINT},to_manager_wangwang =
        #{managerWangWang,jdbcType=VARCHAR},to_shop =
        #{shop,jdbcType=VARCHAR},to_count = #{count,jdbcType=INTEGER},to_price
        = #{price,jdbcType=DECIMAL},to_order_state =
        #{orderState,jdbcType=VARCHAR},to_order_type =
        #{orderType,jdbcType=VARCHAR},to_iratio =
        #{iRatio,jdbcType=DECIMAL},to_sratio =
        #{sRatio,jdbcType=DECIMAL},to_payment =
        #{payment,jdbcType=DECIMAL},to_estimate =
        #{estimate,jdbcType=DECIMAL},to_settlement =
        #{settlement,jdbcType=DECIMAL},to_eIncome =
        #{eIncome,jdbcType=DECIMAL},to_settlement_time =
        #{settlementTime,jdbcType=VARCHAR},to_tk_rate =
        #{tkRate,jdbcType=DECIMAL},to_tk_money =
        #{tkMoney,jdbcType=DECIMAL},to_technology_support_percent =
        #{technologySupportPercent,jdbcType=DECIMAL},to_subsidy_ratio =
        #{subsidyRatio,jdbcType=DECIMAL},to_subsidy =
        #{subsidy,jdbcType=DECIMAL},to_subsidy_type =
        #{subsidyType,jdbcType=VARCHAR},to_transaction_platform =
        #{transactionPlatform,jdbcType=VARCHAR},to_third_service =
        #{thirdService,jdbcType=VARCHAR},to_order_id =
        #{orderId,jdbcType=VARCHAR},to_class_name =
        #{className,jdbcType=VARCHAR},to_source_media_id =
        #{sourceMediaId,jdbcType=VARCHAR},to_source_media_name =
        #{sourceMediaName,jdbcType=VARCHAR},to_ad_position_id =
        #{adPositionId,jdbcType=VARCHAR},to_ad_position_name =
        #{adPositionName,jdbcType=VARCHAR},to_latest_updatetime =
        #{latestUpdateTime,jdbcType=TIMESTAMP},to_orderby=
        #{orderBy,jdbcType=INTEGER},to_relation_id =
        #{relationId,jdbcType=VARCHAR},to_special_id=
        #{specialId,jdbcType=VARCHAR} ,to_trade_id
        =#{tradeId,jdbcType=VARCHAR} where to_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoOrder">
        update yeshi_ec_taobao_order
        <set>
            <if test="createTime != null">to_create_time=#{createTime,jdbcType=VARCHAR},</if>
            <if test="clickTime != null">to_click_time=#{clickTime,jdbcType=VARCHAR},</if>
            <if test="title != null">to_title=#{title,jdbcType=VARCHAR},</if>
            <if test="auctionId != null">to_auction_id=#{auctionId,jdbcType=BIGINT},</if>
            <if test="managerWangWang != null">to_manager_wangwang=#{managerWangWang,jdbcType=VARCHAR},
            </if>
            <if test="shop != null">to_shop=#{shop,jdbcType=VARCHAR},</if>
            <if test="count != null">to_count=#{count,jdbcType=INTEGER},</if>
            <if test="price != null">to_price=#{price,jdbcType=DECIMAL},</if>
            <if test="orderState != null">to_order_state=#{orderState,jdbcType=VARCHAR},</if>
            <if test="orderType != null">to_order_type=#{orderType,jdbcType=VARCHAR},</if>
            <if test="iRatio != null">to_iratio=#{iRatio,jdbcType=DECIMAL},</if>
            <if test="sRatio != null">to_sratio=#{sRatio,jdbcType=DECIMAL},</if>
            <if test="payment != null">to_payment=#{payment,jdbcType=DECIMAL},</if>
            <if test="estimate != null">to_estimate=#{estimate,jdbcType=DECIMAL},</if>
            <if test="settlement != null">to_settlement=#{settlement,jdbcType=DECIMAL},</if>
            <if test="eIncome != null">to_eIncome=#{eIncome,jdbcType=DECIMAL},</if>
            <if test="settlementTime != null">to_settlement_time=#{settlementTime,jdbcType=VARCHAR},
            </if>
            <if test="tkRate != null">to_tk_rate=#{tkRate,jdbcType=DECIMAL},</if>
            <if test="tkMoney != null">to_tk_money=#{tkMoney,jdbcType=DECIMAL},</if>
            <if test="technologySupportPercent != null">to_technology_support_percent=#{technologySupportPercent,jdbcType=DECIMAL},
            </if>
            <if test="subsidyRatio != null">to_subsidy_ratio=#{subsidyRatio,jdbcType=DECIMAL},</if>
            <if test="subsidy != null">to_subsidy=#{subsidy,jdbcType=DECIMAL},</if>
            <if test="subsidyType != null">to_subsidy_type=#{subsidyType,jdbcType=VARCHAR},</if>
            <if test="transactionPlatform != null">to_transaction_platform=#{transactionPlatform,jdbcType=VARCHAR},
            </if>
            <if test="thirdService != null">to_third_service=#{thirdService,jdbcType=VARCHAR},</if>
            <if test="orderId != null">to_order_id=#{orderId,jdbcType=VARCHAR},</if>
            <if test="className != null">to_class_name=#{className,jdbcType=VARCHAR},</if>
            <if test="sourceMediaId != null">to_source_media_id=#{sourceMediaId,jdbcType=VARCHAR},
            </if>
            <if test="sourceMediaName != null">to_source_media_name=#{sourceMediaName,jdbcType=VARCHAR},
            </if>
            <if test="adPositionId != null">to_ad_position_id=#{adPositionId,jdbcType=VARCHAR},</if>
            <if test="adPositionName != null">to_ad_position_name=#{adPositionName,jdbcType=VARCHAR},
            </if>
            <if test="latestUpdateTime != null">to_latest_updatetime=#{latestUpdateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="orderBy != null">to_orderby=#{orderBy,jdbcType=INTEGER},</if>
            <if test="relationId != null">to_relation_id=#{relationId,jdbcType=VARCHAR},</if>
            <if test="specialId != null">to_special_id=#{specialId,jdbcType=VARCHAR},</if>
            <if test="id !=null">to_id =#{id,jdbcType=BIGINT},</if>
            <if test="tradeId !=null">to_trade_id =#{tradeId,jdbcType=VARCHAR},</if>
        </set>
        where to_id = #{id,jdbcType=BIGINT}
    </update>
    <resultMap id="ResultMapExtral" type="com.yeshi.fanli.entity.admin.ReslutOrder">
        <id column="to_id" property="tboid" jdbcType="BIGINT" />
        <result column="to_create_time" property="createTime" jdbcType="VARCHAR" />
        <result column="to_click_time" property="clickTime" jdbcType="VARCHAR" />
        <result column="to_title" property="title" jdbcType="VARCHAR" />
        <result column="to_auction_id" property="auctionId" jdbcType="BIGINT" />
        <result column="to_manager_wangwang" property="managerWangWang"
            jdbcType="VARCHAR" />
        <result column="to_shop" property="shop" jdbcType="VARCHAR" />
        <result column="to_count" property="count" jdbcType="INTEGER" />
        <result column="to_price" property="price" jdbcType="DECIMAL" />
        <result column="to_order_state" property="orderState" jdbcType="VARCHAR" />
        <result column="to_order_type" property="orderType" jdbcType="VARCHAR" />
        <result column="to_iratio" property="iRatio" jdbcType="DECIMAL" />
        <result column="to_sratio" property="sRatio" jdbcType="DECIMAL" />
        <result column="to_payment" property="payment" jdbcType="DECIMAL" />
        <result column="to_estimate" property="estimate" jdbcType="DECIMAL" />
        <result column="to_settlement" property="settlement" jdbcType="DECIMAL" />
        <result column="to_eIncome" property="eIncome" jdbcType="DECIMAL" />
        <result column="to_settlement_time" property="settlementTime"
            jdbcType="VARCHAR" />
        <result column="to_tk_rate" property="tkRate" jdbcType="DECIMAL" />
        <result column="to_tk_money" property="tkMoney" jdbcType="DECIMAL" />
        <result column="to_technology_support_percent" property="technologySupportPercent"
            jdbcType="DECIMAL" />
        <result column="to_subsidy_ratio" property="subsidyRatio"
            jdbcType="DECIMAL" />
        <result column="to_subsidy" property="subsidy" jdbcType="DECIMAL" />
        <result column="to_subsidy_type" property="subsidyType"
            jdbcType="VARCHAR" />
        <result column="to_transaction_platform" property="transactionPlatform"
            jdbcType="VARCHAR" />
        <result column="to_third_service" property="thirdService"
            jdbcType="VARCHAR" />
        <result column="to_order_id" property="orderId" jdbcType="VARCHAR" />
        <result column="to_class_name" property="className" jdbcType="VARCHAR" />
        <result column="to_source_media_id" property="sourceMediaId"
            jdbcType="VARCHAR" />
        <result column="to_source_media_name" property="sourceMediaName"
            jdbcType="VARCHAR" />
        <result column="to_ad_position_id" property="adPositionId"
            jdbcType="VARCHAR" />
        <result column="to_ad_position_name" property="adPositionName"
            jdbcType="VARCHAR" />
        <result column="to_latest_updatetime" property="latestUpdateTime"
            jdbcType="TIMESTAMP" />
        <association property="userInfo" column="uid"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="uid" property="id" jdbcType="BIGINT" />
        </association>
    </resultMap>
    <select id="countByOdrerType" resultType="java.util.HashMap">SELECT COUNT(to_id)AS
        countTotal ,IFNULL(SUM(CASE WHEN `to_order_state` = '订单结算' THEN 1 WHEN
        `to_order_state` = '订单成功' THEN 1 ELSE 0 END),0) AS countSettlement,
        IFNULL(SUM(CASE WHEN `to_order_state` = '订单付款' THEN 1 ELSE 0 END),0)
        AS countPayment, IFNULL(SUM(CASE WHEN `to_order_state` = '订单失效' THEN 1
        ELSE 0 END),0) AS countInvalid FROM `yeshi_ec_taobao_order`
    </select>
    <select id="countToday" resultType="java.lang.Integer">SELECT
        COUNT(DISTINCT(tb.to_order_id)) FROM `yeshi_ec_taobao_order` tb WHERE <![CDATA[tb.`to_order_state`<>'订单失效'  AND TO_DAYS(tb.`to_create_time`) = TO_DAYS(NOW())]]>
    </select>
    <select id="countYesterday" resultType="java.lang.Integer">SELECT
        COUNT(DISTINCT(td.to_order_id))FROM `yeshi_ec_taobao_order` td WHERE <![CDATA[td.`to_order_state`<>'订单失效'  AND TO_DAYS(NOW()) - TO_DAYS( td.`to_create_time`) = 1 ]]>
    </select>
    <select id="countEstimate" resultType="java.lang.Double">SELECT
        IFNULL(SUM(t.to_estimate),0) FROM `yeshi_ec_taobao_order` t WHERE <![CDATA[ t.`to_order_state`<> '订单失效' ]]>
        AND DATE_FORMAT(t.`to_create_time` , '%Y-%m-%d' )= #{date}
    </select>
    <select id="getStateByOrderIdAndPayment" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_order where to_order_id = #{orderId} and
        to_payment = #{payment}
    </select>
    <sql id="Column_DateType">
        <if test="dateType == 1">DATE_FORMAT(t.`to_create_time`,'%Y-%m-%d') AS 'showDate'
        </if>
        <if test="dateType == 2">DATE_FORMAT(t.`to_create_time`,'%m') AS 'showDate'</if>
        <if test="dateType == 3">DATE_FORMAT(t.`to_create_time`,'%Y') AS 'showDate'</if>
    </sql>
    <sql id="Count_Select_DateType">
        <if test="startTime != null and startTime != '' ">
            AND DATE_FORMAT(t.`to_create_time`,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
        </if>
        <if test="endTime != null and endTime != '' ">
            AND DATE_FORMAT(t.`to_create_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
        </if>
        <if test="year != null and year != '' ">AND DATE_FORMAT(t.`to_create_time`,'%Y') = '${year}'</if>
    </sql>
    <sql id="Count_Group_DateType">
        <if test="dateType == 1">GROUP BY DATE_FORMAT(t.`to_create_time`,'%Y-%m-%d')</if>
        <if test="dateType == 2">GROUP BY DATE_FORMAT(t.`to_create_time`,'%Y-%m')</if>
        <if test="dateType == 3">GROUP BY DATE_FORMAT(t.`to_create_time`,'%Y')</if>
    </sql>
    <select id="countOrderNumber" resultType="java.util.HashMap">
        SELECT IFNULL(COUNT(t.`to_id`),0) AS showValue,
        <include refid="Column_DateType" />
        FROM `yeshi_ec_taobao_order` t WHERE t.`to_create_time` IS NOT NULL
        <include refid="Count_Select_DateType" />
        <include refid="Count_Group_DateType" />
        ORDER BY t.`to_create_time`
    </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.taobao.TaoBaoOrderMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.taobao.TaoBaoOrder">
        <id column="to_id" property="id" jdbcType="BIGINT" />
        <result column="to_create_time" property="createTime" jdbcType="VARCHAR" />
        <result column="to_click_time" property="clickTime" jdbcType="VARCHAR" />
        <result column="to_pay_time" property="payTime" jdbcType="VARCHAR" />
        <result column="to_title" property="title" jdbcType="VARCHAR" />
        <result column="to_auction_id" property="auctionId" jdbcType="BIGINT" />
        <result column="to_manager_wangwang" property="managerWangWang"
            jdbcType="VARCHAR" />
        <result column="to_shop" property="shop" jdbcType="VARCHAR" />
        <result column="to_count" property="count" jdbcType="INTEGER" />
        <result column="to_price" property="price" jdbcType="DECIMAL" />
        <result column="to_order_state" property="orderState" jdbcType="VARCHAR" />
        <result column="to_order_type" property="orderType" jdbcType="VARCHAR" />
        <result column="to_iratio" property="iRatio" jdbcType="DECIMAL" />
        <result column="to_sratio" property="sRatio" jdbcType="DECIMAL" />
        <result column="to_payment" property="payment" jdbcType="DECIMAL" />
        <result column="to_estimate" property="estimate" jdbcType="DECIMAL" />
        <result column="to_settlement" property="settlement" jdbcType="DECIMAL" />
        <result column="to_eIncome" property="eIncome" jdbcType="DECIMAL" />
        <result column="to_settlement_time" property="settlementTime"
            jdbcType="VARCHAR" />
        <result column="to_tk_rate" property="tkRate" jdbcType="DECIMAL" />
        <result column="to_tk_money" property="tkMoney" jdbcType="DECIMAL" />
        <result column="to_technology_support_percent" property="technologySupportPercent"
            jdbcType="DECIMAL" />
        <result column="to_subsidy_ratio" property="subsidyRatio"
            jdbcType="DECIMAL" />
        <result column="to_subsidy" property="subsidy" jdbcType="DECIMAL" />
        <result column="to_subsidy_type" property="subsidyType"
            jdbcType="VARCHAR" />
        <result column="to_transaction_platform" property="transactionPlatform"
            jdbcType="VARCHAR" />
        <result column="to_third_service" property="thirdService"
            jdbcType="VARCHAR" />
        <result column="to_order_id" property="orderId" jdbcType="VARCHAR" />
        <result column="to_class_name" property="className" jdbcType="VARCHAR" />
        <result column="to_source_media_id" property="sourceMediaId"
            jdbcType="VARCHAR" />
        <result column="to_source_media_name" property="sourceMediaName"
            jdbcType="VARCHAR" />
        <result column="to_ad_position_id" property="adPositionId"
            jdbcType="VARCHAR" />
        <result column="to_ad_position_name" property="adPositionName"
            jdbcType="VARCHAR" />
        <result column="to_latest_updatetime" property="latestUpdateTime"
            jdbcType="TIMESTAMP" />
        <result column="to_orderby" property="orderBy" jdbcType="INTEGER" />
        <result column="to_relation_id" property="relationId" jdbcType="VARCHAR" />
        <result column="to_special_id" property="specialId" jdbcType="VARCHAR" />
        <result column="to_trade_id" property="tradeId" jdbcType="VARCHAR" />
    </resultMap>
    <sql id="Base_Column_List">to_id,to_create_time,to_click_time,to_pay_time,to_title,to_auction_id,to_manager_wangwang,to_shop,to_count,to_price,to_order_state,to_order_type,to_iratio,to_sratio,to_payment,to_estimate,to_settlement,to_eIncome,to_settlement_time,to_tk_rate,to_tk_money,to_technology_support_percent,to_subsidy_ratio,to_subsidy,to_subsidy_type,to_transaction_platform,to_third_service,to_order_id,to_class_name,to_source_media_id,to_source_media_name,to_ad_position_id,to_ad_position_name,to_latest_updatetime,to_orderby,to_relation_id,to_special_id,to_trade_id
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_order where to_id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectTaoBaoOrderByOrderId" resultMap="BaseResultMap"
        parameterType="java.lang.String">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_order where to_order_id = #{0} for update
    </select>
    <select id="selectLatestByAuctionId" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_order where to_auction_id = #{0} order by to_id
        desc limit 1
    </select>
    <select id="selectTaoBaoOrderByTradeId" resultMap="BaseResultMap"
        parameterType="java.lang.String">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_order where to_trade_id = #{0} for update
    </select>
    <select id="listLongTimeNoUpdateOrders" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_taobao_order t WHERE t.`to_order_state`='订单付款'
        AND UNIX_TIMESTAMP(t.`to_create_time`) <![CDATA[  <  ]]>
        UNIX_TIMESTAMP()-60*60*24*15 AND (t.`to_latest_updatetime` IS NULL OR
        UNIX_TIMESTAMP(t.`to_latest_updatetime`)<![CDATA[ < ]]>
        UNIX_TIMESTAMP()-60*60*24*2) ORDER BY t.`to_create_time` DESC limit
        #{start},#{count}
    </select>
    <select id="listByTradeId" resultMap="BaseResultMap"
        parameterType="java.lang.String">
        select * from yeshi_ec_taobao_order where
        to_trade_id=#{0}
    </select>
    <select id="listAllOrder" resultMap="BaseResultMap">
        select * from yeshi_ec_taobao_order
        <if test="orderNo!=null">
            where to_order_id=#{orderNo}
        </if>
        order by to_create_time desc
        limit #{start},#{count}
    </select>
    <select id="countAllOrder" resultType="java.lang.Long">
        select count(to_id) from yeshi_ec_taobao_order
        <if test="orderNo!=null">
            where to_order_id=#{orderNo}
        </if>
    </select>
    <select id="listBySettlementTime" resultMap="BaseResultMap">
        select * from yeshi_ec_taobao_order
        where 1=1
        <if test="minTime!=null">
          and UNIX_TIMESTAMP(to_settlement_time)*1000>=#{minTime}
        </if>
        <if test="maxTime!=null">
          and #{maxTime}>UNIX_TIMESTAMP(to_settlement_time)*1000
        </if>
        order by to_settlement_time desc
        limit #{start},#{count}
    </select>
    <select id="countBySettlementTime" resultType="java.lang.Long">
        select count(to_id) from yeshi_ec_taobao_order
        where 1=1
        <if test="minTime!=null">
          and UNIX_TIMESTAMP(to_settlement_time)*1000>=#{minTime}
        </if>
        <if test="maxTime!=null">
          and #{maxTime}>UNIX_TIMESTAMP(to_settlement_time)*1000
        </if>
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_taobao_order where to_id = #{id,jdbcType=BIGINT}
    </delete>
    <delete id="deleteByOrderId" parameterType="java.lang.String">delete from
        yeshi_ec_taobao_order where to_order_id = #{0}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoOrder"
        useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_taobao_order
        (to_id,to_create_time,to_click_time,to_pay_time,to_title,to_auction_id,to_manager_wangwang,to_shop,to_count,to_price,to_order_state,to_order_type,to_iratio,to_sratio,to_payment,to_estimate,to_settlement,to_eIncome,to_settlement_time,to_tk_rate,to_tk_money,to_technology_support_percent,to_subsidy_ratio,to_subsidy,to_subsidy_type,to_transaction_platform,to_third_service,to_order_id,to_class_name,to_source_media_id,to_source_media_name,to_ad_position_id,to_ad_position_name,to_latest_updatetime,to_orderby,to_relation_id,to_special_id,to_trade_id)
        values
        (#{id,jdbcType=BIGINT},#{createTime,jdbcType=VARCHAR},#{clickTime,jdbcType=VARCHAR},#{payTime,jdbcType=VARCHAR},#{title,jdbcType=VARCHAR},#{auctionId,jdbcType=BIGINT},#{managerWangWang,jdbcType=VARCHAR},#{shop,jdbcType=VARCHAR},#{count,jdbcType=INTEGER},#{price,jdbcType=DECIMAL},#{orderState,jdbcType=VARCHAR},#{orderType,jdbcType=VARCHAR},#{iRatio,jdbcType=DECIMAL},#{sRatio,jdbcType=DECIMAL},#{payment,jdbcType=DECIMAL},#{estimate,jdbcType=DECIMAL},#{settlement,jdbcType=DECIMAL},#{eIncome,jdbcType=DECIMAL},#{settlementTime,jdbcType=VARCHAR},#{tkRate,jdbcType=DECIMAL},#{tkMoney,jdbcType=DECIMAL},#{technologySupportPercent,jdbcType=DECIMAL},#{subsidyRatio,jdbcType=DECIMAL},#{subsidy,jdbcType=DECIMAL},#{subsidyType,jdbcType=VARCHAR},#{transactionPlatform,jdbcType=VARCHAR},#{thirdService,jdbcType=VARCHAR},#{orderId,jdbcType=VARCHAR},#{className,jdbcType=VARCHAR},#{sourceMediaId,jdbcType=VARCHAR},#{sourceMediaName,jdbcType=VARCHAR},#{adPositionId,jdbcType=VARCHAR},#{adPositionName,jdbcType=VARCHAR},
        #{latestUpdateTime,jdbcType=TIMESTAMP},#{orderBy,jdbcType=INTEGER},
        #{relationId,jdbcType=VARCHAR},#{specialId,jdbcType=VARCHAR}
        ,#{tradeId,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoOrder"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_taobao_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">to_id,</if>
            <if test="createTime != null">to_create_time,</if>
            <if test="clickTime != null">to_click_time,</if>
            <if test="payTime != null">to_pay_time,</if>
            <if test="title != null">to_title,</if>
            <if test="auctionId != null">to_auction_id,</if>
            <if test="managerWangWang != null">to_manager_wangwang,</if>
            <if test="shop != null">to_shop,</if>
            <if test="count != null">to_count,</if>
            <if test="price != null">to_price,</if>
            <if test="orderState != null">to_order_state,</if>
            <if test="orderType != null">to_order_type,</if>
            <if test="iRatio != null">to_iratio,</if>
            <if test="sRatio != null">to_sratio,</if>
            <if test="payment != null">to_payment,</if>
            <if test="estimate != null">to_estimate,</if>
            <if test="settlement != null">to_settlement,</if>
            <if test="eIncome != null">to_eIncome,</if>
            <if test="settlementTime != null">to_settlement_time,</if>
            <if test="tkRate != null">to_tk_rate,</if>
            <if test="tkMoney != null">to_tk_money,</if>
            <if test="technologySupportPercent != null">to_technology_support_percent,</if>
            <if test="subsidyRatio != null">to_subsidy_ratio,</if>
            <if test="subsidy != null">to_subsidy,</if>
            <if test="subsidyType != null">to_subsidy_type,</if>
            <if test="transactionPlatform != null">to_transaction_platform,</if>
            <if test="thirdService != null">to_third_service,</if>
            <if test="orderId != null">to_order_id,</if>
            <if test="className != null">to_class_name,</if>
            <if test="sourceMediaId != null">to_source_media_id,</if>
            <if test="sourceMediaName != null">to_source_media_name,</if>
            <if test="adPositionId != null">to_ad_position_id,</if>
            <if test="adPositionName != null">to_ad_position_name,</if>
            <if test="latestUpdateTime != null">to_latest_updatetime,</if>
            <if test="orderBy != null">to_orderby,</if>
            <if test="relationId != null">to_relation_id,</if>
            <if test="specialId != null">to_special_id,</if>
            <if test="tradeId != null">to_trade_id,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="createTime != null">#{createTime,jdbcType=VARCHAR},</if>
            <if test="clickTime != null">#{clickTime,jdbcType=VARCHAR},</if>
            <if test="payTime != null">#{payTime,jdbcType=VARCHAR},</if>
            <if test="title != null">#{title,jdbcType=VARCHAR},</if>
            <if test="auctionId != null">#{auctionId,jdbcType=BIGINT},</if>
            <if test="managerWangWang != null">#{managerWangWang,jdbcType=VARCHAR},</if>
            <if test="shop != null">#{shop,jdbcType=VARCHAR},</if>
            <if test="count != null">#{count,jdbcType=INTEGER},</if>
            <if test="price != null">#{price,jdbcType=DECIMAL},</if>
            <if test="orderState != null">#{orderState,jdbcType=VARCHAR},</if>
            <if test="orderType != null">#{orderType,jdbcType=VARCHAR},</if>
            <if test="iRatio != null">#{iRatio,jdbcType=DECIMAL},</if>
            <if test="sRatio != null">#{sRatio,jdbcType=DECIMAL},</if>
            <if test="payment != null">#{payment,jdbcType=DECIMAL},</if>
            <if test="estimate != null">#{estimate,jdbcType=DECIMAL},</if>
            <if test="settlement != null">#{settlement,jdbcType=DECIMAL},</if>
            <if test="eIncome != null">#{eIncome,jdbcType=DECIMAL},</if>
            <if test="settlementTime != null">#{settlementTime,jdbcType=VARCHAR},</if>
            <if test="tkRate != null">#{tkRate,jdbcType=DECIMAL},</if>
            <if test="tkMoney != null">#{tkMoney,jdbcType=DECIMAL},</if>
            <if test="technologySupportPercent != null">#{technologySupportPercent,jdbcType=DECIMAL},</if>
            <if test="subsidyRatio != null">#{subsidyRatio,jdbcType=DECIMAL},</if>
            <if test="subsidy != null">#{subsidy,jdbcType=DECIMAL},</if>
            <if test="subsidyType != null">#{subsidyType,jdbcType=VARCHAR},</if>
            <if test="transactionPlatform != null">#{transactionPlatform,jdbcType=VARCHAR},</if>
            <if test="thirdService != null">#{thirdService,jdbcType=VARCHAR},</if>
            <if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if>
            <if test="className != null">#{className,jdbcType=VARCHAR},</if>
            <if test="sourceMediaId != null">#{sourceMediaId,jdbcType=VARCHAR},</if>
            <if test="sourceMediaName != null">#{sourceMediaName,jdbcType=VARCHAR},</if>
            <if test="adPositionId != null">#{adPositionId,jdbcType=VARCHAR},</if>
            <if test="adPositionName != null">#{adPositionName,jdbcType=VARCHAR},</if>
            <if test="latestUpdateTime != null">#{latestUpdateTime,jdbcType=TIMESTAMP},</if>
            <if test="orderBy != null">#{orderBy,jdbcType=INTEGER},</if>
            <if test="relationId != null">#{relationId,jdbcType=VARCHAR},</if>
            <if test="specialId != null">#{specialId,jdbcType=VARCHAR},</if>
            <if test="tradeId != null">#{tradeId,jdbcType=VARCHAR}</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoOrder">update
        yeshi_ec_taobao_order set to_create_time =
        #{createTime,jdbcType=VARCHAR},to_click_time =
        #{clickTime,jdbcType=VARCHAR},to_pay_time =
        #{payTime,jdbcType=VARCHAR},to_title =
        #{title,jdbcType=VARCHAR},to_auction_id =
        #{auctionId,jdbcType=BIGINT},to_manager_wangwang =
        #{managerWangWang,jdbcType=VARCHAR},to_shop =
        #{shop,jdbcType=VARCHAR},to_count = #{count,jdbcType=INTEGER},to_price
        = #{price,jdbcType=DECIMAL},to_order_state =
        #{orderState,jdbcType=VARCHAR},to_order_type =
        #{orderType,jdbcType=VARCHAR},to_iratio =
        #{iRatio,jdbcType=DECIMAL},to_sratio =
        #{sRatio,jdbcType=DECIMAL},to_payment =
        #{payment,jdbcType=DECIMAL},to_estimate =
        #{estimate,jdbcType=DECIMAL},to_settlement =
        #{settlement,jdbcType=DECIMAL},to_eIncome =
        #{eIncome,jdbcType=DECIMAL},to_settlement_time =
        #{settlementTime,jdbcType=VARCHAR},to_tk_rate =
        #{tkRate,jdbcType=DECIMAL},to_tk_money =
        #{tkMoney,jdbcType=DECIMAL},to_technology_support_percent =
        #{technologySupportPercent,jdbcType=DECIMAL},to_subsidy_ratio =
        #{subsidyRatio,jdbcType=DECIMAL},to_subsidy =
        #{subsidy,jdbcType=DECIMAL},to_subsidy_type =
        #{subsidyType,jdbcType=VARCHAR},to_transaction_platform =
        #{transactionPlatform,jdbcType=VARCHAR},to_third_service =
        #{thirdService,jdbcType=VARCHAR},to_order_id =
        #{orderId,jdbcType=VARCHAR},to_class_name =
        #{className,jdbcType=VARCHAR},to_source_media_id =
        #{sourceMediaId,jdbcType=VARCHAR},to_source_media_name =
        #{sourceMediaName,jdbcType=VARCHAR},to_ad_position_id =
        #{adPositionId,jdbcType=VARCHAR},to_ad_position_name =
        #{adPositionName,jdbcType=VARCHAR},to_latest_updatetime =
        #{latestUpdateTime,jdbcType=TIMESTAMP},to_orderby=
        #{orderBy,jdbcType=INTEGER},to_relation_id =
        #{relationId,jdbcType=VARCHAR},to_special_id=
        #{specialId,jdbcType=VARCHAR} ,to_trade_id
        =#{tradeId,jdbcType=VARCHAR} where to_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoOrder">
        update yeshi_ec_taobao_order
        <set>
            <if test="createTime != null">to_create_time=#{createTime,jdbcType=VARCHAR},</if>
            <if test="clickTime != null">to_click_time=#{clickTime,jdbcType=VARCHAR},</if>
            <if test="payTime != null">to_pay_time=#{payTime,jdbcType=VARCHAR},</if>
            <if test="title != null">to_title=#{title,jdbcType=VARCHAR},</if>
            <if test="auctionId != null">to_auction_id=#{auctionId,jdbcType=BIGINT},</if>
            <if test="managerWangWang != null">to_manager_wangwang=#{managerWangWang,jdbcType=VARCHAR},
            </if>
            <if test="shop != null">to_shop=#{shop,jdbcType=VARCHAR},</if>
            <if test="count != null">to_count=#{count,jdbcType=INTEGER},</if>
            <if test="price != null">to_price=#{price,jdbcType=DECIMAL},</if>
            <if test="orderState != null">to_order_state=#{orderState,jdbcType=VARCHAR},</if>
            <if test="orderType != null">to_order_type=#{orderType,jdbcType=VARCHAR},</if>
            <if test="iRatio != null">to_iratio=#{iRatio,jdbcType=DECIMAL},</if>
            <if test="sRatio != null">to_sratio=#{sRatio,jdbcType=DECIMAL},</if>
            <if test="payment != null">to_payment=#{payment,jdbcType=DECIMAL},</if>
            <if test="estimate != null">to_estimate=#{estimate,jdbcType=DECIMAL},</if>
            <if test="settlement != null">to_settlement=#{settlement,jdbcType=DECIMAL},</if>
            <if test="eIncome != null">to_eIncome=#{eIncome,jdbcType=DECIMAL},</if>
            <if test="settlementTime != null">to_settlement_time=#{settlementTime,jdbcType=VARCHAR},
            </if>
            <if test="tkRate != null">to_tk_rate=#{tkRate,jdbcType=DECIMAL},</if>
            <if test="tkMoney != null">to_tk_money=#{tkMoney,jdbcType=DECIMAL},</if>
            <if test="technologySupportPercent != null">to_technology_support_percent=#{technologySupportPercent,jdbcType=DECIMAL},
            </if>
            <if test="subsidyRatio != null">to_subsidy_ratio=#{subsidyRatio,jdbcType=DECIMAL},</if>
            <if test="subsidy != null">to_subsidy=#{subsidy,jdbcType=DECIMAL},</if>
            <if test="subsidyType != null">to_subsidy_type=#{subsidyType,jdbcType=VARCHAR},</if>
            <if test="transactionPlatform != null">to_transaction_platform=#{transactionPlatform,jdbcType=VARCHAR},
            </if>
            <if test="thirdService != null">to_third_service=#{thirdService,jdbcType=VARCHAR},</if>
            <if test="orderId != null">to_order_id=#{orderId,jdbcType=VARCHAR},</if>
            <if test="className != null">to_class_name=#{className,jdbcType=VARCHAR},</if>
            <if test="sourceMediaId != null">to_source_media_id=#{sourceMediaId,jdbcType=VARCHAR},
            </if>
            <if test="sourceMediaName != null">to_source_media_name=#{sourceMediaName,jdbcType=VARCHAR},
            </if>
            <if test="adPositionId != null">to_ad_position_id=#{adPositionId,jdbcType=VARCHAR},</if>
            <if test="adPositionName != null">to_ad_position_name=#{adPositionName,jdbcType=VARCHAR},
            </if>
            <if test="latestUpdateTime != null">to_latest_updatetime=#{latestUpdateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="orderBy != null">to_orderby=#{orderBy,jdbcType=INTEGER},</if>
            <if test="relationId != null">to_relation_id=#{relationId,jdbcType=VARCHAR},</if>
            <if test="specialId != null">to_special_id=#{specialId,jdbcType=VARCHAR},</if>
            <if test="id !=null">to_id =#{id,jdbcType=BIGINT},</if>
            <if test="tradeId !=null">to_trade_id =#{tradeId,jdbcType=VARCHAR},</if>
        </set>
        where to_id = #{id,jdbcType=BIGINT}
    </update>
    <resultMap id="ResultMapExtral" type="com.yeshi.fanli.entity.admin.ReslutOrder">
        <id column="to_id" property="tboid" jdbcType="BIGINT" />
        <result column="to_create_time" property="createTime" jdbcType="VARCHAR" />
        <result column="to_click_time" property="clickTime" jdbcType="VARCHAR" />
        <result column="to_pay_time" property="payTime" jdbcType="VARCHAR" />
        <result column="to_title" property="title" jdbcType="VARCHAR" />
        <result column="to_auction_id" property="auctionId" jdbcType="BIGINT" />
        <result column="to_manager_wangwang" property="managerWangWang"
            jdbcType="VARCHAR" />
        <result column="to_shop" property="shop" jdbcType="VARCHAR" />
        <result column="to_count" property="count" jdbcType="INTEGER" />
        <result column="to_price" property="price" jdbcType="DECIMAL" />
        <result column="to_order_state" property="orderState" jdbcType="VARCHAR" />
        <result column="to_order_type" property="orderType" jdbcType="VARCHAR" />
        <result column="to_iratio" property="iRatio" jdbcType="DECIMAL" />
        <result column="to_sratio" property="sRatio" jdbcType="DECIMAL" />
        <result column="to_payment" property="payment" jdbcType="DECIMAL" />
        <result column="to_estimate" property="estimate" jdbcType="DECIMAL" />
        <result column="to_settlement" property="settlement" jdbcType="DECIMAL" />
        <result column="to_eIncome" property="eIncome" jdbcType="DECIMAL" />
        <result column="to_settlement_time" property="settlementTime"
            jdbcType="VARCHAR" />
        <result column="to_tk_rate" property="tkRate" jdbcType="DECIMAL" />
        <result column="to_tk_money" property="tkMoney" jdbcType="DECIMAL" />
        <result column="to_technology_support_percent" property="technologySupportPercent"
            jdbcType="DECIMAL" />
        <result column="to_subsidy_ratio" property="subsidyRatio"
            jdbcType="DECIMAL" />
        <result column="to_subsidy" property="subsidy" jdbcType="DECIMAL" />
        <result column="to_subsidy_type" property="subsidyType"
            jdbcType="VARCHAR" />
        <result column="to_transaction_platform" property="transactionPlatform"
            jdbcType="VARCHAR" />
        <result column="to_third_service" property="thirdService"
            jdbcType="VARCHAR" />
        <result column="to_order_id" property="orderId" jdbcType="VARCHAR" />
        <result column="to_class_name" property="className" jdbcType="VARCHAR" />
        <result column="to_source_media_id" property="sourceMediaId"
            jdbcType="VARCHAR" />
        <result column="to_source_media_name" property="sourceMediaName"
            jdbcType="VARCHAR" />
        <result column="to_ad_position_id" property="adPositionId"
            jdbcType="VARCHAR" />
        <result column="to_ad_position_name" property="adPositionName"
            jdbcType="VARCHAR" />
        <result column="to_latest_updatetime" property="latestUpdateTime"
            jdbcType="TIMESTAMP" />
        <association property="userInfo" column="uid"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="uid" property="id" jdbcType="BIGINT" />
        </association>
    </resultMap>
    <select id="countByOdrerType" resultType="java.util.HashMap">SELECT COUNT(to_id)AS
        countTotal ,IFNULL(SUM(CASE WHEN `to_order_state` = '订单结算' THEN 1 WHEN
        `to_order_state` = '订单成功' THEN 1 ELSE 0 END),0) AS countSettlement,
        IFNULL(SUM(CASE WHEN `to_order_state` = '订单付款' THEN 1 ELSE 0 END),0)
        AS countPayment, IFNULL(SUM(CASE WHEN `to_order_state` = '订单失效' THEN 1
        ELSE 0 END),0) AS countInvalid FROM `yeshi_ec_taobao_order`
    </select>
    <select id="countToday" resultType="java.lang.Integer">SELECT
        COUNT(DISTINCT(tb.to_order_id)) FROM `yeshi_ec_taobao_order` tb WHERE <![CDATA[tb.`to_order_state`<>'订单失效'  AND TO_DAYS(tb.`to_create_time`) = TO_DAYS(NOW())]]>
    </select>
    <select id="countYesterday" resultType="java.lang.Integer">SELECT
        COUNT(DISTINCT(td.to_order_id))FROM `yeshi_ec_taobao_order` td WHERE <![CDATA[td.`to_order_state`<>'订单失效'  AND TO_DAYS(NOW()) - TO_DAYS( td.`to_create_time`) = 1 ]]>
    </select>
    <select id="countEstimate" resultType="java.lang.Double">SELECT
        IFNULL(SUM(t.to_estimate),0) FROM `yeshi_ec_taobao_order` t WHERE <![CDATA[ t.`to_order_state`<> '订单失效' ]]>
        AND DATE_FORMAT(t.`to_create_time` , '%Y-%m-%d' )= #{date}
    </select>
    <select id="getStateByOrderIdAndPayment" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_order where to_order_id = #{orderId} and
        to_payment = #{payment}
    </select>
    <sql id="Column_DateType">
        <if test="dateType == 1">DATE_FORMAT(t.`to_create_time`,'%Y-%m-%d') AS 'showDate'
        </if>
        <if test="dateType == 2">DATE_FORMAT(t.`to_create_time`,'%m') AS 'showDate'</if>
        <if test="dateType == 3">DATE_FORMAT(t.`to_create_time`,'%Y') AS 'showDate'</if>
    </sql>
    <sql id="Count_Select_DateType">
        <if test="startTime != null and startTime != '' ">
            AND DATE_FORMAT(t.`to_create_time`,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
        </if>
        <if test="endTime != null and endTime != '' ">
            AND DATE_FORMAT(t.`to_create_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
        </if>
        <if test="year != null and year != '' ">AND DATE_FORMAT(t.`to_create_time`,'%Y') = '${year}'</if>
    </sql>
    <sql id="Count_Group_DateType">
        <if test="dateType == 1">GROUP BY DATE_FORMAT(t.`to_create_time`,'%Y-%m-%d')</if>
        <if test="dateType == 2">GROUP BY DATE_FORMAT(t.`to_create_time`,'%Y-%m')</if>
        <if test="dateType == 3">GROUP BY DATE_FORMAT(t.`to_create_time`,'%Y')</if>
    </sql>
    <select id="countOrderNumber" resultType="java.util.HashMap">
        SELECT IFNULL(COUNT(t.`to_id`),0) AS showValue,
        <include refid="Column_DateType" />
        FROM `yeshi_ec_taobao_order` t WHERE t.`to_create_time` IS NOT NULL
        <include refid="Count_Select_DateType" />
        <include refid="Count_Group_DateType" />
        ORDER BY t.`to_create_time`
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/count/HongBaoV2CountServiceImpl.java
@@ -290,7 +290,7 @@
        long count = hongBaoV2CountMapper.countNumberByUid(uid);
        return (int) count;
    }
    @Override
    public BigDecimal countRebateCouponMoney() {
        return hongBaoV2CountMapper.countRebateCouponMoney();
@@ -308,4 +308,14 @@
    }
    
    @Override
    public BigDecimal sumAlreadyGetMoneyByUid(Long uid, List<Integer> typeList, Date minGetTime, Date maxGetTime) {
        return hongBaoV2CountMapper.sumAlreadyGetMoneyByUid(uid, typeList, minGetTime, maxGetTime);
    }
    @Override
    public long countAlreadyGetMoneyByUid(Long uid, List<Integer> typeList, Date minGetTime, Date maxGetTime) {
        return hongBaoV2CountMapper.countAlreadyGetMoneyByUid(uid, typeList, minGetTime, maxGetTime);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/order/tb/TaoBaoOrderServiceImpl.java
@@ -1,8 +1,5 @@
package com.yeshi.fanli.service.impl.order.tb;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceTokenOPPOServiceImpl.java
@@ -48,6 +48,18 @@
    }
    @Override
    public void bindUid(Long uid, Long deviceActiveId) {
        DeviceTokenOPPO oldOppo = deviceTokenOPPOMapper.selectByDeviceActiveId(deviceActiveId);
        if (oldOppo != null) {
            DeviceTokenOPPO update = new DeviceTokenOPPO();
            update.setId(oldOppo.getId());
            update.setUid(uid);
            update.setUpdateTime(new Date());
            deviceTokenOPPOMapper.updateByPrimaryKeySelective(update);
        }
    }
    @Override
    public long countDeviceToken(List<Integer> versionList) {
        return deviceTokenOPPOMapper.countDeviceToken(versionList);
    }
fanli/src/main/java/com/yeshi/fanli/service/inter/count/HongBaoV2CountService.java
@@ -29,6 +29,7 @@
    /**
     * 统计用户红包数量
     *
     * @param uid
     * @return
     */
@@ -151,6 +152,7 @@
    /**
     * 奖励券金额
     *
     * @return
     */
    public BigDecimal countRebateCouponMoney();
@@ -168,5 +170,18 @@
     * @return
     */
    public long countShareOrInviteOrder(Long uid);
    /**
     * 统计已到账
     *
     * @param uid
     * @param typeList
     * @param minGetTime
     * @param maxGetTime
     * @return
     */
    public BigDecimal sumAlreadyGetMoneyByUid(Long uid, List<Integer> typeList, Date minGetTime, Date maxGetTime);
    public long countAlreadyGetMoneyByUid(Long uid, List<Integer> typeList, Date minGetTime, Date maxGetTime);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/push/DeviceTokenOPPOService.java
@@ -28,6 +28,14 @@
    public void unBindUid(Long uid, Long deviceActiveId);
    /**
     * 绑定设备
     *
     * @param uid
     * @param deviceActiveId
     */
    public void bindUid(Long uid, Long deviceActiveId);
    /**
     * 计算所有的设备
     * 
     * @return
fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
@@ -174,7 +174,7 @@
            doImportantTaoBaoGoodsUpdateJob();// 淘宝重要商品的信息更新
            doHongBaoRecieveIntegralGetJob();// 返利到账,金币增加
//            doPlaceOrderIntegralJob();// 下单赠送金币任务
            doDouYinDeviceActiveJob();// 抖音设备激活广告监测
//            doDouYinDeviceActiveJob();// 抖音设备激活广告监测
        }
    }
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeOrderApiUtil.java
@@ -274,6 +274,7 @@
                    taoBaoOrder.setAuctionId(item.optLong("item_id"));
                    taoBaoOrder.setClassName(item.optString("item_category_name"));
                    taoBaoOrder.setClickTime(item.optString("click_time"));
                    taoBaoOrder.setPayTime(item.optString("tb_paid_time"));
                    taoBaoOrder.setCount(item.optInt("item_num"));
                    taoBaoOrder.setCreateTime(item.optString("tk_create_time"));
                    if (!StringUtil.isNullOrEmpty(item.optString("total_commission_fee")))