admin
2020-07-29 c338aa60df58bee9f4c25afedf94fe6930a119c1
SpringContext中的循环任务优化,添加业务监控
6个文件已添加
38个文件已修改
1个文件已删除
7393 ■■■■ 已修改文件
fanli/error.log.2020-07-10 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/MonitorController.java 125 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/ConfigAdminController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/CommonContentController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserAuthController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/DeviceTokenHWMapper.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/DeviceTokenOPPOMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/DeviceTokenVIVOMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/push/PushContentDetailDTO.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/SystemEnum.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/AdJob.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/order/jd/UpdateJDOrderJob.java 303 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/order/pdd/UpdatePDDOrderJob.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/order/suning/UpdateSuningOrderJob.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/order/taobao/UpdateTBRelationAndSpecialOrderJob.java 251 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/order/vipshop/UpdateVipShopOrderJob.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/JobThreadExecutorServiceImpl.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java 1289 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceTokenHWServiceImpl.java 150 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceTokenOPPOServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceTokenVIVOServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/HWPushServiceImpl.java 146 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/OPPOPushServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/VIVOPushServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/CommonTemplateContentService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/DeviceTokenHWService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/DeviceTokenOPPOService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/DeviceTokenVIVOService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/HWPushService.java 123 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/AppMarketUtil.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/Constant.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/RedisKeyEnum.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java 2208 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/cache/HttpGoodsCacheManager.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/mq/cmq/PushCMQManager.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/mapping/order/CommonOrderMapper.xml 2280 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/mapping/push/DeviceTokenHWMapper.xml 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/mapping/push/DeviceTokenOPPOMapper.xml 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/mapping/push/DeviceTokenVIVOMapper.xml 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/xxl-job-executor.properties 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/src/main/java/org/yeshi/utils/NetWorkUtil.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/error.log.2020-07-10
File was deleted
fanli/src/main/java/com/yeshi/fanli/controller/MonitorController.java
@@ -7,45 +7,120 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import com.yeshi.fanli.util.RedisKeyEnum;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.yeshi.fanli.service.inter.common.DataMonitorService;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.NetWorkUtil;
/**
 * 监控
 *
 * @author Administrator
 *
 * @author Administrator
 */
@Controller
@RequestMapping("monitor")
public class MonitorController {
    @Resource
    private DataMonitorService dataMonitorService;
    @Resource
    private RedisManager redisManager;
    /**
     * 10分钟外没爬单就判断为异常
     *
     * @param out
     */
    @RequestMapping("getTaoBaoOrderParseState")
    public void getTaoBaoOrderParseState(HttpServletResponse response, PrintWriter out) {
        Date date = dataMonitorService.getLatestParseTaoBaoOrderSuccessTime();
        // 10分钟做判断
        if (date != null && (Math.abs(date.getTime() - System.currentTimeMillis())) < 1000 * 60 * 10) {
            out.print(JsonUtil.loadTrueResult(""));
            return;
        } else {
            try {
                response.sendError(666, "订单爬取疑似有问题");
                return;
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    @Resource
    private DataMonitorService dataMonitorService;
    /**
     * 10分钟外没爬单就判断为异常
     *
     * @param out
     */
    @RequestMapping("getTaoBaoOrderParseState")
    public void getTaoBaoOrderParseState(HttpServletResponse response, PrintWriter out) {
        Date date = dataMonitorService.getLatestParseTaoBaoOrderSuccessTime();
        // 10分钟做判断
        if (date != null && (Math.abs(date.getTime() - System.currentTimeMillis())) < 1000 * 60 * 10) {
            out.print(JsonUtil.loadTrueResult(""));
            return;
        } else {
            try {
                response.sendError(666, "订单爬取疑似有问题");
                return;
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    /**
     * zookeeper服务
     */
    @RequestMapping("zookeeper")
    public void zookeeper(HttpServletResponse response, PrintWriter out) {
        if (NetWorkUtil.isHostConnectable("134.175.68.214", 2181, 2000)) {
            out.print("200");
        } else {
            try {
                response.sendError(666, "异常");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    /**
     * 商品服务
     */
    @RequestMapping("dubboGoodsService")
    public void dubboGoodsService(HttpServletResponse response, PrintWriter out) {
        if (NetWorkUtil.isHostConnectable("134.175.68.214", 20882, 2000)) {
            out.print("200");
        } else {
            try {
                response.sendError(666, "异常");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    /**
     * 订单爬取是否正常
     * @param platform
     * @return
     */
    private boolean isParseOrderNormal(String platform) {
        String st = redisManager.getCommonString(RedisKeyEnum.monitor.getKey() + platform);
        if (StringUtil.isNullOrEmpty(st)) {
            return false;
        }
        return true;
    }
    /**
     * 订单解析是否正常
     * @param sourceType
     * @param response
     * @param out
     */
    @RequestMapping("orderParse")
    public void dubboGoodsService(int sourceType, HttpServletResponse response, PrintWriter out) {
        if (isParseOrderNormal(sourceType+"")) {
            out.print("200");
        } else {
            try {
                response.sendError(666, "异常");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/admin/ConfigAdminController.java
@@ -14,6 +14,7 @@
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.accept.AdminAcceptData;
import com.yeshi.fanli.util.annotation.RequestNoLogin;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import net.sf.json.JSONArray;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.stereotype.Controller;
@@ -387,4 +388,13 @@
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(array.toString()));
    }
    @RequestNoLogin
    @RequestMapping(value = "getTaoBaoAuthLink")
    public void getTaoBaoAuthLink(AdminAcceptData acceptData, Long uid, String callback, PrintWriter out) {
        JSONObject data = new JSONObject();
        data.put("url", TaoBaoUtil.getTaoBaoAuthLink(uid, "bind"));
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/CommonContentController.java
@@ -66,7 +66,7 @@
            out.print(JsonUtil.loadFalseResult(1, "请传入Key"));
            return;
        }
        List<CommonContentNav> list = commonTemplateContentService.getNavList(CommonContentTypeEnum.valueOf(key));
        List<CommonContentNav> list = commonTemplateContentService.getNavList(CommonContentTypeEnum.valueOf(key),acceptData.getSystem());
        out.print(JsonUtil.loadTrueResult(new Gson().toJson(list)));
    }
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserAuthController.java
@@ -93,8 +93,7 @@
        boolean canParse = "0".equalsIgnoreCase(configService.getValue(ConfigKeyEnum.autoFindTaobaoOrder.getKey(), SystemInfoUtil.getSystem(acceptData))) ? false : true;
        String link = TaoBaoUtil.getTaoBaoUnionAuthUrl(TaoBaoConstant.TAOBAO_AUTH_APPKEY,
                "http://api.flqapp.com/fanli/client/v1/auth/callback/tb", uid, source);
        String link =     TaoBaoUtil.getTaoBaoAuthLink(uid, source);
        String orderJS = configService.getValue(ConfigKeyEnum.taobaoOrderParseJS.getKey(),SystemInfoUtil.getSystem(acceptData));
        if (!canParse)
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java
@@ -86,7 +86,7 @@
        List<CommonContentNav> list = null;
        if (type == null || type == Constant.SOURCE_TYPE_TAOBAO) {
            list = commonTemplateContentService.getNavList(CommonContentTypeEnum.valueOf(key));
            list = commonTemplateContentService.getNavList(CommonContentTypeEnum.valueOf(key),acceptData.getSystem());
        } else if (type == Constant.SOURCE_TYPE_JD) {
            // 暂无分类
        } else if (type == Constant.SOURCE_TYPE_PDD) {
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -1750,7 +1750,6 @@
    @RequestMapping(value = "getPDDLink")
    public void getPDDLink(AcceptData acceptData, Long uid, Long id, String source, PrintWriter out) {
        if (id == null || id <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空"));
            return;
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java
@@ -448,5 +448,8 @@
     * @return
     */
    CommonOrder getFirstOrder(@Param("uid") Long uid);
    List<CommonOrder> test();
    
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/DeviceTokenHWMapper.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.dao.mybatis.push;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
@@ -22,12 +23,14 @@
    List<DeviceTokenHW> selectByDeviceAndUid(@Param("device") String device, @Param("uid") Long uid);
    List<DeviceTokenHW> selectList(@Param("start") long start, @Param("count") int count,
    List<DeviceTokenHW> selectList(@Param("start") long start, @Param("count") int count,@Param("minUpdateTime") Date minUpdateTime,
            @Param("versionList") List<Integer> versionList);
    Long selectCount(@Param("versionList") List<Integer> versionList,@Param("minUpdateTime") Date minUpdateTime);
    List<DeviceTokenHW> selectByUid(@Param("uid") Long uid, @Param("versionList") List<Integer> versionList);
    Long selectCount(@Param("versionList") List<Integer> versionList);
    List<DeviceTokenHW> selectByDevice(String device);
    
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/DeviceTokenOPPOMapper.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.dao.mybatis.push;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
@@ -22,7 +23,7 @@
     * 
     * @return
     */
    long countDeviceToken(@Param("versionList")List<Integer> versionList);
    long countDeviceToken(@Param("versionList")List<Integer> versionList,@Param("minUpdateTime") Date minUpdateTime);
    /**
     * 设备列表
@@ -32,7 +33,7 @@
     * @return
     */
    List<DeviceTokenOPPO> listDeviceToken(@Param("start") long start, @Param("count") int count,
            @Param("versionList") List<Integer> versionList);
            @Param("versionList") List<Integer> versionList,@Param("minUpdateTime") Date minUpdateTime);
    /**
     * 根据用户ID查询
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/DeviceTokenVIVOMapper.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.dao.mybatis.push;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
@@ -22,7 +23,7 @@
     * 
     * @return
     */
    long countDeviceToken(@Param("versionList") List<Integer> versionList);
    long countDeviceToken(@Param("versionList") List<Integer> versionList,@Param("minUpdateTime") Date minUpdateTime);
    /**
     * 设备列表
@@ -32,7 +33,7 @@
     * @return
     */
    List<DeviceTokenVIVO> listDeviceToken(@Param("start") long start, @Param("count") int count,
            @Param("versionList") List<Integer> versionList);
            @Param("versionList") List<Integer> versionList,@Param("minUpdateTime") Date minUpdateTime);
    /**
     * 根据用户ID查询
fanli/src/main/java/com/yeshi/fanli/dto/push/PushContentDetailDTO.java
New file
@@ -0,0 +1,69 @@
package com.yeshi.fanli.dto.push;
//推送内容
public class PushContentDetailDTO {
    private PushTypeEnum type;
    private Long uid;
    private String url;
    private String webUrl;
    private Long goodsId;
    private PushBaseContent content;
    public PushContentDetailDTO(PushTypeEnum type, Long uid, String url, String webUrl, Long goodsId, PushBaseContent content) {
        this.type = type;
        this.uid = uid;
        this.url = url;
        this.webUrl = webUrl;
        this.goodsId = goodsId;
        this.content = content;
    }
    public PushTypeEnum getType() {
        return type;
    }
    public void setType(PushTypeEnum type) {
        this.type = type;
    }
    public Long getUid() {
        return uid;
    }
    public void setUid(Long uid) {
        this.uid = uid;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getWebUrl() {
        return webUrl;
    }
    public void setWebUrl(String webUrl) {
        this.webUrl = webUrl;
    }
    public Long getGoodsId() {
        return goodsId;
    }
    public void setGoodsId(Long goodsId) {
        this.goodsId = goodsId;
    }
    public PushBaseContent getContent() {
        return content;
    }
    public void setContent(PushBaseContent content) {
        this.content = content;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/SystemEnum.java
@@ -8,7 +8,7 @@
 */
public enum SystemEnum {
    blks("com.yeshi.ec.rebate", "com.xyj.ec.fanli-ios", new String[]{}, new SystemFunction[]{
            SystemFunction.bindPhone, SystemFunction.threeSale, SystemFunction.cloudOrder, SystemFunction.godenCorn, SystemFunction.redPack,SystemFunction.faQuan,SystemFunction.fanli
            SystemFunction.bindPhone, SystemFunction.threeSale, SystemFunction.cloudOrder, SystemFunction.godenCorn, SystemFunction.redPack,SystemFunction.faQuan,SystemFunction.fanli,SystemFunction.vip
    }, 1, "板栗快省"),
    flq("com.fanliunion.android", "com.xyj.ec.flq-ios", new String[]{}, new SystemFunction[]{SystemFunction.faQuan,SystemFunction.fanli}, 11, "返利联盟"),
    yhqjx("com.youhuiquanjx.android","com.youhuiquanjx.ios",new String[]{}, new SystemFunction[]{SystemFunction.faQuan}, 12, "优惠券精选");
fanli/src/main/java/com/yeshi/fanli/job/AdJob.java
New file
@@ -0,0 +1,44 @@
package com.yeshi.fanli.job;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.yeshi.fanli.entity.AppVersionInfo;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.common.Config;
import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.service.inter.config.AppVersionService;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.util.AppMarketUtil;
import com.yeshi.fanli.util.StringUtil;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
public class AdJob {
    @Resource
    private AppVersionService appVersionService;
    @Resource
    private ConfigService configService;
    @XxlJob("adjob-watchHWAppMarket")
    public ReturnT<String> watchHWAppMarket(String param) throws Exception {
        //查询目前的线上版本
        String version = AppMarketUtil.getHWLatestVersion("100513147");
        if (!StringUtil.isNullOrEmpty(version)) {
            AppVersionInfo appVersionInfo = appVersionService.getByPlatformAndVersion("android", version, SystemEnum.blks);
            if (appVersionInfo != null) {
                appVersionInfo.getId();
                Config config = configService.getConfig(ConfigKeyEnum.huaweiOnLineVersionCode.getKey(), SystemEnum.blks);
                if (appVersionInfo.getVersionCode() == Integer.parseInt(config.getValue())) {
                    //广告控制提升版本
                    config.setValue((Integer.parseInt(config.getValue()) + 1) + "");
                    configService.update(config);
                }
            }
        }
        return ReturnT.SUCCESS;
    }
}
fanli/src/main/java/com/yeshi/fanli/job/order/jd/UpdateJDOrderJob.java
@@ -6,6 +6,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.util.Constant;
import org.springframework.stereotype.Component;
import com.xxl.job.core.biz.model.ReturnT;
@@ -26,166 +27,172 @@
@Component
public class UpdateJDOrderJob {
    @Resource
    private JDOrderService jdOrderService;
    @Resource
    private JDOrderService jdOrderService;
    @Resource
    private RedisManager redisManager;
    @Resource
    private RedisManager redisManager;
    /**
     * 保存订单
     *
     * @param jdOrderList
     */
    public void saveJDOrders(List<JDOrder> jdOrderList) {
        for (JDOrder order : jdOrderList) {
            LogHelper.orderInfo("京东订单:" + order.getOrderId() + "-" + order.getValidCode());
            if (order.getValidCode() == 15)// 过滤掉待付款
                continue;
    /**
     * 保存订单
     *
     * @param jdOrderList
     */
    public void saveJDOrders(List<JDOrder> jdOrderList) {
        //5分钟不更新就报警
        try {
            redisManager.cacheCommonString(RedisKeyEnum.monitor.getKey() + Constant.SOURCE_TYPE_JD, "1", 60 * 5);
        } catch (Exception e) {
        }
            // 防止多个商品拆单问题,爬取
            if (order.getOrderItemList().size() > 1
                    && order.getOrderTime() > System.currentTimeMillis() - 1000 * 60 * 3L) {
                continue;
            }
        for (JDOrder order : jdOrderList) {
            LogHelper.orderInfo("京东订单:" + order.getOrderId() + "-" + order.getValidCode());
            if (order.getValidCode() == 15)// 过滤掉待付款
                continue;
            try {
                jdOrderService.addJDOrder(order);
                /**
                 * 做频率限制
                 */
                String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.JDOrder, order.getOrderId() + "");
                String result = redisManager.getCommonString(key);
                // 判断
                if (StringUtil.isNullOrEmpty(result)) {
                    JDOrderCMQManager.getInstance().addJDOrder(order.getOrderId() + "");
                    redisManager.cacheCommonString(key, "1", 60 * 60 * 2);// 2小时内不再更新
                }
            } catch (JDOrderException e) {
                e.printStackTrace();
            }
        }
    }
            // 防止多个商品拆单问题,爬取
            if (order.getOrderItemList().size() > 1
                    && order.getOrderTime() > System.currentTimeMillis() - 1000 * 60 * 3L) {
                continue;
            }
    /**
     * 快速订单更新(爬取本小时内的单,每分钟一次)
     */
    @XxlJob("updateJDOrderHandler")
    public ReturnT<String> updateJDSoonOrder(String param) throws Exception {
        if ("1".equalsIgnoreCase(param)) {// 更新本小时内的单
            LogHelper.job("开始爬取京东订单");
            long now = System.currentTimeMillis();
            try {
                jdOrderService.addJDOrder(order);
                /**
                 * 做频率限制
                 */
                String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.JDOrder, order.getOrderId() + "");
                String result = redisManager.getCommonString(key);
                // 判断
                if (StringUtil.isNullOrEmpty(result)) {
                    JDOrderCMQManager.getInstance().addJDOrder(order.getOrderId() + "");
                    redisManager.cacheCommonString(key, "1", 60 * 60 * 2);// 2小时内不再更新
                }
            } catch (JDOrderException e) {
                e.printStackTrace();
            }
        }
    }
            JDOrderResult result = JDApiUtil.getOrderList(1, 200, new Date(now), JDApiUtil.ORDER_TYPE_CREATETIME);
            if (result != null && result.getOrderList() != null)
                saveJDOrders(result.getOrderList());
            // 查询上个小时的
            result = JDApiUtil.getOrderList(1, 200, new Date(now - 1000 * 60 * 60L), JDApiUtil.ORDER_TYPE_CREATETIME);
            if (result != null && result.getOrderList() != null)
                saveJDOrders(result.getOrderList());
        } else if ("1hour".equalsIgnoreCase(param)) {// 更新1小时内的订单
            updateUpdateOrder();
        } else if ("1day".equalsIgnoreCase(param)) {// 更新1天内的订单
            updateLatestDayOrder(new Date(System.currentTimeMillis()));
        } else if ("3day".equalsIgnoreCase(param)) {// 更新最近3天更新的数据
            updateLatest3DayOrder();
        }
    /**
     * 快速订单更新(爬取本小时内的单,每分钟一次)
     */
    @XxlJob("updateJDOrderHandler")
    public ReturnT<String> updateJDSoonOrder(String param) throws Exception {
        if ("1".equalsIgnoreCase(param)) {// 更新本小时内的单
            LogHelper.job("开始爬取京东订单");
            long now = System.currentTimeMillis();
        return ReturnT.SUCCESS;
    }
            JDOrderResult result = JDApiUtil.getOrderList(1, 200, new Date(now), JDApiUtil.ORDER_TYPE_CREATETIME);
            if (result != null && result.getOrderList() != null)
                saveJDOrders(result.getOrderList());
            // 查询上个小时的
            result = JDApiUtil.getOrderList(1, 200, new Date(now - 1000 * 60 * 60L), JDApiUtil.ORDER_TYPE_CREATETIME);
            if (result != null && result.getOrderList() != null)
                saveJDOrders(result.getOrderList());
        } else if ("1hour".equalsIgnoreCase(param)) {// 更新1小时内的订单
            updateUpdateOrder();
        } else if ("1day".equalsIgnoreCase(param)) {// 更新1天内的订单
            updateLatestDayOrder(new Date(System.currentTimeMillis()));
        } else if ("3day".equalsIgnoreCase(param)) {// 更新最近3天更新的数据
            updateLatest3DayOrder();
        }
    /**
     * 爬取最近一小时内的状态更新了的单(10分钟一次)
     */
        return ReturnT.SUCCESS;
    }
    public void updateUpdateOrder() {
        List<JDOrder> jdOrderList = new ArrayList<>();
        int pageSize = 200;
        int page = 1;
        JDOrderResult result = JDApiUtil.getOrderList(page++, pageSize, new Date(), JDApiUtil.ORDER_TYPE_UPDATETIME);
        if (result != null) {
            jdOrderList.addAll(result.getOrderList());
            while (result != null && result.isHasMore()) {
                result = JDApiUtil.getOrderList(page++, pageSize, new Date(), JDApiUtil.ORDER_TYPE_UPDATETIME);
                if (result != null)
                    jdOrderList.addAll(result.getOrderList());
            }
        }
        saveJDOrders(jdOrderList);
    }
    /**
     * 爬取最近一小时内的状态更新了的单(10分钟一次)
     */
    /**
     * 更新一个小时的订单
     *
     * @param date
     */
    private List<JDOrder> getHourOrder(Date date) {
        List<JDOrder> jdOrderList = new ArrayList<>();
        int pageSize = 200;
        int page = 1;
        JDOrderResult result = JDApiUtil.getOrderList(page++, pageSize, date, JDApiUtil.ORDER_TYPE_UPDATETIME);
        if (result != null) {
            jdOrderList.addAll(result.getOrderList());
            while (result != null && result.isHasMore()) {
                result = JDApiUtil.getOrderList(page++, pageSize, date, JDApiUtil.ORDER_TYPE_UPDATETIME);
                if (result != null)
                    jdOrderList.addAll(result.getOrderList());
            }
        }
        return jdOrderList;
    }
    public void updateUpdateOrder() {
        List<JDOrder> jdOrderList = new ArrayList<>();
        int pageSize = 200;
        int page = 1;
        JDOrderResult result = JDApiUtil.getOrderList(page++, pageSize, new Date(), JDApiUtil.ORDER_TYPE_UPDATETIME);
        if (result != null) {
            jdOrderList.addAll(result.getOrderList());
            while (result != null && result.isHasMore()) {
                result = JDApiUtil.getOrderList(page++, pageSize, new Date(), JDApiUtil.ORDER_TYPE_UPDATETIME);
                if (result != null)
                    jdOrderList.addAll(result.getOrderList());
            }
        }
        saveJDOrders(jdOrderList);
    }
    /**
     * 更新一天的数据
     *
     * @param date
     */
    public void updateDayOrder(Date date) {
        Date now = new Date();
        List<JDOrder> orderList = new ArrayList<>();
        Date startTime = new Date(
                TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(date.getTime(), "yyyy-MM-dd"), "yyyy-MM-dd"));
        // 一个小时为一个步长
        for (int i = 0; i < 24; i++) {
            Date da = new Date(startTime.getTime() + 1000 * 60 * 60L * i);
            if (da.getTime() > now.getTime())
                break;
            List<JDOrder> tempOrderList = getHourOrder(da);
            if (tempOrderList != null && tempOrderList.size() > 0)
                orderList.addAll(tempOrderList);
        }
        saveJDOrders(orderList);
    }
    /**
     * 更新一个小时的订单
     *
     * @param date
     */
    private List<JDOrder> getHourOrder(Date date) {
        List<JDOrder> jdOrderList = new ArrayList<>();
        int pageSize = 200;
        int page = 1;
        JDOrderResult result = JDApiUtil.getOrderList(page++, pageSize, date, JDApiUtil.ORDER_TYPE_UPDATETIME);
        if (result != null) {
            jdOrderList.addAll(result.getOrderList());
            while (result != null && result.isHasMore()) {
                result = JDApiUtil.getOrderList(page++, pageSize, date, JDApiUtil.ORDER_TYPE_UPDATETIME);
                if (result != null)
                    jdOrderList.addAll(result.getOrderList());
            }
        }
        return jdOrderList;
    }
    /**
     * 更新最近一天的数据
     *
     * @param date
     */
    public void updateLatestDayOrder(Date date) {
        Date now = new Date();
        List<JDOrder> orderList = new ArrayList<>();
        Date startTime = new Date(date.getTime() - 1000 * 60 * 60 * 24L);
        // 一个小时为一个步长
        for (int i = 0; i < 24; i++) {
            Date da = new Date(startTime.getTime() + 1000 * 60 * 60L * i);
            if (da.getTime() > now.getTime())
                break;
            List<JDOrder> tempOrderList = getHourOrder(da);
            if (tempOrderList != null && tempOrderList.size() > 0)
                orderList.addAll(tempOrderList);
        }
        saveJDOrders(orderList);
    }
    /**
     * 更新一天的数据
     *
     * @param date
     */
    public void updateDayOrder(Date date) {
        Date now = new Date();
        List<JDOrder> orderList = new ArrayList<>();
        Date startTime = new Date(
                TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(date.getTime(), "yyyy-MM-dd"), "yyyy-MM-dd"));
        // 一个小时为一个步长
        for (int i = 0; i < 24; i++) {
            Date da = new Date(startTime.getTime() + 1000 * 60 * 60L * i);
            if (da.getTime() > now.getTime())
                break;
            List<JDOrder> tempOrderList = getHourOrder(da);
            if (tempOrderList != null && tempOrderList.size() > 0)
                orderList.addAll(tempOrderList);
        }
        saveJDOrders(orderList);
    }
    /**
     * 更新最近3天的订单(每天早上凌晨0点过10分,早上8点过10分)
     */
    public void updateLatest3DayOrder() {
        Date now = new Date();
        for (int i = 1; i < 4; i++) {
            updateDayOrder(new Date(now.getTime() - 1000 * 60 * 60 * 24L * i));
        }
    }
    /**
     * 更新最近一天的数据
     *
     * @param date
     */
    public void updateLatestDayOrder(Date date) {
        Date now = new Date();
        List<JDOrder> orderList = new ArrayList<>();
        Date startTime = new Date(date.getTime() - 1000 * 60 * 60 * 24L);
        // 一个小时为一个步长
        for (int i = 0; i < 24; i++) {
            Date da = new Date(startTime.getTime() + 1000 * 60 * 60L * i);
            if (da.getTime() > now.getTime())
                break;
            List<JDOrder> tempOrderList = getHourOrder(da);
            if (tempOrderList != null && tempOrderList.size() > 0)
                orderList.addAll(tempOrderList);
        }
        saveJDOrders(orderList);
    }
    /**
     * 更新最近3天的订单(每天早上凌晨0点过10分,早上8点过10分)
     */
    public void updateLatest3DayOrder() {
        Date now = new Date();
        for (int i = 1; i < 4; i++) {
            updateDayOrder(new Date(now.getTime() - 1000 * 60 * 60 * 24L * i));
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/job/order/pdd/UpdatePDDOrderJob.java
@@ -6,6 +6,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.util.Constant;
import org.springframework.stereotype.Component;
import com.xxl.job.core.biz.model.ReturnT;
@@ -35,6 +36,11 @@
     * @param jdOrderList
     */
    public void savePDDOrders(List<PDDOrder> orderList) {
        //5分钟不更新就报警
        try {
            redisManager.cacheCommonString(RedisKeyEnum.monitor.getKey() + Constant.SOURCE_TYPE_PDD, "1", 60 * 5);
        } catch (Exception e) {
        }
        for (PDDOrder order : orderList) {
            if (order.getOrderStatus() == 2) {
                System.out.println(order);
fanli/src/main/java/com/yeshi/fanli/job/order/suning/UpdateSuningOrderJob.java
@@ -6,6 +6,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.util.Constant;
import org.springframework.stereotype.Component;
import com.xxl.job.core.biz.model.ReturnT;
@@ -36,6 +37,12 @@
     * @param SuningOrderList
     */
    public void saveSuningOrders(List<SuningOrderInfo> suningOrderList) {
        //5分钟不更新就报警
        try {
            redisManager.cacheCommonString(RedisKeyEnum.monitor.getKey() + Constant.SOURCE_TYPE_SUNING, "1", 60 * 5);
        } catch (Exception e) {
        }
        for (SuningOrderInfo order : suningOrderList) {
            try {
                suningOrderService.addOrder(order);
fanli/src/main/java/com/yeshi/fanli/job/order/taobao/UpdateTBRelationAndSpecialOrderJob.java
@@ -7,6 +7,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.util.*;
import org.springframework.stereotype.Component;
import com.xxl.job.core.biz.model.ReturnT;
@@ -14,10 +15,6 @@
import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService;
import com.yeshi.fanli.util.CMQManager;
import com.yeshi.fanli.util.RedisKeyEnum;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import org.yeshi.utils.TimeUtil;
import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
@@ -25,147 +22,149 @@
/**
 * 淘宝渠道订单更新
 *
 * @author hexiaohui
 *
 * @author hexiaohui
 */
@Component
public class UpdateTBRelationAndSpecialOrderJob {
    @Resource
    private TaoBaoOrderService taoBaoOrderService;
    @Resource
    private TaoBaoOrderService taoBaoOrderService;
    @Resource
    private RedisManager redisManager;
    @Resource
    private RedisManager redisManager;
    /**
     * 更新渠道订单
     *
     * @param fromPage
     *            开始页码
     * @param toPage
     *            结束页码(每页100条数据)
     */
    public void updateRelationAndSpecialOrder(long startTime, long endTime) {
        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);
        // 爬取到的订单号
        if (list != null)
            for (TaoBaoOrder order : list) {
                LogHelper.orderInfo("会员/渠道爬取到的订单号:" + order.getOrderId());
            }
    /**
     * 更新渠道订单
     * @param startTime
     * @param endTime
     */
    public void updateRelationAndSpecialOrder(long startTime, long endTime) {
        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);
        // 爬取到的订单号
        if (list != null)
            for (TaoBaoOrder order : list) {
                LogHelper.orderInfo("会员/渠道爬取到的订单号:" + order.getOrderId());
            }
        addRelationAndSpecialOrder(list);
    }
        addRelationAndSpecialOrder(list);
    }
    /**
     * 按付款时间查询
     *
     * @param startTime
     * @param endTime
     */
    public void updateRelationAndSpecialPaidOrder(long startTime, long endTime) {
        List<TaoBaoOrder> list = TaoKeOrderApiUtil.getTaoBaoSpecialOrderList(startTime, endTime, 2);
        List<TaoBaoOrder> list1 = TaoKeOrderApiUtil.getTaoBaoRelationOrderList(startTime, endTime, 2);
        if (list1 != null && list1.size() > 0)
            list.addAll(list1);
        // 爬取到的订单号
        if (list != null)
            for (TaoBaoOrder order : list) {
                LogHelper.orderInfo("会员/渠道爬取到的订单号:" + order.getOrderId());
            }
    /**
     * 按付款时间查询
     *
     * @param startTime
     * @param endTime
     */
    public void updateRelationAndSpecialPaidOrder(long startTime, long endTime) {
        List<TaoBaoOrder> list = TaoKeOrderApiUtil.getTaoBaoSpecialOrderList(startTime, endTime, 2);
        List<TaoBaoOrder> list1 = TaoKeOrderApiUtil.getTaoBaoRelationOrderList(startTime, endTime, 2);
        if (list1 != null && list1.size() > 0)
            list.addAll(list1);
        // 爬取到的订单号
        if (list != null)
            for (TaoBaoOrder order : list) {
                LogHelper.orderInfo("会员/渠道爬取到的订单号:" + order.getOrderId());
            }
        addRelationAndSpecialOrder(list);
    }
        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);
        if (list1 != null && list1.size() > 0)
            list.addAll(list1);
        // 爬取到的订单号
        if (list != null)
            for (TaoBaoOrder order : list) {
                LogHelper.orderInfo("会员/渠道爬取到的订单号:" + order.getOrderId());
            }
        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);
        if (list1 != null && list1.size() > 0)
            list.addAll(list1);
        // 爬取到的订单号
        if (list != null)
            for (TaoBaoOrder order : list) {
                LogHelper.orderInfo("会员/渠道爬取到的订单号:" + order.getOrderId());
            }
        addRelationAndSpecialOrder(list);
    }
    private void addRelationAndSpecialOrder(List<TaoBaoOrder> orderList) {
        try {
            taoBaoOrderService.addTaoBaoOrderList(orderList);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
    private void addRelationAndSpecialOrder(List<TaoBaoOrder> orderList) {
        //5分钟不更新就报警
        try {
            redisManager.cacheCommonString(RedisKeyEnum.monitor.getKey() + Constant.SOURCE_TYPE_TAOBAO, "1", 60 * 5);
        } catch (Exception e) {
        }
        try {
            Map<String, List<TaoBaoOrder>> map = TaoBaoOrderUtil.classifyTaoBaoOrderByOrderId(orderList);
            if (map != null) {
                Iterator<String> its = map.keySet().iterator();
                while (its.hasNext()) {
                    String key = its.next();
                    List<TaoBaoOrder> orders = map.get(key);
                    String redisKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.addOrderQueue,
                            TaoBaoOrderUtil.getOrderDataHashCode(orders));
                    // redis做频率限制
                    try {
                        if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(redisKey))) {
                            continue;
                        }
        try {
            taoBaoOrderService.addTaoBaoOrderList(orderList);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
                    } catch (Exception e) {
        try {
            Map<String, List<TaoBaoOrder>> map = TaoBaoOrderUtil.classifyTaoBaoOrderByOrderId(orderList);
            if (map != null) {
                Iterator<String> its = map.keySet().iterator();
                while (its.hasNext()) {
                    String key = its.next();
                    List<TaoBaoOrder> orders = map.get(key);
                    String redisKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.addOrderQueue,
                            TaoBaoOrderUtil.getOrderDataHashCode(orders));
                    // redis做频率限制
                    try {
                        if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(redisKey))) {
                            continue;
                        }
                    }
                    } catch (Exception e) {
                    LogHelper.orderInfo("添加到队列:" + key);
                    if (orders != null && orders.size() > 0 && System.currentTimeMillis()
                            - TimeUtil.convertToTimeTemp(orders.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss") < 1000
                                    * 60 * 10L)// 10分钟内产生的单作为新订单处理
                        CMQManager.getInstance().addTaoBaoNewOrderMsg(key);
                    else
                        CMQManager.getInstance().addTaoBaoOrderMsg(key);
                    }
                    try {
                        // 20分钟内不再处理
                        redisManager.cacheCommonString(redisKey, "1", 60 * 20);
                    } catch (Exception e) {
                    LogHelper.orderInfo("添加到队列:" + key);
                    if (orders != null && orders.size() > 0 && System.currentTimeMillis()
                            - TimeUtil.convertToTimeTemp(orders.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss") < 1000
                            * 60 * 10L)// 10分钟内产生的单作为新订单处理
                        CMQManager.getInstance().addTaoBaoNewOrderMsg(key);
                    else
                        CMQManager.getInstance().addTaoBaoOrderMsg(key);
                    }
                }
            }
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
    }
                    try {
                        // 20分钟内不再处理
                        redisManager.cacheCommonString(redisKey, "1", 60 * 20);
                    } catch (Exception e) {
    @XxlJob("updateTBRelationAndSpecialOrderHandler")
    public ReturnT<String> updateTBRelationAndSpecialOrder(String param) throws Exception {
        if ("1".equalsIgnoreCase(param)) {//  爬取近20分钟的数据
            doJob1();
        } else if ("1day".equalsIgnoreCase(param)) {// 每5分钟更新(近1天数据)
            doJob2();
        }
        return ReturnT.SUCCESS;
    }
                    }
                }
            }
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
    }
    // 每30s爬取一次
    public void doJob1() {
        LogHelper.job("爬单:30s爬取一次单");
        Date systemDate = TaoKeApiUtil.getTaoBaoSystemTime();
        long endTime = systemDate != null ? systemDate.getTime() : System.currentTimeMillis();
        updateRelationAndSpecialOrder(endTime - 1000 * 60 * 20L, endTime);
        updateRelationAndSpecialPaidOrder(endTime - 1000 * 60 * 20L, endTime);
        updateRelationAndSpecialSettleOrder(endTime - 1000 * 60 * 20L, endTime);
    }
    @XxlJob("updateTBRelationAndSpecialOrderHandler")
    public ReturnT<String> updateTBRelationAndSpecialOrder(String param) throws Exception {
        if ("1".equalsIgnoreCase(param)) {//  爬取近20分钟的数据
            doJob1();
        } else if ("1day".equalsIgnoreCase(param)) {// 每5分钟更新(近1天数据)
            doJob2();
        }
        return ReturnT.SUCCESS;
    }
    // 每5分钟更新(近1天数据)
    public void doJob2() {
        LogHelper.job("爬单:5min爬取一次单");
        Date systemDate = TaoKeApiUtil.getTaoBaoSystemTime();
        long endTime = systemDate != null ? systemDate.getTime() : System.currentTimeMillis();
        updateRelationAndSpecialOrder(endTime - 1000 * 60 * 60 * 24L, endTime);
        updateRelationAndSpecialSettleOrder(endTime - 1000 * 60 * 60 * 24L, endTime);
    }
    // 每30s爬取一次
    public void doJob1() {
        LogHelper.job("爬单:30s爬取一次单");
        Date systemDate = TaoKeApiUtil.getTaoBaoSystemTime();
        long endTime = systemDate != null ? systemDate.getTime() : System.currentTimeMillis();
        updateRelationAndSpecialOrder(endTime - 1000 * 60 * 20L, endTime);
        updateRelationAndSpecialPaidOrder(endTime - 1000 * 60 * 20L, endTime);
        updateRelationAndSpecialSettleOrder(endTime - 1000 * 60 * 20L, endTime);
    }
    // 每5分钟更新(近1天数据)
    public void doJob2() {
        LogHelper.job("爬单:5min爬取一次单");
        Date systemDate = TaoKeApiUtil.getTaoBaoSystemTime();
        long endTime = systemDate != null ? systemDate.getTime() : System.currentTimeMillis();
        updateRelationAndSpecialOrder(endTime - 1000 * 60 * 60 * 24L, endTime);
        updateRelationAndSpecialSettleOrder(endTime - 1000 * 60 * 60 * 24L, endTime);
    }
}
fanli/src/main/java/com/yeshi/fanli/job/order/vipshop/UpdateVipShopOrderJob.java
@@ -5,6 +5,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.util.Constant;
import org.springframework.stereotype.Component;
import com.xxl.job.core.biz.model.ReturnT;
@@ -37,6 +38,11 @@
     * @param VipShopOrderList
     */
    public void saveVipShopOrders(List<VipShopOrder> vipShopOrderList) {
        //5分钟不更新就报警
        try {
            redisManager.cacheCommonString(RedisKeyEnum.monitor.getKey() + Constant.SOURCE_TYPE_VIP, "1", 60 * 5);
        } catch (Exception e) {
        }
        for (VipShopOrder order : vipShopOrderList) {
            try {
                vipShopOrderService.addOrder(order);
fanli/src/main/java/com/yeshi/fanli/service/impl/JobThreadExecutorServiceImpl.java
New file
@@ -0,0 +1,32 @@
package com.yeshi.fanli.service.impl;
import com.aliyun.openservices.shade.com.alibaba.rocketmq.common.ThreadFactoryImpl;
import org.yeshi.utils.TimeUtil;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
public class JobThreadExecutorServiceImpl {
    private ScheduledExecutorService scheduledExecutorService;
    public JobThreadExecutorServiceImpl() {
        scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
            @Override
            public Thread newThread(Runnable r) {
                Thread thread = new Thread(r);
                thread.setDaemon(true);
                return thread;
            }
        });
    }
    public void run(Runnable runnable) {
        scheduledExecutorService.scheduleAtFixedRate(runnable, 1000 * 1, 1000, TimeUnit.MILLISECONDS);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java
@@ -10,6 +10,8 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.SystemFunction;
import com.yeshi.fanli.util.SystemInfoUtil;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
@@ -40,707 +42,708 @@
@Service
public class CommonTemplateContentServiceImpl implements CommonTemplateContentService {
    @Resource
    private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
    @Resource
    private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
    @Resource
    private TaobaoMeterialService taobaoMeterialService;
    @Resource
    private TaobaoMeterialService taobaoMeterialService;
    @Resource
    private TaoKeGoodsService taoKeGoodsService;
    @Resource
    private TaoKeGoodsService taoKeGoodsService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private QualityGoodsService qualityGoodsService;
    @Resource
    private QualityGoodsService qualityGoodsService;
    @Resource
    private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
    @Resource
    private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
    private static List<CommonContentNav> getCommonNav() {
        List<CommonContentNav> navList = new ArrayList<>();
        navList.add(new CommonContentNav("1", "综合"));
        navList.add(new CommonContentNav("2", "最新"));
        navList.add(new CommonContentNav("3", "热卖"));
        navList.add(new CommonContentNav("4", "销量"));
        navList.add(new CommonContentNav("5", "返利比"));
        return navList;
    }
    private static List<CommonContentNav> getCommonNav(SystemEnum system) {
        List<CommonContentNav> navList = new ArrayList<>();
        navList.add(new CommonContentNav("1", "综合"));
        navList.add(new CommonContentNav("2", "最新"));
        navList.add(new CommonContentNav("3", "热卖"));
        navList.add(new CommonContentNav("4", "销量"));
        if (SystemInfoUtil.hasFunctions(system, SystemFunction.fanli))
            navList.add(new CommonContentNav("5", "返利比"));
        return navList;
    }
    private static int getCommonSort(String cid) {
        int sort = DaTaoKeApiUtil.SORT_DEFAULT;
        if ("1".equalsIgnoreCase(cid))
            sort = DaTaoKeApiUtil.SORT_DEFAULT;
        else if ("2".equalsIgnoreCase(cid))
            sort = DaTaoKeApiUtil.SORT_CREATETIME;
        else if ("3".equalsIgnoreCase(cid))
            sort = DaTaoKeApiUtil.SORT_COUPON_NUM;
        else if ("4".equalsIgnoreCase(cid))
            sort = DaTaoKeApiUtil.SORT_SALES;
        else if ("5".equalsIgnoreCase(cid))
            sort = DaTaoKeApiUtil.SORT_COMMISSION;
    private static int getCommonSort(String cid) {
        int sort = DaTaoKeApiUtil.SORT_DEFAULT;
        if ("1".equalsIgnoreCase(cid))
            sort = DaTaoKeApiUtil.SORT_DEFAULT;
        else if ("2".equalsIgnoreCase(cid))
            sort = DaTaoKeApiUtil.SORT_CREATETIME;
        else if ("3".equalsIgnoreCase(cid))
            sort = DaTaoKeApiUtil.SORT_COUPON_NUM;
        else if ("4".equalsIgnoreCase(cid))
            sort = DaTaoKeApiUtil.SORT_SALES;
        else if ("5".equalsIgnoreCase(cid))
            sort = DaTaoKeApiUtil.SORT_COMMISSION;
        return sort;
    }
        return sort;
    }
    @Override
    public List<CommonContentNav> getNavList(CommonContentTypeEnum type) {
        List<CommonContentNav> navList = new ArrayList<>();
        if (type == CommonContentTypeEnum._9k9) {
            navList.add(new CommonContentNav("-1", "综合"));
            navList.add(new CommonContentNav("0", "最新"));
            for (GoodsClass gc : DaTaoKeUtil.goodsClasses) {
                navList.add(new CommonContentNav(gc.getId() + "", gc.getName()));
            }
        } else if (type == CommonContentTypeEnum.chaoSheng) {
            navList.add(new CommonContentNav("1", "1-5元返利"));
            navList.add(new CommonContentNav("2", "5-10元返利 "));
            navList.add(new CommonContentNav("3", "10-15元返利"));
            navList.add(new CommonContentNav("4", "15-20元返利"));
            navList.add(new CommonContentNav("5", "20元以上返利"));
        } else if (type == CommonContentTypeEnum.haoQuan) {
            navList.add(new CommonContentNav("1", "1-5元券"));
            navList.add(new CommonContentNav("2", "5-10元券"));
            navList.add(new CommonContentNav("3", "10-20元券"));
            navList.add(new CommonContentNav("4", "20-30元券"));
            navList.add(new CommonContentNav("5", "30-50元券"));
            navList.add(new CommonContentNav("6", "50元以上券"));
        } else if (type == CommonContentTypeEnum.juJia) {
            navList = getCommonNav();
        } else if (type == CommonContentTypeEnum.meiShi) {
            navList = getCommonNav();
        } else if (type == CommonContentTypeEnum.muYin) {
            navList.add(new CommonContentNav("1", "精选"));
            navList.add(new CommonContentNav("备孕", "备孕"));
            navList.add(new CommonContentNav("0至6个月", "0~6月"));
            navList.add(new CommonContentNav("7至12个月", "7~12月"));
            navList.add(new CommonContentNav("1至3岁", "1~3岁"));
            navList.add(new CommonContentNav("4至6岁", "4~6岁"));
            navList.add(new CommonContentNav("7至12岁", "7~12岁"));
        } else if (type == CommonContentTypeEnum.reMai) {
            navList = getCommonNav();
        } else if (type == CommonContentTypeEnum.chuanYiDaPei) {
            navList = getCommonNav();
        } else if (type == CommonContentTypeEnum.meiZhuangGehu) {
            navList = getCommonNav();
        } else if (type == CommonContentTypeEnum.jingPinXieBao) {
            navList = getCommonNav();
        } else if (type == CommonContentTypeEnum.chaoNanReMai) {
            navList = getCommonNav();
        } else if (type == CommonContentTypeEnum.shuMaShouJi) {
            navList = getCommonNav();
        } else if (type == CommonContentTypeEnum.yunDongKuXie) {
            navList = getCommonNav();
        } else if (type == CommonContentTypeEnum.qiCheHuWai) {
            navList = getCommonNav();
        } else if (type == CommonContentTypeEnum.chaoPinReMai) {
            navList = getCommonNav();
        } else if (type == CommonContentTypeEnum.mianDan) {
            navList = new ArrayList<>();
        }
    @Override
    public List<CommonContentNav> getNavList(CommonContentTypeEnum type,SystemEnum system) {
        List<CommonContentNav> navList = new ArrayList<>();
        if (type == CommonContentTypeEnum._9k9) {
            navList.add(new CommonContentNav("-1", "综合"));
            navList.add(new CommonContentNav("0", "最新"));
            for (GoodsClass gc : DaTaoKeUtil.goodsClasses) {
                navList.add(new CommonContentNav(gc.getId() + "", gc.getName()));
            }
        } else if (type == CommonContentTypeEnum.chaoSheng) {
            navList.add(new CommonContentNav("1", "1-5元返利"));
            navList.add(new CommonContentNav("2", "5-10元返利 "));
            navList.add(new CommonContentNav("3", "10-15元返利"));
            navList.add(new CommonContentNav("4", "15-20元返利"));
            navList.add(new CommonContentNav("5", "20元以上返利"));
        } else if (type == CommonContentTypeEnum.haoQuan) {
            navList.add(new CommonContentNav("1", "1-5元券"));
            navList.add(new CommonContentNav("2", "5-10元券"));
            navList.add(new CommonContentNav("3", "10-20元券"));
            navList.add(new CommonContentNav("4", "20-30元券"));
            navList.add(new CommonContentNav("5", "30-50元券"));
            navList.add(new CommonContentNav("6", "50元以上券"));
        } else if (type == CommonContentTypeEnum.juJia) {
            navList = getCommonNav(system);
        } else if (type == CommonContentTypeEnum.meiShi) {
            navList = getCommonNav(system);
        } else if (type == CommonContentTypeEnum.muYin) {
            navList.add(new CommonContentNav("1", "精选"));
            navList.add(new CommonContentNav("备孕", "备孕"));
            navList.add(new CommonContentNav("0至6个月", "0~6月"));
            navList.add(new CommonContentNav("7至12个月", "7~12月"));
            navList.add(new CommonContentNav("1至3岁", "1~3岁"));
            navList.add(new CommonContentNav("4至6岁", "4~6岁"));
            navList.add(new CommonContentNav("7至12岁", "7~12岁"));
        } else if (type == CommonContentTypeEnum.reMai) {
            navList = getCommonNav(system);
        } else if (type == CommonContentTypeEnum.chuanYiDaPei) {
            navList = getCommonNav(system);
        } else if (type == CommonContentTypeEnum.meiZhuangGehu) {
            navList = getCommonNav(system);
        } else if (type == CommonContentTypeEnum.jingPinXieBao) {
            navList = getCommonNav(system);
        } else if (type == CommonContentTypeEnum.chaoNanReMai) {
            navList = getCommonNav(system);
        } else if (type == CommonContentTypeEnum.shuMaShouJi) {
            navList = getCommonNav(system);
        } else if (type == CommonContentTypeEnum.yunDongKuXie) {
            navList = getCommonNav(system);
        } else if (type == CommonContentTypeEnum.qiCheHuWai) {
            navList = getCommonNav(system);
        } else if (type == CommonContentTypeEnum.chaoPinReMai) {
            navList = getCommonNav(system);
        } else if (type == CommonContentTypeEnum.mianDan) {
            navList = new ArrayList<>();
        }
        return navList;
    }
        return navList;
    }
    @Cacheable(value = "commonContentCache", key = "#type+'-'+#cid+'-'+#page+'-'+#pageSize+'-'+#system")
    @Override
    public CommonContentResult getContentList(CommonContentTypeEnum type, String cid, int page, int pageSize, SystemEnum system) {
        CommonContentResult result = null;
        if (type == CommonContentTypeEnum._9k9) {
            result = get9K9Content(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.juJia) {
            result = getJuJiaShengHuoContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.muYin) {
            result = getMuYinJingXuanContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.meiShi) {
            result = getYouXuanMeiShiContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.chuanYiDaPei) {
            result = getChuanYiDaPeiContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.meiZhuangGehu) {
            result = getMeiZhuangGeHuContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.jingPinXieBao) {
            result = getJingPinXieBaoContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.chaoNanReMai) {
            result = getChaoNanReMaiContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.shuMaShouJi) {
            result = getShuMaShouJiContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.yunDongKuXie) {
            result = getYunDongKuXieContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.qiCheHuWai) {
            result = getQiCheHuWaiContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.chaoPinReMai) {
            result = getChaoPinReMaiContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.chaoSheng) {
            result = getCaoShengContent(cid, page, pageSize,system);
        } else if (type == CommonContentTypeEnum.haoQuan) {
            result = getHaoQuanContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.mianDan) {
            result = getMianDanContent(page, pageSize);
        }
    @Cacheable(value = "commonContentCache", key = "#type+'-'+#cid+'-'+#page+'-'+#pageSize+'-'+#system")
    @Override
    public CommonContentResult getContentList(CommonContentTypeEnum type, String cid, int page, int pageSize, SystemEnum system) {
        CommonContentResult result = null;
        if (type == CommonContentTypeEnum._9k9) {
            result = get9K9Content(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.juJia) {
            result = getJuJiaShengHuoContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.muYin) {
            result = getMuYinJingXuanContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.meiShi) {
            result = getYouXuanMeiShiContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.chuanYiDaPei) {
            result = getChuanYiDaPeiContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.meiZhuangGehu) {
            result = getMeiZhuangGeHuContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.jingPinXieBao) {
            result = getJingPinXieBaoContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.chaoNanReMai) {
            result = getChaoNanReMaiContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.shuMaShouJi) {
            result = getShuMaShouJiContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.yunDongKuXie) {
            result = getYunDongKuXieContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.qiCheHuWai) {
            result = getQiCheHuWaiContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.chaoPinReMai) {
            result = getChaoPinReMaiContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.chaoSheng) {
            result = getCaoShengContent(cid, page, pageSize, system);
        } else if (type == CommonContentTypeEnum.haoQuan) {
            result = getHaoQuanContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.mianDan) {
            result = getMianDanContent(page, pageSize);
        }
        if (result != null) {// 商品信息过滤
            List<TaoBaoGoodsBrief> goodsList = taoBaoGoodsUpdateService
                    .filterImportantTaoBaoGoods(result.getGoodsList());
            result.setGoodsList(goodsList);
        }
        if (result != null) {// 商品信息过滤
            List<TaoBaoGoodsBrief> goodsList = taoBaoGoodsUpdateService
                    .filterImportantTaoBaoGoods(result.getGoodsList());
            result.setGoodsList(goodsList);
        }
        return result;
    }
        return result;
    }
    /**
     * 9快9包邮
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult get9K9Content(String cid, int page, int pageSize) {
        if (pageSize == 20)
            pageSize = 50;
    /**
     * 9快9包邮
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult get9K9Content(String cid, int page, int pageSize) {
        if (pageSize == 20)
            pageSize = 50;
        DaTaoKeGoodsResult result = null;
        if ("-1".equalsIgnoreCase(cid)) {
            result = DaTaoKeApiUtil.getGoodsList("", null, null, new BigDecimal("10"), null, page, pageSize,
                    DaTaoKeApiUtil.SORT_DEFAULT);
        DaTaoKeGoodsResult result = null;
        if ("-1".equalsIgnoreCase(cid)) {
            result = DaTaoKeApiUtil.getGoodsList("", null, null, new BigDecimal("10"), null, page, pageSize,
                    DaTaoKeApiUtil.SORT_DEFAULT);
            if (result == null || result.getGoodsList() == null || result.getGoodsList().size() == 0) {
                result = new DaTaoKeGoodsResult();
                result.setGoodsList(
                        daTaoKeGoodsDetailV2Service.listByMaxPrice(null, new BigDecimal("10"), null, page, pageSize));
                result.setTotalCount(daTaoKeGoodsDetailV2Service.countByMaxPrice(null, new BigDecimal("10")));
            }
            if (result == null || result.getGoodsList() == null || result.getGoodsList().size() == 0) {
                result = new DaTaoKeGoodsResult();
                result.setGoodsList(
                        daTaoKeGoodsDetailV2Service.listByMaxPrice(null, new BigDecimal("10"), null, page, pageSize));
                result.setTotalCount(daTaoKeGoodsDetailV2Service.countByMaxPrice(null, new BigDecimal("10")));
            }
        } else if ("0".equalsIgnoreCase(cid)) {
            result = DaTaoKeApiUtil.getGoodsList("", null, null, new BigDecimal("10"), null, page, pageSize,
                    DaTaoKeApiUtil.SORT_CREATETIME);
            if (result == null || result.getGoodsList() == null || result.getGoodsList().size() == 0) {
                result = new DaTaoKeGoodsResult();
                result.setGoodsList(daTaoKeGoodsDetailV2Service.listByMaxPrice(null, new BigDecimal("10"), "createTime",
                        page, pageSize));
                result.setTotalCount(daTaoKeGoodsDetailV2Service.countByMaxPrice(null, new BigDecimal("10")));
            }
        } else {
            List<Integer> cidList = new ArrayList<>();
            cidList.add(Integer.parseInt(cid));
            result = DaTaoKeApiUtil.getGoodsList("", cidList, null, new BigDecimal("10"), null, page, pageSize,
                    DaTaoKeApiUtil.SORT_DEFAULT);
        } else if ("0".equalsIgnoreCase(cid)) {
            result = DaTaoKeApiUtil.getGoodsList("", null, null, new BigDecimal("10"), null, page, pageSize,
                    DaTaoKeApiUtil.SORT_CREATETIME);
            if (result == null || result.getGoodsList() == null || result.getGoodsList().size() == 0) {
                result = new DaTaoKeGoodsResult();
                result.setGoodsList(daTaoKeGoodsDetailV2Service.listByMaxPrice(null, new BigDecimal("10"), "createTime",
                        page, pageSize));
                result.setTotalCount(daTaoKeGoodsDetailV2Service.countByMaxPrice(null, new BigDecimal("10")));
            }
        } else {
            List<Integer> cidList = new ArrayList<>();
            cidList.add(Integer.parseInt(cid));
            result = DaTaoKeApiUtil.getGoodsList("", cidList, null, new BigDecimal("10"), null, page, pageSize,
                    DaTaoKeApiUtil.SORT_DEFAULT);
            if (result == null || result.getGoodsList() == null || result.getGoodsList().size() == 0) {
                result = new DaTaoKeGoodsResult();
                result.setGoodsList(daTaoKeGoodsDetailV2Service.listByMaxPrice(Integer.parseInt(cid),
                        new BigDecimal("10"), null, page, pageSize));
                result.setTotalCount(
                        daTaoKeGoodsDetailV2Service.countByMaxPrice(Integer.parseInt(cid), new BigDecimal("10")));
            }
        }
            if (result == null || result.getGoodsList() == null || result.getGoodsList().size() == 0) {
                result = new DaTaoKeGoodsResult();
                result.setGoodsList(daTaoKeGoodsDetailV2Service.listByMaxPrice(Integer.parseInt(cid),
                        new BigDecimal("10"), null, page, pageSize));
                result.setTotalCount(
                        daTaoKeGoodsDetailV2Service.countByMaxPrice(Integer.parseInt(cid), new BigDecimal("10")));
            }
        }
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
    }
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 超级省钱
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getCaoShengContent(String cid, int page, int pageSize, SystemEnum system) {
        pageSize = Constant.PAGE_SIZE;
        Integer startAmount = null;
        Integer endAmount = null;
    /**
     * 超级省钱
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getCaoShengContent(String cid, int page, int pageSize, SystemEnum system) {
        pageSize = Constant.PAGE_SIZE;
        Integer startAmount = null;
        Integer endAmount = null;
        if (cid.equalsIgnoreCase(1 + "")) {
            startAmount = 1;
            endAmount = 5;
        } else if (cid.equalsIgnoreCase(2 + "")) {
            startAmount = 5;
            endAmount = 10;
        } else if (cid.equalsIgnoreCase(3 + "")) {
            startAmount = 10;
            endAmount = 15;
        } else if (cid.equalsIgnoreCase(4 + "")) {
            startAmount = 15;
            endAmount = 20;
        } else if (cid.equalsIgnoreCase(5 + "")) {
            startAmount = 20;
            endAmount = 10000;
        }
        if (cid.equalsIgnoreCase(1 + "")) {
            startAmount = 1;
            endAmount = 5;
        } else if (cid.equalsIgnoreCase(2 + "")) {
            startAmount = 5;
            endAmount = 10;
        } else if (cid.equalsIgnoreCase(3 + "")) {
            startAmount = 10;
            endAmount = 15;
        } else if (cid.equalsIgnoreCase(4 + "")) {
            startAmount = 15;
            endAmount = 20;
        } else if (cid.equalsIgnoreCase(5 + "")) {
            startAmount = 20;
            endAmount = 10000;
        }
        double tkRate = 20.00;
        double tkRate = 20.00;
        BigDecimal proportion = hongBaoManageService.getFanLiRate(system);
        List<QualityFactory> listQuery = qualityGoodsService.listQueryByRebateAmount((page - 1) * pageSize, pageSize,
                proportion.toString(), startAmount, endAmount, tkRate);
        BigDecimal proportion = hongBaoManageService.getFanLiRate(system);
        List<QualityFactory> listQuery = qualityGoodsService.listQueryByRebateAmount((page - 1) * pageSize, pageSize,
                proportion.toString(), startAmount, endAmount, tkRate);
        long count = qualityGoodsService.countQueryByRebateAmount(proportion.toString(), startAmount, endAmount,
                tkRate);
        long count = qualityGoodsService.countQueryByRebateAmount(proportion.toString(), startAmount, endAmount,
                tkRate);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        // 遍历列表数据
        if (listQuery != null)
            for (QualityFactory quality : listQuery) {
                TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief();
                if (taoBaoGoodsBrief == null) {
                    continue;
                }
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        // 遍历列表数据
        if (listQuery != null)
            for (QualityFactory quality : listQuery) {
                TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief();
                if (taoBaoGoodsBrief == null) {
                    continue;
                }
                int biz30day = taoBaoGoodsBrief.getBiz30day();
                if (biz30day >= 10000) {
                    double sales = biz30day;
                    String salesCountMidea = String.format("%.1f", sales / 10000);
                    taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
                } else {
                    taoBaoGoodsBrief.setSalesCount(biz30day + "");
                }
                goodsList.add(taoBaoGoodsBrief);
            }
        return new CommonContentResult(goodsList, count);
    }
                int biz30day = taoBaoGoodsBrief.getBiz30day();
                if (biz30day >= 10000) {
                    double sales = biz30day;
                    String salesCountMidea = String.format("%.1f", sales / 10000);
                    taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
                } else {
                    taoBaoGoodsBrief.setSalesCount(biz30day + "");
                }
                goodsList.add(taoBaoGoodsBrief);
            }
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 高额好券
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getHaoQuanContent(String cid, int page, int pageSize) {
        pageSize = Constant.PAGE_SIZE;
    /**
     * 高额好券
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getHaoQuanContent(String cid, int page, int pageSize) {
        pageSize = Constant.PAGE_SIZE;
        Integer startAmount = null;
        Integer endAmount = null;
        Integer startAmount = null;
        Integer endAmount = null;
        if (cid.equalsIgnoreCase(1 + "")) {
            startAmount = 1;
            endAmount = 5;
        } else if (cid.equalsIgnoreCase(2 + "")) {
            startAmount = 5;
            endAmount = 10;
        } else if (cid.equalsIgnoreCase(3 + "")) {
            startAmount = 10;
            endAmount = 20;
        } else if (cid.equalsIgnoreCase(4 + "")) {
            startAmount = 20;
            endAmount = 30;
        } else if (cid.equalsIgnoreCase(5 + "")) {
            startAmount = 30;
            endAmount = 50;
        } else if (cid.equalsIgnoreCase(6 + "")) {
            startAmount = 50;
            endAmount = 10000;
        }
        if (cid.equalsIgnoreCase(1 + "")) {
            startAmount = 1;
            endAmount = 5;
        } else if (cid.equalsIgnoreCase(2 + "")) {
            startAmount = 5;
            endAmount = 10;
        } else if (cid.equalsIgnoreCase(3 + "")) {
            startAmount = 10;
            endAmount = 20;
        } else if (cid.equalsIgnoreCase(4 + "")) {
            startAmount = 20;
            endAmount = 30;
        } else if (cid.equalsIgnoreCase(5 + "")) {
            startAmount = 30;
            endAmount = 50;
        } else if (cid.equalsIgnoreCase(6 + "")) {
            startAmount = 50;
            endAmount = 10000;
        }
        Integer startPropor = 20;
        Integer startPropor = 20;
        List<QualityFactory> listQuery = qualityGoodsService.listQueryByCouponAmount((page - 1) * pageSize, pageSize,
                startAmount, endAmount, startPropor);
        List<QualityFactory> listQuery = qualityGoodsService.listQueryByCouponAmount((page - 1) * pageSize, pageSize,
                startAmount, endAmount, startPropor);
        long count = qualityGoodsService.countQueryByCouponAmount(startAmount, endAmount, startPropor);
        long count = qualityGoodsService.countQueryByCouponAmount(startAmount, endAmount, startPropor);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        // 遍历列表数据
        // 遍历列表数据
        for (QualityFactory selectionGoods : listQuery) {
        for (QualityFactory selectionGoods : listQuery) {
            TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
            TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
            if (taoBaoGoodsBrief == null) {
                continue;
            }
            if (taoBaoGoodsBrief == null) {
                continue;
            }
            int biz30day = taoBaoGoodsBrief.getBiz30day();
            if (biz30day >= 10000) {
                double sales = biz30day;
                String salesCountMidea = String.format("%.1f", sales / 10000);
                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
            } else {
                taoBaoGoodsBrief.setSalesCount(biz30day + "");
            }
            goodsList.add(taoBaoGoodsBrief);
        }
        return new CommonContentResult(goodsList, count);
    }
            int biz30day = taoBaoGoodsBrief.getBiz30day();
            if (biz30day >= 10000) {
                double sales = biz30day;
                String salesCountMidea = String.format("%.1f", sales / 10000);
                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
            } else {
                taoBaoGoodsBrief.setSalesCount(biz30day + "");
            }
            goodsList.add(taoBaoGoodsBrief);
        }
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 居家生活
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getJuJiaShengHuoContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        List<Integer> cidList = new ArrayList<>();
        cidList.add(4);// 居家生活
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 居家生活
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getJuJiaShengHuoContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        List<Integer> cidList = new ArrayList<>();
        cidList.add(4);// 居家生活
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 优选美食
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getYouXuanMeiShiContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        List<Integer> cidList = new ArrayList<>();
        cidList.add(6);// 美食
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 优选美食
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getYouXuanMeiShiContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        List<Integer> cidList = new ArrayList<>();
        cidList.add(6);// 美食
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 潮品热卖
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getChaoPinReMaiContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
    /**
     * 潮品热卖
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getChaoPinReMaiContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.search("潮", null, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
    }
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.search("潮", null, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 获取母婴精选
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getMuYinJingXuanContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        if ("1".equalsIgnoreCase(cid)) {// 大淘客数据
            List<Integer> cidList = new ArrayList<>();
            cidList.add(2);// 母婴
            result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize,
                    DaTaoKeApiUtil.SORT_DEFAULT);
    /**
     * 获取母婴精选
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getMuYinJingXuanContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        if ("1".equalsIgnoreCase(cid)) {// 大淘客数据
            List<Integer> cidList = new ArrayList<>();
            cidList.add(2);// 母婴
            result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize,
                    DaTaoKeApiUtil.SORT_DEFAULT);
            List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
            long count = 0;
            if (result != null) {
                count = result.getTotalCount();
                if (result.getGoodsList() != null)
                    for (DaTaoKeDetailV2 detail : result.getGoodsList())
                        goodsList.add(TaoBaoUtil.convert(detail));
            }
            return new CommonContentResult(goodsList, count);
            List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
            long count = 0;
            if (result != null) {
                count = result.getTotalCount();
                if (result.getGoodsList() != null)
                    for (DaTaoKeDetailV2 detail : result.getGoodsList())
                        goodsList.add(TaoBaoUtil.convert(detail));
            }
            return new CommonContentResult(goodsList, count);
        } else {//
            List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache("母婴_" + cid,
                    "母婴主题");
        } else {//
            List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache("母婴_" + cid,
                    "母婴主题");
            if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
                return null;
            }
            if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
                return null;
            }
            TaobaoMeterial meterial = taobaoMeterials.get(0);
            Integer materialId = meterial.getMaterialId();
            if (materialId != null) {
                List<TaoBaoGoodsBrief> listBrands = new ArrayList<>();
                try {
                    listBrands = taoKeGoodsService.listByMaterial(materialId, page, pageSize);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return new CommonContentResult(listBrands, 1000);
            }
            return new CommonContentResult(new ArrayList<>(), 0);
        }
            TaobaoMeterial meterial = taobaoMeterials.get(0);
            Integer materialId = meterial.getMaterialId();
            if (materialId != null) {
                List<TaoBaoGoodsBrief> listBrands = new ArrayList<>();
                try {
                    listBrands = taoKeGoodsService.listByMaterial(materialId, page, pageSize);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return new CommonContentResult(listBrands, 1000);
            }
            return new CommonContentResult(new ArrayList<>(), 0);
        }
    }
    }
    /**
     * 穿衣搭配
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getChuanYiDaPeiContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        List<Integer> cidList = new ArrayList<>();
        cidList.add(1);// 女装
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
    /**
     * 穿衣搭配
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getChuanYiDaPeiContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        List<Integer> cidList = new ArrayList<>();
        cidList.add(1);// 女装
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
    }
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 美妆个护
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getMeiZhuangGeHuContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        List<Integer> cidList = new ArrayList<>();
        cidList.add(3);// 美妆
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.search("洗护", cidList, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 美妆个护
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getMeiZhuangGeHuContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        List<Integer> cidList = new ArrayList<>();
        cidList.add(3);// 美妆
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.search("洗护", cidList, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 精品鞋包
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    /**
     * 精品鞋包
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getJingPinXieBaoContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.search("鞋 女", null, null, null, page, pageSize, sort);
        DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("包 女", null, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount() + result1.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
            if (result1.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result1.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        Collections.shuffle(goodsList);
        return new CommonContentResult(goodsList, count);
    }
    private CommonContentResult getJingPinXieBaoContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.search("鞋 女", null, null, null, page, pageSize, sort);
        DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("包 女", null, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount() + result1.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
            if (result1.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result1.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        Collections.shuffle(goodsList);
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 潮男热卖
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getChaoNanReMaiContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.search("潮 男", null, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        Collections.shuffle(goodsList);
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 潮男热卖
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getChaoNanReMaiContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.search("潮 男", null, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        Collections.shuffle(goodsList);
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 数码手机
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getShuMaShouJiContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.search("电", null, null, null, page, pageSize, sort);
        DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("手机", null, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount() + result1.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
            if (result1.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result1.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        Collections.shuffle(goodsList);
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 数码手机
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getShuMaShouJiContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.search("电", null, null, null, page, pageSize, sort);
        DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("手机", null, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount() + result1.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
            if (result1.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result1.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        Collections.shuffle(goodsList);
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 运动酷鞋
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getYunDongKuXieContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.search("鞋 男", null, null, null, page, pageSize, sort);
        DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("运动 男", null, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount() + result1.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
            if (result1.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result1.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        Collections.shuffle(goodsList);
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 运动酷鞋
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getYunDongKuXieContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.search("鞋 男", null, null, null, page, pageSize, sort);
        DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("运动 男", null, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount() + result1.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
            if (result1.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result1.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        Collections.shuffle(goodsList);
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 汽车户外
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getQiCheHuWaiContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        List<Integer> cidList = new ArrayList<>();
        cidList.add(7);
        cidList.add(13);
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
        DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("运动 男", cidList, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount() + result1.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
            if (result1.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result1.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        Collections.shuffle(goodsList);
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 汽车户外
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getQiCheHuWaiContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        List<Integer> cidList = new ArrayList<>();
        cidList.add(7);
        cidList.add(13);
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
        DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("运动 男", cidList, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount() + result1.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
            if (result1.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result1.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        Collections.shuffle(goodsList);
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 获取免单商品
     *
     * @return
     */
    private CommonContentResult getMianDanContent(int page, int pageSize) {
        CommonContentResult result = new CommonContentResult();
        List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
        long count = qualityGoodsService.countFreeGoods();
        result.setCount(count);
        List<Long> listGid = new ArrayList<Long>();
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        for (QualityFactory qualityFactory : listQuery) {
            TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
            if (taoBaoGoodsBrief == null) {
                continue;
            }
            listGid.add(taoBaoGoodsBrief.getAuctionId());
            goodsList.add(taoBaoGoodsBrief);
        }
        // 去掉已经不在售的商品
        List<TaoBaoGoodsBrief> listTaoKeGoods = null;
        try {
            listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
        } catch (TaoKeApiException e) {
            e.printStackTrace();
        } catch (TaobaoGoodsDownException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        Map<Long, TaoBaoGoodsBrief> goodsMap = new HashMap<>();
        if (listTaoKeGoods != null)
            for (TaoBaoGoodsBrief goods : listTaoKeGoods)
                goodsMap.put(goods.getAuctionId(), goods);
        for (int i = 0; i < goodsList.size(); i++) {
            if (goodsMap.get(goodsList.get(i).getAuctionId()) == null) {
                goodsList.remove(i--);
            }
        }
        // 过滤基本商品信息
        goodsList = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(goodsList);
    /**
     * 获取免单商品
     *
     * @return
     */
    private CommonContentResult getMianDanContent(int page, int pageSize) {
        CommonContentResult result = new CommonContentResult();
        List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
        long count = qualityGoodsService.countFreeGoods();
        result.setCount(count);
        List<Long> listGid = new ArrayList<Long>();
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        for (QualityFactory qualityFactory : listQuery) {
            TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
            if (taoBaoGoodsBrief == null) {
                continue;
            }
            listGid.add(taoBaoGoodsBrief.getAuctionId());
            goodsList.add(taoBaoGoodsBrief);
        }
        // 去掉已经不在售的商品
        List<TaoBaoGoodsBrief> listTaoKeGoods = null;
        try {
            listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
        } catch (TaoKeApiException e) {
            e.printStackTrace();
        } catch (TaobaoGoodsDownException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        Map<Long, TaoBaoGoodsBrief> goodsMap = new HashMap<>();
        if (listTaoKeGoods != null)
            for (TaoBaoGoodsBrief goods : listTaoKeGoods)
                goodsMap.put(goods.getAuctionId(), goods);
        for (int i = 0; i < goodsList.size(); i++) {
            if (goodsMap.get(goodsList.get(i).getAuctionId()) == null) {
                goodsList.remove(i--);
            }
        }
        // 过滤基本商品信息
        goodsList = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(goodsList);
        for (int i = 0; i < goodsList.size(); i++) {
            TaoBaoGoodsBrief goods = goodsList.get(i);
            BigDecimal price = TaoBaoUtil.getAfterUseCouplePrice(goods);
            if (price.compareTo(new BigDecimal(10)) >= 0) {
                goodsList.remove(i--);
            }
        }
        result.setGoodsList(goodsList);
        return result;
    }
        for (int i = 0; i < goodsList.size(); i++) {
            TaoBaoGoodsBrief goods = goodsList.get(i);
            BigDecimal price = TaoBaoUtil.getAfterUseCouplePrice(goods);
            if (price.compareTo(new BigDecimal(10)) >= 0) {
                goodsList.remove(i--);
            }
        }
        result.setGoodsList(goodsList);
        return result;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceTokenHWServiceImpl.java
@@ -17,90 +17,90 @@
@Service
public class DeviceTokenHWServiceImpl implements DeviceTokenHWService {
    @Resource
    private DeviceTokenHWMapper deviceTokenHWMapper;
    @Resource
    private DeviceTokenHWMapper deviceTokenHWMapper;
    @Override
    public List<DeviceTokenHW> getDeviceTokenList(int page, int pageSize, List<Integer> versionList) {
        return deviceTokenHWMapper.selectList((page - 1) * pageSize, pageSize, versionList);
    }
    @Override
    public List<DeviceTokenHW> getDeviceTokenList(int page, int pageSize, List<Integer> versionList, Date minUpdateTime) {
        return deviceTokenHWMapper.selectList((page - 1) * pageSize, pageSize, minUpdateTime, versionList);
    }
    @Override
    public Long countDeviceToken(List<Integer> versionList) {
        Long count = deviceTokenHWMapper.selectCount(versionList);
        return count == null ? 0 : count;
    }
    @Override
    public Long countDeviceToken(List<Integer> versionList,Date minUpdateTime) {
        Long count = deviceTokenHWMapper.selectCount(versionList,minUpdateTime);
        return count == null ? 0 : count;
    }
    @Transactional
    @Override
    public void addDeviceToken(String token, String device, Long uid, int version) {
        if (StringUtil.isNullOrEmpty(device))
            return;
        //
        if (uid != null && uid == 0)
            uid = null;
    @Transactional
    @Override
    public void addDeviceToken(String token, String device, Long uid, int version) {
        if (StringUtil.isNullOrEmpty(device))
            return;
        //
        if (uid != null && uid == 0)
            uid = null;
        List<DeviceTokenHW> list = deviceTokenHWMapper.selectByDeviceForUpdate(device);
        if (list == null || list.size() == 0) {
            DeviceTokenHW deviceTokenHW = new DeviceTokenHW();
            deviceTokenHW.setDevice(device);
            deviceTokenHW.setDeviceToken(token);
            deviceTokenHW.setDeviceTokenMd5(StringUtil.Md5(token));
            deviceTokenHW.setVersion(version);
            deviceTokenHW.setUpdateTime(new Date());
            if (uid != null)
                deviceTokenHW.setUser(new UserInfo(uid));
            deviceTokenHWMapper.insertSelective(deviceTokenHW);
        } else {
            for (DeviceTokenHW deviceTokenHW : list) {
                DeviceTokenHW update = new DeviceTokenHW();
                update.setId(deviceTokenHW.getId());
                if (!StringUtil.isNullOrEmpty(token)) {
                    update.setDeviceToken(token);
                    update.setDeviceTokenMd5(StringUtil.Md5(token));
                    update.setVersion(version);
                }
                update.setUpdateTime(new Date());
                if (uid != null)
                    update.setUser(new UserInfo(uid));
                deviceTokenHWMapper.updateByPrimaryKeySelective(update);
            }
        }
    }
        List<DeviceTokenHW> list = deviceTokenHWMapper.selectByDeviceForUpdate(device);
        if (list == null || list.size() == 0) {
            DeviceTokenHW deviceTokenHW = new DeviceTokenHW();
            deviceTokenHW.setDevice(device);
            deviceTokenHW.setDeviceToken(token);
            deviceTokenHW.setDeviceTokenMd5(StringUtil.Md5(token));
            deviceTokenHW.setVersion(version);
            deviceTokenHW.setUpdateTime(new Date());
            if (uid != null)
                deviceTokenHW.setUser(new UserInfo(uid));
            deviceTokenHWMapper.insertSelective(deviceTokenHW);
        } else {
            for (DeviceTokenHW deviceTokenHW : list) {
                DeviceTokenHW update = new DeviceTokenHW();
                update.setId(deviceTokenHW.getId());
                if (!StringUtil.isNullOrEmpty(token)) {
                    update.setDeviceToken(token);
                    update.setDeviceTokenMd5(StringUtil.Md5(token));
                    update.setVersion(version);
                }
                update.setUpdateTime(new Date());
                if (uid != null)
                    update.setUser(new UserInfo(uid));
                deviceTokenHWMapper.updateByPrimaryKeySelective(update);
            }
        }
    }
    @Override
    public List<DeviceTokenHW> getDeviceTokenByUid(Long uid) {
        if (uid == null)
            return null;
        return deviceTokenHWMapper.selectByUid(uid, null);
    }
    @Override
    public List<DeviceTokenHW> getDeviceTokenByUid(Long uid) {
        if (uid == null)
            return null;
        return deviceTokenHWMapper.selectByUid(uid, null);
    }
    @Override
    public void unBindDeviceToken(String device) {
        List<DeviceTokenHW> list = deviceTokenHWMapper.selectByDevice(device);
        if (list == null || list.size() == 0)
            return;
        for (DeviceTokenHW deviceTokenHW : list) {
            deviceTokenHW.setUser(null);
            deviceTokenHW.setUpdateTime(new Date());
            deviceTokenHWMapper.updateByPrimaryKey(deviceTokenHW);
        }
    }
    @Override
    public void unBindDeviceToken(String device) {
        List<DeviceTokenHW> list = deviceTokenHWMapper.selectByDevice(device);
        if (list == null || list.size() == 0)
            return;
        for (DeviceTokenHW deviceTokenHW : list) {
            deviceTokenHW.setUser(null);
            deviceTokenHW.setUpdateTime(new Date());
            deviceTokenHWMapper.updateByPrimaryKey(deviceTokenHW);
        }
    }
    @Override
    public void bindUid(String device, Long uid) {
        deviceTokenHWMapper.bindUidByDevice(uid, device);
    }
    @Override
    public void bindUid(String device, Long uid) {
        deviceTokenHWMapper.bindUidByDevice(uid, device);
    }
    @Override
    public List<DeviceTokenHW> getDeviceTokenByUid(Long uid, List<Integer> versionList) {
        if (uid == null)
            return null;
    @Override
    public List<DeviceTokenHW> getDeviceTokenByUid(Long uid, List<Integer> versionList) {
        if (uid == null)
            return null;
        if (versionList != null && versionList.size() == 0)
            return null;
        if (versionList != null && versionList.size() == 0)
            return null;
        return deviceTokenHWMapper.selectByUid(uid, versionList);
    }
        return deviceTokenHWMapper.selectByUid(uid, versionList);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceTokenOPPOServiceImpl.java
@@ -60,13 +60,13 @@
    }
    @Override
    public long countDeviceToken(List<Integer> versionList) {
        return deviceTokenOPPOMapper.countDeviceToken(versionList);
    public long countDeviceToken(List<Integer> versionList, Date minUpdateTime) {
        return deviceTokenOPPOMapper.countDeviceToken(versionList,minUpdateTime);
    }
    @Override
    public List<DeviceTokenOPPO> listDeviceToken(int page, int pageSize, List<Integer> versionList) {
        return deviceTokenOPPOMapper.listDeviceToken((page - 1) * pageSize, pageSize, versionList);
    public List<DeviceTokenOPPO> listDeviceToken(int page, int pageSize, List<Integer> versionList, Date minUpdateTime) {
        return deviceTokenOPPOMapper.listDeviceToken((page - 1) * pageSize, pageSize, versionList,minUpdateTime);
    }
    @Override
fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceTokenVIVOServiceImpl.java
@@ -60,13 +60,13 @@
    }
    @Override
    public long countDeviceToken(List<Integer> versionList) {
        return deviceTokenVIVOMapper.countDeviceToken(versionList);
    public long countDeviceToken(List<Integer> versionList, Date minUpdateTime) {
        return deviceTokenVIVOMapper.countDeviceToken(versionList,minUpdateTime);
    }
    @Override
    public List<DeviceTokenVIVO> listDeviceToken(int page, int pageSize, List<Integer> versionList) {
        return deviceTokenVIVOMapper.listDeviceToken((page - 1) * pageSize, pageSize, versionList);
    public List<DeviceTokenVIVO> listDeviceToken(int page, int pageSize, List<Integer> versionList, Date minUpdateTime) {
        return deviceTokenVIVOMapper.listDeviceToken((page - 1) * pageSize, pageSize, versionList,minUpdateTime);
    }
    @Override
fanli/src/main/java/com/yeshi/fanli/service/impl/push/HWPushServiceImpl.java
@@ -1,20 +1,10 @@
package com.yeshi.fanli.service.impl.push;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Resource;
import com.yeshi.fanli.dto.push.PushBaseContent;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dto.push.PushContentDetailDTO;
import com.yeshi.fanli.dto.push.PushTypeEnum;
import com.yeshi.fanli.entity.AppVersionInfo;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.bus.user.UserCustomSettings;
import com.yeshi.fanli.entity.bus.user.UserCustomSettings.UserSettingTypeEnum;
import com.yeshi.fanli.entity.push.DeviceTokenHW;
@@ -24,8 +14,14 @@
import com.yeshi.fanli.service.inter.push.DeviceTokenHWService;
import com.yeshi.fanli.service.inter.push.HWPushService;
import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.mq.cmq.PushCMQManager;
import com.yeshi.fanli.util.push.HWPushUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
@Service
public class HWPushServiceImpl implements HWPushService {
@@ -42,7 +38,7 @@
    private List<Integer> getVersionCodeList(List<Integer> versionCodeList, SystemEnum system) {
        List<Integer> versionList = new ArrayList<>();
        if (versionCodeList == null) {// 全推
            List<AppVersionInfo> appInfoList = appVersionService.listByPlatformAndMinVersionCode("android", 46,system);
            List<AppVersionInfo> appInfoList = appVersionService.listByPlatformAndMinVersionCode("android", 46, system);
            if (appInfoList != null)
                for (AppVersionInfo version : appInfoList) {
                    versionList.add(version.getVersionCode());
@@ -58,52 +54,46 @@
        return versionList;
    }
    @Async("pushExecutor")
    @Override
    public void pushGoods(Long uid, Long auctionId, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.goodsdetail, uid, null, null, auctionId, baseContent);
        addPushQueue(PushTypeEnum.goodsdetail, uid, null, null, auctionId, baseContent);
    }
    @Async("pushExecutor")
    @Override
    public void pushUrl(Long uid, String url, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.url, uid, null, url, null, baseContent);
        addPushQueue(PushTypeEnum.url, uid, null, url, null, baseContent);
    }
    @Async("pushExecutor")
    @Override
    public void pushZNX(Long uid, PushBaseContent baseContent) throws PushException {
        push(PushTypeEnum.ZNX, uid, null, null, null, baseContent);
        addPushQueue(PushTypeEnum.ZNX, uid, null, null, null, baseContent);
    }
    @Async("pushExecutor")
    @Override
    public void pushWEEX(Long uid, String weexUrl, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.weex, uid, weexUrl, null, null, baseContent);
        addPushQueue(PushTypeEnum.weex, uid, weexUrl, null, null, baseContent);
    }
    @Async("pushExecutor")
    @Override
    public void pushBaiChuanUrl(Long uid, String url, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.baichuan, uid, null, url, null, baseContent);
        addPushQueue(PushTypeEnum.baichuan, uid, null, url, null, baseContent);
    }
    @Async("pushExecutor")
    @Override
    public void pushWelfareCenter(Long uid, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.welfare, uid, null, null, null, baseContent);
        addPushQueue(PushTypeEnum.welfare, uid, null, null, null, baseContent);
    }
    @Override
    public void pushUserSignInNotification(Long uid, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.signin, uid, null, null, null, baseContent);
        addPushQueue(PushTypeEnum.signin, uid, null, null, null, baseContent);
    }
    private List<DeviceTokenHW> filterDeviceToken(List<DeviceTokenHW> hwDeviceList, int hour) {
@@ -136,58 +126,62 @@
        return hwDeviceList;
    }
    //添加到推送队列
    private void addPushQueue(PushTypeEnum type, Long uid, String url, String webUrl,
                              Long goodsId, PushBaseContent content) {
        //添加到推送队列
        PushContentDetailDTO dto = new PushContentDetailDTO(type, uid, url, webUrl, goodsId, content);
        PushCMQManager.getInstance().addHWPush(dto);
    }
    /**
     * 推送
     *
     * @param type
     * @param uid
     * @param content
     * @param url
     * @param webUrl
     * @param dto
     * @throws PushException
     */
    private void push(PushTypeEnum type, Long uid, String url, String webUrl,
                      Long goodsId, PushBaseContent content) throws PushException {
    public void push(PushContentDetailDTO dto) throws PushException {
        int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
        List<Integer> newVersionList = getVersionCodeList(content.getVersionCodeList(),content.getSystem());
        List<Integer> newVersionList = getVersionCodeList(dto.getContent().getVersionCodeList(), dto.getContent().getSystem());
        // 1.6.5后开始推送
        for (int i = 0; i < newVersionList.size(); i++) {
            if (newVersionList.get(i) < 47)
                newVersionList.remove(i--);
        }
        if (uid == null || uid == 0) {
            long deviceCount = deviceTokenHWService.countDeviceToken(newVersionList);
        if (dto.getUid() == null || dto.getUid() == 0) {
            //只推送近30天的活跃
            Date minUpdateTime = new Date(System.currentTimeMillis() - Constant.PUSH_MIN_TIME);
            long deviceCount = deviceTokenHWService.countDeviceToken(newVersionList, minUpdateTime);
            int page = (int) (deviceCount % 100 == 0 ? deviceCount / 100 : deviceCount / 100 + 1);
            for (int p = 1; p <= page; p++) {
                List<DeviceTokenHW> hwDeviceList = deviceTokenHWService.getDeviceTokenList(p, 100, newVersionList);
                List<DeviceTokenHW> hwDeviceList = deviceTokenHWService.getDeviceTokenList(p, 100, newVersionList, minUpdateTime);
                hwDeviceList = filterDeviceToken(hwDeviceList, hour);
                List<String> tokenList = new ArrayList<>();
                for (DeviceTokenHW token : hwDeviceList)
                    tokenList.add(token.getDeviceToken());
                try {
                    if (type == PushTypeEnum.goodsdetail) {// 商品详情
                        if (goodsId == null)
                    if (dto.getType() == PushTypeEnum.goodsdetail) {// 商品详情
                        if (dto.getGoodsId() == null)
                            throw new PushException(2, "参数不完整");
                        HWPushUtil.pushGoods(tokenList, content.getTitle(), content.getContent(), 1, goodsId);
                    } else if (type == PushTypeEnum.url) {// 链接
                        if (StringUtil.isNullOrEmpty(webUrl))
                        HWPushUtil.pushGoods(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), 1, dto.getGoodsId());
                    } else if (dto.getType() == PushTypeEnum.url) {// 链接
                        if (StringUtil.isNullOrEmpty(dto.getWebUrl()))
                            throw new PushException(2, "参数不完整");
                        HWPushUtil.pushUrl(tokenList, content.getTitle(), content.getContent(), webUrl);
                    } else if (type == PushTypeEnum.ZNX) {// 站内信
                        HWPushUtil.pushZNX(tokenList, content.getTitle(), content.getContent());
                    } else if (type == PushTypeEnum.weex) {// weex
                        if (StringUtil.isNullOrEmpty(url))
                        HWPushUtil.pushUrl(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), dto.getWebUrl());
                    } else if (dto.getType() == PushTypeEnum.ZNX) {// 站内信
                        HWPushUtil.pushZNX(tokenList, dto.getContent().getTitle(), dto.getContent().getContent());
                    } else if (dto.getType() == PushTypeEnum.weex) {// weex
                        if (StringUtil.isNullOrEmpty(dto.getUrl()))
                            throw new PushException(2, "参数不完整");
                        HWPushUtil.pushWEEX(tokenList, content.getTitle(), content.getContent(), url);
                    } else if (type == PushTypeEnum.baichuan) {// 百川链接
                        if (StringUtil.isNullOrEmpty(webUrl))
                        HWPushUtil.pushWEEX(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), dto.getUrl());
                    } else if (dto.getType() == PushTypeEnum.baichuan) {// 百川链接
                        if (StringUtil.isNullOrEmpty(dto.getWebUrl()))
                            throw new PushException(2, "参数不完整");
                        HWPushUtil.pushBaiChuanUrl(tokenList, content.getTitle(), content.getContent(), webUrl);
                    } else if (type == PushTypeEnum.welfare) {// 福利中心
                        HWPushUtil.pushWelfareCenter(tokenList, content.getTitle(), content.getContent());
                    } else if (type == PushTypeEnum.signin) {// 签到
                        HWPushUtil.pushUserSignInNotification(tokenList, content.getTitle(), content.getContent());
                        HWPushUtil.pushBaiChuanUrl(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), dto.getWebUrl());
                    } else if (dto.getType() == PushTypeEnum.welfare) {// 福利中心
                        HWPushUtil.pushWelfareCenter(tokenList, dto.getContent().getTitle(), dto.getContent().getContent());
                    } else if (dto.getType() == PushTypeEnum.signin) {// 签到
                        HWPushUtil.pushUserSignInNotification(tokenList, dto.getContent().getTitle(), dto.getContent().getContent());
                    }
                } catch (Exception e) {
                    PushLogHelper.hwError(e);
@@ -196,7 +190,7 @@
            }
        } else {
            // 华为单推
            List<DeviceTokenHW> hwDeviceList = deviceTokenHWService.getDeviceTokenByUid(uid, newVersionList);
            List<DeviceTokenHW> hwDeviceList = deviceTokenHWService.getDeviceTokenByUid(dto.getUid(), newVersionList);
            List<String> tokenList = new ArrayList<>();
            if (hwDeviceList != null) {
                hwDeviceList = filterDeviceToken(hwDeviceList, hour);
@@ -207,28 +201,28 @@
                return;
            try {
                if (type == PushTypeEnum.goodsdetail) {// 商品详情
                    if (goodsId == null)
                if (dto.getType() == PushTypeEnum.goodsdetail) {// 商品详情
                    if (dto.getGoodsId() == null)
                        throw new PushException(2, "参数不完整");
                    HWPushUtil.pushGoods(tokenList, content.getTitle(), content.getContent(), 1, goodsId);
                } else if (type == PushTypeEnum.url) {// 链接
                    if (StringUtil.isNullOrEmpty(webUrl))
                    HWPushUtil.pushGoods(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), 1, dto.getGoodsId());
                } else if (dto.getType() == PushTypeEnum.url) {// 链接
                    if (StringUtil.isNullOrEmpty(dto.getWebUrl()))
                        throw new PushException(2, "参数不完整");
                    HWPushUtil.pushUrl(tokenList, content.getTitle(), content.getContent(), webUrl);
                } else if (type == PushTypeEnum.ZNX) {// 站内信
                    HWPushUtil.pushZNX(tokenList, content.getTitle(), content.getContent());
                } else if (type == PushTypeEnum.weex) {// weex
                    if (StringUtil.isNullOrEmpty(url))
                    HWPushUtil.pushUrl(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), dto.getWebUrl());
                } else if (dto.getType() == PushTypeEnum.ZNX) {// 站内信
                    HWPushUtil.pushZNX(tokenList, dto.getContent().getTitle(), dto.getContent().getContent());
                } else if (dto.getType() == PushTypeEnum.weex) {// weex
                    if (StringUtil.isNullOrEmpty(dto.getUrl()))
                        throw new PushException(2, "参数不完整");
                    HWPushUtil.pushWEEX(tokenList, content.getTitle(), content.getContent(), url);
                } else if (type == PushTypeEnum.baichuan) {// 百川链接
                    if (StringUtil.isNullOrEmpty(webUrl))
                    HWPushUtil.pushWEEX(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), dto.getUrl());
                } else if (dto.getType() == PushTypeEnum.baichuan) {// 百川链接
                    if (StringUtil.isNullOrEmpty(dto.getWebUrl()))
                        throw new PushException(2, "参数不完整");
                    HWPushUtil.pushBaiChuanUrl(tokenList, content.getTitle(), content.getContent(), webUrl);
                } else if (type == PushTypeEnum.welfare) {// 福利中心
                    HWPushUtil.pushWelfareCenter(tokenList, content.getTitle(), content.getContent());
                } else if (type == PushTypeEnum.signin) {// 签到
                    HWPushUtil.pushUserSignInNotification(tokenList, content.getTitle(), content.getContent());
                    HWPushUtil.pushBaiChuanUrl(tokenList, dto.getContent().getTitle(), dto.getContent().getContent(), dto.getWebUrl());
                } else if (dto.getType() == PushTypeEnum.welfare) {// 福利中心
                    HWPushUtil.pushWelfareCenter(tokenList, dto.getContent().getTitle(), dto.getContent().getContent());
                } else if (dto.getType() == PushTypeEnum.signin) {// 签到
                    HWPushUtil.pushUserSignInNotification(tokenList, dto.getContent().getTitle(), dto.getContent().getContent());
                }
            } catch (Exception e) {
                PushLogHelper.hwError(e);
fanli/src/main/java/com/yeshi/fanli/service/impl/push/OPPOPushServiceImpl.java
@@ -1,15 +1,12 @@
package com.yeshi.fanli.service.impl.push;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import javax.annotation.Resource;
import com.yeshi.fanli.dto.push.PushBaseContent;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.util.Constant;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@@ -156,11 +153,12 @@
        }
        if (uid == null || uid == 0) {
            Date minUpdatetime=new Date(System.currentTimeMillis()- Constant.PUSH_MIN_TIME);
            int pageSize = 200;
            long deviceCount = deviceTokenOPPOService.countDeviceToken(newVersionList);
            long deviceCount = deviceTokenOPPOService.countDeviceToken(newVersionList,minUpdatetime);
            int page = (int) (deviceCount % pageSize == 0 ? deviceCount / pageSize : deviceCount / pageSize + 1);
            for (int p = 1; p <= page; p++) {
                List<DeviceTokenOPPO> deviceList = deviceTokenOPPOService.listDeviceToken(p, pageSize, newVersionList);
                List<DeviceTokenOPPO> deviceList = deviceTokenOPPOService.listDeviceToken(p, pageSize, newVersionList,minUpdatetime);
                deviceList = filterDeviceToken(deviceList, hour);
                List<String> tokenList = new ArrayList<>();
fanli/src/main/java/com/yeshi/fanli/service/impl/push/VIVOPushServiceImpl.java
@@ -1,15 +1,12 @@
package com.yeshi.fanli.service.impl.push;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import javax.annotation.Resource;
import com.yeshi.fanli.dto.push.PushBaseContent;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.util.Constant;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@@ -155,11 +152,12 @@
        }
        if (uid == null || uid == 0) {
            Date minUpdatetime=new Date(System.currentTimeMillis()- Constant.PUSH_MIN_TIME);
            int pageSize = 200;
            long deviceCount = deviceTokenVIVOService.countDeviceToken(newVersionList);
            long deviceCount = deviceTokenVIVOService.countDeviceToken(newVersionList,minUpdatetime);
            int page = (int) (deviceCount % pageSize == 0 ? deviceCount / pageSize : deviceCount / pageSize + 1);
            for (int p = 1; p <= page; p++) {
                List<DeviceTokenVIVO> deviceList = deviceTokenVIVOService.listDeviceToken(p, pageSize, newVersionList);
                List<DeviceTokenVIVO> deviceList = deviceTokenVIVOService.listDeviceToken(p, pageSize, newVersionList,minUpdatetime);
                deviceList = filterDeviceToken(deviceList, hour);
                List<String> tokenList = new ArrayList<>();
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/CommonTemplateContentService.java
@@ -20,7 +20,7 @@
     * @param type
     * @return
     */
    public List<CommonContentNav> getNavList(CommonContentTypeEnum type);
    public List<CommonContentNav> getNavList(CommonContentTypeEnum type,SystemEnum system);
    /**
     * 获取内容列表
fanli/src/main/java/com/yeshi/fanli/service/inter/push/DeviceTokenHWService.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.service.inter.push;
import java.util.Date;
import java.util.List;
import com.yeshi.fanli.entity.push.DeviceTokenHW;
@@ -11,17 +12,19 @@
 *
 */
public interface DeviceTokenHWService {
    /**
     * 分页查询数据
     *
     * @param start
     * @param page
     * @param pageSize
     * @param versionList
     * @param minUpdateTime
     * @return
     */
    List<DeviceTokenHW> getDeviceTokenList(int page, int pageSize, List<Integer> versionList);
    List<DeviceTokenHW> getDeviceTokenList(int page, int pageSize, List<Integer> versionList, Date minUpdateTime);
    Long countDeviceToken(List<Integer> versionList);
    Long countDeviceToken(List<Integer> versionList,Date minUpdateTime);
    /**
     * 添加数据
fanli/src/main/java/com/yeshi/fanli/service/inter/push/DeviceTokenOPPOService.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.service.inter.push;
import java.util.Date;
import java.util.List;
import com.yeshi.fanli.entity.push.DeviceTokenOPPO;
@@ -40,7 +41,7 @@
     * 
     * @return
     */
    public long countDeviceToken(List<Integer> verisonList);
    public long countDeviceToken(List<Integer> verisonList, Date minUpdateTime);
    /**
     * 设备列表
@@ -49,7 +50,7 @@
     * @param pageSize
     * @return
     */
    public List<DeviceTokenOPPO> listDeviceToken(int page, int pageSize, List<Integer> verisonList);
    public List<DeviceTokenOPPO> listDeviceToken(int page, int pageSize, List<Integer> verisonList, Date minUpdateTime);
    /**
     * 根据用户ID检索
fanli/src/main/java/com/yeshi/fanli/service/inter/push/DeviceTokenVIVOService.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.service.inter.push;
import java.util.Date;
import java.util.List;
import com.yeshi.fanli.entity.push.DeviceTokenVIVO;
@@ -40,7 +41,7 @@
     * 
     * @return
     */
    public long countDeviceToken(List<Integer> verisonList);
    public long countDeviceToken(List<Integer> verisonList, Date minUpdateTime);
    /**
     * 设备列表
@@ -49,7 +50,7 @@
     * @param pageSize
     * @return
     */
    public List<DeviceTokenVIVO> listDeviceToken(int page, int pageSize, List<Integer> verisonList);
    public List<DeviceTokenVIVO> listDeviceToken(int page, int pageSize, List<Integer> verisonList, Date minUpdateTime);
    /**
     * 根据用户ID检索
fanli/src/main/java/com/yeshi/fanli/service/inter/push/HWPushService.java
@@ -1,81 +1,88 @@
package com.yeshi.fanli.service.inter.push;
import com.yeshi.fanli.dto.push.PushBaseContent;
import com.yeshi.fanli.dto.push.PushContentDetailDTO;
import com.yeshi.fanli.exception.push.PushException;
import java.util.List;
/**
 * 华为推送服务
 *
 * @author Administrator
 *
 * @author Administrator
 */
public interface HWPushService {
    /**
     * 推送商品
     *
     * @param uid
     * @throws PushException
     */
    void pushGoods(Long uid, Long auctionId, PushBaseContent baseContent)
            throws PushException;
    /**
     * 推送商品
     *
     * @param uid
     * @throws PushException
     */
    void pushGoods(Long uid, Long auctionId, PushBaseContent baseContent)
            throws PushException;
    /**
     * 推送链接
     *
     * @param uid
     * @param url
     * @throws PushException
     */
    void pushUrl(Long uid, String url,PushBaseContent baseContent)
            throws PushException;
    /**
     * 推送链接
     *
     * @param uid
     * @param url
     * @throws PushException
     */
    void pushUrl(Long uid, String url, PushBaseContent baseContent)
            throws PushException;
    /**
     * 推送站内信
     *
     * @param uId
     * @throws PushException
     */
    void pushZNX(Long uId,PushBaseContent baseContent) throws PushException;
    /**
     * 推送站内信
     *
     * @param uId
     * @throws PushException
     */
    void pushZNX(Long uId, PushBaseContent baseContent) throws PushException;
    /**
     * 适用版本 1.4.8及以后 推送weex页面
     *
     * @param uid
     * @param weexUrl
     * @throws PushException
     */
    void pushWEEX(Long uid, String weexUrl,PushBaseContent baseContent)
            throws PushException;
    /**
     * 适用版本 1.4.8及以后 推送weex页面
     *
     * @param uid
     * @param weexUrl
     * @throws PushException
     */
    void pushWEEX(Long uid, String weexUrl, PushBaseContent baseContent)
            throws PushException;
    /**
     * 适用版本 1.4.8及以后 推送百川网页
     *
     * @param uid
     * @param url
     * @throws PushException
     */
    void pushBaiChuanUrl(Long uid, String url,PushBaseContent baseContent)
            throws PushException;
    /**
     * 适用版本 1.4.8及以后 推送百川网页
     *
     * @param uid
     * @param url
     * @throws PushException
     */
    void pushBaiChuanUrl(Long uid, String url, PushBaseContent baseContent)
            throws PushException;
    /**
     * 推送福利中心(版本号:1.5.1后)
     *
     * @param uid
    /**
     * 推送福利中心(版本号:1.5.1后)
     *
     * @param uid
     * @throws PushException
     */
    void pushWelfareCenter(Long uid, PushBaseContent baseContent) throws PushException;
     * @throws PushException
     */
    void pushWelfareCenter(Long uid,PushBaseContent baseContent) throws PushException;
    /**
     * 推送签到提醒
     *
     * @param uid
     * @throws PushException
     */
    void pushUserSignInNotification(Long uid, PushBaseContent baseContent) throws PushException;
    /**
     * 推送签到提醒
     *
     * @param uid
     * @throws PushException
     */
    void pushUserSignInNotification(Long uid, PushBaseContent baseContent) throws PushException;
    /**
     * 推送
     *
     * @param dto
     * @throws PushException
     */
    void push(PushContentDetailDTO dto) throws PushException;
}
fanli/src/main/java/com/yeshi/fanli/util/AppMarketUtil.java
New file
@@ -0,0 +1,51 @@
package com.yeshi.fanli.util;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.yeshi.utils.HttpUtil;
import java.io.IOException;
import java.net.URLEncoder;
/**
 * 应用市场帮助类
 */
public class AppMarketUtil {
    /**
     * 获取应用的最新版本
     *
     * @param appId
     * @return
     */
    public static String getHWLatestVersion(String appId) {
        try {
            String url = String.format("https://appgallery.cloud.huawei.com/uowap/index?method=internal.getTabDetail&serviceType=13&reqPageNum=1&uri=%s&appid=C%s&shareTo=undefined&locale=en_US&maxResults=10&currentUrl=%s&version=10.0.0", URLEncoder.encode("app|C" + appId, "UTF-8"), appId, URLEncoder.encode(String.format("https://appgallery.cloud.huawei.com/uowap/index.html#/detailApp/C%s", appId), "UTF-8"));
            System.out.println(url);
            String result = HttpUtil.get(url);
            JSONObject root = JSONObject.fromObject(result);
            JSONArray array = root.optJSONArray("layoutData");
            for (int i = 0; i < array.size(); i++) {
                JSONObject item = array.optJSONObject(i);
                if (item != null && item.optJSONArray("dataList") != null) {
                    JSONArray array1 = item.optJSONArray("dataList");
                    if (array1 != null)
                        for (int j = 0; j < array1.size(); j++) {
                            item = array1.optJSONObject(j);
                            if (item != null && !StringUtil.isNullOrEmpty(item.optString("version") )) {
                                return item.optString("version").trim();
                            }
                        }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
fanli/src/main/java/com/yeshi/fanli/util/Constant.java
@@ -93,6 +93,9 @@
    public static final String TAOBAO_AUTH_APPSECRET = "e0a2e05deabf5ce039b52e5b492d5382";
    public static final String TAOBAO_RELATION_PID_DEFAULT = "mm_124933865_56750082_87140050199";
    public static final String TAOBAO_SPECIAL_PID_DEFAULT = "mm_124933865_56750082_89555600043";
    public static final long PUSH_MIN_TIME=1000*60*60*24*30*2L;
    
    
    //优惠狗云发单群唤起关键词
fanli/src/main/java/com/yeshi/fanli/util/RedisKeyEnum.java
@@ -66,9 +66,8 @@
    convertLinkDocTemp("convert-link-doc-temp-", "转链文本暂存"),
    convertLinkDocResultTemp("convert-link-doc-result-temp-", "转链文本结果暂存"),
    userSystem("user-system-","用户系统归属")
    ;
    userSystem("user-system-","用户系统归属"),
    monitor("monitor-order-","订单监控");
    private final String key;
    private final String desc;
fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
@@ -10,6 +10,10 @@
import javax.annotation.Resource;
import com.yeshi.fanli.dto.push.PushContentDetailDTO;
import com.yeshi.fanli.service.impl.JobThreadExecutorServiceImpl;
import com.yeshi.fanli.service.inter.push.HWPushService;
import com.yeshi.fanli.util.mq.cmq.PushCMQManager;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.task.TaskExecutor;
@@ -81,1231 +85,1205 @@
/**
 * 系统初始化
 *
 * @author Administrator
 *
 * @author Administrator
 */
@Component
public class SpringContext implements ApplicationListener<ContextRefreshedEvent> {
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private BoutiqueAutoRuleService boutiqueAutoRuleService;
    @Resource
    private BoutiqueAutoRuleService boutiqueAutoRuleService;
    @Resource
    private ExtractService extractService;
    @Resource
    private ExtractService extractService;
    @Resource
    private IOSPushService iosPushService;
    @Resource
    private IOSPushService iosPushService;
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    @Resource
    private LabelService labelService;
    @Resource
    private OrderProcessService orderProcessService;
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    @Resource
    private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
    @Resource
    private OrderProcessService orderProcessService;
    @Resource
    private ThreeSaleSerivce threeSaleSerivce;
    @Resource
    private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
    @Resource
    private TaoBaoOrderService taoBaoOrderService;
    @Resource
    private UserSystemCouponService userSystemCouponService;
    @Resource
    private RedisManager redisManager;
    @Resource
    private ThreeSaleSerivce threeSaleSerivce;
    @Resource
    private UserMoneyDebtService userMoneyDebtService;
    @Resource
    private TaoBaoOrderService taoBaoOrderService;
    @Resource
    private JDOrderService jdOrderService;
    @Resource
    private RedisManager redisManager;
    @Resource
    private PDDOrderService pddOrderService;
    @Resource
    private UserMoneyDebtService userMoneyDebtService;
    @Resource
    private HongBaoV2Service hongBaoV2Service;
    @Resource
    private JDOrderService jdOrderService;
    @Resource
    private IntegralGetService integralGetService;
    @Resource
    private PDDOrderService pddOrderService;
    @Resource
    private CommonOrderService commonOrderService;
    @Resource
    private HongBaoV2Service hongBaoV2Service;
    @Resource
    private HongBaoOrderService hongBaoOrderService;
    @Resource
    private IntegralGetService integralGetService;
    @Resource
    private IntegralTaskRecordService integralTaskRecordService;
    @Resource
    private CommonOrderService commonOrderService;
    @Resource
    private DeviceActiveService deviceActiveService;
    @Resource
    private HongBaoOrderService hongBaoOrderService;
    @Resource
    private TeamDividentsManager teamDividentsManager;
    @Resource
    private IntegralTaskRecordService integralTaskRecordService;
    @Resource
    private TeamEincomeManager teamEincomeManager;
    @Resource
    private DeviceActiveService deviceActiveService;
    @Resource
    private VipShopOrderService vipShopOrderService;
    @Resource
    private TeamDividentsManager teamDividentsManager;
    @Resource
    private SuningOrderService suningOrderService;
    @Resource
    private TeamEincomeManager teamEincomeManager;
    @Resource
    private HWPushService hwPushService;
    @Resource
    private VipShopOrderService vipShopOrderService;
    @Resource
    private SuningOrderService suningOrderService;
    private static boolean isInited = false;
    private static boolean isInited = false;
    public void onApplicationEvent(ContextRefreshedEvent arg0) {
        if (arg0.getApplicationContext().getParent() != null) {
            System.out.println(System.currentTimeMillis());
            onApplication(arg0);
        }
    }
    public void onApplicationEvent(ContextRefreshedEvent arg0) {
        if (arg0.getApplicationContext().getParent() != null) {
            System.out.println(System.currentTimeMillis());
            onApplication(arg0);
        }
    }
    private synchronized void onApplication(ContextRefreshedEvent context) {
        if (!isInited) {
            isInited = true;
            System.out.println("系统初始化完成");
            init(context);
        }
    }
    private synchronized void onApplication(ContextRefreshedEvent context) {
        if (!isInited) {
            isInited = true;
            System.out.println("系统初始化完成");
            init(context);
        }
    }
    private void init(ContextRefreshedEvent arg0) {
        initCOS();
        if (Constant.IS_TASK) {
            doExtractResult();// 处理提现结果
            doTaoBaoOrders();// 处理淘宝订单
            doTaoBaoNewOrders();// 处理淘宝订单(刚刚产生的)
            doOrderFanLiNew();// 新版返利
            doOrderShareFanLi();
            doWeiQuanOrder();// 处理维权订单
            doPushIOS();// 处理发送IOS消息
            doUserMoneyDebtJob();// 债务偿还
            initScheduler();// 启动商品更新定时任务
            doUpdateGoodsJob(); // 更新商品队列
            doJDOrderJob();// 京东订单处理
            doPDDOrderJob();// 拼多多订单处理
            doVipShopOrderJob();// 唯品会订单处理
            doSuningOrderJob();// 苏宁订单处理
            doImportantTaoBaoGoodsUpdateJob();// 淘宝重要商品的信息更新
            doHongBaoRecieveIntegralGetJob();// 返利到账,金币增加
            // doPlaceOrderIntegralJob();// 下单赠送金币任务
            // doDouYinDeviceActiveJob();// 抖音设备激活广告监测
            doOrderTeamIncomePreFanLi();// 处理订单提成返利
            doDividentsPreJob();
    private void init(ContextRefreshedEvent arg0) {
        initCOS();
        if (Constant.IS_TASK) {
            doExtractResult();// 处理提现结果
            doTaoBaoOrders();// 处理淘宝订单
            doTaoBaoNewOrders();// 处理淘宝订单(刚刚产生的)
            doOrderFanLiNew();// 新版返利
            doOrderShareFanLi();
            doWeiQuanOrder();// 处理维权订单
            doPushIOS();// 处理发送IOS消息
            doUserMoneyDebtJob();// 债务偿还
            initScheduler();// 启动商品更新定时任务
            doUpdateGoodsJob(); // 更新商品队列
            doJDOrderJob();// 京东订单处理
            doPDDOrderJob();// 拼多多订单处理
            doVipShopOrderJob();// 唯品会订单处理
            doSuningOrderJob();// 苏宁订单处理
            doImportantTaoBaoGoodsUpdateJob();// 淘宝重要商品的信息更新
            doHongBaoRecieveIntegralGetJob();// 返利到账,金币增加
            // doPlaceOrderIntegralJob();// 下单赠送金币任务
            // doDouYinDeviceActiveJob();// 抖音设备激活广告监测
            doOrderTeamIncomePreFanLi();// 处理订单提成返利
            doDividentsPreJob();
            doOrderTeamRewardFanLi();
            doDividentsJob();
            doOrderTeamRewardFanLi();
            doDividentsJob();
        }
    }
            //华为推送
            doHWPushJob();
        }
    /**
     * 对象存储初始化
     */
    public static void initCOS() {
        // 载入cos参数
        Properties ps = org.yeshi.utils.PropertiesUtil
                .getProperties(SpringContext.class.getClassLoader().getResourceAsStream("cos.properties"));
        COSInitParams params = new COSInitParams();
        params.setAppId(Long.parseLong(ps.getProperty("appId")));
        params.setBucketName(ps.getProperty("bucketName"));
        params.setRegion(ps.getProperty("region"));
        params.setSecretId(ps.getProperty("secretId"));
        params.setSecretKey(ps.getProperty("secretKey"));
        // 初始化
        COSManager.getInstance().init(params);
    }
    }
    /**
     * 处理提现结果的队列
     */
    public void doExtractResult() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
    /**
     * 对象存储初始化
     */
    public static void initCOS() {
        // 载入cos参数
        Properties ps = org.yeshi.utils.PropertiesUtil
                .getProperties(SpringContext.class.getClassLoader().getResourceAsStream("cos.properties"));
        COSInitParams params = new COSInitParams();
        params.setAppId(Long.parseLong(ps.getProperty("appId")));
        params.setBucketName(ps.getProperty("bucketName"));
        params.setRegion(ps.getProperty("region"));
        params.setSecretId(ps.getProperty("secretId"));
        params.setSecretKey(ps.getProperty("secretKey"));
        // 初始化
        COSManager.getInstance().init(params);
    }
                    try {
    /**
     * 处理提现结果的队列
     */
    public void doExtractResult() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                try {
                        Map<String, AlipayTransferResultInfo> map = CMQManager.getInstance().consumeExtractResultMsg(1);
                    Map<String, AlipayTransferResultInfo> map = CMQManager.getInstance().consumeExtractResultMsg(1);
                        if (map != null) {
                            Iterator<String> its = map.keySet().iterator();
                            while (its.hasNext()) {
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                                String key = its.next();
                                try {
                                    extractService.processExtractResult(map.get(key));
                                    CMQManager.getInstance().deleteExtractResultMsg(key);
                                } catch (Exception e) {
                                    try {
                                        LogHelper.errorDetailInfo(e);
                                    } catch (Exception e1) {
                                        e1.printStackTrace();
                                    }
                                }
                            }
                        }
                    } catch (Exception e) {
                    }
                }
            }
        });
    }
                            String key = its.next();
                            try {
                                extractService.processExtractResult(map.get(key));
                                CMQManager.getInstance().deleteExtractResultMsg(key);
                            } catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e);
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            }
                        }
                    }
                } catch (Exception e) {
                }
            }
        });
    }
    /**
     * 处理淘宝订单
     */
    public void doTaoBaoOrders() {
        // 同时开启3个线程处理
        for (int i = 0; i < 3; i++) {
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    while (true) {
                        try {
    /**
     * 处理淘宝订单
     */
    public void doTaoBaoOrders() {
        // 同时开启3个线程处理
        for (int i = 0; i < 3; i++) {
            new JobThreadExecutorServiceImpl().run(new Runnable() {
                @Override
                public void run() {
                    try {
                        // 取16个订单
                        List<String> orderIds = CMQManager.getInstance().consumeTaoBaoOrderMsg(16);
                        if (orderIds != null) {
                            for (String orderId : orderIds) {
                                if (NumberUtil.isNumeric(orderId.trim())) {
                                    Map<String, List<TaoBaoOrder>> map = new HashMap<>();
                                    List<TaoBaoOrder> orderList = taoBaoOrderService
                                            .getTaoBaoOrderByOrderId(orderId);
                                    map.put(orderId, orderList);
                                    LogHelper.orderInfo("开始处理订单:" + orderId);
                                    orderProcessService.processOrder(map);
                                    LogHelper.orderInfo("结束处理订单:" + orderId);
                                }
                            }
                        }
                    } catch (Exception e) {
                        try {
                            LogHelper.errorDetailInfo(e);
                        } catch (Exception e1) {
                            // 取16个订单
                            List<String> orderIds = CMQManager.getInstance().consumeTaoBaoOrderMsg(16);
                            if (orderIds != null) {
                                for (String orderId : orderIds) {
                                    if (NumberUtil.isNumeric(orderId.trim())) {
                                        Map<String, List<TaoBaoOrder>> map = new HashMap<>();
                                        List<TaoBaoOrder> orderList = taoBaoOrderService
                                                .getTaoBaoOrderByOrderId(orderId);
                                        map.put(orderId, orderList);
                                        LogHelper.orderInfo("开始处理订单:" + orderId);
                                        orderProcessService.processOrder(map);
                                        LogHelper.orderInfo("结束处理订单:" + orderId);
                                    }
                                }
                            }
                        } catch (Exception e) {
                            try {
                                LogHelper.errorDetailInfo(e);
                            } catch (Exception e1) {
                        }
                    }
                }
            });
        }
    }
                            }
                        }
                    }
                }
            });
        }
    }
    /**
     * 刚刚产生的订单
     */
    public void doTaoBaoNewOrders() {
        // 同时开启3个线程处理
        for (int i = 0; i < 1; i++) {
            new JobThreadExecutorServiceImpl().run(new Runnable() {
                @Override
                public void run() {
                    try {
                        // 取16个订单
                        List<String> orderIds = CMQManager.getInstance().consumeTaoBaoNewOrderMsg(16);
                        Map<String, List<TaoBaoOrder>> map = new HashMap<>();
                        if (orderIds != null) {
                            for (String orderId : orderIds) {
                                List<TaoBaoOrder> orderList = taoBaoOrderService.getTaoBaoOrderByOrderId(orderId);
                                map.put(orderId, orderList);
    /**
     * 刚刚产生的订单
     */
    public void doTaoBaoNewOrders() {
        // 同时开启3个线程处理
        for (int i = 0; i < 1; i++) {
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    while (true) {
                        try {
                            // 取16个订单
                            List<String> orderIds = CMQManager.getInstance().consumeTaoBaoNewOrderMsg(16);
                            Map<String, List<TaoBaoOrder>> map = new HashMap<>();
                            if (orderIds != null) {
                                for (String orderId : orderIds) {
                                    List<TaoBaoOrder> orderList = taoBaoOrderService.getTaoBaoOrderByOrderId(orderId);
                                    map.put(orderId, orderList);
                                LogHelper.orderInfo("新订单-开始处理订单:" + orderId);
                                long startTime = System.currentTimeMillis();
                                orderProcessService.processOrder(map);
                                LogHelper.orderInfo("新订单-结束处理订单:" + orderId + "-  处理时间:"
                                        + (System.currentTimeMillis() - startTime));
                            }
                        }
                    } catch (Exception e) {
                        try {
                            LogHelper.errorDetailInfo(e);
                        } catch (Exception e1) {
                                    LogHelper.orderInfo("新订单-开始处理订单:" + orderId);
                                    long startTime = System.currentTimeMillis();
                                    orderProcessService.processOrder(map);
                                    LogHelper.orderInfo("新订单-结束处理订单:" + orderId + "-  处理时间:"
                                            + (System.currentTimeMillis() - startTime));
                                }
                            }
                        } catch (Exception e) {
                            try {
                                LogHelper.errorDetailInfo(e);
                            } catch (Exception e1) {
                        }
                    }
                }
            });
        }
    }
                            }
                        }
                    }
                }
            });
        }
    }
    /**
     * 处理新版淘宝订单返利
     */
    public void doOrderFanLiNew() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                try {
                    Map<String, HongBaoV2> map = CMQManager.getInstance().consumeFanLiMsgNew(16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String handler = its.next();
                            try {
                                HongBaoV2 hongbao = map.get(handler);
                                if (hongbao != null) {
                                    String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.hongBaoFanLi,
                                            hongbao.getId() + "");
                                    if (StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
                                        // 处理之后要隔2小时再次进行处理
                                        redisManager.cacheCommonString(key, "1", 60 * 60 * 2);
                                        orderProcessService.fanli(map.get(handler));
                                    }
                                }
                                CMQManager.getInstance().deleteFanLiMsgNew(handler);
                            } catch (TaoBaoWeiQuanException e) {
                                try {
                                    LogHelper.errorDetailInfo(e);
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            } catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e, "HongBaoV2-ID:" + map.get(handler).getId(), "");
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            }
                        }
                    }
    /**
     * 处理新版淘宝订单返利
     */
    public void doOrderFanLiNew() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Map<String, HongBaoV2> map = CMQManager.getInstance().consumeFanLiMsgNew(16);
                        if (map != null) {
                            Iterator<String> its = map.keySet().iterator();
                            while (its.hasNext()) {
                                String handler = its.next();
                                try {
                                    HongBaoV2 hongbao = map.get(handler);
                                    if (hongbao != null) {
                                        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.hongBaoFanLi,
                                                hongbao.getId() + "");
                                        if (StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
                                            // 处理之后要隔2小时再次进行处理
                                            redisManager.cacheCommonString(key, "1", 60 * 60 * 2);
                                            orderProcessService.fanli(map.get(handler));
                                        }
                                    }
                                    CMQManager.getInstance().deleteFanLiMsgNew(handler);
                                } catch (TaoBaoWeiQuanException e) {
                                    try {
                                        LogHelper.errorDetailInfo(e);
                                    } catch (Exception e1) {
                                        e1.printStackTrace();
                                    }
                                } catch (Exception e) {
                                    try {
                                        LogHelper.errorDetailInfo(e, "HongBaoV2-ID:" + map.get(handler).getId(), "");
                                    } catch (Exception e1) {
                                        e1.printStackTrace();
                                    }
                                }
                            }
                        }
                } catch (Exception e) {
                    } catch (Exception e) {
                }
            }
                    }
                }
            }
        });
    }
        });
    }
    /**
     * 处理团队订单返利
     */
    public void doOrderTeamIncomePreFanLi() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Map<String, UidDateDTO> map = TeamOrderCMQManager.getInstance()
                                .consumeFanLiTeamIncomePreMsg(16);
                        if (map != null) {
                            Iterator<String> its = map.keySet().iterator();
                            while (its.hasNext()) {
                                String handler = its.next();
                                try {
                                    UidDateDTO dto = map.get(handler);
                                    orderProcessService.fanliPreInvaite(dto.getUid(), dto.getDate());
                                    TeamOrderCMQManager.getInstance().deleteTeamIncomePreMsg(handler);
                                } catch (Exception e) {
                                    try {
                                        LogHelper.errorDetailInfo(e,new Gson().toJson(map.get(handler)).toString(), "");
                                    } catch (Exception e1) {
                                        e1.printStackTrace();
                                    }
                                }
                            }
                        }
                    } catch (Exception e) {
    /**
     * 处理团队订单返利
     */
    public void doOrderTeamIncomePreFanLi() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                try {
                    Map<String, UidDateDTO> map = TeamOrderCMQManager.getInstance()
                            .consumeFanLiTeamIncomePreMsg(16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String handler = its.next();
                            try {
                                UidDateDTO dto = map.get(handler);
                                orderProcessService.fanliPreInvaite(dto.getUid(), dto.getDate());
                                TeamOrderCMQManager.getInstance().deleteTeamIncomePreMsg(handler);
                            } catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e, new Gson().toJson(map.get(handler)).toString(), "");
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            }
                        }
                    }
                } catch (Exception e) {
                    }
                }
            }
        });
    }
                }
            }
        });
    }
    /**
     * 处理团队奖金返利
     */
    public void doOrderTeamRewardFanLi() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Map<String, UidDateDTO> map = TeamOrderCMQManager.getInstance().consumeFanLiTeamIncomeMsg(16);
                        if (map != null) {
                            Iterator<String> its = map.keySet().iterator();
                            while (its.hasNext()) {
                                String handler = its.next();
                                try {
                                    UidDateDTO dto = map.get(handler);
                                    teamEincomeManager.addTeamRewardTOUserAccount(dto.getDate(), dto.getUid());
                                    TeamOrderCMQManager.getInstance().deleteTeamIncomeMsg(handler);
                                } catch (Exception e) {
                                    try {
                                        LogHelper.errorDetailInfo(e, map.get(handler).toString(), "");
                                    } catch (Exception e1) {
                                        e1.printStackTrace();
                                    }
                                }
                            }
                        }
                    } catch (Exception e) {
    /**
     * 处理团队奖金返利
     */
    public void doOrderTeamRewardFanLi() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                try {
                    Map<String, UidDateDTO> map = TeamOrderCMQManager.getInstance().consumeFanLiTeamIncomeMsg(16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String handler = its.next();
                            try {
                                UidDateDTO dto = map.get(handler);
                                teamEincomeManager.addTeamRewardTOUserAccount(dto.getDate(), dto.getUid());
                                TeamOrderCMQManager.getInstance().deleteTeamIncomeMsg(handler);
                            } catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e, map.get(handler).toString(), "");
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            }
                        }
                    }
                } catch (Exception e) {
                }
            }
        });
    }
                    }
                }
            }
        });
    }
    /**
     * 处理分享订单返利
     */
    public void doOrderShareFanLi() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                try {
                    Map<String, UidDateDTO> map = CMQManager.getInstance().consumeFanLiShareMsg(16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String handler = its.next();
                            try {
                                UidDateDTO dto = map.get(handler);
                                orderProcessService.fanliShare(dto.getUid(), dto.getDate());
                                CMQManager.getInstance().deleteFanLiShareMsg(handler);
                            } catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e, map.get(handler).toString(), "");
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            }
                        }
                    }
                } catch (Exception e) {
    /**
     * 处理分享订单返利
     */
    public void doOrderShareFanLi() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Map<String, UidDateDTO> map = CMQManager.getInstance().consumeFanLiShareMsg(16);
                        if (map != null) {
                            Iterator<String> its = map.keySet().iterator();
                            while (its.hasNext()) {
                                String handler = its.next();
                                try {
                                    UidDateDTO dto = map.get(handler);
                                    orderProcessService.fanliShare(dto.getUid(), dto.getDate());
                                    CMQManager.getInstance().deleteFanLiShareMsg(handler);
                                } catch (Exception e) {
                                    try {
                                        LogHelper.errorDetailInfo(e, map.get(handler).toString(), "");
                                    } catch (Exception e1) {
                                        e1.printStackTrace();
                                    }
                                }
                            }
                        }
                    } catch (Exception e) {
                }
            }
                    }
                }
            }
        });
    }
        });
    }
    /**
     * 处理淘宝订单维权
     */
    public void doWeiQuanOrder() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
    /**
     * 处理淘宝订单维权
     */
    public void doWeiQuanOrder() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                try {
                    Map<String, TaoBaoWeiQuanOrder> map = CMQManager.getInstance().consumeWeiQuanOrderMsg(16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String handler = its.next();
                            try {
                                orderProcessService.weiQuanOrder(map.get(handler));
                                CMQManager.getInstance().deleteWeiQuanOrderMsg(handler);
                            } catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e);
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            }
                        }
                    }
                } catch (Exception e) {
                }
            }
        });
    }
                        Map<String, TaoBaoWeiQuanOrder> map = CMQManager.getInstance().consumeWeiQuanOrderMsg(16);
                        if (map != null) {
                            Iterator<String> its = map.keySet().iterator();
                            while (its.hasNext()) {
                                String handler = its.next();
                                try {
                                    orderProcessService.weiQuanOrder(map.get(handler));
                                    CMQManager.getInstance().deleteWeiQuanOrderMsg(handler);
                                } catch (Exception e) {
                                    try {
                                        LogHelper.errorDetailInfo(e);
                                    } catch (Exception e1) {
                                        e1.printStackTrace();
                                    }
                                }
                            }
                        }
                    } catch (Exception e) {
    /**
     * IOS 推送消息
     */
    public void doPushIOS() {
                    }
                }
            }
        });
    }
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                try {
    /**
     * IOS 推送消息
     */
    public void doPushIOS() {
                    Map<String, PushQueueRecord> map = CMQManager.getInstance().consumeIOSPushMsg(10);
        executor.execute(new Runnable() {
            @Override
            public void run() {
                    if (map != null) {
                while (true) {
                    try {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                        Map<String, PushQueueRecord> map = CMQManager.getInstance().consumeIOSPushMsg(10);
                            String key = its.next();
                            try {
                                iosPushService.readyPushIOS(map.get(key));
                        if (map != null) {
                                CMQManager.getInstance().deleteIOSPushMsg(key);
                            Iterator<String> its = map.keySet().iterator();
                            while (its.hasNext()) {
                            } catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e);
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            }
                        }
                    }
                } catch (Exception e) {
                    LogHelper.errorDetailInfo(e);
                }
            }
        });
                                String key = its.next();
                                try {
                                    iosPushService.readyPushIOS(map.get(key));
    }
                                    CMQManager.getInstance().deleteIOSPushMsg(key);
    /**
     * 创建Scheduler()执行自动爬取
     */
    private void initScheduler() {
        boutiqueAutoRuleService.startScheduler();
    }
                                } catch (Exception e) {
                                    try {
                                        LogHelper.errorDetailInfo(e);
                                    } catch (Exception e1) {
                                        e1.printStackTrace();
                                    }
                                }
                            }
                        }
                    } catch (Exception e) {
                        LogHelper.errorDetailInfo(e);
                    }
                }
            }
        });
    /**
     * 更新精选库商品
     */
    public void doUpdateGoodsJob() {
        for (int i = 0; i < 1; i++)
            new JobThreadExecutorServiceImpl().run(new Runnable() {
                @Override
                public void run() {
                    try {
                        Map<String, Long> map = CMQManager.getInstance().consumeNeedUpdateTaoBaoGoodsIdMsg(16);
                        if (map != null) {
                            Iterator<String> its = map.keySet().iterator();
                            while (its.hasNext()) {
                                String key = its.next();
                                taoBaoGoodsUpdateService.updateByTaoKeGoodsDetail(Long.parseLong(key));
                                CMQManager.getInstance().deleteNeedUpdateTaoBaoGoodsIdMsg(key);
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        LogHelper.error("更新商品出错:" + e.getMessage());
                    }
                }
            });
    }
    }
    /**
     * 用户借贷处理
     */
    public void doUserMoneyDebtJob() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                try {
                    Map<String, UserMoneyChangeDTO> map = UserMoneyChangeCMQManager.getInstance()
                            .consumeQueueMsg(UserMoneyChangeCMQManager.QUEUE_DEBT, 16);
                    if (map != null) {
    /**
     * 创建Scheduler()执行自动爬取
     */
    private void initScheduler() {
        boutiqueAutoRuleService.startScheduler();
    }
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String key = its.next();
                            try {
                                UserMoneyChangeDTO dto = map.get(key);
                                if (dto != null && dto.getChangeMoney().compareTo(new BigDecimal(0)) > 0) {
                                    userMoneyDebtService.repayDebt(dto.getUid());
                                }
                                UserMoneyChangeCMQManager.getInstance()
                                        .deleteQueueMsg(UserMoneyChangeCMQManager.QUEUE_DEBT, key);
                            } catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e);
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            }
                        }
                    }
                } catch (Exception e) {
                    LogHelper.error("还款出错:" + e.getMessage());
                }
            }
        });
    }
    /**
     * 更新精选库商品
     */
    public void doUpdateGoodsJob() {
        for (int i = 0; i < 1; i++)
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    while (true) {
                        try {
                            Map<String, Long> map = CMQManager.getInstance().consumeNeedUpdateTaoBaoGoodsIdMsg(16);
                            if (map != null) {
                                Iterator<String> its = map.keySet().iterator();
                                while (its.hasNext()) {
                                    String key = its.next();
                                    taoBaoGoodsUpdateService.updateByTaoKeGoodsDetail(Long.parseLong(key));
                                    CMQManager.getInstance().deleteNeedUpdateTaoBaoGoodsIdMsg(key);
                                }
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                            LogHelper.error("更新商品出错:" + e.getMessage());
                        }
                    }
                }
            });
    }
    public void doJDOrderJob() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                try {
                    Map<String, String> map = JDOrderCMQManager.getInstance().consumeJDOrder(16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String key = its.next();
                            try {
                                String orderId = map.get(key);
                                if (!StringUtil.isNullOrEmpty(orderId)) {
                                    JDOrder order = jdOrderService.selectDetailByOrderId(Long.parseLong(orderId));
                                    orderProcessService.processJDOrder(order);
                                }
                                JDOrderCMQManager.getInstance().deleteJDOrder(key);
                            } catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e);
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            }
                        }
                    }
                } catch (Exception e) {
                    LogHelper.error("拼多多订单出错:" + e.getMessage());
                }
            }
        });
    /**
     * 用户借贷处理
     */
    public void doUserMoneyDebtJob() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Map<String, UserMoneyChangeDTO> map = UserMoneyChangeCMQManager.getInstance()
                                .consumeQueueMsg(UserMoneyChangeCMQManager.QUEUE_DEBT, 16);
                        if (map != null) {
    }
                            Iterator<String> its = map.keySet().iterator();
                            while (its.hasNext()) {
                                String key = its.next();
                                try {
                                    UserMoneyChangeDTO dto = map.get(key);
                                    if (dto != null && dto.getChangeMoney().compareTo(new BigDecimal(0)) > 0) {
                                        userMoneyDebtService.repayDebt(dto.getUid());
                                    }
                                    UserMoneyChangeCMQManager.getInstance()
                                            .deleteQueueMsg(UserMoneyChangeCMQManager.QUEUE_DEBT, key);
                                } catch (Exception e) {
                                    try {
                                        LogHelper.errorDetailInfo(e);
                                    } catch (Exception e1) {
                                        e1.printStackTrace();
                                    }
                                }
                            }
                        }
                    } catch (Exception e) {
                        LogHelper.error("还款出错:" + e.getMessage());
                    }
                }
            }
        });
    }
    public void doPDDOrderJob() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                try {
                    Map<String, String> map = PDDOrderCMQManager.getInstance().consumePDDOrder(16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String key = its.next();
                            try {
                                String orderId = map.get(key);
                                if (!StringUtil.isNullOrEmpty(orderId)) {
                                    List<PDDOrder> orderList = pddOrderService.selectByOrderSn(orderId);
                                    if (orderList != null)
                                        for (PDDOrder order : orderList)
                                            orderProcessService.processPDDOrder(order);
                                }
                                PDDOrderCMQManager.getInstance().deletePDDOrder(key);
                            } catch (Exception e) {
                                LogHelper.errorDetailInfo(e);
                            }
                        }
                    }
                } catch (Exception e) {
                    LogHelper.error("拼多多订单:" + e.getMessage());
                }
            }
        });
    public void doJDOrderJob() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Map<String, String> map = JDOrderCMQManager.getInstance().consumeJDOrder(16);
                        if (map != null) {
                            Iterator<String> its = map.keySet().iterator();
                            while (its.hasNext()) {
                                String key = its.next();
                                try {
                                    String orderId = map.get(key);
                                    if (!StringUtil.isNullOrEmpty(orderId)) {
                                        JDOrder order = jdOrderService.selectDetailByOrderId(Long.parseLong(orderId));
                                        orderProcessService.processJDOrder(order);
                                    }
                                    JDOrderCMQManager.getInstance().deleteJDOrder(key);
                                } catch (Exception e) {
                                    try {
                                        LogHelper.errorDetailInfo(e);
                                    } catch (Exception e1) {
                                        e1.printStackTrace();
                                    }
                                }
                            }
                        }
                    } catch (Exception e) {
                        LogHelper.error("拼多多订单出错:" + e.getMessage());
    }
                    }
                }
            }
        });
    public void doVipShopOrderJob() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                try {
                    Map<String, String> map = VipShopOrderCMQManager.getInstance().consumeVipShopOrder(16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String key = its.next();
                            try {
                                String orderId = map.get(key);
                                LogHelper.test("唯品会订单消费:" + orderId);
                                if (!StringUtil.isNullOrEmpty(orderId)) {
                                    List<VipShopOrder> orderList = vipShopOrderService.listDetailByOrderSn(orderId);
                                    if (orderList != null)
                                        for (VipShopOrder order : orderList)
                                            orderProcessService.processVipShopOrder(order);
                                }
                                VipShopOrderCMQManager.getInstance().deleteVipShopOrder(key);
                            } catch (Exception e) {
                                LogHelper.errorDetailInfo(e);
                            }
                        }
                    }
                } catch (Exception e) {
                    LogHelper.errorDetailInfo(e);
                }
            }
        });
    }
    }
    public void doPDDOrderJob() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Map<String, String> map = PDDOrderCMQManager.getInstance().consumePDDOrder(16);
                        if (map != null) {
                            Iterator<String> its = map.keySet().iterator();
                            while (its.hasNext()) {
                                String key = its.next();
                                try {
                                    String orderId = map.get(key);
                                    if (!StringUtil.isNullOrEmpty(orderId)) {
                                        List<PDDOrder> orderList = pddOrderService.selectByOrderSn(orderId);
                                        if (orderList != null)
                                            for (PDDOrder order : orderList)
                                                orderProcessService.processPDDOrder(order);
                                    }
                                    PDDOrderCMQManager.getInstance().deletePDDOrder(key);
                                } catch (Exception e) {
                                    LogHelper.errorDetailInfo(e);
                                }
                            }
                        }
                    } catch (Exception e) {
                        LogHelper.error("拼多多订单:" + e.getMessage());
                    }
                }
            }
        });
    }
    public void doSuningOrderJob() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                try {
                    Map<String, String> map = SuningOrderCMQManager.getInstance().consumeSuningOrder(16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String key = its.next();
                            try {
                                String orderId = map.get(key);
                                if (!StringUtil.isNullOrEmpty(orderId)) {
                                    List<SuningOrderInfo> orderList = suningOrderService.listByOrderCode(orderId);
                                    if (orderList != null)
                                        for (SuningOrderInfo order : orderList)
                                            orderProcessService.processSuningOrder(order);
                                }
                                SuningOrderCMQManager.getInstance().deleteSuningOrder(key);
                            } catch (Exception e) {
                                LogHelper.errorDetailInfo(e);
                            }
                        }
                    }
                } catch (Exception e) {
                    LogHelper.errorDetailInfo(e);
                }
            }
        });
    public void doVipShopOrderJob() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Map<String, String> map = VipShopOrderCMQManager.getInstance().consumeVipShopOrder(16);
                        if (map != null) {
                            Iterator<String> its = map.keySet().iterator();
                            while (its.hasNext()) {
                                String key = its.next();
                                try {
                                    String orderId = map.get(key);
                                    LogHelper.test("唯品会订单消费:"+orderId);
                                    if (!StringUtil.isNullOrEmpty(orderId)) {
                                        List<VipShopOrder> orderList = vipShopOrderService.listDetailByOrderSn(orderId);
                                        if (orderList != null)
                                            for (VipShopOrder order : orderList)
                                                orderProcessService.processVipShopOrder(order);
                                    }
                                    VipShopOrderCMQManager.getInstance().deleteVipShopOrder(key);
                                } catch (Exception e) {
                                    LogHelper.errorDetailInfo(e);
                                }
                            }
                        }
                    } catch (Exception e) {
                        LogHelper.errorDetailInfo(e);
                    }
                }
            }
        });
    }
    }
    public void doSuningOrderJob() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Map<String, String> map = SuningOrderCMQManager.getInstance().consumeSuningOrder(16);
                        if (map != null) {
                            Iterator<String> its = map.keySet().iterator();
                            while (its.hasNext()) {
                                String key = its.next();
                                try {
                                    String orderId = map.get(key);
                                    if (!StringUtil.isNullOrEmpty(orderId)) {
                                        List<SuningOrderInfo> orderList = suningOrderService.listByOrderCode(orderId);
                                        if (orderList != null)
                                            for (SuningOrderInfo order : orderList)
                                                orderProcessService.processSuningOrder(order);
                                    }
                                    SuningOrderCMQManager.getInstance().deleteSuningOrder(key);
                                } catch (Exception e) {
                                    LogHelper.errorDetailInfo(e);
                                }
                            }
                        }
                    } catch (Exception e) {
                        LogHelper.errorDetailInfo(e);
                    }
                }
            }
        });
    /**
     * 重要的淘宝商品信息更新
     */
    public void doImportantTaoBaoGoodsUpdateJob() {
        // 开启2个线程做更新
        for (int i = 0; i < 2; i++)
            new JobThreadExecutorServiceImpl().run(new Runnable() {
                @Override
                public void run() {
                    Map<String, Long> map = CMQManager.getInstance().consumeTBImpGoodsUpdateMsg(16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String key = its.next();
                            try {
                                long startTime = System.currentTimeMillis();
                                TaoBaoGoodsBrief goods = TaoKeApiUtil.searchGoodsDetail(map.get(key));
                                // 更新一条数据需要的时间
                                taoBaoGoodsUpdateService.updateTaoBaoGoods(goods);
                                long time = System.currentTimeMillis() - startTime;
                                LogHelper.test("淘宝重要商品库更新时间:" + time);
                            } catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e);
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            } finally {
                                CMQManager.getInstance().deleteTBImpGoodsUpdateMsg(key);
                            }
                        }
                    }
                }
            });
    }
    }
    /**
     * 红包到账后的金币获取
     */
    public void doHongBaoRecieveIntegralGetJob() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                    Map<String, Long> map = HongBaoRecieveCMQManager.getInstance()
                            .consumeQueueMsg(HongBaoRecieveCMQManager.QUEUE_INTEGRAL, 16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String key = its.next();
                            Long hongBaoId = map.get(key);
                            try {
                                HongBaoV2 hongBaoV2 = hongBaoV2Service.selectByPrimaryKey(hongBaoId);
                                if (hongBaoV2 != null && hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU
                                        && hongBaoV2.getMoney().compareTo(new BigDecimal(0)) > 0) {
                                    // 到账送金币
                                    fanliGetIntegral(hongBaoV2);
                                    HongBaoRecieveCMQManager.getInstance()
                                            .deleteQueueMsg(HongBaoRecieveCMQManager.QUEUE_INTEGRAL, key);
    /**
     * 重要的淘宝商品信息更新
     */
    public void doImportantTaoBaoGoodsUpdateJob() {
        // 开启2个线程做更新
        for (int i = 0; i < 2; i++)
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    while (true) {
                        Map<String, Long> map = CMQManager.getInstance().consumeTBImpGoodsUpdateMsg(16);
                        if (map != null) {
                            Iterator<String> its = map.keySet().iterator();
                            while (its.hasNext()) {
                                String key = its.next();
                                try {
                                    long startTime = System.currentTimeMillis();
                                    TaoBaoGoodsBrief goods = TaoKeApiUtil.searchGoodsDetail(map.get(key));
                                    // 更新一条数据需要的时间
                                    taoBaoGoodsUpdateService.updateTaoBaoGoods(goods);
                                    long time = System.currentTimeMillis() - startTime;
                                    LogHelper.test("淘宝重要商品库更新时间:" + time);
                                } catch (Exception e) {
                                    try {
                                        LogHelper.errorDetailInfo(e);
                                    } catch (Exception e1) {
                                        e1.printStackTrace();
                                    }
                                } finally {
                                    CMQManager.getInstance().deleteTBImpGoodsUpdateMsg(key);
                                }
                            }
                        }
                    }
                }
            });
    }
                                    // 返利不足0.01元送金币
                                    if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 自购
                                        // 判断是否为该用户的首笔红包
                                        List<Integer> typeList = new ArrayList<>();
                                        typeList.add(HongBaoV2.TYPE_ZIGOU);
                                        HongBaoV2 firstHongBao = hongBaoV2Service.getFirstValidHongBaoByTypeAndUid(
                                                typeList, hongBaoV2.getUserInfo().getId());
                                        if (firstHongBao != null
                                                && firstHongBao.getId().longValue() == hongBaoV2.getId()) {// 自购首单到账
                                            // 查询下级红包
                                            BigDecimal firstLevelMoney = new BigDecimal(0);
                                            BigDecimal secondLevelMoney = new BigDecimal(0);
                                            // 获取改单下面的红包
                                            List<HongBaoV2> hongBaoList = new ArrayList<>();
                                            HongBaoOrder hongBaoOrder = hongBaoOrderService
                                                    .selectDetailByHongBaoId(hongBaoV2.getId());
                                            if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {// 计算改订单号下面的所有返利金额
                                                CommonOrder commonOrder = hongBaoOrder.getCommonOrder();
                                                List<CommonOrder> list = commonOrderService.listBySourceTypeAndOrderId(
                                                        commonOrder.getSourceType(), commonOrder.getOrderNo());
                                                for (CommonOrder co : list) {
                                                    HongBaoOrder hbo = hongBaoOrderService
                                                            .selectDetailByCommonOrderId(co.getId());
                                                    if (hbo != null && hbo.getHongBaoV2() != null)
                                                        hongBaoList.add(hbo.getHongBaoV2());
                                                }
                                            }
    /**
     * 红包到账后的金币获取
     */
    public void doHongBaoRecieveIntegralGetJob() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    Map<String, Long> map = HongBaoRecieveCMQManager.getInstance()
                            .consumeQueueMsg(HongBaoRecieveCMQManager.QUEUE_INTEGRAL, 16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String key = its.next();
                            Long hongBaoId = map.get(key);
                            try {
                                HongBaoV2 hongBaoV2 = hongBaoV2Service.selectByPrimaryKey(hongBaoId);
                                if (hongBaoV2 != null && hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU
                                        && hongBaoV2.getMoney().compareTo(new BigDecimal(0)) > 0) {
                                    // 到账送金币
                                    fanliGetIntegral(hongBaoV2);
                                    HongBaoRecieveCMQManager.getInstance()
                                            .deleteQueueMsg(HongBaoRecieveCMQManager.QUEUE_INTEGRAL, key);
                                            for (HongBaoV2 hb : hongBaoList) {
                                                List<HongBaoV2> children = hongBaoV2Service
                                                        .listChildrenById(hb.getId());
                                                if (children != null)
                                                    for (HongBaoV2 child : children)
                                                        if (child.getType() == HongBaoV2.TYPE_YIJI) {
                                                            firstLevelMoney = firstLevelMoney.add(child.getMoney());
                                                        } else if (child.getType() == HongBaoV2.TYPE_ERJI) {
                                                            secondLevelMoney = secondLevelMoney.add(child.getMoney());
                                                        }
                                            }
                                    // 返利不足0.01元送金币
                                    if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 自购
                                        // 判断是否为该用户的首笔红包
                                        List<Integer> typeList = new ArrayList<>();
                                        typeList.add(HongBaoV2.TYPE_ZIGOU);
                                        HongBaoV2 firstHongBao = hongBaoV2Service.getFirstValidHongBaoByTypeAndUid(
                                                typeList, hongBaoV2.getUserInfo().getId());
                                        if (firstHongBao != null
                                                && firstHongBao.getId().longValue() == hongBaoV2.getId()) {// 自购首单到账
                                            // 查询下级红包
                                            BigDecimal firstLevelMoney = new BigDecimal(0);
                                            BigDecimal secondLevelMoney = new BigDecimal(0);
                                            // 获取改单下面的红包
                                            List<HongBaoV2> hongBaoList = new ArrayList<>();
                                            HongBaoOrder hongBaoOrder = hongBaoOrderService
                                                    .selectDetailByHongBaoId(hongBaoV2.getId());
                                            if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {// 计算改订单号下面的所有返利金额
                                                CommonOrder commonOrder = hongBaoOrder.getCommonOrder();
                                                List<CommonOrder> list = commonOrderService.listBySourceTypeAndOrderId(
                                                        commonOrder.getSourceType(), commonOrder.getOrderNo());
                                                for (CommonOrder co : list) {
                                                    HongBaoOrder hbo = hongBaoOrderService
                                                            .selectDetailByCommonOrderId(co.getId());
                                                    if (hbo != null && hbo.getHongBaoV2() != null)
                                                        hongBaoList.add(hbo.getHongBaoV2());
                                                }
                                            }
                                            // 查询下级的生效时间
                                            ThreeSale threeSale = threeSaleSerivce.selectLatestByWorkerIdAndState(
                                                    hongBaoV2.getUserInfo().getId(), ThreeSale.STATE_SUCCESS);
                                            if (threeSale != null && threeSale.getSucceedTime() != null && threeSale
                                                    .getSucceedTime() < hongBaoV2.getCreateTime().getTime()) {// 邀请成功的时间是否在下单的时间之前
                                                // 成功时间要大于20190910日才开始送金币
                                                if (threeSale.getSucceedTime() > TimeUtil.convertToTimeTemp("20190901",
                                                        "yyyyMMdd")) {
                                                    if (firstLevelMoney.compareTo(new BigDecimal("0.01")) < 0) {// 一级返利小于0.01
                                                        integralTaskRecordService.firstRebateOrderRewardBoss(
                                                                threeSale.getBoss().getId(),
                                                                hongBaoV2.getUserInfo().getId(), null);
                                                        LogHelper.test("自购-一级用户-" + threeSale.getBoss().getId()
                                                                + "-hongBaoId:" + hongBaoV2.getId());
                                                    }
                                                }
                                            }
                                            // 查询下下级生效时间
                                            if (threeSale != null) {
                                                threeSale = threeSaleSerivce.selectLatestByWorkerIdAndState(
                                                        threeSale.getBoss().getId(), ThreeSale.STATE_SUCCESS);
                                                if (threeSale != null && threeSale.getSucceedTime() != null && threeSale
                                                        .getSucceedTime() < hongBaoV2.getCreateTime().getTime()) {// 邀请成功的时间是否在下单的时间之前
                                                    // 成功时间要大于20190910日才开始送金币
                                                    if (threeSale.getSucceedTime() > TimeUtil
                                                            .convertToTimeTemp("20190901", "yyyyMMdd")) {
                                                        if (secondLevelMoney.compareTo(new BigDecimal("0.01")) < 0) {// 二级返利小于0.01
                                                            integralTaskRecordService.firstRebateOrderRewardBossSuper(
                                                                    threeSale.getBoss().getId(),
                                                                    hongBaoV2.getUserInfo().getId(), null);
                                                            LogHelper.test("自购-二级用户-" + threeSale.getBoss().getId()
                                                                    + "-hongBaoId:" + hongBaoV2.getId());
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    } else if (hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_GOODS) {// 分享赚
                                        // 判断是否为该用户的首笔红包
                                        List<Integer> typeList = new ArrayList<>();
                                        typeList.add(HongBaoV2.TYPE_SHARE_GOODS);
                                        HongBaoV2 firstHongBao = hongBaoV2Service.getFirstValidHongBaoByTypeAndUid(
                                                typeList, hongBaoV2.getUserInfo().getId());
                                        if (firstHongBao != null
                                                && firstHongBao.getId().longValue() == hongBaoV2.getId()) // 分享首笔到账
                                        {
                                            for (HongBaoV2 hb : hongBaoList) {
                                                List<HongBaoV2> children = hongBaoV2Service
                                                        .listChildrenById(hb.getId());
                                                if (children != null)
                                                    for (HongBaoV2 child : children)
                                                        if (child.getType() == HongBaoV2.TYPE_YIJI) {
                                                            firstLevelMoney = firstLevelMoney.add(child.getMoney());
                                                        } else if (child.getType() == HongBaoV2.TYPE_ERJI) {
                                                            secondLevelMoney = secondLevelMoney.add(child.getMoney());
                                                        }
                                            }
                                            // 查询下级红包
                                            BigDecimal firstLevelMoney = new BigDecimal(0);
                                            // 获取改单下面的红包
                                            List<HongBaoV2> hongBaoList = new ArrayList<>();
                                            HongBaoOrder hongBaoOrder = hongBaoOrderService
                                                    .selectDetailByHongBaoId(hongBaoV2.getId());
                                            if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {// 计算改订单号下面的所有返利金额
                                                CommonOrder commonOrder = hongBaoOrder.getCommonOrder();
                                                List<CommonOrder> list = commonOrderService.listBySourceTypeAndOrderId(
                                                        commonOrder.getSourceType(), commonOrder.getOrderNo());
                                                for (CommonOrder co : list) {
                                                    HongBaoOrder hbo = hongBaoOrderService
                                                            .selectDetailByCommonOrderId(co.getId());
                                                    if (hbo != null && hbo.getHongBaoV2() != null)
                                                        hongBaoList.add(hbo.getHongBaoV2());
                                                }
                                            }
                                            // 查询下级的生效时间
                                            ThreeSale threeSale = threeSaleSerivce.selectLatestByWorkerIdAndState(
                                                    hongBaoV2.getUserInfo().getId(), ThreeSale.STATE_SUCCESS);
                                            if (threeSale != null && threeSale.getSucceedTime() != null && threeSale
                                                    .getSucceedTime() < hongBaoV2.getCreateTime().getTime()) {// 邀请成功的时间是否在下单的时间之前
                                                // 成功时间要大于20190910日才开始送金币
                                                if (threeSale.getSucceedTime() > TimeUtil.convertToTimeTemp("20190901",
                                                        "yyyyMMdd")) {
                                                    if (firstLevelMoney.compareTo(new BigDecimal("0.01")) < 0) {// 一级返利小于0.01
                                                        integralTaskRecordService.firstRebateOrderRewardBoss(
                                                                threeSale.getBoss().getId(),
                                                                hongBaoV2.getUserInfo().getId(), null);
                                                        LogHelper.test("自购-一级用户-" + threeSale.getBoss().getId()
                                                                + "-hongBaoId:" + hongBaoV2.getId());
                                                    }
                                                }
                                            }
                                            // 查询下下级生效时间
                                            if (threeSale != null) {
                                                threeSale = threeSaleSerivce.selectLatestByWorkerIdAndState(
                                                        threeSale.getBoss().getId(), ThreeSale.STATE_SUCCESS);
                                                if (threeSale != null && threeSale.getSucceedTime() != null && threeSale
                                                        .getSucceedTime() < hongBaoV2.getCreateTime().getTime()) {// 邀请成功的时间是否在下单的时间之前
                                                    // 成功时间要大于20190910日才开始送金币
                                                    if (threeSale.getSucceedTime() > TimeUtil
                                                            .convertToTimeTemp("20190901", "yyyyMMdd")) {
                                                        if (secondLevelMoney.compareTo(new BigDecimal("0.01")) < 0) {// 二级返利小于0.01
                                                            integralTaskRecordService.firstRebateOrderRewardBossSuper(
                                                                    threeSale.getBoss().getId(),
                                                                    hongBaoV2.getUserInfo().getId(), null);
                                                            LogHelper.test("自购-二级用户-" + threeSale.getBoss().getId()
                                                                    + "-hongBaoId:" + hongBaoV2.getId());
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    } else if (hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_GOODS) {// 分享赚
                                        // 判断是否为该用户的首笔红包
                                        List<Integer> typeList = new ArrayList<>();
                                        typeList.add(HongBaoV2.TYPE_SHARE_GOODS);
                                        HongBaoV2 firstHongBao = hongBaoV2Service.getFirstValidHongBaoByTypeAndUid(
                                                typeList, hongBaoV2.getUserInfo().getId());
                                        if (firstHongBao != null
                                                && firstHongBao.getId().longValue() == hongBaoV2.getId()) // 分享首笔到账
                                        {
                                            for (HongBaoV2 hb : hongBaoList) {
                                                List<HongBaoV2> children = hongBaoV2Service
                                                        .listChildrenById(hb.getId());
                                                if (children != null)
                                                    for (HongBaoV2 child : children)
                                                        if (child.getType() == HongBaoV2.TYPE_SHARE_YIJI) {
                                                            firstLevelMoney = firstLevelMoney.add(child.getMoney());
                                                        }
                                            }
                                            // 查询下级红包
                                            BigDecimal firstLevelMoney = new BigDecimal(0);
                                            // 获取改单下面的红包
                                            List<HongBaoV2> hongBaoList = new ArrayList<>();
                                            HongBaoOrder hongBaoOrder = hongBaoOrderService
                                                    .selectDetailByHongBaoId(hongBaoV2.getId());
                                            if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {// 计算改订单号下面的所有返利金额
                                                CommonOrder commonOrder = hongBaoOrder.getCommonOrder();
                                                List<CommonOrder> list = commonOrderService.listBySourceTypeAndOrderId(
                                                        commonOrder.getSourceType(), commonOrder.getOrderNo());
                                                for (CommonOrder co : list) {
                                                    HongBaoOrder hbo = hongBaoOrderService
                                                            .selectDetailByCommonOrderId(co.getId());
                                                    if (hbo != null && hbo.getHongBaoV2() != null)
                                                        hongBaoList.add(hbo.getHongBaoV2());
                                                }
                                            }
                                            ThreeSale threeSale = threeSaleSerivce.selectLatestByWorkerIdAndState(
                                                    hongBaoV2.getUserInfo().getId(), ThreeSale.STATE_SUCCESS);
                                            if (threeSale != null && threeSale.getSucceedTime() != null && threeSale
                                                    .getSucceedTime() < hongBaoV2.getCreateTime().getTime()) {// 邀请成功的时间是否在下单的时间之前
                                                // 成功时间要大于20190910日才开始送金币
                                                if (threeSale.getSucceedTime() > TimeUtil.convertToTimeTemp("20190901",
                                                        "yyyyMMdd")) {
                                                    if (firstLevelMoney.compareTo(new BigDecimal("0.01")) < 0) {// 一级返利小于0.01
                                                        integralTaskRecordService.firstSharerOrderRewardBoss(
                                                                threeSale.getBoss().getId(),
                                                                hongBaoV2.getUserInfo().getId(), null);
                                                        LogHelper.test("分享-一级用户-" + threeSale.getBoss().getId()
                                                                + "-hongBaoId:" + hongBaoV2.getId());
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                            for (HongBaoV2 hb : hongBaoList) {
                                                List<HongBaoV2> children = hongBaoV2Service
                                                        .listChildrenById(hb.getId());
                                                if (children != null)
                                                    for (HongBaoV2 child : children)
                                                        if (child.getType() == HongBaoV2.TYPE_SHARE_YIJI) {
                                                            firstLevelMoney = firstLevelMoney.add(child.getMoney());
                                                        }
                                            }
                            } catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e);
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            } finally {
                                            ThreeSale threeSale = threeSaleSerivce.selectLatestByWorkerIdAndState(
                                                    hongBaoV2.getUserInfo().getId(), ThreeSale.STATE_SUCCESS);
                                            if (threeSale != null && threeSale.getSucceedTime() != null && threeSale
                                                    .getSucceedTime() < hongBaoV2.getCreateTime().getTime()) {// 邀请成功的时间是否在下单的时间之前
                                                // 成功时间要大于20190910日才开始送金币
                                                if (threeSale.getSucceedTime() > TimeUtil.convertToTimeTemp("20190901",
                                                        "yyyyMMdd")) {
                                                    if (firstLevelMoney.compareTo(new BigDecimal("0.01")) < 0) {// 一级返利小于0.01
                                                        integralTaskRecordService.firstSharerOrderRewardBoss(
                                                                threeSale.getBoss().getId(),
                                                                hongBaoV2.getUserInfo().getId(), null);
                                                        LogHelper.test("分享-一级用户-" + threeSale.getBoss().getId()
                                                                + "-hongBaoId:" + hongBaoV2.getId());
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
        });
    }
                            } catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e);
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            } finally {
    private void fanliGetIntegral(HongBaoV2 hongBaoV2) {
        if (hongBaoV2 != null && hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU
                && hongBaoV2.getMoney().compareTo(new BigDecimal(0)) > 0) {
            // 查询对应的订单号
            Long mainHongBaoId = hongBaoV2.getId();
            if (hongBaoV2.getParent() != null && hongBaoV2.getParent().getId() != null)
                mainHongBaoId = hongBaoV2.getParent().getId();
                            }
                        }
                    }
                }
            }
        });
    }
            HongBaoOrder hongbaoOrder = hongBaoOrderService.selectDetailByHongBaoId(mainHongBaoId);
            if (hongbaoOrder == null || hongbaoOrder.getCommonOrder() == null)
                return;
            CommonOrder commonOrder = hongbaoOrder.getCommonOrder();
    private void fanliGetIntegral(HongBaoV2 hongBaoV2) {
        if (hongBaoV2 != null && hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU
                && hongBaoV2.getMoney().compareTo(new BigDecimal(0)) > 0) {
            // 查询对应的订单号
            Long mainHongBaoId = hongBaoV2.getId();
            if (hongBaoV2.getParent() != null && hongBaoV2.getParent().getId() != null)
                mainHongBaoId = hongBaoV2.getParent().getId();
            if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 自购订单
                integralGetService.addRebateOrder(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(),
                        commonOrder.getSourceType());
            } else if (hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_GOODS) {// 分享订单
                integralGetService.addShareOrder(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(),
                        commonOrder.getSourceType());
            } else if (hongBaoV2.getType() == HongBaoV2.TYPE_YIJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 一级邀请
                integralGetService.addInviteOrderLevelOne(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(),
                        commonOrder.getSourceType());
            } else if (hongBaoV2.getType() == HongBaoV2.TYPE_ERJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 二级邀请
                integralGetService.addInviteOrderLevelTwo(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(),
                        commonOrder.getSourceType());
            }
        }
    }
            HongBaoOrder hongbaoOrder = hongBaoOrderService.selectDetailByHongBaoId(mainHongBaoId);
            if (hongbaoOrder == null || hongbaoOrder.getCommonOrder() == null)
                return;
            CommonOrder commonOrder = hongbaoOrder.getCommonOrder();
    private boolean isFirstValidOrder(String orderId, int sourceType, Long uid) {
        CommonOrder commonOrder = commonOrderService.selectLatestValidByUid(uid);
        if (commonOrder != null && commonOrder.getOrderNo().equalsIgnoreCase(orderId)
                && sourceType == commonOrder.getSourceType())
            return true;
        else
            return false;
    }
            if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 自购订单
                integralGetService.addRebateOrder(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(),
                        commonOrder.getSourceType());
            } else if (hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_GOODS) {// 分享订单
                integralGetService.addShareOrder(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(),
                        commonOrder.getSourceType());
            } else if (hongBaoV2.getType() == HongBaoV2.TYPE_YIJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 一级邀请
                integralGetService.addInviteOrderLevelOne(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(),
                        commonOrder.getSourceType());
            } else if (hongBaoV2.getType() == HongBaoV2.TYPE_ERJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 二级邀请
                integralGetService.addInviteOrderLevelTwo(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(),
                        commonOrder.getSourceType());
            }
        }
    }
    // 下单获取金币任务
    public void doPlaceOrderIntegralJob() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                    Map<String, Order> map = PlaceOrderCMQManager.getInstance()
                            .consumeQueueMsg(PlaceOrderCMQManager.QUEUE_INTEGRAL, 16);
                    if (map != null) {
    private boolean isFirstValidOrder(String orderId, int sourceType, Long uid) {
        CommonOrder commonOrder = commonOrderService.selectLatestValidByUid(uid);
        if (commonOrder != null && commonOrder.getOrderNo().equalsIgnoreCase(orderId)
                && sourceType == commonOrder.getSourceType())
            return true;
        else
            return false;
    }
                        for (Iterator<String> its = map.keySet().iterator(); its.hasNext(); ) {
                            try {
                                String key = its.next();
                                Order order = map.get(key);
                                // 是否是首单
                                if (isFirstValidOrder(order.getOrderId(), order.getOrderType(),
                                        order.getUserInfo().getId())) {
                                    // 统计订单下的用户所获得的返利金额
                                    List<CommonOrder> list = commonOrderService
                                            .listBySourceTypeAndOrderId(order.getOrderType(), order.getOrderId());
                                    Map<Long, BigDecimal> hongBaoMoney = new HashMap<>();
                                    if (list != null)
                                        for (CommonOrder commonOrder : list) {
                                            HongBaoOrder hongBaoOrder = hongBaoOrderService
                                                    .selectDetailByCommonOrderId(commonOrder.getId());
                                            if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null) {
                                                Long mainUid = hongBaoOrder.getHongBaoV2().getUserInfo().getId();
                                                if (hongBaoMoney.get(mainUid) == null)
                                                    hongBaoMoney.put(mainUid, new BigDecimal(0));
                                                hongBaoMoney.put(mainUid, hongBaoMoney.get(mainUid)
                                                        .add(hongBaoOrder.getHongBaoV2().getMoney()));
                                                // 查询上级
                                                List<HongBaoV2> children = hongBaoV2Service
                                                        .listChildrenById(hongBaoOrder.getHongBaoV2().getId());
                                                if (children != null) {
                                                    for (HongBaoV2 hongBao : children) {
                                                        Long uid = hongBao.getUserInfo().getId();
                                                        if (hongBaoMoney.get(uid) == null)
                                                            hongBaoMoney.put(uid, new BigDecimal(0));
                                                        hongBaoMoney.put(uid,
                                                                hongBaoMoney.get(uid).add(hongBao.getMoney()));
                                                    }
                                                }
                                            }
                                        }
    // 下单获取金币任务
    public void doPlaceOrderIntegralJob() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    Map<String, Order> map = PlaceOrderCMQManager.getInstance()
                            .consumeQueueMsg(PlaceOrderCMQManager.QUEUE_INTEGRAL, 16);
                    if (map != null) {
                                    if (isFirstValidOrder(order.getOrderId(), order.getOrderType(),
                                            order.getUserInfo().getId())) {// 有效的首单
                                        if (hongBaoMoney.get(order.getUserInfo().getId()) == null || hongBaoMoney
                                                .get(order.getUserInfo().getId()).compareTo(new BigDecimal("0")) <= 0) {
                                            // 分享奖金是0
                                            integralTaskRecordService.firstShareOrderReward(order.getUserInfo().getId(),
                                                    null);
                                        }
                        for (Iterator<String> its = map.keySet().iterator(); its.hasNext();) {
                            try {
                                String key = its.next();
                                Order order = map.get(key);
                                // 是否是首单
                                if (isFirstValidOrder(order.getOrderId(), order.getOrderType(),
                                        order.getUserInfo().getId())) {
                                    // 统计订单下的用户所获得的返利金额
                                    List<CommonOrder> list = commonOrderService
                                            .listBySourceTypeAndOrderId(order.getOrderType(), order.getOrderId());
                                    Map<Long, BigDecimal> hongBaoMoney = new HashMap<>();
                                    if (list != null)
                                        for (CommonOrder commonOrder : list) {
                                            HongBaoOrder hongBaoOrder = hongBaoOrderService
                                                    .selectDetailByCommonOrderId(commonOrder.getId());
                                            if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null) {
                                                Long mainUid = hongBaoOrder.getHongBaoV2().getUserInfo().getId();
                                                if (hongBaoMoney.get(mainUid) == null)
                                                    hongBaoMoney.put(mainUid, new BigDecimal(0));
                                                hongBaoMoney.put(mainUid, hongBaoMoney.get(mainUid)
                                                        .add(hongBaoOrder.getHongBaoV2().getMoney()));
                                                // 查询上级
                                                List<HongBaoV2> children = hongBaoV2Service
                                                        .listChildrenById(hongBaoOrder.getHongBaoV2().getId());
                                                if (children != null) {
                                                    for (HongBaoV2 hongBao : children) {
                                                        Long uid = hongBao.getUserInfo().getId();
                                                        if (hongBaoMoney.get(uid) == null)
                                                            hongBaoMoney.put(uid, new BigDecimal(0));
                                                        hongBaoMoney.put(uid,
                                                                hongBaoMoney.get(uid).add(hongBao.getMoney()));
                                                    }
                                                }
                                            }
                                        }
                                        // 获取上两级数据
                                        UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId());
                                        if (boss != null) {// 判断上级的红包
                                            if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId())
                                                    .compareTo(new BigDecimal("0")) <= 0) {
                                                // 补偿金币
                                                integralTaskRecordService.firstSharerOrderRewardBoss(boss.getId(),
                                                        order.getUserInfo().getId(), null);
                                            }
                                        }
                                    if (isFirstValidOrder(order.getOrderId(), order.getOrderType(),
                                            order.getUserInfo().getId())) {// 有效的首单
                                        if (hongBaoMoney.get(order.getUserInfo().getId()) == null || hongBaoMoney
                                                .get(order.getUserInfo().getId()).compareTo(new BigDecimal("0")) <= 0) {
                                            // 分享奖金是0
                                            integralTaskRecordService.firstShareOrderReward(order.getUserInfo().getId(),
                                                    null);
                                        }
                                    } else {// 自购订单
                                        UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId());
                                        if (boss != null) {// 判断上级的红包
                                            if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId())
                                                    .compareTo(new BigDecimal("0")) <= 0) {
                                                // 补偿金币1级
                                                integralTaskRecordService.firstRebateOrderRewardBoss(boss.getId(),
                                                        order.getUserInfo().getId(), null);
                                            }
                                        // 获取上两级数据
                                        UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId());
                                        if (boss != null) {// 判断上级的红包
                                            if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId())
                                                    .compareTo(new BigDecimal("0")) <= 0) {
                                                // 补偿金币
                                                integralTaskRecordService.firstSharerOrderRewardBoss(boss.getId(),
                                                        order.getUserInfo().getId(), null);
                                            }
                                        }
                                            boss = threeSaleSerivce.getBoss(boss.getId());
                                            if (boss != null) {// 判断上级的红包
                                                if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney
                                                        .get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) {
                                                    // 补偿金币2级
                                                    integralTaskRecordService.firstRebateOrderRewardBossSuper(
                                                            boss.getId(), order.getUserInfo().getId(), null);
                                                }
                                            }
                                        }
                                    }
                                }
                                PlaceOrderCMQManager.getInstance().deleteQueueMsg(PlaceOrderCMQManager.QUEUE_INTEGRAL,
                                        key);
                            } catch (Exception e) {
                                LogHelper.errorDetailInfo(e);
                            }
                        }
                                    } else {// 自购订单
                                        UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId());
                                        if (boss != null) {// 判断上级的红包
                                            if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId())
                                                    .compareTo(new BigDecimal("0")) <= 0) {
                                                // 补偿金币1级
                                                integralTaskRecordService.firstRebateOrderRewardBoss(boss.getId(),
                                                        order.getUserInfo().getId(), null);
                                            }
                    }
                }
        });
    }
                                            boss = threeSaleSerivce.getBoss(boss.getId());
                                            if (boss != null) {// 判断上级的红包
                                                if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney
                                                        .get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) {
                                                    // 补偿金币2级
                                                    integralTaskRecordService.firstRebateOrderRewardBossSuper(
                                                            boss.getId(), order.getUserInfo().getId(), null);
                                                }
                                            }
                                        }
                                    }
                                }
                                PlaceOrderCMQManager.getInstance().deleteQueueMsg(PlaceOrderCMQManager.QUEUE_INTEGRAL,
                                        key);
                            } catch (Exception e) {
                                LogHelper.errorDetailInfo(e);
                            }
                        }
    // 抖音广告监控
    public void doPlaceOrderAdJob() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                Map<String, Order> map = PlaceOrderCMQManager.getInstance()
                        .consumeQueueMsg(PlaceOrderCMQManager.QUEUE_AD, 16);
                if (map != null) {
                    // 是否是首单
                    for (Iterator<String> its = map.keySet().iterator(); its.hasNext(); ) {
                        String key = its.next();
                        Order order = map.get(key);
                        if (isFirstValidOrder(order.getOrderId(), order.getOrderType(),
                                order.getUserInfo().getId())) {// 有效的首单
                            // TODO 抖音的数据回调
                        }
                    }
                }
            }
        });
    }
                    }
                }
            }
        });
    }
    @Resource
    private DouYinClickEventService douYinClickEventService;
    // 抖音广告监控
    public void doPlaceOrderAdJob() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    Map<String, Order> map = PlaceOrderCMQManager.getInstance()
                            .consumeQueueMsg(PlaceOrderCMQManager.QUEUE_AD, 16);
                    if (map != null) {
                        // 是否是首单
                        for (Iterator<String> its = map.keySet().iterator(); its.hasNext();) {
                            String key = its.next();
                            Order order = map.get(key);
                            if (isFirstValidOrder(order.getOrderId(), order.getOrderType(),
                                    order.getUserInfo().getId())) {// 有效的首单
                                // TODO 抖音的数据回调
                            }
                        }
                    }
                }
            }
        });
    }
    // 抖音
    public void doDouYinDeviceActiveJob() {
        LogHelper.test("开始执行:doDouYinDeviceActiveJob");
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                    Map<String, DouYinDeviceActiveQueueDTO> map = DouYinDeviceActiveCMQManager.getInstance()
                            .consume(16);
                    if (map != null) {
                        // 是否是首单
                        for (Iterator<String> its = map.keySet().iterator(); its.hasNext(); ) {
                            String key = its.next();
                            DouYinDeviceActiveQueueDTO active = map.get(key);
                            if (active.getType() == DouYinDeviceActiveQueueDTO.TYPE_AD) {// 抖音
                                DouYinClickEvent event = douYinClickEventService.selectByCallback(active.getCallback());
                                if (event != null) {
                                    if (event.getOs() == 0 && !StringUtil.isNullOrEmpty(event.getUuid())) {
                                        DeviceActive deviceActive = deviceActiveService
                                                .getFirstActiveInfoByImei(event.getUuid());
                                        if (deviceActive != null) {
                                            if (event != null) {
                                                if (event.getOs() == 0)
                                                    DouYinAdUtil.activeAndroid(event.getCallback(), event.getImei(),
                                                            deviceActive.getCreateTime().getTime());
                                                else if (event.getOs() == 1)
                                                    DouYinAdUtil.activeIOS(event.getCallback(), event.getIdfa(),
                                                            deviceActive.getCreateTime().getTime());
                                            }
                                        }
                                    } else {// TODO 处理IOS
    @Resource
    private DouYinClickEventService douYinClickEventService;
                                    }
                                }
    // 抖音
    public void doDouYinDeviceActiveJob() {
        LogHelper.test("开始执行:doDouYinDeviceActiveJob");
        executor.execute(new Runnable() {
            @Override
            public void run() {
                LogHelper.test("开始执行:doDouYinDeviceActiveJob-run");
                while (true) {
                    Map<String, DouYinDeviceActiveQueueDTO> map = DouYinDeviceActiveCMQManager.getInstance()
                            .consume(16);
                    if (map != null) {
                        // 是否是首单
                        for (Iterator<String> its = map.keySet().iterator(); its.hasNext();) {
                            String key = its.next();
                            DouYinDeviceActiveQueueDTO active = map.get(key);
                            if (active.getType() == DouYinDeviceActiveQueueDTO.TYPE_AD) {// 抖音
                                DouYinClickEvent event = douYinClickEventService.selectByCallback(active.getCallback());
                                if (event != null) {
                                    if (event.getOs() == 0 && !StringUtil.isNullOrEmpty(event.getUuid())) {
                                        DeviceActive deviceActive = deviceActiveService
                                                .getFirstActiveInfoByImei(event.getUuid());
                                        if (deviceActive != null) {
                                            if (event != null) {
                                                if (event.getOs() == 0)
                                                    DouYinAdUtil.activeAndroid(event.getCallback(), event.getImei(),
                                                            deviceActive.getCreateTime().getTime());
                                                else if (event.getOs() == 1)
                                                    DouYinAdUtil.activeIOS(event.getCallback(), event.getIdfa(),
                                                            deviceActive.getCreateTime().getTime());
                                            }
                                        }
                                    } else {// TODO 处理IOS
                            } else if (active.getType() == DouYinDeviceActiveQueueDTO.TYPE_DEVICE) {// 设备
                                    }
                                }
                                if (active.getPlatform() == 1) {
                                    DeviceActive deviceActive = deviceActiveService
                                            .getFirstActiveInfo(active.getDevice());
                                    if (deviceActive != null && !StringUtil.isNullOrEmpty(deviceActive.getImei())) {
                                        DouYinClickEvent event = douYinClickEventService
                                                .selectByUuid(deviceActive.getImei());
                                        if (event != null) {// 回调
                                            if (deviceActive != null)
                                                DouYinAdUtil.activeAndroid(event.getCallback(), event.getImei(),
                                                        deviceActive.getCreateTime().getTime());
                                        }
                                    }
                                } else {
                                    // TODO 兼容IOS
                                }
                            }
                            DouYinDeviceActiveCMQManager.getInstance().delete(key);
                        }
                    }
                }
        });
    }
                            } else if (active.getType() == DouYinDeviceActiveQueueDTO.TYPE_DEVICE) {// 设备
    // 分红
    public void doDividentsPreJob() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                    Map<String, UidDateDTO> map = TeamOrderCMQManager.getInstance().consumeTeamDividentsPreMsg(16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String key = its.next();
                            UidDateDTO dto = map.get(key);
                            try {
                                teamDividentsManager.addToTeamEincome(dto.getUid(), dto.getDate());
                                TeamOrderCMQManager.getInstance().deleteTeamDividentsPreMsg(key);
                            } catch (TeamDividentsRecordException e1) {
                                if (e1.getCode() == TeamDividentsRecordException.CODE_EXIST) {
                                    TeamOrderCMQManager.getInstance().deleteTeamDividentsPreMsg(key);
                                } else {
                                    try {
                                        LogHelper.errorDetailInfo(e1);
                                    } catch (Exception e2) {
                                        e2.printStackTrace();
                                    }
                                }
                            } catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e);
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            } finally {
                                if (active.getPlatform() == 1) {
                                    DeviceActive deviceActive = deviceActiveService
                                            .getFirstActiveInfo(active.getDevice());
                                    if (deviceActive != null && !StringUtil.isNullOrEmpty(deviceActive.getImei())) {
                                        DouYinClickEvent event = douYinClickEventService
                                                .selectByUuid(deviceActive.getImei());
                                        if (event != null) {// 回调
                                            if (deviceActive != null)
                                                DouYinAdUtil.activeAndroid(event.getCallback(), event.getImei(),
                                                        deviceActive.getCreateTime().getTime());
                                        }
                                    }
                                } else {
                                    // TODO 兼容IOS
                                }
                            }
                            DouYinDeviceActiveCMQManager.getInstance().delete(key);
                        }
                    }
                }
            }
        });
    }
                            }
                        }
                    }
                }
        });
    }
    // 分红
    public void doDividentsPreJob() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    Map<String, UidDateDTO> map = TeamOrderCMQManager.getInstance().consumeTeamDividentsPreMsg(16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String key = its.next();
                            UidDateDTO dto = map.get(key);
                            try {
                                teamDividentsManager.addToTeamEincome(dto.getUid(), dto.getDate());
                                TeamOrderCMQManager.getInstance().deleteTeamDividentsPreMsg(key);
                            } catch (TeamDividentsRecordException e1) {
                                if (e1.getCode() == TeamDividentsRecordException.CODE_EXIST) {
                                    TeamOrderCMQManager.getInstance().deleteTeamDividentsPreMsg(key);
                                } else {
                                    try {
                                        LogHelper.errorDetailInfo(e1);
                                    } catch (Exception e2) {
                                        e2.printStackTrace();
                                    }
                                }
                            }
    // 分红
    public void doDividentsJob() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                    Map<String, UidDateDTO> map = TeamOrderCMQManager.getInstance().consumeTeamDividentsMsg(16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String key = its.next();
                            UidDateDTO dto = map.get(key);
                            try {
                                teamEincomeManager.addTeamDividentsTOUserAccount(dto.getDate(), dto.getUid());
                                TeamOrderCMQManager.getInstance().deleteTeamDividentsMsg(key);
                            } catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e);
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            } finally {
                            catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e);
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            } finally {
                            }
                        }
                    }
            }
        });
    }
                            }
                        }
                    }
                }
            }
        });
    }
    // 分红
    public void doDividentsJob() {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    Map<String, UidDateDTO> map = TeamOrderCMQManager.getInstance().consumeTeamDividentsMsg(16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String key = its.next();
                            UidDateDTO dto = map.get(key);
                            try {
                                teamEincomeManager.addTeamDividentsTOUserAccount(dto.getDate(), dto.getUid());
                                TeamOrderCMQManager.getInstance().deleteTeamDividentsMsg(key);
                            } catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e);
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            } finally {
    // 华为推送
    public void doHWPushJob() {
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                    Map<String, PushContentDetailDTO> map = PushCMQManager.getInstance().consumeHWPush(16);
                    if (map != null) {
                        Iterator<String> its = map.keySet().iterator();
                        while (its.hasNext()) {
                            String key = its.next();
                            PushContentDetailDTO dto = map.get(key);
                            try {
                                hwPushService.push(dto);
                                PushCMQManager.getInstance().deleteHWPush(key);
                            } catch (Exception e) {
                                try {
                                    LogHelper.errorDetailInfo(e);
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            } finally {
                            }
                        }
                    }
                }
            }
        });
    }
                            }
                        }
                    }
                }
        });
    }
}
fanli/src/main/java/com/yeshi/fanli/util/cache/HttpGoodsCacheManager.java
@@ -103,7 +103,7 @@
        CommonContentTypeEnum[] types = CommonContentTypeEnum.values();
        for (int p = 1; p < 3; p++) {
            for (CommonContentTypeEnum type : types) {
                List<CommonContentNav> navList = commonTemplateContentService.getNavList(type);
                List<CommonContentNav> navList = commonTemplateContentService.getNavList(type,SystemEnum.blks);
                if (navList != null && navList.size() > 0)
                    for (CommonContentNav nav : navList) {
                        commonTemplateContentService.getContentList(type, nav.getCid(), p, 50, SystemEnum.blks);
fanli/src/main/java/com/yeshi/fanli/util/mq/cmq/PushCMQManager.java
New file
@@ -0,0 +1,74 @@
package com.yeshi.fanli.util.mq.cmq;
import com.google.gson.Gson;
import com.qcloud.cmq.Message;
import com.yeshi.fanli.dto.money.UserMoneyChangeDTO;
import com.yeshi.fanli.dto.push.PushContentDetailDTO;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.mq.cmq.order.JDOrderCMQManager;
import org.yeshi.utils.CMQUtil;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PushCMQManager {
    private static String secretId = "AKIDTlpgJhLjOozvd6QI2XnpfGbgV4NQJk25";
    private static String secretKey = "xhCSUHo55oHUQ6XicFcmfIgspX0EEzWo";
    private static PushCMQManager pushCMQManager;
    private static CMQUtil cmqUtil;
    public static String PUSH_HW = "push-hw";
    static {
        cmqUtil = CMQUtil.getInstance(secretId, secretKey);
        PUSH_HW += "-" + Constant.systemCommonConfig.getProjectName();
        cmqUtil.createQueue(PUSH_HW);
    }
    public static PushCMQManager getInstance() {
        if (pushCMQManager == null)
            pushCMQManager = new PushCMQManager();
        return pushCMQManager;
    }
    /**
     * @param dto
     */
    public void addHWPush(PushContentDetailDTO dto) {
        if (dto == null)
            return;
        String json = new Gson().toJson(dto);
        cmqUtil.sendMsg(PUSH_HW, json);
    }
    /**
     * 消费队列消息
     *
     * @param count
     * @return
     */
    public Map<String, PushContentDetailDTO> consumeHWPush(int count) {
        List<Message> list = cmqUtil.recieveMsg(count, PUSH_HW);
        Map<String, PushContentDetailDTO> map = new HashMap<>();
        if (list != null)
            for (Message msg : list) {
                String result = msg.msgBody;
                PushContentDetailDTO dto = new Gson().fromJson(result, PushContentDetailDTO.class);
                map.put(msg.receiptHandle, dto);
            }
        return map;
    }
    /**
     * 删除京东队列
     *
     * @param receiptHandle
     */
    public void deleteHWPush(String receiptHandle) {
        cmqUtil.deleteMsg(PUSH_HW, receiptHandle);
    }
}
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java
@@ -179,7 +179,7 @@
        urlMap.put(13, TEHUI_URL);
    }
    public static TaoBaoSearchResult search(SearchFilter filter, boolean proxy,String specialId,String relationId) {
    public static TaoBaoSearchResult search(SearchFilter filter, boolean proxy, String specialId, String relationId) {
        if (filter.getKey().startsWith("http://") || filter.getKey().startsWith("https://")) {
            String[] sts = filter.getKey().split("\\?")[1].split("&");
            for (String st : sts) {
@@ -459,8 +459,8 @@
        return presult;
    }
    public static TaoBaoSearchResult search(SearchFilter filter,String specialId,String relationId) {
        return search(filter, false,specialId,relationId);
    public static TaoBaoSearchResult search(SearchFilter filter, String specialId, String relationId) {
        return search(filter, false, specialId, relationId);
    }
    public static TaoBaoSearchResult search2(SearchFilter filter, TaoBaoUnionConfig config) {
@@ -2243,6 +2243,7 @@
    /**
     * 从券链接中获取券ID
     *
     * @param couponLink
     * @return
     */
@@ -2253,4 +2254,16 @@
        return null;
    }
    /**
     * 获取淘宝授权链接
     * @param uid
     * @param source
     * @return
     */
    public static String getTaoBaoAuthLink(Long uid, String source) {
        return TaoBaoUtil.getTaoBaoUnionAuthUrl(TaoBaoConstant.TAOBAO_AUTH_APPKEY,
                "http://api.flqapp.com/fanli/client/v1/auth/callback/tb", uid, source);
    }
}
fanli/src/main/resource/mapping/order/CommonOrderMapper.xml
@@ -3,291 +3,301 @@
<mapper namespace="com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.order.CommonOrder">
        <id column="co_id" property="id" jdbcType="BIGINT" />
        <result column="co_order_no" property="orderNo" jdbcType="VARCHAR" />
        <result column="co_source_type" property="sourceType" jdbcType="INTEGER" />
        <result column="co_source_position" property="sourcePosition"
            jdbcType="VARCHAR" />
        <result column="co_count" property="count" jdbcType="INTEGER" />
        <result column="co_state" property="state" jdbcType="INTEGER" />
        <result column="co_state_whole_order" property="stateWholeOrder"
            jdbcType="INTEGER" />
        <result column="co_estimate" property="estimate" jdbcType="DECIMAL" />
        <result column="co_eIncome" property="eIncome" jdbcType="DECIMAL" />
        <result column="co_payment" property="payment" jdbcType="DECIMAL" />
        <result column="co_settlement" property="settlement" jdbcType="DECIMAL" />
        <result column="co_third_create_time" property="thirdCreateTime"
            jdbcType="TIMESTAMP" />
        <result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP" />
        <result column="co_order_by" property="orderBy" jdbcType="INTEGER" />
        <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR" />
        <result column="co_state_desc" property="stateDesc" jdbcType="VARCHAR" />
        <result column="co_urank" property="urank" jdbcType="INTEGER" />
        <result column="co_child_source_type" property="childSourceType"
            jdbcType="VARCHAR" />
        <association property="userInfo" column="co_uid"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="co_uid" property="id" jdbcType="BIGINT" />
        </association>
        <association property="commonOrderGoods" column="co_order_goods_id"
            javaType="com.yeshi.fanli.entity.order.CommonOrderGoods">
            <id column="co_order_goods_id" property="id" jdbcType="BIGINT" />
        </association>
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.order.CommonOrder">
        <id column="co_id" property="id" jdbcType="BIGINT"/>
        <result column="co_order_no" property="orderNo" jdbcType="VARCHAR"/>
        <result column="co_source_type" property="sourceType" jdbcType="INTEGER"/>
        <result column="co_source_position" property="sourcePosition"
                jdbcType="VARCHAR"/>
        <result column="co_count" property="count" jdbcType="INTEGER"/>
        <result column="co_state" property="state" jdbcType="INTEGER"/>
        <result column="co_state_whole_order" property="stateWholeOrder"
                jdbcType="INTEGER"/>
        <result column="co_estimate" property="estimate" jdbcType="DECIMAL"/>
        <result column="co_eIncome" property="eIncome" jdbcType="DECIMAL"/>
        <result column="co_payment" property="payment" jdbcType="DECIMAL"/>
        <result column="co_settlement" property="settlement" jdbcType="DECIMAL"/>
        <result column="co_third_create_time" property="thirdCreateTime"
                jdbcType="TIMESTAMP"/>
        <result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP"/>
        <result column="co_order_by" property="orderBy" jdbcType="INTEGER"/>
        <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR"/>
        <result column="co_state_desc" property="stateDesc" jdbcType="VARCHAR"/>
        <result column="co_urank" property="urank" jdbcType="INTEGER"/>
        <result column="co_child_source_type" property="childSourceType"
                jdbcType="VARCHAR"/>
        <association property="userInfo" column="co_uid"
                     javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="co_uid" property="id" jdbcType="BIGINT"/>
        </association>
        <association property="commonOrderGoods" column="co_order_goods_id"
                     javaType="com.yeshi.fanli.entity.order.CommonOrderGoods">
            <id column="co_order_goods_id" property="id" jdbcType="BIGINT"/>
        </association>
    </resultMap>
    <resultMap id="BaseDetailResultMap" type="com.yeshi.fanli.entity.order.CommonOrder">
        <id column="co_id" property="id" jdbcType="BIGINT" />
        <result column="co_order_no" property="orderNo" jdbcType="VARCHAR" />
        <result column="co_source_type" property="sourceType" jdbcType="INTEGER" />
        <result column="co_source_position" property="sourcePosition"
            jdbcType="VARCHAR" />
        <result column="co_count" property="count" jdbcType="INTEGER" />
        <result column="co_state" property="state" jdbcType="INTEGER" />
        <result column="co_state_whole_order" property="stateWholeOrder"
            jdbcType="INTEGER" />
        <result column="co_estimate" property="estimate" jdbcType="DECIMAL" />
        <result column="co_eIncome" property="eIncome" jdbcType="DECIMAL" />
        <result column="co_payment" property="payment" jdbcType="DECIMAL" />
        <result column="co_settlement" property="settlement" jdbcType="DECIMAL" />
        <result column="co_third_create_time" property="thirdCreateTime"
            jdbcType="TIMESTAMP" />
        <result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP" />
        <result column="co_order_by" property="orderBy" jdbcType="INTEGER" />
        <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR" />
        <result column="co_state_desc" property="stateDesc" jdbcType="VARCHAR" />
        <result column="co_urank" property="urank" jdbcType="INTEGER" />
        <result column="co_child_source_type" property="childSourceType"
            jdbcType="VARCHAR" />
        <association property="userInfo" column="co_uid"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="co_uid" property="id" jdbcType="BIGINT" />
        </association>
        <association property="commonOrderGoods"
            resultMap="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.BaseResultMap" />
    </resultMap>
    <resultMap id="ResultMap" type="com.yeshi.fanli.vo.order.CommonOrderVO">
        <id column="co_id" property="id" jdbcType="BIGINT" />
        <result column="co_order_no" property="orderNo" jdbcType="VARCHAR" />
        <result column="co_source_type" property="sourceType" jdbcType="INTEGER" />
        <result column="co_source_position" property="sourcePosition"
            jdbcType="VARCHAR" />
        <result column="co_count" property="count" jdbcType="INTEGER" />
        <result column="co_state" property="state" jdbcType="INTEGER" />
        <result column="co_state_whole_order" property="stateWholeOrder"
            jdbcType="INTEGER" />
        <result column="co_estimate" property="estimate" jdbcType="DECIMAL" />
        <result column="co_eIncome" property="eIncome" jdbcType="DECIMAL" />
        <result column="co_payment" property="payment" jdbcType="DECIMAL" />
        <result column="co_settlement" property="settlement" jdbcType="DECIMAL" />
        <result column="co_third_create_time" property="thirdCreateTime"
            jdbcType="TIMESTAMP" />
        <result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP" />
        <result column="co_order_by" property="orderBy" jdbcType="INTEGER" />
        <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="totalMoney" property="hongBao" jdbcType="DECIMAL" />
        <result column="couponMoney" property="couponMoney" jdbcType="DECIMAL" />
        <result column="hongBaoState" property="hongBaoState" jdbcType="INTEGER" />
        <result column="hongBaoType" property="hongBaoType" jdbcType="INTEGER" />
        <result column="accountTime" property="accountTime" jdbcType="TIMESTAMP" />
        <result column="preAccountTime" property="preAccountTime"
            jdbcType="TIMESTAMP" />
        <result column="totalCount" property="totalCount" jdbcType="INTEGER" />
        <result column="totalSettlement" property="totalSettlement"
            jdbcType="DECIMAL" />
        <result column="totalPayment" property="totalPayment" jdbcType="DECIMAL" />
        <result column="userId" property="userId" jdbcType="VARCHAR" />
        <result column="userName" property="userName" jdbcType="VARCHAR" />
        <result column="userPortrait" property="userPortrait" jdbcType="VARCHAR" />
        <result column="hb_id" property="hongbaoId" jdbcType="BIGINT" />
        <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR" />
        <result column="co_state_desc" property="stateDesc" jdbcType="VARCHAR" />
        <result column="co_uid" property="userId" jdbcType="VARCHAR" />
        <result column="co_urank" property="urank" jdbcType="INTEGER" />
        <result column="co_child_source_type" property="childSourceType"
            jdbcType="VARCHAR" />
        <association property="userInfo" column="co_uid"
            resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap" />
        <association property="commonOrderGoods" column="co_order_goods_id"
            resultMap="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.BaseResultMap" />
    </resultMap>
    <resultMap id="ThreeResultMap" type="com.yeshi.fanli.vo.order.CommonOrderVO">
        <id column="co_id" property="id" jdbcType="BIGINT" />
        <result column="co_order_no" property="orderNo" jdbcType="VARCHAR" />
        <result column="co_source_type" property="sourceType" jdbcType="INTEGER" />
        <result column="co_source_position" property="sourcePosition"
            jdbcType="VARCHAR" />
        <result column="co_count" property="count" jdbcType="INTEGER" />
        <result column="co_state" property="state" jdbcType="INTEGER" />
        <result column="co_state_whole_order" property="stateWholeOrder"
            jdbcType="INTEGER" />
        <result column="co_estimate" property="estimate" jdbcType="DECIMAL" />
        <result column="co_eIncome" property="eIncome" jdbcType="DECIMAL" />
        <result column="co_payment" property="payment" jdbcType="DECIMAL" />
        <result column="co_settlement" property="settlement" jdbcType="DECIMAL" />
        <result column="co_third_create_time" property="thirdCreateTime"
            jdbcType="TIMESTAMP" />
        <result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP" />
        <result column="co_order_by" property="orderBy" jdbcType="INTEGER" />
        <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="totalMoney" property="hongBao" jdbcType="DECIMAL" />
        <result column="couponMoney" property="couponMoney" jdbcType="DECIMAL" />
        <result column="hongBaoState" property="hongBaoState" jdbcType="INTEGER" />
        <result column="hongBaoType" property="hongBaoType" jdbcType="INTEGER" />
        <result column="accountTime" property="accountTime" jdbcType="TIMESTAMP" />
        <result column="preAccountTime" property="preAccountTime"
            jdbcType="TIMESTAMP" />
        <result column="totalCount" property="totalCount" jdbcType="INTEGER" />
        <result column="totalSettlement" property="totalSettlement"
            jdbcType="DECIMAL" />
        <result column="totalPayment" property="totalPayment" jdbcType="DECIMAL" />
        <result column="userId" property="userId" jdbcType="VARCHAR" />
        <result column="userName" property="userName" jdbcType="VARCHAR" />
        <result column="userPortrait" property="userPortrait" jdbcType="VARCHAR" />
        <result column="hb_id" property="hongbaoId" jdbcType="BIGINT" />
        <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR" />
        <result column="co_state_desc" property="stateDesc" jdbcType="VARCHAR" />
        <result column="co_urank" property="urank" jdbcType="INTEGER" />
        <result column="co_child_source_type" property="childSourceType"
            jdbcType="VARCHAR" />
        <association property="userInfo" column="co_uid"
            select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPrimaryKey" />
        <association property="commonOrderGoods" column="co_order_goods_id"
            select="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.selectByPrimaryKey" />
    </resultMap>
    <resultMap id="OrderCountMap" type="com.yeshi.fanli.vo.order.OrderCountVO">
        <result column="self" property="self" jdbcType="BIGINT" />
        <result column="shared" property="shared" jdbcType="BIGINT" />
        <result column="invite" property="invite" jdbcType="BIGINT" />
    </resultMap>
    <sql id="Base_Column_List">co_id,co_uid,co_order_no,co_source_type,co_source_position,co_order_goods_id,co_count,co_state,co_state_whole_order,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,co_order_by,co_create_time,co_update_time,co_trade_id,co_state_desc,co_urank,co_child_source_type
    </resultMap>
    <resultMap id="BaseDetailResultMap" type="com.yeshi.fanli.entity.order.CommonOrder">
        <id column="co_id" property="id" jdbcType="BIGINT"/>
        <result column="co_order_no" property="orderNo" jdbcType="VARCHAR"/>
        <result column="co_source_type" property="sourceType" jdbcType="INTEGER"/>
        <result column="co_source_position" property="sourcePosition"
                jdbcType="VARCHAR"/>
        <result column="co_count" property="count" jdbcType="INTEGER"/>
        <result column="co_state" property="state" jdbcType="INTEGER"/>
        <result column="co_state_whole_order" property="stateWholeOrder"
                jdbcType="INTEGER"/>
        <result column="co_estimate" property="estimate" jdbcType="DECIMAL"/>
        <result column="co_eIncome" property="eIncome" jdbcType="DECIMAL"/>
        <result column="co_payment" property="payment" jdbcType="DECIMAL"/>
        <result column="co_settlement" property="settlement" jdbcType="DECIMAL"/>
        <result column="co_third_create_time" property="thirdCreateTime"
                jdbcType="TIMESTAMP"/>
        <result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP"/>
        <result column="co_order_by" property="orderBy" jdbcType="INTEGER"/>
        <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR"/>
        <result column="co_state_desc" property="stateDesc" jdbcType="VARCHAR"/>
        <result column="co_urank" property="urank" jdbcType="INTEGER"/>
        <result column="co_child_source_type" property="childSourceType"
                jdbcType="VARCHAR"/>
        <association property="userInfo" column="co_uid"
                     javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="co_uid" property="id" jdbcType="BIGINT"/>
        </association>
        <association property="commonOrderGoods"
                     resultMap="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.BaseResultMap"/>
    </resultMap>
    <resultMap id="ResultMap" type="com.yeshi.fanli.vo.order.CommonOrderVO">
        <id column="co_id" property="id" jdbcType="BIGINT"/>
        <result column="co_order_no" property="orderNo" jdbcType="VARCHAR"/>
        <result column="co_source_type" property="sourceType" jdbcType="INTEGER"/>
        <result column="co_source_position" property="sourcePosition"
                jdbcType="VARCHAR"/>
        <result column="co_count" property="count" jdbcType="INTEGER"/>
        <result column="co_state" property="state" jdbcType="INTEGER"/>
        <result column="co_state_whole_order" property="stateWholeOrder"
                jdbcType="INTEGER"/>
        <result column="co_estimate" property="estimate" jdbcType="DECIMAL"/>
        <result column="co_eIncome" property="eIncome" jdbcType="DECIMAL"/>
        <result column="co_payment" property="payment" jdbcType="DECIMAL"/>
        <result column="co_settlement" property="settlement" jdbcType="DECIMAL"/>
        <result column="co_third_create_time" property="thirdCreateTime"
                jdbcType="TIMESTAMP"/>
        <result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP"/>
        <result column="co_order_by" property="orderBy" jdbcType="INTEGER"/>
        <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="totalMoney" property="hongBao" jdbcType="DECIMAL"/>
        <result column="couponMoney" property="couponMoney" jdbcType="DECIMAL"/>
        <result column="hongBaoState" property="hongBaoState" jdbcType="INTEGER"/>
        <result column="hongBaoType" property="hongBaoType" jdbcType="INTEGER"/>
        <result column="accountTime" property="accountTime" jdbcType="TIMESTAMP"/>
        <result column="preAccountTime" property="preAccountTime"
                jdbcType="TIMESTAMP"/>
        <result column="totalCount" property="totalCount" jdbcType="INTEGER"/>
        <result column="totalSettlement" property="totalSettlement"
                jdbcType="DECIMAL"/>
        <result column="totalPayment" property="totalPayment" jdbcType="DECIMAL"/>
        <result column="userId" property="userId" jdbcType="VARCHAR"/>
        <result column="userName" property="userName" jdbcType="VARCHAR"/>
        <result column="userPortrait" property="userPortrait" jdbcType="VARCHAR"/>
        <result column="hb_id" property="hongbaoId" jdbcType="BIGINT"/>
        <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR"/>
        <result column="co_state_desc" property="stateDesc" jdbcType="VARCHAR"/>
        <result column="co_uid" property="userId" jdbcType="VARCHAR"/>
        <result column="co_urank" property="urank" jdbcType="INTEGER"/>
        <result column="co_child_source_type" property="childSourceType"
                jdbcType="VARCHAR"/>
        <association property="userInfo" column="co_uid"
                     resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap"/>
        <association property="commonOrderGoods" column="co_order_goods_id"
                     resultMap="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.BaseResultMap"/>
    </resultMap>
    <resultMap id="ThreeResultMap" type="com.yeshi.fanli.vo.order.CommonOrderVO">
        <id column="co_id" property="id" jdbcType="BIGINT"/>
        <result column="co_order_no" property="orderNo" jdbcType="VARCHAR"/>
        <result column="co_source_type" property="sourceType" jdbcType="INTEGER"/>
        <result column="co_source_position" property="sourcePosition"
                jdbcType="VARCHAR"/>
        <result column="co_count" property="count" jdbcType="INTEGER"/>
        <result column="co_state" property="state" jdbcType="INTEGER"/>
        <result column="co_state_whole_order" property="stateWholeOrder"
                jdbcType="INTEGER"/>
        <result column="co_estimate" property="estimate" jdbcType="DECIMAL"/>
        <result column="co_eIncome" property="eIncome" jdbcType="DECIMAL"/>
        <result column="co_payment" property="payment" jdbcType="DECIMAL"/>
        <result column="co_settlement" property="settlement" jdbcType="DECIMAL"/>
        <result column="co_third_create_time" property="thirdCreateTime"
                jdbcType="TIMESTAMP"/>
        <result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP"/>
        <result column="co_order_by" property="orderBy" jdbcType="INTEGER"/>
        <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="totalMoney" property="hongBao" jdbcType="DECIMAL"/>
        <result column="couponMoney" property="couponMoney" jdbcType="DECIMAL"/>
        <result column="hongBaoState" property="hongBaoState" jdbcType="INTEGER"/>
        <result column="hongBaoType" property="hongBaoType" jdbcType="INTEGER"/>
        <result column="accountTime" property="accountTime" jdbcType="TIMESTAMP"/>
        <result column="preAccountTime" property="preAccountTime"
                jdbcType="TIMESTAMP"/>
        <result column="totalCount" property="totalCount" jdbcType="INTEGER"/>
        <result column="totalSettlement" property="totalSettlement"
                jdbcType="DECIMAL"/>
        <result column="totalPayment" property="totalPayment" jdbcType="DECIMAL"/>
        <result column="userId" property="userId" jdbcType="VARCHAR"/>
        <result column="userName" property="userName" jdbcType="VARCHAR"/>
        <result column="userPortrait" property="userPortrait" jdbcType="VARCHAR"/>
        <result column="hb_id" property="hongbaoId" jdbcType="BIGINT"/>
        <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR"/>
        <result column="co_state_desc" property="stateDesc" jdbcType="VARCHAR"/>
        <result column="co_urank" property="urank" jdbcType="INTEGER"/>
        <result column="co_child_source_type" property="childSourceType"
                jdbcType="VARCHAR"/>
        <association property="userInfo" column="co_uid"
                     select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPrimaryKey"/>
        <association property="commonOrderGoods" column="co_order_goods_id"
                     select="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.selectByPrimaryKey"/>
    </resultMap>
    <resultMap id="OrderCountMap" type="com.yeshi.fanli.vo.order.OrderCountVO">
        <result column="self" property="self" jdbcType="BIGINT"/>
        <result column="shared" property="shared" jdbcType="BIGINT"/>
        <result column="invite" property="invite" jdbcType="BIGINT"/>
    </resultMap>
    <sql id="Base_Column_List">co_id,co_uid,co_order_no,co_source_type,co_source_position,co_order_goods_id,co_count,co_state,co_state_whole_order,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,co_order_by,co_create_time,co_update_time,co_trade_id,co_state_desc,co_urank,co_child_source_type
    </sql>
    <sql id="Order_Column_List">co_id,co_uid,co_order_no,co_source_type,co_source_position,
    <sql id="Order_Column_List">co_id,co_uid,co_order_no,co_source_type,co_source_position,
        co_order_goods_id,co_count,co_state,co_state_whole_order,
        co_estimate,co_eIncome,co_payment,co_settlement, co_third_create_time,
        MAX(co_settle_time) AS co_settle_time, co_order_by, co_create_time,
        co_update_time,co_state_desc,co_urank,co_child_source_type
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_common_order where co_id = #{id,jdbcType=BIGINT}
    </select>
    <select id="countByOrderNOAndOrderType" resultType="java.lang.Integer">select
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
            parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List"/>
        from yeshi_ec_common_order where co_id = #{id,jdbcType=BIGINT}
    </select>
    <!--测试 -->
    <select id="test" resultMap="BaseResultMap"
            parameterType="java.lang.Long">
        SELECT co.`co_order_no`,co.`co_source_type`,SUM(co.`co_settlement`) as co_settlement,co.`co_uid`,co.`co_third_create_time` FROM yeshi_ec_common_order co  LEFT JOIN  yeshi_ec_threesale s ON s.`worker_id`=co.`co_uid`  LEFT JOIN yeshi_ec_user_invite_valid_record r ON r.`tvr_uid`=s.`worker_id` WHERE s.`id`>0 AND r.`tvr_id` IS NULL AND co.`co_state`=2 AND co.`co_settle_time`>'2020-07-01' AND '2020-07-27 17:00:00'> co.`co_settle_time` GROUP BY co.`co_order_no`,co.`co_source_type`
    </select>
    <select id="countByOrderNOAndOrderType" resultType="java.lang.Integer">select
        count(co_id) from yeshi_ec_common_order where co_order_no=#{orderNO}
        and co_source_type=#{orderType}
    </select>
    <select id="selectByOrderNoAndOrderTypeAndOrderBy" resultMap="BaseResultMap">select
    <select id="selectByOrderNoAndOrderTypeAndOrderBy" resultMap="BaseResultMap">select
        * from yeshi_ec_common_order where co_order_no=#{orderNo} and
        co_source_type=#{orderType} and co_order_by=#{orderBy}
    </select>
    <select id="countByUidAndOrderStateWithOrderBalanceTime"
        resultType="java.lang.Long">SELECT COUNT(*) FROM yeshi_ec_common_order co WHERE
    <select id="countByUidAndOrderStateWithOrderBalanceTime"
            resultType="java.lang.Long">SELECT COUNT(*) FROM yeshi_ec_common_order co WHERE
        co.`co_state`=#{state} and co.`co_uid`=#{uid} and co.`co_settle_time`
        is not null and co.`co_settle_time`&gt;=#{minDate} and
        #{maxDate}&gt;co.`co_settle_time`</select>
    <select id="listBySourceTypeAndOrderNo" resultMap="BaseResultMap">SELECT * FROM
    <select id="listBySourceTypeAndOrderNo" resultMap="BaseResultMap">SELECT * FROM
        yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType} and
        co_order_no=#{orderNo}
    </select>
    <select id="selectBySourceTypeAndTradeId" resultMap="BaseResultMap">SELECT *
    <select id="selectBySourceTypeAndTradeId" resultMap="BaseResultMap">SELECT *
        FROM yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType}
        and co_trade_id=#{tradeId} limit 1
    </select>
    <select id="listBySourceTypeAndTradeId" resultMap="BaseResultMap">SELECT * FROM
    <select id="listBySourceTypeAndTradeId" resultMap="BaseResultMap">SELECT * FROM
        yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType} and
        co_trade_id=#{tradeId}
    </select>
    <select id="listBySourceTypeAndTradeIdList" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_common_order co WHERE
        co.co_source_type=#{sourceType}
        <if test="tradeIdList!=null">
            <foreach collection="tradeIdList" item="tradeId" open=" and ("
                close=")" separator=" or ">co.co_trade_id=#{tradeId}</foreach>
        </if>
    </select>
    <select id="listBySourceTypeAndStateAndThirdCrateTime"
        resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_common_order co WHERE
        co.co_source_type=#{sourceType}
        <if test="state!=null">and co_state=#{state}</if>
        <if test="minTime!=null">and
            UNIX_TIMESTAMP(co_third_create_time)*1000&gt;=#{minTime}</if>
        <if test="maxTime!=null">and #{maxTime}&gt;
            UNIX_TIMESTAMP(co_third_create_time)*1000
        </if>
        order by co_id desc limit #{start},#{count}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
    <select id="listBySourceTypeAndTradeIdList" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_common_order co WHERE
        co.co_source_type=#{sourceType}
        <if test="tradeIdList!=null">
            <foreach collection="tradeIdList" item="tradeId" open=" and ("
                     close=")" separator=" or ">co.co_trade_id=#{tradeId}
            </foreach>
        </if>
    </select>
    <select id="listBySourceTypeAndStateAndThirdCrateTime"
            resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_common_order co WHERE
        co.co_source_type=#{sourceType}
        <if test="state!=null">and co_state=#{state}</if>
        <if test="minTime!=null">and
            UNIX_TIMESTAMP(co_third_create_time)*1000&gt;=#{minTime}
        </if>
        <if test="maxTime!=null">and #{maxTime}&gt;
            UNIX_TIMESTAMP(co_third_create_time)*1000
        </if>
        order by co_id desc limit #{start},#{count}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_common_order where co_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.order.CommonOrder"
        useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_common_order
    <insert id="insert" parameterType="com.yeshi.fanli.entity.order.CommonOrder"
            useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_common_order
        (co_id,co_uid,co_order_no,co_source_type,co_source_position,co_order_goods_id,co_count,co_state,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,co_create_time,co_update_time,co_state_whole_order,co_order_by,co_trade_id,co_state_desc,co_urank,co_child_source_type)
        values
        (#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{orderNo,jdbcType=VARCHAR},#{sourceType,jdbcType=INTEGER},#{sourcePosition,jdbcType=VARCHAR},#{commonOrderGoods.id,jdbcType=BIGINT},#{count,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{estimate,jdbcType=DECIMAL},#{eIncome,jdbcType=DECIMAL},#{payment,jdbcType=DECIMAL},#{settlement,jdbcType=DECIMAL},#{thirdCreateTime,jdbcType=TIMESTAMP},#{settleTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{stateWholeOrder,jdbcType=INTEGER},#{orderBy,jdbcType=INTEGER},#{tradeId,jdbcType=VARCHAR},#{stateDesc,jdbcType=VARCHAR},#{urank,jdbcType=INTEGER},#{childSourceType,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.order.CommonOrder"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_common_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">co_id,</if>
            <if test="userInfo != null">co_uid,</if>
            <if test="orderNo != null">co_order_no,</if>
            <if test="sourceType != null">co_source_type,</if>
            <if test="sourcePosition != null">co_source_position,</if>
            <if test="commonOrderGoods != null">co_order_goods_id,</if>
            <if test="count != null">co_count,</if>
            <if test="state != null">co_state,</if>
            <if test="stateWholeOrder != null">co_state_whole_order,</if>
            <if test="estimate != null">co_estimate,</if>
            <if test="eIncome != null">co_eIncome,</if>
            <if test="payment != null">co_payment,</if>
            <if test="settlement != null">co_settlement,</if>
            <if test="thirdCreateTime != null">co_third_create_time,</if>
            <if test="settleTime != null">co_settle_time,</if>
            <if test="orderBy != null">co_order_by,</if>
            <if test="createTime != null">co_create_time,</if>
            <if test="updateTime != null">co_update_time,</if>
            <if test="tradeId != null">co_trade_id,</if>
            <if test="stateDesc != null">co_state_desc,</if>
            <if test="urank != null">co_urank,</if>
            <if test="childSourceType != null">co_child_source_type,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="userInfo != null">#{userInfo.id,jdbcType=BIGINT},</if>
            <if test="orderNo != null">#{orderNo,jdbcType=VARCHAR},</if>
            <if test="sourceType != null">#{sourceType,jdbcType=INTEGER},</if>
            <if test="sourcePosition != null">#{sourcePosition,jdbcType=VARCHAR},</if>
            <if test="commonOrderGoods != null">#{commonOrderGoods.id,jdbcType=BIGINT},</if>
            <if test="count != null">#{count,jdbcType=INTEGER},</if>
            <if test="state != null">#{state,jdbcType=INTEGER},</if>
            <if test="stateWholeOrder != null">#{stateWholeOrder,jdbcType=INTEGER},</if>
            <if test="estimate != null">#{estimate,jdbcType=DECIMAL},</if>
            <if test="eIncome != null">#{eIncome,jdbcType=DECIMAL},</if>
            <if test="payment != null">#{payment,jdbcType=DECIMAL},</if>
            <if test="settlement != null">#{settlement,jdbcType=DECIMAL},</if>
            <if test="thirdCreateTime != null">#{thirdCreateTime,jdbcType=TIMESTAMP},</if>
            <if test="settleTime != null">#{settleTime,jdbcType=TIMESTAMP},</if>
            <if test="orderBy != null">#{orderBy,jdbcType=INTEGER},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="tradeId != null">#{tradeId,jdbcType=VARCHAR},</if>
            <if test="stateDesc != null">#{stateDesc,jdbcType=VARCHAR},</if>
            <if test="urank != null">#{urank,jdbcType=INTEGER},</if>
            <if test="childSourceType != null">#{childSourceType,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.order.CommonOrder">update
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.order.CommonOrder"
            useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_common_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">co_id,</if>
            <if test="userInfo != null">co_uid,</if>
            <if test="orderNo != null">co_order_no,</if>
            <if test="sourceType != null">co_source_type,</if>
            <if test="sourcePosition != null">co_source_position,</if>
            <if test="commonOrderGoods != null">co_order_goods_id,</if>
            <if test="count != null">co_count,</if>
            <if test="state != null">co_state,</if>
            <if test="stateWholeOrder != null">co_state_whole_order,</if>
            <if test="estimate != null">co_estimate,</if>
            <if test="eIncome != null">co_eIncome,</if>
            <if test="payment != null">co_payment,</if>
            <if test="settlement != null">co_settlement,</if>
            <if test="thirdCreateTime != null">co_third_create_time,</if>
            <if test="settleTime != null">co_settle_time,</if>
            <if test="orderBy != null">co_order_by,</if>
            <if test="createTime != null">co_create_time,</if>
            <if test="updateTime != null">co_update_time,</if>
            <if test="tradeId != null">co_trade_id,</if>
            <if test="stateDesc != null">co_state_desc,</if>
            <if test="urank != null">co_urank,</if>
            <if test="childSourceType != null">co_child_source_type,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="userInfo != null">#{userInfo.id,jdbcType=BIGINT},</if>
            <if test="orderNo != null">#{orderNo,jdbcType=VARCHAR},</if>
            <if test="sourceType != null">#{sourceType,jdbcType=INTEGER},</if>
            <if test="sourcePosition != null">#{sourcePosition,jdbcType=VARCHAR},</if>
            <if test="commonOrderGoods != null">#{commonOrderGoods.id,jdbcType=BIGINT},</if>
            <if test="count != null">#{count,jdbcType=INTEGER},</if>
            <if test="state != null">#{state,jdbcType=INTEGER},</if>
            <if test="stateWholeOrder != null">#{stateWholeOrder,jdbcType=INTEGER},</if>
            <if test="estimate != null">#{estimate,jdbcType=DECIMAL},</if>
            <if test="eIncome != null">#{eIncome,jdbcType=DECIMAL},</if>
            <if test="payment != null">#{payment,jdbcType=DECIMAL},</if>
            <if test="settlement != null">#{settlement,jdbcType=DECIMAL},</if>
            <if test="thirdCreateTime != null">#{thirdCreateTime,jdbcType=TIMESTAMP},</if>
            <if test="settleTime != null">#{settleTime,jdbcType=TIMESTAMP},</if>
            <if test="orderBy != null">#{orderBy,jdbcType=INTEGER},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="tradeId != null">#{tradeId,jdbcType=VARCHAR},</if>
            <if test="stateDesc != null">#{stateDesc,jdbcType=VARCHAR},</if>
            <if test="urank != null">#{urank,jdbcType=INTEGER},</if>
            <if test="childSourceType != null">#{childSourceType,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.order.CommonOrder">update
        yeshi_ec_common_order set co_uid =
        #{userInfo.id,jdbcType=BIGINT},co_order_no =
        #{orderNo,jdbcType=VARCHAR},co_source_type =
@@ -311,543 +321,546 @@
        ,co_child_source_type =#{childSourceType,jdbcType=VARCHAR} where co_id
        = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.order.CommonOrder">
        update yeshi_ec_common_order
        <set>
            <if test="userInfo != null">co_uid=#{userInfo.id,jdbcType=BIGINT},</if>
            <if test="orderNo != null">co_order_no=#{orderNo,jdbcType=VARCHAR},</if>
            <if test="sourceType != null">co_source_type=#{sourceType,jdbcType=INTEGER},</if>
            <if test="sourcePosition != null">co_source_position=#{sourcePosition,jdbcType=VARCHAR},
            </if>
            <if test="commonOrderGoods != null">co_order_goods_id=#{commonOrderGoods.id,jdbcType=BIGINT},
            </if>
            <if test="count != null">co_count=#{count,jdbcType=INTEGER},</if>
            <if test="state != null">co_state=#{state,jdbcType=INTEGER},</if>
            <if test="stateWholeOrder != null">co_state_whole_order=#{stateWholeOrder,jdbcType=INTEGER},
            </if>
            <if test="estimate != null">co_estimate=#{estimate,jdbcType=DECIMAL},</if>
            <if test="eIncome != null">co_eIncome=#{eIncome,jdbcType=DECIMAL},</if>
            <if test="payment != null">co_payment=#{payment,jdbcType=DECIMAL},</if>
            <if test="settlement != null">co_settlement=#{settlement,jdbcType=DECIMAL},</if>
            <if test="thirdCreateTime != null">co_third_create_time=#{thirdCreateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="settleTime != null">co_settle_time=#{settleTime,jdbcType=TIMESTAMP},</if>
            <if test="orderBy != null">co_order_by=#{orderBy,jdbcType=INTEGER},</if>
            <if test="createTime != null">co_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">co_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="tradeId !=null">co_trade_id =#{tradeId,jdbcType=VARCHAR},</if>
            <if test="stateDesc !=null">co_state_desc =#{stateDesc,jdbcType=VARCHAR},</if>
            <if test="urank !=null">co_urank =#{urank,jdbcType=INTEGER},</if>
            <if test="childSourceType !=null">co_child_source_type=#{childSourceType,jdbcType=VARCHAR},
            </if>
        </set>
        where co_id = #{id,jdbcType=BIGINT}
    </update>
    <sql id="SELECT_PARAM_ORDER_STATE">
        <if test="orderState != null and orderState ==  1">
            <!-- 有效订单: 整个订单有效 -->
            AND <![CDATA[co.`co_state` <> 3]]>
            AND (co.co_state_whole_order = 1 or co.co_state_whole_order = 2)
        </if>
        <if test="orderState != null and orderState ==  2">
            AND co.co_state = 3
            <!-- 维权订单 -->
        </if>
        <if test="orderState != null and orderState ==  3">
            <!-- 整个订单失效 -->
            AND co.co_state_whole_order = 3
        </if>
        <if test="orderState != null and orderState ==  4">
            <!-- 已收货订单 -->
            AND co.co_state = 2
        </if>
    </sql>
    <sql id="SELECT_PARAM_ORDER_CREATE_TIME">
        <if test="startTime != null and startTime != '' ">AND <![CDATA[co.co_third_create_time >= #{startTime}]]>
        </if>
        <if test="endTime != null and endTime != '' ">AND <![CDATA[co.co_third_create_time <= #{endTime}]]>
        </if>
        <if test="day == 1">
            <!-- 今天 -->
            AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW())
        </if>
        <if test="day == 2">
            <!-- 昨天 -->
            AND TO_DAYS(NOW()) - TO_DAYS(co.`co_third_create_time`) = 1
        </if>
        <if test="day == 3 or day == 10">
            <!-- 本月 -->
            AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day == 4">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),
            DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1
        </if>
        <if test="day == 6">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),
            DATE_FORMAT(co.`co_third_create_time`, '%Y%m')) = 1
        </if>
        <if test="day == 11">
            <!-- 近3个月产生 -->
            AND co.`co_third_create_time` BETWEEN DATE_SUB(NOW(),INTERVAL 3
            MONTH) AND NOW()
        </if>
        <if test="day == 12">
            <!-- 近半年产生 -->
            AND co.`co_third_create_time` BETWEEN DATE_SUB(NOW(),INTERVAL 6
            MONTH) AND NOW()
        </if>
    </sql>
    <sql id="SELECT_PARAM_HONGBAO_TYPE">
        <if test="type != null and type == 1">
            <!-- 自购订单 -->
            AND (v2.hb_type =1 or v2.hb_type =2)
        </if>
        <if test="type != null and type == 2">
            <!-- 分享订单 -->
            AND v2.`hb_type` = 20
        </if>
        <if test="type != null and type == 3">
            <!-- 邀请订单 -->
            AND (v2.`hb_type` = 5 OR v2.`hb_type` = 6 OR v2.`hb_type` = 7 OR
            v2.`hb_type` = 21 OR v2.`hb_type` = 22)
        </if>
    </sql>
    <sql id="SELECT_PARAM_HONGBAO_STATE">
        <if test="state != null and state == 1">
            <!-- 未到账 -->
            AND (hb.hb_state = 1 or hb.hb_state = 2)
        </if>
        <if test="state != null and state == 2">
            <!-- 已到账 -->
            AND hb.hb_state = 3
        </if>
        <if test="state != null and state == 3">
            <!-- 红包已失效、整个订单失效 -->
            AND hb.hb_state =4 AND co.co_state_whole_order = 3
        </if>
    </sql>
    <sql id="Hongbao_Column_List">hb_id,hb_uid,hb_urank,hb_pid,hb_type,hb_state,hb_pre_get_time,hb_get_time,hb_version,
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.order.CommonOrder">
        update yeshi_ec_common_order
        <set>
            <if test="userInfo != null">co_uid=#{userInfo.id,jdbcType=BIGINT},</if>
            <if test="orderNo != null">co_order_no=#{orderNo,jdbcType=VARCHAR},</if>
            <if test="sourceType != null">co_source_type=#{sourceType,jdbcType=INTEGER},</if>
            <if test="sourcePosition != null">co_source_position=#{sourcePosition,jdbcType=VARCHAR},
            </if>
            <if test="commonOrderGoods != null">co_order_goods_id=#{commonOrderGoods.id,jdbcType=BIGINT},
            </if>
            <if test="count != null">co_count=#{count,jdbcType=INTEGER},</if>
            <if test="state != null">co_state=#{state,jdbcType=INTEGER},</if>
            <if test="stateWholeOrder != null">co_state_whole_order=#{stateWholeOrder,jdbcType=INTEGER},
            </if>
            <if test="estimate != null">co_estimate=#{estimate,jdbcType=DECIMAL},</if>
            <if test="eIncome != null">co_eIncome=#{eIncome,jdbcType=DECIMAL},</if>
            <if test="payment != null">co_payment=#{payment,jdbcType=DECIMAL},</if>
            <if test="settlement != null">co_settlement=#{settlement,jdbcType=DECIMAL},</if>
            <if test="thirdCreateTime != null">co_third_create_time=#{thirdCreateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="settleTime != null">co_settle_time=#{settleTime,jdbcType=TIMESTAMP},</if>
            <if test="orderBy != null">co_order_by=#{orderBy,jdbcType=INTEGER},</if>
            <if test="createTime != null">co_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">co_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="tradeId !=null">co_trade_id =#{tradeId,jdbcType=VARCHAR},</if>
            <if test="stateDesc !=null">co_state_desc =#{stateDesc,jdbcType=VARCHAR},</if>
            <if test="urank !=null">co_urank =#{urank,jdbcType=INTEGER},</if>
            <if test="childSourceType !=null">co_child_source_type=#{childSourceType,jdbcType=VARCHAR},
            </if>
        </set>
        where co_id = #{id,jdbcType=BIGINT}
    </update>
    <sql id="SELECT_PARAM_ORDER_STATE">
        <if test="orderState != null and orderState ==  1">
            <!-- 有效订单: 整个订单有效 -->
            AND <![CDATA[co.`co_state` <> 3]]>
            AND (co.co_state_whole_order = 1 or co.co_state_whole_order = 2)
        </if>
        <if test="orderState != null and orderState ==  2">
            AND co.co_state = 3
            <!-- 维权订单 -->
        </if>
        <if test="orderState != null and orderState ==  3">
            <!-- 整个订单失效 -->
            AND co.co_state_whole_order = 3
        </if>
        <if test="orderState != null and orderState ==  4">
            <!-- 已收货订单 -->
            AND co.co_state = 2
        </if>
    </sql>
    <sql id="SELECT_PARAM_ORDER_CREATE_TIME">
        <if test="startTime != null and startTime != '' ">AND <![CDATA[co.co_third_create_time >= #{startTime}]]>
        </if>
        <if test="endTime != null and endTime != '' ">AND <![CDATA[co.co_third_create_time <= #{endTime}]]>
        </if>
        <if test="day == 1">
            <!-- 今天 -->
            AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW())
        </if>
        <if test="day == 2">
            <!-- 昨天 -->
            AND TO_DAYS(NOW()) - TO_DAYS(co.`co_third_create_time`) = 1
        </if>
        <if test="day == 3 or day == 10">
            <!-- 本月 -->
            AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day == 4">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),
            DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1
        </if>
        <if test="day == 6">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),
            DATE_FORMAT(co.`co_third_create_time`, '%Y%m')) = 1
        </if>
        <if test="day == 11">
            <!-- 近3个月产生 -->
            AND co.`co_third_create_time` BETWEEN DATE_SUB(NOW(),INTERVAL 3
            MONTH) AND NOW()
        </if>
        <if test="day == 12">
            <!-- 近半年产生 -->
            AND co.`co_third_create_time` BETWEEN DATE_SUB(NOW(),INTERVAL 6
            MONTH) AND NOW()
        </if>
    </sql>
    <sql id="SELECT_PARAM_HONGBAO_TYPE">
        <if test="type != null and type == 1">
            <!-- 自购订单 -->
            AND (v2.hb_type =1 or v2.hb_type =2)
        </if>
        <if test="type != null and type == 2">
            <!-- 分享订单 -->
            AND v2.`hb_type` = 20
        </if>
        <if test="type != null and type == 3">
            <!-- 邀请订单 -->
            AND (v2.`hb_type` = 5 OR v2.`hb_type` = 6 OR v2.`hb_type` = 7 OR
            v2.`hb_type` = 21 OR v2.`hb_type` = 22)
        </if>
    </sql>
    <sql id="SELECT_PARAM_HONGBAO_STATE">
        <if test="state != null and state == 1">
            <!-- 未到账 -->
            AND (hb.hb_state = 1 or hb.hb_state = 2)
        </if>
        <if test="state != null and state == 2">
            <!-- 已到账 -->
            AND hb.hb_state = 3
        </if>
        <if test="state != null and state == 3">
            <!-- 红包已失效、整个订单失效 -->
            AND hb.hb_state =4 AND co.co_state_whole_order = 3
        </if>
    </sql>
    <sql id="Hongbao_Column_List">hb_id,hb_uid,hb_urank,hb_pid,hb_type,hb_state,hb_pre_get_time,hb_get_time,hb_version,
        IF(v2.`hb_state` = 4, 0, v2.hb_money)AS hb_money
    </sql>
    <select id="listUserOrder" resultMap="ResultMap">
        <!-- 查询用户订单 -->
        SELECT COALESCE(SUM(hb.`hb_money`),0)AS totalMoney, hb.hb_state AS
        hongBaoState, hb.`hb_type` AS hongBaoType, MAX(hb.`hb_get_time`) AS
        accountTime, MAX(hb.`hb_pre_get_time`) AS preAccountTime,
        <include refid="Order_Column_List" />
        FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        <include refid="Hongbao_Column_List" />
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        <if test="type == 2 and day == 5">
            <!-- 本月月将要到账分享订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="type == 3 and day == 5">
            <!-- 本月将要到账邀请订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <!-- 红包类型 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
        <!-- 订单状态 -->
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
        <!-- 订单时间 -->
        <include refid="SELECT_PARAM_HONGBAO_STATE" />
        <!-- 订单号查询 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <!-- 订单来源 -->
        <if test="listSource != null and listSource.size() &gt; 0">
            <foreach collection="listSource" item="item" open="AND ("
                close=")" separator="or">co.co_source_type = #{item}</foreach>
        </if>
        <![CDATA[AND co.co_source_type <> 4 AND co.co_source_type <> 5]]>
        GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY
        co.co_third_create_time DESC LIMIT ${start},${count}
    </select>
    <select id="countUserOrder" resultType="java.lang.Long">
        <!-- 统计用户订单数量 -->
        SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.ho_id FROM
        yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        <include refid="Hongbao_Column_List" />
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        <!-- 红包类型 -->
        <if test="type == 2 and day == 5">
            <!-- 本月月将要到账分享订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="type == 3 and day == 5">
            <!-- 本月将要到账邀请订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
        <!-- 订单状态 -->
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
        <!-- 订单时间 -->
        <include refid="SELECT_PARAM_HONGBAO_STATE" />
        <!-- 订单号查询 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <!-- 订单来源 -->
        <if test="listSource != null and listSource.size() &gt; 0">
            <foreach collection="listSource" item="item" open="AND ("
                close=")" separator="or">co.co_source_type = #{item}</foreach>
        </if>
        <![CDATA[AND co.co_source_type <> 4 AND co.co_source_type <> 5]]>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <select id="listOrderGoodsInfo" resultMap="ResultMap"
        parameterType="java.util.List">
        <!-- 查询用户订单商品信息 -->
        SELECT COALESCE(SUM(tc.`co_payment`),0)AS
        totalPayment,COALESCE(SUM(tc.`co_settlement`),0)AS totalSettlement,
        COALESCE(SUM(tc.`co_count`),0)AS
        totalCount,tc.`co_source_type`,tc.`co_order_no`,tg.*,tc.co_id FROM
        yeshi_ec_common_order_goods tg LEFT JOIN yeshi_ec_common_order tc ON
        tc.`co_order_goods_id` = tg.`cog_id` WHERE
        <foreach collection="list" item="item" separator=" OR ">(tc.`co_source_type`
            = #{item.sourceType,jdbcType=INTEGER} AND tc.`co_order_no` =
            #{item.orderNo,jdbcType=VARCHAR})
        </foreach>
        GROUP BY tc.`co_order_no`,tc.`co_order_goods_id`
    </select>
    <select id="countHistoryOrder" resultType="java.util.HashMap">
        <!-- 统计历史订单数量 -->
        SELECT SUM(A.self)AS totalSelf,SUM(A.shared)AS
        totalShared,SUM(A.invite)AS totalInvite FROM (
        <!-- 返利订单 -->
        SELECT IFNULL(COUNT(ho_id),0) AS self,0 AS shared,0 AS invite FROM
        (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT *
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= ${uid} AND
        (v2.`hb_type` = 1 OR v2.`hb_type` = 2) ) hb ON
        hb.hb_id=ho.`ho_hongbao_id`
        <!-- 自购订单 -->
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL and hb.hb_state!=4
        <if test="day != null and day == 1">
            <!-- 今天 -->
            AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW())
        </if>
        <if test="day != null and day == 2">
            <!-- 昨天 -->
            AND TO_DAYS(NOW()) - TO_DAYS(co.co_third_create_time) = 1
        </if>
        <if test="day != null and day == 3">
            <!-- 本月 -->
            AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day != null and day == 4">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),
            DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)YX UNION ALL
        <!-- 分享订单 -->
        SELECT 0 AS self,IFNULL(COUNT(ho_id),0) AS shared,0 AS invite FROM
        (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT *
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= ${uid} AND v2.`hb_type`
        = 20 ) hb ON hb.hb_id=ho.`ho_hongbao_id`
        <!-- 分享订单 -->
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL and hb.hb_state!=4
        <if test="day != null and day == 1">
            <!-- 今天 -->
            AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW())
        </if>
        <if test="day != null and day == 2">
            <!-- 昨天 -->
            AND TO_DAYS(NOW()) - TO_DAYS(co.`co_third_create_time`) = 1
        </if>
        <if test="day != null and day == 3">
            <!-- 本月 -->
            AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day != null and day == 4">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),
            DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)WQ UNION ALL
        <!-- 邀请订单 -->
        SELECT 0 AS self,0 AS shared,IFNULL(COUNT(ho_id),0) AS invite FROM
        (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT *
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= ${uid} AND
        (v2.`hb_type` = 5 OR v2.`hb_type` = 6 OR v2.`hb_type` = 7 OR
        v2.`hb_type` = 21 OR v2.`hb_type` = 22 ) ) hbp ON
        hbp.hb_pid=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON
        co.`co_id`=ho.`ho_order_id` WHERE hbp.hb_id IS NOT NULL and
        hbp.hb_state!=4
        <if test="day != null and day == 1">
            <!-- 今天 -->
            AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW())
        </if>
        <if test="day != null and day == 2">
            <!-- 昨天 -->
            AND TO_DAYS(NOW()) - TO_DAYS(co.`co_third_create_time`) = 1
        </if>
        <if test="day != null and day == 3">
            <!-- 本月 -->
            AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day != null and day == 4">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),
            DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)SX )A
    </select>
    <sql id="OrderCountQuery">WHERE
        co.`co_state_whole_order`<![CDATA[<>]]>3
        <if test="day == 1">
            <!-- 今天 -->
            AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW())
        </if>
        <if test="day == 2">
            <!-- 昨天 -->
            AND TO_DAYS(NOW()) - TO_DAYS(co.`co_third_create_time`) = 1
        </if>
        <if test="day == 3">
            <!-- 本月 -->
            AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day == 4">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(),
            '%Y%m'),DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1
        </if>
        <!-- 订单来源 -->
        <if test="listSource != null and listSource.size() &gt; 0">
            <foreach collection="listSource" item="item" open="AND ("
                close=")" separator="or">co.co_source_type = #{item}</foreach>
        </if>
    </sql>
    <select id="getOrderCount" resultMap="OrderCountMap">
        SELECT sum(self) as self,sum(shared) as shared,sum(invite) as invite
        from ( SELECT IFNULL(COUNT(co_order_no),0)AS self,0 AS shared,0 AS
        invite FROM (SELECT co.`co_order_no` FROM (SELECT * FROM
        yeshi_ec_hongbao_v2 v WHERE v.`hb_uid`= ${uid} AND v.`hb_type` = 1)v2
        LEFT JOIN yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id` =
        IF(v2.hb_pid IS NULL,v2.hb_id,v2.hb_pid) LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id` = ho.`ho_order_id`
        <include refid="OrderCountQuery" />
        GROUP BY co.`co_order_no`,co.`co_source_type`)A UNION ALL SELECT 0 AS
        self,IFNULL(COUNT(co_order_no),0)AS shared,0 AS invite FROM (SELECT
        co.`co_order_no` FROM (SELECT * FROM yeshi_ec_hongbao_v2 v WHERE
        v.`hb_uid`= ${uid} AND v.`hb_type` = 20)v2 LEFT JOIN
        yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id` = IF(v2.hb_pid IS
        NULL,v2.hb_id,v2.hb_pid) LEFT JOIN yeshi_ec_common_order co ON
        co.`co_id` = ho.`ho_order_id`
        <include refid="OrderCountQuery" />
        GROUP BY co.`co_order_no`,co.`co_source_type`)A UNION ALL SELECT 0 AS
        self,0 AS shared,IFNULL(COUNT(co_order_no),0)AS invite FROM (SELECT
        co.`co_order_no` FROM (SELECT * FROM yeshi_ec_hongbao_v2 v WHERE
        v.`hb_uid`= ${uid} AND (v.`hb_type` = 5 OR v.`hb_type` = 6 OR
        v.`hb_type` = 7 OR v.`hb_type` = 21 OR v.`hb_type` = 22))v2 LEFT JOIN
        yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id` = IF(v2.hb_pid IS
        NULL,v2.hb_id,v2.hb_pid) LEFT JOIN yeshi_ec_common_order co ON
        co.`co_id` = ho.`ho_order_id`
        <include refid="OrderCountQuery" />
        GROUP BY co.`co_order_no`,co.`co_source_type`)A )B
    </select>
    <select id="countUserOrderToApp" resultType="Long">
        <!-- 有效订单 -->
        SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.`ho_id` FROM
        yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT * FROM
        yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid}
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        <if test="state != null and state == 1">
            <!-- 未到账 -->
            AND (v2.hb_state = 1 or v2.hb_state = 2)
        </if>
        <if test="state != null and state == 2">
            <!-- 已到账 -->
            AND v2.hb_state = 3
        </if>
        <if test="state != null and state == 3">
            <!-- 红包已失效 -->
            AND v2.hb_state =4
        </if>
        ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL<![CDATA[AND co.`co_state` <> 3]]>
        <if test="stateOrder == 1">
            <!-- 有效订单 -->
            AND (co.`co_state_whole_order` =1 OR co.`co_state_whole_order` = 2)
        </if>
        <if test="stateOrder == 2">
            <!-- 维权订单 -->
            AND co.`co_state` = 3
        </if>
        <if test="stateOrder == 3">
            <!-- 失效订单 -->
            AND co.`co_state_whole_order` = 3
        </if>
        <!-- 订单时间 -->
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <!-- <select id="countByUidAndOrderState" resultType="java.util.HashMap">
        SELECT SUM(A.valid)AS totalValid, SUM(A.proces)AS totalProces,SUM(A.Invalid)AS
        totalInvite FROM ( 有效订单 SELECT IFNULL(COUNT(ho_id),0) AS valid,0 AS proces,0
        AS Invalid FROM (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN
        ( SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid} <include
        refid="SELECT_PARAM_HONGBAO_TYPE" /> ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id
        IS NOT NULL <![CDATA[AND co.`co_state` <> 3]]> AND (co.`co_state_whole_order`
        =1 OR co.`co_state_whole_order` = 2) <include refid="SELECT_PARAM_ORDER_CREATE_TIME"
        /> 订单来源 <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)YX UNION ALL 维权订单 SELECT 0
        AS valid,IFNULL(COUNT(ho_id),0) AS proces,0 AS Invalid FROM (SELECT ho.`ho_id`
        FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT * FROM yeshi_ec_hongbao_v2
        v2 WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT
        JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id
        IS NOT NULL AND co.`co_state` = 3 <include refid="SELECT_PARAM_ORDER_CREATE_TIME"
        /> 订单来源 <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)WQ UNION ALL 失效订单 SELECT 0
        AS valid,0 AS proces,IFNULL(COUNT(ho_id),0) AS Invalid FROM (SELECT ho.`ho_id`
        FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT * FROM yeshi_ec_hongbao_v2
        v2 WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT
        JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id
        IS NOT NULL AND co.`co_state_whole_order` = 3 <include refid="SELECT_PARAM_ORDER_CREATE_TIME"
        /> 订单来源 <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)SX )A </select> -->
    <select id="countBonusOrderNumber" resultType="java.lang.Long">
        <!-- 奖金统计:订单数量 -->
        SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.`ho_id` FROM
        yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT * FROM
        yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid}
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <select id="countBonusOrderMoney" resultType="java.math.BigDecimal">
        <!-- 奖金统计:订单总返利金额 去掉已失效 -->
        SELECT COALESCE(SUM(hb.`hb_money`),0)AS totalmoney FROM
        yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT
        <include refid="Hongbao_Column_List" />
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid}
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        AND (v2.hb_state = 1 or v2.hb_state = 2 or v2.hb_state = 3) ) hb ON
        IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id
        IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
        <if test="day != null and day == 4">
            AND co.`co_state` = 2
            <!-- 上月 :统计已收货 -->
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
    </select>
    <select id="countBonusOrderMoneyAndNumber" resultType="java.util.HashMap">
        SELECT COUNT(*) AS totalNum, CAST(SUM(moneys) AS DECIMAL(19,2)) AS
        totalmoney FROM (SELECT CAST(SUM(hb.`hb_money`) AS DECIMAL(19,2))AS
        moneys FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT
        <include refid="Hongbao_Column_List" />
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid}
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        AND (v2.hb_state = 1 or v2.hb_state = 2 or v2.hb_state = 3) ) hb ON
        IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id
        IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
        <if test="day != null and day == 4">AND co.`co_state` = 2</if>
        <!-- 上月 :统计已收货 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <sql id="SELECT_HONGBAO_STATE">
        <if test="state != null and state == 1">
            <!-- 未到账 -->
            AND (v2.hb_state = 1 or v2.hb_state = 2)
        </if>
        <if test="state != null and state == 2">
            <!-- 已到账 -->
            AND v2.hb_state = 3
        </if>
        <if test="state != null and state == 3">
            <!-- 红包已失效 -->
            AND v2.hb_state =4
        </if>
    </sql>
    <select id="listQueryByUid" resultMap="ResultMap">
        <!-- 查询用户订单 -->
        SELECT hb.`hb_money` AS totalMoney, hb.hb_state AS hongBaoState,
        hb.`hb_type` AS hongBaoType, hb.`hb_get_time` AS accountTime,
        hb.`hb_pre_get_time` AS preAccountTime, co.*,cog.* FROM
        yeshi_ec_hongbao_order ho LEFT JOIN (SELECT * FROM yeshi_ec_hongbao_v2
        v2 WHERE v2.`hb_uid`= #{uid}
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        <!-- 红包类型 -->
        <include refid="SELECT_HONGBAO_STATE" />
        <!-- 红包状态 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` LEFT
        JOIN yeshi_ec_common_order_goods cog ON cog.`cog_id`=
        co.`co_order_goods_id` WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
        <!-- 订单状态 -->
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
        <!-- 订单时间 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <if test="payment != null">AND
            co.co_payment <![CDATA[<]]>
            #{payment}
        </if>
        ORDER BY co.co_third_create_time DESC LIMIT ${start},${count}
    </select>
    <select id="countQueryByUid" resultType="java.lang.Long">
        <!-- 统计用户订单数量 -->
        SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.ho_id FROM
        yeshi_ec_hongbao_order ho LEFT JOIN (SELECT * FROM yeshi_ec_hongbao_v2
        v2 WHERE v2.`hb_uid`= #{uid}
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        <!-- 红包类型 -->
        <include refid="SELECT_HONGBAO_STATE" />
        <!-- 红包状态 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
        <!-- 订单状态 -->
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
        <!-- 订单时间 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        )A
    </select>
    <select id="getBuFenOrderState" resultMap="ResultMap">SELECT
    <select id="listUserOrder" resultMap="ResultMap">
        <!-- 查询用户订单 -->
        SELECT COALESCE(SUM(hb.`hb_money`),0)AS totalMoney, hb.hb_state AS
        hongBaoState, hb.`hb_type` AS hongBaoType, MAX(hb.`hb_get_time`) AS
        accountTime, MAX(hb.`hb_pre_get_time`) AS preAccountTime,
        <include refid="Order_Column_List"/>
        FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        <include refid="Hongbao_Column_List"/>
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
        <include refid="SELECT_PARAM_HONGBAO_TYPE"/>
        <if test="type == 2 and day == 5">
            <!-- 本月月将要到账分享订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="type == 3 and day == 5">
            <!-- 本月将要到账邀请订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <!-- 红包类型 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE"/>
        <!-- 订单状态 -->
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME"/>
        <!-- 订单时间 -->
        <include refid="SELECT_PARAM_HONGBAO_STATE"/>
        <!-- 订单号查询 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <!-- 订单来源 -->
        <if test="listSource != null and listSource.size() &gt; 0">
            <foreach collection="listSource" item="item" open="AND ("
                     close=")" separator="or">co.co_source_type = #{item}
            </foreach>
        </if>
        <![CDATA[AND co.co_source_type <> 4 AND co.co_source_type <> 5]]>
        GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY
        co.co_third_create_time DESC LIMIT ${start},${count}
    </select>
    <select id="countUserOrder" resultType="java.lang.Long">
        <!-- 统计用户订单数量 -->
        SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.ho_id FROM
        yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        <include refid="Hongbao_Column_List"/>
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
        <include refid="SELECT_PARAM_HONGBAO_TYPE"/>
        <!-- 红包类型 -->
        <if test="type == 2 and day == 5">
            <!-- 本月月将要到账分享订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="type == 3 and day == 5">
            <!-- 本月将要到账邀请订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE"/>
        <!-- 订单状态 -->
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME"/>
        <!-- 订单时间 -->
        <include refid="SELECT_PARAM_HONGBAO_STATE"/>
        <!-- 订单号查询 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <!-- 订单来源 -->
        <if test="listSource != null and listSource.size() &gt; 0">
            <foreach collection="listSource" item="item" open="AND ("
                     close=")" separator="or">co.co_source_type = #{item}
            </foreach>
        </if>
        <![CDATA[AND co.co_source_type <> 4 AND co.co_source_type <> 5]]>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <select id="listOrderGoodsInfo" resultMap="ResultMap"
            parameterType="java.util.List">
        <!-- 查询用户订单商品信息 -->
        SELECT COALESCE(SUM(tc.`co_payment`),0)AS
        totalPayment,COALESCE(SUM(tc.`co_settlement`),0)AS totalSettlement,
        COALESCE(SUM(tc.`co_count`),0)AS
        totalCount,tc.`co_source_type`,tc.`co_order_no`,tg.*,tc.co_id FROM
        yeshi_ec_common_order_goods tg LEFT JOIN yeshi_ec_common_order tc ON
        tc.`co_order_goods_id` = tg.`cog_id` WHERE
        <foreach collection="list" item="item" separator=" OR ">(tc.`co_source_type`
            = #{item.sourceType,jdbcType=INTEGER} AND tc.`co_order_no` =
            #{item.orderNo,jdbcType=VARCHAR})
        </foreach>
        GROUP BY tc.`co_order_no`,tc.`co_order_goods_id`
    </select>
    <select id="countHistoryOrder" resultType="java.util.HashMap">
        <!-- 统计历史订单数量 -->
        SELECT SUM(A.self)AS totalSelf,SUM(A.shared)AS
        totalShared,SUM(A.invite)AS totalInvite FROM (
        <!-- 返利订单 -->
        SELECT IFNULL(COUNT(ho_id),0) AS self,0 AS shared,0 AS invite FROM
        (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT *
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= ${uid} AND
        (v2.`hb_type` = 1 OR v2.`hb_type` = 2) ) hb ON
        hb.hb_id=ho.`ho_hongbao_id`
        <!-- 自购订单 -->
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL and hb.hb_state!=4
        <if test="day != null and day == 1">
            <!-- 今天 -->
            AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW())
        </if>
        <if test="day != null and day == 2">
            <!-- 昨天 -->
            AND TO_DAYS(NOW()) - TO_DAYS(co.co_third_create_time) = 1
        </if>
        <if test="day != null and day == 3">
            <!-- 本月 -->
            AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day != null and day == 4">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),
            DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)YX UNION ALL
        <!-- 分享订单 -->
        SELECT 0 AS self,IFNULL(COUNT(ho_id),0) AS shared,0 AS invite FROM
        (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT *
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= ${uid} AND v2.`hb_type`
        = 20 ) hb ON hb.hb_id=ho.`ho_hongbao_id`
        <!-- 分享订单 -->
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL and hb.hb_state!=4
        <if test="day != null and day == 1">
            <!-- 今天 -->
            AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW())
        </if>
        <if test="day != null and day == 2">
            <!-- 昨天 -->
            AND TO_DAYS(NOW()) - TO_DAYS(co.`co_third_create_time`) = 1
        </if>
        <if test="day != null and day == 3">
            <!-- 本月 -->
            AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day != null and day == 4">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),
            DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)WQ UNION ALL
        <!-- 邀请订单 -->
        SELECT 0 AS self,0 AS shared,IFNULL(COUNT(ho_id),0) AS invite FROM
        (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT *
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= ${uid} AND
        (v2.`hb_type` = 5 OR v2.`hb_type` = 6 OR v2.`hb_type` = 7 OR
        v2.`hb_type` = 21 OR v2.`hb_type` = 22 ) ) hbp ON
        hbp.hb_pid=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON
        co.`co_id`=ho.`ho_order_id` WHERE hbp.hb_id IS NOT NULL and
        hbp.hb_state!=4
        <if test="day != null and day == 1">
            <!-- 今天 -->
            AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW())
        </if>
        <if test="day != null and day == 2">
            <!-- 昨天 -->
            AND TO_DAYS(NOW()) - TO_DAYS(co.`co_third_create_time`) = 1
        </if>
        <if test="day != null and day == 3">
            <!-- 本月 -->
            AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day != null and day == 4">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),
            DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)SX )A
    </select>
    <sql id="OrderCountQuery">WHERE
        co.`co_state_whole_order`<![CDATA[<>]]>3
        <if test="day == 1">
            <!-- 今天 -->
            AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW())
        </if>
        <if test="day == 2">
            <!-- 昨天 -->
            AND TO_DAYS(NOW()) - TO_DAYS(co.`co_third_create_time`) = 1
        </if>
        <if test="day == 3">
            <!-- 本月 -->
            AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="day == 4">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(),
            '%Y%m'),DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1
        </if>
        <!-- 订单来源 -->
        <if test="listSource != null and listSource.size() &gt; 0">
            <foreach collection="listSource" item="item" open="AND ("
                     close=")" separator="or">co.co_source_type = #{item}
            </foreach>
        </if>
    </sql>
    <select id="getOrderCount" resultMap="OrderCountMap">
        SELECT sum(self) as self,sum(shared) as shared,sum(invite) as invite
        from ( SELECT IFNULL(COUNT(co_order_no),0)AS self,0 AS shared,0 AS
        invite FROM (SELECT co.`co_order_no` FROM (SELECT * FROM
        yeshi_ec_hongbao_v2 v WHERE v.`hb_uid`= ${uid} AND v.`hb_type` = 1)v2
        LEFT JOIN yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id` =
        IF(v2.hb_pid IS NULL,v2.hb_id,v2.hb_pid) LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id` = ho.`ho_order_id`
        <include refid="OrderCountQuery"/>
        GROUP BY co.`co_order_no`,co.`co_source_type`)A UNION ALL SELECT 0 AS
        self,IFNULL(COUNT(co_order_no),0)AS shared,0 AS invite FROM (SELECT
        co.`co_order_no` FROM (SELECT * FROM yeshi_ec_hongbao_v2 v WHERE
        v.`hb_uid`= ${uid} AND v.`hb_type` = 20)v2 LEFT JOIN
        yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id` = IF(v2.hb_pid IS
        NULL,v2.hb_id,v2.hb_pid) LEFT JOIN yeshi_ec_common_order co ON
        co.`co_id` = ho.`ho_order_id`
        <include refid="OrderCountQuery"/>
        GROUP BY co.`co_order_no`,co.`co_source_type`)A UNION ALL SELECT 0 AS
        self,0 AS shared,IFNULL(COUNT(co_order_no),0)AS invite FROM (SELECT
        co.`co_order_no` FROM (SELECT * FROM yeshi_ec_hongbao_v2 v WHERE
        v.`hb_uid`= ${uid} AND (v.`hb_type` = 5 OR v.`hb_type` = 6 OR
        v.`hb_type` = 7 OR v.`hb_type` = 21 OR v.`hb_type` = 22))v2 LEFT JOIN
        yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id` = IF(v2.hb_pid IS
        NULL,v2.hb_id,v2.hb_pid) LEFT JOIN yeshi_ec_common_order co ON
        co.`co_id` = ho.`ho_order_id`
        <include refid="OrderCountQuery"/>
        GROUP BY co.`co_order_no`,co.`co_source_type`)A )B
    </select>
    <select id="countUserOrderToApp" resultType="Long">
        <!-- 有效订单 -->
        SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.`ho_id` FROM
        yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT * FROM
        yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid}
        <include refid="SELECT_PARAM_HONGBAO_TYPE"/>
        <if test="state != null and state == 1">
            <!-- 未到账 -->
            AND (v2.hb_state = 1 or v2.hb_state = 2)
        </if>
        <if test="state != null and state == 2">
            <!-- 已到账 -->
            AND v2.hb_state = 3
        </if>
        <if test="state != null and state == 3">
            <!-- 红包已失效 -->
            AND v2.hb_state =4
        </if>
        ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL<![CDATA[AND co.`co_state` <> 3]]>
        <if test="stateOrder == 1">
            <!-- 有效订单 -->
            AND (co.`co_state_whole_order` =1 OR co.`co_state_whole_order` = 2)
        </if>
        <if test="stateOrder == 2">
            <!-- 维权订单 -->
            AND co.`co_state` = 3
        </if>
        <if test="stateOrder == 3">
            <!-- 失效订单 -->
            AND co.`co_state_whole_order` = 3
        </if>
        <!-- 订单时间 -->
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME"/>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <!-- <select id="countByUidAndOrderState" resultType="java.util.HashMap">
        SELECT SUM(A.valid)AS totalValid, SUM(A.proces)AS totalProces,SUM(A.Invalid)AS
        totalInvite FROM ( 有效订单 SELECT IFNULL(COUNT(ho_id),0) AS valid,0 AS proces,0
        AS Invalid FROM (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN
        ( SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid} <include
        refid="SELECT_PARAM_HONGBAO_TYPE" /> ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id
        IS NOT NULL <![CDATA[AND co.`co_state` <> 3]]> AND (co.`co_state_whole_order`
        =1 OR co.`co_state_whole_order` = 2) <include refid="SELECT_PARAM_ORDER_CREATE_TIME"
        /> 订单来源 <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)YX UNION ALL 维权订单 SELECT 0
        AS valid,IFNULL(COUNT(ho_id),0) AS proces,0 AS Invalid FROM (SELECT ho.`ho_id`
        FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT * FROM yeshi_ec_hongbao_v2
        v2 WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT
        JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id
        IS NOT NULL AND co.`co_state` = 3 <include refid="SELECT_PARAM_ORDER_CREATE_TIME"
        /> 订单来源 <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)WQ UNION ALL 失效订单 SELECT 0
        AS valid,0 AS proces,IFNULL(COUNT(ho_id),0) AS Invalid FROM (SELECT ho.`ho_id`
        FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT * FROM yeshi_ec_hongbao_v2
        v2 WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT
        JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id
        IS NOT NULL AND co.`co_state_whole_order` = 3 <include refid="SELECT_PARAM_ORDER_CREATE_TIME"
        /> 订单来源 <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type`)SX )A </select> -->
    <select id="countBonusOrderNumber" resultType="java.lang.Long">
        <!-- 奖金统计:订单数量 -->
        SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.`ho_id` FROM
        yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT * FROM
        yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid}
        <include refid="SELECT_PARAM_HONGBAO_TYPE"/>
        ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME"/>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <select id="countBonusOrderMoney" resultType="java.math.BigDecimal">
        <!-- 奖金统计:订单总返利金额 去掉已失效 -->
        SELECT COALESCE(SUM(hb.`hb_money`),0)AS totalmoney FROM
        yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT
        <include refid="Hongbao_Column_List"/>
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid}
        <include refid="SELECT_PARAM_HONGBAO_TYPE"/>
        AND (v2.hb_state = 1 or v2.hb_state = 2 or v2.hb_state = 3) ) hb ON
        IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id
        IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME"/>
        <if test="day != null and day == 4">
            AND co.`co_state` = 2
            <!-- 上月 :统计已收货 -->
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
    </select>
    <select id="countBonusOrderMoneyAndNumber" resultType="java.util.HashMap">
        SELECT COUNT(*) AS totalNum, CAST(SUM(moneys) AS DECIMAL(19,2)) AS
        totalmoney FROM (SELECT CAST(SUM(hb.`hb_money`) AS DECIMAL(19,2))AS
        moneys FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT
        <include refid="Hongbao_Column_List"/>
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid}
        <include refid="SELECT_PARAM_HONGBAO_TYPE"/>
        AND (v2.hb_state = 1 or v2.hb_state = 2 or v2.hb_state = 3) ) hb ON
        IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id
        IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME"/>
        <if test="day != null and day == 4">AND co.`co_state` = 2</if>
        <!-- 上月 :统计已收货 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <sql id="SELECT_HONGBAO_STATE">
        <if test="state != null and state == 1">
            <!-- 未到账 -->
            AND (v2.hb_state = 1 or v2.hb_state = 2)
        </if>
        <if test="state != null and state == 2">
            <!-- 已到账 -->
            AND v2.hb_state = 3
        </if>
        <if test="state != null and state == 3">
            <!-- 红包已失效 -->
            AND v2.hb_state =4
        </if>
    </sql>
    <select id="listQueryByUid" resultMap="ResultMap">
        <!-- 查询用户订单 -->
        SELECT hb.`hb_money` AS totalMoney, hb.hb_state AS hongBaoState,
        hb.`hb_type` AS hongBaoType, hb.`hb_get_time` AS accountTime,
        hb.`hb_pre_get_time` AS preAccountTime, co.*,cog.* FROM
        yeshi_ec_hongbao_order ho LEFT JOIN (SELECT * FROM yeshi_ec_hongbao_v2
        v2 WHERE v2.`hb_uid`= #{uid}
        <include refid="SELECT_PARAM_HONGBAO_TYPE"/>
        <!-- 红包类型 -->
        <include refid="SELECT_HONGBAO_STATE"/>
        <!-- 红包状态 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` LEFT
        JOIN yeshi_ec_common_order_goods cog ON cog.`cog_id`=
        co.`co_order_goods_id` WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE"/>
        <!-- 订单状态 -->
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME"/>
        <!-- 订单时间 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <if test="payment != null">AND
            co.co_payment <![CDATA[<]]>
            #{payment}
        </if>
        ORDER BY co.co_third_create_time DESC LIMIT ${start},${count}
    </select>
    <select id="countQueryByUid" resultType="java.lang.Long">
        <!-- 统计用户订单数量 -->
        SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.ho_id FROM
        yeshi_ec_hongbao_order ho LEFT JOIN (SELECT * FROM yeshi_ec_hongbao_v2
        v2 WHERE v2.`hb_uid`= #{uid}
        <include refid="SELECT_PARAM_HONGBAO_TYPE"/>
        <!-- 红包类型 -->
        <include refid="SELECT_HONGBAO_STATE"/>
        <!-- 红包状态 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE"/>
        <!-- 订单状态 -->
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME"/>
        <!-- 订单时间 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        )A
    </select>
    <select id="getBuFenOrderState" resultMap="ResultMap">SELECT
        co.co_state,v2.`hb_state` AS hongBaoState FROM `yeshi_ec_common_order`
        co LEFT JOIN yeshi_ec_hongbao_order ho ON co.`co_id`=ho.`ho_order_id`
        LEFT JOIN yeshi_ec_hongbao_v2 v2 ON IF(v2.hb_pid IS
@@ -855,256 +868,263 @@
        #{orderNo} AND co.co_state<![CDATA[<>]]>
        4 AND v2.hb_uid = #{uid} ORDER BY co.`co_state` DESC LIMIT 1
    </select>
    <select id="listQuery" resultMap="ThreeResultMap">
        SELECT A.*,u.id AS userId,u.`nick_name` AS userName,u.`portrait` AS
        userPortrait FROM (SELECT hb.hb_id,hb.hb_uid,hb.`hb_money` AS
        totalMoney, hb.hb_state AS hongBaoState, hb.`hb_type` AS hongBaoType,
        hb.`hb_get_time` AS accountTime, hb.`hb_pre_get_time` AS
        preAccountTime, co.* FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        <!-- 红包类型 -->
        <include refid="SELECT_HONGBAO_STATE" />
        <!-- 红包状态 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        <if test="listShopId != null">
            LEFT JOIN yeshi_ec_common_order_goods g ON
            co.`co_order_goods_id`=g.`cog_id`
        </if>
    <select id="listQuery" resultMap="ThreeResultMap">
        SELECT A.*,u.id AS userId,u.`nick_name` AS userName,u.`portrait` AS
        userPortrait FROM (SELECT hb.hb_id,hb.hb_uid,hb.`hb_money` AS
        totalMoney, hb.hb_state AS hongBaoState, hb.`hb_type` AS hongBaoType,
        hb.`hb_get_time` AS accountTime, hb.`hb_pre_get_time` AS
        preAccountTime, co.* FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
        <include refid="SELECT_PARAM_HONGBAO_TYPE"/>
        <!-- 红包类型 -->
        <include refid="SELECT_HONGBAO_STATE"/>
        <!-- 红包状态 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        <if test="listShopId != null">
            LEFT JOIN yeshi_ec_common_order_goods g ON
            co.`co_order_goods_id`=g.`cog_id`
        </if>
        LEFT JOIN yeshi_ec_user u on u.id=co.co_uid
        LEFT JOIN yeshi_ec_user u on u.id=co.co_uid
        WHERE u.system=#{system} AND hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
        <!-- 订单状态 -->
        <if test="startTime != null and startTime != '' ">AND <![CDATA[co.co_third_create_time >= #{startTime}]]>
        </if>
        <if test="endTime != null and endTime != '' ">AND <![CDATA[co.co_third_create_time <= #{endTime}]]>
        </if>
        <if test="key != null and key != '' ">
            <if test="keyType == 1 ">AND co.co_order_no = '${key}'</if>
            <if test="keyType == 2 ">AND hb.hb_uid = ${key}</if>
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        <if test="listGoodsId != null">
            <foreach collection="listGoodsId" item="goodsId" open=" and ("
                separator=" or " close=")">co.`co_order_goods_id` =#{goodsId}</foreach>
        </if>
        <if test="listShopId != null">
            <foreach collection="listShopId" item="shopId" open=" and ("
                separator=" or " close=")">g.`cog_shop_id` =#{shopId}</foreach>
        </if>
        <if test="minTime != null">
            <!-- 高风险订单 -->
            AND co.`co_third_create_time`&gt;#{minTime} AND<![CDATA[ (co.`co_estimate`>=  ${money} OR co.`co_eIncome`> ${money})]]>
        </if>
        ORDER BY co.co_third_create_time DESC LIMIT ${start},${count} ) A LEFT
        JOIN yeshi_ec_user u ON u.id = A.hb_uid
    </select>
    <select id="listQueryWithNoChild" resultMap="ThreeResultMap">
        SELECT A.*,u.id AS userId,u.`nick_name` AS userName,u.`portrait` AS
        userPortrait FROM (SELECT hb.hb_id,hb.hb_uid,hb.`hb_money` AS
        totalMoney, hb.hb_state AS hongBaoState, hb.`hb_type` AS hongBaoType,
        hb.`hb_get_time` AS accountTime, hb.`hb_pre_get_time` AS
        preAccountTime, co.* FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        <!-- 红包类型 -->
        <include refid="SELECT_HONGBAO_STATE" />
        <!-- 红包状态 -->
        )hb ON hb.hb_id=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co
        ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
        <!-- 订单状态 -->
        <if test="startTime != null and startTime != '' ">AND <![CDATA[co.co_third_create_time >= #{startTime}]]>
        </if>
        <if test="endTime != null and endTime != '' ">AND <![CDATA[co.co_third_create_time <= #{endTime}]]>
        </if>
        <if test="key != null and key != '' ">
            <if test="keyType == 1 ">AND co.co_order_no = '${key}'</if>
            <if test="keyType == 2 ">AND hb.hb_uid = ${key}</if>
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        <if test="payment != null">AND
            co.co_payment <![CDATA[<]]>
            #{payment}
        </if>
        ORDER BY co.co_third_create_time DESC LIMIT ${start},${count} ) A LEFT
        JOIN yeshi_ec_user u ON u.id = A.hb_uid where u.system=#{system}
    </select>
    <select id="countQuery" resultType="java.lang.Long">
        SELECT count(ho.ho_id) FROM yeshi_ec_hongbao_order ho LEFT JOIN
        (SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        <!-- 红包类型 -->
        <include refid="SELECT_HONGBAO_STATE" />
        <!-- 红包状态 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        <if test="listShopId != null">LEFT JOIN yeshi_ec_common_order_goods g ON
            co.`co_order_goods_id`=g.`cog_id`
        </if>
        WHERE u.system=#{system} AND hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE"/>
        <!-- 订单状态 -->
        <if test="startTime != null and startTime != '' ">AND <![CDATA[co.co_third_create_time >= #{startTime}]]>
        </if>
        <if test="endTime != null and endTime != '' ">AND <![CDATA[co.co_third_create_time <= #{endTime}]]>
        </if>
        <if test="key != null and key != '' ">
            <if test="keyType == 1 ">AND co.co_order_no = '${key}'</if>
            <if test="keyType == 2 ">AND hb.hb_uid = ${key}</if>
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        <if test="listGoodsId != null">
            <foreach collection="listGoodsId" item="goodsId" open=" and ("
                     separator=" or " close=")">co.`co_order_goods_id` =#{goodsId}
            </foreach>
        </if>
        <if test="listShopId != null">
            <foreach collection="listShopId" item="shopId" open=" and ("
                     separator=" or " close=")">g.`cog_shop_id` =#{shopId}
            </foreach>
        </if>
        <if test="minTime != null">
            <!-- 高风险订单 -->
            AND co.`co_third_create_time`&gt;#{minTime} AND
            <![CDATA[ (co.`co_estimate`>=  ${money} OR co.`co_eIncome`> ${money})]]>
        </if>
        ORDER BY co.co_third_create_time DESC LIMIT ${start},${count} ) A LEFT
        JOIN yeshi_ec_user u ON u.id = A.hb_uid
    </select>
    <select id="listQueryWithNoChild" resultMap="ThreeResultMap">
        SELECT A.*,u.id AS userId,u.`nick_name` AS userName,u.`portrait` AS
        userPortrait FROM (SELECT hb.hb_id,hb.hb_uid,hb.`hb_money` AS
        totalMoney, hb.hb_state AS hongBaoState, hb.`hb_type` AS hongBaoType,
        hb.`hb_get_time` AS accountTime, hb.`hb_pre_get_time` AS
        preAccountTime, co.* FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
        <include refid="SELECT_PARAM_HONGBAO_TYPE"/>
        <!-- 红包类型 -->
        <include refid="SELECT_HONGBAO_STATE"/>
        <!-- 红包状态 -->
        )hb ON hb.hb_id=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co
        ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE"/>
        <!-- 订单状态 -->
        <if test="startTime != null and startTime != '' ">AND <![CDATA[co.co_third_create_time >= #{startTime}]]>
        </if>
        <if test="endTime != null and endTime != '' ">AND <![CDATA[co.co_third_create_time <= #{endTime}]]>
        </if>
        <if test="key != null and key != '' ">
            <if test="keyType == 1 ">AND co.co_order_no = '${key}'</if>
            <if test="keyType == 2 ">AND hb.hb_uid = ${key}</if>
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        <if test="payment != null">AND
            co.co_payment <![CDATA[<]]>
            #{payment}
        </if>
        ORDER BY co.co_third_create_time DESC LIMIT ${start},${count} ) A LEFT
        JOIN yeshi_ec_user u ON u.id = A.hb_uid where u.system=#{system}
    </select>
    <select id="countQuery" resultType="java.lang.Long">
        SELECT count(ho.ho_id) FROM yeshi_ec_hongbao_order ho LEFT JOIN
        (SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
        <include refid="SELECT_PARAM_HONGBAO_TYPE"/>
        <!-- 红包类型 -->
        <include refid="SELECT_HONGBAO_STATE"/>
        <!-- 红包状态 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        <if test="listShopId != null">LEFT JOIN yeshi_ec_common_order_goods g ON
            co.`co_order_goods_id`=g.`cog_id`
        </if>
        LEFT JOIN yeshi_ec_user u on u.id=co_uid
        WHERE u.system=#{system} AND hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
        <!-- 订单状态 -->
        <if test="startTime != null and startTime != '' ">AND <![CDATA[co.co_third_create_time >= #{startTime}]]>
        </if>
        <if test="endTime != null and endTime != '' ">AND <![CDATA[co.co_third_create_time <= #{endTime}]]>
        </if>
        <if test="key != null and key != '' ">
            <if test="keyType == 1 ">AND co.co_order_no = '${key}'</if>
            <if test="keyType == 2 ">AND hb.hb_uid = ${key}</if>
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        <if test="listGoodsId != null">
            <foreach collection="listGoodsId" item="goodsId" open=" and ("
                separator=" or " close=")">co.`co_order_goods_id` =#{goodsId}</foreach>
        </if>
        <if test="listShopId != null">
            <foreach collection="listShopId" item="shopId" open=" and ("
                separator=" or " close=")">g.`cog_shop_id` =#{shopId}</foreach>
        </if>
        <if test="payment != null">AND
            co.co_payment <![CDATA[<]]>
            #{payment}
        </if>
        <if test="minTime != null">
            <!-- 高风险订单 -->
            AND co.`co_third_create_time`&gt;#{minTime} AND<![CDATA[ (co.`co_estimate`>=  ${money} OR co.`co_eIncome`> ${money})]]>
        </if>
    </select>
    <select id="countQueryWithNoChild" resultType="java.lang.Long">
        SELECT count(ho.ho_id) FROM yeshi_ec_hongbao_order ho LEFT JOIN
        (SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        <!-- 红包类型 -->
        <include refid="SELECT_HONGBAO_STATE" />
        <!-- 红包状态 -->
        )hb ON hb.hb_id=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co
        ON co.`co_id`=ho.`ho_order_id`
        LEFT JOIN yeshi_ec_user u ON u.id=co.co_uid
        LEFT JOIN yeshi_ec_user u on u.id=co_uid
        WHERE u.system=#{system} AND hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE"/>
        <!-- 订单状态 -->
        <if test="startTime != null and startTime != '' ">AND <![CDATA[co.co_third_create_time >= #{startTime}]]>
        </if>
        <if test="endTime != null and endTime != '' ">AND <![CDATA[co.co_third_create_time <= #{endTime}]]>
        </if>
        <if test="key != null and key != '' ">
            <if test="keyType == 1 ">AND co.co_order_no = '${key}'</if>
            <if test="keyType == 2 ">AND hb.hb_uid = ${key}</if>
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        <if test="listGoodsId != null">
            <foreach collection="listGoodsId" item="goodsId" open=" and ("
                     separator=" or " close=")">co.`co_order_goods_id` =#{goodsId}
            </foreach>
        </if>
        <if test="listShopId != null">
            <foreach collection="listShopId" item="shopId" open=" and ("
                     separator=" or " close=")">g.`cog_shop_id` =#{shopId}
            </foreach>
        </if>
        <if test="payment != null">AND
            co.co_payment <![CDATA[<]]>
            #{payment}
        </if>
        <if test="minTime != null">
            <!-- 高风险订单 -->
            AND co.`co_third_create_time`&gt;#{minTime} AND
            <![CDATA[ (co.`co_estimate`>=  ${money} OR co.`co_eIncome`> ${money})]]>
        </if>
    </select>
    <select id="countQueryWithNoChild" resultType="java.lang.Long">
        SELECT count(ho.ho_id) FROM yeshi_ec_hongbao_order ho LEFT JOIN
        (SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
        <include refid="SELECT_PARAM_HONGBAO_TYPE"/>
        <!-- 红包类型 -->
        <include refid="SELECT_HONGBAO_STATE"/>
        <!-- 红包状态 -->
        )hb ON hb.hb_id=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co
        ON co.`co_id`=ho.`ho_order_id`
        LEFT JOIN yeshi_ec_user u ON u.id=co.co_uid
        WHERE u.system =#{system} AND hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
        <!-- 订单状态 -->
        <if test="startTime != null and startTime != '' ">AND <![CDATA[co.co_third_create_time >= #{startTime}]]>
        </if>
        <if test="endTime != null and endTime != '' ">AND <![CDATA[co.co_third_create_time <= #{endTime}]]>
        </if>
        <if test="key != null and key != '' ">
            <if test="keyType == 1 ">AND co.co_order_no = '${key}'</if>
            <if test="keyType == 2 ">AND hb.hb_uid = ${key}</if>
        </if>
        <if test="payment != null">AND
            co.co_payment <![CDATA[<]]>
            #{payment}
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
    </select>
    <select id="getCouponHongbaoByOrderNo" resultMap="ResultMap">
        SELECT COALESCE(SUM(IF(hb.hb_type=1,hb.`hb_money`,0)),0)AS totalMoney,
        COALESCE(SUM(IF(hb.hb_type=10,hb.`hb_money`,0)),0)AS couponMoney,
        hb.`hb_type` AS hongBaoType, MAX(hb.`hb_get_time`) AS accountTime,
        MAX(hb.`hb_pre_get_time`) AS preAccountTime, hb.hb_state AS
        hongBaoState,
        <include refid="Order_Column_List" />
        FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT * FROM
        yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid}
        <if test="hongBaoState != null">AND v2.`hb_state` = #{hongBaoState}</if>
        )hb ON hb.hb_id = ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order
        co ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id IS NOT NULL AND
        co.co_order_no = #{orderNo}
    </select>
    <select id="getCommonOrderByOrderNo" resultMap="ResultMap">
        <!-- 查询用户订单 -->
        SELECT COALESCE(SUM(hb.`hb_money`),0)AS totalMoney,
        COALESCE(SUM(co.`co_payment`),0)AS totalPayment, hb.hb_state AS
        hongBaoState, hb.`hb_type` AS hongBaoType,
        <include refid="Order_Column_List" />
        FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        <include refid="Hongbao_Column_List" />
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL AND co.co_order_no = #{orderNo} AND
        co.`co_source_type` = #{sourceType}
        <if test="orderState != null">
            AND co.co_state = #{orderState}
            <!-- 已收货 -->
        </if>
        GROUP BY co.`co_order_no`, co.`co_source_type`
    </select>
    <select id="getByOrderNo" resultMap="BaseResultMap">SELECT * FROM
        WHERE u.system =#{system} AND hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE"/>
        <!-- 订单状态 -->
        <if test="startTime != null and startTime != '' ">AND <![CDATA[co.co_third_create_time >= #{startTime}]]>
        </if>
        <if test="endTime != null and endTime != '' ">AND <![CDATA[co.co_third_create_time <= #{endTime}]]>
        </if>
        <if test="key != null and key != '' ">
            <if test="keyType == 1 ">AND co.co_order_no = '${key}'</if>
            <if test="keyType == 2 ">AND hb.hb_uid = ${key}</if>
        </if>
        <if test="payment != null">AND
            co.co_payment <![CDATA[<]]>
            #{payment}
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
    </select>
    <select id="getCouponHongbaoByOrderNo" resultMap="ResultMap">
        SELECT COALESCE(SUM(IF(hb.hb_type=1,hb.`hb_money`,0)),0)AS totalMoney,
        COALESCE(SUM(IF(hb.hb_type=10,hb.`hb_money`,0)),0)AS couponMoney,
        hb.`hb_type` AS hongBaoType, MAX(hb.`hb_get_time`) AS accountTime,
        MAX(hb.`hb_pre_get_time`) AS preAccountTime, hb.hb_state AS
        hongBaoState,
        <include refid="Order_Column_List"/>
        FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT * FROM
        yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid}
        <if test="hongBaoState != null">AND v2.`hb_state` = #{hongBaoState}</if>
        )hb ON hb.hb_id = ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order
        co ON co.`co_id`=ho.`ho_order_id` WHERE hb.hb_id IS NOT NULL AND
        co.co_order_no = #{orderNo}
    </select>
    <select id="getCommonOrderByOrderNo" resultMap="ResultMap">
        <!-- 查询用户订单 -->
        SELECT COALESCE(SUM(hb.`hb_money`),0)AS totalMoney,
        COALESCE(SUM(co.`co_payment`),0)AS totalPayment, hb.hb_state AS
        hongBaoState, hb.`hb_type` AS hongBaoType,
        <include refid="Order_Column_List"/>
        FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        <include refid="Hongbao_Column_List"/>
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL AND co.co_order_no = #{orderNo} AND
        co.`co_source_type` = #{sourceType}
        <if test="orderState != null">
            AND co.co_state = #{orderState}
            <!-- 已收货 -->
        </if>
        GROUP BY co.`co_order_no`, co.`co_source_type`
    </select>
    <select id="getByOrderNo" resultMap="BaseResultMap">SELECT * FROM
        yeshi_ec_common_order co WHERE co_uid = #{uid} AND
        co_order_no=#{orderNo}
    </select>
    <select id="getByOrderNoAndSourceType" resultMap="BaseResultMap">
    <select id="getByOrderNoAndSourceType" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_common_order co 
        WHERE co_uid = #{uid} AND co_order_no=#{orderNo} AND co_source_type = #{sourceType}
    </select>
    <select id="listByUid" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_common_order co WHERE co_uid = #{uid}
        <if test="stateList!=null">
            <foreach collection="stateList" separator=" or " open="and ("
                item="state" close=")">co_state=#{state}</foreach>
        </if>
        limit #{start},#{count}
    </select>
    <select id="firstValidOrderByUid" resultMap="ResultMap">
        SELECT co.*,v2.`hb_get_time` AS accountTime FROM
        yeshi_ec_hongbao_order ho LEFT JOIN yeshi_ec_hongbao_v2 v2 ON
        IF(v2.hb_pid IS NULL,v2.hb_id,v2.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE v2.hb_id
        IS NOT NULL AND v2.`hb_uid` = #{uid} AND v2.`hb_state` = 3
        <if test="typeHB == 1">
            <!-- 自购订单 -->
            AND (v2.hb_type =1 or v2.hb_type =2)
        </if>
        <if test="typeHB == 2">
            <!-- 分享订单 -->
            AND v2.`hb_type` = 20
        </if>
        <if test="typeHB == 3">
            <!-- 邀请订单 -->
            AND (v2.`hb_type` = 5 OR v2.`hb_type` = 6 OR v2.`hb_type` = 7 OR
            v2.`hb_type` = 21 OR v2.`hb_type` = 22)
        </if>
        <if test="typeDate == 3">
            <!-- 本月 -->
            AND DATE_FORMAT(co.`co_create_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="typeDate == 4">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(),
            '%Y%m'),DATE_FORMAT(co.`co_create_time`, '%Y%m')) = 1
        </if>
        ORDER BY co.`co_id` LIMIT 1
    </select>
    <select id="getFirstShareOrderByUid" resultMap="BaseResultMap">SELECT co.* FROM
    <select id="listByUid" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_common_order co WHERE co_uid = #{uid}
        <if test="stateList!=null">
            <foreach collection="stateList" separator=" or " open="and ("
                     item="state" close=")">co_state=#{state}
            </foreach>
        </if>
        limit #{start},#{count}
    </select>
    <select id="firstValidOrderByUid" resultMap="ResultMap">
        SELECT co.*,v2.`hb_get_time` AS accountTime FROM
        yeshi_ec_hongbao_order ho LEFT JOIN yeshi_ec_hongbao_v2 v2 ON
        IF(v2.hb_pid IS NULL,v2.hb_id,v2.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE v2.hb_id
        IS NOT NULL AND v2.`hb_uid` = #{uid} AND v2.`hb_state` = 3
        <if test="typeHB == 1">
            <!-- 自购订单 -->
            AND (v2.hb_type =1 or v2.hb_type =2)
        </if>
        <if test="typeHB == 2">
            <!-- 分享订单 -->
            AND v2.`hb_type` = 20
        </if>
        <if test="typeHB == 3">
            <!-- 邀请订单 -->
            AND (v2.`hb_type` = 5 OR v2.`hb_type` = 6 OR v2.`hb_type` = 7 OR
            v2.`hb_type` = 21 OR v2.`hb_type` = 22)
        </if>
        <if test="typeDate == 3">
            <!-- 本月 -->
            AND DATE_FORMAT(co.`co_create_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="typeDate == 4">
            <!-- 上月 -->
            AND PERIOD_DIFF(DATE_FORMAT(NOW(),
            '%Y%m'),DATE_FORMAT(co.`co_create_time`, '%Y%m')) = 1
        </if>
        ORDER BY co.`co_id` LIMIT 1
    </select>
    <select id="getFirstShareOrderByUid" resultMap="BaseResultMap">SELECT co.* FROM
        yeshi_ec_hongbao_order ho LEFT JOIN yeshi_ec_hongbao_v2 v2 ON v2.hb_id
        = ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON
        co.`co_id`=ho.`ho_order_id` WHERE v2.`hb_uid` = #{uid} AND
        v2.`hb_type` = 20 ORDER BY co.`co_third_create_time` LIMIT 1
    </select>
    <select id="getTotalRewardMoneyByOrderNoAndSourceType"
        resultType="BigDecimal">SELECT SUM(hb_money) FROM(SELECT v2.`hb_money` FROM
    <select id="getTotalRewardMoneyByOrderNoAndSourceType"
            resultType="BigDecimal">SELECT SUM(hb_money) FROM(SELECT v2.`hb_money` FROM
        yeshi_ec_hongbao_order ho LEFT JOIN yeshi_ec_hongbao_v2 v2 ON v2.hb_id
        = ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON
        co.`co_id`=ho.`ho_order_id` WHERE v2.`hb_type` = 20 AND v2.`hb_state`
        = 3 AND co.`co_order_no` = #{orderNo} AND co.`co_source_type`=
        #{sourceType})A
    </select>
    <select id="count24HValidOrderByUid" resultType="Long">SELECT
    <select id="count24HValidOrderByUid" resultType="Long">SELECT
        IFNULL(COUNT(A.co_order_no),0) FROM (SELECT co.`co_order_no` FROM
        yeshi_ec_hongbao_order ho LEFT JOIN yeshi_ec_hongbao_v2 v2 ON v2.hb_id
        = ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON
@@ -1115,133 +1135,135 @@
        DATE_SUB(NOW(), INTERVAL 1 DAY) GROUP BY
        co.`co_order_no`,co.`co_source_type`)A
    </select>
    <select id="searchOrderByUid" resultMap="ResultMap">
        SELECT COALESCE(SUM(hb.`hb_money`),0)AS totalMoney, hb.hb_state AS
        hongBaoState, hb.`hb_type` AS hongBaoType, MAX(hb.`hb_get_time`) AS
        accountTime, MAX(hb.`hb_pre_get_time`) AS preAccountTime,
        <include refid="Order_Column_List" />
        FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        <include refid="Hongbao_Column_List" />
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<>10]]>)hb
        ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT
        JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE
        hb.hb_id IS NOT NULL
        <foreach collection="list" item="esOrder" open=" and (" close=")"
            separator=" or ">(co.co_trade_id=#{esOrder.tradeId} AND co.co_source_type =
            #{esOrder.platform})
        </foreach>
        GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY
        co.co_third_create_time DESC LIMIT ${start},${count}
    </select>
    <select id="countSearchOrderByUid" resultType="java.lang.Long">
        SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.ho_id FROM
        yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        <include refid="Hongbao_Column_List" />
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        <foreach collection="list" item="esOrder" open=" and (" close=")"
            separator=" or ">(co.co_trade_id=#{esOrder.tradeId} AND co.co_source_type =
            #{esOrder.platform})
        </foreach>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <select id="getMinSettleTimeAndUid" resultMap="BaseResultMap">SELECT
    <select id="searchOrderByUid" resultMap="ResultMap">
        SELECT COALESCE(SUM(hb.`hb_money`),0)AS totalMoney, hb.hb_state AS
        hongBaoState, hb.`hb_type` AS hongBaoType, MAX(hb.`hb_get_time`) AS
        accountTime, MAX(hb.`hb_pre_get_time`) AS preAccountTime,
        <include refid="Order_Column_List"/>
        FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        <include refid="Hongbao_Column_List"/>
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<>10]]>)hb
        ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT
        JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE
        hb.hb_id IS NOT NULL
        <foreach collection="list" item="esOrder" open=" and (" close=")"
                 separator=" or ">(co.co_trade_id=#{esOrder.tradeId} AND co.co_source_type =
            #{esOrder.platform})
        </foreach>
        GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY
        co.co_third_create_time DESC LIMIT ${start},${count}
    </select>
    <select id="countSearchOrderByUid" resultType="java.lang.Long">
        SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.ho_id FROM
        yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        <include refid="Hongbao_Column_List"/>
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        <foreach collection="list" item="esOrder" open=" and (" close=")"
                 separator=" or ">(co.co_trade_id=#{esOrder.tradeId} AND co.co_source_type =
            #{esOrder.platform})
        </foreach>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <select id="getMinSettleTimeAndUid" resultMap="BaseResultMap">SELECT
        d.`co_uid`,MAX(d.`co_settle_time`) AS co_settle_time FROM
        `yeshi_ec_common_order` d WHERE d.`co_settle_time` IS NOT NULL AND
        d.`co_payment` &gt; 1 GROUP BY d.`co_uid`</select>
    <select id="getOrderList" resultMap="ResultMap">
        SELECT hb.`hb_type` AS hongBaoType, MAX(hb.`hb_get_time`) AS
        accountTime, MAX(hb.`hb_pre_get_time`) AS preAccountTime,
        <include refid="Order_Column_List" />
        FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        <include refid="Hongbao_Column_List" />
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        <if test="type == 2 and day == 5">
            <!-- 本月月将要到账分享订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="type == 3 and day == 5">
            <!-- 本月将要到账邀请订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <!-- 红包类型 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
        <!-- 订单状态 -->
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
        <!-- 订单时间 -->
        <include refid="SELECT_PARAM_HONGBAO_STATE" />
        <!-- 订单号查询 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <!-- 订单来源 -->
        <if test="listSource != null and listSource.size() &gt; 0">
            <foreach collection="listSource" item="item" open="AND ("
                close=")" separator="or">co.co_source_type = #{item}</foreach>
        </if>
        GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY
        co.co_third_create_time DESC LIMIT ${start},${count}
    </select>
    <select id="countOrderList" resultType="java.lang.Long">
        SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.ho_id FROM
        yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        <include refid="Hongbao_Column_List" />
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
        <include refid="SELECT_PARAM_HONGBAO_TYPE" />
        <!-- 红包类型 -->
        <if test="type == 2 and day == 5">
            <!-- 本月月将要到账分享订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="type == 3 and day == 5">
            <!-- 本月将要到账邀请订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
        <!-- 订单状态 -->
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
        <!-- 订单时间 -->
        <include refid="SELECT_PARAM_HONGBAO_STATE" />
        <!-- 订单号查询 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <!-- 订单来源 -->
        <if test="listSource != null and listSource.size() &gt; 0">
            <foreach collection="listSource" item="item" open="AND ("
                close=")" separator="or">co.co_source_type = #{item}</foreach>
        </if>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <select id="countOrderByUidAndSettled" resultType="Long">SELECT
    <select id="getOrderList" resultMap="ResultMap">
        SELECT hb.`hb_type` AS hongBaoType, MAX(hb.`hb_get_time`) AS
        accountTime, MAX(hb.`hb_pre_get_time`) AS preAccountTime,
        <include refid="Order_Column_List"/>
        FROM yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        <include refid="Hongbao_Column_List"/>
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
        <include refid="SELECT_PARAM_HONGBAO_TYPE"/>
        <if test="type == 2 and day == 5">
            <!-- 本月月将要到账分享订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="type == 3 and day == 5">
            <!-- 本月将要到账邀请订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <!-- 红包类型 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE"/>
        <!-- 订单状态 -->
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME"/>
        <!-- 订单时间 -->
        <include refid="SELECT_PARAM_HONGBAO_STATE"/>
        <!-- 订单号查询 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <!-- 订单来源 -->
        <if test="listSource != null and listSource.size() &gt; 0">
            <foreach collection="listSource" item="item" open="AND ("
                     close=")" separator="or">co.co_source_type = #{item}
            </foreach>
        </if>
        GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY
        co.co_third_create_time DESC LIMIT ${start},${count}
    </select>
    <select id="countOrderList" resultType="java.lang.Long">
        SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.ho_id FROM
        yeshi_ec_hongbao_order ho LEFT JOIN (SELECT
        <include refid="Hongbao_Column_List"/>
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
        <include refid="SELECT_PARAM_HONGBAO_TYPE"/>
        <!-- 红包类型 -->
        <if test="type == 2 and day == 5">
            <!-- 本月月将要到账分享订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        <if test="type == 3 and day == 5">
            <!-- 本月将要到账邀请订单 -->
            AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') =
            DATE_FORMAT(CURDATE(),'%Y%m')
        </if>
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE"/>
        <!-- 订单状态 -->
        <include refid="SELECT_PARAM_ORDER_CREATE_TIME"/>
        <!-- 订单时间 -->
        <include refid="SELECT_PARAM_HONGBAO_STATE"/>
        <!-- 订单号查询 -->
        <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
        <!-- 订单来源 -->
        <if test="listSource != null and listSource.size() &gt; 0">
            <foreach collection="listSource" item="item" open="AND ("
                     close=")" separator="or">co.co_source_type = #{item}
            </foreach>
        </if>
        GROUP BY co.`co_order_no`, co.`co_source_type` )A
    </select>
    <select id="countOrderByUidAndSettled" resultType="Long">SELECT
        COUNT(d.`co_id`) FROM `yeshi_ec_common_order` d WHERE d.`co_uid` =
        #{uid} AND d.`co_settle_time` IS NOT NULL AND d.`co_payment` &gt;=
        #{payment}
    </select>
    <select id="getNewestOrderNoByTaoBao" resultType="String">
    <select id="getNewestOrderNoByTaoBao" resultType="String">
        SELECT d.`co_order_no` FROM `yeshi_ec_common_order` d
        WHERE d.`co_source_type` = 1
        ORDER BY d.`co_id` DESC
        LIMIT 1
    </select>
    <select id="listByOrderNo" resultMap="BaseResultMap">
    <select id="listByOrderNo" resultMap="BaseResultMap">
        SELECT * FROM `yeshi_ec_common_order` d
        WHERE d.`co_order_no` = #{orderNo}
        GROUP BY d.`co_order_no`,d.`co_source_type`
    </select>
    <select id="getFirstOrder" resultMap="BaseResultMap">
    <select id="getFirstOrder" resultMap="BaseResultMap">
        SELECT * FROM `yeshi_ec_common_order` d
        WHERE d.co_uid = #{uid}
        ORDER BY d.co_third_create_time 
fanli/src/main/resource/mapping/push/DeviceTokenHWMapper.xml
@@ -33,8 +33,14 @@
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_uid_devicetoken_hw
        where 1=1
        <if test="minUpdateTime!=null">
            AND  dh_updatetime>=#{minUpdateTime}
        </if>
        <if test="versionList!=null">
            <foreach collection="versionList" open="where (" separator=" or "
            <foreach collection="versionList" open="and (" separator=" or "
                item="ver" close=")">
                dh_version=#{ver}
            </foreach>
@@ -56,10 +62,14 @@
    <select id="selectCount" resultType="java.lang.Long">
        select count(dh_id) from
        yeshi_ec_uid_devicetoken_hw
        yeshi_ec_uid_devicetoken_hw where 1=1
        <if test="minUpdateTime!=null">
            AND  dh_updatetime>=#{minUpdateTime}
        </if>
        <if test="versionList!=null">
            <foreach collection="versionList" open="where (" separator=" or "
            <foreach collection="versionList" open="and (" separator=" or "
                item="ver" close=")">
                dh_version=#{ver}
            </foreach>
fanli/src/main/resource/mapping/push/DeviceTokenOPPOMapper.xml
@@ -35,8 +35,17 @@
        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
        where  1=1
        <if test="minUpdateTime!=null">
            and  (do_create_time>=#{minUpdateTime}  or do_update_time>=#{minUpdateTime} )
        </if>
        <if test="versionList!=null">
            <foreach collection="versionList" open="where (" separator=" or "
            <foreach collection="versionList" open="and (" separator=" or "
                item="ver" close=")">
                da_version_code=#{ver}
            </foreach>
@@ -50,8 +59,17 @@
        from yeshi_ec_uid_devicetoken_oppo
        left join
        yeshi_ec_device_active a on a.da_id=do_device_id
        where  1=1
        <if test="minUpdateTime!=null">
            and  (do_create_time>=#{minUpdateTime}  or do_update_time>=#{minUpdateTime} )
        </if>
        <if test="versionList!=null">
            <foreach collection="versionList" open="where (" separator=" or "
            <foreach collection="versionList" open="and (" separator=" or "
                item="ver" close=")">
                da_version_code=#{ver}
            </foreach>
fanli/src/main/resource/mapping/push/DeviceTokenVIVOMapper.xml
@@ -35,8 +35,15 @@
        count(dv_id)
        from yeshi_ec_uid_devicetoken_vivo op left join
        yeshi_ec_device_active a on a.da_id=op.dv_device_id
        where 1=1
        <if test="minUpdateTime!=null">
            and (dv_create_time>=#{minUpdateTime} or dv_update_time>=#{minUpdateTime} )
        </if>
        <if test="versionList!=null">
            <foreach collection="versionList" open="where (" separator=" or "
            <foreach collection="versionList" open="and (" separator=" or "
                item="ver" close=")">
                da_version_code=#{ver}
            </foreach>
@@ -50,8 +57,15 @@
        from yeshi_ec_uid_devicetoken_vivo
        left join
        yeshi_ec_device_active a on a.da_id=dv_device_id
        where 1=1
        <if test="minUpdateTime!=null">
            and (dv_create_time>=#{minUpdateTime} or dv_update_time>=#{minUpdateTime} )
        </if>
        <if test="versionList!=null">
            <foreach collection="versionList" open="where (" separator=" or "
            <foreach collection="versionList" open="and (" separator=" or "
                item="ver" close=")">
                da_version_code=#{ver}
            </foreach>
fanli/src/main/resource/xxl-job-executor.properties
@@ -1,5 +1,5 @@
### 调度中心部署跟地址 [选填]:如调度中心集群部署存在多个地址则用逗号分隔。执行器将会使用该地址进行"执行器心跳注册"和"任务结果回调";为空则关闭自动注册;
xxl.job.admin.addresses=http://111.231.250.166:8080/xxl-job-admin
xxl.job.admin.addresses=http://111.231.250.166:9000/xxl-job-admin
### 执行器AppName [选填]:执行器心跳注册分组依据;为空则关闭自动注册
xxl.job.executor.appname=pro-job
### 执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯实用;地址信息用于 "执行器注册" 和 "调度中心请求并触发任务";
utils/src/main/java/org/yeshi/utils/NetWorkUtil.java
New file
@@ -0,0 +1,33 @@
package org.yeshi.utils;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
public class NetWorkUtil {
    /**
     * 指定端口是否可连接
     * @param host
     * @param port
     * @param timeOut
     * @return
     */
    public static boolean isHostConnectable(String host, int port,int timeOut) {
        Socket socket = new Socket();
        try {
            socket.connect(new InetSocketAddress(host, port),timeOut);
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        } finally {
            try {
                socket.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return true;
    }
}