admin
2020-07-04 9d35ba657fa5e3add766405d76e3ff8c4dcd4ad4
多系统兼容优化
9个文件已添加
95个文件已修改
24051 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/CallBackController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/AppPageNotificationAdminController.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/BrandShopAdminController.java 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsEvaluateAdminController.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/HelpCenterAdminController.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushCouponController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushGoodsController.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushInfoController.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/HomeNavbarAdminController.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5HelpCenterController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5SwiperPictureController.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/BrandController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/HelpController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/HomeNavbarController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/PushController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserMsgController.java 1839 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConfigControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java 3250 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/HomeNavbarControllerV2.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/PreviewInfoControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserCloudControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/ConfigController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/InviteController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/dynamic/GoodsEvaluateDao.java 72 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/brand/BrandClassMapper.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/brand/BrandClassSystemMapMapper.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/common/CommonConfigMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/help/AppPageNotificationMapper.java 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/help/HelpCenterMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/help/HelpClassMapper.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/homemodule/HomeNavbarMapper.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/PushCouponMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/PushGoodsMapper.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/PushInfoMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/push/PushBaseContent.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/brand/BrandClassSystemMap.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/help/AppPageNotification.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/help/HelpCenter.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/help/HelpClass.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/homemodule/HomeNavbar.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/config/CommonConfig.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/dynamic/GoodsEvaluate.java 477 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/push/PushCoupon.java 274 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/push/PushGoods.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/push/PushInfo.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java 841 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/IntegralTaskJob.java 107 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/PushJob.java 172 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/brand/BrandClassMapper.xml 217 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/brand/BrandClassSystemMapMapper.xml 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/common/CommonConfigMapper.xml 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/help/AppPageNotificationMapper.xml 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/help/HelpCenterMapper.xml 285 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/help/HelpClassMapper.xml 230 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/homemodule/HomeNavbarMapper.xml 504 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/push/PushCouponMapper.xml 201 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/push/PushGoodsMapper.xml 299 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/push/PushInfoMapper.xml 221 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassServiceImpl.java 307 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/common/CommonConfigServiceImpl.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java 4776 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/help/AppPageNotificationServiceImpl.java 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpCenterServiceImpl.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpClassServiceImpl.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/HomeNavbarServiceImpl.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/HomeNavbarUserServiceImpl.java 429 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SuperHomeNavbarServiceImpl.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/money/msg/UserMoneyMsgNotificationServiceImpl.java 455 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/msg/UserOrderMsgNotificationServiceImpl.java 260 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/HWPushServiceImpl.java 378 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/OPPOPushServiceImpl.java 71 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushCouponServiceImpl.java 379 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushGoodsServiceImpl.java 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushInfoServiceImpl.java 612 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushServiceImpl.java 1028 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/VIVOPushServiceImpl.java 70 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderPayServiceImpl.java 677 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/ShamUserServiceImpl.java 311 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java 1699 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java 2187 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandClassService.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/common/CommonConfigService.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/dynamic/GoodsEvaluateService.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/help/AppPageNotificationService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/help/HelpCenterService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/help/HelpClassService.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/HomeNavbarService.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/HomeNavbarUserService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/SuperHomeNavbarService.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/HWPushService.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/OPPOPushService.java 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/PushCouponService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/PushGoodsService.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/PushInfoService.java 104 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/VIVOPushService.java 139 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/cache/HttpGoodsCacheManager.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/test/java/org/fanli/AppVersionTest.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/test/java/org/fanli/MyBatisProduce.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/test/java/org/fanli/config/Test_Brand.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/CallBackController.java
@@ -338,8 +338,9 @@
            ActivityUser user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser();
            try {
                for(SystemEnum system:SystemEnum.values())
                goodsEvaluateService.addGoodsEvaluate(itemId + "", imageList, user, doc, null,
                        new Date(startTime - 1000 * 60 * 20L * i), SystemEnum.blks);
                        new Date(startTime - 1000 * 60 * 20L * i),system);
            } catch (GoodsEvaluateException e) {
                e.printStackTrace();
            } catch (Exception e) {
fanli/src/main/java/com/yeshi/fanli/controller/admin/AppPageNotificationAdminController.java
@@ -9,6 +9,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.accept.AdminAcceptData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
@@ -51,7 +52,7 @@
     * @param out
     */
//    @RequestMapping(value = "saveAdd")
    public void saveAdd(String callback, AppPageNotification appPageNotification, PrintWriter out) {
    public void saveAdd(AdminAcceptData acceptData, String callback, AppPageNotification appPageNotification, PrintWriter out) {
        try {
            String content = appPageNotification.getContent();
            if (StringUtil.isNullOrEmpty(content) ) {
@@ -61,7 +62,7 @@
            
            AppPageNotificationTypeEnum type = appPageNotification.getType();
            if (type != null) {
                AppPageNotification old = appPageNotificationService.getAppPageNotificationByType(type.name());
                AppPageNotification old = appPageNotificationService.getAppPageNotificationByType(type.name(),acceptData.getSystem());
                if (old != null) {
                    JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("已存在此类型"));
                    return;
@@ -208,7 +209,7 @@
     * @param out
     */
    @RequestMapping(value = "query")
    public void query(String callback, Integer pageIndex, Integer pageSize, String key,
    public void query(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key,
             Integer show, Integer canClose,String version, String platform,  PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
@@ -219,7 +220,7 @@
        try {
            List<AppPageNotification> list = appPageNotificationService.listQuery((pageIndex - 1) * pageSize, 
                    pageSize, key, show, canClose);
                    pageSize, key, show, canClose,acceptData.getSystem());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
@@ -246,7 +247,7 @@
                }
            }
            
            long count = appPageNotificationService.countQuery(key, show, canClose);
            long count = appPageNotificationService.countQuery(key, show, canClose,acceptData.getSystem());
            
            List<AppVersionInfo> versionList = null;
            if (!StringUtil.isNullOrEmpty(version) || !StringUtil.isNullOrEmpty(platform)) {
@@ -256,7 +257,7 @@
                    if (appVersion != null)
                        versionList.add(appVersion);
                } else {
                    List<AppVersionInfo> appVersionList = appVersionService.getAppVersionInfoListByPlatform(platform);
                    List<AppVersionInfo> appVersionList = appVersionService.getAppVersionInfoListByPlatform(platform,acceptData.getSystem());
                    if (appVersionList != null) {
                        versionList.addAll(appVersionList);
                    }
@@ -428,14 +429,12 @@
            e.printStackTrace();
        }
    }
    /**
     * 设置版本
     *
     *  设置版本
     * @param callback
     * @param id
     * @param moveType
     * @param sex
     * @param versions
     * @param out
     */
    @RequestMapping(value = "setVersions")
fanli/src/main/java/com/yeshi/fanli/controller/admin/BrandShopAdminController.java
@@ -9,6 +9,8 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.accept.AdminAcceptData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartHttpServletRequest;
@@ -54,13 +56,14 @@
     * 保存信息
     * 
     * @param callback
     * @param special
     * @param out
     */
    @RequestMapping(value = "save")
    public void save(String callback, BrandClass brandClass, PrintWriter out) {
    public void save(AdminAcceptData acceptData, String callback, BrandClass brandClass, PrintWriter out) {
        try {
            brandClassService.saveObject(brandClass);
            List<SystemEnum> systemList=new ArrayList<>();
            systemList.add(acceptData.getSystem());
            brandClassService.saveObject(brandClass,systemList);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
        } catch (BrandClassException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
@@ -74,13 +77,12 @@
     * 修改排序
     * 
     * @param callback
     * @param goodsClass
     * @param out
     */
    @RequestMapping(value = "updateOrder")
    public void updateOrder(String callback, Long id, Integer moveType, PrintWriter out) {
    public void updateOrder(AdminAcceptData acceptData,String callback, Long id, Integer moveType, PrintWriter out) {
        try {
            brandClassService.updateOrder(id, moveType);
            brandClassService.updateOrder(id, moveType,acceptData.getSystem());
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
        } catch (BrandClassException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
@@ -101,7 +103,7 @@
     * @param out
     */
    @RequestMapping(value = "query")
    public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state,
    public void query(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Integer state,
            PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
@@ -112,13 +114,13 @@
        }
        try {
            List<BrandClass> list = brandClassService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state);
            List<BrandClass> list = brandClassService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state,acceptData.getSystem());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            long count = brandClassService.countQuery(key, state);
            long count = brandClassService.countQuery(key, state,acceptData.getSystem());
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
@@ -193,9 +195,9 @@
     * @param out
     */
    @RequestMapping(value = "getOptions")
    public void getOptions(String callback, PrintWriter out) {
    public void getOptions(AdminAcceptData acceptData, String callback, PrintWriter out) {
        try {
            List<BrandClass> list = brandClassService.listEffective();
            List<BrandClass> list = brandClassService.listEffective(acceptData.getSystem());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
@@ -292,7 +294,6 @@
     * 添加店铺入库
     * 
     * @param callback
     * @param special
     * @param out
     */
    @RequestMapping(value = "saveShopInfo")
@@ -376,7 +377,6 @@
     * 保存信息
     * 
     * @param callback
     * @param special
     * @param out
     */
    @RequestMapping(value = "saveClassShop")
@@ -402,7 +402,6 @@
     * 修改排序
     * 
     * @param callback
     * @param goodsClass
     * @param out
     */
    @RequestMapping(value = "updateOrderClassShop")
@@ -531,7 +530,6 @@
     * 修改排序
     * 
     * @param callback
     * @param goodsClass
     * @param out
     */
    @RequestMapping(value = "updateOrderBrand")
fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsEvaluateAdminController.java
@@ -609,7 +609,7 @@
     * @param out
     */
    @RequestMapping(value = "query")
    public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state, String typeEnum, PrintWriter out) {
    public void query(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Integer state, String typeEnum, PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
        }
@@ -618,7 +618,7 @@
        }
        try {
            List<GoodsEvaluate> list = goodsEvaluateService.query((pageIndex - 1) * pageSize, pageSize, key, state, 1, typeEnum);
            List<GoodsEvaluate> list = goodsEvaluateService.query((pageIndex - 1) * pageSize, pageSize, key, state, 1, typeEnum,acceptData.getSystem());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
@@ -640,7 +640,7 @@
                }
            }
            long count = goodsEvaluateService.count(key, state, 1, typeEnum);
            long count = goodsEvaluateService.count(key, state, 1, typeEnum,acceptData.getSystem());
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
@@ -664,7 +664,7 @@
     * @param out
     */
    @RequestMapping(value = "querySuCai")
    public void querySuCai(String callback, Integer pageIndex, Integer pageSize, String key, Integer state,
    public void querySuCai(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Integer state,
            PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
@@ -674,7 +674,7 @@
        }
        try {
            List<GoodsEvaluate> list = goodsEvaluateService.query((pageIndex - 1) * pageSize, pageSize, key, state, 2, null);
            List<GoodsEvaluate> list = goodsEvaluateService.query((pageIndex - 1) * pageSize, pageSize, key, state, 2, null,acceptData.getSystem());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
@@ -696,7 +696,7 @@
                }
            }
            long count = goodsEvaluateService.count(key, state, 2, null);
            long count = goodsEvaluateService.count(key, state, 2, null,acceptData.getSystem());
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
fanli/src/main/java/com/yeshi/fanli/controller/admin/HelpCenterAdminController.java
@@ -175,7 +175,7 @@
            if (pageSize == null)
                pageSize = Constant.PAGE_SIZE;
            List<HelpCenter> list = helpCenterService.query(0, Integer.MAX_VALUE, key, cid, orderMode, state);
            List<HelpCenter> list = helpCenterService.query(0, Integer.MAX_VALUE, key, cid, orderMode, state,acceptData.getSystem());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
@@ -404,9 +404,9 @@
     * @param out
     */
    @RequestMapping(value = "updateSort")
    public void updateSort(String callback, Integer moveType, Long id, PrintWriter out) {
    public void updateSort(AdminAcceptData acceptData, String callback, Integer moveType, Long id, PrintWriter out) {
        try {
            helpClassService.updateSort(moveType, id);
            helpClassService.updateSort(moveType, id,acceptData.getSystem());
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
        } catch (HelpClassException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
@@ -465,7 +465,7 @@
        pageSize = Integer.MAX_VALUE;
        try {
            List<HelpClass> list = helpClassService.query(0, pageSize, key, showState);
            List<HelpClass> list = helpClassService.query(0, pageSize, key, showState,acceptData.getSystem());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
@@ -552,7 +552,7 @@
     * @param out
     */
    @RequestMapping(value = "getProvidedClass")
    public void getAllClass(String callback, PrintWriter out) {
    public void getAllClass(AdminAcceptData acceptData, String callback, PrintWriter out) {
        try {
            HelpClass helpClass = new HelpClass();
@@ -562,7 +562,7 @@
            List<HelpClass> reslut_list = new ArrayList<HelpClass>();
            reslut_list.add(helpClass);
            List<HelpClass> list = helpClassService.getProvidedClass();
            List<HelpClass> list = helpClassService.getProvidedClass(acceptData.getSystem());
            if (list != null && list.size() > 0) {
                reslut_list.addAll(list);
            }
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java
@@ -7,6 +7,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.accept.AdminAcceptData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.HttpUtil;
@@ -75,8 +76,8 @@
     * @throws Exception
     */
    @RequestMapping(value = "newPushUrlAll")
    public void newPushUrlAll(String callback, String url, String title, String content, String uids,
            String arrayIOS, String arrayAndroid, PrintWriter out) {
    public void newPushUrlAll(AdminAcceptData acceptData, String callback, String url, String title, String content, String uids,
                              String arrayIOS, String arrayAndroid, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(url) || StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请填写链接,标题与内容"));
@@ -111,12 +112,12 @@
            
            if (listuid == null) {
                // 全推
                pushService.pushUrl(null, title, content, url, listIOS, listAndroid);
                pushService.pushUrl(null, title, content, url, listIOS, listAndroid,acceptData.getSystem());
            } else {
                // 部分推送
                for (String str_uid: listuid) {
                    if (str_uid != null && str_uid.trim().length() > 0) {
                        pushService.pushUrl(Long.parseLong(str_uid), title, content, url, listIOS, listAndroid);
                        pushService.pushUrl(Long.parseLong(str_uid), title, content, url, listIOS, listAndroid,acceptData.getSystem());
                    }
                }
            }
@@ -134,13 +135,12 @@
     * 
     * 方法说明: 站内信推送 -(新后台)
     * 
     * @param uId
     * @param title
     * @param content
     * @throws Exception
     */
    @RequestMapping(value = "newPushFanZNX")
    public void newPushFanZNX(String callback, String uids, String title, String content, String arrayIOS,
    public void newPushFanZNX(AdminAcceptData acceptData,String callback, String uids, String title, String content, String arrayIOS,
            String arrayAndroid, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) {
@@ -171,12 +171,12 @@
            
            if (listuid == null) {
                // 全推
                pushService.pushZNX(null, title, content, listIOS, listAndroid);
                pushService.pushZNX(null, title, content, listIOS, listAndroid,acceptData.getSystem());
            } else {
                // 部分推送
                for (String str_uid: listuid) {
                    if (str_uid != null && str_uid.trim().length() > 0) {
                        pushService.pushZNX(Long.parseLong(str_uid), title, content, listIOS, listAndroid);
                        pushService.pushZNX(Long.parseLong(str_uid), title, content, listIOS, listAndroid,acceptData.getSystem());
                        userSystemMsgService.addUserSystemMsg(Long.parseLong(str_uid), UserSystemMsgTypeEnum.question,
                                title, content, UserSystemMsg.TIME_TAG_EMERGENT, null);
@@ -196,13 +196,12 @@
     * 
     * 方法说明: 百川推送 -(新后台)
     * 
     * @param uId
     * @param title
     * @param content
     * @throws Exception
     */
    @RequestMapping(value = "pushBaiChuan")
    public void pushBaiChuan(String callback, String uids, String title, String content, String url, String arrayIOS,
    public void pushBaiChuan(AdminAcceptData acceptData,String callback, String uids, String title, String content, String url, String arrayIOS,
            String arrayAndroid, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) {
@@ -232,12 +231,12 @@
            
            if (listuid == null) {
                // 全推
                pushService.pushBaiChuanUrl(null, title, content, url, listIOS, listAndroid);
                pushService.pushBaiChuanUrl(null, title, content, url, listIOS, listAndroid,acceptData.getSystem());
            } else {
                // 部分推送
                for (String str_uid: listuid) {
                    if (str_uid != null && str_uid.trim().length() > 0) {
                        pushService.pushBaiChuanUrl(Long.parseLong(str_uid), title, content, url, listIOS, listAndroid);
                        pushService.pushBaiChuanUrl(Long.parseLong(str_uid), title, content, url, listIOS, listAndroid,acceptData.getSystem());
                    }
                }
            }
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushCouponController.java
@@ -8,6 +8,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.accept.AdminAcceptData;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -143,7 +144,7 @@
     * @param out
     */
    @RequestMapping(value = "query")
    public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state, PrintWriter out) {
    public void query(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Integer state, PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
@@ -155,7 +156,7 @@
        try {
            List<PushCoupon> list = pushCouponService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state);
            List<PushCoupon> list = pushCouponService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state,acceptData.getSystem());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
@@ -180,7 +181,7 @@
                listVO.add(pushCouponVO);
            }
            long count = pushCouponService.countQuery(key, state);
            long count = pushCouponService.countQuery(key, state,acceptData.getSystem());
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
@@ -204,7 +205,6 @@
    
    /**
     * 推送
     * @param id 推送id
     * @param out
     * @throws Exception
     */
@@ -243,7 +243,6 @@
    /**
     * 版本转换为list
     * @param pushGoods
     */
    public void convertVersionList(PushCouponVO pushCouponVO) {
      String versions = pushCouponVO.getVersions();
@@ -271,7 +270,6 @@
    /**
     * 转换json
     * @param pushGoods
     */
    public void convertVersion(PushCoupon pushCoupon, String arrayIOS, String arrayAndroid) {
        
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushGoodsController.java
@@ -9,6 +9,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.accept.AdminAcceptData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
@@ -226,7 +227,7 @@
     * @param out
     */
    @RequestMapping(value = "query")
    public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state, PrintWriter out) {
    public void query(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Integer state, PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
@@ -238,7 +239,7 @@
        try {
            List<PushGoods> list = pushGoodsService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state);
            List<PushGoods> list = pushGoodsService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state,acceptData.getSystem());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
@@ -261,7 +262,7 @@
                convertVersionList(pushGoods);
            }
            long count = pushGoodsService.countQuery(key, state);
            long count = pushGoodsService.countQuery(key, state,acceptData.getSystem());
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
@@ -286,7 +287,6 @@
    /**
     *   商品推送
     * 
     * @param id 推送id
     * @param out
     * @throws Exception
     */
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushInfoController.java
@@ -6,6 +6,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.accept.AdminAcceptData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
@@ -27,12 +28,9 @@
@RequestMapping("admin/new/api/v1/pushInfo")
public class PushInfoController {
    @Resource
    private PushInfoService pushInfoService;
    
    /**
     * 新增/修改
     * 
@@ -63,8 +61,8 @@
     * @param out
     */
    @RequestMapping(value = "query")
    public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer keyType,
            Integer state, String type, PrintWriter out) {
    public void query(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Integer keyType,
                      Integer state, String type, PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
@@ -76,14 +74,14 @@
        try {
            List<PushInfo> list = pushInfoService.listQuery((pageIndex-1) * pageSize, pageSize, key, keyType, state, type);
            List<PushInfo> list = pushInfoService.listQuery((pageIndex-1) * pageSize, pageSize, key, keyType, state, type,acceptData.getSystem());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            long count = pushInfoService.countQuery(key, keyType, state, type);
            long count = pushInfoService.countQuery(key, keyType, state, type,acceptData.getSystem());
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
@@ -139,7 +137,6 @@
    
    /**
     * 推送
     * @param id 推送id
     * @param out
     * @throws Exception
     */
fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/HomeNavbarAdminController.java
@@ -7,6 +7,7 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.yeshi.fanli.entity.accept.AdminAcceptData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartHttpServletRequest;
@@ -36,7 +37,6 @@
     * 保存信息
     * 
     * @param callback
     * @param special
     * @param out
     */
    @RequestMapping(value = "save")
@@ -65,7 +65,6 @@
     * 修改排序
     * 
     * @param callback
     * @param goodsClass
     * @param out
     */
    @RequestMapping(value = "updateOrder")
@@ -92,7 +91,7 @@
     * @param out
     */
    @RequestMapping(value = "query")
    public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer sex, PrintWriter out) {
    public void query(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Integer sex, PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
        }
@@ -102,13 +101,13 @@
        }
        try {
            List<HomeNavbar> list = homeNavbarService.listQuery((pageIndex - 1) * pageSize, pageSize, key, sex);
            List<HomeNavbar> list = homeNavbarService.listQuery((pageIndex - 1) * pageSize, pageSize, key, sex,acceptData.getSystem());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            
            long count = homeNavbarService.countlistQuery(key, sex);
            long count = homeNavbarService.countlistQuery(key, sex,acceptData.getSystem());
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5HelpCenterController.java
@@ -65,7 +65,7 @@
            if (pageId == null)
                pageId = 0L;
            List<HelpCenter> list1 = helpCenterService.listValid(pageId, pageSize, key, cid);
            List<HelpCenter> list1 = helpCenterService.listValid(pageId, pageSize, key, cid,acceptData.getSystem());
            List<HelpCenter> list = new ArrayList<>();
            if (list1 != null && list1.size() > 0)
                list.addAll(list1);
@@ -158,7 +158,7 @@
        try {
            List<HelpClass> resultList = new ArrayList<>();
            List<HelpClass> list = helpClassService.getClassByState(1);
            List<HelpClass> list = helpClassService.getClassByState(1,acceptData.getSystem());
            if (list != null && list.size() > 0) {
                resultList.addAll(list);
            }
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5SwiperPictureController.java
@@ -1,23 +1,19 @@
package com.yeshi.fanli.controller.apph5;
import java.io.PrintWriter;
import java.util.List;
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.vo.homemodule.BannerVO;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.vo.homemodule.BannerVO;
import net.sf.json.JSONObject;
import javax.annotation.Resource;
import java.io.PrintWriter;
import java.util.List;
/**
 * 动态
@@ -33,7 +29,7 @@
    private SwiperPictureService swiperPictureService;
    @RequestMapping(value = "getpicture")
    public void getDetail(String callback, String card, PrintWriter out) {
    public void getDetail(AcceptData acceptData, String callback, String card, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(card)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("唯一标识为空"));
@@ -41,7 +37,7 @@
        }
            
        List<BannerVO> list = swiperPictureService.getByBannerCard(card, SystemEnum.blks);
        List<BannerVO> list = swiperPictureService.getByBannerCard(card, acceptData.getSystem());
        if (list == null || list.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
            return;
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/BrandController.java
@@ -84,7 +84,7 @@
    @RequestMapping(value = "getClass", method = RequestMethod.POST)
    public void getClass(AcceptData acceptData, PrintWriter out) {
        try {
            List<BrandClass> list = brandClassService.listBrandClassEffectiveCache();
            List<BrandClass> list = brandClassService.listBrandClassEffectiveCache(acceptData.getSystem());
            if (list == null) {
                list = new ArrayList<BrandClass>();
            }
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/HelpController.java
@@ -64,7 +64,7 @@
        String version = acceptData.getVersion();
        AppPageNotification ap = appPageNotificationService.getValidNotificationByTypeCache(type, platform,
                Integer.parseInt(version));
                Integer.parseInt(version),acceptData.getSystem());
        if ("home".equalsIgnoreCase(type) && VersionUtil.smallerThan_1_5_1(platform, version) && ap != null) {
            AppPageNotification no = new AppPageNotification();
            no.setContentUrl("");
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/HomeNavbarController.java
@@ -37,7 +37,7 @@
        
        List<HomeNavbar> list = new ArrayList<HomeNavbar>();
        
        List<HomeNavbar> listNavbar = homeNavbarService.listQueryDefaultNavbar(0);
        List<HomeNavbar> listNavbar = homeNavbarService.listQueryDefaultNavbar(0,acceptData.getSystem());
        if (listNavbar != null) {
            list.addAll(listNavbar);
        }
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/PushController.java
@@ -229,10 +229,10 @@
        // 设备注册时间
        Date createTime = deviceActive.getCreateTime();
        count = pushGoodsService.countHistoryByPushTime(uid, createTime);
        count = pushGoodsService.countHistoryByPushTime(uid, createTime,acceptData.getSystem());
        int pageSize = Constant.PAGE_SIZE;
        List<PushGoods> list = pushGoodsService.listHistoryByPushTime((page - 1) * pageSize, pageSize, uid, createTime);
        List<PushGoods> list = pushGoodsService.listHistoryByPushTime((page - 1) * pageSize, pageSize, uid, createTime,acceptData.getSystem());
        if (list == null)
            list = new ArrayList<>();
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserMsgController.java
@@ -99,1030 +99,1029 @@
@RequestMapping("api/v1/user/msg")
public class UserMsgController {
    @Resource
    private BusinessSystemService businessSystemService;
    @Resource
    private MsgOrderDetailService msgOrderDetailService;
    @Resource
    private BusinessSystemService businessSystemService;
    @Resource
    private MsgOrderDetailService msgOrderDetailService;
    @Resource
    private MsgMoneyDetailService msgMoneyDetailService;
    @Resource
    private MsgMoneyDetailService msgMoneyDetailService;
    @Resource
    private MsgInviteDetailService msgInviteDetailService;
    @Resource
    private MsgInviteDetailService msgInviteDetailService;
    @Resource
    private MsgAccountDetailService msgAccountDetailService;
    @Resource
    private MsgAccountDetailService msgAccountDetailService;
    @Resource
    private MsgOtherDetailService msgOtherDetailService;
    @Resource
    private MsgOtherDetailService msgOtherDetailService;
    @Resource
    private UserMsgReadStateService userMsgReadStateService;
    @Resource
    private UserMsgReadStateService userMsgReadStateService;
    @Resource
    private RecommendUserGoodsService recommendUserGoodsService;
    @Resource
    private RecommendUserGoodsService recommendUserGoodsService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserSystemMsgService userSystemMsgService;
    @Resource
    private UserSystemMsgService userSystemMsgService;
    @Resource
    private CommonGoodsService commonGoodsService;
    @Resource
    private CommonGoodsService commonGoodsService;
    @Resource
    private QualityFactoryService qualityFactoryService;
    @Resource
    private QualityFactoryService qualityFactoryService;
    @Resource
    private UserCustomSettingsService userCustomSettingsService;
    @Resource
    private UserCustomSettingsService userCustomSettingsService;
    @Resource
    private RedisManager redisManager;
    @Resource
    private RedisManager redisManager;
    @Resource
    private SpecialService specialService;
    @Resource
    private SpecialService specialService;
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    @Resource
    private PushGoodsService pushGoodsService;
    @Resource
    private PushGoodsService pushGoodsService;
    @Resource
    private DeviceActiveService deviceActiveService;
    @Resource
    private DeviceActiveService deviceActiveService;
    @Resource
    private MsgConfigService msgConfigService;
    @Resource
    private MsgConfigService msgConfigService;
    @Resource
    private MsgDeviceReadStateService msgDeviceReadStateService;
    @Resource
    private MsgDeviceReadStateService msgDeviceReadStateService;
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @Resource
    private UserInfoExtraService userInfoExtraService;
    // 消息的类型
    final static String MSG_TYPE_ORDER = "order";
    final static String MSG_TYPE_MONEY = "money";
    final static String MSG_TYPE_ACCOUNT = "account";
    final static String MSG_TYPE_INVITE = "invite";
    final static String MSG_TYPE_OTHER = "other";
    // 消息的类型
    final static String MSG_TYPE_ORDER = "order";
    final static String MSG_TYPE_MONEY = "money";
    final static String MSG_TYPE_ACCOUNT = "account";
    final static String MSG_TYPE_INVITE = "invite";
    final static String MSG_TYPE_OTHER = "other";
    /**
     * 获取消息列表
     *
     * @param acceptData
     * @param uid
     * @param page
     * @param type
     * @param out
     */
    @RequestMapping(value = "getMsgList", method = RequestMethod.POST)
    public void getMsgList(AcceptData acceptData, Long uid, int page, String type, PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
    /**
     * 获取消息列表
     *
     * @param acceptData
     * @param uid
     * @param page
     * @param type
     * @param out
     */
    @RequestMapping(value = "getMsgList", method = RequestMethod.POST)
    public void getMsgList(AcceptData acceptData, Long uid, int page, String type, PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        if (StringUtil.isNullOrEmpty(type)) {
            out.print(JsonUtil.loadFalseResult(2, "请上传type"));
            return;
        }
        if (StringUtil.isNullOrEmpty(type)) {
            out.print(JsonUtil.loadFalseResult(2, "请上传type"));
            return;
        }
        List<UserMsgVO> list = new ArrayList<>();
        long count = 0;
        List<UserMsgVO> list = new ArrayList<>();
        long count = 0;
        switch (type) {
        case MSG_TYPE_ORDER:
            userMsgReadStateService.readOrderMsg(uid);
            List<MsgOrderDetail> detailList = msgOrderDetailService.listMsgOrderDetail(uid, page);
            count = msgOrderDetailService.countMsgOrderDetail(uid);
            if (detailList != null)
                for (MsgOrderDetail detail : detailList) {
                    JSONObject params = new JSONObject();
                    params.put("orderNo", detail.getOrderId());
                    if (detail.getType() == MsgTypeOrderTypeEnum.invite    || detail.getType() == MsgTypeOrderTypeEnum.orderInvite)
                        params.put("orderHideNo", UserUtil.filterOrderId(detail.getOrderId()));
                    UserMsgVO msgVO = UserMsgVOFactory.create(detail, jumpDetailV2Service.getByTypeCache("order_search"), params);
                    msgVO.setType(MSG_TYPE_ORDER);
                    list.add(msgVO);
                }
            break;
        case MSG_TYPE_MONEY:
            userMsgReadStateService.readMoneyMsg(uid);
            List<MsgMoneyDetail> detailList1 = msgMoneyDetailService.listMsgMoneyDetail(uid, page);
            count = msgMoneyDetailService.countMsgMoneyDetail(uid);
            if (detailList1 != null)
                for (MsgMoneyDetail detail : detailList1) {
                    UserMsgVO msgVO = UserMsgVOFactory.create(detail);
                    msgVO.setType(MSG_TYPE_MONEY);
                    list.add(msgVO);
                }
            break;
        case MSG_TYPE_ACCOUNT:
            userMsgReadStateService.readAccountMsg(uid);
            List<MsgAccountDetail> detailList2 = msgAccountDetailService.listMsgAccountDetail(uid, page);
            count = msgAccountDetailService.countMsgAccountDetail(uid);
            if (detailList2 != null)
                for (MsgAccountDetail detail : detailList2) {
                    UserMsgVO msgVO = UserMsgVOFactory.create(detail);
                    msgVO.setType(MSG_TYPE_ACCOUNT);
                    list.add(msgVO);
                }
            break;
        case MSG_TYPE_INVITE:
            userMsgReadStateService.readInviteMsg(uid);
            List<MsgInviteDetail> detailList3 = msgInviteDetailService.listMsgInviteDetail(uid, page);
            count = msgInviteDetailService.countMsgInviteDetail(uid);
            if (detailList3 != null)
                for (MsgInviteDetail detail : detailList3) {
                    UserMsgVO vo = UserMsgVOFactory.create(detail);
                    if (vo != null) {
                        vo.setType(MSG_TYPE_INVITE);
                        list.add(vo);
                    } else {
                        count--;
                    }
                }
            break;
        case MSG_TYPE_OTHER:
            userMsgReadStateService.readOtherMsg(uid);
            List<MsgOtherDetail> detailList4 = msgOtherDetailService.listMsgOtherDetail(uid, page);
            count = msgOtherDetailService.countMsgOtherDetail(uid);
            if (detailList4 != null)
                for (MsgOtherDetail detail : detailList4) {
                    UserMsgVO vo = UserMsgVOFactory.create(detail);
                    if (vo != null) {
                        vo.setType(MSG_TYPE_OTHER);
                        list.add(vo);
                    } else {
                        count--;
                    }
                }
            break;
        }
        switch (type) {
            case MSG_TYPE_ORDER:
                userMsgReadStateService.readOrderMsg(uid);
                List<MsgOrderDetail> detailList = msgOrderDetailService.listMsgOrderDetail(uid, page);
                count = msgOrderDetailService.countMsgOrderDetail(uid);
                if (detailList != null)
                    for (MsgOrderDetail detail : detailList) {
                        JSONObject params = new JSONObject();
                        params.put("orderNo", detail.getOrderId());
                        if (detail.getType() == MsgTypeOrderTypeEnum.invite || detail.getType() == MsgTypeOrderTypeEnum.orderInvite)
                            params.put("orderHideNo", UserUtil.filterOrderId(detail.getOrderId()));
        GsonBuilder builder = new GsonBuilder();
        builder = getTimeDescJsonBuilder(builder);
        JSONObject root = new JSONObject();
        root.put("data", builder.create().toJson(list));
        root.put("count", count);
        out.print(JsonUtil.loadTrueResult(root));
    }
                        UserMsgVO msgVO = UserMsgVOFactory.create(detail, jumpDetailV2Service.getByTypeCache("order_search"), params);
                        msgVO.setType(MSG_TYPE_ORDER);
                        list.add(msgVO);
                    }
                break;
            case MSG_TYPE_MONEY:
                userMsgReadStateService.readMoneyMsg(uid);
                List<MsgMoneyDetail> detailList1 = msgMoneyDetailService.listMsgMoneyDetail(uid, page);
                count = msgMoneyDetailService.countMsgMoneyDetail(uid);
                if (detailList1 != null)
                    for (MsgMoneyDetail detail : detailList1) {
                        UserMsgVO msgVO = UserMsgVOFactory.create(detail);
                        msgVO.setType(MSG_TYPE_MONEY);
                        list.add(msgVO);
                    }
                break;
            case MSG_TYPE_ACCOUNT:
                userMsgReadStateService.readAccountMsg(uid);
                List<MsgAccountDetail> detailList2 = msgAccountDetailService.listMsgAccountDetail(uid, page);
                count = msgAccountDetailService.countMsgAccountDetail(uid);
                if (detailList2 != null)
                    for (MsgAccountDetail detail : detailList2) {
                        UserMsgVO msgVO = UserMsgVOFactory.create(detail);
                        msgVO.setType(MSG_TYPE_ACCOUNT);
                        list.add(msgVO);
                    }
                break;
            case MSG_TYPE_INVITE:
                userMsgReadStateService.readInviteMsg(uid);
                List<MsgInviteDetail> detailList3 = msgInviteDetailService.listMsgInviteDetail(uid, page);
                count = msgInviteDetailService.countMsgInviteDetail(uid);
                if (detailList3 != null)
                    for (MsgInviteDetail detail : detailList3) {
                        UserMsgVO vo = UserMsgVOFactory.create(detail);
                        if (vo != null) {
                            vo.setType(MSG_TYPE_INVITE);
                            list.add(vo);
                        } else {
                            count--;
                        }
                    }
                break;
            case MSG_TYPE_OTHER:
                userMsgReadStateService.readOtherMsg(uid);
                List<MsgOtherDetail> detailList4 = msgOtherDetailService.listMsgOtherDetail(uid, page);
                count = msgOtherDetailService.countMsgOtherDetail(uid);
                if (detailList4 != null)
                    for (MsgOtherDetail detail : detailList4) {
                        UserMsgVO vo = UserMsgVOFactory.create(detail);
                        if (vo != null) {
                            vo.setType(MSG_TYPE_OTHER);
                            list.add(vo);
                        } else {
                            count--;
                        }
                    }
                break;
        }
    /**
     * 获取消息未读数
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestSerializableByKey(key = "#acceptData.device")
    @RequestMapping(value = "getUnReadMsgCount", method = RequestMethod.POST)
    public void getUnReadMsgCount(AcceptData acceptData, Long uid, PrintWriter out) {
        GsonBuilder androidBuilder = new GsonBuilder().registerTypeAdapter(Integer.class,
                new JsonSerializer<Integer>() {
                    @Override
                    public JsonElement serialize(Integer value, Type theType, JsonSerializationContext context) {
                        if (value == null) {
                            return new JsonPrimitive("0");
                        } else {
                            if (value >= 100)
                                return new JsonPrimitive("99+");
                            else
                                return new JsonPrimitive(value);
                        }
                    }
                });
        if (uid == null) {
            // 如果用户未登录就读取设备消息
            UserMsgUnReadNum num = new UserMsgUnReadNum();
            num.setTypeAccount(0);
            num.setTypeInvite(0);
            num.setTypeMoney(0);
            num.setTypeOrder(0);
            num.setTypeOther(0);
            num.setTypeScore(0);
            num.setTypeSystem(0);
            JSONObject data = null;
            if ("android".equalsIgnoreCase(acceptData.getPlatform())) {
                data = JSONObject
                        .fromObject(androidBuilder.excludeFieldsWithoutExposeAnnotation().create().toJson(num));
            } else {
                data = JSONObject.fromObject(JsonUtil.getApiCommonGson().toJson(num));
            }
            data.put("totalCount", 0);
        GsonBuilder builder = new GsonBuilder();
        builder = getTimeDescJsonBuilder(builder);
        JSONObject root = new JSONObject();
        root.put("data", builder.create().toJson(list));
        root.put("count", count);
        out.print(JsonUtil.loadTrueResult(root));
    }
            try {
                UserSettingsVO vo = userCustomSettingsService.getMySettings(uid);
                if (vo != null && vo.getNoNewsRedDot() != null && vo.getNoNewsRedDot() == 1) {
                    data.put("totalCount", 0);
                }
            } catch (UserCustomSettingsException e) {
            }
    /**
     * 获取消息未读数
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestSerializableByKey(key = "#acceptData.device")
    @RequestMapping(value = "getUnReadMsgCount", method = RequestMethod.POST)
    public void getUnReadMsgCount(AcceptData acceptData, Long uid, PrintWriter out) {
        GsonBuilder androidBuilder = new GsonBuilder().registerTypeAdapter(Integer.class,
                new JsonSerializer<Integer>() {
                    @Override
                    public JsonElement serialize(Integer value, Type theType, JsonSerializationContext context) {
                        if (value == null) {
                            return new JsonPrimitive("0");
                        } else {
                            if (value >= 100)
                                return new JsonPrimitive("99+");
                            else
                                return new JsonPrimitive(value);
                        }
                    }
                });
        if (uid == null) {
            // 如果用户未登录就读取设备消息
            UserMsgUnReadNum num = new UserMsgUnReadNum();
            num.setTypeAccount(0);
            num.setTypeInvite(0);
            num.setTypeMoney(0);
            num.setTypeOrder(0);
            num.setTypeOther(0);
            num.setTypeScore(0);
            num.setTypeSystem(0);
            JSONObject data = null;
            if ("android".equalsIgnoreCase(acceptData.getPlatform())) {
                data = JSONObject
                        .fromObject(androidBuilder.excludeFieldsWithoutExposeAnnotation().create().toJson(num));
            } else {
                data = JSONObject.fromObject(JsonUtil.getApiCommonGson().toJson(num));
            }
            data.put("totalCount", 0);
            if (VersionUtil.greaterThan_1_5_50(acceptData.getPlatform(), acceptData.getVersion())) {
                int totalCount = msgDeviceReadStateService.getUnReadCount(acceptData.getDevice(),
                        "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, MsgDeviceReadState.TYPE_KEFU);
                data.put("totalCount", totalCount);
            }
            data.put("mineCount", 0);
            out.print(JsonUtil.loadTrueResult(data));
            return;
        }
        UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
            try {
                UserSettingsVO vo = userCustomSettingsService.getMySettings(uid);
                if (vo != null && vo.getNoNewsRedDot() != null && vo.getNoNewsRedDot() == 1) {
                    data.put("totalCount", 0);
                }
            } catch (UserCustomSettingsException e) {
            }
        int totalCount = num.getTypeAccount() + num.getTypeInvite() + num.getTypeMoney() + num.getTypeOrder()
                + num.getTypeScore() + num.getTypeSystem() + num.getTypeOther();
            if (VersionUtil.greaterThan_1_5_50(acceptData.getPlatform(), acceptData.getVersion())) {
                int totalCount = msgDeviceReadStateService.getUnReadCount(acceptData.getDevice(),
                        "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, MsgDeviceReadState.TYPE_KEFU);
                data.put("totalCount", totalCount);
            }
            data.put("mineCount", 0);
            out.print(JsonUtil.loadTrueResult(data));
            return;
        }
        UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
        // 1.5.50及以后的版本需要添加设备未读消息
        if (VersionUtil.greaterThan_1_5_50(acceptData.getPlatform(), acceptData.getVersion())) {
            totalCount += msgDeviceReadStateService.getUnReadCount(acceptData.getDevice(),
                    "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, MsgDeviceReadState.TYPE_KEFU);
        }
        int totalCount = num.getTypeAccount() + num.getTypeInvite() + num.getTypeMoney() + num.getTypeOrder()
                + num.getTypeScore() + num.getTypeSystem() + num.getTypeOther();
        JSONObject data = null;
        if ("android".equalsIgnoreCase(acceptData.getPlatform())) {
            data = JSONObject.fromObject(androidBuilder.excludeFieldsWithoutExposeAnnotation().create().toJson(num));
        } else {
            data = JSONObject.fromObject(JsonUtil.getApiCommonGson().toJson(num));
        }
        data.put("totalCount", totalCount);
        // "我的"选项角标
        int welfareCenterNews = 0;
        if (uid != null) {
            UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
            if (userInfoExtra != null) {
                if (userInfoExtra.getCouponNews() != null) {
                    welfareCenterNews = userInfoExtra.getCouponNews();
                }
            }
        }
        // 1.5.50及以后的版本需要添加设备未读消息
        if (VersionUtil.greaterThan_1_5_50(acceptData.getPlatform(), acceptData.getVersion())) {
            totalCount += msgDeviceReadStateService.getUnReadCount(acceptData.getDevice(),
                    "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, MsgDeviceReadState.TYPE_KEFU);
        }
        data.put("mineCount", welfareCenterNews);
        JSONObject data = null;
        if ("android".equalsIgnoreCase(acceptData.getPlatform())) {
            data = JSONObject.fromObject(androidBuilder.excludeFieldsWithoutExposeAnnotation().create().toJson(num));
        } else {
            data = JSONObject.fromObject(JsonUtil.getApiCommonGson().toJson(num));
        }
        data.put("totalCount", totalCount);
        // "我的"选项角标
        int welfareCenterNews = 0;
        if (uid != null) {
            UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
            if (userInfoExtra != null) {
                if (userInfoExtra.getCouponNews() != null) {
                    welfareCenterNews = userInfoExtra.getCouponNews();
                }
            }
        }
        try {
            UserSettingsVO vo = userCustomSettingsService.getMySettings(uid);
            if (vo != null && vo.getNoNewsRedDot() != null && vo.getNoNewsRedDot() == 1) {
                data.put("totalCount", 0);
            }
        } catch (UserCustomSettingsException e) {
            e.printStackTrace();
        }
        data.put("mineCount", welfareCenterNews);
        out.print(JsonUtil.loadTrueResult(data));
    }
        try {
            UserSettingsVO vo = userCustomSettingsService.getMySettings(uid);
            if (vo != null && vo.getNoNewsRedDot() != null && vo.getNoNewsRedDot() == 1) {
                data.put("totalCount", 0);
            }
        } catch (UserCustomSettingsException e) {
            e.printStackTrace();
        }
    private String getTimeDesc(Date nowDate, Date targetDate) {
        Calendar now = Calendar.getInstance();
        now.setTime(nowDate);
        if (TimeUtil.getGernalTime(targetDate.getTime(), "yyyy-MM-dd")
                .equalsIgnoreCase(TimeUtil.getGernalTime(now.getTimeInMillis(), "yyyy-MM-dd"))) {
            return "今天 " + TimeUtil.getGernalTime(targetDate.getTime(), "HH:mm");
        } else if (TimeUtil.getGernalTime(targetDate.getTime(), "yyyy-MM-dd")
                .equalsIgnoreCase(TimeUtil.getGernalTime(now.getTimeInMillis() - 1000 * 60 * 60 * 24L, "yyyy-MM-dd"))) {
            return "昨天 " + TimeUtil.getGernalTime(targetDate.getTime(), "HH:mm");
        } else {
            return TimeUtil.getGernalTime(targetDate.getTime(), "yyyy.MM.dd HH:mm");
        }
    }
        out.print(JsonUtil.loadTrueResult(data));
    }
    private GsonBuilder getTimeDescJsonBuilder(GsonBuilder builder) {
        builder = builder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
            @Override
            public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
                if (value == null) {
                    return new JsonPrimitive("");
                } else {
                    Calendar now = Calendar.getInstance();
                    return new JsonPrimitive(getTimeDesc(new Date(now.getTimeInMillis()), value));
                }
            }
        }).registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() {
            @Override
            public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) {
                if (value == null) {
                    return new JsonPrimitive("0");
                } else {
                    return new JsonPrimitive(BigDecimalUtil.getWithNoZera(value).toString());
                }
            }
        });
    private String getTimeDesc(Date nowDate, Date targetDate) {
        Calendar now = Calendar.getInstance();
        now.setTime(nowDate);
        if (TimeUtil.getGernalTime(targetDate.getTime(), "yyyy-MM-dd")
                .equalsIgnoreCase(TimeUtil.getGernalTime(now.getTimeInMillis(), "yyyy-MM-dd"))) {
            return "今天 " + TimeUtil.getGernalTime(targetDate.getTime(), "HH:mm");
        } else if (TimeUtil.getGernalTime(targetDate.getTime(), "yyyy-MM-dd")
                .equalsIgnoreCase(TimeUtil.getGernalTime(now.getTimeInMillis() - 1000 * 60 * 60 * 24L, "yyyy-MM-dd"))) {
            return "昨天 " + TimeUtil.getGernalTime(targetDate.getTime(), "HH:mm");
        } else {
            return TimeUtil.getGernalTime(targetDate.getTime(), "yyyy.MM.dd HH:mm");
        }
    }
        return builder;
    }
    private GsonBuilder getTimeDescJsonBuilder(GsonBuilder builder) {
        builder = builder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
            @Override
            public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
                if (value == null) {
                    return new JsonPrimitive("");
                } else {
                    Calendar now = Calendar.getInstance();
                    return new JsonPrimitive(getTimeDesc(new Date(now.getTimeInMillis()), value));
                }
            }
        }).registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() {
            @Override
            public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) {
                if (value == null) {
                    return new JsonPrimitive("0");
                } else {
                    return new JsonPrimitive(BigDecimalUtil.getWithNoZera(value).toString());
                }
            }
        });
    private void addRecommendGoods(Long uid, String device, String imei, String idfa) {
        TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(1, 50, imei, idfa,"");
        if (result != null && result.getTaoBaoGoodsBriefs() != null) {
            for (int i = 0; i < result.getTaoBaoGoodsBriefs().size(); i++) {
                if (result.getTaoBaoGoodsBriefs().get(i).getCouponAmount() == null
                        || result.getTaoBaoGoodsBriefs().get(i).getCouponAmount().compareTo(new BigDecimal(0)) <= 0) {
                    result.getTaoBaoGoodsBriefs().remove(i);
                    i--;
                }
            }
            // 随机几个
            int count = (int) (Math.random() * 3) + 1;
            Set<Integer> positionList = new HashSet<>();
            for (int i = 0; i < count; i++)
                if (result.getTaoBaoGoodsBriefs().size() > 0) {
                    positionList.add((int) (result.getTaoBaoGoodsBriefs().size() * Math.random()));
                }
        return builder;
    }
            if (positionList != null && positionList.size() > 0) {
                List<CommonGoods> goodsList = new ArrayList<>();
                for (Integer p : positionList) {
                    TaoBaoGoodsBrief goodsB = result.getTaoBaoGoodsBriefs().get(p);
                    try {
                        CommonGoods cgoods = commonGoodsService
                                .addOrUpdateCommonGoods(CommonGoodsFactory.create(goodsB));
                        goodsList.add(cgoods);
                    } catch (CommonGoodsException e) {
                        e.printStackTrace();
                    }
                }
                try {
                    recommendUserGoodsService.addRecommend(uid, device, "", goodsList);
                } catch (RecommendUserGoodsException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    private void addRecommendGoods(Long uid, String device, String imei, String idfa) {
        TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(1, 50, imei, idfa, "");
        if (result != null && result.getTaoBaoGoodsBriefs() != null) {
            for (int i = 0; i < result.getTaoBaoGoodsBriefs().size(); i++) {
                if (result.getTaoBaoGoodsBriefs().get(i).getCouponAmount() == null
                        || result.getTaoBaoGoodsBriefs().get(i).getCouponAmount().compareTo(new BigDecimal(0)) <= 0) {
                    result.getTaoBaoGoodsBriefs().remove(i);
                    i--;
                }
            }
            // 随机几个
            int count = (int) (Math.random() * 3) + 1;
            Set<Integer> positionList = new HashSet<>();
            for (int i = 0; i < count; i++)
                if (result.getTaoBaoGoodsBriefs().size() > 0) {
                    positionList.add((int) (result.getTaoBaoGoodsBriefs().size() * Math.random()));
                }
    private void addRecommendGoods(Long uid, String device) {
        List<QualityFactory> qfList = qualityFactoryService.listByMinSalesCountOrderByCreateTimeDesc(10000, 1, 20);
        if (qfList != null && qfList != null) {
            for (int i = 0; i < qfList.size(); i++) {
                if (qfList.get(i).getTaoBaoGoodsBrief().getCouponAmount() == null
                        || qfList.get(i).getTaoBaoGoodsBrief().getCouponAmount().compareTo(new BigDecimal(0)) <= 0) {
                    qfList.remove(i);
                    i--;
                }
            }
            // 随机几个
            int count = (int) (Math.random() * 3) + 1;
            Set<Integer> positionList = new HashSet<>();
            for (int i = 0; i < count; i++)
                if (qfList.size() > 0) {
                    positionList.add((int) (qfList.size() * Math.random()));
                }
            if (positionList != null && positionList.size() > 0) {
                List<CommonGoods> goodsList = new ArrayList<>();
                for (Integer p : positionList) {
                    TaoBaoGoodsBrief goodsB = result.getTaoBaoGoodsBriefs().get(p);
                    try {
                        CommonGoods cgoods = commonGoodsService
                                .addOrUpdateCommonGoods(CommonGoodsFactory.create(goodsB));
                        goodsList.add(cgoods);
                    } catch (CommonGoodsException e) {
                        e.printStackTrace();
                    }
                }
                try {
                    recommendUserGoodsService.addRecommend(uid, device, "", goodsList);
                } catch (RecommendUserGoodsException e) {
                    e.printStackTrace();
                }
            }
        }
    }
            if (positionList != null && positionList.size() > 0) {
                List<CommonGoods> goodsList = new ArrayList<>();
                for (Integer p : positionList) {
                    TaoBaoGoodsBrief goodsB = qfList.get(p).getTaoBaoGoodsBrief();
                    try {
                        CommonGoods cgoods = commonGoodsService
                                .addOrUpdateCommonGoods(CommonGoodsFactory.create(goodsB));
                        goodsList.add(cgoods);
                    } catch (CommonGoodsException e) {
                        e.printStackTrace();
                    }
                }
                try {
                    recommendUserGoodsService.addRecommend(uid, device, "", goodsList);
                } catch (RecommendUserGoodsException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    private void addRecommendGoods(Long uid, String device) {
        List<QualityFactory> qfList = qualityFactoryService.listByMinSalesCountOrderByCreateTimeDesc(10000, 1, 20);
        if (qfList != null && qfList != null) {
            for (int i = 0; i < qfList.size(); i++) {
                if (qfList.get(i).getTaoBaoGoodsBrief().getCouponAmount() == null
                        || qfList.get(i).getTaoBaoGoodsBrief().getCouponAmount().compareTo(new BigDecimal(0)) <= 0) {
                    qfList.remove(i);
                    i--;
                }
            }
            // 随机几个
            int count = (int) (Math.random() * 3) + 1;
            Set<Integer> positionList = new HashSet<>();
            for (int i = 0; i < count; i++)
                if (qfList.size() > 0) {
                    positionList.add((int) (qfList.size() * Math.random()));
                }
    /**
     * 获取首页消息
     *
     * @param acceptData
     * @param uid
     * @param page
     * @param out
     */
    @RequestMapping(value = "getHomeMsgList", method = RequestMethod.POST)
    public void getHomeMsgList(AcceptData acceptData, Long uid, int page, HttpSession session, PrintWriter out) {
        if (uid != null && uid == 0)
            uid = null;
        if (uid != null)
            userSystemMsgService.syncSystemZNX(uid);
            if (positionList != null && positionList.size() > 0) {
                List<CommonGoods> goodsList = new ArrayList<>();
                for (Integer p : positionList) {
                    TaoBaoGoodsBrief goodsB = qfList.get(p).getTaoBaoGoodsBrief();
                    try {
                        CommonGoods cgoods = commonGoodsService
                                .addOrUpdateCommonGoods(CommonGoodsFactory.create(goodsB));
                        goodsList.add(cgoods);
                    } catch (CommonGoodsException e) {
                        e.printStackTrace();
                    }
                }
                try {
                    recommendUserGoodsService.addRecommend(uid, device, "", goodsList);
                } catch (RecommendUserGoodsException e) {
                    e.printStackTrace();
                }
            }
        }
    }
        String device = acceptData.getDevice();
        if (device == null || device.trim().length() == 0) {
            out.print(JsonUtil.loadFalseResult("设备号不能为空"));
            return;
        }
    /**
     * 获取首页消息
     *
     * @param acceptData
     * @param uid
     * @param page
     * @param out
     */
    @RequestMapping(value = "getHomeMsgList", method = RequestMethod.POST)
    public void getHomeMsgList(AcceptData acceptData, Long uid, int page, HttpSession session, PrintWriter out) {
        if (uid != null && uid == 0)
            uid = null;
        if (uid != null)
            userSystemMsgService.syncSystemZNX(uid);
        if (page == 1) {
            if (uid != null)
                recommendUserGoodsService.syncDeviceAndUid(uid, acceptData.getDevice());
        String device = acceptData.getDevice();
        if (device == null || device.trim().length() == 0) {
            out.print(JsonUtil.loadFalseResult("设备号不能为空"));
            return;
        }
            boolean canAdd = false;
            int hour = Calendar.getInstance().get(Calendar.HOUR);
            RecommendUserGoods goods = recommendUserGoodsService.getLatestRecommendUserGoodsByDevice(device);
        if (page == 1) {
            if (uid != null)
                recommendUserGoodsService.syncDeviceAndUid(uid, acceptData.getDevice());
            if (goods == null) {
                canAdd = true;
            } else {
                // 是否和上次间隔时间足够
                if (System.currentTimeMillis() - goods.getCreateTime().getTime() >= 1000 * 60 * 60 * 4L) {
                    canAdd = true;
                }
            }
            boolean canAdd = false;
            int hour = Calendar.getInstance().get(Calendar.HOUR);
            RecommendUserGoods goods = recommendUserGoodsService.getLatestRecommendUserGoodsByDevice(device);
            // String key = "recommend-goods-user-" + uid;
            String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.recommendGoodsUser, device);
            if (Constant.IS_OUTNET) {
                if (canAdd && StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
                    if (Constant.IS_OUTNET)
                        redisManager.cacheCommonString(key, "1", 20);
                    if (hour < 12)
                        addRecommendGoods(uid, device);
                    else
                        addRecommendGoods(uid, device, acceptData.getImei(), acceptData.getIdfa());
                    session.removeAttribute("recommendgoods");
                }
            } else {
                if (canAdd) {
                    if (hour < 12)
                        addRecommendGoods(uid, device);
                    else
                        addRecommendGoods(uid, device, acceptData.getImei(), acceptData.getIdfa());
                }
            }
        }
            if (goods == null) {
                canAdd = true;
            } else {
                // 是否和上次间隔时间足够
                if (System.currentTimeMillis() - goods.getCreateTime().getTime() >= 1000 * 60 * 60 * 4L) {
                    canAdd = true;
                }
            }
        List<UserHomeMsgVO> volist = new ArrayList<>();
            // String key = "recommend-goods-user-" + uid;
            String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.recommendGoodsUser, device);
            if (Constant.IS_OUTNET) {
                if (canAdd && StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
                    if (Constant.IS_OUTNET)
                        redisManager.cacheCommonString(key, "1", 20);
                    if (hour < 12)
                        addRecommendGoods(uid, device);
                    else
                        addRecommendGoods(uid, device, acceptData.getImei(), acceptData.getIdfa());
                    session.removeAttribute("recommendgoods");
                }
            } else {
                if (canAdd) {
                    if (hour < 12)
                        addRecommendGoods(uid, device);
                    else
                        addRecommendGoods(uid, device, acceptData.getImei(), acceptData.getIdfa());
                }
            }
        }
        List<RecommendUserGoods> list = recommendUserGoodsService.listRecommendGoodsByDevice(device, page,
                Constant.PAGE_SIZE);
        long count = recommendUserGoodsService.countRecommendGoodsByDevice(device);
        List<UserHomeMsgVO> volist = new ArrayList<>();
        Date now = new Date();
        for (RecommendUserGoods goods : list) {
            UserHomeMsgVO vo = new UserHomeMsgVO();
            vo.setContent(goods.getRecommendDesc());
            vo.setCreateTime(getTimeDesc(now, goods.getCreateTime()));
            if (goods.getGoodsList().size() == 1)
                vo.setType(UserHomeMsgVO.TYPE_GOODS_1);
            else if (goods.getGoodsList().size() == 2)
                vo.setType(UserHomeMsgVO.TYPE_GOODS_2);
            else if (goods.getGoodsList().size() == 3)
                vo.setType(UserHomeMsgVO.TYPE_GOODS_3);
            List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
            for (CommonGoods cg : goods.getGoodsList()) {
                if (goods.getGoodsList().size() == 1)
                    cg.setPicture(TbImgUtil.getTBSizeImg(
                            StringUtil.isNullOrEmpty(cg.getPictureWhite()) ? cg.getPicture() : cg.getPictureWhite(),
                            400));
                else if (goods.getGoodsList().size() == 2)
                    cg.setPicture(TbImgUtil.getTBSizeImg(
                            StringUtil.isNullOrEmpty(cg.getPictureWhite()) ? cg.getPicture() : cg.getPictureWhite(),
                            320));
                else if (goods.getGoodsList().size() == 3)
                    cg.setPicture(TbImgUtil.getTBSizeImg(
                            StringUtil.isNullOrEmpty(cg.getPictureWhite()) ? cg.getPicture() : cg.getPictureWhite(),
                            220));
                TaoBaoGoodsBrief tbGoods = new TaoBaoGoodsBrief();
                if (cg.getCouponAmount() == null)
                    tbGoods.setCouponAmount(new BigDecimal(0));
                else
                    tbGoods.setCouponAmount(cg.getCouponAmount());
                tbGoods.setAuctionId(cg.getGoodsId());
                tbGoods.setPictUrl(cg.getPicture());
                goodsList.add(tbGoods);
            }
        List<RecommendUserGoods> list = recommendUserGoodsService.listRecommendGoodsByDevice(device, page,
                Constant.PAGE_SIZE);
        long count = recommendUserGoodsService.countRecommendGoodsByDevice(device);
            vo.setGoodsList(goodsList);
            vo.setTitle("猜你喜欢");
            vo.setIcon("http://img.flqapp.com/resource/msg/icon_msg_guess_like.png");
            volist.add(vo);
        }
        Date now = new Date();
        for (RecommendUserGoods goods : list) {
            UserHomeMsgVO vo = new UserHomeMsgVO();
            vo.setContent(goods.getRecommendDesc());
            vo.setCreateTime(getTimeDesc(now, goods.getCreateTime()));
            if (goods.getGoodsList().size() == 1)
                vo.setType(UserHomeMsgVO.TYPE_GOODS_1);
            else if (goods.getGoodsList().size() == 2)
                vo.setType(UserHomeMsgVO.TYPE_GOODS_2);
            else if (goods.getGoodsList().size() == 3)
                vo.setType(UserHomeMsgVO.TYPE_GOODS_3);
            List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
            for (CommonGoods cg : goods.getGoodsList()) {
                if (goods.getGoodsList().size() == 1)
                    cg.setPicture(TbImgUtil.getTBSizeImg(
                            StringUtil.isNullOrEmpty(cg.getPictureWhite()) ? cg.getPicture() : cg.getPictureWhite(),
                            400));
                else if (goods.getGoodsList().size() == 2)
                    cg.setPicture(TbImgUtil.getTBSizeImg(
                            StringUtil.isNullOrEmpty(cg.getPictureWhite()) ? cg.getPicture() : cg.getPictureWhite(),
                            320));
                else if (goods.getGoodsList().size() == 3)
                    cg.setPicture(TbImgUtil.getTBSizeImg(
                            StringUtil.isNullOrEmpty(cg.getPictureWhite()) ? cg.getPicture() : cg.getPictureWhite(),
                            220));
                TaoBaoGoodsBrief tbGoods = new TaoBaoGoodsBrief();
                if (cg.getCouponAmount() == null)
                    tbGoods.setCouponAmount(new BigDecimal(0));
                else
                    tbGoods.setCouponAmount(cg.getCouponAmount());
                tbGoods.setAuctionId(cg.getGoodsId());
                tbGoods.setPictUrl(cg.getPicture());
                goodsList.add(tbGoods);
            }
            vo.setGoodsList(goodsList);
            vo.setTitle("猜你喜欢");
            vo.setIcon("http://img.flqapp.com/resource/msg/icon_msg_guess_like.png");
            volist.add(vo);
        }
        Long time = (uid == null ? System.currentTimeMillis() : userInfoService.selectByPKey(uid).getCreatetime());
        if (volist.size() > 0 && volist.size() < Constant.PAGE_SIZE) {
            // 添加欢迎语
            // 创建时间在28号后的才有新人欢迎
            if ((time > TimeUtil.convertToTimeTemp("2019-01-28", "yyyy-MM-dd") || uid == null)) {
                UserHomeMsgVO vo = new UserHomeMsgVO();
                vo.setContent(String.format("恭喜你,成为%s的用户\n独家优惠券帮你省钱;\n参与奖金活动帮你赚钱;\n让%s成为你的省钱助手吧!",
                        Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()),
                        Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion())));
                vo.setTitle("新人欢迎");
                vo.setCreateTime(getTimeDesc(now, new Date(time)));
                vo.setType(UserHomeMsgVO.TYPE_WELCOME);
                volist.add(vo);
                count++;
            }
        }
        JSONObject root = new JSONObject();
        root.put("msgList", new Gson().toJson(volist));
        if (page == 1 && uid != null) {
            UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
            UserSystemMsg usm = userSystemMsgService.getLatestUserSystemMsg(uid);
            if (usm != null)
                root.put("systemMsg",
                        new UserSystemMsgVO(usm.getId(), usm.getType().name(), usm.getSolved(), "系统消息", usm.getTitle(),
                                usm.getTimeTag() == 1 ? "http://img.flqapp.com/resource/msg/icon_emergent.png" : "",
                                "http://img.flqapp.com/resource/msg/icon_msg_system.png",
                                getTimeDesc(now, usm.getCreateTime()), num.getTypeSystem()));
        }
        root.put("count", count);
        out.print(JsonUtil.loadTrueResult(root));
    }
        Long time = (uid == null ? System.currentTimeMillis() : userInfoService.selectByPKey(uid).getCreatetime());
    private UserCommonMsgVO getKeFuMsg(AcceptData acceptData) {
        MsgDeviceReadState kefuState = msgDeviceReadStateService.getByDeviceAndPlatformAndType(
                UserCommonMsgVO.TYPE_KEFU, acceptData.getDevice(),
                acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
        // 人工客服
        UserCommonMsgVO vo = new UserCommonMsgVO("http://img.flqapp.com/resource/msg/icon_kefu.png", "人工客服", new Date(),
                UserCommonMsgVO.TYPE_KEFU, "", false, null, null, 0);
        if (kefuState != null) {
            vo.setUnReadCount(kefuState.getUnReadCount() == null ? 0 : kefuState.getUnReadCount());
            if (!StringUtil.isNullOrEmpty(kefuState.getLatestContent()))
                vo.setLatestMsg(kefuState.getLatestContent());
        if (volist.size() > 0 && volist.size() < Constant.PAGE_SIZE) {
            // 添加欢迎语
            // 创建时间在28号后的才有新人欢迎
            if ((time > TimeUtil.convertToTimeTemp("2019-01-28", "yyyy-MM-dd") || uid == null)) {
                UserHomeMsgVO vo = new UserHomeMsgVO();
                vo.setContent(String.format("恭喜你,成为%s的用户\n独家优惠券帮你省钱;\n参与奖金活动帮你赚钱;\n让%s成为你的省钱助手吧!",
                        Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()),
                        Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion())));
                vo.setTitle("新人欢迎");
                vo.setCreateTime(getTimeDesc(now, new Date(time)));
                vo.setType(UserHomeMsgVO.TYPE_WELCOME);
                volist.add(vo);
                count++;
            }
        }
            if (vo.getUnReadCount() != null && vo.getUnReadCount() > 0)
                vo.setRead(false);
            else
                vo.setRead(true);
        JSONObject root = new JSONObject();
        root.put("msgList", new Gson().toJson(volist));
        if (page == 1 && uid != null) {
            UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
            UserSystemMsg usm = userSystemMsgService.getLatestUserSystemMsg(uid);
            if (usm != null)
                root.put("systemMsg",
                        new UserSystemMsgVO(usm.getId(), usm.getType().name(), usm.getSolved(), "系统消息", usm.getTitle(),
                                usm.getTimeTag() == 1 ? "http://img.flqapp.com/resource/msg/icon_emergent.png" : "",
                                "http://img.flqapp.com/resource/msg/icon_msg_system.png",
                                getTimeDesc(now, usm.getCreateTime()), num.getTypeSystem()));
        }
        root.put("count", count);
        out.print(JsonUtil.loadTrueResult(root));
    }
            if (kefuState.getLatestContentTime() != null)
                vo.setTime(kefuState.getLatestContentTime());
    private UserCommonMsgVO getKeFuMsg(AcceptData acceptData) {
        MsgDeviceReadState kefuState = msgDeviceReadStateService.getByDeviceAndPlatformAndType(
                UserCommonMsgVO.TYPE_KEFU, acceptData.getDevice(),
                acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
        // 人工客服
        UserCommonMsgVO vo = new UserCommonMsgVO("http://img.flqapp.com/resource/msg/icon_kefu.png", "人工客服", new Date(),
                UserCommonMsgVO.TYPE_KEFU, "", false, null, null, 0);
        if (kefuState != null) {
            vo.setUnReadCount(kefuState.getUnReadCount() == null ? 0 : kefuState.getUnReadCount());
            if (!StringUtil.isNullOrEmpty(kefuState.getLatestContent()))
                vo.setLatestMsg(kefuState.getLatestContent());
        } else
            vo.setRead(true);
            if (vo.getUnReadCount() != null && vo.getUnReadCount() > 0)
                vo.setRead(false);
            else
                vo.setRead(true);
        if (StringUtil.isNullOrEmpty(vo.getLatestMsg()))
            vo.setLatestMsg("[点击打开人工客服]");
            if (kefuState.getLatestContentTime() != null)
                vo.setTime(kefuState.getLatestContentTime());
        return vo;
    }
        } else
            vo.setRead(true);
    /**
     * 获取消息列表
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestSerializableByKey(key = "#acceptData.device")
    @RequestMapping(value = "getHomeMsgListNew", method = RequestMethod.POST)
    public void getHomeMsgListNew(AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid != null && uid == 0)
            uid = null;
        if (uid != null) {
            userSystemMsgService.syncSystemZNX(uid);
        }
        if (StringUtil.isNullOrEmpty(vo.getLatestMsg()))
            vo.setLatestMsg("[点击打开人工客服]");
        List<UserMsgCenter> listCenter = new ArrayList<>();
        return vo;
    }
        // 单条消息
        List<UserCommonMsgVO> commonMsgList = new ArrayList<>();
    /**
     * 获取消息列表
     *
     * @param acceptData
     * @param uid
     * @param page
     * @param type
     * @param out
     */
    @RequestSerializableByKey(key = "#acceptData.device")
    @RequestMapping(value = "getHomeMsgListNew", method = RequestMethod.POST)
    public void getHomeMsgListNew(AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid != null && uid == 0)
            uid = null;
        if (uid != null) {
            userSystemMsgService.syncSystemZNX(uid);
        }
        long currentTime = System.currentTimeMillis();
        List<UserMsgCenter> listCenter = new ArrayList<>();
        // 官宣任务
        if (uid != null) {
            MsgCommonDTO guanXuanMsg = msgConfigService.getGuanXuanMsg(acceptData.getSystem());
            if (guanXuanMsg != null && guanXuanMsg.getShow() == true) {
                boolean read = false;
                UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
                if (num != null && (num.getGuanXuanReadTime() != null
                        && guanXuanMsg.getUpdateTime().getTime() < num.getGuanXuanReadTime().getTime()))
                    read = true;
                // 查询是否已读
                if ((guanXuanMsg.getStartTime() != null && currentTime < guanXuanMsg.getStartTime().getTime())
                        || (guanXuanMsg.getEndTime() != null && currentTime > guanXuanMsg.getEndTime().getTime())) {
                    // 不显示
                } else
                    commonMsgList.add(new UserCommonMsgVO(guanXuanMsg.getIcon(), guanXuanMsg.getTitle(),
                            guanXuanMsg.getUpdateTime(), UserCommonMsgVO.TYPE_GUANXUAN, guanXuanMsg.getContent(), read,
                            guanXuanMsg.getJumpDetail(), guanXuanMsg.getParams(), 0));
            }
        }
        // 单条消息
        List<UserCommonMsgVO> commonMsgList = new ArrayList<>();
        // 板栗快省小助手
        MsgCommonDTO zhuShouMsg = msgConfigService.getZhuShouMsg(acceptData.getSystem());
        if (zhuShouMsg != null && zhuShouMsg.getShow() == true) {
            boolean read = false;
            MsgDeviceReadState state = msgDeviceReadStateService.getByDeviceAndPlatformAndType(
                    UserCommonMsgVO.TYPE_ZHUSHOU, acceptData.getDevice(),
                    acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
            if (state != null && state.getReadTime() != null
                    && zhuShouMsg.getUpdateTime().getTime() < state.getReadTime().getTime())
                read = true;
            // 查询是否已读
        long currentTime = System.currentTimeMillis();
            if ((zhuShouMsg.getStartTime() != null && currentTime < zhuShouMsg.getStartTime().getTime())
                    || (zhuShouMsg.getEndTime() != null && currentTime > zhuShouMsg.getEndTime().getTime())) {
                // 不显示
            } else
                commonMsgList.add(new UserCommonMsgVO(zhuShouMsg.getIcon(), zhuShouMsg.getTitle(),
                        zhuShouMsg.getUpdateTime(), UserCommonMsgVO.TYPE_ZHUSHOU, zhuShouMsg.getContent(), read,
                        zhuShouMsg.getJumpDetail(), zhuShouMsg.getParams(), 0));
        }
        // 官宣任务
        if (uid != null) {
            MsgCommonDTO guanXuanMsg = msgConfigService.getGuanXuanMsg(acceptData.getSystem());
            if (guanXuanMsg != null && guanXuanMsg.getShow() == true) {
                boolean read = false;
                UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
                if (num != null && (num.getGuanXuanReadTime() != null
                        && guanXuanMsg.getUpdateTime().getTime() < num.getGuanXuanReadTime().getTime()))
                    read = true;
                // 查询是否已读
                if ((guanXuanMsg.getStartTime() != null && currentTime < guanXuanMsg.getStartTime().getTime())
                        || (guanXuanMsg.getEndTime() != null && currentTime > guanXuanMsg.getEndTime().getTime())) {
                    // 不显示
                } else
                    commonMsgList.add(new UserCommonMsgVO(guanXuanMsg.getIcon(), guanXuanMsg.getTitle(),
                            guanXuanMsg.getUpdateTime(), UserCommonMsgVO.TYPE_GUANXUAN, guanXuanMsg.getContent(), read,
                            guanXuanMsg.getJumpDetail(), guanXuanMsg.getParams(), 0));
            }
        }
        // 人工客服
        commonMsgList.add(getKeFuMsg(acceptData));
        // 板栗快省小助手
        MsgCommonDTO zhuShouMsg = msgConfigService.getZhuShouMsg(acceptData.getSystem());
        if (zhuShouMsg != null && zhuShouMsg.getShow() == true) {
            boolean read = false;
            MsgDeviceReadState state = msgDeviceReadStateService.getByDeviceAndPlatformAndType(
                    UserCommonMsgVO.TYPE_ZHUSHOU, acceptData.getDevice(),
                    acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
            if (state != null && state.getReadTime() != null
                    && zhuShouMsg.getUpdateTime().getTime() < state.getReadTime().getTime())
                read = true;
            // 查询是否已读
        // 推荐记录
        DeviceActive deviceActive = deviceActiveService.getDeviceByDeviceAndPlatform(acceptData.getDevice(),
                acceptData.getDevice(), acceptData.getPlatform());
        if (deviceActive != null) {
            // 设备注册时间
            Date createTime = deviceActive.getCreateTime();
            List<PushGoods> list = pushGoodsService.listHistoryByPushTime(0, 1, uid, createTime, acceptData.getSystem());
            if (list != null && list.size() > 0) {
                MsgDeviceReadState state = msgDeviceReadStateService.getByDeviceAndPlatformAndType(
                        UserCommonMsgVO.TYPE_RECOMMEND, acceptData.getDevice(),
                        acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
                boolean read = false;
                if (state != null && state.getReadTime() != null
                        && list.get(0).getPushTime().getTime() < state.getReadTime().getTime())
                    read = true;
            if ((zhuShouMsg.getStartTime() != null && currentTime < zhuShouMsg.getStartTime().getTime())
                    || (zhuShouMsg.getEndTime() != null && currentTime > zhuShouMsg.getEndTime().getTime())) {
                // 不显示
            } else
                commonMsgList.add(new UserCommonMsgVO(zhuShouMsg.getIcon(), zhuShouMsg.getTitle(),
                        zhuShouMsg.getUpdateTime(), UserCommonMsgVO.TYPE_ZHUSHOU, zhuShouMsg.getContent(), read,
                        zhuShouMsg.getJumpDetail(), zhuShouMsg.getParams(), 0));
        }
                commonMsgList.add(new UserCommonMsgVO("http://img.flqapp.com/resource/msg/icon_recommend.png", "推荐记录",
                        list.get(0).getPushTime(), UserCommonMsgVO.TYPE_RECOMMEND, list.get(0).getContent(), read,
                        jumpDetailV2Service.getByTypeCache("recommend_list"), null, 0));
            }
        }
        // 人工客服
        commonMsgList.add(getKeFuMsg(acceptData));
        //
        // 推荐记录
        DeviceActive deviceActive = deviceActiveService.getDeviceByDeviceAndPlatform(acceptData.getDevice(),
                acceptData.getDevice(), acceptData.getPlatform());
        if (deviceActive != null) {
            // 设备注册时间
            Date createTime = deviceActive.getCreateTime();
            List<PushGoods> list = pushGoodsService.listHistoryByPushTime(0, 1, uid, createTime);
            if (list != null && list.size() > 0) {
                MsgDeviceReadState state = msgDeviceReadStateService.getByDeviceAndPlatformAndType(
                        UserCommonMsgVO.TYPE_RECOMMEND, acceptData.getDevice(),
                        acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
                boolean read = false;
                if (state != null && state.getReadTime() != null
                        && list.get(0).getPushTime().getTime() < state.getReadTime().getTime())
                    read = true;
        // list = pushGoodsService.listHistoryByPushTime(0, 1, uid, createTime);
                commonMsgList.add(new UserCommonMsgVO("http://img.flqapp.com/resource/msg/icon_recommend.png", "推荐记录",
                        list.get(0).getPushTime(), UserCommonMsgVO.TYPE_RECOMMEND, list.get(0).getContent(), read,
                        jumpDetailV2Service.getByTypeCache("recommend_list"), null, 0));
            }
        }
        // 1、活动区域
        int platformCode = Constant.getPlatformCode(acceptData.getPlatform());
        //
        List<Special> listSpecial = specialService.listByPlaceKey("msg_activities", platformCode,
                Integer.parseInt(acceptData.getVersion()), acceptData.getSystem());
        if (listSpecial != null && listSpecial.size() > 0) {
            for (Special special : listSpecial) {
        // list = pushGoodsService.listHistoryByPushTime(0, 1, uid, createTime);
                boolean needLogin = special.isJumpLogin();
                JumpDetailV2 jumpDetail = special.getJumpDetail();
                if (jumpDetail != null) {
                    jumpDetail.setNeedLogin(needLogin);
                    special.setJumpDetail(jumpDetail);
                }
        // 1、活动区域
        int platformCode = Constant.getPlatformCode(acceptData.getPlatform());
                UserMsgCenter msgCenter = new UserMsgCenter();
                msgCenter.setSpecial(special);
                listCenter.add(msgCenter);
            }
        }
        List<Special> listSpecial = specialService.listByPlaceKey("msg_activities", platformCode,
                Integer.parseInt(acceptData.getVersion()),acceptData.getSystem());
        if (listSpecial != null && listSpecial.size() > 0) {
            for (Special special : listSpecial) {
        // 2、消息区域
        if (uid != null && uid > 0) {
            int page = 1;
            List<UserMsgVO> list = new ArrayList<>();
            List<MsgOrderDetail> detailList = msgOrderDetailService.listMsgOrderDetail(uid, page);
            if (detailList != null && detailList.size() > 0) {
                for (MsgOrderDetail detail : detailList) {
                    JSONObject params = new JSONObject();
                    params.put("orderNo", detail.getOrderId());
                    if (detail.getType() == MsgTypeOrderTypeEnum.invite || detail.getType() == MsgTypeOrderTypeEnum.orderInvite)
                        params.put("orderHideNo", UserUtil.filterOrderId(detail.getOrderId()));
                    UserMsgVO userMsgVO = UserMsgVOFactory.create(detail,
                            jumpDetailV2Service.getByTypeCache("order_search"), params);
                    userMsgVO.setType(MSG_TYPE_ORDER);
                    list.add(userMsgVO);
                }
            }
                boolean needLogin = special.isJumpLogin();
                JumpDetailV2 jumpDetail = special.getJumpDetail();
                if (jumpDetail != null) {
                    jumpDetail.setNeedLogin(needLogin);
                    special.setJumpDetail(jumpDetail);
                }
            List<MsgMoneyDetail> detailList1 = msgMoneyDetailService.listMsgMoneyDetail(uid, page);
            if (detailList1 != null && detailList1.size() > 0) {
                for (MsgMoneyDetail detail : detailList1) {
                    UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
                    userMsgVO.setType(MSG_TYPE_MONEY);
                    list.add(userMsgVO);
                }
            }
                UserMsgCenter msgCenter = new UserMsgCenter();
                msgCenter.setSpecial(special);
                listCenter.add(msgCenter);
            }
        }
            List<MsgAccountDetail> detailList2 = msgAccountDetailService.listMsgAccountDetail(uid, page);
            if (detailList2 != null && detailList2.size() > 0) {
                for (MsgAccountDetail detail : detailList2) {
                    UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
                    userMsgVO.setType(MSG_TYPE_ACCOUNT);
                    list.add(userMsgVO);
                }
            }
        // 2、消息区域
        if (uid != null && uid > 0) {
            int page = 1;
            List<UserMsgVO> list = new ArrayList<>();
            List<MsgOrderDetail> detailList = msgOrderDetailService.listMsgOrderDetail(uid, page);
            if (detailList != null && detailList.size() > 0) {
                for (MsgOrderDetail detail : detailList) {
                    JSONObject params = new JSONObject();
                    params.put("orderNo", detail.getOrderId());
                    if (detail.getType() == MsgTypeOrderTypeEnum.invite    || detail.getType() == MsgTypeOrderTypeEnum.orderInvite)
                        params.put("orderHideNo", UserUtil.filterOrderId(detail.getOrderId()));
                    UserMsgVO userMsgVO = UserMsgVOFactory.create(detail,
                            jumpDetailV2Service.getByTypeCache("order_search"), params);
                    userMsgVO.setType(MSG_TYPE_ORDER);
                    list.add(userMsgVO);
                }
            }
            List<MsgInviteDetail> detailList3 = msgInviteDetailService.listMsgInviteDetail(uid, page);
            if (detailList3 != null && detailList3.size() > 0) {
                for (MsgInviteDetail detail : detailList3) {
                    UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
                    if (userMsgVO != null) {
                        userMsgVO.setType(MSG_TYPE_INVITE);
                        list.add(userMsgVO);
                    }
                }
            }
            List<MsgMoneyDetail> detailList1 = msgMoneyDetailService.listMsgMoneyDetail(uid, page);
            if (detailList1 != null && detailList1.size() > 0) {
                for (MsgMoneyDetail detail : detailList1) {
                    UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
                    userMsgVO.setType(MSG_TYPE_MONEY);
                    list.add(userMsgVO);
                }
            }
            List<MsgOtherDetail> detailList4 = msgOtherDetailService.listMsgOtherDetail(uid, page);
            if (detailList4 != null && detailList4.size() > 0) {
                for (MsgOtherDetail detail : detailList4) {
                    UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
                    if (userMsgVO != null) {
                        userMsgVO.setType(MSG_TYPE_OTHER);
                        list.add(userMsgVO);
                    }
                }
            }
            List<MsgAccountDetail> detailList2 = msgAccountDetailService.listMsgAccountDetail(uid, page);
            if (detailList2 != null && detailList2.size() > 0) {
                for (MsgAccountDetail detail : detailList2) {
                    UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
                    userMsgVO.setType(MSG_TYPE_ACCOUNT);
                    list.add(userMsgVO);
                }
            }
            if (list.size() > 0) {
                // 时间排序
                listSort(list);
            List<MsgInviteDetail> detailList3 = msgInviteDetailService.listMsgInviteDetail(uid, page);
            if (detailList3 != null && detailList3.size() > 0) {
                for (MsgInviteDetail detail : detailList3) {
                    UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
                    if (userMsgVO != null) {
                        userMsgVO.setType(MSG_TYPE_INVITE);
                        list.add(userMsgVO);
                    }
                }
            }
                if (list.size() >= 20) {
                    list = list.subList(0, 19);
                }
            List<MsgOtherDetail> detailList4 = msgOtherDetailService.listMsgOtherDetail(uid, page);
            if (detailList4 != null && detailList4.size() > 0) {
                for (MsgOtherDetail detail : detailList4) {
                    UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
                    if (userMsgVO != null) {
                        userMsgVO.setType(MSG_TYPE_OTHER);
                        list.add(userMsgVO);
                    }
                }
            }
                for (UserMsgVO userMsgVO : list) {
                    UserMsgCenter userMsgCenter = new UserMsgCenter();
                    userMsgCenter.setUserMsg(userMsgVO);
                    listCenter.add(userMsgCenter);
                }
            }
        }
            if (list.size() > 0) {
                // 时间排序
                listSort(list);
        // 3、添加欢迎语
        Long time = (uid == null ? System.currentTimeMillis() : userInfoService.selectByPKey(uid).getCreatetime());
        // 创建时间在28号后的才有新人欢迎
        if ((time > TimeUtil.convertToTimeTemp("2019-01-28", "yyyy-MM-dd") || uid == null)) {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("title", "新人欢迎");
            map.put("content",
                    String.format("恭喜你,成为%s的用户\n独家优惠券帮你省钱;\n参与奖金活动帮你赚钱;\n让%s成为你的省钱助手吧!",
                            Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()),
                            Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion())));
            map.put("createTime", new Date(time));
            UserMsgCenter msgCenternre = new UserMsgCenter();
            msgCenternre.setWelcomeMsg(map);
            listCenter.add(msgCenternre);
        }
                if (list.size() >= 20) {
                    list = list.subList(0, 19);
                }
        GsonBuilder builder = new GsonBuilder();
        builder = getTimeDescJsonBuilder(builder);
        JSONObject root = new JSONObject();
                for (UserMsgVO userMsgVO : list) {
                    UserMsgCenter userMsgCenter = new UserMsgCenter();
                    userMsgCenter.setUserMsg(userMsgVO);
                    listCenter.add(userMsgCenter);
                }
            }
        }
        if (uid != null && uid > 0) {
            UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
            UserSystemMsg usm = userSystemMsgService.getLatestUserSystemMsg(uid);
            if (usm != null) {
                // commonMsgList.add(0,new UserCommonMsgVO(icon, "系统消息", time,
                // type, latestMsg, ,
                // jumpDetailV2Service.getByTypeCache("system_msg"), params));
                root.put("systemMsg",
                        new UserSystemMsgVO(usm.getId(), usm.getType().name(), usm.getSolved(), "系统消息", usm.getTitle(),
                                usm.getTimeTag() == 1 ? "http://img.flqapp.com/resource/msg/icon_emergent.png" : "",
                                "http://img.flqapp.com/resource/msg/icon_msg_system.png",
                                getTimeDesc(new Date(), usm.getCreateTime()), num.getTypeSystem()));
            }
        }
        // 3、添加欢迎语
        Long time = (uid == null ? System.currentTimeMillis() : userInfoService.selectByPKey(uid).getCreatetime());
        // 创建时间在28号后的才有新人欢迎
        if ((time > TimeUtil.convertToTimeTemp("2019-01-28", "yyyy-MM-dd") || uid == null)) {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("title", "新人欢迎");
            map.put("content",
                    String.format("恭喜你,成为%s的用户\n独家优惠券帮你省钱;\n参与奖金活动帮你赚钱;\n让%s成为你的省钱助手吧!",
                            Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()),
                            Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion())));
            map.put("createTime", new Date(time));
            UserMsgCenter msgCenternre = new UserMsgCenter();
            msgCenternre.setWelcomeMsg(map);
            listCenter.add(msgCenternre);
        }
        /**
         * 提醒大图
         */
        if (!"douyin".equalsIgnoreCase(acceptData.getChannel())) {
            MsgCommonDTO notify = msgConfigService.getNotifyMsg(acceptData.getSystem());
        GsonBuilder builder = new GsonBuilder();
        builder = getTimeDescJsonBuilder(builder);
        JSONObject root = new JSONObject();
            if (notify != null && notify.getShow() == true) {
                boolean read = false;
                MsgDeviceReadState state = msgDeviceReadStateService.getByDeviceAndPlatformAndType(
                        UserCommonMsgVO.TYPE_NOTIFY, acceptData.getDevice(),
                        acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
                if (state != null && state.getReadTime() != null
                        && zhuShouMsg.getUpdateTime().getTime() < state.getReadTime().getTime())
                    read = true;
                if (notify.getJumpDetail() == null)
                    read = true;
                // 查询是否已读
                UserCommonMsgVO vo = new UserCommonMsgVO(notify.getIcon(), notify.getTitle(), notify.getUpdateTime(),
                        UserCommonMsgVO.TYPE_NOTIFY, notify.getContent(), read, notify.getJumpDetail(),
                        notify.getParams(), 0);
                vo.setPicture(notify.getPicture());
                root.put("notifyMsg", builder.create().toJson(vo));
            }
        }
        root.put("list", builder.create().toJson(listCenter));
        root.put("commonList", builder.create().toJson(commonMsgList));
        root.put("count", listCenter.size());
        out.print(JsonUtil.loadTrueResult(root));
    }
        if (uid != null && uid > 0) {
            UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
            UserSystemMsg usm = userSystemMsgService.getLatestUserSystemMsg(uid);
            if (usm != null) {
                // commonMsgList.add(0,new UserCommonMsgVO(icon, "系统消息", time,
                // type, latestMsg, ,
                // jumpDetailV2Service.getByTypeCache("system_msg"), params));
                root.put("systemMsg",
                        new UserSystemMsgVO(usm.getId(), usm.getType().name(), usm.getSolved(), "系统消息", usm.getTitle(),
                                usm.getTimeTag() == 1 ? "http://img.flqapp.com/resource/msg/icon_emergent.png" : "",
                                "http://img.flqapp.com/resource/msg/icon_msg_system.png",
                                getTimeDesc(new Date(), usm.getCreateTime()), num.getTypeSystem()));
            }
        }
    public static void listSort(List<UserMsgVO> list) {
        Collections.sort(list, new Comparator<UserMsgVO>() {
            @Override
            public int compare(UserMsgVO o1, UserMsgVO o2) {
                if (o1.getTime().getTime() > o2.getTime().getTime()) {
                    return -1;
                } else if (o1 == o2) {
                    return 0;
                } else {
                    return 1;
                }
            }
        });
    }
        /**
         * 提醒大图
         */
        if (!"douyin".equalsIgnoreCase(acceptData.getChannel())) {
            MsgCommonDTO notify = msgConfigService.getNotifyMsg(acceptData.getSystem());
    /**
     * 获取系统消息列表
     *
     * @param acceptData
     * @param uid
     * @param page
     * @param out
     */
    @RequestMapping(value = "getSystemMsgList", method = RequestMethod.POST)
    public void getSystemMsgList(AcceptData acceptData, Long uid, int page, PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
            if (notify != null && notify.getShow() == true) {
                boolean read = false;
                MsgDeviceReadState state = msgDeviceReadStateService.getByDeviceAndPlatformAndType(
                        UserCommonMsgVO.TYPE_NOTIFY, acceptData.getDevice(),
                        acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
                if (state != null && state.getReadTime() != null
                        && zhuShouMsg.getUpdateTime().getTime() < state.getReadTime().getTime())
                    read = true;
                if (notify.getJumpDetail() == null)
                    read = true;
                // 查询是否已读
                UserCommonMsgVO vo = new UserCommonMsgVO(notify.getIcon(), notify.getTitle(), notify.getUpdateTime(),
                        UserCommonMsgVO.TYPE_NOTIFY, notify.getContent(), read, notify.getJumpDetail(),
                        notify.getParams(), 0);
                vo.setPicture(notify.getPicture());
                root.put("notifyMsg", builder.create().toJson(vo));
            }
        }
        root.put("list", builder.create().toJson(listCenter));
        root.put("commonList", builder.create().toJson(commonMsgList));
        root.put("count", listCenter.size());
        out.print(JsonUtil.loadTrueResult(root));
    }
        List<UserSystemMsgVO> voList = new ArrayList<>();
        List<UserSystemMsg> list = userSystemMsgService.listUserSystemMsg(uid, page, Constant.PAGE_SIZE);
        if (list != null)
            for (UserSystemMsg usm : list) {
                voList.add(new UserSystemMsgVO(usm.getId(), usm.getType().name(), usm.getSolved(), usm.getTitle(),
                        usm.getContent(),
                        usm.getTimeTag() == 1 ? "http://img.flqapp.com/resource/msg/icon_emergent.png" : "", null,
                        usm.getCreateTime().getTime() + "", 0));
            }
        long count = userSystemMsgService.countUserSystemMsg(uid);
    public static void listSort(List<UserMsgVO> list) {
        Collections.sort(list, new Comparator<UserMsgVO>() {
            @Override
            public int compare(UserMsgVO o1, UserMsgVO o2) {
                if (o1.getTime().getTime() > o2.getTime().getTime()) {
                    return -1;
                } else if (o1 == o2) {
                    return 0;
                } else {
                    return 1;
                }
            }
        });
    }
        userMsgReadStateService.readUserSystemMsg(uid);
    /**
     * 获取系统消息列表
     *
     * @param acceptData
     * @param uid
     * @param page
     * @param out
     */
    @RequestMapping(value = "getSystemMsgList", method = RequestMethod.POST)
    public void getSystemMsgList(AcceptData acceptData, Long uid, int page, PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        JSONObject root = new JSONObject();
        root.put("data", voList);
        root.put("count", count);
        out.print(JsonUtil.loadTrueResult(root));
    }
        List<UserSystemMsgVO> voList = new ArrayList<>();
        List<UserSystemMsg> list = userSystemMsgService.listUserSystemMsg(uid, page, Constant.PAGE_SIZE);
        if (list != null)
            for (UserSystemMsg usm : list) {
                voList.add(new UserSystemMsgVO(usm.getId(), usm.getType().name(), usm.getSolved(), usm.getTitle(),
                        usm.getContent(),
                        usm.getTimeTag() == 1 ? "http://img.flqapp.com/resource/msg/icon_emergent.png" : "", null,
                        usm.getCreateTime().getTime() + "", 0));
            }
        long count = userSystemMsgService.countUserSystemMsg(uid);
    /**
     * 设置问题已经解决
     *
     * @param acceptData
     * @param uid
     * @param id
     * @param out
     */
    @RequestMapping(value = "setSystemMsgSolved", method = RequestMethod.POST)
    public void setSystemMsgSolved(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        userMsgReadStateService.readUserSystemMsg(uid);
        if (id == null) {
            out.print(JsonUtil.loadFalseResult(2, "消息ID为空"));
            return;
        }
        JSONObject root = new JSONObject();
        root.put("data", voList);
        root.put("count", count);
        out.print(JsonUtil.loadTrueResult(root));
    }
        try {
            userSystemMsgService.setSystemMsgSolved(uid, id);
            out.print(JsonUtil.loadTrueResult(""));
        } catch (UserSystemMsgException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
    }
    /**
     * 设置问题已经解决
     *
     * @param acceptData
     * @param uid
     * @param id
     * @param out
     */
    @RequestMapping(value = "setSystemMsgSolved", method = RequestMethod.POST)
    public void setSystemMsgSolved(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
    @RequestMapping(value = "setAllMsgRead", method = RequestMethod.POST)
    public void setAllMsgRead(AcceptData acceptData, Long uid, PrintWriter out) {
        msgDeviceReadStateService.setAllMsgRead(acceptData.getDevice(),
                "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2);
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        if (id == null) {
            out.print(JsonUtil.loadFalseResult(2, "消息ID为空"));
            return;
        }
        // 初始化读取状态
        msgDeviceReadStateService.initReadState(acceptData.getDevice(),
                "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, UserCommonMsgVO.TYPE_RECOMMEND);
        msgDeviceReadStateService.initReadState(acceptData.getDevice(),
                "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, UserCommonMsgVO.TYPE_ZHUSHOU);
        try {
            userSystemMsgService.setSystemMsgSolved(uid, id);
            out.print(JsonUtil.loadTrueResult(""));
        } catch (UserSystemMsgException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
    }
        // 设置设备消息所有已读
        msgDeviceReadStateService.setAllMsgRead(acceptData.getDevice(),
                "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2);
    @RequestMapping(value = "setAllMsgRead", method = RequestMethod.POST)
    public void setAllMsgRead(AcceptData acceptData, Long uid, PrintWriter out) {
        msgDeviceReadStateService.setAllMsgRead(acceptData.getDevice(),
                "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2);
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
        int totalNum = num.getTypeAccount() + num.getTypeInvite() + num.getTypeMoney() + num.getTypeOrder()
                + num.getTypeScore() + num.getTypeSystem() + num.getTypeOther();
        if (totalNum == 0) {
            out.print(JsonUtil.loadFalseResult(1, "没有未读消息"));
            return;
        } else
            userMsgReadStateService.setAllMsgRead(uid);
        out.print(JsonUtil.loadTrueResult(""));
    }
        // 初始化读取状态
        msgDeviceReadStateService.initReadState(acceptData.getDevice(),
                "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, UserCommonMsgVO.TYPE_RECOMMEND);
        msgDeviceReadStateService.initReadState(acceptData.getDevice(),
                "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, UserCommonMsgVO.TYPE_ZHUSHOU);
    /**
     * 阅读通用消息
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "readCommonMsg", method = RequestMethod.POST)
    public void readCommonMsg(AcceptData acceptData, Long uid, String type, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(type)) {
            out.print(JsonUtil.loadFalseResult(2, "请上传type"));
            return;
        }
        if (type.equalsIgnoreCase(UserCommonMsgVO.TYPE_GUANXUAN)) {
            if (uid != null) {
                UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
                UserMsgUnReadNum update = new UserMsgUnReadNum();
                update.setId(num.getId());
                update.setGuanXuanReadTime(new Date());
                update.setUpdateTime(new Date());
                userMsgReadStateService.updateSelective(update);
            }
        // 设置设备消息所有已读
        msgDeviceReadStateService.setAllMsgRead(acceptData.getDevice(),
                "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2);
        } else if (type.equalsIgnoreCase(UserCommonMsgVO.TYPE_RECOMMEND)) {
            msgDeviceReadStateService.setDeviceMsgRead(UserCommonMsgVO.TYPE_RECOMMEND, acceptData.getDevice(),
                    (acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2));
        } else if (type.equalsIgnoreCase(UserCommonMsgVO.TYPE_ZHUSHOU)) {
            msgDeviceReadStateService.setDeviceMsgRead(UserCommonMsgVO.TYPE_ZHUSHOU, acceptData.getDevice(),
                    (acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2));
        }
        out.print(JsonUtil.loadTrueResult(""));
    }
        UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
        int totalNum = num.getTypeAccount() + num.getTypeInvite() + num.getTypeMoney() + num.getTypeOrder()
                + num.getTypeScore() + num.getTypeSystem() + num.getTypeOther();
        if (totalNum == 0) {
            out.print(JsonUtil.loadFalseResult(1, "没有未读消息"));
            return;
        } else
            userMsgReadStateService.setAllMsgRead(uid);
        out.print(JsonUtil.loadTrueResult(""));
    }
    /**
     * 上传最近的客服消息
     *
     * @param acceptData
     * @param content
     * @param out
     */
    @RequestMapping(value = "uploadLatestKeFuMsg", method = RequestMethod.POST)
    public void uploadLatestKeFuMsg(AcceptData acceptData, String content, Long datetime, PrintWriter out) {
    /**
     * 阅读通用消息
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "readCommonMsg", method = RequestMethod.POST)
    public void readCommonMsg(AcceptData acceptData, Long uid, String type, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(type)) {
            out.print(JsonUtil.loadFalseResult(2, "请上传type"));
            return;
        }
        if (type.equalsIgnoreCase(UserCommonMsgVO.TYPE_GUANXUAN)) {
            if (uid != null) {
                UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
                UserMsgUnReadNum update = new UserMsgUnReadNum();
                update.setId(num.getId());
                update.setGuanXuanReadTime(new Date());
                update.setUpdateTime(new Date());
                userMsgReadStateService.updateSelective(update);
            }
        if (StringUtil.isNullOrEmpty(content) || datetime == null) {
            out.print(JsonUtil.loadFalseResult("参数不完整"));
            return;
        }
        msgDeviceReadStateService.addUnreadDeviceMsg(MsgDeviceReadState.TYPE_KEFU, acceptData.getDevice(),
                "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, 0, content, new Date(datetime));
        out.print(JsonUtil.loadTrueResult(""));
    }
        } else if (type.equalsIgnoreCase(UserCommonMsgVO.TYPE_RECOMMEND)) {
            msgDeviceReadStateService.setDeviceMsgRead(UserCommonMsgVO.TYPE_RECOMMEND, acceptData.getDevice(),
                    (acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2));
        } else if (type.equalsIgnoreCase(UserCommonMsgVO.TYPE_ZHUSHOU)) {
            msgDeviceReadStateService.setDeviceMsgRead(UserCommonMsgVO.TYPE_ZHUSHOU, acceptData.getDevice(),
                    (acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2));
        }
        out.print(JsonUtil.loadTrueResult(""));
    }
    /**
     * 上传最近的客服消息
     *
     * @param acceptData
     * @param content
     * @param out
     */
    @RequestMapping(value = "uploadLatestKeFuMsg", method = RequestMethod.POST)
    public void uploadLatestKeFuMsg(AcceptData acceptData, String content, Long datetime, PrintWriter out) {
    /**
     * 删除消息
     *
     * @param acceptData
     * @param type
     * @param id
     * @param out
     */
    @RequestMapping(value = "deleteMsg", method = RequestMethod.POST)
    public void deleteMsg(AcceptData acceptData, String type, Long id, Long uid, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(type) || id == null || uid == null) {
            out.print(JsonUtil.loadFalseResult("参数不完整"));
            return;
        }
        if (StringUtil.isNullOrEmpty(content) || datetime == null) {
            out.print(JsonUtil.loadFalseResult("参数不完整"));
            return;
        }
        msgDeviceReadStateService.addUnreadDeviceMsg(MsgDeviceReadState.TYPE_KEFU, acceptData.getDevice(),
                "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, 0, content, new Date(datetime));
        out.print(JsonUtil.loadTrueResult(""));
    }
        switch (type) {
            case MSG_TYPE_ORDER:
                MsgOrderDetail msgOrderDetail = msgOrderDetailService.selectByPrimaryKey(id);
                if (msgOrderDetail != null && msgOrderDetail.getUser().getId().longValue() == uid.longValue()) {
                    msgOrderDetailService.deleteByPrimaryKey(id);
                }
                break;
            case MSG_TYPE_MONEY:
                MsgMoneyDetail moneyDetail = msgMoneyDetailService.selectByPrimaryKey(id);
                if (moneyDetail != null && moneyDetail.getUser().getId().longValue() == uid.longValue()) {
                    msgMoneyDetailService.deleteByPrimaryKey(id);
                }
                break;
            case MSG_TYPE_ACCOUNT:
                MsgAccountDetail accountDetail = msgAccountDetailService.selectByPrimaryKey(id);
                if (accountDetail != null && accountDetail.getUser().getId().longValue() == uid.longValue()) {
                    msgAccountDetailService.deleteByPrimaryKey(id);
                }
                break;
            case MSG_TYPE_INVITE:
                MsgInviteDetail inviteDetail = msgInviteDetailService.selectByPrimaryKey(id);
                if (inviteDetail != null && inviteDetail.getUser().getId().longValue() == uid.longValue()) {
                    msgInviteDetailService.deleteByPrimaryKey(id);
                }
                break;
            case MSG_TYPE_OTHER:
                MsgOtherDetail otherDetail = msgOtherDetailService.selectByPrimaryKey(id);
                if (otherDetail != null && otherDetail.getUser().getId().longValue() == uid.longValue()) {
                    msgOtherDetailService.deleteByPrimaryKey(id);
                }
                break;
        }
        out.print(JsonUtil.loadTrueResult(""));
    }
    /**
     * 删除消息
     * @param acceptData
     * @param type
     * @param id
     * @param out
     */
    @RequestMapping(value = "deleteMsg", method = RequestMethod.POST)
    public void deleteMsg(AcceptData acceptData, String type, Long id, Long uid, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(type) || id == null || uid == null) {
            out.print(JsonUtil.loadFalseResult("参数不完整"));
            return;
        }
        switch (type) {
        case MSG_TYPE_ORDER:
            MsgOrderDetail msgOrderDetail  = msgOrderDetailService.selectByPrimaryKey(id);
            if (msgOrderDetail != null && msgOrderDetail.getUser().getId().longValue() == uid.longValue()) {
                msgOrderDetailService.deleteByPrimaryKey(id);
            }
            break;
        case MSG_TYPE_MONEY:
            MsgMoneyDetail moneyDetail  = msgMoneyDetailService.selectByPrimaryKey(id);
            if (moneyDetail != null && moneyDetail.getUser().getId().longValue() == uid.longValue()) {
                msgMoneyDetailService.deleteByPrimaryKey(id);
            }
            break;
        case MSG_TYPE_ACCOUNT:
            MsgAccountDetail accountDetail  = msgAccountDetailService.selectByPrimaryKey(id);
            if (accountDetail != null && accountDetail.getUser().getId().longValue() == uid.longValue()) {
                msgAccountDetailService.deleteByPrimaryKey(id);
            }
            break;
        case MSG_TYPE_INVITE:
            MsgInviteDetail inviteDetail  = msgInviteDetailService.selectByPrimaryKey(id);
            if (inviteDetail != null && inviteDetail.getUser().getId().longValue() == uid.longValue()) {
                msgInviteDetailService.deleteByPrimaryKey(id);
            }
            break;
        case MSG_TYPE_OTHER:
            MsgOtherDetail otherDetail  = msgOtherDetailService.selectByPrimaryKey(id);
            if (otherDetail != null && otherDetail.getUser().getId().longValue() == uid.longValue()) {
                msgOtherDetailService.deleteByPrimaryKey(id);
            }
            break;
        }
        out.print(JsonUtil.loadTrueResult(""));
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConfigControllerV2.java
@@ -188,7 +188,7 @@
        List<FloatAD> listAD = new ArrayList<FloatAD>();
        List<FloatImgDetailVO> listVO = new ArrayList<FloatImgDetailVO>();
        List<FloatAD> list = floatADService.getValidFloatADCache(FloatAD.POSITION_INDEX, null, platform,
                Integer.parseInt(version));
                Integer.parseInt(version),acceptData.getSystem());
        if (list != null && !list.isEmpty())
            listAD.addAll(list);
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java
@@ -626,7 +626,7 @@
            List<GoodsEvaluate> listNew = new ArrayList<GoodsEvaluate>();
            List<GoodsEvaluate> list = goodsEvaluateService.queryMaterialsCache((page - 1) * Constant.PAGE_SIZE,
                    Constant.PAGE_SIZE, type);
                    Constant.PAGE_SIZE, type,acceptData.getSystem());
            if (!VersionUtil.greaterThan_2_1_1(acceptData.getPlatform(), acceptData.getVersion())) {
                listNew.addAll(list);
@@ -775,7 +775,7 @@
                }
            });
            Gson gson = gsonBuilder.create();
            long count = goodsEvaluateService.countValidMaterials(type);
            long count = goodsEvaluateService.countValidMaterials(type,acceptData.getSystem());
            JSONArray jsonArray = new JSONArray();
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -127,1889 +127,1887 @@
@RequestMapping("api/v2/goods")
public class GoodsControllerV2 {
    @Resource
    private BusinessSystemService businessSystemService;
    @Resource
    private BusinessSystemService businessSystemService;
    @Resource
    private ConfigService configService;
    @Resource
    private ConfigService configService;
    @Resource
    private TBPidService tbPidService;
    @Resource
    private TBPidService tbPidService;
    @Resource
    private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
    @Resource
    private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
    @Resource
    private RedisManager redisManager;
    @Resource
    private RedisManager redisManager;
    @Resource
    private TaoBaoShopService taoBaoShopService;
    @Resource
    private TaoBaoShopService taoBaoShopService;
    @Resource
    private ShamUserService shamUserService;
    @Resource
    private ShamUserService shamUserService;
    @Resource
    private CollectionGoodsV2Service collectionGoodsV2Service;
    @Resource
    private CollectionGoodsV2Service collectionGoodsV2Service;
    @Resource
    private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
    @Resource
    private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
    @Resource
    private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
    @Resource
    private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
    @Resource
    private TaoBaoUnionConfigService taoBaoUnionConfigService;
    @Resource
    private TaoBaoUnionConfigService taoBaoUnionConfigService;
    @Resource
    private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
    @Resource
    private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
    @Resource
    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
    @Resource
    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
    @Resource
    private SystemClientParamsService systemClientParamsService;
    @Resource
    private SystemClientParamsService systemClientParamsService;
    @Resource
    private UserGoodsStorageService userGoodsStorageService;
    @Resource
    private UserGoodsStorageService userGoodsStorageService;
    @Resource
    private ConfigTaoLiJinService configTaoLiJinService;
    @Resource
    private ConfigTaoLiJinService configTaoLiJinService;
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @Resource
    private UserMoneyExtraService userMoneyExtraService;
    @Resource
    private UserMoneyExtraService userMoneyExtraService;
    @Resource
    private ScanHistoryV2Service scanHistoryV2Service;
    @Resource
    private ScanHistoryV2Service scanHistoryV2Service;
    @Resource
    private TLJBuyGoodsService tljBuyGoodsService;
    @Resource
    private TLJBuyGoodsService tljBuyGoodsService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private JDGoodsCacheUtil jdGoodsCacheUtil;
    @Resource
    private JDGoodsCacheUtil jdGoodsCacheUtil;
    @Resource
    private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
    @Resource
    private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
    @Resource
    private IntegralGetService integralGetService;
    @Resource
    private IntegralGetService integralGetService;
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    @Resource
    private JDGoodsClassService jdGoodsClassService;
    @Resource
    private JDGoodsClassService jdGoodsClassService;
    @Resource
    private TLJFreeBuyGoodsService tljFreeBuyGoodsService;
    @Resource
    private TLJFreeBuyGoodsService tljFreeBuyGoodsService;
    @Resource
    private UserTaoLiJinNewbiesService userTaoLiJinNewbiesService;
    @Resource
    private UserTaoLiJinNewbiesService userTaoLiJinNewbiesService;
    @Resource
    private UserVIPInfoService userVIPInfoService;
    @Resource
    private UserVIPInfoService userVIPInfoService;
    @Resource
    private UserVipConfigService userVipConfigService;
    @Resource
    private UserVipConfigService userVipConfigService;
    @Resource
    private GoodsEvaluateService goodsEvaluateService;
    @Resource
    private GoodsEvaluateService goodsEvaluateService;
    @Resource
    private UserLevelManager userLevelManager;
    @Resource
    private UserLevelManager userLevelManager;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    private ConfigParamsDTO getParamsDTO(String platform, String version, Long uid) {
        UserLevelEnum level = UserLevelEnum.daRen;
        if (uid != null && uid > 0) {
            level = userLevelManager.getUserLevel(uid);
            if (level != null) {
                if (System.currentTimeMillis() < Constant.NEW_ORDER_FANLI_RULE_TIME)
                    level = UserLevelUtil.getOldLevel(level);
            }
        }
        if (level == null)
            level = UserLevelEnum.daRen;
        return orderHongBaoMoneyComputeService.getShowComputeRate(platform, version, level);
    }
    private ConfigParamsDTO getParamsDTO(String platform, String version, Long uid) {
        UserLevelEnum level = UserLevelEnum.daRen;
        if (uid != null && uid > 0) {
            level = userLevelManager.getUserLevel(uid);
            if (level != null) {
                if (System.currentTimeMillis() < Constant.NEW_ORDER_FANLI_RULE_TIME)
                    level = UserLevelUtil.getOldLevel(level);
            }
        }
        if (level == null)
            level = UserLevelEnum.daRen;
        return orderHongBaoMoneyComputeService.getShowComputeRate(platform, version, level);
    }
    private TaoBaoGoodsBrief filterDaTaoKeGoodsInfo(TaoBaoGoodsBrief goods) {
        try {
            DaTaoKeFilterResult result = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goods);
            if (result.getFilterType() == DaTaoKeFilterResult.FILTER_TYPE_COUPON
                    || result.getFilterType() == DaTaoKeFilterResult.FILTER_TYPE_PRICE_AND_COUPON) {
                // 缓存基础链接
                String dpid = null;
                if (TaoBaoUtil.isSpecialGoods(goods.getMaterialLibType())) {
                    dpid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT;
                } else {
                    dpid = TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID;
                }
                String link = taoBaoGoodsCacheUtil.getBaseConvertLink(goods.getAuctionId(), dpid);
                if (!StringUtil.isNullOrEmpty(link)) {
                    // result.getGoods().setCouponLink(link);
                    return result.getGoods();
                } else {
                    link = DaTaoKeApiUtil.convertLink(goods.getAuctionId(), dpid);
                    if (!StringUtil.isNullOrEmpty(link)) {
                        // result.getGoods().setCouponLink(link);
                        taoBaoGoodsCacheUtil.cacheBaseConvertLink(goods.getAuctionId(), dpid, link);
                    }
                    return result.getGoods();
                }
            }
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
    private TaoBaoGoodsBrief filterDaTaoKeGoodsInfo(TaoBaoGoodsBrief goods) {
        try {
            DaTaoKeFilterResult result = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goods);
            if (result.getFilterType() == DaTaoKeFilterResult.FILTER_TYPE_COUPON
                    || result.getFilterType() == DaTaoKeFilterResult.FILTER_TYPE_PRICE_AND_COUPON) {
                // 缓存基础链接
                String dpid = null;
                if (TaoBaoUtil.isSpecialGoods(goods.getMaterialLibType())) {
                    dpid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT;
                } else {
                    dpid = TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID;
                }
                String link = taoBaoGoodsCacheUtil.getBaseConvertLink(goods.getAuctionId(), dpid);
                if (!StringUtil.isNullOrEmpty(link)) {
                    // result.getGoods().setCouponLink(link);
                    return result.getGoods();
                } else {
                    link = DaTaoKeApiUtil.convertLink(goods.getAuctionId(), dpid);
                    if (!StringUtil.isNullOrEmpty(link)) {
                        // result.getGoods().setCouponLink(link);
                        taoBaoGoodsCacheUtil.cacheBaseConvertLink(goods.getAuctionId(), dpid, link);
                    }
                    return result.getGoods();
                }
            }
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
        return goods;
    }
        return goods;
    }
    /**
     * 淘宝商品详情
     *
     * @param acceptData
     * @param id
     * @param uid
     * @param from
     * @param out
     */
    @RequestMapping(value = "getDetailTB", method = RequestMethod.POST)
    public void getDetialTB(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
        if (id == null) {
            out.print(JsonUtil.loadFalseResult(1, "商品id不能为空"));
            return;
        }
    /**
     * 淘宝商品详情
     *
     * @param acceptData
     * @param id
     * @param uid
     * @param from
     * @param out
     */
    @RequestMapping(value = "getDetailTB", method = RequestMethod.POST)
    public void getDetialTB(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
        if (id == null) {
            out.print(JsonUtil.loadFalseResult(1, "商品id不能为空"));
            return;
        }
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
        }
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
        }
        GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
        extraVO.setIsNative(false);
        GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
        extraVO.setIsNative(false);
        // IOS是否正在上线
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
            String version = acceptData.getVersion();
            extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version),acceptData.getSystem()));
        }
        // IOS是否正在上线
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
            String version = acceptData.getVersion();
            extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version), acceptData.getSystem()));
        }
        long startTime = java.lang.System.currentTimeMillis();
        long startTime = java.lang.System.currentTimeMillis();
        // 获取淘客参数
        ClientTBPid clientTBPid = null;
        // 获取淘客参数
        ClientTBPid clientTBPid = null;
        // 用户未登录
        if (acceptData.getPlatform().equalsIgnoreCase("android")) {
            clientTBPid = tbPidService.getAndroidDefault();
        } else {
            clientTBPid = tbPidService.getIOSDefault();
        }
        // 用户未登录
        if (acceptData.getPlatform().equalsIgnoreCase("android")) {
            clientTBPid = tbPidService.getAndroidDefault();
        } else {
            clientTBPid = tbPidService.getIOSDefault();
        }
        LogHelper.test("获取PID耗时:" + (java.lang.System.currentTimeMillis() - startTime));
        LogHelper.test("获取PID耗时:" + (java.lang.System.currentTimeMillis() - startTime));
        // final List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        // 是否在服务端进行转链
        boolean convertInServer = configService.isConvertTaoBaoLinkInServer(acceptData.getSystem());
        // final List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        // 是否在服务端进行转链
        boolean convertInServer = configService.isConvertTaoBaoLinkInServer(acceptData.getSystem());
        TaoBaoGoodsBrief goods = null;
        TaoBaoGoodsBrief goods = null;
        if (!convertInServer) {
            try {
                goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(id);
                if (goods == null) {
                    TaoKeAppInfo app = new TaoKeAppInfo();
                    app.setAppKey(TaoBaoConstant.TAOBAO_COMMON_APPKEY);
                    app.setAppSecret(TaoBaoConstant.TAOBAO_COMMON_APPSECRET);
                    app.setPid(TaoBaoConstant.TAOBAO_COMMON_PID);
                    app.setAdzoneId(TaoBaoConstant.TAOBAO_COMMON_PID.split("_")[3]);
                    goods = TaoKeApiUtil.searchGoodsDetail(id, app);
        if (!convertInServer) {
            try {
                goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(id);
                if (goods == null) {
                    TaoKeAppInfo app = new TaoKeAppInfo();
                    app.setAppKey(TaoBaoConstant.TAOBAO_COMMON_APPKEY);
                    app.setAppSecret(TaoBaoConstant.TAOBAO_COMMON_APPSECRET);
                    app.setPid(TaoBaoConstant.TAOBAO_COMMON_PID);
                    app.setAdzoneId(TaoBaoConstant.TAOBAO_COMMON_PID.split("_")[3]);
                    goods = TaoKeApiUtil.searchGoodsDetail(id, app);
                    final TaoBaoGoodsBrief finalGoods = goods;
                    if (goods != null) {
                        ThreadUtil.run(new Runnable() {
                            @Override
                            public void run() {
                                taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(finalGoods);
                            }
                        });
                    }
                }
            } catch (TaobaoGoodsDownException e) {
                // 商品下架
                ThreadUtil.run(new Runnable() {
                    final TaoBaoGoodsBrief finalGoods = goods;
                    if (goods != null) {
                        ThreadUtil.run(new Runnable() {
                            @Override
                            public void run() {
                                taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(finalGoods);
                            }
                        });
                    }
                }
            } catch (TaobaoGoodsDownException e) {
                // 商品下架
                ThreadUtil.run(new Runnable() {
                    public void run() {
                        taoBaoGoodsUpdateService.offlineTaoBaoGoods(id);
                    }
                });
            }
                    public void run() {
                        taoBaoGoodsUpdateService.offlineTaoBaoGoods(id);
                    }
                });
            }
        } else {
            final String clientPid = clientTBPid.getPid();
            String appId = clientPid.split("_")[2];
            TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
            TaoKeAppInfo app = new TaoKeAppInfo();
            app.setAdzoneId(clientPid.split("_")[3]);
            app.setAppKey(config.getAppKey());
            app.setAppSecret(config.getAppSecret());
            app.setPid(clientPid);
        } else {
            final String clientPid = clientTBPid.getPid();
            String appId = clientPid.split("_")[2];
            TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
            TaoKeAppInfo app = new TaoKeAppInfo();
            app.setAdzoneId(clientPid.split("_")[3]);
            app.setAppKey(config.getAppKey());
            app.setAppSecret(config.getAppSecret());
            app.setPid(clientPid);
            try {
                goods = TaoKeApiUtil.searchGoodsDetail(id, app);
                if (goods.getTkRate() == null || new BigDecimal(0).compareTo(goods.getTkRate()) == 0) {
                    TaoBaoGoodsBrief linkInfo = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app);
                    if (linkInfo != null) {
                        goods.setAuctionUrl(linkInfo.getAuctionUrl());
                        goods.setCouponLink(linkInfo.getCouponLink());
                        goods.setTkRate(linkInfo.getTkRate());
                    }
                }
            try {
                goods = TaoKeApiUtil.searchGoodsDetail(id, app);
                if (goods.getTkRate() == null || new BigDecimal(0).compareTo(goods.getTkRate()) == 0) {
                    TaoBaoGoodsBrief linkInfo = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app);
                    if (linkInfo != null) {
                        goods.setAuctionUrl(linkInfo.getAuctionUrl());
                        goods.setCouponLink(linkInfo.getCouponLink());
                        goods.setTkRate(linkInfo.getTkRate());
                    }
                }
            } catch (NumberFormatException e) {
                e.printStackTrace();
            } catch (TaobaoGoodsDownException e) {
                ThreadUtil.run(new Runnable() {
                    public void run() {
                        taoBaoGoodsUpdateService.offlineTaoBaoGoods(id);
                    }
                });
            }
            } catch (NumberFormatException e) {
                e.printStackTrace();
            } catch (TaobaoGoodsDownException e) {
                ThreadUtil.run(new Runnable() {
                    public void run() {
                        taoBaoGoodsUpdateService.offlineTaoBaoGoods(id);
                    }
                });
            }
        }
        }
        if (goods != null) {
            final TaoBaoGoodsBrief newGoods = goods;
            ThreadUtil.run(new Runnable() {
                public void run() {
                    try {
                        // 更新商品
                        LogHelper.test("更新商品详情:" + newGoods.getAuctionId());
                        taoBaoGoodsUpdateService.updateTaoBaoGoods(newGoods);
                    } catch (TaobaoGoodsUpdateException e) {
        if (goods != null) {
            final TaoBaoGoodsBrief newGoods = goods;
            ThreadUtil.run(new Runnable() {
                public void run() {
                    try {
                        // 更新商品
                        LogHelper.test("更新商品详情:" + newGoods.getAuctionId());
                        taoBaoGoodsUpdateService.updateTaoBaoGoods(newGoods);
                    } catch (TaobaoGoodsUpdateException e) {
                    }
                }
            });
        }
                    }
                }
            });
        }
        TaoBaoGoodsBrief tb = goods;
        TaoBaoGoodsBrief tb = goods;
        if (tb == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
            return;
        }
        if (tb == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
            return;
        }
        if (tb.getImgList() == null) {
            tb.setImgList(new ArrayList<>());
        }
        if (tb.getImgList() == null) {
            tb.setImgList(new ArrayList<>());
        }
        // tb.getImgList().add(0, tb.getPictUrl());
        // tb.getImgList().add(0, tb.getPictUrl());
        List<String> finalImgList = new ArrayList<>();
        for (String img : tb.getImgList()) {
            finalImgList.add(TbImgUtil.getTBSizeImg(img, 600));
        }
        List<String> finalImgList = new ArrayList<>();
        for (String img : tb.getImgList()) {
            finalImgList.add(TbImgUtil.getTBSizeImg(img, 600));
        }
        if (finalImgList.size() == 0) {
            finalImgList.add(tb.getPictUrl());
        }
        if (finalImgList.size() == 0) {
            finalImgList.add(tb.getPictUrl());
        }
        if (!StringUtil.isNullOrEmpty(tb.getPictUrlWhite()))
            finalImgList.add(0, tb.getPictUrlWhite());
        if (!StringUtil.isNullOrEmpty(tb.getPictUrlWhite()))
            finalImgList.add(0, tb.getPictUrlWhite());
        // 移除相同图片
        if (finalImgList.size() > 0)
            for (int i = 0; i < finalImgList.size(); i++) {
                if (i < finalImgList.size() - 1)
                    if (TbImgUtil.getTBSizeImg(finalImgList.get(i), 600)
                            .equalsIgnoreCase(TbImgUtil.getTBSizeImg(finalImgList.get(i + 1), 600))) {
                        finalImgList.remove(i--);
                    }
            }
        // 移除相同图片
        if (finalImgList.size() > 0)
            for (int i = 0; i < finalImgList.size(); i++) {
                if (i < finalImgList.size() - 1)
                    if (TbImgUtil.getTBSizeImg(finalImgList.get(i), 600)
                            .equalsIgnoreCase(TbImgUtil.getTBSizeImg(finalImgList.get(i + 1), 600))) {
                        finalImgList.remove(i--);
                    }
            }
        tb.setImgList(finalImgList);
        tb.setImgList(finalImgList);
        // 大淘客商品过滤
        try {
            goods = filterDaTaoKeGoodsInfo(goods);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
        // 大淘客商品过滤
        try {
            goods = filterDaTaoKeGoodsInfo(goods);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO);
        if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
            goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
            goodsDetail.getMoneyInfo().setShareMoney("¥" + TaoBaoUtil.getGoodsHongBaoMoney(goods,
                    hongBaoManageService.getShareRate(UserLevelEnum.superVIP), true));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
        goodsDetail.getMoneyInfo()
                .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(),acceptData.getSystem()));
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO);
        if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
            goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
            goodsDetail.getMoneyInfo().setShareMoney("¥" + TaoBaoUtil.getGoodsHongBaoMoney(goods,
                    hongBaoManageService.getShareRate(UserLevelEnum.superVIP), true));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
        goodsDetail.getMoneyInfo()
                .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(), acceptData.getSystem()));
        if (TaoBaoUtil.isYUShou(goods)) {
            if (!StringUtil.isNullOrEmpty(goods.getPresaleDiscountFeeText())) {
                if (goodsDetail.getLabels() == null)
                    goodsDetail.setLabels(new ArrayList<>());
                goodsDetail.getLabels().add(new ClientTextStyleVO(goods.getPresaleDiscountFeeText(), "#FF2B4E"));
            }
        }
        // 在标题添加优惠信息
        if (TaoBaoUtil.isYUShou(goods)) {
            if (!StringUtil.isNullOrEmpty(goods.getPresaleDiscountFeeText())) {
                if (goodsDetail.getLabels() == null)
                    goodsDetail.setLabels(new ArrayList<>());
                goodsDetail.getLabels().add(new ClientTextStyleVO(goods.getPresaleDiscountFeeText(), "#FF2B4E"));
            }
        }
        // 在标题添加优惠信息
        // 店铺信息
        TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(id, goods.getSellerId());
        if (shop != null) {
            String shopLink = shop.getShopLink();
            if (StringUtil.isNullOrEmpty(shopLink)) {
                shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId()));
            }
            goodsDetail.setShopInfo(ShopInfoVOFactory.convertTaoBaoShop(shop));
        }
        // 店铺信息
        TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(id, goods.getSellerId());
        if (shop != null) {
            String shopLink = shop.getShopLink();
            if (StringUtil.isNullOrEmpty(shopLink)) {
                shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId()));
            }
            goodsDetail.setShopInfo(ShopInfoVOFactory.convertTaoBaoShop(shop));
        }
        // 免单商品
        if (!StringUtil.isNullOrEmpty(from) && "miandan".equals(from)) {
            MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
            if (goodsDetail.isHasCoupon()) {
                moneyInfo.setFanliMoney("¥" + goodsDetail.getCouponPrice());
            } else {
                moneyInfo.setFanliMoney("¥" + goodsDetail.getZkPrice());
            }
            goodsDetail.setMoneyInfo(moneyInfo);
        }
        // 免单商品
        if (!StringUtil.isNullOrEmpty(from) && "miandan".equals(from)) {
            MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
            if (goodsDetail.isHasCoupon()) {
                moneyInfo.setFanliMoney("¥" + goodsDetail.getCouponPrice());
            } else {
                moneyInfo.setFanliMoney("¥" + goodsDetail.getZkPrice());
            }
            goodsDetail.setMoneyInfo(moneyInfo);
        }
        extraVO.setTbPidInfo(clientTBPid);
        extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img.html?id=" + id);
        extraVO.setTbPidInfo(clientTBPid);
        extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img.html?id=" + id);
        // 分享赚人提示
        MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
        List<ShamUser> listShareUser = new ArrayList<ShamUser>();
        if (moneyInfo != null) {
            String shareMoney = moneyInfo.getShareMoney();
            if (goods.getBiz30day() >= 1000) {
                listShareUser = shamUserService.listRandShareUser(10, new BigDecimal(shareMoney.replaceAll("¥", "")), 1,
                        5);
            }
        }
        extraVO.setListShareUser(listShareUser);
        // 分享赚人提示
        MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
        List<ShamUser> listShareUser = new ArrayList<ShamUser>();
        if (moneyInfo != null) {
            String shareMoney = moneyInfo.getShareMoney();
            if (goods.getBiz30day() >= 1000) {
                listShareUser = shamUserService.listRandShareUser(10, new BigDecimal(shareMoney.replaceAll("¥", "")), 1,
                        5);
            }
        }
        extraVO.setListShareUser(listShareUser);
        // 领券人列表
        List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
        if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null
                && goods.getCouponAmount().compareTo(new BigDecimal(0)) > 0) {
            if (goods.getBiz30day() >= 1000) {
                listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
            }
        }
        extraVO.setListCouponUser(listCouponUser);
        // 领券人列表
        List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
        if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null
                && goods.getCouponAmount().compareTo(new BigDecimal(0)) > 0) {
            if (goods.getBiz30day() >= 1000) {
                listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
            }
        }
        extraVO.setListCouponUser(listCouponUser);
        if (uid != null) {
            // 是否加入收藏
            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
                    Constant.SOURCE_TYPE_TAOBAO);
            extraVO.setCollected(collectionGoods != null ? true : false);
            // 是否加入选品库
            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_TAOBAO));
        }
        if (uid != null) {
            // 是否加入收藏
            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
                    Constant.SOURCE_TYPE_TAOBAO);
            extraVO.setCollected(collectionGoods != null ? true : false);
            // 是否加入选品库
            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_TAOBAO));
        }
        // 测试
        SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system,
                "goods_detail_jump_taobao");
        if ("1".equalsIgnoreCase((params.getValue() + "").trim())) {
            extraVO.setIsNative(true);
        }
        // 测试
        SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system,
                "goods_detail_jump_taobao");
        if ("1".equalsIgnoreCase((params.getValue() + "").trim())) {
            extraVO.setIsNative(true);
        }
        String h5Url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()),
                Constant.systemCommonConfig.getShareGoodsPagePath(), "", id + "");
        String h5Url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()),
                Constant.systemCommonConfig.getShareGoodsPagePath(), "", id + "");
        extraVO.setH5Url(h5Url);
        extraVO.setH5Url(h5Url);
        String helpLink = null;
        boolean fanliValid = true;
        boolean shareValid = true;
        int moneyType = 1;
        String helpLink = null;
        boolean fanliValid = true;
        boolean shareValid = true;
        int moneyType = 1;
        if (from != null && from.equals("taolijin_buy")) {
            // 查询分享库
            TLJBuyGoods buyGoods = tljBuyGoodsService.selectByAuctionIdAndDay(id,
                    TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
            if (buyGoods == null) {
                out.print(JsonUtil.loadFalseResult(2, "自购立减红包过期"));
                return;
            }
        if (from != null && from.equals("taolijin_buy")) {
            // 查询分享库
            TLJBuyGoods buyGoods = tljBuyGoodsService.selectByAuctionIdAndDay(id,
                    TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
            if (buyGoods == null) {
                out.print(JsonUtil.loadFalseResult(2, "自购立减红包过期"));
                return;
            }
            moneyType = 2;
            fanliValid = true;
            shareValid = false;
            helpLink = configService.getValue(ConfigKeyEnum.zigoulijianNofanliHelp.getKey(),acceptData.getSystem());
            moneyType = 2;
            fanliValid = true;
            shareValid = false;
            helpLink = configService.getValue(ConfigKeyEnum.zigoulijianNofanliHelp.getKey(), acceptData.getSystem());
            BigDecimal tljHongBao = TaoBaoUtil.getGoodsHongBaoMoney(goods, TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE,
                    false);
            BigDecimal tljHongBao = TaoBaoUtil.getGoodsHongBaoMoney(goods, TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE,
                    false);
            ReduceHongBao reduceHongBao = new ReduceHongBao();
            reduceHongBao.setLeft(buyGoods.getLeftHongBaoCount());
            reduceHongBao.setMoney(tljHongBao.toString());
            reduceHongBao.setName("付款立减 ");
            reduceHongBao.setTip("当日领取,当日内使用,过期失效");
            reduceHongBao.setTotal(buyGoods.getTotalHongBaoCount());
            ReduceHongBao reduceHongBao = new ReduceHongBao();
            reduceHongBao.setLeft(buyGoods.getLeftHongBaoCount());
            reduceHongBao.setMoney(tljHongBao.toString());
            reduceHongBao.setName("付款立减 ");
            reduceHongBao.setTip("当日领取,当日内使用,过期失效");
            reduceHongBao.setTotal(buyGoods.getTotalHongBaoCount());
            OtherInfo otherInfo = new OtherInfo();
            otherInfo.setReduceHongBao(reduceHongBao);
            goodsDetail.setOtherInfo(otherInfo);
            OtherInfo otherInfo = new OtherInfo();
            otherInfo.setReduceHongBao(reduceHongBao);
            goodsDetail.setOtherInfo(otherInfo);
            // 1.6.5后改为福利价
            if (com.yeshi.fanli.util.VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {
                if (goodsDetail.getCouponPrice() != null
                        && goodsDetail.getCouponPrice().compareTo(new BigDecimal(0)) > 0)
                    goodsDetail.setCouponPrice(goodsDetail.getCouponPrice().subtract(tljHongBao));
                else
                    goodsDetail.setZkPrice(goodsDetail.getZkPrice().subtract(tljHongBao));
            }
        } else if (from != null && from.equals("taolijin_free_buy")) {
            TLJFreeBuyGoods freeGoods = tljFreeBuyGoodsService.selectByAuctionIdAndDay(id,
                    TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
            if (freeGoods == null) {
                out.print(JsonUtil.loadFalseResult(2, "免单商品已下架"));
                return;
            }
            // 1.6.5后改为福利价
            if (com.yeshi.fanli.util.VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {
                if (goodsDetail.getCouponPrice() != null
                        && goodsDetail.getCouponPrice().compareTo(new BigDecimal(0)) > 0)
                    goodsDetail.setCouponPrice(goodsDetail.getCouponPrice().subtract(tljHongBao));
                else
                    goodsDetail.setZkPrice(goodsDetail.getZkPrice().subtract(tljHongBao));
            }
        } else if (from != null && from.equals("taolijin_free_buy")) {
            TLJFreeBuyGoods freeGoods = tljFreeBuyGoodsService.selectByAuctionIdAndDay(id,
                    TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
            if (freeGoods == null) {
                out.print(JsonUtil.loadFalseResult(2, "免单商品已下架"));
                return;
            }
            fanliValid = true;
            shareValid = false;
            BigDecimal couponPrice = goodsDetail.getCouponPrice();
            if (couponPrice == null)
                couponPrice = goodsDetail.getZkPrice();
            fanliValid = true;
            shareValid = false;
            BigDecimal couponPrice = goodsDetail.getCouponPrice();
            if (couponPrice == null)
                couponPrice = goodsDetail.getZkPrice();
            NewUserHongBao newUserHongBao = new NewUserHongBao();
            newUserHongBao.setMoney(couponPrice.setScale(2).toString());
            newUserHongBao.setName("新人红包 ");
            newUserHongBao.setTip("当日领取,当日内使用,过期失效");
            newUserHongBao.setLeft(1);
            newUserHongBao.setTotal(1);
            NewUserHongBao newUserHongBao = new NewUserHongBao();
            newUserHongBao.setMoney(couponPrice.setScale(2).toString());
            newUserHongBao.setName("新人红包 ");
            newUserHongBao.setTip("当日领取,当日内使用,过期失效");
            newUserHongBao.setLeft(1);
            newUserHongBao.setTotal(1);
            OtherInfo otherInfo = new OtherInfo();
            otherInfo.setReduceHongBao(newUserHongBao);
            goodsDetail.setOtherInfo(otherInfo);
            OtherInfo otherInfo = new OtherInfo();
            otherInfo.setReduceHongBao(newUserHongBao);
            goodsDetail.setOtherInfo(otherInfo);
            // 专属标签
            List<ClientTextStyleVO> labels = new ArrayList<ClientTextStyleVO>();
            labels.add(new ClientTextStyleVO("新人专属", "#FE0014"));
            labels.add(new ClientTextStyleVO("实付0元", "#FF9600"));
            goodsDetail.setLabels(labels);
            // 专属标签
            List<ClientTextStyleVO> labels = new ArrayList<ClientTextStyleVO>();
            labels.add(new ClientTextStyleVO("新人专属", "#FE0014"));
            labels.add(new ClientTextStyleVO("实付0元", "#FF9600"));
            goodsDetail.setLabels(labels);
        } else {// 普通购买
            OtherInfo otherInfo = new OtherInfo();
            RewardCouponVO rewardCoupon = new RewardCouponVO();
            rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
            JSONObject params1 = new JSONObject();
            if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
                params1.put("url", configService.getValue(ConfigKeyEnum.specialGuideRewardCouponLink.getKey(),acceptData.getSystem()));
            else
                params1.put("url", userVipConfigService.getValueByKey("vip_link"));
            rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney());
            if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
                rewardCoupon.setDesc("返");
                params1.put("url", userVipConfigService.getValueByKey("vip_link"));
                rewardCoupon.getJumpDetail().setNeedLogin(true);
            } else
                rewardCoupon.setDesc("用返利奖励券最高返");
            rewardCoupon.setParams(params1.toString());
        } else {// 普通购买
            OtherInfo otherInfo = new OtherInfo();
            RewardCouponVO rewardCoupon = new RewardCouponVO();
            rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
            JSONObject params1 = new JSONObject();
            if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
                params1.put("url", configService.getValue(ConfigKeyEnum.specialGuideRewardCouponLink.getKey(), acceptData.getSystem()));
            else
                params1.put("url", userVipConfigService.getValueByKey("vip_link"));
            rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney());
            if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
                rewardCoupon.setDesc("返");
                params1.put("url", userVipConfigService.getValueByKey("vip_link"));
                rewardCoupon.getJumpDetail().setNeedLogin(true);
            } else
                rewardCoupon.setDesc("用返利奖励券最高返");
            rewardCoupon.setParams(params1.toString());
            otherInfo.setRewardCoupon(rewardCoupon);
            if ("ios".equalsIgnoreCase(acceptData.getPlatform())
                    && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()),acceptData.getSystem()))
                otherInfo.setRewardCoupon(null);
            otherInfo.setRewardCoupon(rewardCoupon);
            if ("ios".equalsIgnoreCase(acceptData.getPlatform())
                    && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()))
                otherInfo.setRewardCoupon(null);
            goodsDetail.setOtherInfo(otherInfo);
        }
        extraVO.setFanliValid(fanliValid);
        extraVO.setShareValid(shareValid);
            goodsDetail.setOtherInfo(otherInfo);
        }
        extraVO.setFanliValid(fanliValid);
        extraVO.setShareValid(shareValid);
        MoneyInfoVO goodsMoney = goodsDetail.getMoneyInfo();
        if (goodsMoney != null) {
            goodsMoney.setMoneyType(moneyType);
        }
        MoneyInfoVO goodsMoney = goodsDetail.getMoneyInfo();
        if (goodsMoney != null) {
            goodsMoney.setMoneyType(moneyType);
        }
        // 分享路径
        if (StringUtil.isNullOrEmpty(helpLink)) {
            helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(),acceptData.getSystem());
        }
        // 分享路径
        if (StringUtil.isNullOrEmpty(helpLink)) {
            helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(), acceptData.getSystem());
        }
        // 分享路径
        ShareVO shareInfoVO = new ShareVO();
        shareInfoVO.setHelpLink(helpLink);
        extraVO.setShare(shareInfoVO);
        // 分享路径
        ShareVO shareInfoVO = new ShareVO();
        shareInfoVO.setHelpLink(helpLink);
        extraVO.setShare(shareInfoVO);
        if (goodsDetail.isHasCoupon()) {
            // 设置couponList
            List<CouponInfoVO> couponInfoList = new ArrayList<>();
            couponInfoList.add(goodsDetail.getCouponInfo());
            goodsDetail.setCouponInfoList(couponInfoList);
        }
        if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) {
            getCloudInfo(acceptData, uid, goodsDetail, extraVO);  // 云发单文案信息
        }
        JSONObject object = new JSONObject();
        object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
        object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
        out.print(JsonUtil.loadTrueResult(object.toString()));
        if (goodsDetail.isHasCoupon()) {
            // 设置couponList
            List<CouponInfoVO> couponInfoList = new ArrayList<>();
            couponInfoList.add(goodsDetail.getCouponInfo());
            goodsDetail.setCouponInfoList(couponInfoList);
        }
        final TaoBaoGoodsBrief goodsInfo = tb;
        ThreadUtil.run(new Runnable() {
            public void run() {
                // 添加浏览记录
                try {
                    scanHistoryV2Service.addScanHistory(uid, acceptData.getDevice(), goodsInfo);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    /**
     * 京东商品详情
     *
     * @param acceptData
     * @param id
     * @param uid
     * @param from
     * @param out
     */
    @RequestMapping(value = "getDetailJD")
    public void getDetialJD(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
        // uid=2255993L;
        // 系统验证
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
        }
        if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) {
            getCloudInfo(acceptData, uid, goodsDetail, extraVO);  // 云发单文案信息
        }
        JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id); // 高级接口
        if (jdGoods == null) {
            jdGoods = JDUtil.getGoodsDetail(id); // 爬取网页
            // jdGoods = JDApiUtil.getGoodsDetail(id); // 普通接口
        }
        JSONObject object = new JSONObject();
        object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
        object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
        out.print(JsonUtil.loadTrueResult(object.toString()));
        if (jdGoods == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
            return;
        }
        final TaoBaoGoodsBrief goodsInfo = tb;
        ThreadUtil.run(new Runnable() {
            public void run() {
                // 添加浏览记录
                try {
                    scanHistoryV2Service.addScanHistory(uid, acceptData.getDevice(), goodsInfo);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
        List<String> imageList = jdGoods.getImageList();
        if (imageList == null) {
            imageList = new ArrayList<String>();
            imageList.add(jdGoods.getPicUrl());
        }
    /**
     * 京东商品详情
     *
     * @param acceptData
     * @param id
     * @param uid
     * @param from
     * @param out
     */
    @RequestMapping(value = "getDetailJD")
    public void getDetialJD(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
        // uid=2255993L;
        // 系统验证
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
        }
        // 保存缓存
        jdGoodsCacheUtil.saveGoodsInfo(jdGoods);
        JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id); // 高级接口
        if (jdGoods == null) {
            jdGoods = JDUtil.getGoodsDetail(id); // 爬取网页
            // jdGoods = JDApiUtil.getGoodsDetail(id); // 普通接口
        }
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
        if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
            goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
            goodsDetail.getMoneyInfo().setShareMoney("¥"
                    + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getShareRate(UserLevelEnum.superVIP)));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
        goodsDetail.getMoneyInfo()
                .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(),acceptData.getSystem()));
        if (jdGoods == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
            return;
        }
        // 附加信息
        OtherInfo otherInfo = new OtherInfo();
        List<String> imageList = jdGoods.getImageList();
        if (imageList == null) {
            imageList = new ArrayList<String>();
            imageList.add(jdGoods.getPicUrl());
        }
        // 京东plus返利
        String maxMoneyPlus = null;
        JDCategoryInfo categoryInfo = jdGoods.getCategoryInfo();
        if (categoryInfo != null && categoryInfo.getCid3() != null && jdGoods.getCommissionInfo() != null) {
            Long cid3 = categoryInfo.getCid3();
            JDGoodsClass threeClass = jdGoodsClassService.getThreeClassByCid(Integer.parseInt(cid3.toString()));
            if (threeClass != null && threeClass.getSelfComm() != null
                    && threeClass.getSelfComm().compareTo(new BigDecimal(0)) > 0) {
                BigDecimal commissionShare = jdGoods.getCommissionInfo().getCommissionShare();
                // plus比例 小于正常比例
                if (commissionShare != null && commissionShare.compareTo(threeClass.getSelfComm()) > 0) {
                    jdGoods.setCommissionPlus(threeClass.getSelfComm());
                    // plus返利
                    BigDecimal fanliMoneyPlus = JDUtil.getGoodsFanLiMoneyPlus(jdGoods,
                            hongBaoManageService.getFanLiRate());
                    otherInfo.setFanliMoneyPlus("京东plus返¥" + fanliMoneyPlus);
                    // 使用奖励券最高返
                    if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
                        maxMoneyPlus = "(京东plus返¥" + JDUtil.getGoodsFanLiMoneyPlus(jdGoods,
                                hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)) + ")";
                    } else
                        maxMoneyPlus = "(京东plus最高返¥"
                                + fanliMoneyPlus.add(MoneyBigDecimalUtil.mul(fanliMoneyPlus, Constant.MAX_REWARD_RATE))
                                + ")";
                }
            }
        }
        // 保存缓存
        jdGoodsCacheUtil.saveGoodsInfo(jdGoods);
        // 奖励券返利
        RewardCouponVO rewardCoupon = new RewardCouponVO();
        rewardCoupon.setMaxMoneyPlus(maxMoneyPlus);
        rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
        JSONObject params1 = new JSONObject();
        if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
            params1.put("url", configService.getValue(ConfigKeyEnum.specialGuideRewardCouponLink.getKey(),acceptData.getSystem()));
        else
            params1.put("url", userVipConfigService.getValueByKey("vip_link"));
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
        if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
            goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
            goodsDetail.getMoneyInfo().setShareMoney("¥"
                    + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getShareRate(UserLevelEnum.superVIP)));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
        goodsDetail.getMoneyInfo()
                .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(), acceptData.getSystem()));
        rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney());
        if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
            rewardCoupon.setDesc("返");
            params1.put("url", userVipConfigService.getValueByKey("vip_link"));
            rewardCoupon.getJumpDetail().setNeedLogin(true);
        } else {
            rewardCoupon.setDesc("用返利奖励券最高返");
        }
        rewardCoupon.setParams(params1.toString());
        // 附加信息
        OtherInfo otherInfo = new OtherInfo();
        otherInfo.setRewardCoupon(rewardCoupon);
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())
                && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()),acceptData.getSystem()))
            otherInfo.setRewardCoupon(null);
        // 京东plus返利
        String maxMoneyPlus = null;
        JDCategoryInfo categoryInfo = jdGoods.getCategoryInfo();
        if (categoryInfo != null && categoryInfo.getCid3() != null && jdGoods.getCommissionInfo() != null) {
            Long cid3 = categoryInfo.getCid3();
            JDGoodsClass threeClass = jdGoodsClassService.getThreeClassByCid(Integer.parseInt(cid3.toString()));
            if (threeClass != null && threeClass.getSelfComm() != null
                    && threeClass.getSelfComm().compareTo(new BigDecimal(0)) > 0) {
                BigDecimal commissionShare = jdGoods.getCommissionInfo().getCommissionShare();
                // plus比例 小于正常比例
                if (commissionShare != null && commissionShare.compareTo(threeClass.getSelfComm()) > 0) {
                    jdGoods.setCommissionPlus(threeClass.getSelfComm());
                    // plus返利
                    BigDecimal fanliMoneyPlus = JDUtil.getGoodsFanLiMoneyPlus(jdGoods,
                            hongBaoManageService.getFanLiRate());
                    otherInfo.setFanliMoneyPlus("京东plus返¥" + fanliMoneyPlus);
                    // 使用奖励券最高返
                    if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
                        maxMoneyPlus = "(京东plus返¥" + JDUtil.getGoodsFanLiMoneyPlus(jdGoods,
                                hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)) + ")";
                    } else
                        maxMoneyPlus = "(京东plus最高返¥"
                                + fanliMoneyPlus.add(MoneyBigDecimalUtil.mul(fanliMoneyPlus, Constant.MAX_REWARD_RATE))
                                + ")";
                }
            }
        }
        goodsDetail.setOtherInfo(otherInfo);
        // 奖励券返利
        RewardCouponVO rewardCoupon = new RewardCouponVO();
        rewardCoupon.setMaxMoneyPlus(maxMoneyPlus);
        rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
        JSONObject params1 = new JSONObject();
        if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
            params1.put("url", configService.getValue(ConfigKeyEnum.specialGuideRewardCouponLink.getKey(), acceptData.getSystem()));
        else
            params1.put("url", userVipConfigService.getValueByKey("vip_link"));
        CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
        if (couponInfo != null) {
            // 券链接处理
            String materialId = "https://item.jd.com/" + id + ".html";
            String url = JDApiUtil.convertLinkWithSubUnionId(materialId, couponInfo.getLink(),
                    JDApiUtil.POSITION_COUPON + "", null);
            couponInfo.setLink(url);
        }
        rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney());
        if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
            rewardCoupon.setDesc("返");
            params1.put("url", userVipConfigService.getValueByKey("vip_link"));
            rewardCoupon.getJumpDetail().setNeedLogin(true);
        } else {
            rewardCoupon.setDesc("用返利奖励券最高返");
        }
        rewardCoupon.setParams(params1.toString());
        ShopInfoVO shopInfo = goodsDetail.getShopInfo();
        if (shopInfo != null) {
            if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
                    || shopInfo.getScoreSeller() == null) {
                goodsDetail.setShopInfo(null);
            }
        }
        otherInfo.setRewardCoupon(rewardCoupon);
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())
                && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()))
            otherInfo.setRewardCoupon(null);
        GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
        extraVO.setIsNative(false);
        // IOS是否正在上线
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
            String version = acceptData.getVersion();
            extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version),acceptData.getSystem()));
        }
        goodsDetail.setOtherInfo(otherInfo);
        Long inOrderCount30Days = jdGoods.getInOrderCount30Days();
        List<ShamUser> listShareUser = new ArrayList<ShamUser>();
        CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
        if (couponInfo != null) {
            // 券链接处理
            String materialId = "https://item.jd.com/" + id + ".html";
            String url = JDApiUtil.convertLinkWithSubUnionId(materialId, couponInfo.getLink(),
                    JDApiUtil.POSITION_COUPON + "", null);
            couponInfo.setLink(url);
        }
        // 京东开启分享
        String open = configService.getValue(ConfigKeyEnum.shareOpenJD.getKey(),acceptData.getSystem());
        if ("1".equals(open.trim())) {
            extraVO.setShareValid(true);
            MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
            if (moneyInfo != null) {
                String shareMoney = moneyInfo.getShareMoney().replaceAll("¥", "");
                if (Integer.parseInt(inOrderCount30Days.toString()) >= 1000) {
                    listShareUser.addAll(shamUserService.listRandShareUser(10, new BigDecimal(shareMoney), 1, 5));
                }
            }
        }
        ShopInfoVO shopInfo = goodsDetail.getShopInfo();
        if (shopInfo != null) {
            if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
                    || shopInfo.getScoreSeller() == null) {
                goodsDetail.setShopInfo(null);
            }
        }
        extraVO.setListShareUser(listShareUser);
        GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
        extraVO.setIsNative(false);
        // IOS是否正在上线
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
            String version = acceptData.getVersion();
            extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version), acceptData.getSystem()));
        }
        // 领券人列表
        List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
        if (goodsDetail.isHasCoupon() && Integer.parseInt(inOrderCount30Days.toString()) >= 1000) {
            listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
        }
        extraVO.setListCouponUser(listCouponUser);
        Long inOrderCount30Days = jdGoods.getInOrderCount30Days();
        List<ShamUser> listShareUser = new ArrayList<ShamUser>();
        if (uid != null) {
            // 是否加入收藏
            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
                    Constant.SOURCE_TYPE_JD);
            extraVO.setCollected(collectionGoods != null ? true : false);
            // 是否加入选品库
            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_JD));
        }
        // 京东开启分享
        String open = configService.getValue(ConfigKeyEnum.shareOpenJD.getKey(), acceptData.getSystem());
        if ("1".equals(open.trim())) {
            extraVO.setShareValid(true);
            MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
            if (moneyInfo != null) {
                String shareMoney = moneyInfo.getShareMoney().replaceAll("¥", "");
                if (Integer.parseInt(inOrderCount30Days.toString()) >= 1000) {
                    listShareUser.addAll(shamUserService.listRandShareUser(10, new BigDecimal(shareMoney), 1, 5));
                }
            }
        }
        // 图文详情
        extraVO.setDetailUrl("https://in.m.jd.com/product/jieshao/video/" + id + ".html");
        extraVO.setListShareUser(listShareUser);
        // 测试
        SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system,
                "goods_detail_jump_taobao");
        if ("1".equalsIgnoreCase((params.getValue() + "").trim())) {
            extraVO.setIsNative(true);
        }
        // 领券人列表
        List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
        if (goodsDetail.isHasCoupon() && Integer.parseInt(inOrderCount30Days.toString()) >= 1000) {
            listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
        }
        extraVO.setListCouponUser(listCouponUser);
        // 商品链接
        String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(acceptData.getSystem()),
                Constant.systemCommonConfig.getShareGoodsPagePathJD(), "", id + "");
        // try {
        // extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
        // } catch (Exception e) {
        extraVO.setH5Url(h5Url);
        // }
        if (uid != null) {
            // 是否加入收藏
            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
                    Constant.SOURCE_TYPE_JD);
            extraVO.setCollected(collectionGoods != null ? true : false);
            // 是否加入选品库
            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_JD));
        }
        String helpLink = null;
        extraVO.setFanliValid(true);
        // 图文详情
        extraVO.setDetailUrl("https://in.m.jd.com/product/jieshao/video/" + id + ".html");
        if (StringUtil.isNullOrEmpty(helpLink)) {
            helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(),acceptData.getSystem());
        }
        // 测试
        SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system,
                "goods_detail_jump_taobao");
        if ("1".equalsIgnoreCase((params.getValue() + "").trim())) {
            extraVO.setIsNative(true);
        }
        ShareVO shareInfoVO = new ShareVO();
        shareInfoVO.setHelpLink(helpLink);
        extraVO.setShare(shareInfoVO);
        if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) {
            getCloudInfo(acceptData, uid, goodsDetail, extraVO);  // 云发单文案信息
        }
        // 商品链接
        String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(acceptData.getSystem()),
                Constant.systemCommonConfig.getShareGoodsPagePathJD(), "", id + "");
        // try {
        // extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
        // } catch (Exception e) {
        extraVO.setH5Url(h5Url);
        // }
        JSONObject object = new JSONObject();
        object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
        object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
        out.print(JsonUtil.loadTrueResult(object.toString()));
        String helpLink = null;
        extraVO.setFanliValid(true);
        final JDGoods goods = jdGoods;
        final Long fuid = uid;
        ThreadUtil.run(new Runnable() {
            public void run() {
                // 添加浏览记录
                try {
                    scanHistoryV2Service.addJDScanHistory(fuid, acceptData.getDevice(), goods);
                } catch (Exception e) {
                    e.printStackTrace();
                }
        if (StringUtil.isNullOrEmpty(helpLink)) {
            helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(), acceptData.getSystem());
        }
                try {
                    goodsEvaluateService.updateJDGoods(goods);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
        ShareVO shareInfoVO = new ShareVO();
        shareInfoVO.setHelpLink(helpLink);
        extraVO.setShare(shareInfoVO);
    /**
     * 拼多多商品详情
     *
     * @param acceptData
     * @param id
     * @param uid
     * @param from
     * @param out
     */
    @RequestMapping(value = "getDetailPDD", method = RequestMethod.POST)
    public void getDetialPDD(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
        // 系统验证
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
        }
        if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) {
            getCloudInfo(acceptData, uid, goodsDetail, extraVO);  // 云发单文案信息
        }
        PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id);
        if (pddGoods == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
            return;
        }
        JSONObject object = new JSONObject();
        object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
        object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
        out.print(JsonUtil.loadTrueResult(object.toString()));
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        final JDGoods goods = jdGoods;
        final Long fuid = uid;
        ThreadUtil.run(new Runnable() {
            public void run() {
                // 添加浏览记录
                try {
                    scanHistoryV2Service.addJDScanHistory(fuid, acceptData.getDevice(), goods);
                } catch (Exception e) {
                    e.printStackTrace();
                }
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO);
        if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
            goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
            goodsDetail.getMoneyInfo().setShareMoney("¥" + PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods,
                    hongBaoManageService.getShareRate(UserLevelEnum.superVIP)));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
        goodsDetail.getMoneyInfo()
                .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(),acceptData.getSystem()));
                try {
                    goodsEvaluateService.updateJDGoods(goods);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
        // 附加信息
        OtherInfo otherInfo = new OtherInfo();
        RewardCouponVO rewardCoupon = new RewardCouponVO();
        rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
        JSONObject params1 = new JSONObject();
        if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
            params1.put("url", configService.getValue(ConfigKeyEnum.specialGuideRewardCouponLink.getKey(),acceptData.getSystem()));
        else
            params1.put("url", userVipConfigService.getValueByKey("vip_link"));
    /**
     * 拼多多商品详情
     *
     * @param acceptData
     * @param id
     * @param uid
     * @param from
     * @param out
     */
    @RequestMapping(value = "getDetailPDD", method = RequestMethod.POST)
    public void getDetialPDD(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
        // 系统验证
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
        }
        rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney());
        if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
            rewardCoupon.setDesc("返");
            params1.put("url", userVipConfigService.getValueByKey("vip_link"));
            rewardCoupon.getJumpDetail().setNeedLogin(true);
        } else
            rewardCoupon.setDesc("用返利奖励券最高返");
        rewardCoupon.setParams(params1.toString());
        otherInfo.setRewardCoupon(rewardCoupon);
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())
                && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()),acceptData.getSystem()))
            otherInfo.setRewardCoupon(null);
        goodsDetail.setOtherInfo(otherInfo);
        PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id);
        if (pddGoods == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
            return;
        }
        CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
        PDDPromotionUrl convertUrl = null;
        if (couponInfo != null) {
            convertUrl = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_COUPON + "", null);
            if (convertUrl != null)
                couponInfo.setLink(convertUrl.getUrl());
        }
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        ShopInfoVO shopInfo = goodsDetail.getShopInfo();
        if (shopInfo != null) {
            if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
                    || shopInfo.getScoreSeller() == null) {
                goodsDetail.setShopInfo(null);
            }
        }
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO);
        if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
            goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
            goodsDetail.getMoneyInfo().setShareMoney("¥" + PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods,
                    hongBaoManageService.getShareRate(UserLevelEnum.superVIP)));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
        goodsDetail.getMoneyInfo()
                .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(), acceptData.getSystem()));
        GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
        extraVO.setIsNative(false);
        // IOS是否正在上线
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
            String version = acceptData.getVersion();
            extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version),acceptData.getSystem()));
        }
        // 附加信息
        OtherInfo otherInfo = new OtherInfo();
        RewardCouponVO rewardCoupon = new RewardCouponVO();
        rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
        JSONObject params1 = new JSONObject();
        if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
            params1.put("url", configService.getValue(ConfigKeyEnum.specialGuideRewardCouponLink.getKey(), acceptData.getSystem()));
        else
            params1.put("url", userVipConfigService.getValueByKey("vip_link"));
        // 图文详情
        extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_pdd.html?id=" + id);
        rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney());
        if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
            rewardCoupon.setDesc("返");
            params1.put("url", userVipConfigService.getValueByKey("vip_link"));
            rewardCoupon.getJumpDetail().setNeedLogin(true);
        } else
            rewardCoupon.setDesc("用返利奖励券最高返");
        rewardCoupon.setParams(params1.toString());
        otherInfo.setRewardCoupon(rewardCoupon);
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())
                && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()))
            otherInfo.setRewardCoupon(null);
        goodsDetail.setOtherInfo(otherInfo);
        String salesTip = pddGoods.getSalesTip();
        if (!StringUtil.isNullOrEmpty(salesTip)) {
            int indexOf = salesTip.indexOf("+");
            if (indexOf > 0) {
                salesTip = salesTip.substring(0, indexOf);
            }
        CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
        PDDPromotionUrl convertUrl = null;
        if (couponInfo != null) {
            convertUrl = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_COUPON + "", null);
            if (convertUrl != null)
                couponInfo.setLink(convertUrl.getUrl());
        }
            int totalSales = 0;
            if (salesTip.contains("万")) {
                salesTip = salesTip.substring(0, salesTip.indexOf("万"));
                totalSales = (int) (Float.parseFloat(salesTip) * 10000);
            } else {
                totalSales = Integer.parseInt(salesTip);
            }
        ShopInfoVO shopInfo = goodsDetail.getShopInfo();
        if (shopInfo != null) {
            if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
                    || shopInfo.getScoreSeller() == null) {
                goodsDetail.setShopInfo(null);
            }
        }
            List<ShamUser> listShareUser = new ArrayList<ShamUser>();
            MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
            if (moneyInfo != null) {
                String shareMoney = moneyInfo.getShareMoney().replaceAll("¥", "");
                if (totalSales >= 50000) {
                    listShareUser = shamUserService.listRandShareUser(10, new BigDecimal(shareMoney), 1, 5);
                }
            }
            extraVO.setListShareUser(listShareUser);
        GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
        extraVO.setIsNative(false);
        // IOS是否正在上线
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
            String version = acceptData.getVersion();
            extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version), acceptData.getSystem()));
        }
        // 图文详情
        extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_pdd.html?id=" + id);
        String salesTip = pddGoods.getSalesTip();
        if (!StringUtil.isNullOrEmpty(salesTip)) {
            int indexOf = salesTip.indexOf("+");
            if (indexOf > 0) {
                salesTip = salesTip.substring(0, indexOf);
            }
            int totalSales = 0;
            if (salesTip.contains("万")) {
                salesTip = salesTip.substring(0, salesTip.indexOf("万"));
                totalSales = (int) (Float.parseFloat(salesTip) * 10000);
            } else {
                totalSales = Integer.parseInt(salesTip);
            }
            List<ShamUser> listShareUser = new ArrayList<ShamUser>();
            MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
            if (moneyInfo != null) {
                String shareMoney = moneyInfo.getShareMoney().replaceAll("¥", "");
                if (totalSales >= 50000) {
                    listShareUser = shamUserService.listRandShareUser(10, new BigDecimal(shareMoney), 1, 5);
                }
            }
            extraVO.setListShareUser(listShareUser);
            // 领券人列表
            List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
            if (goodsDetail.isHasCoupon() && totalSales >= 50000) {
                listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
            }
            extraVO.setListCouponUser(listCouponUser);
        }
        if (uid != null) {
            // 是否加入收藏
            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
                    Constant.SOURCE_TYPE_PDD);
            extraVO.setCollected(collectionGoods != null ? true : false);
            // 是否加入选品库
            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_PDD));
        }
        extraVO.setIsNative(true);
        // 分享路径
        String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(acceptData.getSystem()),
                Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + "");
        // try {
        // extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
        // } catch (Exception e) {
        extraVO.setH5Url(h5Url);
        // }
        String helpLink = null;
        extraVO.setFanliValid(true);
        extraVO.setShareValid(true);
        if (StringUtil.isNullOrEmpty(helpLink)) {
            helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(), acceptData.getSystem());
        }
        ShareVO shareInfoVO = new ShareVO();
        shareInfoVO.setHelpLink(helpLink);
        extraVO.setShare(shareInfoVO);
        if (convertUrl != null) {
            extraVO.setCouponJumpLink(convertUrl.getUrl());
            extraVO.setNativeCouponJumpLink(PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl()));
        }
        if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) {
            getCloudInfo(acceptData, uid, goodsDetail, extraVO); // 云发单文案信息
        }
        // 免单商品
        if (!StringUtil.isNullOrEmpty(from) && "miandan".equals(from)) {
            MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
            if (goodsDetail.isHasCoupon()) {
                moneyInfo.setFanliMoney("¥" + goodsDetail.getCouponPrice());
            } else {
                moneyInfo.setFanliMoney("¥" + goodsDetail.getZkPrice());
            }
            goodsDetail.setMoneyInfo(moneyInfo);
        }
        JSONObject object = new JSONObject();
        object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
        object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
        out.print(JsonUtil.loadTrueResult(object.toString()));
        ThreadUtil.run(new Runnable() {
            public void run() {
                // 添加浏览记录
                try {
                    scanHistoryV2Service.addPDDScanHistory(uid, acceptData.getDevice(), pddGoods);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                try {
                    goodsEvaluateService.updatePDDGoods(pddGoods);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    /**
     * 唯品会详情
     *
     * @param acceptData
     * @param id
     * @param uid
     * @param from
     * @param out
     */
    @RequestMapping(value = "getDetailVIP", method = RequestMethod.POST)
    public void getDetialVIP(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
        // 系统验证
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
        }
        VIPGoodsInfo vipGoodsInfo = VipShopApiUtil.getGoodsDetail(id + "");
        if (vipGoodsInfo == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
            return;
        }
            // 领券人列表
            List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
            if (goodsDetail.isHasCoupon() && totalSales >= 50000) {
                listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
            }
            extraVO.setListCouponUser(listCouponUser);
        }
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        if (uid != null) {
            // 是否加入收藏
            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
                    Constant.SOURCE_TYPE_PDD);
            extraVO.setCollected(collectionGoods != null ? true : false);
            // 是否加入选品库
            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_PDD));
        }
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertVIPGoods(vipGoodsInfo, paramsDTO);
        if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
            goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
            goodsDetail.getMoneyInfo().setShareMoney("¥" + VipShopUtil.getGoodsFanLiMoney(vipGoodsInfo,
                    hongBaoManageService.getShareRate(UserLevelEnum.superVIP)));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
        goodsDetail.getMoneyInfo()
                .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(), acceptData.getSystem()));
        extraVO.setIsNative(true);
        // 附加信息
        OtherInfo otherInfo = new OtherInfo();
        RewardCouponVO rewardCoupon = new RewardCouponVO();
        rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
        JSONObject params1 = new JSONObject();
        if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
            params1.put("url", configService.getValue(ConfigKeyEnum.specialGuideRewardCouponLink.getKey(), acceptData.getSystem()));
        else
            params1.put("url", userVipConfigService.getValueByKey("vip_link"));
        // 分享路径
        String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(acceptData.getSystem()),
                Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + "");
        // try {
        // extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
        // } catch (Exception e) {
        extraVO.setH5Url(h5Url);
        // }
        rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney());
        rewardCoupon.setDesc("返");
        params1.put("url", userVipConfigService.getValueByKey("vip_link"));
        rewardCoupon.getJumpDetail().setNeedLogin(true);
        String helpLink = null;
        extraVO.setFanliValid(true);
        extraVO.setShareValid(true);
        rewardCoupon.setParams(params1.toString());
        otherInfo.setRewardCoupon(rewardCoupon);
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())
                && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()))
            otherInfo.setRewardCoupon(null);
        goodsDetail.setOtherInfo(otherInfo);
        if (StringUtil.isNullOrEmpty(helpLink)) {
            helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(),acceptData.getSystem());
        }
        ShopInfoVO shopInfo = goodsDetail.getShopInfo();
        if (shopInfo != null) {
            if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
                    || shopInfo.getScoreSeller() == null) {
                goodsDetail.setShopInfo(null);
            }
        }
        ShareVO shareInfoVO = new ShareVO();
        shareInfoVO.setHelpLink(helpLink);
        extraVO.setShare(shareInfoVO);
        GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
        extraVO.setIsNative(false);
        // IOS是否正在上线
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
            String version = acceptData.getVersion();
            extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version), acceptData.getSystem()));
        }
        if (convertUrl != null) {
            extraVO.setCouponJumpLink(convertUrl.getUrl());
            extraVO.setNativeCouponJumpLink(PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl()));
        }
        if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) {
            getCloudInfo(acceptData, uid, goodsDetail, extraVO); // 云发单文案信息
        }
        // 免单商品
        if (!StringUtil.isNullOrEmpty(from) && "miandan".equals(from)) {
            MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
            if (goodsDetail.isHasCoupon()) {
                moneyInfo.setFanliMoney("¥" + goodsDetail.getCouponPrice());
            } else {
                moneyInfo.setFanliMoney("¥" + goodsDetail.getZkPrice());
            }
            goodsDetail.setMoneyInfo(moneyInfo);
        }
        // 图文详情
        extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_pdd.html?id=" + id);
        JSONObject object = new JSONObject();
        object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
        object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
        out.print(JsonUtil.loadTrueResult(object.toString()));
        if (uid != null) {
            // 是否加入收藏
            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
                    Constant.SOURCE_TYPE_VIP);
            extraVO.setCollected(collectionGoods != null ? true : false);
            // 是否加入选品库
            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_VIP));
        }
        ThreadUtil.run(new Runnable() {
            public void run() {
                // 添加浏览记录
                try {
                    scanHistoryV2Service.addPDDScanHistory(uid, acceptData.getDevice(), pddGoods);
                } catch (Exception e) {
                    e.printStackTrace();
                }
        extraVO.setIsNative(true);
                try {
                    goodsEvaluateService.updatePDDGoods(pddGoods);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
        // 分享路径
        String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(acceptData.getSystem()),
                Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + "");
        // try {
        // extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
        // } catch (Exception e) {
        extraVO.setH5Url(h5Url);
        // }
    /**
     * 唯品会详情
     *
     * @param acceptData
     * @param id
     * @param uid
     * @param from
     * @param out
     */
    @RequestMapping(value = "getDetailVIP", method = RequestMethod.POST)
    public void getDetialVIP(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
        // 系统验证
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
        }
        String helpLink = null;
        extraVO.setFanliValid(true);
        extraVO.setShareValid(true);
        VIPGoodsInfo vipGoodsInfo = VipShopApiUtil.getGoodsDetail(id + "");
        if (vipGoodsInfo == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
            return;
        }
        if (StringUtil.isNullOrEmpty(helpLink)) {
            helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(), acceptData.getSystem());
        }
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        ShareVO shareInfoVO = new ShareVO();
        shareInfoVO.setHelpLink(helpLink);
        extraVO.setShare(shareInfoVO);
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertVIPGoods(vipGoodsInfo, paramsDTO);
        if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
            goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
            goodsDetail.getMoneyInfo().setShareMoney("¥" + VipShopUtil.getGoodsFanLiMoney(vipGoodsInfo,
                    hongBaoManageService.getShareRate(UserLevelEnum.superVIP)));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
        goodsDetail.getMoneyInfo()
                .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(),acceptData.getSystem()));
        // 云发单文案信息
        getCloudInfo(acceptData, uid, goodsDetail, extraVO);
        // 附加信息
        OtherInfo otherInfo = new OtherInfo();
        RewardCouponVO rewardCoupon = new RewardCouponVO();
        rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
        JSONObject params1 = new JSONObject();
        if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
            params1.put("url", configService.getValue(ConfigKeyEnum.specialGuideRewardCouponLink.getKey(),acceptData.getSystem()));
        else
            params1.put("url", userVipConfigService.getValueByKey("vip_link"));
        JSONObject object = new JSONObject();
        object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
        object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
        out.print(JsonUtil.loadTrueResult(object.toString()));
        rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney());
        rewardCoupon.setDesc("返");
        params1.put("url", userVipConfigService.getValueByKey("vip_link"));
        rewardCoupon.getJumpDetail().setNeedLogin(true);
        ThreadUtil.run(new Runnable() {
            public void run() {
                // 添加浏览记录
                try {
                    scanHistoryV2Service.addVIPScanHistory(uid, acceptData.getDevice(), vipGoodsInfo);
                } catch (Exception e) {
                    e.printStackTrace();
                }
        rewardCoupon.setParams(params1.toString());
        otherInfo.setRewardCoupon(rewardCoupon);
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())
                && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()),acceptData.getSystem()))
            otherInfo.setRewardCoupon(null);
        goodsDetail.setOtherInfo(otherInfo);
                try {
                    goodsEvaluateService.updateVIPGoods(vipGoodsInfo);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
        ShopInfoVO shopInfo = goodsDetail.getShopInfo();
        if (shopInfo != null) {
            if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
                    || shopInfo.getScoreSeller() == null) {
                goodsDetail.setShopInfo(null);
            }
        }
    @RequestMapping(value = "getDetailSuning", method = RequestMethod.POST)
    public void getDetialSuning(AcceptData acceptData, String id, Long uid, String from, PrintWriter out) {
        // 系统验证
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
        }
        GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
        extraVO.setIsNative(false);
        // IOS是否正在上线
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
            String version = acceptData.getVersion();
            extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version),acceptData.getSystem()));
        }
        String[] ids = SuningUtil.getGoodsIdDetail(id);
        // 图文详情
        extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_pdd.html?id=" + id);
        SuningGoodsInfo suningGoodsInfo = SuningApiUtil.getGoodsDetail(ids[1], ids[0]);
        if (uid != null) {
            // 是否加入收藏
            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
                    Constant.SOURCE_TYPE_VIP);
            extraVO.setCollected(collectionGoods != null ? true : false);
            // 是否加入选品库
            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_VIP));
        }
        if (suningGoodsInfo == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
            return;
        }
        extraVO.setIsNative(true);
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        // 分享路径
        String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(acceptData.getSystem()),
                Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + "");
        // try {
        // extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
        // } catch (Exception e) {
        extraVO.setH5Url(h5Url);
        // }
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertSuningGoods(suningGoodsInfo, paramsDTO);
        if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
            goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
            goodsDetail.getMoneyInfo().setShareMoney("¥" + SuningUtil.getGoodsFanLiMoney(suningGoodsInfo,
                    hongBaoManageService.getShareRate(UserLevelEnum.superVIP)));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
        goodsDetail.getMoneyInfo()
                .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(), acceptData.getSystem()));
        String helpLink = null;
        extraVO.setFanliValid(true);
        extraVO.setShareValid(true);
        // 附加信息
        OtherInfo otherInfo = new OtherInfo();
        RewardCouponVO rewardCoupon = new RewardCouponVO();
        rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
        JSONObject params1 = new JSONObject();
        if (StringUtil.isNullOrEmpty(helpLink)) {
            helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(),acceptData.getSystem());
        }
        params1.put("url", userVipConfigService.getValueByKey("vip_link"));
        ShareVO shareInfoVO = new ShareVO();
        shareInfoVO.setHelpLink(helpLink);
        extraVO.setShare(shareInfoVO);
        // 云发单文案信息
        getCloudInfo(acceptData, uid, goodsDetail, extraVO);
        rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney());
        rewardCoupon.setDesc("返");
        params1.put("url", userVipConfigService.getValueByKey("vip_link"));
        rewardCoupon.getJumpDetail().setNeedLogin(true);
        JSONObject object = new JSONObject();
        object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
        object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
        out.print(JsonUtil.loadTrueResult(object.toString()));
        rewardCoupon.setParams(params1.toString());
        otherInfo.setRewardCoupon(rewardCoupon);
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())
                && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()))
            otherInfo.setRewardCoupon(null);
        goodsDetail.setOtherInfo(otherInfo);
        ThreadUtil.run(new Runnable() {
            public void run() {
                // 添加浏览记录
                try {
                    scanHistoryV2Service.addVIPScanHistory(uid, acceptData.getDevice(), vipGoodsInfo);
                } catch (Exception e) {
                    e.printStackTrace();
                }
        ShopInfoVO shopInfo = goodsDetail.getShopInfo();
        if (shopInfo != null) {
            if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
                    || shopInfo.getScoreSeller() == null) {
                goodsDetail.setShopInfo(null);
            }
        }
                try {
                    goodsEvaluateService.updateVIPGoods(vipGoodsInfo);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
        GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
        extraVO.setIsNative(false);
        // IOS是否正在上线
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
            String version = acceptData.getVersion();
            extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version), acceptData.getSystem()));
        }
    @RequestMapping(value = "getDetailSuning", method = RequestMethod.POST)
    public void getDetialSuning(AcceptData acceptData, String id, Long uid, String from, PrintWriter out) {
        // 系统验证
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
        }
        // 图文详情
        extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_suning.html?id="
                + suningGoodsInfo.getCommodityInfo().getCommodityCode() + "&supplierCode="
                + suningGoodsInfo.getCommodityInfo().getSupplierCode());
        String[] ids = SuningUtil.getGoodsIdDetail(id);
        if (uid != null) {
            // 是否加入收藏
            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid,
                    Long.parseLong(suningGoodsInfo.getCommodityInfo().getCommodityCode()), Constant.SOURCE_TYPE_SUNING);
            extraVO.setCollected(collectionGoods != null ? true : false);
            // 是否加入选品库
            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid,
                    Long.parseLong(suningGoodsInfo.getCommodityInfo().getCommodityCode()),
                    Constant.SOURCE_TYPE_SUNING));
        }
        SuningGoodsInfo suningGoodsInfo = SuningApiUtil.getGoodsDetail(ids[1], ids[0]);
        extraVO.setIsNative(true);
        if (suningGoodsInfo == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
            return;
        }
        // 分享路径
        String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(acceptData.getSystem()),
                Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + "");
        // try {
        // extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
        // } catch (Exception e) {
        extraVO.setH5Url(h5Url);
        // }
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        String helpLink = null;
        extraVO.setFanliValid(true);
        extraVO.setShareValid(true);
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertSuningGoods(suningGoodsInfo, paramsDTO);
        if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
            goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
            goodsDetail.getMoneyInfo().setShareMoney("¥" + SuningUtil.getGoodsFanLiMoney(suningGoodsInfo,
                    hongBaoManageService.getShareRate(UserLevelEnum.superVIP)));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
        goodsDetail.getMoneyInfo()
                .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(),acceptData.getSystem()));
        if (StringUtil.isNullOrEmpty(helpLink)) {
            helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(), acceptData.getSystem());
        }
        // 附加信息
        OtherInfo otherInfo = new OtherInfo();
        RewardCouponVO rewardCoupon = new RewardCouponVO();
        rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
        JSONObject params1 = new JSONObject();
        ShareVO shareInfoVO = new ShareVO();
        shareInfoVO.setHelpLink(helpLink);
        extraVO.setShare(shareInfoVO);
        params1.put("url", userVipConfigService.getValueByKey("vip_link"));
        // 云发单文案信息
        getCloudInfo(acceptData, uid, goodsDetail, extraVO);
        rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney());
        rewardCoupon.setDesc("返");
        params1.put("url", userVipConfigService.getValueByKey("vip_link"));
        rewardCoupon.getJumpDetail().setNeedLogin(true);
        JSONObject object = new JSONObject();
        object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
        object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
        out.print(JsonUtil.loadTrueResult(object.toString()));
        rewardCoupon.setParams(params1.toString());
        otherInfo.setRewardCoupon(rewardCoupon);
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())
                && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()),acceptData.getSystem()))
            otherInfo.setRewardCoupon(null);
        goodsDetail.setOtherInfo(otherInfo);
        ThreadUtil.run(new Runnable() {
            public void run() {
                // 添加浏览记录
                try {
                    scanHistoryV2Service.addSuningScanHistory(uid, acceptData.getDevice(), suningGoodsInfo);
                } catch (Exception e) {
                    e.printStackTrace();
                }
        ShopInfoVO shopInfo = goodsDetail.getShopInfo();
        if (shopInfo != null) {
            if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
                    || shopInfo.getScoreSeller() == null) {
                goodsDetail.setShopInfo(null);
            }
        }
                try {
                    goodsEvaluateService.updateSuningGoods(suningGoodsInfo);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
        GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
        extraVO.setIsNative(false);
        // IOS是否正在上线
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
            String version = acceptData.getVersion();
            extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version),acceptData.getSystem()));
        }
    /**
     * // 云发单文案信息
     *
     * @param goodsDetail
     */
    private void getCloudInfo(AcceptData acceptData, Long uid, GoodsDetailVO goodsDetail, GoodsDetailExtraVO extraVO) {
        // 云发单是否开启
        boolean cloudOpen = configService.isRobotCloudOpen(ConfigKeyEnum.robotCloudOpenGoodsDetail.getKey(), acceptData.getPlatform(), acceptData.getVersion(), acceptData.getSystem());
        if (!cloudOpen && uid != null) {
            List<String> testUsers = configService.getTestUsers(acceptData.getSystem());
            if (testUsers != null && testUsers.contains(uid + "")) {
                cloudOpen = true;
            }
        }
        extraVO.setCloudOpen(cloudOpen);
        // 图文详情
        extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_suning.html?id="
                + suningGoodsInfo.getCommodityInfo().getCommodityCode() + "&supplierCode="
                + suningGoodsInfo.getCommodityInfo().getSupplierCode());
        // 无券或者未开启发圈
        if (!goodsDetail.isHasCoupon() || !cloudOpen) {
            return;
        }
        if (uid != null) {
            // 是否加入收藏
            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid,
                    Long.parseLong(suningGoodsInfo.getCommodityInfo().getCommodityCode()), Constant.SOURCE_TYPE_SUNING);
            extraVO.setCollected(collectionGoods != null ? true : false);
            // 是否加入选品库
            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid,
                    Long.parseLong(suningGoodsInfo.getCommodityInfo().getCommodityCode()),
                    Constant.SOURCE_TYPE_SUNING));
        }
        GoodsEvaluate evaluate = goodsEvaluateService.queryExistSingle(goodsDetail.getGoodsId() + "", goodsDetail.getGoodsType(), acceptData.getSystem());
        if (evaluate != null) {
            String cloudText = null;
            List<CommentInfo> comments = evaluate.getComments();
            if (comments != null && comments.size() > 0) {
                cloudText = comments.get(0).getContent();
            }
        extraVO.setIsNative(true);
            String cloudPic = null;
            List<ImgInfo> imgList = evaluate.getImgList();
            if (imgList != null && imgList.size() > 0) {
                for (ImgInfo imgInfo : imgList) {
                    ImgEnum type = imgInfo.getType();
                    if (type == ImgEnum.goods) {
                        cloudPic = imgInfo.getUrl();
                    }
                }
            }
        // 分享路径
        String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(acceptData.getSystem()),
                Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + "");
        // try {
        // extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
        // } catch (Exception e) {
        extraVO.setH5Url(h5Url);
        // }
            if (!StringUtil.isNullOrEmpty(cloudText) && !StringUtil.isNullOrEmpty(cloudPic)) {
        String helpLink = null;
        extraVO.setFanliValid(true);
        extraVO.setShareValid(true);
                cloudText = cloudText.replace("[原价]", MoneyBigDecimalUtil.getWithNoZera(goodsDetail.getZkPrice()) + "");
                if (!goodsDetail.isHasCoupon()) {
                    cloudText = cloudText.replace("领券抢购", "抢购");
                    cloudText = cloudText.replace("【券后价】[券后价]元", "");
                } else {
                    cloudText = cloudText.replace("[券后价]", MoneyBigDecimalUtil.getWithNoZera(goodsDetail.getCouponPrice()) + "");
                }
                cloudText = cloudText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
        if (StringUtil.isNullOrEmpty(helpLink)) {
            helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(),acceptData.getSystem());
        }
                extraVO.setCloudPic(cloudPic);
                extraVO.setCloudText(cloudText);
            }
        }
    }
        ShareVO shareInfoVO = new ShareVO();
        shareInfoVO.setHelpLink(helpLink);
        extraVO.setShare(shareInfoVO);
    /**
     * 商品详情推荐(猜你喜欢 + 推荐)
     *
     * @param acceptData
     * @param id
     * @param out
     */
    @RequestMapping(value = "getRecommendGoods", method = RequestMethod.POST)
    public void getRecommendGoods(AcceptData acceptData, String id, Integer goodsType, PrintWriter out) {
        if (goodsType == null) {
            goodsType = Constant.SOURCE_TYPE_TAOBAO;
        }
        // 云发单文案信息
        getCloudInfo(acceptData, uid, goodsDetail, extraVO);
        JSONObject object = new JSONObject();
        object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
        object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
        out.print(JsonUtil.loadTrueResult(object.toString()));
        try {
            // 京东
            if (goodsType == Constant.SOURCE_TYPE_JD) {
                JSONObject data = new JSONObject();
                data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
        ThreadUtil.run(new Runnable() {
            public void run() {
                // 添加浏览记录
                try {
                    scanHistoryV2Service.addSuningScanHistory(uid, acceptData.getDevice(), suningGoodsInfo);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                List<JDGoods> list = JDUtil.getRecommendGoodsById(Long.parseLong(id));
                if (list == null) {
                    list = new ArrayList<JDGoods>();
                } else if (list.size() > 10) {
                    list = list.subList(0, 10);
                }
                try {
                    goodsEvaluateService.updateSuningGoods(suningGoodsInfo);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    /**
     *     // 云发单文案信息
     * @param goodsDetail
     */
    private void getCloudInfo(AcceptData acceptData,Long uid, GoodsDetailVO goodsDetail, GoodsDetailExtraVO extraVO) {
        // 云发单是否开启
        boolean cloudOpen = configService.isRobotCloudOpen(ConfigKeyEnum.robotCloudOpenGoodsDetail.getKey(),acceptData.getPlatform(),acceptData.getVersion(),acceptData.getSystem());
        if (!cloudOpen && uid != null) {
            List<String> testUsers = configService.getTestUsers(acceptData.getSystem());
            if (testUsers != null && testUsers.contains(uid+"")) {
                cloudOpen = true;
            }
        }
        extraVO.setCloudOpen(cloudOpen);
        // 无券或者未开启发圈
        if (!goodsDetail.isHasCoupon() || !cloudOpen) {
            return;
        }
        GoodsEvaluate evaluate = goodsEvaluateService.queryExistSingle(goodsDetail.getGoodsId() +"", goodsDetail.getGoodsType());
        if (evaluate != null) {
            String cloudText = null;
            List<CommentInfo> comments = evaluate.getComments();
            if (comments != null && comments.size() > 0) {
                cloudText = comments.get(0).getContent();
            }
            String cloudPic = null;
            List<ImgInfo> imgList = evaluate.getImgList();
            if (imgList != null && imgList.size() > 0) {
                for (ImgInfo imgInfo: imgList) {
                    ImgEnum type = imgInfo.getType();
                    if (type == ImgEnum.goods) {
                        cloudPic = imgInfo.getUrl();
                    }
                }
            }
            if (!StringUtil.isNullOrEmpty(cloudText) && !StringUtil.isNullOrEmpty(cloudPic)) {
                cloudText = cloudText.replace("[原价]", MoneyBigDecimalUtil.getWithNoZera(goodsDetail.getZkPrice()) + "");
                if (!goodsDetail.isHasCoupon()) {
                    cloudText = cloudText.replace("领券抢购", "抢购");
                    cloudText = cloudText.replace("【券后价】[券后价]元", "");
                } else {
                    cloudText = cloudText.replace("[券后价]", MoneyBigDecimalUtil.getWithNoZera(goodsDetail.getCouponPrice()) + "");
                }
                cloudText = cloudText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
                extraVO.setCloudPic(cloudPic);
                extraVO.setCloudText(cloudText);
            }
        }
    }
                ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null);
                List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
    /**
     * 商品详情推荐(猜你喜欢 + 推荐)
     *
     * @param acceptData
     * @param id
     * @param out
     */
    @RequestMapping(value = "getRecommendGoods", method = RequestMethod.POST)
    public void getRecommendGoods(AcceptData acceptData, String id, Integer goodsType, PrintWriter out) {
        if (goodsType == null) {
            goodsType = Constant.SOURCE_TYPE_TAOBAO;
        }
                for (JDGoods goods : list) {
                    listDetailVO.add(GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO));
                }
        try {
            // 京东
            if (goodsType == Constant.SOURCE_TYPE_JD) {
                JSONObject data = new JSONObject();
                data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
                // 取偶数个数据
                if (listDetailVO.size() % 2 != 0) {
                    listDetailVO.remove(listDetailVO.size() - 1);
                }
                List<JDGoods> list = JDUtil.getRecommendGoodsById(Long.parseLong(id));
                if (list == null) {
                    list = new ArrayList<JDGoods>();
                } else if (list.size() > 10) {
                    list = list.subList(0, 10);
                }
                data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
                out.print(JsonUtil.loadTrueResult(data));
                return;
            }
                ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null);
                List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
            // 拼多多
            if (goodsType == Constant.SOURCE_TYPE_PDD) {
                JSONObject data = new JSONObject();
                data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
                for (JDGoods goods : list) {
                    listDetailVO.add(GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO));
                }
                List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
                // 取偶数个数据
                if (listDetailVO.size() % 2 != 0) {
                    listDetailVO.remove(listDetailVO.size() - 1);
                }
                List<Long> goodsIdList = PinDuoDuoUtil.getRecommendGoodsId(Long.parseLong(id));
                if (goodsIdList != null && goodsIdList.size() > 0) {
                    PDDSearchFilter pddfilter = new PDDSearchFilter();
                    pddfilter.setPage(1);
                    pddfilter.setPageSize(Constant.PAGE_SIZE);
                    Long[] strings = new Long[goodsIdList.size()];
                    pddfilter.setGoodsIdList(goodsIdList.toArray(strings));
                data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
                out.print(JsonUtil.loadTrueResult(data));
                return;
            }
                    PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
                    if (result != null) {
                        List<PDDGoodsDetail> goodsList = result.getGoodsList();
                        if (goodsList != null && goodsList.size() > 0) {
            // 拼多多
            if (goodsType == Constant.SOURCE_TYPE_PDD) {
                JSONObject data = new JSONObject();
                data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
                            if (goodsList.size() > 10) {
                                goodsList = goodsList.subList(0, 10);
                            }
                List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
                            ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(),
                                    null);
                            for (PDDGoodsDetail goods : goodsList) {
                                listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO));
                            }
                        }
                    }
                }
                List<Long> goodsIdList = PinDuoDuoUtil.getRecommendGoodsId(Long.parseLong(id));
                if (goodsIdList != null && goodsIdList.size() > 0) {
                    PDDSearchFilter pddfilter = new PDDSearchFilter();
                    pddfilter.setPage(1);
                    pddfilter.setPageSize(Constant.PAGE_SIZE);
                    Long[] strings = new Long[goodsIdList.size()];
                    pddfilter.setGoodsIdList(goodsIdList.toArray(strings));
                // 取偶数个数据
                if (listDetailVO.size() % 2 != 0) {
                    listDetailVO.remove(listDetailVO.size() - 1);
                }
                    PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
                    if (result != null) {
                        List<PDDGoodsDetail> goodsList = result.getGoodsList();
                        if (goodsList != null && goodsList.size() > 0) {
                data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
                out.print(JsonUtil.loadTrueResult(data));
                return;
            }
                            if (goodsList.size() > 10) {
                                goodsList = goodsList.subList(0, 10);
                            }
            // 唯品会
            if (goodsType == Constant.SOURCE_TYPE_VIP) {
                JSONObject data = new JSONObject();
                data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
                data.put("listQuality", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
                out.print(JsonUtil.loadTrueResult(data));
                return;
            }
                            ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(),
                                    null);
                            for (PDDGoodsDetail goods : goodsList) {
                                listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO));
                            }
                        }
                    }
                }
            // 苏宁
            if (goodsType == Constant.SOURCE_TYPE_SUNING) {
                List<SuningGoodsInfo> resultList = null;
                String[] ids = SuningUtil.getGoodsIdDetail(id);
                List<SuningGoodsInfoRecommend> list = SuningApiUtil.getRecommendGoods(ids[1], ids[0]);
                if (list != null && list.size() > 0) {
                    List<String> listId = new ArrayList<>();
                    for (SuningGoodsInfoRecommend goodsInfo : list) {
                        if (goodsInfo != null) {
                            listId.add(goodsInfo.getCommodityCode() + "-" + goodsInfo.getSupplierCode());
                        }
                    }
                    resultList = SuningApiUtil.getGoodsDetailList(listId);
                }
                // 取偶数个数据
                if (listDetailVO.size() % 2 != 0) {
                    listDetailVO.remove(listDetailVO.size() - 1);
                }
                List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
                if (resultList != null) {
                    if (resultList != null && resultList.size() > 0) {
                        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                                acceptData.getVersion());
                data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
                out.print(JsonUtil.loadTrueResult(data));
                return;
            }
                        for (SuningGoodsInfo goods : resultList) {
                            GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertSuningGoods(goods, paramsDTO);
                            listDetailVO.add(goodsDetailVO);
                        }
                    }
                }
            // 唯品会
            if (goodsType == Constant.SOURCE_TYPE_VIP) {
                JSONObject data = new JSONObject();
                data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
                data.put("listQuality", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
                out.print(JsonUtil.loadTrueResult(data));
                return;
            }
            // 苏宁
            if (goodsType == Constant.SOURCE_TYPE_SUNING) {
                List<SuningGoodsInfo> resultList = null;
                String[] ids = SuningUtil.getGoodsIdDetail(id);
                List<SuningGoodsInfoRecommend> list = SuningApiUtil.getRecommendGoods(ids[1], ids[0]);
                if (list != null && list.size() > 0) {
                    List<String> listId = new ArrayList<>();
                    for (SuningGoodsInfoRecommend goodsInfo:  list) {
                         if (goodsInfo != null) {
                             listId.add(goodsInfo.getCommodityCode() + "-" + goodsInfo.getSupplierCode());
                         }
                    }
                    resultList = SuningApiUtil.getGoodsDetailList(listId);
                }
                List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
                if (resultList != null) {
                    if (resultList != null && resultList.size() > 0) {
                        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                                acceptData.getVersion());
                JSONObject data = new JSONObject();
                data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
                data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
                out.print(JsonUtil.loadTrueResult(data));
                return;
            }
                        for (SuningGoodsInfo goods : resultList) {
                            GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertSuningGoods(goods, paramsDTO);
                            listDetailVO.add(goodsDetailVO);
                        }
                    }
                }
                JSONObject data = new JSONObject();
                data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
                data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
                out.print(JsonUtil.loadTrueResult(data));
                return;
            }
            List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(Long.parseLong(id), 10);
            // 初始化
            if (goodsList == null) {
                goodsList = new ArrayList<TaoBaoGoodsBrief>();
            }
            List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(Long.parseLong(id), 10);
            // 初始化
            if (goodsList == null) {
                goodsList = new ArrayList<TaoBaoGoodsBrief>();
            }
            List<GoodsDetailVO> listExtra = new ArrayList<GoodsDetailVO>();
            ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null);
            goodsList.parallelStream().forEach(goods -> {
                if (goods != null) {
                    listExtra.add(GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO));
                }
            });
            List<GoodsDetailVO> listExtra = new ArrayList<GoodsDetailVO>();
            ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null);
            goodsList.parallelStream().forEach(goods -> {
                if (goods != null) {
                    listExtra.add(GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO));
                }
            });
            List<GoodsDetailVO> listQuality = new ArrayList<GoodsDetailVO>();
            // 取偶数个数据
            if (listExtra.size() % 2 != 0) {
                listExtra.remove(listExtra.size() - 1);
            }
            List<GoodsDetailVO> listQuality = new ArrayList<GoodsDetailVO>();
            // 取偶数个数据
            if (listExtra.size() % 2 != 0) {
                listExtra.remove(listExtra.size() - 1);
            }
            if (listQuality.size() % 2 != 0) {
                listQuality.remove(listQuality.size() - 1);
            }
            if (listQuality.size() % 2 != 0) {
                listQuality.remove(listQuality.size() - 1);
            }
            JSONObject data = new JSONObject();
            data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listExtra));
            data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listQuality));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
            JSONObject data = new JSONObject();
            data.put("listQuality", new JSONArray());
            data.put("listGuess", new JSONArray());
            out.print(JsonUtil.loadTrueResult(data));
        }
    }
            JSONObject data = new JSONObject();
            data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listExtra));
            data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listQuality));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
            JSONObject data = new JSONObject();
            data.put("listQuality", new JSONArray());
            data.put("listGuess", new JSONArray());
            out.print(JsonUtil.loadTrueResult(data));
        }
    }
    /**
     * 京东购买链接
     *
     * @param acceptData
     * @param uid
     * @param id
     * @param couponUrl
     *            -优惠券链接
     * @param source
     * @param out
     */
    @RequestMapping(value = "getJDLink")
    public void getJDLink(AcceptData acceptData, Long uid, Long id, String couponUrl, String source, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
            return;
        }
    /**
     * 京东购买链接
     *
     * @param acceptData
     * @param uid
     * @param id
     * @param couponUrl  -优惠券链接
     * @param source
     * @param out
     */
    @RequestMapping(value = "getJDLink")
    public void getJDLink(AcceptData acceptData, Long uid, Long id, String couponUrl, String source, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
            return;
        }
        if (id == null || id <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空"));
            return;
        }
        if (id == null || id <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空"));
            return;
        }
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
            out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
            return;
        }
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
            out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
            return;
        }
        JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(id);
        if (goods == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
            return;
        }
        JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(id);
        if (goods == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
            return;
        }
        String jumpLink = null;
        String materialId = "https://item.jd.com/" + id + ".html";
        if (StringUtil.isNullOrEmpty(couponUrl)) {
            JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods.getCouponInfoList(), goods.getPrice());
            if (couponInfo != null) {
                couponUrl = couponInfo.getLink();
            }
            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "",
                    uid + "");
            if (jumpLink == null) {
                jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, JDApiUtil.POSITION_FANLI + "",
                        uid + "");
            }
        } else {
            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "",
                    uid + "");
            if (StringUtil.isNullOrEmpty(jumpLink)) {
                jumpLink = couponUrl;
            }
        }
        String jumpLink = null;
        String materialId = "https://item.jd.com/" + id + ".html";
        if (StringUtil.isNullOrEmpty(couponUrl)) {
            JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods.getCouponInfoList(), goods.getPrice());
            if (couponInfo != null) {
                couponUrl = couponInfo.getLink();
            }
            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "",
                    uid + "");
            if (jumpLink == null) {
                jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, JDApiUtil.POSITION_FANLI + "",
                        uid + "");
            }
        } else {
            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "",
                    uid + "");
            if (StringUtil.isNullOrEmpty(jumpLink)) {
                jumpLink = couponUrl;
            }
        }
        JSONObject data = new JSONObject();
        data.put("native", true);
        data.put("jumpLink", jumpLink);
        out.print(JsonUtil.loadTrueResult(data));
        JSONObject data = new JSONObject();
        data.put("native", true);
        data.put("jumpLink", jumpLink);
        out.print(JsonUtil.loadTrueResult(data));
        // 获得金币
        integralGetService.addCouponRebate(uid);
    }
        // 获得金币
        integralGetService.addCouponRebate(uid);
    }
    @RequestMapping(value = "getJDCouponLink")
    public void getJDCouponLink(AcceptData acceptData, Long id, String couponUrl, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(couponUrl)) {
            out.print(JsonUtil.loadFalseResult(1, "券链接不能为空"));
            return;
        }
        if (id == null || id <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空"));
            return;
        }
    @RequestMapping(value = "getJDCouponLink")
    public void getJDCouponLink(AcceptData acceptData, Long id, String couponUrl, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(couponUrl)) {
            out.print(JsonUtil.loadFalseResult(1, "券链接不能为空"));
            return;
        }
        if (id == null || id <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空"));
            return;
        }
        String jumpLink = null;
        String materialId = "https://item.jd.com/" + id + ".html";
        String jumpLink = null;
        String materialId = "https://item.jd.com/" + id + ".html";
        jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", null);
        if (StringUtil.isNullOrEmpty(jumpLink)) {
            jumpLink = couponUrl;
        }
        jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", null);
        if (StringUtil.isNullOrEmpty(jumpLink)) {
            jumpLink = couponUrl;
        }
        JSONObject data = new JSONObject();
        data.put("native", true);
        data.put("jumpLink", jumpLink);
        out.print(JsonUtil.loadTrueResult(data));
    }
        JSONObject data = new JSONObject();
        data.put("native", true);
        data.put("jumpLink", jumpLink);
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 拼多多购买链接
     *
     * @param acceptData
     * @param uid
     * @param id
     * @param source
     * @param out
     */
    @RequestMapping(value = "getPDDLink")
    public void getPDDLink(AcceptData acceptData, Long uid, Long id, String source, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
            return;
        }
    /**
     * 拼多多购买链接
     *
     * @param acceptData
     * @param uid
     * @param id
     * @param source
     * @param out
     */
    @RequestMapping(value = "getPDDLink")
    public void getPDDLink(AcceptData acceptData, Long uid, Long id, String source, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
            return;
        }
        if (id == null || id <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空"));
            return;
        }
        if (id == null || id <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空"));
            return;
        }
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
            out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
            return;
        }
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
            out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
            return;
        }
        PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(id);
        if (goods == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
            return;
        }
        PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(id);
        if (goods == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
            return;
        }
        PDDPromotionUrl convertUrl = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_FANLI + "", uid + "");
        JSONObject data = new JSONObject();
        data.put("native", true);
        PDDPromotionUrl convertUrl = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_FANLI + "", uid + "");
        JSONObject data = new JSONObject();
        data.put("native", true);
        data.put("jumpLink", convertUrl.getUrl());
        data.put("nativeJumpLink", PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl()));
        out.print(JsonUtil.loadTrueResult(data));
        data.put("jumpLink", convertUrl.getUrl());
        data.put("nativeJumpLink", PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl()));
        out.print(JsonUtil.loadTrueResult(data));
        // 获得金币
        integralGetService.addCouponRebate(uid);
    }
        // 获得金币
        integralGetService.addCouponRebate(uid);
    }
    /**
     * 拼多多购买链接
     *
     * @param acceptData
     * @param uid
     * @param id
     * @param source
     * @param out
     */
    @RequestMapping(value = "getVIPLink")
    public void getVIPLink(AcceptData acceptData, Long uid, Long id, String source, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
            return;
        }
    /**
     * 拼多多购买链接
     *
     * @param acceptData
     * @param uid
     * @param id
     * @param source
     * @param out
     */
    @RequestMapping(value = "getVIPLink")
    public void getVIPLink(AcceptData acceptData, Long uid, Long id, String source, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
            return;
        }
        if (id == null || id <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空"));
            return;
        }
        if (id == null || id <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空"));
            return;
        }
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
            out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
            return;
        }
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
            out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
            return;
        }
        VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(id + "");
        if (goods == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
            return;
        }
        VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(id + "");
        if (goods == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
            return;
        }
        VIPConvertResultDTO convertUrl = VipShopApiUtil.convertLink(id + "", VipShopUtil.getBuyChanTag(uid));
        JSONObject data = new JSONObject();
        data.put("native", true);
        data.put("jumpLink", convertUrl.getUrl());
        data.put("nativeJumpLink", convertUrl.getDeeplinkUrl());
        out.print(JsonUtil.loadTrueResult(data));
        VIPConvertResultDTO convertUrl = VipShopApiUtil.convertLink(id + "", VipShopUtil.getBuyChanTag(uid));
        JSONObject data = new JSONObject();
        data.put("native", true);
        data.put("jumpLink", convertUrl.getUrl());
        data.put("nativeJumpLink", convertUrl.getDeeplinkUrl());
        out.print(JsonUtil.loadTrueResult(data));
        // 获得金币
        integralGetService.addCouponRebate(uid);
    }
        // 获得金币
        integralGetService.addCouponRebate(uid);
    }
    @RequestMapping(value = "getSuningLink")
    public void getSuningLink(AcceptData acceptData, Long uid, String id, String source, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
            return;
        }
    @RequestMapping(value = "getSuningLink")
    public void getSuningLink(AcceptData acceptData, Long uid, String id, String source, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
            return;
        }
        if (StringUtil.isNullOrEmpty(id)) {
            out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空"));
            return;
        }
        if (StringUtil.isNullOrEmpty(id)) {
            out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空"));
            return;
        }
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
            out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
            return;
        }
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
            out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
            return;
        }
        String[] sts = SuningUtil.getGoodsIdDetail(id);
        String supplierCode = sts[0];
        String goodsCode = sts[1];
        String[] sts = SuningUtil.getGoodsIdDetail(id);
        String supplierCode = sts[0];
        String goodsCode = sts[1];
        SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(goodsCode, supplierCode);
        if (goods == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
            return;
        }
        SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(goodsCode, supplierCode);
        if (goods == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
            return;
        }
        String quanUrl = null;
        if (!StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl()))
            quanUrl = goods.getCouponInfo().getCouponUrl();
        String link = SuningApiUtil.convertLink(SuningUtil.getProductUrl(supplierCode, goodsCode), quanUrl,
                SuningApiUtil.PID_BUY, uid + "");
        JSONObject data = new JSONObject();
        data.put("native", false);
        data.put("jumpLink", link);
        out.print(JsonUtil.loadTrueResult(data));
        String quanUrl = null;
        if (!StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl()))
            quanUrl = goods.getCouponInfo().getCouponUrl();
        String link = SuningApiUtil.convertLink(SuningUtil.getProductUrl(supplierCode, goodsCode), quanUrl,
                SuningApiUtil.PID_BUY, uid + "");
        JSONObject data = new JSONObject();
        data.put("native", false);
        data.put("jumpLink", link);
        out.print(JsonUtil.loadTrueResult(data));
        // 获得金币
        integralGetService.addCouponRebate(uid);
    }
        // 获得金币
        integralGetService.addCouponRebate(uid);
    }
    /**
     * 是否在参与推广
     *
     * @param goodsId
     *            -商品ID
     * @param goodsType
     *            -TB/JD
     * @param out
     */
    @RequestMapping(value = "isGoodsExtend")
    public void isGoodsExtend(AcceptData acceptData, String goodsId, Integer goodsType, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(goodsId)) {
            out.print(JsonUtil.loadFalseResult(1, "未参与推广"));
            return;
        }
        if (goodsType == null) {
            out.print(JsonUtil.loadFalseResult(2, "缺少goodsType"));
            return;
        }
        JSONObject data = new JSONObject();
        if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
            TaoBaoGoodsBrief goods = null;
            try {
                goods = TaoKeApiUtil.getSimpleGoodsInfo(Long.parseLong(goodsId));
            } catch (NumberFormatException e) {
                e.printStackTrace();
            } catch (TaobaoGoodsDownException e) {
                e.printStackTrace();
            }
    /**
     * 是否在参与推广
     *
     * @param goodsId   -商品ID
     * @param goodsType -TB/JD
     * @param out
     */
    @RequestMapping(value = "isGoodsExtend")
    public void isGoodsExtend(AcceptData acceptData, String goodsId, Integer goodsType, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(goodsId)) {
            out.print(JsonUtil.loadFalseResult(1, "未参与推广"));
            return;
        }
        if (goodsType == null) {
            out.print(JsonUtil.loadFalseResult(2, "缺少goodsType"));
            return;
        }
        JSONObject data = new JSONObject();
        if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
            TaoBaoGoodsBrief goods = null;
            try {
                goods = TaoKeApiUtil.getSimpleGoodsInfo(Long.parseLong(goodsId));
            } catch (NumberFormatException e) {
                e.printStackTrace();
            } catch (TaobaoGoodsDownException e) {
                e.printStackTrace();
            }
            if (goods == null) {
                data.put("extend", false);
                data.put("url", "https://h5.m.taobao.com/awp/core/detail.htm?id=" + goodsId);
            } else {
                data.put("extend", true);
            }
            if (goods == null) {
                data.put("extend", false);
                data.put("url", "https://h5.m.taobao.com/awp/core/detail.htm?id=" + goodsId);
            } else {
                data.put("extend", true);
            }
        } else if (goodsType == Constant.SOURCE_TYPE_JD) {
            JDGoods goods = JDApiUtil.getGoodsDetail(Long.parseLong(goodsId));
            if (goods == null) {
                data.put("extend", false);
                data.put("url", String.format("https://item.m.jd.com/product/%s.html", goodsId));
            } else {
                data.put("extend", true);
            }
        } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
            PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsId));
            if (goods == null) {
                data.put("extend", false);
                data.put("url", String.format("https://mobile.yangkeduo.com/goods.html?goods_id=%s", goodsId));
            } else {
                data.put("extend", true);
            }
        } else if (goodsType == Constant.SOURCE_TYPE_VIP) {
            VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(goodsId);
            if (goods == null) {
                data.put("extend", false);
                data.put("url","");
            } else {
                data.put("extend", true);
            }
        } else if (goodsType == Constant.SOURCE_TYPE_SUNING) {
            SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(goodsId.split("-")[1], goodsId.split("-")[0]);
            if (goods == null) {
                data.put("extend", false);
                data.put("url", String.format("https://m.suning.com/product/%s/%s.html", goodsId.split("-")[0],goodsId.split("-")[1]));
            } else {
                data.put("extend", true);
            }
        }
        out.print(JsonUtil.loadTrueResult(data));
    }
        } else if (goodsType == Constant.SOURCE_TYPE_JD) {
            JDGoods goods = JDApiUtil.getGoodsDetail(Long.parseLong(goodsId));
            if (goods == null) {
                data.put("extend", false);
                data.put("url", String.format("https://item.m.jd.com/product/%s.html", goodsId));
            } else {
                data.put("extend", true);
            }
        } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
            PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsId));
            if (goods == null) {
                data.put("extend", false);
                data.put("url", String.format("https://mobile.yangkeduo.com/goods.html?goods_id=%s", goodsId));
            } else {
                data.put("extend", true);
            }
        } else if (goodsType == Constant.SOURCE_TYPE_VIP) {
            VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(goodsId);
            if (goods == null) {
                data.put("extend", false);
                data.put("url", "");
            } else {
                data.put("extend", true);
            }
        } else if (goodsType == Constant.SOURCE_TYPE_SUNING) {
            SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(goodsId.split("-")[1], goodsId.split("-")[0]);
            if (goods == null) {
                data.put("extend", false);
                data.put("url", String.format("https://m.suning.com/product/%s/%s.html", goodsId.split("-")[0], goodsId.split("-")[1]));
            } else {
                data.put("extend", true);
            }
        }
        out.print(JsonUtil.loadTrueResult(data));
    }
    @RequestMapping(value = "listSimpleGoods", method = RequestMethod.POST)
    public void listSimpleGoods(AcceptData acceptData, String goodsInfo, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(goodsInfo)) {
            out.print(JsonUtil.loadFalseResult(1, "商品信息为空"));
            return;
        }
    @RequestMapping(value = "listSimpleGoods", method = RequestMethod.POST)
    public void listSimpleGoods(AcceptData acceptData, String goodsInfo, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(goodsInfo)) {
            out.print(JsonUtil.loadFalseResult(1, "商品信息为空"));
            return;
        }
        net.sf.json.JSONArray array = net.sf.json.JSONArray.fromObject(goodsInfo);
        net.sf.json.JSONArray array = net.sf.json.JSONArray.fromObject(goodsInfo);
        List<CommonGoods> commonGoodsList = new ArrayList<>();
        List<CommonGoods> commonGoodsList = new ArrayList<>();
        for (int i = 0; i < array.size(); i++) {
            JSONObject obj = array.optJSONObject(i);
            CommonGoods cg = new CommonGoods();
            cg.setGoodsId(obj.optLong("goodsId"));
            cg.setGoodsType(obj.optInt("goodsType"));
            commonGoodsList.add(cg);
        }
        for (int i = 0; i < array.size(); i++) {
            JSONObject obj = array.optJSONObject(i);
            CommonGoods cg = new CommonGoods();
            cg.setGoodsId(obj.optLong("goodsId"));
            cg.setGoodsType(obj.optInt("goodsType"));
            commonGoodsList.add(cg);
        }
        if (commonGoodsList.size() > 9) {
            out.print(JsonUtil.loadFalseResult(1, "最多同时获取9条数据"));
            return;
        }
        if (commonGoodsList.size() > 9) {
            out.print(JsonUtil.loadFalseResult(1, "最多同时获取9条数据"));
            return;
        }
        // 分离各个平台的商品信息
        List<Long> tbGoodsList = new ArrayList<>();
        List<Long> jdGoodsList = new ArrayList<>();
        List<Long> pddGoodsList = new ArrayList<>();
        // 分离各个平台的商品信息
        List<Long> tbGoodsList = new ArrayList<>();
        List<Long> jdGoodsList = new ArrayList<>();
        List<Long> pddGoodsList = new ArrayList<>();
        List<String> keyList = new ArrayList<>();
        List<String> keyList = new ArrayList<>();
        for (CommonGoods cg : commonGoodsList) {
            keyList.add(cg.getGoodsId() + "-" + cg.getGoodsType());
            if (cg.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
                tbGoodsList.add(cg.getGoodsId());
            } else if (cg.getGoodsType() == Constant.SOURCE_TYPE_JD) {
                jdGoodsList.add(cg.getGoodsId());
            } else if (cg.getGoodsType() == Constant.SOURCE_TYPE_PDD) {
                pddGoodsList.add(cg.getGoodsId());
            }
        }
        for (CommonGoods cg : commonGoodsList) {
            keyList.add(cg.getGoodsId() + "-" + cg.getGoodsType());
            if (cg.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
                tbGoodsList.add(cg.getGoodsId());
            } else if (cg.getGoodsType() == Constant.SOURCE_TYPE_JD) {
                jdGoodsList.add(cg.getGoodsId());
            } else if (cg.getGoodsType() == Constant.SOURCE_TYPE_PDD) {
                pddGoodsList.add(cg.getGoodsId());
            }
        }
        Map<String, GoodsDetailVO> tempGoodsList = new HashMap<>();
        Map<String, GoodsDetailVO> tempGoodsList = new HashMap<>();
        ConfigParamsDTO params = new ConfigParamsDTO(hongBaoManageService.getFanLiRate(),
                hongBaoManageService.getShareRate(), new BigDecimal(80),
                hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP));
        ConfigParamsDTO params = new ConfigParamsDTO(hongBaoManageService.getFanLiRate(),
                hongBaoManageService.getShareRate(), new BigDecimal(80),
                hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP));
        if (tbGoodsList.size() > 0) {
            List<TaoBaoGoodsBrief> goodsList = null;
            try {
                goodsList = TaoKeApiUtil.getBatchGoodsInfo(tbGoodsList);
            } catch (TaobaoGoodsDownException e) {
                e.printStackTrace();
            } catch (TaoKeApiException e) {
                e.printStackTrace();
            }
            if (goodsList != null)
                for (TaoBaoGoodsBrief goods : goodsList) {
                    goods.setTkRate(new BigDecimal(0));
                    tempGoodsList.put(goods.getAuctionId() + "-" + Constant.SOURCE_TYPE_TAOBAO,
                            GoodsDetailVOFactory.convertTaoBao(goods, params));
                }
        }
        if (jdGoodsList.size() > 0) {
            List<JDGoods> goodsList = JDApiUtil.getGoodsDetail(jdGoodsList);
            for (JDGoods goods : goodsList) {
                tempGoodsList.put(goods.getSkuId() + "-" + Constant.SOURCE_TYPE_JD,
                        GoodsDetailVOFactory.convertJDGoods(goods, params));
            }
        }
        if (pddGoodsList.size() > 0) {
            List<PDDGoodsDetail> goodsList = PinDuoDuoApiUtil.listGoodsDetail(pddGoodsList);
            for (PDDGoodsDetail goods : goodsList) {
                tempGoodsList.put(goods.getGoodsId() + "-" + Constant.SOURCE_TYPE_PDD,
                        GoodsDetailVOFactory.convertPDDGoods(goods, params));
            }
        }
        List<GoodsDetailVO> voList = new ArrayList<>();
        Gson gson = JsonUtil.getApiCommonGson();
        for (String key : keyList) {
            GoodsDetailVO vo = tempGoodsList.get(key);
            if (vo != null) {
                voList.add(vo);
            }
        }
        out.print(JsonUtil.loadTrueResult(gson.toJson(voList)));
    }
        if (tbGoodsList.size() > 0) {
            List<TaoBaoGoodsBrief> goodsList = null;
            try {
                goodsList = TaoKeApiUtil.getBatchGoodsInfo(tbGoodsList);
            } catch (TaobaoGoodsDownException e) {
                e.printStackTrace();
            } catch (TaoKeApiException e) {
                e.printStackTrace();
            }
            if (goodsList != null)
                for (TaoBaoGoodsBrief goods : goodsList) {
                    goods.setTkRate(new BigDecimal(0));
                    tempGoodsList.put(goods.getAuctionId() + "-" + Constant.SOURCE_TYPE_TAOBAO,
                            GoodsDetailVOFactory.convertTaoBao(goods, params));
                }
        }
        if (jdGoodsList.size() > 0) {
            List<JDGoods> goodsList = JDApiUtil.getGoodsDetail(jdGoodsList);
            for (JDGoods goods : goodsList) {
                tempGoodsList.put(goods.getSkuId() + "-" + Constant.SOURCE_TYPE_JD,
                        GoodsDetailVOFactory.convertJDGoods(goods, params));
            }
        }
        if (pddGoodsList.size() > 0) {
            List<PDDGoodsDetail> goodsList = PinDuoDuoApiUtil.listGoodsDetail(pddGoodsList);
            for (PDDGoodsDetail goods : goodsList) {
                tempGoodsList.put(goods.getGoodsId() + "-" + Constant.SOURCE_TYPE_PDD,
                        GoodsDetailVOFactory.convertPDDGoods(goods, params));
            }
        }
        List<GoodsDetailVO> voList = new ArrayList<>();
        Gson gson = JsonUtil.getApiCommonGson();
        for (String key : keyList) {
            GoodsDetailVO vo = tempGoodsList.get(key);
            if (vo != null) {
                voList.add(vo);
            }
        }
        out.print(JsonUtil.loadTrueResult(gson.toJson(voList)));
    }
    /**
     * 京东转链
     * @Title: getJDLink
     * @Description:
     * @param acceptData
     * @param link
     * @param uid
     * @param out
     * void 返回类型
     * @throws
     */
    @RequestMapping(value = "convertJDLink")
    public void convertJDLink(AcceptData acceptData, String link, Long uid, String callback, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(link)) {
            out.print(JsonUtil.loadFalseResult(1, "链接为空"));
            return;
        }
    /**
     * 京东转链
     *
     * @param acceptData
     * @param link
     * @param uid
     * @param out        void 返回类型
     * @throws
     * @Title: getJDLink
     * @Description:
     */
    @RequestMapping(value = "convertJDLink")
    public void convertJDLink(AcceptData acceptData, String link, Long uid, String callback, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(link)) {
            out.print(JsonUtil.loadFalseResult(1, "链接为空"));
            return;
        }
        link = JDApiUtil.convertLinkWithSubUnionId(link, null, JDApiUtil.POSITION_FANLI + "", uid + "");
        link = JDApiUtil.convertLinkWithSubUnionId(link, null, JDApiUtil.POSITION_FANLI + "", uid + "");
        JSONObject data = new JSONObject();
        data.put("link", link);
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
        JSONObject data = new JSONObject();
        data.put("link", link);
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/HomeNavbarControllerV2.java
@@ -109,7 +109,7 @@
            List<HomeNavbar> listItems = new ArrayList<HomeNavbar>();
            // 系统默认导航栏
            List<HomeNavbar> listNavbar = homeNavbarService.listQueryEffectiveNavbar();
            List<HomeNavbar> listNavbar = homeNavbarService.listQueryEffectiveNavbar(acceptData.getSystem());
            if (listNavbar != null && listNavbar.size() > 0) {
                listItems.addAll(listNavbar);
            }
@@ -251,7 +251,7 @@
            List<HomeNavbar> listItems = new ArrayList<HomeNavbar>();
            
            
            List<HomeNavbar> listNavbar = homeNavbarUserService.restoreSystemDefault(uid, acceptData.getDevice());
            List<HomeNavbar> listNavbar = homeNavbarUserService.restoreSystemDefault(uid, acceptData.getDevice(),acceptData.getSystem());
            if (listNavbar != null && listNavbar.size() > 0) {
                listItems.addAll(listNavbar);
            }
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java
@@ -721,7 +721,7 @@
        try {
            List<String> listIOS = new ArrayList<String>();
            List<String> listAndroid = new ArrayList<String>();
            pushService.pushZNX(remindId, title, content, listIOS, listAndroid);
            pushService.pushZNX(remindId, title, content, listIOS, listAndroid,acceptData.getSystem());
            userSystemMsgService.addUserSystemMsg(remindId, UserSystemMsgTypeEnum.common, title, content,
                    UserSystemMsg.TIME_TAG_COMMON, null);
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/PreviewInfoControllerV2.java
@@ -492,7 +492,7 @@
            PushContentDTO dto = PushMsgFactory.createInviteOrderStatisticed(Constant.SOURCE_TYPE_TAOBAO, orderId,
                    BigDecimal.ZERO);
            try {
                pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
                pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null,acceptData.getSystem());
            } catch (NumberFormatException e) {
                e.printStackTrace();
            } catch (PushException e) {
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
@@ -560,7 +560,7 @@
        AppPageNotification ap = null;
        if (page == 1) {
            ap = appPageNotificationService.getValidNotificationByTypeCache(notifyType, acceptData.getPlatform(),
                    Integer.parseInt(acceptData.getVersion()));
                    Integer.parseInt(acceptData.getVersion()),acceptData.getSystem());
            // 没有通知
            if (ap == null || !ap.getShow()) {
                ap = null;
@@ -931,16 +931,16 @@
        out.print(JsonUtil.loadTrueResult(buildSearchResult(data, ap)));
    }
    /**
     * 拼多多
     *
     * @param kw
     *  拼多多
     * @param acceptData
     * @param key
     * @param page
     * @param filter
     * @param order
     * @param startprice
     * @param endprice
     * @return
     * @param ap
     * @param out
     */
    private void searchPDDGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order,
            AppPageNotification ap, PrintWriter out) {
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserCloudControllerV2.java
@@ -810,7 +810,7 @@
        }
        
        try {
            GoodsEvaluate evaluate = goodsEvaluateService.queryExistSingle(goodsId, goodsType);
            GoodsEvaluate evaluate = goodsEvaluateService.queryExistSingle(goodsId, goodsType,acceptData.getSystem());
            if (evaluate != null) {
                userCloudService.sendByDynamic(uid, evaluate.getId());
            } else {
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/ConfigController.java
@@ -153,7 +153,7 @@
        List<FloatAD> listAD = new ArrayList<FloatAD>();
        List<FloatImgDetailVO> listVO = new ArrayList<FloatImgDetailVO>();
        List<FloatAD> list = floatADService.getValidFloatADCache(FloatAD.POSITION_INDEX, null, platform,
                Integer.parseInt(version));
                Integer.parseInt(version),acceptData.getSystem());
        if (list != null && !list.isEmpty())
            listAD.addAll(list);
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/InviteController.java
@@ -384,7 +384,7 @@
        try {
            List<String> listIOS = new ArrayList<String>();
            List<String> listAndroid = new ArrayList<String>();
            pushService.pushZNX(remindId, title, content, listIOS, listAndroid);
            pushService.pushZNX(remindId, title, content, listIOS, listAndroid,acceptData.getSystem());
            userSystemMsgService.addUserSystemMsg(remindId, UserSystemMsgTypeEnum.common, title, content,
                    UserSystemMsg.TIME_TAG_COMMON, null);
fanli/src/main/java/com/yeshi/fanli/dao/dynamic/GoodsEvaluateDao.java
@@ -7,6 +7,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
@@ -37,11 +38,10 @@
        mongoTemplate.save(record);
    }
    /**
     * 状态切换
     *
     * @param record
     * @param id
     * @param state
     */
    public void updateSatate(String id, int state) {
        Query query = new Query();
@@ -99,7 +99,7 @@
     * 
     * @return
     */
    public List<GoodsEvaluate> query(int start, int count, String key, Integer state, int dynamicType, String typeEnum) {
    public List<GoodsEvaluate> query(int start, int count, String key, Integer state, int dynamicType, String typeEnum, SystemEnum system) {
        Query query = new Query();
        List<Criteria> list = new ArrayList<Criteria>();
        list.add(Criteria.where("dynamicType").is(dynamicType));
@@ -110,6 +110,9 @@
        
        if (!StringUtil.isNullOrEmpty(typeEnum))
            list.add(Criteria.where("type").is(typeEnum));
        if(system!=null)
            list.add(Criteria.where("system").is(system));
        
        if (!StringUtil.isNullOrEmpty(key))
            list.add(new Criteria().orOperator(
@@ -127,7 +130,7 @@
        return mongoTemplate.find(query, GoodsEvaluate.class);
    }
    public long count(String key, Integer state, int dynamicType, String typeEnum) {
    public long count(String key, Integer state, int dynamicType, String typeEnum, SystemEnum system) {
        Query query = new Query();
        List<Criteria> list = new ArrayList<Criteria>();
        list.add(Criteria.where("dynamicType").is(dynamicType));
@@ -135,6 +138,9 @@
        if (state != null) {
            list.add(Criteria.where("state").is(state));
        }
        if(system!=null)
            list.add(Criteria.where("system").is(system));
        
        if (!StringUtil.isNullOrEmpty(typeEnum))
            list.add(Criteria.where("type").is(typeEnum));
@@ -157,10 +163,9 @@
     * 查询有效
     * @param start
     * @param count
     * @param key
     * @return
     */
    public List<GoodsEvaluate> queryValid(int start, int count, int dynamicType) {
    public List<GoodsEvaluate> queryValid(int start, int count, int dynamicType,SystemEnum system) {
        Date now = new Date();
        Query query = new Query();
        List<Criteria> list = new ArrayList<Criteria>();
@@ -169,6 +174,8 @@
        list.add(Criteria.where("state").is(1));
        list.add(Criteria.where("startTime").lte(now));
        list.add(Criteria.where("endTime").gte(now));
        if(system!=null)
            list.add(Criteria.where("system").is(system));
        
        if (list.size() > 0) {
            Criteria[] cas = new Criteria[list.size()];
@@ -184,10 +191,9 @@
    /**
     * 统计有效
     * @param key
     * @return
     */
    public long countValid(int dynamicType) {
    public long countValid(int dynamicType,SystemEnum system) {
        Date now = new Date();
        Query query = new Query();
        List<Criteria> list = new ArrayList<Criteria>();
@@ -196,6 +202,8 @@
        list.add(Criteria.where("state").is(1));
        list.add(Criteria.where("startTime").lte(now));
        list.add(Criteria.where("endTime").gte(now));
        if(system!=null)
            list.add(Criteria.where("system").is(system));
        
        if (list.size() > 0) {
            Criteria[] cas = new Criteria[list.size()];
@@ -209,18 +217,17 @@
    
    /**
     * 查询有效
     * @param start
     * @param count
     * @param key
     * @return
     */
    public List<GoodsEvaluate> querySingleExist() {
    public List<GoodsEvaluate> querySingleExist(SystemEnum system) {
        Query query = new Query();
        List<Criteria> list = new ArrayList<Criteria>();
        
        list.add(Criteria.where("dynamicType").is(1));
        list.add(Criteria.where("state").is(1));
        list.add(Criteria.where("goods.goodsType").is(1));
        if(system!=null)
            list.add(Criteria.where("system").is(system));
        
        if (list.size() > 0) {
            Criteria[] cas = new Criteria[list.size()];
@@ -231,19 +238,21 @@
        return mongoTemplate.find(query, GoodsEvaluate.class);
    }
    
    /**
     * 查询有效
     * @param start
     * @param count
     * @param key
     * @param goodsType
     * @param goodsId
     * @param system
     * @return
     */
    public List<GoodsEvaluate> queryExist(int goodsType, String goodsId) {
    public List<GoodsEvaluate> queryExist(int goodsType, String goodsId,SystemEnum system) {
        Query query = new Query();
        List<Criteria> list = new ArrayList<Criteria>();
        list.add(Criteria.where("dynamicType").is(1));
        list.add(Criteria.where("state").is(1));
        if(system!=null)
            list.add(Criteria.where("system").is(system));
        list.add(Criteria.where("imgList.goods.goodsId").is(goodsId));
        list.add(Criteria.where("imgList.goods.goodsType").is(goodsType));
        
@@ -260,17 +269,16 @@
    
    /**
     * 查询有效
     * @param start
     * @param count
     * @param key
     * @return
     */
    public List<GoodsEvaluate> queryExistSingle(int goodsType, String goodsId) {
    public List<GoodsEvaluate> queryExistSingle(int goodsType, String goodsId,SystemEnum system) {
        Query query = new Query();
        List<Criteria> list = new ArrayList<Criteria>();
        list.add(Criteria.where("dynamicType").is(1));
        list.add(Criteria.where("state").is(1));
        list.add(Criteria.where("type").is("single"));
        if(system!=null)
            list.add(Criteria.where("system").is(system));
        list.add(Criteria.where("imgList.goods.goodsId").is(goodsId));
        list.add(Criteria.where("imgList.goods.goodsType").is(goodsType));
        
@@ -287,9 +295,6 @@
    
    /**
     * 查询有效
     * @param start
     * @param count
     * @param key
     * @return
     */
    public List<GoodsEvaluate> queryOverdue() {
@@ -300,12 +305,8 @@
        return mongoTemplate.find(query, GoodsEvaluate.class);
    }
    
    /**
     * 查询有效
     * @param start
     * @param count
     * @param key
     * @return
     */
    public List<GoodsEvaluate> removeDownGoods() {
@@ -355,7 +356,6 @@
     * 查询有效-倒序
     * @param start
     * @param count
     * @param key
     * @return
     */
    public List<GoodsEvaluate> queryValidSortASC(int start, int count, EvaluateEnum tyepEnum, boolean sortDesc) {
@@ -386,12 +386,12 @@
        return mongoTemplate.find(query, GoodsEvaluate.class);
    }
    /**
     * 查询有效
     * @param start
     * @param count
     * @param key
     *
     * @param goodsType
     * @param goodsId
     * @param limitTime
     * @return
     */
    public List<GoodsEvaluate> queryExistLimitTime(int goodsType, String goodsId, Date limitTime) {
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/brand/BrandClassMapper.java
@@ -2,6 +2,7 @@
import java.util.List;
import com.yeshi.fanli.entity.SystemEnum;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
@@ -13,7 +14,7 @@
     * 查询品牌分类
     * @return
     */
    List<BrandClass> listEffective();
    List<BrandClass> listEffective(@Param("system")SystemEnum system);
    
    /**
     * 排序
@@ -23,7 +24,6 @@
    
    /**
     * 获取相邻序号
     * @param position
     * @param type
     * @return
     */
@@ -47,8 +47,8 @@
     * @return
     */
    List<BrandClass> listQuery(@Param("start") long start, @Param("count") int count, @Param("key") String key,
            @Param("state") Integer state);
            @Param("state") Integer state,@Param("system") SystemEnum system);
    
    long countQuery(@Param("key") String key, @Param("state") Integer state);
    long countQuery(@Param("key") String key, @Param("state") Integer state,@Param("system")SystemEnum system);
        
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/brand/BrandClassSystemMapMapper.java
New file
@@ -0,0 +1,13 @@
package com.yeshi.fanli.dao.mybatis.brand;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.brand.BrandClassSystemMap;
import org.apache.ibatis.annotations.Param;
import javax.annotation.Nullable;
import java.util.List;
public interface BrandClassSystemMapMapper extends BaseMapper<BrandClassSystemMap> {
    List<BrandClassSystemMap> listByClassIdsAndSystem(@Nullable @Param("classIdList") List<Long> idList, @Param("system") SystemEnum system);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/common/CommonConfigMapper.java
New file
@@ -0,0 +1,10 @@
package com.yeshi.fanli.dao.mybatis.common;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.config.CommonConfig;
public interface CommonConfigMapper extends BaseMapper<CommonConfig> {
    CommonConfig selectByKey(String key);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/help/AppPageNotificationMapper.java
@@ -2,6 +2,7 @@
import java.util.List;
import com.yeshi.fanli.entity.SystemEnum;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.entity.bus.help.AppPageNotification;
@@ -16,21 +17,6 @@
    AppPageNotification selectByPrimaryKey(Long id);
    /**
     * 通过类型获取通知
     *
     * @param type
     * @return
     */
    AppPageNotification selectByType(String type);
    /**
     * 通过类型获取有效通知
     *
     * @param type
     * @return
     */
    List<AppPageNotification> listValidByType(String type);
    int updateByPrimaryKeySelective(AppPageNotification record);
@@ -44,11 +30,27 @@
    int deleteBatchByPrimaryKey(List<Long> list);
    /**
     * 通过类型获取通知
     *
     * @param type
     * @return
     */
    AppPageNotification selectByType(@Param("type") String type,@Param("system")  SystemEnum system);
    /**
     * 通过类型获取有效通知
     *
     * @param type
     * @return
     */
    List<AppPageNotification> listValidByType(@Param("type") String type,@Param("system")  SystemEnum system);
    /**
     * 后端列表查询
     * @return
     */
    List<AppPageNotification> listQuery(@Param("start") long start, @Param("count") int count, @Param("key") String key,
            @Param("show") Integer show, @Param("canClose") Integer canClose);
            @Param("show") Integer show, @Param("canClose") Integer canClose,@Param("system")  SystemEnum system);
    long countQuery(@Param("key") String key, @Param("show") Integer show, @Param("canClose") Integer canClose);
    long countQuery(@Param("key") String key, @Param("show") Integer show, @Param("canClose") Integer canClose,@Param("system")  SystemEnum system);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/help/HelpCenterMapper.java
@@ -2,6 +2,7 @@
import java.util.List;
import com.yeshi.fanli.entity.SystemEnum;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
@@ -19,14 +20,14 @@
     * @return
     */
    List<HelpCenter> listValid(@Param("pageId") Long pageId, @Param("count") int count, 
            @Param("key") String title, @Param("cid") Long cid);
            @Param("key") String title, @Param("cid") Long cid,@Param("system") SystemEnum system);
    
    
    List<HelpCenter> query(@Param("start") int start, @Param("count") int count, 
            @Param("key") String title, @Param("cid") Long cid,
             @Param("orderMode") Integer orderMode,  @Param("state") Integer state);
             @Param("orderMode") Integer orderMode,  @Param("state") Integer state,@Param("system") SystemEnum system);
    
    long countQuery(@Param("key") String title, @Param("cid") Long cid, @Param("state") Integer state);
    long countQuery(@Param("key") String title, @Param("cid") Long cid, @Param("state") Integer state,@Param("system") SystemEnum system);
    
    /**
     * 批量删除
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/help/HelpClassMapper.java
@@ -2,6 +2,7 @@
import java.util.List;
import com.yeshi.fanli.entity.SystemEnum;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
@@ -24,9 +25,9 @@
     * @return
     */
    List<HelpClass> listQuery(@Param("start") long start, @Param("count") int count, 
            @Param("key") String key, @Param("state") Integer state);
            @Param("key") String key, @Param("state") Integer state, @Param("system") SystemEnum system );
    
    long countQuery(@Param("key") String key, @Param("state") Integer state);
    long countQuery(@Param("key") String key, @Param("state") Integer state, @Param("system") SystemEnum system);
    
    
    /**
@@ -41,7 +42,7 @@
     * @param sort 排序值
     * @return
     */
    HelpClass getChangeOrder(@Param("type") Integer type, @Param("sort") Integer sort);
    HelpClass getChangeOrder(@Param("type") Integer type, @Param("sort") Integer sort, @Param("system") SystemEnum system);
    
    
    /**
@@ -49,11 +50,11 @@
     * @param state
     * @return
     */
    List<HelpClass> getClassByState(@Param("state") Integer state);
    List<HelpClass> getClassByState(@Param("state") Integer state, @Param("system") SystemEnum system);
    
    /**
     * 查询所有分类 提供筛选
     * @return
     */
    List<HelpClass> getProvidedClass();
    List<HelpClass> getProvidedClass( @Param("system") SystemEnum system);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/homemodule/HomeNavbarMapper.java
@@ -2,6 +2,7 @@
import java.util.List;
import com.yeshi.fanli.entity.SystemEnum;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
@@ -74,29 +75,29 @@
     * @param key
     * @return
     */
    List<HomeNavbar> listQuery(@Param("start") long start, @Param("count") int count, @Param("key") String key, @Param("sex") Integer sex);
    List<HomeNavbar> listQuery(@Param("start") long start, @Param("count") int count, @Param("key") String key, @Param("sex") Integer sex, @Param("system") SystemEnum system);
    
    long countListQuery(@Param("key") String key, @Param("sex") Integer sex);
    long countListQuery(@Param("key") String key, @Param("sex") Integer sex, @Param("system") SystemEnum system);
    
    /**
     * 查询有效导航栏
     * @return
     */
    List<HomeNavbar> listQueryEffective();
    List<HomeNavbar> listQueryEffective( @Param("system") SystemEnum system);
    
    
    /**
     * 默认导航栏
     * @return
     */
    List<HomeNavbar> listQueryDefaultNavbar(@Param("sex") Integer sex);
    List<HomeNavbar> listQueryDefaultNavbar(@Param("sex") Integer sex, @Param("system") SystemEnum system);
    
    
    /**
     *  固定导航栏
     * @return
     */
    List<HomeNavbar> listQueryFixedNavbar();
    List<HomeNavbar> listQueryFixedNavbar( @Param("system") SystemEnum system);
    
    
    /**
@@ -104,6 +105,6 @@
     * @param classId
     * @return
     */
    HomeNavbar getEffectiveByClassId(@Param("classId") Long classId);
    HomeNavbar getEffectiveByClassId(@Param("classId") Long classId, @Param("system") SystemEnum system);
    
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/PushCouponMapper.java
@@ -2,6 +2,7 @@
import java.util.List;
import com.yeshi.fanli.entity.SystemEnum;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
@@ -17,14 +18,14 @@
     * @return
     */
    List<PushCoupon> listQuery(@Param("start") long start, @Param("count") int count,
            @Param("key") String key, @Param("state") Integer state);
                               @Param("key") String key, @Param("state") Integer state, @Param("system")SystemEnum system);
    
    long countQuery(@Param("key") String key, @Param("state") Integer state);
    long countQuery(@Param("key") String key, @Param("state") Integer state, @Param("system")SystemEnum system);
    
    
    /**
     * 有效活动
     * @return
     */
    List<PushCoupon> listQueryEffective();
    List<PushCoupon> listQueryEffective(@Param("system")SystemEnum system);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/PushGoodsMapper.java
@@ -3,6 +3,7 @@
import java.util.Date;
import java.util.List;
import com.yeshi.fanli.entity.SystemEnum;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.entity.push.PushGoods;
@@ -36,9 +37,9 @@
     * @return
     */
    List<PushGoods> listQuery(@Param("start") long start, @Param("count") int count,
            @Param("key") String key, @Param("state") Integer state);
                              @Param("key") String key, @Param("state") Integer state, @Param("system") SystemEnum system);
    
    long countQuery(@Param("key") String key, @Param("state") Integer state);
    long countQuery(@Param("key") String key, @Param("state") Integer state, @Param("system") SystemEnum system);
    
    
    /**
@@ -49,16 +50,16 @@
     * @return
     */
    List<PushGoods> listHistoryByPushTime(@Param("start") long start, @Param("count") int count,
         @Param("uid") Long uid, @Param("pushTime") Date pushTime);
         @Param("uid") Long uid, @Param("pushTime") Date pushTime, @Param("system") SystemEnum system);
    /**
     * 统计历史推送商品信息
     * @param start
     * @param count
     * @param uid
     * @param pushTime
     * @param system
     * @return
     */
    long countHistoryByPushTime(@Param("uid") Long uid, @Param("pushTime") Date pushTime);
    long countHistoryByPushTime(@Param("uid") Long uid, @Param("pushTime") Date pushTime, @Param("system") SystemEnum system);
    
    /**
     * 查询已推送记录
@@ -72,6 +73,6 @@
     * 需要执行推送的任务
     * @return
     */
    List<PushGoods> listTask();
    List<PushGoods> listTask( @Param("system") SystemEnum system);
    
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/PushInfoMapper.java
@@ -2,6 +2,7 @@
import java.util.List;
import com.yeshi.fanli.entity.SystemEnum;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
@@ -23,14 +24,14 @@
     */
    List<PushInfo> listQuery(@Param("start") long start, @Param("count") int count,
             @Param("key") String key, @Param("keyType") Integer keyType, @Param("state") Integer state
             ,  @Param("type")String type);
             ,  @Param("type")String type, @Param("system") SystemEnum system);
    
    long countQuery(@Param("key") String key, @Param("keyType") Integer keyType,
            @Param("state") Integer state,  @Param("type")String type);
            @Param("state") Integer state,  @Param("type")String type, @Param("system") SystemEnum system);
    
    /**
     * 需要执行推送的任务
     * @return
     */
    List<PushInfo> listTask();
    List<PushInfo> listTask(@Param("system") SystemEnum system);
}
fanli/src/main/java/com/yeshi/fanli/dto/push/PushBaseContent.java
New file
@@ -0,0 +1,55 @@
package com.yeshi.fanli.dto.push;
import com.yeshi.fanli.entity.SystemEnum;
import java.util.List;
public class PushBaseContent {
    private String title;
    private String content;
    private List<Integer> versionCodeList;
    private SystemEnum system;
    public PushBaseContent() {
    }
    public PushBaseContent(String title, String content, List<Integer> versionCodeList, SystemEnum system) {
        this.title = title;
        this.content = content;
        this.versionCodeList = versionCodeList;
        this.system = system;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public List<Integer> getVersionCodeList() {
        return versionCodeList;
    }
    public void setVersionCodeList(List<Integer> versionCodeList) {
        this.versionCodeList = versionCodeList;
    }
    public SystemEnum getSystem() {
        return system;
    }
    public void setSystem(SystemEnum system) {
        this.system = system;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/brand/BrandClassSystemMap.java
New file
@@ -0,0 +1,51 @@
package com.yeshi.fanli.entity.brand;
import com.yeshi.fanli.entity.SystemEnum;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
import java.util.Date;
@Table("yeshi_ec_brand_class_system_map")
public class BrandClassSystemMap {
    @Column(name="sm_id")
    private Long id;
    @Column(name="sm_system")
    private SystemEnum system;
    @Column(name="sm_brand_class_id")
    private BrandClass brandClass;
    @Column(name="sm_create_time")
    private Date createTime;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public SystemEnum getSystem() {
        return system;
    }
    public void setSystem(SystemEnum system) {
        this.system = system;
    }
    public BrandClass getBrandClass() {
        return brandClass;
    }
    public void setBrandClass(BrandClass brandClass) {
        this.brandClass = brandClass;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/help/AppPageNotification.java
@@ -7,6 +7,7 @@
import com.google.gson.annotations.Expose;
import com.yeshi.fanli.entity.SystemEnum;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
@@ -113,6 +114,17 @@
    
    @Column(name = "an_updatetime")
    private Date updateTime;// 更新时间
    //系统
    @Column(name = "an_system")
    private SystemEnum system;
    public SystemEnum getSystem() {
        return system;
    }
    public void setSystem(SystemEnum system) {
        this.system = system;
    }
    @Transient // 页面名称
    private String pageName;
fanli/src/main/java/com/yeshi/fanli/entity/bus/help/HelpCenter.java
@@ -3,6 +3,7 @@
import java.io.Serializable;
import java.util.Date;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.format.annotation.DateTimeFormat;
import org.yeshi.utils.mybatis.Column;
@@ -55,7 +56,17 @@
    @Column(name = "h_updatetime")
    private Date updatetime; // 更新时间(修改时间)
    @Column(name = "h_system")
    private SystemEnum system; //系统
    public SystemEnum getSystem() {
        return system;
    }
    public void setSystem(SystemEnum system) {
        this.system = system;
    }
    public Long getId() {
        return id;
fanli/src/main/java/com/yeshi/fanli/entity/bus/help/HelpClass.java
@@ -3,6 +3,7 @@
import java.io.Serializable;
import java.util.Date;
import com.yeshi.fanli.entity.SystemEnum;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
@@ -61,8 +62,19 @@
    // 更新时间
    @Column(name = "hc_update_time")
    private Date updateTime;
    //系统
    @Column(name = "hc_system")
    private SystemEnum system;
    public SystemEnum getSystem() {
        return system;
    }
    public void setSystem(SystemEnum system) {
        this.system = system;
    }
    private String startTime_str;
    private String endTime_str;
    
fanli/src/main/java/com/yeshi/fanli/entity/bus/homemodule/HomeNavbar.java
@@ -3,6 +3,7 @@
import java.io.Serializable;
import java.util.Date;
import com.yeshi.fanli.entity.SystemEnum;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
@@ -110,7 +111,19 @@
    @Expose
    @Column(name = "br_params")
    private String params;
    @Column(name = "br_system")
    private SystemEnum system;
    public SystemEnum getSystem() {
        return system;
    }
    public void setSystem(SystemEnum system) {
        this.system = system;
    }
    // 起始时间
    private String startTime_str;
    // 结束时间
fanli/src/main/java/com/yeshi/fanli/entity/config/CommonConfig.java
New file
@@ -0,0 +1,72 @@
package com.yeshi.fanli.entity.config;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
/**
 * 通用配置
 */
@Table("yeshi_ec_common_config")
public class CommonConfig {
    @Column(name = "id")
    private Long id;
    @Column(name = "key")
    private String key;
    @Column(name = "value")
    private String value;
    @Column(name = "name")
    private String name;
    @Column(name = "beizhu")
    private String beizhu;
    @Column(name = "createtime")
    private String createtime;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getKey() {
        return key;
    }
    public void setKey(String key) {
        this.key = key;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getBeizhu() {
        return beizhu;
    }
    public void setBeizhu(String beizhu) {
        this.beizhu = beizhu;
    }
    public String getCreatetime() {
        return createtime;
    }
    public void setCreatetime(String createtime) {
        this.createtime = createtime;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/dynamic/GoodsEvaluate.java
@@ -5,6 +5,7 @@
import java.util.Date;
import java.util.List;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
@@ -16,321 +17,333 @@
/**
 * 动态商品测评
 *
 * @author Administrator
 *
 * @author Administrator
 */
@Document(collection = "goods_evaluate")
public class GoodsEvaluate implements Serializable {
    private static final long serialVersionUID = 1L;
    private static final long serialVersionUID = 1L;
    // 图片格式: 一排显示: 0无图 1一张 2两张 3张
    public final static int LINE_NUM_ZERO = 0;
    public final static int LINE_NUM_ONE = 1;
    public final static int LINE_NUM_TWO = 2;
    public final static int LINE_NUM_THREE = 3;
    // 图片格式: 一排显示: 0无图 1一张 2两张 3张
    public final static int LINE_NUM_ZERO = 0;
    public final static int LINE_NUM_ONE = 1;
    public final static int LINE_NUM_TWO = 2;
    public final static int LINE_NUM_THREE = 3;
    public enum EvaluateEnum {
        single("单品"), multiple("多品"), activity("活动");
    public enum EvaluateEnum {
        single("单品"), multiple("多品"), activity("活动");
        private final String desc;
        private final String desc;
        private EvaluateEnum(String desc) {
            this.desc = desc;
        }
        private EvaluateEnum(String desc) {
            this.desc = desc;
        }
        public String getDesc() {
            return desc;
        }
    }
        public String getDesc() {
            return desc;
        }
    }
    @Id
    @Expose
    @Field("_id")
    private String id;
    @Id
    @Expose
    @Field("_id")
    private String id;
    // 类型
    @Field("type")
    private EvaluateEnum type;
    // 类型
    @Field("type")
    private EvaluateEnum type;
    @Expose
    @Field("user")
    private ActivityUser user; // 发布用户
    @Expose
    @Field("user")
    private ActivityUser user; // 发布用户
    @Expose
    @Field("title")
    private String title; // 发布内容
    @Expose
    @Field("title")
    private String title; // 发布内容
    @Expose
    @Field("shareNum")
    private Integer shareNum; // 分享次数
    @Expose
    @Field("shareNum")
    private Integer shareNum; // 分享次数
    // 图片一行显示: 0无图 1一张 2两张 3张
    @Expose
    @Field("lineNum")
    private Integer lineNum;
    // 图片一行显示: 0无图 1一张 2两张 3张
    @Expose
    @Field("lineNum")
    private Integer lineNum;
    @Expose
    @Field("imgList")
    private List<ImgInfo> imgList = new ArrayList<ImgInfo>(); // 图片信息
    @Expose
    @Field("imgList")
    private List<ImgInfo> imgList = new ArrayList<ImgInfo>(); // 图片信息
    @Field("shareNumReal")
    private Integer shareNumReal; // 分享次数真实
    @Field("shareNumReal")
    private Integer shareNumReal; // 分享次数真实
    @Expose
    @Field("goods")
    private GoodsDetailVO goods; // 商品信息
    @Expose
    @Field("goods")
    private GoodsDetailVO goods; // 商品信息
    @Expose
    @Field("comments")
    private List<CommentInfo> comments = new ArrayList<CommentInfo>(); // 评论信息
    @Expose
    @Field("comments")
    private List<CommentInfo> comments = new ArrayList<CommentInfo>(); // 评论信息
    @Expose
    @Field("publishTime")
    private Date publishTime; // 发布时间
    @Expose
    @Field("publishTime")
    private Date publishTime; // 发布时间
    @Field("state")
    private Integer state; // 状态
    @Field("state")
    private Integer state; // 状态
    @Field("weight")
    private Double weight; // 权重
    @Field("weight")
    private Double weight; // 权重
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Field("startTime")
    private Date startTime; // 开始时间
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Field("startTime")
    private Date startTime; // 开始时间
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Field("endTime")
    private Date endTime; // 结束时间
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Field("endTime")
    private Date endTime; // 结束时间
    @Field("createTime")
    private Date createTime; // 创建时间
    @Field("createTime")
    private Date createTime; // 创建时间
    @Field("updateTime")
    private Date updateTime; // 更新时间
    @Field("updateTime")
    private Date updateTime; // 更新时间
    @Field("mainPicNum")
    private Integer mainPicNum; // 图片主图
    @Field("mainPicNum")
    private Integer mainPicNum; // 图片主图
    @Field("dynamicType")
    private Integer dynamicType; // 1发圈 2素材
    @Field("dynamicType")
    private Integer dynamicType; // 1发圈 2素材
    @Field("zeroPoint")
    private Integer zeroPoint; // 是否0点活动-10点进行发圈     1-是
    @Field("zeroPoint")
    private Integer zeroPoint; // 是否0点活动-10点进行发圈     1-是
    @Expose
    @Field("jumpLink")
    private String jumpLink;
    @Field("system")
    private SystemEnum system; // 系统
    // 是否云发单
    @Expose
    private boolean cloud;
    private String startTimeChar;
    private String endTimeChar;
    @Expose
    @Field("jumpLink")
    private String jumpLink;
    // 备注
    private String remarks;
    // 是否云发单
    @Expose
    private boolean cloud;
    public String getId() {
        return id;
    }
    private String startTimeChar;
    private String endTimeChar;
    public void setId(String id) {
        this.id = id;
    }
    // 备注
    private String remarks;
    public ActivityUser getUser() {
        return user;
    }
    public void setUser(ActivityUser user) {
        this.user = user;
    }
    public SystemEnum getSystem() {
        return system;
    }
    public String getTitle() {
        return title;
    }
    public void setSystem(SystemEnum system) {
        this.system = system;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getId() {
        return id;
    }
    public List<ImgInfo> getImgList() {
        return imgList;
    }
    public void setId(String id) {
        this.id = id;
    }
    public void setImgList(List<ImgInfo> imgList) {
        this.imgList = imgList;
    }
    public ActivityUser getUser() {
        return user;
    }
    public Integer getLineNum() {
        return lineNum;
    }
    public void setUser(ActivityUser user) {
        this.user = user;
    }
    public void setLineNum(Integer lineNum) {
        this.lineNum = lineNum;
    }
    public String getTitle() {
        return title;
    }
    public Integer getShareNum() {
        return shareNum;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public List<ImgInfo> getImgList() {
        return imgList;
    }
    public void setImgList(List<ImgInfo> imgList) {
        this.imgList = imgList;
    }
    public Integer getLineNum() {
        return lineNum;
    }
    public void setLineNum(Integer lineNum) {
        this.lineNum = lineNum;
    }
    public Integer getShareNum() {
        return shareNum;
    }
    public void setShareNum(Integer shareNum) {
        this.shareNum = shareNum;
    }
    public void setShareNum(Integer shareNum) {
        this.shareNum = shareNum;
    }
    public GoodsDetailVO getGoods() {
        return goods;
    }
    public GoodsDetailVO getGoods() {
        return goods;
    }
    public void setGoods(GoodsDetailVO goods) {
        this.goods = goods;
    }
    public void setGoods(GoodsDetailVO goods) {
        this.goods = goods;
    }
    public List<CommentInfo> getComments() {
        return comments;
    }
    public List<CommentInfo> getComments() {
        return comments;
    }
    public void setComments(List<CommentInfo> comments) {
        this.comments = comments;
    }
    public void setComments(List<CommentInfo> comments) {
        this.comments = comments;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Integer getState() {
        return state;
    }
    public Integer getState() {
        return state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
    public Double getWeight() {
        return weight;
    }
    public Double getWeight() {
        return weight;
    }
    public void setWeight(Double weight) {
        this.weight = weight;
    }
    public void setWeight(Double weight) {
        this.weight = weight;
    }
    public Date getStartTime() {
        return startTime;
    }
    public Date getStartTime() {
        return startTime;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public Date getEndTime() {
        return endTime;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public Integer getShareNumReal() {
        return shareNumReal;
    }
    public Integer getShareNumReal() {
        return shareNumReal;
    }
    public void setShareNumReal(Integer shareNumReal) {
        this.shareNumReal = shareNumReal;
    }
    public void setShareNumReal(Integer shareNumReal) {
        this.shareNumReal = shareNumReal;
    }
    public String getStartTimeChar() {
        return startTimeChar;
    }
    public String getStartTimeChar() {
        return startTimeChar;
    }
    public void setStartTimeChar(String startTimeChar) {
        this.startTimeChar = startTimeChar;
    }
    public void setStartTimeChar(String startTimeChar) {
        this.startTimeChar = startTimeChar;
    }
    public String getEndTimeChar() {
        return endTimeChar;
    }
    public String getEndTimeChar() {
        return endTimeChar;
    }
    public void setEndTimeChar(String endTimeChar) {
        this.endTimeChar = endTimeChar;
    }
    public void setEndTimeChar(String endTimeChar) {
        this.endTimeChar = endTimeChar;
    }
    public Date getPublishTime() {
        return publishTime;
    }
    public Date getPublishTime() {
        return publishTime;
    }
    public void setPublishTime(Date publishTime) {
        this.publishTime = publishTime;
    }
    public void setPublishTime(Date publishTime) {
        this.publishTime = publishTime;
    }
    public Integer getMainPicNum() {
        return mainPicNum;
    }
    public Integer getMainPicNum() {
        return mainPicNum;
    }
    public void setMainPicNum(Integer mainPicNum) {
        this.mainPicNum = mainPicNum;
    }
    public void setMainPicNum(Integer mainPicNum) {
        this.mainPicNum = mainPicNum;
    }
    public EvaluateEnum getType() {
        return type;
    }
    public EvaluateEnum getType() {
        return type;
    }
    public void setType(EvaluateEnum type) {
        this.type = type;
    }
    public void setType(EvaluateEnum type) {
        this.type = type;
    }
    public Integer getDynamicType() {
        return dynamicType;
    }
    public Integer getDynamicType() {
        return dynamicType;
    }
    public void setDynamicType(Integer dynamicType) {
        this.dynamicType = dynamicType;
    }
    public void setDynamicType(Integer dynamicType) {
        this.dynamicType = dynamicType;
    }
    public String getRemarks() {
        return remarks;
    }
    public String getRemarks() {
        return remarks;
    }
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }
    public String getJumpLink() {
        return jumpLink;
    }
    public String getJumpLink() {
        return jumpLink;
    }
    public void setJumpLink(String jumpLink) {
        this.jumpLink = jumpLink;
    }
    public void setJumpLink(String jumpLink) {
        this.jumpLink = jumpLink;
    }
    public boolean isCloud() {
        return cloud;
    }
    public boolean isCloud() {
        return cloud;
    }
    public void setCloud(boolean cloud) {
        this.cloud = cloud;
    }
    public void setCloud(boolean cloud) {
        this.cloud = cloud;
    }
    public Integer getZeroPoint() {
        return zeroPoint;
    }
    public Integer getZeroPoint() {
        return zeroPoint;
    }
    public void setZeroPoint(Integer zeroPoint) {
        this.zeroPoint = zeroPoint;
    }
    public void setZeroPoint(Integer zeroPoint) {
        this.zeroPoint = zeroPoint;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/push/PushCoupon.java
@@ -3,6 +3,7 @@
import java.math.BigDecimal;
import java.util.Date;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.format.annotation.DateTimeFormat;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
@@ -10,178 +11,189 @@
@Table("yeshi_ec_push_coupon")
public class PushCoupon {
    @Column(name = "pc_id")
    private Long id;
    @Column(name = "pc_id")
    private Long id;
    // 显示标题
    @Column(name = "pc_title")
    private String title;
    // 显示标题
    @Column(name = "pc_title")
    private String title;
    // 显示内容
    @Column(name = "pc_content")
    private String content;
    // 显示内容
    @Column(name = "pc_content")
    private String content;
    // 券数量
    @Column(name = "pc_amount")
    private Integer amount;
    // 券数量
    @Column(name = "pc_amount")
    private Integer amount;
    // 券比例
    @Column(name = "pc_percent")
    private BigDecimal percent;
    // 券比例
    @Column(name = "pc_percent")
    private BigDecimal percent;
    // 单推用户id,多租id
    @Column(name = "pc_uids")
    private String uids;
    // 单推用户id,多租id
    @Column(name = "pc_uids")
    private String uids;
    // 版本号
    @Column(name = "pc_versions")
    private String versions;
    // 单推用户id
    @Column(name = "pc_remark")
    private String remark;
    // 版本号
    @Column(name = "pc_versions")
    private String versions;
    // 起始时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Column(name = "pc_start_time")
    private Date startTime;
    // 单推用户id
    @Column(name = "pc_remark")
    private String remark;
    // 结束时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Column(name = "pc_end_time")
    private Date endTime;
    // 起始时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Column(name = "pc_start_time")
    private Date startTime;
    // 是否已推送
    @Column(name = "pc_pushed")
    private boolean pushed;
    // 结束时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Column(name = "pc_end_time")
    private Date endTime;
    // 推送时间
    @Column(name = "pc_push_time")
    private Date pushTime;
    // 是否已推送
    @Column(name = "pc_pushed")
    private boolean pushed;
    @Column(name = "pc_create_time")
    private Date createTime;
    // 推送时间
    @Column(name = "pc_push_time")
    private Date pushTime;
    @Column(name = "pc_update_time")
    private Date updateTime;
    @Column(name = "pc_create_time")
    private Date createTime;
    public PushCoupon() {
    }
    @Column(name = "pc_update_time")
    private Date updateTime;
    public PushCoupon(Long id) {
        this.id = id;
    }
    @Column(name = "pc_system")
    private SystemEnum system;
    public Long getId() {
        return id;
    }
    public SystemEnum getSystem() {
        return system;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public void setSystem(SystemEnum system) {
        this.system = system;
    }
    public String getTitle() {
        return title;
    }
    public PushCoupon() {
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public PushCoupon(Long id) {
        this.id = id;
    }
    public String getContent() {
        return content;
    }
    public Long getId() {
        return id;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Integer getAmount() {
        return amount;
    }
    public String getTitle() {
        return title;
    }
    public void setAmount(Integer amount) {
        this.amount = amount;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public BigDecimal getPercent() {
        return percent;
    }
    public String getContent() {
        return content;
    }
    public void setPercent(BigDecimal percent) {
        this.percent = percent;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getUids() {
        return uids;
    }
    public Integer getAmount() {
        return amount;
    }
    public void setUids(String uids) {
        this.uids = uids;
    }
    public void setAmount(Integer amount) {
        this.amount = amount;
    }
    public String getRemark() {
        return remark;
    }
    public BigDecimal getPercent() {
        return percent;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public void setPercent(BigDecimal percent) {
        this.percent = percent;
    }
    public Date getStartTime() {
        return startTime;
    }
    public String getUids() {
        return uids;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public void setUids(String uids) {
        this.uids = uids;
    }
    public Date getEndTime() {
        return endTime;
    }
    public String getRemark() {
        return remark;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public boolean isPushed() {
        return pushed;
    }
    public Date getStartTime() {
        return startTime;
    }
    public void setPushed(boolean pushed) {
        this.pushed = pushed;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public Date getPushTime() {
        return pushTime;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setPushTime(Date pushTime) {
        this.pushTime = pushTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public boolean isPushed() {
        return pushed;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public void setPushed(boolean pushed) {
        this.pushed = pushed;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public Date getPushTime() {
        return pushTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public void setPushTime(Date pushTime) {
        this.pushTime = pushTime;
    }
    public String getVersions() {
        return versions;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setVersions(String versions) {
        this.versions = versions;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getVersions() {
        return versions;
    }
    public void setVersions(String versions) {
        this.versions = versions;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/push/PushGoods.java
@@ -3,6 +3,7 @@
import java.util.Date;
import java.util.List;
import com.yeshi.fanli.entity.SystemEnum;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
@@ -79,7 +80,18 @@
    // 浏览次数
    @Column(name = "pg_scan_num")
    private Integer scanNum;
    //系统
    @Column(name = "pg_system")
    private SystemEnum system;
    public SystemEnum getSystem() {
        return system;
    }
    public void setSystem(SystemEnum system) {
        this.system = system;
    }
    // 定时时间
    private String controlTime_str;
    
fanli/src/main/java/com/yeshi/fanli/entity/push/PushInfo.java
@@ -3,6 +3,7 @@
import java.util.Date;
import java.util.List;
import com.yeshi.fanli.entity.SystemEnum;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
@@ -64,6 +65,17 @@
    @Column(name = "pi_update_time")
    private Date updateTime;
    @Column(name = "pi_system")
    private SystemEnum system;
    public SystemEnum getSystem() {
        return system;
    }
    public void setSystem(SystemEnum system) {
        this.system = system;
    }
    // 推送URL
    private String url;
    // 是否定时
fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java
@@ -8,6 +8,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -54,474 +55,476 @@
@Component
public class DynamicInfoJob {
    @Resource
    private DynamicInfoService dynamicInfoService;
    @Resource
    private DynamicInfoService dynamicInfoService;
    @Resource
    private ActivityService activityService;
    @Resource
    private ActivityService activityService;
    @Resource
    private NYouHuiService nyouHuiService;
    @Resource
    private NYouHuiService nyouHuiService;
    @Resource
    private ActivityUserService activityUserService;
    @Resource
    private ActivityUserService activityUserService;
    @Resource
    private WXMPDynamicInfoService wxmpDynamicInfoService;
    @Resource
    private WXMPDynamicInfoService wxmpDynamicInfoService;
    @Resource
    private ConvertLinkManager convertLinkManager;
    @Resource
    private ConvertLinkManager convertLinkManager;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    @Resource
    private GoodsEvaluateService goodsEvaluateService;
    @Resource
    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
    @Resource
    private GoodsEvaluateService goodsEvaluateService;
    /**
     * 每10分钟 晚上00:00~06:00不下发任何一个商品
     */
    @Scheduled(cron = "0 0/10 6-23 * * ?")
    public void insetDynamicInfo() {
    @Resource
    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
        if (!Constant.IS_TASK) {
            return;
        }
    /**
     * 每10分钟 晚上00:00~06:00不下发任何一个商品
     */
    @Scheduled(cron = "0 0/10 6-23 * * ?")
    public void insetDynamicInfo() {
        try {
            dynamicInfoService.insertTimeHotSale();
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
        if (!Constant.IS_TASK) {
            return;
        }
        try {
            dynamicInfoService.insertTimeRecommend();
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        try {
            dynamicInfoService.insertTimeHotSale();
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    /**
     * 早上6,7,15,16,21,22,23点更新1次
     */
    @Scheduled(cron = "0 0 6,7,15,16,21,22,23 * * ? ")
    public void insetShopInfo1() {
        try {
            dynamicInfoService.insertTimeRecommend();
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        if (!Constant.IS_TASK) {
            return;
        }
    /**
     * 早上6,7,15,16,21,22,23点更新1次
     */
    @Scheduled(cron = "0 0 6,7,15,16,21,22,23 * * ? ")
    public void insetShopInfo1() {
        try {
            dynamicInfoService.insertShopInfo();
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        if (!Constant.IS_TASK) {
            return;
        }
    /**
     * 早上8:00~10:00每半个小时更新
     */
    @Scheduled(cron = "0 0/30 8,9,10 * * ?")
    public void insetShopInfo2() {
        try {
            dynamicInfoService.insertShopInfo();
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        if (!Constant.IS_TASK) {
            return;
        }
    /**
     * 早上8:00~10:00每半个小时更新
     */
    @Scheduled(cron = "0 0/30 8,9,10 * * ?")
    public void insetShopInfo2() {
        try {
            dynamicInfoService.insertShopInfo();
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        if (!Constant.IS_TASK) {
            return;
        }
    /**
     * 早上11:00~14:00每半个小时更新
     */
    @Scheduled(cron = "0 0/30 11,12,13,14 * * ?")
    public void insetShopInfo3() {
        try {
            dynamicInfoService.insertShopInfo();
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        if (!Constant.IS_TASK) {
            return;
        }
    /**
     * 早上11:00~14:00每半个小时更新
     */
    @Scheduled(cron = "0 0/30 11,12,13,14 * * ?")
    public void insetShopInfo3() {
        try {
            dynamicInfoService.insertShopInfo();
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        if (!Constant.IS_TASK) {
            return;
        }
    /**
     * 下午17:00~20:00每半个小时更新
     */
    @Scheduled(cron = "0 0/30 17,18,19,20 * * ? ")
    public void insetShopInfo4() {
        try {
            dynamicInfoService.insertShopInfo();
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        if (!Constant.IS_TASK) {
            return;
        }
    /**
     * 下午17:00~20:00每半个小时更新
     */
    @Scheduled(cron = "0 0/30 17,18,19,20 * * ? ")
    public void insetShopInfo4() {
        try {
            dynamicInfoService.insertShopInfo();
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        if (!Constant.IS_TASK) {
            return;
        }
    /**
     * 每天零点删除3天之前数据
     */
    @Scheduled(cron = "0 0 1,10 * * ?")
    public void remove() {
        try {
            dynamicInfoService.insertShopInfo();
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        if (!Constant.IS_TASK) {
            return;
        }
    /**
     * 每天零点删除3天之前数据
     */
    @Scheduled(cron = "0 0 1,10 * * ?")
    public void remove() {
        try {
            LogHelper.test("DynamicInfoJob-remove-开始执行态");
            dynamicInfoService.removeByDate(DateUtil.reduceDay(2, new Date()));
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        if (!Constant.IS_TASK) {
            return;
        }
    /**
     * 后台编辑动态: 每3分钟检索
     */
    @Scheduled(cron = "0 0/3 * * * ?")
    public void activityNeedPublish() {
        if (!Constant.IS_TASK) {
            return;
        }
        try {
            LogHelper.test("DynamicInfoJob-remove-开始执行态");
            dynamicInfoService.removeByDate(DateUtil.reduceDay(2, new Date()));
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        try {
            List<RecommendActivity> list = activityService.getNeedPublish();
            if (list == null || list.size() == 0) {
                return;
            }
    /**
     * 后台编辑动态: 每3分钟检索
     */
    @Scheduled(cron = "0 0/3 * * * ?")
    public void activityNeedPublish() {
        if (!Constant.IS_TASK) {
            return;
        }
            for (RecommendActivity activity : list) {
                Integer type = activity.getType();
                if (RecommendActivity.TYPE_SHARE_GOODS == type) {
                    // 商品动态
                    dynamicInfoService.insertActivityRecommend(activity);
        try {
            List<RecommendActivity> list = activityService.getNeedPublish();
            if (list == null || list.size() == 0) {
                return;
            }
                    activity.setState(1);
                    activityService.updateByPrimaryKeySelective(activity);
            for (RecommendActivity activity : list) {
                Integer type = activity.getType();
                if (RecommendActivity.TYPE_SHARE_GOODS == type) {
                    // 商品动态
                    dynamicInfoService.insertActivityRecommend(activity);
                } else if (RecommendActivity.TYPE_INVITE == type) {
                    // 邀请素材
                    RecommendActivityInviteInfo inviteInfo = activityService
                            .getRecommendActivityInviteInfoByActivityId(activity.getId());
                    activity.setInviteInfo(inviteInfo);
                    activity.setState(1);
                    activityService.updateByPrimaryKeySelective(activity);
                    dynamicInfoService.insertInviteActivity(activity);
                } else if (RecommendActivity.TYPE_INVITE == type) {
                    // 邀请素材
                    RecommendActivityInviteInfo inviteInfo = activityService
                            .getRecommendActivityInviteInfoByActivityId(activity.getId());
                    activity.setInviteInfo(inviteInfo);
                    activity.setState(1);
                    activityService.updateByPrimaryKeySelective(activity);
                }
            }
                    dynamicInfoService.insertInviteActivity(activity);
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
                    activity.setState(1);
                    activityService.updateByPrimaryKeySelective(activity);
                }
            }
    /**
     * 每天6点天更新邀请素材
     */
    @Scheduled(cron = "0 0 6 * * ?")
    public void insertTimeInvite() {
        if (!Constant.IS_TASK) {
            return;
        }
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        try {
            dynamicInfoService.insertTimeInvite();
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    /**
     * 每天6点天更新邀请素材
     */
    @Scheduled(cron = "0 0 6 * * ?")
    public void insertTimeInvite() {
        if (!Constant.IS_TASK) {
            return;
        }
    /**
     *
     * @Title: demoJobHandler @Description: 更新小程序动态商品 @param
     * param @return @throws Exception ReturnT<String> 返回类型 @throws
     */
    @XxlJob("dynamic-updateWXMPDynamicInfo")
    public ReturnT<String> updateWXMPDynamicInfoHandler(String param) throws Exception {
        addJDNYHInfo();
        return ReturnT.SUCCESS;
    }
        try {
            dynamicInfoService.insertTimeInvite();
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    /**
     * 添加内优惠相关商品 @Title: addJDNYHInfo @Description: void 返回类型 @throws
     */
    private void addJDNYHInfo() throws Exception {
    /**
     * @Title: demoJobHandler @Description: 更新小程序动态商品 @param
     * param @return @throws Exception ReturnT<String> 返回类型 @throws
     */
    @XxlJob("dynamic-updateWXMPDynamicInfo")
    public ReturnT<String> updateWXMPDynamicInfoHandler(String param) throws Exception {
        addJDNYHInfo();
        return ReturnT.SUCCESS;
    }
        List<NYouHuiGoods> list = nyouHuiService.list(1, 1);
        if (list != null && list.size() > 0) {
            NYouHuiGoods goods = list.get(0);
            String id = goods.toId();
            WXMPDynamicInfo info = new WXMPDynamicInfo();
            info.setId(WXMPDynamicInfo.SOURCE_NYH + "#" + id);
            String desc = goods.getDesc();
    /**
     * 添加内优惠相关商品 @Title: addJDNYHInfo @Description: void 返回类型 @throws
     */
    private void addJDNYHInfo() throws Exception {
            info.setSource(WXMPDynamicInfo.SOURCE_NYH);
            info.setUser(activityUserService.getRandomHaoHuo());
            // 做链接转换
            for (String link : goods.getLinkList()) {
                desc = desc.replaceFirst("\\[链接\\]", link);
            }
        List<NYouHuiGoods> list = nyouHuiService.list(1, 1);
        if (list != null && list.size() > 0) {
            NYouHuiGoods goods = list.get(0);
            String id = goods.toId();
            WXMPDynamicInfo info = new WXMPDynamicInfo();
            info.setId(WXMPDynamicInfo.SOURCE_NYH + "#" + id);
            String desc = goods.getDesc();
            desc = convertLinkManager.convertJDLinkFromText(desc, 0L, true);
            info.setContent(desc);
            info.setSource(WXMPDynamicInfo.SOURCE_NYH);
            info.setUser(activityUserService.getRandomHaoHuo());
            // 做链接转换
            for (String link : goods.getLinkList()) {
                desc = desc.replaceFirst("\\[链接\\]", link);
            }
            List<JDGoods> goodsList = JDApiUtil.queryGoodsDetail(goods.getSkuList());
            List<GoodsPicture> imgs = new ArrayList<>();
            desc = convertLinkManager.convertJDLinkFromText(desc, 0L, true);
            info.setContent(desc);
            BigDecimal totalMoney = new BigDecimal(0);
            List<String> lastPicture = new ArrayList<>();
            for (JDGoods jdGoods : goodsList) {
                GoodsPicture picture = new GoodsPicture();
                BigDecimal money = JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getShareRate());
                totalMoney = totalMoney.add(money);
                picture.setGoodsVO(
                        GoodsDetailVOFactory.convertJDGoods(jdGoods,
                                new ConfigParamsDTO(hongBaoManageService.getFanLiRate(),
                                        hongBaoManageService.getShareRate(), null,
                                        hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
                picture.setGoodState(0);
                picture.setJumpDetail(jumpDetailV2Service.getByTypeCache("goodsdetail"));
                picture.setParams(null);
                picture.setUrl(jdGoods.getPicUrl());
                imgs.add(picture);
                if (jdGoods.getImageList() != null)
                    if (jdGoods.getImageList().size() > 4)
                        lastPicture.addAll(jdGoods.getImageList().subList(1, 4));
                    else if (jdGoods.getImageList().size() > 1)
                        lastPicture.addAll(jdGoods.getImageList().subList(1, jdGoods.getImageList().size()));
            }
            info.setShareMoney(totalMoney);
            int count = 0;
            while (imgs.size() < 4 && count < 4) {
                count++;
                String picurl = lastPicture.get((int) (lastPicture.size() * Math.random()));
                if (picurl != null) {
                    lastPicture.remove(picurl);
                    GoodsPicture picture = new GoodsPicture();
                    picture.setUrl(picurl);
                    imgs.add(picture);
                }
            }
            List<JDGoods> goodsList = JDApiUtil.queryGoodsDetail(goods.getSkuList());
            List<GoodsPicture> imgs = new ArrayList<>();
            info.setImgs(imgs);
            BigDecimal totalMoney = new BigDecimal(0);
            List<String> lastPicture = new ArrayList<>();
            for (JDGoods jdGoods : goodsList) {
                GoodsPicture picture = new GoodsPicture();
                BigDecimal money = JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getShareRate());
                totalMoney = totalMoney.add(money);
                picture.setGoodsVO(
                        GoodsDetailVOFactory.convertJDGoods(jdGoods,
                                new ConfigParamsDTO(hongBaoManageService.getFanLiRate(),
                                        hongBaoManageService.getShareRate(), null,
                                        hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
                picture.setGoodState(0);
                picture.setJumpDetail(jumpDetailV2Service.getByTypeCache("goodsdetail"));
                picture.setParams(null);
                picture.setUrl(jdGoods.getPicUrl());
                imgs.add(picture);
                if (jdGoods.getImageList() != null)
                    if (jdGoods.getImageList().size() > 4)
                        lastPicture.addAll(jdGoods.getImageList().subList(1, 4));
                    else if (jdGoods.getImageList().size() > 1)
                        lastPicture.addAll(jdGoods.getImageList().subList(1, jdGoods.getImageList().size()));
            }
            info.setShareMoney(totalMoney);
            int count = 0;
            while (imgs.size() < 4 && count < 4) {
                count++;
                String picurl = lastPicture.get((int) (lastPicture.size() * Math.random()));
                if (picurl != null) {
                    lastPicture.remove(picurl);
                    GoodsPicture picture = new GoodsPicture();
                    picture.setUrl(picurl);
                    imgs.add(picture);
                }
            }
            wxmpDynamicInfoService.addWXMPDynamicInfo(info);
        }
    }
            info.setImgs(imgs);
    /**
     *  每一个小时随机在分享数的基础上加10~100。增加的时间段是每天8~22点。
     * 早上6,7,15,16,21,22,23点更新1次
     */
    @Scheduled(cron = "0 0 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 * * ? ")
    public void addRanDomShareCount() {
        if (!Constant.IS_TASK) {
            return;
        }
            wxmpDynamicInfoService.addWXMPDynamicInfo(info);
        }
    }
        try {
            goodsEvaluateService.addRanDomShareCount();
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    /**
     * 商品加入发圈
     */
    @XxlJob("dynamic-insertEvaluate")
    public ReturnT<String> insertEvaluate(String param) throws Exception {
        // 好单库
        boolean addResult = addHDKListSelected();
        // 大淘客备用
        if (!addResult) {
            addDTKFriendsFircleList();
        }
        return ReturnT.SUCCESS;
    }
    /**
     * 好单库商品加入发圈
     * @return
     */
    private boolean addHDKListSelected () {
        boolean addResult = false;
        Integer minId = 1;
        while (minId != null) {
            HDKGoodsListResultDTO dto = HaoDanKuApiUtil.getInstance().listSelected(minId);
            if (dto == null) {
                minId = null;
            } else {
                minId = dto.getMinId();
                List<HDKWXCircleContentDTO>  list = dto.getList();
                if (list== null || list.size() == 0) {
                    continue;
                }
                for (HDKWXCircleContentDTO circleContentDTO: list) {
                    try {
                        String itemid = circleContentDTO.getItemid();
                        HDKGoodsDetail hdkGoods = HaoDanKuApiUtil.getInstance().getItemDetail(itemid);
                        if (hdkGoods == null) {
                            continue;
                        }
                        List<String> pics = circleContentDTO.getItempic();
                        String copy_content = circleContentDTO.getCopy_content();
                        String showtitle = StringEscapeUtils.unescapeHtml(copy_content);
                        showtitle = showtitle.replace("<br>", "\r\n");
                        List<ActivityRuleUser> ruleList = activityUserService.listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20);
                        ActivityUser user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser();
                        int addProcess = goodsEvaluateService.addGoodsEvaluate(TaoBaoGoodsFactory.create(hdkGoods), pics, user, showtitle);
                        if (addProcess == 0) {
                            addResult = true;
                            break;
                        }
                    } catch (GoodsEvaluateException e) {
                        e.printStackTrace();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
            if(addResult)
             break;
        }
        return addResult;
    }
    /**
     * 大淘客商品加入发圈
     * @return
     */
    private boolean addDTKFriendsFircleList() {
        boolean addResult = false;
        try {
            DaTaoKeGoodsResult result = DaTaoKeApiUtil.getFriendsFircleList("1", 100);
            while (result.getGoodsList() != null && result.getGoodsList().size() > 0) {
                for (DaTaoKeDetailV2 detailV2 : result.getGoodsList()) {
                    try {
                        Long goodsId = detailV2.getGoodsId();
                        String circleText = detailV2.getCircleText();
                        if (circleText == null) {
                            continue;
                        }
                        String showtitle = URLDecoder.decode(circleText, "UTF-8");
                        showtitle = showtitle.replace("&nbsp;", " ");
                        DaTaoKeDetailV2 tkGoods = DaTaoKeApiUtil.getGoodsDetailByGoodsId(goodsId);
                        if(tkGoods == null) {
                            continue;
                        }
                        ActivityUser user = null;
                        if (detailV2.getCid() != null) {
                            user = activityUserService.getRandomByDaTaoKeCid(detailV2.getCid());
                        }
                        if (user == null) {
                            List<ActivityRuleUser> ruleList = activityUserService
                                    .listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20);
                            user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser();
                        }
                        int addProcess = goodsEvaluateService.addGoodsEvaluate(TaoBaoUtil.convert(tkGoods), null, user, showtitle);
                        if (addProcess == 0) {
                            addResult = true;
                            break;
                        }
                    } catch (GoodsEvaluateException e) {
                        e.printStackTrace();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
    /**
     * 每一个小时随机在分享数的基础上加10~100。增加的时间段是每天8~22点。
     * 早上6,7,15,16,21,22,23点更新1次
     */
    @Scheduled(cron = "0 0 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 * * ? ")
    public void addRanDomShareCount() {
        if (!Constant.IS_TASK) {
            return;
        }
                if (addResult) {
                    break;
                }
        try {
            for (SystemEnum system : SystemEnum.values())
                goodsEvaluateService.addRanDomShareCount(system);
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
                try {
                    result = DaTaoKeApiUtil.getFriendsFircleList(result.getPageId(), 100);
                } catch (Exception e) {
                    result = DaTaoKeApiUtil.getFriendsFircleList(result.getPageId(), 100);
                }
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
        return addResult;
    }
    /**
     * 商品加入发圈
     */
    @XxlJob("dynamic-insertEvaluate")
    public ReturnT<String> insertEvaluate(String param) throws Exception {
        // 好单库
        boolean addResult = addHDKListSelected();
        // 大淘客备用
        if (!addResult) {
            addDTKFriendsFircleList();
        }
        return ReturnT.SUCCESS;
    }
    /**
     * 好单库商品加入发圈
     *
     * @return
     */
    private boolean addHDKListSelected() {
        boolean addResult = false;
        Integer minId = 1;
        while (minId != null) {
            HDKGoodsListResultDTO dto = HaoDanKuApiUtil.getInstance().listSelected(minId);
            if (dto == null) {
                minId = null;
            } else {
                minId = dto.getMinId();
                List<HDKWXCircleContentDTO> list = dto.getList();
                if (list == null || list.size() == 0) {
                    continue;
                }
                for (HDKWXCircleContentDTO circleContentDTO : list) {
                    try {
                        String itemid = circleContentDTO.getItemid();
                        HDKGoodsDetail hdkGoods = HaoDanKuApiUtil.getInstance().getItemDetail(itemid);
                        if (hdkGoods == null) {
                            continue;
                        }
                        List<String> pics = circleContentDTO.getItempic();
                        String copy_content = circleContentDTO.getCopy_content();
                        String showtitle = StringEscapeUtils.unescapeHtml(copy_content);
                        showtitle = showtitle.replace("<br>", "\r\n");
                        List<ActivityRuleUser> ruleList = activityUserService.listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20);
                        ActivityUser user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser();
                        int addProcess = goodsEvaluateService.addGoodsEvaluate(TaoBaoGoodsFactory.create(hdkGoods), pics, user, showtitle, SystemEnum.blks);
                        if (addProcess == 0) {
                            addResult = true;
                            break;
                        }
                    } catch (GoodsEvaluateException e) {
                        e.printStackTrace();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
            if (addResult)
                break;
        }
        return addResult;
    }
    /**
     * 大淘客商品加入发圈
     *
     * @return
     */
    private boolean addDTKFriendsFircleList() {
        boolean addResult = false;
        try {
            DaTaoKeGoodsResult result = DaTaoKeApiUtil.getFriendsFircleList("1", 100);
            while (result.getGoodsList() != null && result.getGoodsList().size() > 0) {
                for (DaTaoKeDetailV2 detailV2 : result.getGoodsList()) {
                    try {
                        Long goodsId = detailV2.getGoodsId();
                        String circleText = detailV2.getCircleText();
                        if (circleText == null) {
                            continue;
                        }
                        String showtitle = URLDecoder.decode(circleText, "UTF-8");
                        showtitle = showtitle.replace("&nbsp;", " ");
                        DaTaoKeDetailV2 tkGoods = DaTaoKeApiUtil.getGoodsDetailByGoodsId(goodsId);
                        if (tkGoods == null) {
                            continue;
                        }
                        ActivityUser user = null;
                        if (detailV2.getCid() != null) {
                            user = activityUserService.getRandomByDaTaoKeCid(detailV2.getCid());
                        }
                        if (user == null) {
                            List<ActivityRuleUser> ruleList = activityUserService
                                    .listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20);
                            user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser();
                        }
                        int addProcess = goodsEvaluateService.addGoodsEvaluate(TaoBaoUtil.convert(tkGoods), null, user, showtitle, SystemEnum.blks);
                        if (addProcess == 0) {
                            addResult = true;
                            break;
                        }
                    } catch (GoodsEvaluateException e) {
                        e.printStackTrace();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                if (addResult) {
                    break;
                }
                try {
                    result = DaTaoKeApiUtil.getFriendsFircleList(result.getPageId(), 100);
                } catch (Exception e) {
                    result = DaTaoKeApiUtil.getFriendsFircleList(result.getPageId(), 100);
                }
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
        return addResult;
    }
}
fanli/src/main/java/com/yeshi/fanli/job/IntegralTaskJob.java
@@ -5,6 +5,8 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -20,68 +22,71 @@
/**
 * 金币任务
 *
 * @author Administrator
 *
 * @author Administrator
 */
@Component
public class IntegralTaskJob {
    @Resource
    private PushService pushService;
    @Resource
    private PushService pushService;
    @Resource
    private IntegralTaskRecordService integralTaskRecordService;
    @Resource
    private IntegralTaskRecordService integralTaskRecordService;
    @Resource
    private IntegralTaskClassService integralTaskClassService;
    @Resource
    private IntegralTaskClassService integralTaskClassService;
    /**
     * 推送签到提醒(每天15点半查询)
     */
    @Scheduled(cron = "0 30 15 * * ? ")
    public void pushSignInNotify() {
        if (!Constant.IS_TASK)
            return;
        // 获取昨天签到过的
        IntegralTaskClass dailySignClass = integralTaskClassService.getByUniqueKey(UniqueKeyEnum.dailySign.name());
        if (dailySignClass == null)
            return;
        Long cid = dailySignClass.getId();
    @Resource
    private UserInfoService userInfoService;
        long timeStamp = System.currentTimeMillis();
        Date minTime = new Date(TimeUtil.convertToTimeTemp(
                TimeUtil.getGernalTime(timeStamp - 1000 * 60 * 60 * 24L, "yyyy-MM-dd"), "yyyy-MM-dd"));
        Date maxTime = new Date(
                TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(timeStamp, "yyyy-MM-dd"), "yyyy-MM-dd"));
    /**
     * 推送签到提醒(每天15点半查询)
     */
    @Scheduled(cron = "0 30 15 * * ? ")
    public void pushSignInNotify() {
        if (!Constant.IS_TASK)
            return;
        // 获取昨天签到过的
        IntegralTaskClass dailySignClass = integralTaskClassService.getByUniqueKey(UniqueKeyEnum.dailySign.name());
        if (dailySignClass == null)
            return;
        Long cid = dailySignClass.getId();
        Date todayMinTime = new Date(
                TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(timeStamp, "yyyy-MM-dd"), "yyyy-MM-dd"));
        long timeStamp = System.currentTimeMillis();
        Date minTime = new Date(TimeUtil.convertToTimeTemp(
                TimeUtil.getGernalTime(timeStamp - 1000 * 60 * 60 * 24L, "yyyy-MM-dd"), "yyyy-MM-dd"));
        Date maxTime = new Date(
                TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(timeStamp, "yyyy-MM-dd"), "yyyy-MM-dd"));
        Date todayMaxTime = new Date(TimeUtil.convertToTimeTemp(
                TimeUtil.getGernalTime(timeStamp + 1000 * 60 * 60 * 24L, "yyyy-MM-dd"), "yyyy-MM-dd"));
        Date todayMinTime = new Date(
                TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(timeStamp, "yyyy-MM-dd"), "yyyy-MM-dd"));
        long count = integralTaskRecordService.countByCidAndUidAndCreateTime(cid, null, minTime, maxTime);
        int page = (int) (count % 200 == 0 ? count / 200 : count / 200 + 1);
        for (int p = 0; p < page; p++) {
            List<IntegralTaskRecord> list = integralTaskRecordService.listByCidAndUidAndCreateTime(cid, null, minTime,
                    maxTime, p + 1, 200);
            if (list != null) {
                for (IntegralTaskRecord record : list) {
                    // 查询今天是否已经签到
                    long todayCount = integralTaskRecordService.countByCidAndUidAndCreateTime(cid, record.getUid(),
                            todayMinTime, todayMaxTime);
                    if (todayCount <= 0) {// 如果未签到,需要推送信息
                        try {
                            pushService.pushUserSignInNotification(record.getUid(), "今日未签到提醒", "今日还未签到,连续签到金币翻倍哦", null,
                                    null);
                        } catch (PushException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }
        Date todayMaxTime = new Date(TimeUtil.convertToTimeTemp(
                TimeUtil.getGernalTime(timeStamp + 1000 * 60 * 60 * 24L, "yyyy-MM-dd"), "yyyy-MM-dd"));
        long count = integralTaskRecordService.countByCidAndUidAndCreateTime(cid, null, minTime, maxTime);
        int page = (int) (count % 200 == 0 ? count / 200 : count / 200 + 1);
        for (int p = 0; p < page; p++) {
            List<IntegralTaskRecord> list = integralTaskRecordService.listByCidAndUidAndCreateTime(cid, null, minTime,
                    maxTime, p + 1, 200);
            if (list != null) {
                for (IntegralTaskRecord record : list) {
                    // 查询今天是否已经签到
                    long todayCount = integralTaskRecordService.countByCidAndUidAndCreateTime(cid, record.getUid(),
                            todayMinTime, todayMaxTime);
                    if (todayCount <= 0) {// 如果未签到,需要推送信息
                        SystemEnum system = userInfoService.getUserSystem(record.getUid());
                        try {
                            pushService.pushUserSignInNotification(record.getUid(), "今日未签到提醒", "今日还未签到,连续签到金币翻倍哦", null,
                                    null,system);
                        } catch (PushException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/job/PushJob.java
@@ -7,6 +7,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -23,91 +24,92 @@
@Component
public class PushJob {
    @Resource
    private PushInfoService pushInfoService;
    @Resource
    private PushGoodsService pushGoodsService;
    /**
     * 推送老版本IOS(每晚8点推送)
     */
    @Scheduled(cron = "0 0 20 * * ? ")
    public void pushOldIOS() {
        if (!Constant.IS_TASK)
            return;
        Scanner scanner = new Scanner(
                this.getClass().getClassLoader().getResourceAsStream("certificate/devicetoken.txt"));
        List<String> deviceList = new ArrayList<>();
        while (scanner.hasNext()) {
            deviceList.add(scanner.next().trim());
        }
        // 每次推送50条数据
        InputStream cer = null;
        int p = deviceList.size() / 50 + 1;
        JSONObject json = IOSPushFactory.createURLPush("https://0x9.me/TusaI", "板栗快省苹果端进行了重大更新!请立即升级",
                "更多优惠券,更高返利,尽在新版苹果端板栗快省!");
        for (int i = 0; i < p; i++) {
            cer = this.getClass().getClassLoader().getResourceAsStream("certificate/老版本-生产证书.p12");
            try {
                IOSPushUtil.pushIOS(
                        deviceList.subList(i * 50,
                                (i * 50 + 50) > deviceList.size() ? deviceList.size() : (i * 50 + 50)),
                        json, cer, "123");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    @Resource
    private PushInfoService pushInfoService;
    /**
     *  定时消息推送任务 每个30秒爬取
     */
    @Scheduled(cron = "30 * * * * ? ")
    public void pushInfo() {
        if (!Constant.IS_TASK) {
            return;
        }
        // 站内信、网页、百川
        try {
            List<PushInfo> listTask = pushInfoService.listTask();
            if (listTask != null && listTask.size() > 0) {
                for (PushInfo pushInfo: listTask) {
                    pushInfoService.taskPush(pushInfo);
                }
            }
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
        //    今日推荐
        try {
            List<PushGoods> listTask = pushGoodsService.listTask();
            if (listTask != null && listTask.size() > 0) {
                for (PushGoods pushGoods: listTask) {
                    pushGoodsService.taskPush(pushGoods);
                }
            }
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    @Resource
    private PushGoodsService pushGoodsService;
    /**
     * 推送老版本IOS(每晚8点推送)
     */
    @Scheduled(cron = "0 0 20 * * ? ")
    public void pushOldIOS() {
        if (!Constant.IS_TASK)
            return;
        Scanner scanner = new Scanner(
                this.getClass().getClassLoader().getResourceAsStream("certificate/devicetoken.txt"));
        List<String> deviceList = new ArrayList<>();
        while (scanner.hasNext()) {
            deviceList.add(scanner.next().trim());
        }
        // 每次推送50条数据
        InputStream cer = null;
        int p = deviceList.size() / 50 + 1;
        JSONObject json = IOSPushFactory.createURLPush("https://0x9.me/TusaI", "板栗快省苹果端进行了重大更新!请立即升级",
                "更多优惠券,更高返利,尽在新版苹果端板栗快省!");
        for (int i = 0; i < p; i++) {
            cer = this.getClass().getClassLoader().getResourceAsStream("certificate/老版本-生产证书.p12");
            try {
                IOSPushUtil.pushIOS(
                        deviceList.subList(i * 50,
                                (i * 50 + 50) > deviceList.size() ? deviceList.size() : (i * 50 + 50)),
                        json, cer, "123");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    /**
     * 定时消息推送任务 每个30秒爬取
     */
    @Scheduled(cron = "30 * * * * ? ")
    public void pushInfo() {
        if (!Constant.IS_TASK) {
            return;
        }
        for (SystemEnum system : SystemEnum.values()) {
            // 站内信、网页、百川
            try {
                List<PushInfo> listTask = pushInfoService.listTask(system);
                if (listTask != null && listTask.size() > 0) {
                    for (PushInfo pushInfo : listTask) {
                        pushInfoService.taskPush(pushInfo);
                    }
                }
            } catch (Exception e) {
                try {
                    LogHelper.errorDetailInfo(e);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
            //    今日推荐
            try {
                List<PushGoods> listTask = pushGoodsService.listTask(system);
                if (listTask != null && listTask.size() > 0) {
                    for (PushGoods pushGoods : listTask) {
                        pushGoodsService.taskPush(pushGoods);
                    }
                }
            } catch (Exception e) {
                try {
                    LogHelper.errorDetailInfo(e);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/brand/BrandClassMapper.xml
@@ -2,109 +2,124 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.brand.BrandClassMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.brand.BrandClass">
    <id column="bc_id" property="id" jdbcType="BIGINT"/>
    <result column="bc_name" property="name" jdbcType="VARCHAR"/>
    <result column="bc_state" property="state" jdbcType="INTEGER"/>
    <result column="bc_orderby" property="orderBy" jdbcType="INTEGER"/>
    <result column="bc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="bc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <association column="bc_gclass_id" property="goodsClass" javaType="com.yeshi.fanli.entity.bus.clazz.GoodsClass">
        <id column="bc_gclass_id" property="id" jdbcType="BIGINT" />
    </association>
  </resultMap>
  <sql id="Base_Column_List">bc_id,bc_name,bc_gclass_id,bc_state,bc_orderby,bc_create_time,bc_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_brand_class where bc_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_brand_class where bc_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.brand.BrandClass" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_brand_class (bc_id,bc_name,bc_gclass_id,bc_state,bc_orderby,bc_create_time,bc_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{goodsClass.id,jdbcType=BIGINT},#{state,jdbcType=INTEGER},#{orderBy,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.brand.BrandClass" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_brand_class
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">bc_id,</if>
      <if test="name != null">bc_name,</if>
      <if test="goodsClass != null">bc_gclass_id,</if>
      <if test="state != null">bc_state,</if>
      <if test="orderBy != null">bc_orderby,</if>
      <if test="createTime != null">bc_create_time,</if>
      <if test="updateTime != null">bc_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="name != null">#{name,jdbcType=VARCHAR},</if>
      <if test="goodsClass != null">#{goodsClass.id,jdbcType=BIGINT},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</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>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.brand.BrandClass">update yeshi_ec_brand_class set bc_name = #{name,jdbcType=VARCHAR},bc_gclass_id = #{goodsClass.id,jdbcType=BIGINT},bc_state = #{state,jdbcType=INTEGER},bc_orderby = #{orderBy,jdbcType=INTEGER},bc_create_time = #{createTime,jdbcType=TIMESTAMP},bc_update_time = #{updateTime,jdbcType=TIMESTAMP} where bc_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.brand.BrandClass">update yeshi_ec_brand_class
    <set>
      <if test="name != null">bc_name=#{name,jdbcType=VARCHAR},</if>
      <if test="goodsClass != null">bc_gclass_id=#{goodsClass.id,jdbcType=BIGINT},</if>
      <if test="state != null">bc_state=#{state,jdbcType=INTEGER},</if>
      <if test="orderBy != null">bc_orderby=#{orderBy,jdbcType=INTEGER},</if>
      <if test="createTime != null">bc_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">bc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where bc_id = #{id,jdbcType=BIGINT}
  </update>
  <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List">
        delete from yeshi_ec_brand_class WHERE bc_id in
        <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
   </delete>
  <select id="listEffective" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_brand_class
    WHERE bc_state = 1
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.brand.BrandClass">
        <id column="bc_id" property="id" jdbcType="BIGINT"/>
        <result column="bc_name" property="name" jdbcType="VARCHAR"/>
        <result column="bc_state" property="state" jdbcType="INTEGER"/>
        <result column="bc_orderby" property="orderBy" jdbcType="INTEGER"/>
        <result column="bc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="bc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <association column="bc_gclass_id" property="goodsClass" javaType="com.yeshi.fanli.entity.bus.clazz.GoodsClass">
            <id column="bc_gclass_id" property="id" jdbcType="BIGINT"/>
        </association>
    </resultMap>
    <sql id="Base_Column_List">bc_id,bc_name,bc_gclass_id,bc_state,bc_orderby,bc_create_time,bc_update_time</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/>from yeshi_ec_brand_class where bc_id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey"
            parameterType="java.lang.Long">delete from yeshi_ec_brand_class where bc_id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.brand.BrandClass" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_brand_class (bc_id,bc_name,bc_gclass_id,bc_state,bc_orderby,bc_create_time,bc_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{goodsClass.id,jdbcType=BIGINT},#{state,jdbcType=INTEGER},#{orderBy,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.brand.BrandClass" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_brand_class
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">bc_id,</if>
            <if test="name != null">bc_name,</if>
            <if test="goodsClass != null">bc_gclass_id,</if>
            <if test="state != null">bc_state,</if>
            <if test="orderBy != null">bc_orderby,</if>
            <if test="createTime != null">bc_create_time,</if>
            <if test="updateTime != null">bc_update_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="name != null">#{name,jdbcType=VARCHAR},</if>
            <if test="goodsClass != null">#{goodsClass.id,jdbcType=BIGINT},</if>
            <if test="state != null">#{state,jdbcType=INTEGER},</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>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
            parameterType="com.yeshi.fanli.entity.brand.BrandClass">update yeshi_ec_brand_class set bc_name = #{name,jdbcType=VARCHAR},bc_gclass_id = #{goodsClass.id,jdbcType=BIGINT},bc_state = #{state,jdbcType=INTEGER},bc_orderby = #{orderBy,jdbcType=INTEGER},bc_create_time = #{createTime,jdbcType=TIMESTAMP},bc_update_time = #{updateTime,jdbcType=TIMESTAMP} where bc_id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.brand.BrandClass">update
        yeshi_ec_brand_class
        <set>
            <if test="name != null">bc_name=#{name,jdbcType=VARCHAR},</if>
            <if test="goodsClass != null">bc_gclass_id=#{goodsClass.id,jdbcType=BIGINT},</if>
            <if test="state != null">bc_state=#{state,jdbcType=INTEGER},</if>
            <if test="orderBy != null">bc_orderby=#{orderBy,jdbcType=INTEGER},</if>
            <if test="createTime != null">bc_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">bc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where bc_id = #{id,jdbcType=BIGINT}
    </update>
    <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List">
        delete from yeshi_ec_brand_class WHERE bc_id in
        <foreach collection="list" item="item" open="(" close=")"
                 separator=",">#{item}
        </foreach>
    </delete>
    <select id="listEffective" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_brand_class left join  yeshi_ec_brand_class_system_map m on m.sm_brand_class_id=bc_id
    WHERE  bc_state = 1
    <if test="system!=null">
        AND sm_system=#{system}
    </if>
    ORDER BY bc_orderby
  </select>
  <select id="getMaxOrder" resultType="java.lang.Integer">
    <select id="getMaxOrder" resultType="java.lang.Integer">
       SELECT IFNULL(MAX(bc_orderby),0) FROM yeshi_ec_brand_class
  </select>
   <select id="getByAdjoinOrder" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_brand_class
        WHERE  1=1
        <if test="type == -1">
            AND bc_orderby <![CDATA[<]]> #{order}
            ORDER BY bc_orderby desc
        </if>
        <if test="type == 1">
            AND bc_orderby <![CDATA[>]]> #{order}
            ORDER BY bc_orderby
        </if>
        LIMIT 1
   </select>
   <select id="listQuery" resultMap="BaseResultMap">
      SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_brand_class
      WHERE 1=1
          <if test="key != null and key !='' ">
              AND bc_name LIKE '%${key}%'
          </if>
          <if test="state != null">
               AND bc_state = #{state}
          </if>
      ORDER BY bc_orderby
      LIMIT ${start},${count}
  </select>
  <select id="countQuery" resultType="java.lang.Long">
      SELECT IFNULL(COUNT(bc_id),0) FROM yeshi_ec_brand_class
      WHERE 1=1
          <if test="key != null and key !='' ">
              AND bc_name LIKE '%${key}%'
          </if>
          <if test="state != null">
               AND  bc_state =  #{state}
          </if>
  </select>
    <select id="getByAdjoinOrder" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM yeshi_ec_brand_class
        WHERE 1=1
        <if test="type == -1">
            AND bc_orderby <![CDATA[<]]> #{order}
            ORDER BY bc_orderby desc
        </if>
        <if test="type == 1">
            AND bc_orderby <![CDATA[>]]> #{order}
            ORDER BY bc_orderby
        </if>
        LIMIT 1
    </select>
    <select id="listQuery" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM yeshi_ec_brand_class left join  yeshi_ec_brand_class_system_map m on m.sm_brand_class_id=bc_id
        WHERE 1=1   AND sm_system=#{system}
        <if test="key != null and key !='' ">
            AND bc_name LIKE '%${key}%'
        </if>
        <if test="state != null">
            AND bc_state = #{state}
        </if>
        ORDER BY bc_orderby
        LIMIT ${start},${count}
    </select>
    <select id="countQuery" resultType="java.lang.Long">
        SELECT IFNULL(COUNT(bc_id),0) FROM yeshi_ec_brand_class  left join  yeshi_ec_brand_class_system_map m on m.sm_brand_class_id=bc_id
        WHERE 1=1    AND sm_system=#{system}
        <if test="key != null and key !='' ">
            AND bc_name LIKE '%${key}%'
        </if>
        <if test="state != null">
            AND bc_state = #{state}
        </if>
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/brand/BrandClassSystemMapMapper.xml
New file
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.brand.BrandClassSystemMapMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.brand.BrandClassSystemMap">
        <id column="sm_id" property="id" jdbcType="BIGINT"/>
        <result column="sm_system" property="system" jdbcType="VARCHAR"/>
        <result column="sm_create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <association property="brandClass" javaType="com.yeshi.fanli.entity.brand.BrandClass"
                     column="sm_brand_class_id">
            <id column="sm_brand_class_id" property="id" jdbcType="BIGINT"></id>
        </association>
    </resultMap>
    <sql id="Base_Column_List">sm_id,sm_system,sm_brand_class_id,sm_create_time</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/>from yeshi_ec_brand_class_system_map where sm_id = #{id,jdbcType=BIGINT}
    </select>
    <select id="listByClassIdsAndSystem" resultMap="BaseResultMap" >select
        <include refid="Base_Column_List"/>from yeshi_ec_brand_class_system_map where sm_system = #{system}
        <if test="classIdList!=null">
            <foreach collection="" item="classId" separator=" or " open=" and (" close=")">
                sm_brand_class_id=#{classId}
            </foreach>
        </if>
    </select>
    <delete id="deleteByPrimaryKey"
            parameterType="java.lang.Long">delete from yeshi_ec_brand_class_system_map where sm_id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.brand.BrandClassSystemMap" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_brand_class_system_map (sm_id,sm_system,sm_brand_class_id,sm_create_time) values (#{id,jdbcType=BIGINT},#{system,jdbcType=VARCHAR},#{brandClass.id,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP})</insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.brand.BrandClassSystemMap"
            useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_brand_class_system_map
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">sm_id,</if>
            <if test="system != null">sm_system,</if>
            <if test="brandClass != null">sm_brand_class_id,</if>
            <if test="createTime != null">sm_create_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="system != null">#{system,jdbcType=VARCHAR},</if>
            <if test="brandClass != null">#{brandClass.id,jdbcType=BIGINT},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
            parameterType="com.yeshi.fanli.entity.brand.BrandClassSystemMap">update yeshi_ec_brand_class_system_map set sm_system = #{system,jdbcType=VARCHAR},sm_brand_class_id = #{brandClass.id,jdbcType=BIGINT},sm_create_time = #{createTime,jdbcType=TIMESTAMP} where sm_id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.brand.BrandClassSystemMap">update
        yeshi_ec_brand_class_system_map
        <set>
            <if test="system != null">sm_system=#{system,jdbcType=VARCHAR},</if>
            <if test="brandClass != null">sm_brand_class_id=#{brandClass.id,jdbcType=BIGINT},</if>
            <if test="createTime != null">sm_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
        </set>
        where sm_id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/common/CommonConfigMapper.xml
New file
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.common.CommonConfigMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.config.CommonConfig">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="key" property="key" jdbcType="VARCHAR"/>
        <result column="value" property="value" jdbcType="VARCHAR"/>
        <result column="name" property="name" jdbcType="VARCHAR"/>
        <result column="beizhu" property="beizhu" jdbcType="VARCHAR"/>
        <result column="createtime" property="createtime" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">id,key,value,name,beizhu,createtime</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/>from yeshi_ec_common_config where id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByKey" resultMap="BaseResultMap" parameterType="java.lang.String">select
        <include refid="Base_Column_List"/>from yeshi_ec_common_config where `key` = #{0}
    </select>
    <delete id="deleteByPrimaryKey"
            parameterType="java.lang.Long">delete from yeshi_ec_common_config where id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.config.CommonConfig" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_common_config (id,key,value,name,beizhu,createtime) values (#{id,jdbcType=BIGINT},#{key,jdbcType=VARCHAR},#{value,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR},#{beizhu,jdbcType=VARCHAR},#{createtime,jdbcType=VARCHAR})</insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.config.CommonConfig" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_common_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="key != null">key,</if>
            <if test="value != null">value,</if>
            <if test="name != null">name,</if>
            <if test="beizhu != null">beizhu,</if>
            <if test="createtime != null">createtime,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="key != null">#{key,jdbcType=VARCHAR},</if>
            <if test="value != null">#{value,jdbcType=VARCHAR},</if>
            <if test="name != null">#{name,jdbcType=VARCHAR},</if>
            <if test="beizhu != null">#{beizhu,jdbcType=VARCHAR},</if>
            <if test="createtime != null">#{createtime,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
            parameterType="com.yeshi.fanli.entity.config.CommonConfig">update yeshi_ec_common_config set key = #{key,jdbcType=VARCHAR},value = #{value,jdbcType=VARCHAR},name = #{name,jdbcType=VARCHAR},beizhu = #{beizhu,jdbcType=VARCHAR},createtime = #{createtime,jdbcType=VARCHAR} where id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.config.CommonConfig">update
        yeshi_ec_common_config
        <set>
            <if test="key != null">key=#{key,jdbcType=VARCHAR},</if>
            <if test="value != null">value=#{value,jdbcType=VARCHAR},</if>
            <if test="name != null">name=#{name,jdbcType=VARCHAR},</if>
            <if test="beizhu != null">beizhu=#{beizhu,jdbcType=VARCHAR},</if>
            <if test="createtime != null">createtime=#{createtime,jdbcType=VARCHAR},</if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/help/AppPageNotificationMapper.xml
@@ -16,8 +16,9 @@
        <result column="an_updatetime" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="an_begin_time" property="beginTime" jdbcType="TIMESTAMP"/>
           <result column="an_end_time" property="endTime" jdbcType="TIMESTAMP"/>
        <result column="an_system" property="system" jdbcType="VARCHAR" />
    </resultMap>
    <sql id="Base_Column_List">an_id,an_type,an_show,an_can_close,an_content,an_content_url,an_md5,an_createtime,an_begin_time,an_end_time,an_updatetime
    <sql id="Base_Column_List">an_id,an_type,an_show,an_can_close,an_content,an_content_url,an_md5,an_createtime,an_begin_time,an_end_time,an_updatetime,an_system
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
@@ -30,12 +31,12 @@
        parameterType="java.lang.String">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_apppage_notification where an_type = #{0}
        from yeshi_ec_apppage_notification where an_type = #{type} and an_system=#{system}
    </select>
    <select id="listValidByType" resultMap="BaseResultMap" parameterType="java.lang.String">
        SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_apppage_notification 
        WHERE an_type = #{0} AND an_show = 1
        WHERE an_type = #{type} AND an_system=#{system} AND an_show = 1
             AND IF(an_begin_time IS NULL,TRUE, an_begin_time<![CDATA[<=]]> NOW()) 
              AND IF(an_end_time IS NULL,TRUE, an_end_time <![CDATA[>=]]> NOW())
    </select>
@@ -47,9 +48,9 @@
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.help.AppPageNotification"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_apppage_notification
        (an_id,an_type,an_show,an_can_close,an_content,an_content_url,an_md5,an_createtime,an_begin_time,an_end_time,an_updatetime)
        (an_id,an_type,an_show,an_can_close,an_content,an_content_url,an_md5,an_createtime,an_begin_time,an_end_time,an_updatetime,an_system)
        values
        (#{id,jdbcType=BIGINT},#{type,jdbcType=VARCHAR},#{show,jdbcType=BOOLEAN},#{canClose,jdbcType=BOOLEAN},#{content,jdbcType=VARCHAR},#{contentUrl,jdbcType=VARCHAR},#{md5,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{beginTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
        (#{id,jdbcType=BIGINT},#{type,jdbcType=VARCHAR},#{show,jdbcType=BOOLEAN},#{canClose,jdbcType=BOOLEAN},#{content,jdbcType=VARCHAR},#{contentUrl,jdbcType=VARCHAR},#{md5,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{beginTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{system,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.help.AppPageNotification"
        useGeneratedKeys="true" keyProperty="id">
@@ -66,6 +67,7 @@
            <if test="beginTime != null">an_begin_time,</if>
             <if test="endTime != null">an_end_time,</if>
            <if test="updateTime != null">an_updatetime,</if>
            <if test="system != null">an_system,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -80,6 +82,7 @@
            <if test="beginTime != null">#{beginTime,jdbcType=TIMESTAMP},</if>
             <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="system != null">#{system,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.help.AppPageNotification">update
@@ -91,7 +94,8 @@
        #{contentUrl,jdbcType=VARCHAR},an_md5 =
        #{md5,jdbcType=VARCHAR},an_createtime =
        #{createTime,jdbcType=TIMESTAMP},an_begin_time = #{beginTime,jdbcType=TIMESTAMP},an_end_time = #{endTime,jdbcType=TIMESTAMP},an_updatetime =
        #{updateTime,jdbcType=TIMESTAMP} where an_id = #{id,jdbcType=BIGINT}
        #{updateTime,jdbcType=TIMESTAMP},an_system =
        #{system,jdbcType=VARCHAR} where an_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.help.AppPageNotification">
        update yeshi_ec_apppage_notification
@@ -106,6 +110,7 @@
            <if test="beginTime != null">an_begin_time=#{beginTime,jdbcType=TIMESTAMP},</if>
             <if test="endTime != null">an_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">an_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="system != null">an_system=#{system,jdbcType=VARCHAR},</if>
        </set>
        where an_id = #{id,jdbcType=BIGINT}
    </update>
@@ -113,7 +118,7 @@
    
    <select id="listQuery" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />  FROM yeshi_ec_apppage_notification
        WHERE 1=1
        WHERE 1=1 AND an_system=#{system}
           <if test='key != null and key != ""'>
                  AND (an_type like '%${key}%' or an_content like '%${key}%') 
           </if>
@@ -129,7 +134,7 @@
   
   <select id="countQuery" resultType="java.lang.Long">
        SELECT IFNULL(count(an_id),0)  FROM yeshi_ec_apppage_notification 
        WHERE 1=1
        WHERE 1=1 AND an_system=#{system}
            <if test='key != null and key != ""'>
                  AND (an_type like '%${key}%' or an_content like '%${key}%') 
           </if>
fanli/src/main/java/com/yeshi/fanli/mapping/help/HelpCenterMapper.xml
@@ -2,141 +2,154 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.help.HelpCenterMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.help.HelpCenter">
    <id column="h_id" property="id" jdbcType="BIGINT"/>
    <result column="h_title" property="title" jdbcType="VARCHAR"/>
    <result column="h_weight" property="weight" jdbcType="INTEGER"/>
    <result column="h_state" property="state" jdbcType="INTEGER"/>
    <result column="h_start_time" property="startTime" jdbcType="TIMESTAMP"/>
    <result column="h_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="h_createtime" property="createtime" jdbcType="TIMESTAMP"/>
    <result column="h_updatetime" property="updatetime" jdbcType="TIMESTAMP"/>
    <association property="helpClass" column="h_cid"
            javaType="com.yeshi.fanli.entity.bus.help.HelpClass">
            <id column="h_cid" property="id" jdbcType="BIGINT" />
            <id column="hc_name" property="name" jdbcType="VARCHAR" />
    </association>
  </resultMap>
  <sql id="Base_Column_List">h_id,h_title,h_weight,h_state,h_cid,h_start_time,h_end_time,h_createtime,h_updatetime</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_help_center where h_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_help_center where h_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_help_center (h_id,h_title,h_weight,h_state,h_cid,h_start_time,h_end_time,h_createtime,h_updatetime) values (#{id,jdbcType=BIGINT},#{title,jdbcType=VARCHAR},#{weight,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{helpClass.id,jdbcType=BIGINT},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{createtime,jdbcType=TIMESTAMP},#{updatetime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_help_center
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">h_id,</if>
      <if test="title != null">h_title,</if>
      <if test="weight != null">h_weight,</if>
      <if test="state != null">h_state,</if>
      <if test="helpClass != null">h_cid,</if>
      <if test="startTime != null">h_start_time,</if>
      <if test="endTime != null">h_end_time,</if>
      <if test="createtime != null">h_createtime,</if>
      <if test="updatetime != null">h_updatetime,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="title != null">#{title,jdbcType=VARCHAR},</if>
      <if test="weight != null">#{weight,jdbcType=INTEGER},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
      <if test="helpClass != null">#{helpClass.id,jdbcType=BIGINT},</if>
      <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="createtime != null">#{createtime,jdbcType=TIMESTAMP},</if>
      <if test="updatetime != null">#{updatetime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter">update yeshi_ec_help_center set h_title = #{title,jdbcType=VARCHAR},h_weight = #{weight,jdbcType=INTEGER},h_state = #{state,jdbcType=INTEGER},h_cid = #{helpClass.id,jdbcType=BIGINT},h_start_time = #{startTime,jdbcType=TIMESTAMP},h_end_time = #{endTime,jdbcType=TIMESTAMP},h_createtime = #{createtime,jdbcType=TIMESTAMP},h_updatetime = #{updatetime,jdbcType=TIMESTAMP} where h_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter">update yeshi_ec_help_center
    <set>
      <if test="title != null">h_title=#{title,jdbcType=VARCHAR},</if>
      <if test="weight != null">h_weight=#{weight,jdbcType=INTEGER},</if>
      <if test="state != null">h_state=#{state,jdbcType=INTEGER},</if>
      <if test="helpClass != null">h_cid=#{helpClass.id,jdbcType=BIGINT},</if>
      <if test="startTime != null">h_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">h_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="createtime != null">h_createtime=#{createtime,jdbcType=TIMESTAMP},</if>
      <if test="updatetime != null">h_updatetime=#{updatetime,jdbcType=TIMESTAMP},</if>
    </set> where h_id = #{id,jdbcType=BIGINT}
  </update>
   <select id="query" resultMap="BaseResultMap">
    SELECT *  FROM yeshi_ec_help_center     ht
    LEFT JOIN  yeshi_ec_help_class hc ON ht.h_cid = hc.hc_id
        WHERE     <![CDATA[1>0]]>
       <if test='key != null and key != ""'>
              AND ht.h_title like '%${key}%'
       </if>
       <if test='cid != null'>
              AND ht.h_cid = #{cid}
       </if>
       <if test='state != null'>
              AND ht.h_state = #{state}
       </if>
       <if test='orderMode == 1'>
            ORDER BY  ht.h_weight  DESC
       </if>
       <if test='orderMode == 2'>
            ORDER BY  ht.h_weight
       </if>
       <if test='orderMode == 3'>
            ORDER BY  ht.h_createtime  DESC
       </if>
        <if test='orderMode == 4'>
            ORDER BY ht.h_createtime
       </if>
        <if test='orderMode == 5'>
            ORDER BY  ht.h_updatetime  DESC
       </if>
        <if test='orderMode == 6'>
            ORDER BY  ht.h_updatetime
       </if>
        LIMIT ${start},${count}
   </select>
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.help.HelpCenter">
        <id column="h_id" property="id" jdbcType="BIGINT"/>
        <result column="h_title" property="title" jdbcType="VARCHAR"/>
        <result column="h_weight" property="weight" jdbcType="INTEGER"/>
        <result column="h_state" property="state" jdbcType="INTEGER"/>
        <result column="h_start_time" property="startTime" jdbcType="TIMESTAMP"/>
        <result column="h_end_time" property="endTime" jdbcType="TIMESTAMP"/>
        <result column="h_createtime" property="createtime" jdbcType="TIMESTAMP"/>
        <result column="h_updatetime" property="updatetime" jdbcType="TIMESTAMP"/>
        <result column="h_system" property="system" jdbcType="VARCHAR"/>
        <association property="helpClass" column="h_cid"
                     javaType="com.yeshi.fanli.entity.bus.help.HelpClass">
            <id column="h_cid" property="id" jdbcType="BIGINT"/>
            <id column="hc_name" property="name" jdbcType="VARCHAR"/>
        </association>
    </resultMap>
   <select id="countQuery" resultType="java.lang.Long">
    SELECT  count(h_id)  FROM yeshi_ec_help_center
        WHERE     <![CDATA[1>0]]>
       <if test='key != null and key != ""'>
              AND h_title like '%${key}%'
       </if>
       <if test='cid != null'>
              AND h_cid  = #{cid}
       </if>
        <if test='state != null'>
              AND ht.h_state = #{state}
       </if>
    </select>
   <select id="listValid" resultMap="BaseResultMap">
    SELECT h_id, h_title FROM yeshi_ec_help_center
    WHERE h_id > #{pageId} AND h_state = 1
         AND IF(h_start_time IS NULL,TRUE, h_start_time<![CDATA[<=]]>NOW())
          AND IF(h_end_time IS NULL,TRUE, h_end_time >=NOW())
      <if test='key != null and key != ""'>
              AND h_title like '%${key}%'
       </if>
       <if test='cid != null'>
              AND h_cid  = #{cid}
       </if>
        ORDER BY h_weight DESC
        LIMIT ${count}
   </select>
   <delete id="deleteBatchById" parameterType="int">
        <!-- 批量删除  -->
        delete from yeshi_ec_help_center where h_id in
        <foreach item="item" collection="idList" open="(" separator=","
            close=")">
            #{item}
        </foreach>
    </delete>
    <sql id="Base_Column_List">h_id,h_title,h_weight,h_state,h_cid,h_start_time,h_end_time,h_createtime,h_updatetime,h_system</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/>from yeshi_ec_help_center where h_id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey"
            parameterType="java.lang.Long">delete from yeshi_ec_help_center where h_id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_help_center (h_id,h_title,h_weight,h_state,h_cid,h_start_time,h_end_time,h_createtime,h_updatetime,h_system) values (#{id,jdbcType=BIGINT},#{title,jdbcType=VARCHAR},#{weight,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{helpClass.id,jdbcType=BIGINT},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{createtime,jdbcType=TIMESTAMP},#{updatetime,jdbcType=TIMESTAMP},#{system,jdbcType=VARCHAR})</insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_help_center
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">h_id,</if>
            <if test="title != null">h_title,</if>
            <if test="weight != null">h_weight,</if>
            <if test="state != null">h_state,</if>
            <if test="helpClass != null">h_cid,</if>
            <if test="startTime != null">h_start_time,</if>
            <if test="endTime != null">h_end_time,</if>
            <if test="createtime != null">h_createtime,</if>
            <if test="updatetime != null">h_updatetime,</if>
            <if test="system != null">h_system,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="title != null">#{title,jdbcType=VARCHAR},</if>
            <if test="weight != null">#{weight,jdbcType=INTEGER},</if>
            <if test="state != null">#{state,jdbcType=INTEGER},</if>
            <if test="helpClass != null">#{helpClass.id,jdbcType=BIGINT},</if>
            <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
            <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="createtime != null">#{createtime,jdbcType=TIMESTAMP},</if>
            <if test="updatetime != null">#{updatetime,jdbcType=TIMESTAMP},</if>
            <if test="system != null">#{system,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
            parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter">update yeshi_ec_help_center set h_title = #{title,jdbcType=VARCHAR},h_weight = #{weight,jdbcType=INTEGER},h_state = #{state,jdbcType=INTEGER},h_cid = #{helpClass.id,jdbcType=BIGINT},h_start_time = #{startTime,jdbcType=TIMESTAMP},h_end_time = #{endTime,jdbcType=TIMESTAMP},h_createtime = #{createtime,jdbcType=TIMESTAMP},h_updatetime = #{updatetime,jdbcType=TIMESTAMP},h_system = #{system,jdbcType=VARCHAR} where h_id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter">update
        yeshi_ec_help_center
        <set>
            <if test="title != null">h_title=#{title,jdbcType=VARCHAR},</if>
            <if test="weight != null">h_weight=#{weight,jdbcType=INTEGER},</if>
            <if test="state != null">h_state=#{state,jdbcType=INTEGER},</if>
            <if test="helpClass != null">h_cid=#{helpClass.id,jdbcType=BIGINT},</if>
            <if test="startTime != null">h_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
            <if test="endTime != null">h_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="createtime != null">h_createtime=#{createtime,jdbcType=TIMESTAMP},</if>
            <if test="updatetime != null">h_updatetime=#{updatetime,jdbcType=TIMESTAMP},</if>
            <if test="system != null">h_system=#{system,jdbcType=VARCHAR},</if>
        </set>
        where h_id = #{id,jdbcType=BIGINT}
    </update>
    <select id="query" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_help_center ht
        LEFT JOIN yeshi_ec_help_class hc ON ht.h_cid = hc.hc_id
        WHERE    <![CDATA[1>0]]>  AND h_system=#{system}
        <if test='key != null and key != ""'>
            AND ht.h_title like '%${key}%'
        </if>
        <if test='cid != null'>
            AND ht.h_cid = #{cid}
        </if>
        <if test='state != null'>
            AND ht.h_state = #{state}
        </if>
        <if test='orderMode == 1'>
            ORDER BY ht.h_weight DESC
        </if>
        <if test='orderMode == 2'>
            ORDER BY ht.h_weight
        </if>
        <if test='orderMode == 3'>
            ORDER BY ht.h_createtime DESC
        </if>
        <if test='orderMode == 4'>
            ORDER BY ht.h_createtime
        </if>
        <if test='orderMode == 5'>
            ORDER BY ht.h_updatetime DESC
        </if>
        <if test='orderMode == 6'>
            ORDER BY ht.h_updatetime
        </if>
        LIMIT ${start},${count}
    </select>
    <select id="countQuery" resultType="java.lang.Long">
        SELECT count(h_id) FROM yeshi_ec_help_center
        WHERE    <![CDATA[1>0]]>
        <if test='key != null and key != ""'>
            AND h_title like '%${key}%'
        </if>
        <if test='cid != null'>
            AND h_cid = #{cid}
        </if>
        <if test='state != null'>
            AND ht.h_state = #{state}
        </if>
        AND h_system=#{system}
    </select>
    <select id="listValid" resultMap="BaseResultMap">
        SELECT h_id, h_title FROM yeshi_ec_help_center
        WHERE h_id > #{pageId} AND h_state = 1 AND h_system=#{system}
        AND IF(h_start_time IS NULL,TRUE, h_start_time<![CDATA[<=]]>NOW())
        AND IF(h_end_time IS NULL,TRUE, h_end_time >=NOW())
        <if test='key != null and key != ""'>
            AND h_title like '%${key}%'
        </if>
        <if test='cid != null'>
            AND h_cid = #{cid}
        </if>
        ORDER BY h_weight DESC
        LIMIT ${count}
    </select>
    <delete id="deleteBatchById" parameterType="int">
        <!-- 批量删除  -->
        delete from yeshi_ec_help_center where h_id in
        <foreach item="item" collection="idList" open="(" separator=","
                 close=")">
            #{item}
        </foreach>
    </delete>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/help/HelpClassMapper.xml
@@ -2,121 +2,137 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.help.HelpClassMapper">
   <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.help.HelpClass">
    <id column="hc_id" property="id" jdbcType="BIGINT"/>
    <result column="hc_name" property="name" jdbcType="VARCHAR"/>
    <result column="hc_picture" property="picture" jdbcType="VARCHAR"/>
    <result column="hc_sort" property="sort" jdbcType="INTEGER"/>
    <result column="hc_show_state" property="showState" jdbcType="INTEGER"/>
    <result column="hc_start_time" property="startTime" jdbcType="TIMESTAMP"/>
    <result column="hc_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="hc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="hc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">hc_id,hc_name,hc_picture,hc_sort,hc_show_state,hc_start_time,hc_end_time,hc_create_time,hc_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_help_class where hc_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_help_class where hc_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.help.HelpClass" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_help_class (hc_id,hc_name,hc_picture,hc_sort,hc_show_state,hc_start_time,hc_end_time,hc_create_time,hc_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{sort,jdbcType=INTEGER},#{showState,jdbcType=INTEGER},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.help.HelpClass" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_help_class
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">hc_id,</if>
      <if test="name != null">hc_name,</if>
      <if test="picture != null">hc_picture,</if>
      <if test="sort != null">hc_sort,</if>
      <if test="showState != null">hc_show_state,</if>
      <if test="startTime != null">hc_start_time,</if>
      <if test="endTime != null">hc_end_time,</if>
      <if test="createTime != null">hc_create_time,</if>
      <if test="updateTime != null">hc_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="name != null">#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">#{picture,jdbcType=VARCHAR},</if>
      <if test="sort != null">#{sort,jdbcType=INTEGER},</if>
      <if test="showState != null">#{showState,jdbcType=INTEGER},</if>
      <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.help.HelpClass">update yeshi_ec_help_class set hc_name = #{name,jdbcType=VARCHAR},hc_picture = #{picture,jdbcType=VARCHAR},hc_sort = #{sort,jdbcType=INTEGER},hc_show_state = #{showState,jdbcType=INTEGER},hc_start_time = #{startTime,jdbcType=TIMESTAMP},hc_end_time = #{endTime,jdbcType=TIMESTAMP},hc_create_time = #{createTime,jdbcType=TIMESTAMP},hc_update_time = #{updateTime,jdbcType=TIMESTAMP} where hc_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.help.HelpClass">update yeshi_ec_help_class
    <set>
      <if test="name != null">hc_name=#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">hc_picture=#{picture,jdbcType=VARCHAR},</if>
      <if test="sort != null">hc_sort=#{sort,jdbcType=INTEGER},</if>
      <if test="showState != null">hc_show_state=#{showState,jdbcType=INTEGER},</if>
      <if test="startTime != null">hc_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">hc_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">hc_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">hc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where hc_id = #{id,jdbcType=BIGINT}
  </update>
   <delete id="deleteByPrimaryKeyBatch" parameterType="java.util.List">
    delete from yeshi_ec_help_class WHERE hc_id in
    <foreach collection="list" item="item" open="(" close=")"
        separator=",">#{item}</foreach>
   </delete>
   <select id="listQuery" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />  FROM yeshi_ec_help_class
        WHERE 1=1
           <if test='key != null and key != ""'>
                  AND (hc_name like '%${key}%')
           </if>
           <if test='state != null'>
                  AND hc_show_state = #{state}
           </if>
           ORDER BY hc_sort
        LIMIT ${start},${count}
   </select>
   <select id="countQuery" resultType="java.lang.Long">
        SELECT IFNULL(count(hc_id),0)  FROM yeshi_ec_help_class
        WHERE 1=1
           <if test='key != null and key != ""'>
                  AND (hc_name like '%${key}%')
           </if>
           <if test='state != null'>
                  AND hc_show_state = #{state}
           </if>
    </select>
   <select id="getMaxOrder" resultType="java.lang.Integer">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.help.HelpClass">
        <id column="hc_id" property="id" jdbcType="BIGINT"/>
        <result column="hc_name" property="name" jdbcType="VARCHAR"/>
        <result column="hc_picture" property="picture" jdbcType="VARCHAR"/>
        <result column="hc_sort" property="sort" jdbcType="INTEGER"/>
        <result column="hc_show_state" property="showState" jdbcType="INTEGER"/>
        <result column="hc_start_time" property="startTime" jdbcType="TIMESTAMP"/>
        <result column="hc_end_time" property="endTime" jdbcType="TIMESTAMP"/>
        <result column="hc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="hc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="hc_system" property="system" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">hc_id,hc_name,hc_picture,hc_sort,hc_show_state,hc_start_time,hc_end_time,hc_create_time,hc_update_time,hc_system</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/>from yeshi_ec_help_class where hc_id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey"
            parameterType="java.lang.Long">delete from yeshi_ec_help_class where hc_id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.help.HelpClass" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_help_class (hc_id,hc_name,hc_picture,hc_sort,hc_show_state,hc_start_time,hc_end_time,hc_create_time,hc_update_time,hc_system) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{sort,jdbcType=INTEGER},#{showState,jdbcType=INTEGER},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{system,jdbcType=VARCHAR})</insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.help.HelpClass" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_help_class
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">hc_id,</if>
            <if test="name != null">hc_name,</if>
            <if test="picture != null">hc_picture,</if>
            <if test="sort != null">hc_sort,</if>
            <if test="showState != null">hc_show_state,</if>
            <if test="startTime != null">hc_start_time,</if>
            <if test="endTime != null">hc_end_time,</if>
            <if test="createTime != null">hc_create_time,</if>
            <if test="updateTime != null">hc_update_time,</if>
            <if test="system != null">hc_system,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="name != null">#{name,jdbcType=VARCHAR},</if>
            <if test="picture != null">#{picture,jdbcType=VARCHAR},</if>
            <if test="sort != null">#{sort,jdbcType=INTEGER},</if>
            <if test="showState != null">#{showState,jdbcType=INTEGER},</if>
            <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
            <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="system != null">#{system,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
            parameterType="com.yeshi.fanli.entity.bus.help.HelpClass">update yeshi_ec_help_class set hc_name = #{name,jdbcType=VARCHAR},hc_picture = #{picture,jdbcType=VARCHAR},hc_sort = #{sort,jdbcType=INTEGER},hc_show_state = #{showState,jdbcType=INTEGER},hc_start_time = #{startTime,jdbcType=TIMESTAMP},hc_end_time = #{endTime,jdbcType=TIMESTAMP},hc_create_time = #{createTime,jdbcType=TIMESTAMP},hc_update_time = #{updateTime,jdbcType=TIMESTAMP},hc_system = #{system,jdbcType=VARCHAR} where hc_id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.help.HelpClass">update
        yeshi_ec_help_class
        <set>
            <if test="name != null">hc_name=#{name,jdbcType=VARCHAR},</if>
            <if test="picture != null">hc_picture=#{picture,jdbcType=VARCHAR},</if>
            <if test="sort != null">hc_sort=#{sort,jdbcType=INTEGER},</if>
            <if test="showState != null">hc_show_state=#{showState,jdbcType=INTEGER},</if>
            <if test="startTime != null">hc_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
            <if test="endTime != null">hc_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">hc_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">hc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="system != null">hc_system=#{system,jdbcType=VARCHAR},</if>
        </set>
        where hc_id = #{id,jdbcType=BIGINT}
    </update>
    <delete id="deleteByPrimaryKeyBatch" parameterType="java.util.List">
        delete from yeshi_ec_help_class WHERE hc_id in
        <foreach collection="list" item="item" open="(" close=")"
                 separator=",">#{item}
        </foreach>
    </delete>
    <select id="listQuery" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM yeshi_ec_help_class
        WHERE 1=1 AND hc_system=#{system}
        <if test='key != null and key != ""'>
            AND (hc_name like '%${key}%')
        </if>
        <if test='state != null'>
            AND hc_show_state = #{state}
        </if>
        ORDER BY hc_sort
        LIMIT ${start},${count}
    </select>
    <select id="countQuery" resultType="java.lang.Long">
        SELECT IFNULL(count(hc_id),0) FROM yeshi_ec_help_class
        WHERE 1=1 AND hc_system=#{system}
        <if test='key != null and key != ""'>
            AND (hc_name like '%${key}%')
        </if>
        <if test='state != null'>
            AND hc_show_state = #{state}
        </if>
    </select>
    <select id="getMaxOrder" resultType="java.lang.Integer">
        SELECT IFNULL(MAX(hc_sort),0) FROM yeshi_ec_help_class limit 1
   </select>
   <select id="getChangeOrder" resultMap="BaseResultMap">
        SELECT  <include refid="Base_Column_List" /> FROM yeshi_ec_help_class
        WHERE 1=1
        <if test="type == -1">
            <![CDATA[and hc_sort < #{sort}]]>
            order by hc_sort desc
        </if>
        <if test="type == 1">
            <![CDATA[and hc_sort > #{sort} ]]>
            order by hc_sort
        </if>
        limit 1
   </select>
   <select id="getClassByState" resultMap="BaseResultMap">
    <select id="getChangeOrder" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM yeshi_ec_help_class
        WHERE 1=1 AND hc_system=#{system}
        <if test="type == -1">
            <![CDATA[and hc_sort < #{sort}]]>
            order by hc_sort desc
        </if>
        <if test="type == 1">
            <![CDATA[and hc_sort > #{sort} ]]>
            order by hc_sort
        </if>
        limit 1
    </select>
    <select id="getClassByState" resultMap="BaseResultMap">
        SELECT hc_id,hc_name,hc_picture FROM yeshi_ec_help_class
        WHERE  hc_show_state = #{state}
        WHERE  hc_show_state = #{state}  AND hc_system=#{system}
            AND IF(hc_start_time IS NULL,TRUE, hc_start_time<![CDATA[<=]]>NOW())
              AND IF(hc_end_time IS NULL,TRUE, hc_end_time >=NOW())
           ORDER BY hc_sort 
   </select>
    <select id="getProvidedClass" resultMap="BaseResultMap">
        SELECT hc_id,hc_name,hc_picture  FROM yeshi_ec_help_class
        SELECT hc_id,hc_name,hc_picture  FROM yeshi_ec_help_class where hc_system=#{system}
           ORDER BY hc_sort 
   </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/homemodule/HomeNavbarMapper.xml
@@ -2,273 +2,289 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.homemodule.HomeNavbarMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.homemodule.HomeNavbar">
    <id column="br_id" property="id" jdbcType="BIGINT"/>
    <result column="br_name" property="name" jdbcType="VARCHAR"/>
    <result column="br_picture" property="picture" jdbcType="VARCHAR"/>
    <result column="br_class_id" property="classId" jdbcType="BIGINT"/>
    <result column="br_swiper_banner_id" property="swiperBannerId" jdbcType="BIGINT"/>
    <result column="br_url" property="url" jdbcType="VARCHAR"/>
    <result column="br_type" property="type" jdbcType="VARCHAR"/>
    <result column="br_orderby" property="orderby" jdbcType="INTEGER"/>
    <result column="br_order_man" property="orderMan" jdbcType="INTEGER"/>
    <result column="br_order_woman" property="orderWoman" jdbcType="INTEGER"/>
    <result column="br_start_time" property="startTime" jdbcType="TIMESTAMP"/>
    <result column="br_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="br_state" property="state" jdbcType="INTEGER"/>
    <result column="br_is_default" property="isDefault" jdbcType="VARCHAR"/>
    <result column="br_is_fixed" property="isFixed" jdbcType="VARCHAR"/>
    <result column="br_params" property="params" jdbcType="VARCHAR"/>
    <result column="br_createtime" property="createtime" jdbcType="TIMESTAMP"/>
    <result column="br_updatetime" property="updatetime" jdbcType="TIMESTAMP"/>
    <result column="br_type" property="type" typeHandler="com.yeshi.fanli.util.mybatishandler.NavbarTypeEnumHandler"/>
    <result column="sex" property="sex" jdbcType="INTEGER"/>
  </resultMap>
  <sql id="Base_Column_List">br_id,br_name,br_picture,br_class_id,br_swiper_banner_id,br_url,br_type,br_orderby,br_order_man,br_order_woman,br_start_time,br_end_time,br_state,br_is_default,br_is_fixed,br_params,br_createtime,br_updatetime</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_home_navbar where br_id = #{id,jdbcType=BIGINT}
  </select>
  <select id="getDefaultMaxOrder" resultType="java.lang.Integer">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.homemodule.HomeNavbar">
        <id column="br_id" property="id" jdbcType="BIGINT"/>
        <result column="br_name" property="name" jdbcType="VARCHAR"/>
        <result column="br_picture" property="picture" jdbcType="VARCHAR"/>
        <result column="br_class_id" property="classId" jdbcType="BIGINT"/>
        <result column="br_swiper_banner_id" property="swiperBannerId" jdbcType="BIGINT"/>
        <result column="br_url" property="url" jdbcType="VARCHAR"/>
        <result column="br_type" property="type" jdbcType="VARCHAR"/>
        <result column="br_orderby" property="orderby" jdbcType="INTEGER"/>
        <result column="br_order_man" property="orderMan" jdbcType="INTEGER"/>
        <result column="br_order_woman" property="orderWoman" jdbcType="INTEGER"/>
        <result column="br_start_time" property="startTime" jdbcType="TIMESTAMP"/>
        <result column="br_end_time" property="endTime" jdbcType="TIMESTAMP"/>
        <result column="br_state" property="state" jdbcType="INTEGER"/>
        <result column="br_is_default" property="isDefault" jdbcType="VARCHAR"/>
        <result column="br_is_fixed" property="isFixed" jdbcType="VARCHAR"/>
        <result column="br_params" property="params" jdbcType="VARCHAR"/>
        <result column="br_createtime" property="createtime" jdbcType="TIMESTAMP"/>
        <result column="br_updatetime" property="updatetime" jdbcType="TIMESTAMP"/>
        <result column="br_type" property="type"
                typeHandler="com.yeshi.fanli.util.mybatishandler.NavbarTypeEnumHandler"/>
        <result column="sex" property="sex" jdbcType="INTEGER"/>
        <result column="br_system" property="system" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">br_id,br_name,br_picture,br_class_id,br_swiper_banner_id,br_url,br_type,br_orderby,br_order_man,br_order_woman,br_start_time,br_end_time,br_state,br_is_default,br_is_fixed,br_params,br_createtime,br_updatetime,br_system</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/>from yeshi_ec_home_navbar where br_id = #{id,jdbcType=BIGINT}
    </select>
    <select id="getDefaultMaxOrder" resultType="java.lang.Integer">
       SELECT IFNULL(MAX(br_orderby),0) FROM yeshi_ec_home_navbar
       order by br_orderby desc
  </select>
  <select id="getManMaxOrder" resultType="java.lang.Integer">
    <select id="getManMaxOrder" resultType="java.lang.Integer">
       SELECT IFNULL(MAX(br_order_man),0) FROM yeshi_ec_home_navbar
       order by br_order_man desc
  </select>
  <select id="getWomanMaxOrder" resultType="java.lang.Integer">
    <select id="getWomanMaxOrder" resultType="java.lang.Integer">
       SELECT IFNULL(MAX(br_order_woman),0) FROM yeshi_ec_home_navbar
       order by br_order_woman desc
  </select>
   <select id="getDefaultChangeOrder" resultMap="BaseResultMap">
       SELECT h.* FROM yeshi_ec_home_navbar h
       LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
    WHERE 1=1 and h.br_orderby is not null
        <if test="type == -1">
               <![CDATA[and h.br_orderby < #{order}]]>
               order by h.br_orderby  desc
        </if>
        <if test="type == 1">
            <![CDATA[and h.br_orderby > #{order}]]>
            order by h.br_orderby
        </if>
     LIMIT 1
  </select>
  <select id="getManChangeOrder" resultMap="BaseResultMap">
       SELECT h.* FROM yeshi_ec_home_navbar h
       LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
    WHERE 1=1 and h.br_order_man is  not null
        <if test="type == -1">
               <![CDATA[and h.br_order_man < #{order}]]>
               order by h.br_order_man  desc
        </if>
        <if test="type == 1">
            <![CDATA[and h.br_order_man > #{order}]]>
            order by h.br_order_man
        </if>
     LIMIT 1
  </select>
  <select id="getWomanChangeOrder" resultMap="BaseResultMap">
       SELECT h.* FROM yeshi_ec_home_navbar h
       LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
    WHERE 1=1 and h.br_order_woman is not null
        <if test="type == -1">
               <![CDATA[and h.br_order_woman < #{order}]]>
               order by h.br_order_woman  desc
        </if>
        <if test="type == 1">
            <![CDATA[and h.br_order_woman > #{order}]]>
            order by h.br_order_woman
        </if>
     LIMIT 1
  </select>
   <select id="listQuery" resultMap="BaseResultMap">
        SELECT h.*,c.sex AS sex  FROM yeshi_ec_home_navbar h
        LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
        WHERE 1=1
           <if test='key != null and key != ""'>
                  AND (h.br_name like '%${key}%')
           </if>
           <!-- 通用版 -->
            <if test="sex == 0">
                AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 0 OR c.`sex` = 10 OR c.`sex` = 20))
                ORDER BY h.br_orderby
            </if>
            <!-- 女版 -->
            <if test="sex == 1">
                AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 1 OR c.`sex` = 10 OR c.`sex` = 12))
                ORDER BY h.br_order_woman
            </if>
            <!-- 男版 -->
            <if test="sex == 2">
                AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 2 OR c.`sex` = 20 OR c.`sex` = 12))
                ORDER BY h.br_order_man
            </if>
        LIMIT ${start},${count}
   </select>
   <select id="countListQuery" resultType="java.lang.Long">
        SELECT IFNULL(count(br_id),0)  FROM yeshi_ec_home_navbar h
        LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
        WHERE 1=1
           <if test='key != null and key != ""'>
                  AND (h.br_name like '%${key}%')
           </if>
           <!-- 通用版 -->
            <if test="sex == 0">
                AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 0 OR c.`sex` = 10 OR c.`sex` = 20))
                ORDER BY h.br_orderby
            </if>
            <!-- 女版 -->
            <if test="sex == 1">
                AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 1 OR c.`sex` = 10 OR c.`sex` = 12))
                ORDER BY h.br_order_woman
            </if>
            <!-- 男版 -->
            <if test="sex == 2">
                AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 2 OR c.`sex` = 20 OR c.`sex` = 12))
                ORDER BY h.br_order_man
            </if>
   </select>
   <select id="listQueryEffective" resultMap="BaseResultMap">
    <select id="getDefaultChangeOrder" resultMap="BaseResultMap">
        SELECT h.* FROM yeshi_ec_home_navbar h
        LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
        WHERE 1=1 and h.br_orderby is not null
        <if test="type == -1">
            <![CDATA[and h.br_orderby < #{order}]]>
            order by h.br_orderby desc
        </if>
        <if test="type == 1">
            <![CDATA[and h.br_orderby > #{order}]]>
            order by h.br_orderby
        </if>
        LIMIT 1
    </select>
    <select id="getManChangeOrder" resultMap="BaseResultMap">
        SELECT h.* FROM yeshi_ec_home_navbar h
        LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
        WHERE 1=1 and h.br_order_man is not null
        <if test="type == -1">
            <![CDATA[and h.br_order_man < #{order}]]>
            order by h.br_order_man desc
        </if>
        <if test="type == 1">
            <![CDATA[and h.br_order_man > #{order}]]>
            order by h.br_order_man
        </if>
        LIMIT 1
    </select>
    <select id="getWomanChangeOrder" resultMap="BaseResultMap">
        SELECT h.* FROM yeshi_ec_home_navbar h
        LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
        WHERE 1=1 and h.br_order_woman is not null
        <if test="type == -1">
            <![CDATA[and h.br_order_woman < #{order}]]>
            order by h.br_order_woman desc
        </if>
        <if test="type == 1">
            <![CDATA[and h.br_order_woman > #{order}]]>
            order by h.br_order_woman
        </if>
        LIMIT 1
    </select>
    <select id="listQuery" resultMap="BaseResultMap">
        SELECT h.*,c.sex AS sex FROM yeshi_ec_home_navbar h
        LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
        WHERE 1=1
        AND br_system=#{system}
        <if test='key != null and key != ""'>
            AND (h.br_name like '%${key}%')
        </if>
        <!-- 通用版 -->
        <if test="sex == 0">
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 0 OR c.`sex` = 10 OR c.`sex` = 20))
            ORDER BY h.br_orderby
        </if>
        <!-- 女版 -->
        <if test="sex == 1">
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 1 OR c.`sex` = 10 OR c.`sex` = 12))
            ORDER BY h.br_order_woman
        </if>
        <!-- 男版 -->
        <if test="sex == 2">
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 2 OR c.`sex` = 20 OR c.`sex` = 12))
            ORDER BY h.br_order_man
        </if>
        LIMIT ${start},${count}
    </select>
    <select id="countListQuery" resultType="java.lang.Long">
        SELECT IFNULL(count(br_id),0) FROM yeshi_ec_home_navbar h
        LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
        WHERE 1=1
        AND br_system=#{system}
        <if test='key != null and key != ""'>
            AND (h.br_name like '%${key}%')
        </if>
        <!-- 通用版 -->
        <if test="sex == 0">
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 0 OR c.`sex` = 10 OR c.`sex` = 20))
            ORDER BY h.br_orderby
        </if>
        <!-- 女版 -->
        <if test="sex == 1">
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 1 OR c.`sex` = 10 OR c.`sex` = 12))
            ORDER BY h.br_order_woman
        </if>
        <!-- 男版 -->
        <if test="sex == 2">
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 2 OR c.`sex` = 20 OR c.`sex` = 12))
            ORDER BY h.br_order_man
        </if>
    </select>
    <select id="listQueryEffective" resultMap="BaseResultMap">
      SELECT h.*,c.sex AS sex FROM yeshi_ec_home_navbar h
      LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
      WHERE h.br_state = 1
      WHERE h.br_state = 1   AND br_system=#{system}
              AND IF(h.br_start_time IS NULL,TRUE, h.br_start_time<![CDATA[<=]]> NOW()) 
              AND IF(h.br_end_time IS NULL,TRUE, h.br_end_time <![CDATA[>=]]> NOW())
            ORDER BY h.br_orderby 
   </select>
   <select id="listQueryDefaultNavbar" resultMap="BaseResultMap">
      SELECT h.*,c.sex AS sex FROM    yeshi_ec_home_navbar h
      LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
      WHERE h.br_state = 1 AND br_is_default = 1
              AND IF(h.br_start_time IS NULL,TRUE, h.br_start_time<![CDATA[<=]]> NOW())
              AND IF(h.br_end_time IS NULL,TRUE, h.br_end_time <![CDATA[>=]]> NOW())
               <!-- 通用版 -->
            <if test="sex == 0">
                AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 0 OR c.`sex` = 10 OR c.`sex` = 20))
                ORDER BY h.br_orderby
            </if>
            <!-- 女版 -->
            <if test="sex == 1">
                AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 1 OR c.`sex` = 10 OR c.`sex` = 12))
                ORDER BY h.br_order_woman
            </if>
            <!-- 男版 -->
            <if test="sex == 2">
                AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 2 OR c.`sex` = 20 OR c.`sex` = 12))
                ORDER BY h.br_order_man
            </if>
   </select>
   <select id="listQueryFixedNavbar" resultMap="BaseResultMap">
    <select id="listQueryDefaultNavbar" resultMap="BaseResultMap">
        SELECT h.*,c.sex AS sex FROM yeshi_ec_home_navbar h
        LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
        WHERE br_system=#{system} AND h.br_state = 1 AND br_is_default = 1
        AND IF(h.br_start_time IS NULL,TRUE, h.br_start_time<![CDATA[<=]]> NOW())
        AND IF(h.br_end_time IS NULL,TRUE, h.br_end_time <![CDATA[>=]]> NOW())
        <!-- 通用版 -->
        <if test="sex == 0">
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 0 OR c.`sex` = 10 OR c.`sex` = 20))
            ORDER BY h.br_orderby
        </if>
        <!-- 女版 -->
        <if test="sex == 1">
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 1 OR c.`sex` = 10 OR c.`sex` = 12))
            ORDER BY h.br_order_woman
        </if>
        <!-- 男版 -->
        <if test="sex == 2">
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 2 OR c.`sex` = 20 OR c.`sex` = 12))
            ORDER BY h.br_order_man
        </if>
    </select>
    <select id="listQueryFixedNavbar" resultMap="BaseResultMap">
      SELECT * FROM    yeshi_ec_home_navbar 
      WHERE br_state = 1 AND br_is_default = 1 AND br_is_fixed = 1
      WHERE br_state = 1   AND br_system=#{system} AND br_is_default = 1 AND br_is_fixed = 1
              AND IF(br_start_time IS NULL,TRUE, br_start_time<![CDATA[<=]]> NOW()) 
              AND IF(br_end_time IS NULL,TRUE, br_end_time <![CDATA[>=]]> NOW())
      ORDER BY br_orderby
   </select>
   <select id="getEffectiveByClassId" resultMap="BaseResultMap">
    <select id="getEffectiveByClassId" resultMap="BaseResultMap">
      SELECT * FROM    yeshi_ec_home_navbar 
      WHERE br_state = 1  AND br_class_id = #{classId}
      WHERE br_state = 1   AND br_system=#{system} AND br_class_id = #{classId}
      LIMIT 1
   </select>
   <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List">
        delete from yeshi_ec_home_navbar WHERE br_id in
        <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
   </delete>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List">
        delete from yeshi_ec_home_navbar WHERE br_id in
        <foreach collection="list" item="item" open="(" close=")"
                 separator=",">#{item}
        </foreach>
    </delete>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
      delete from yeshi_ec_home_navbar where br_id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.homemodule.HomeNavbar" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_home_navbar (br_id,br_name,br_picture,br_class_id,br_swiper_banner_id,br_url,br_type,br_orderby,br_order_man,br_order_woman,br_start_time,br_end_time,br_state,br_is_default,br_is_fixed,br_params,br_createtime,br_updatetime) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{classId,jdbcType=BIGINT},#{swiperBannerId,jdbcType=BIGINT},#{url,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{orderby,jdbcType=INTEGER},#{orderMan,jdbcType=INTEGER},#{orderWoman,jdbcType=INTEGER},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{state,jdbcType=INTEGER},#{isDefault,jdbcType=VARCHAR},#{isFixed,jdbcType=VARCHAR},#{params,jdbcType=VARCHAR},#{createtime,jdbcType=TIMESTAMP},#{updatetime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.homemodule.HomeNavbar" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_home_navbar
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">br_id,</if>
      <if test="name != null">br_name,</if>
      <if test="picture != null">br_picture,</if>
      <if test="classId != null">br_class_id,</if>
      <if test="swiperBannerId != null">br_swiper_banner_id,</if>
      <if test="url != null">br_url,</if>
      <if test="type != null">br_type,</if>
      <if test="orderby != null">br_orderby,</if>
      <if test="orderMan != null">br_order_man,</if>
      <if test="orderWoman != null">br_order_woman,</if>
      <if test="startTime != null">br_start_time,</if>
      <if test="endTime != null">br_end_time,</if>
      <if test="state != null">br_state,</if>
      <if test="isDefault != null">br_is_default,</if>
      <if test="isFixed != null">br_is_fixed,</if>
      <if test="params != null">br_params,</if>
      <if test="createtime != null">br_createtime,</if>
      <if test="updatetime != null">br_updatetime,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="name != null">#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">#{picture,jdbcType=VARCHAR},</if>
      <if test="classId != null">#{classId,jdbcType=BIGINT},</if>
      <if test="swiperBannerId != null">#{swiperBannerId,jdbcType=BIGINT},</if>
      <if test="url != null">#{url,jdbcType=VARCHAR},</if>
      <if test="type != null">#{type,jdbcType=VARCHAR},</if>
      <if test="orderby != null">#{orderby,jdbcType=INTEGER},</if>
      <if test="orderMan != null">#{orderMan,jdbcType=INTEGER},</if>
      <if test="orderWoman != null">#{orderWoman,jdbcType=INTEGER},</if>
      <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
      <if test="isDefault != null">#{isDefault,jdbcType=VARCHAR},</if>
      <if test="isFixed != null">#{isFixed,jdbcType=VARCHAR},</if>
      <if test="params != null">#{params,jdbcType=VARCHAR},</if>
      <if test="createtime != null">#{createtime,jdbcType=TIMESTAMP},</if>
      <if test="updatetime != null">#{updatetime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.homemodule.HomeNavbar">update yeshi_ec_home_navbar set br_name = #{name,jdbcType=VARCHAR},br_picture = #{picture,jdbcType=VARCHAR},br_class_id = #{classId,jdbcType=BIGINT},br_swiper_banner_id = #{swiperBannerId,jdbcType=BIGINT},br_url = #{url,jdbcType=VARCHAR},br_type = #{type,jdbcType=VARCHAR},br_orderby = #{orderby,jdbcType=INTEGER},br_order_man = #{orderMan,jdbcType=INTEGER},br_order_woman = #{orderWoman,jdbcType=INTEGER},br_start_time = #{startTime,jdbcType=TIMESTAMP},br_end_time = #{endTime,jdbcType=TIMESTAMP},br_state = #{state,jdbcType=INTEGER},br_is_default = #{isDefault,jdbcType=VARCHAR},br_is_fixed = #{isFixed,jdbcType=VARCHAR},br_params = #{params,jdbcType=VARCHAR},br_createtime = #{createtime,jdbcType=TIMESTAMP},br_updatetime = #{updatetime,jdbcType=TIMESTAMP} where br_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.homemodule.HomeNavbar">update yeshi_ec_home_navbar
    <set>
      <if test="name != null">br_name=#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">br_picture=#{picture,jdbcType=VARCHAR},</if>
      <if test="classId != null">br_class_id=#{classId,jdbcType=BIGINT},</if>
      <if test="swiperBannerId != null">br_swiper_banner_id=#{swiperBannerId,jdbcType=BIGINT},</if>
      <if test="url != null">br_url=#{url,jdbcType=VARCHAR},</if>
      <if test="type != null">br_type=#{type,jdbcType=VARCHAR},</if>
      <if test="orderby != null">br_orderby=#{orderby,jdbcType=INTEGER},</if>
      <if test="orderMan != null">br_order_man=#{orderMan,jdbcType=INTEGER},</if>
      <if test="orderWoman != null">br_order_woman=#{orderWoman,jdbcType=INTEGER},</if>
      <if test="startTime != null">br_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">br_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="state != null">br_state=#{state,jdbcType=INTEGER},</if>
      <if test="isDefault != null">br_is_default=#{isDefault,jdbcType=VARCHAR},</if>
      <if test="isFixed != null">br_is_fixed=#{isFixed,jdbcType=VARCHAR},</if>
      <if test="params != null">br_params=#{params,jdbcType=VARCHAR},</if>
      <if test="createtime != null">br_createtime=#{createtime,jdbcType=TIMESTAMP},</if>
      <if test="updatetime != null">br_updatetime=#{updatetime,jdbcType=TIMESTAMP},</if>
    </set> where br_id = #{id,jdbcType=BIGINT}
  </update>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.homemodule.HomeNavbar" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_home_navbar (br_id,br_name,br_picture,br_class_id,br_swiper_banner_id,br_url,br_type,br_orderby,br_order_man,br_order_woman,br_start_time,br_end_time,br_state,br_is_default,br_is_fixed,br_params,br_createtime,br_updatetime,br_system) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{classId,jdbcType=BIGINT},#{swiperBannerId,jdbcType=BIGINT},#{url,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{orderby,jdbcType=INTEGER},#{orderMan,jdbcType=INTEGER},#{orderWoman,jdbcType=INTEGER},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{state,jdbcType=INTEGER},#{isDefault,jdbcType=VARCHAR},#{isFixed,jdbcType=VARCHAR},#{params,jdbcType=VARCHAR},#{createtime,jdbcType=TIMESTAMP},#{updatetime,jdbcType=TIMESTAMP},#{system,jdbcType=VARCHAR})</insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.homemodule.HomeNavbar"
            useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_home_navbar
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">br_id,</if>
            <if test="name != null">br_name,</if>
            <if test="picture != null">br_picture,</if>
            <if test="classId != null">br_class_id,</if>
            <if test="swiperBannerId != null">br_swiper_banner_id,</if>
            <if test="url != null">br_url,</if>
            <if test="type != null">br_type,</if>
            <if test="orderby != null">br_orderby,</if>
            <if test="orderMan != null">br_order_man,</if>
            <if test="orderWoman != null">br_order_woman,</if>
            <if test="startTime != null">br_start_time,</if>
            <if test="endTime != null">br_end_time,</if>
            <if test="state != null">br_state,</if>
            <if test="isDefault != null">br_is_default,</if>
            <if test="isFixed != null">br_is_fixed,</if>
            <if test="params != null">br_params,</if>
            <if test="createtime != null">br_createtime,</if>
            <if test="updatetime != null">br_updatetime,</if>
            <if test="system != null">br_system,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="name != null">#{name,jdbcType=VARCHAR},</if>
            <if test="picture != null">#{picture,jdbcType=VARCHAR},</if>
            <if test="classId != null">#{classId,jdbcType=BIGINT},</if>
            <if test="swiperBannerId != null">#{swiperBannerId,jdbcType=BIGINT},</if>
            <if test="url != null">#{url,jdbcType=VARCHAR},</if>
            <if test="type != null">#{type,jdbcType=VARCHAR},</if>
            <if test="orderby != null">#{orderby,jdbcType=INTEGER},</if>
            <if test="orderMan != null">#{orderMan,jdbcType=INTEGER},</if>
            <if test="orderWoman != null">#{orderWoman,jdbcType=INTEGER},</if>
            <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
            <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="state != null">#{state,jdbcType=INTEGER},</if>
            <if test="isDefault != null">#{isDefault,jdbcType=VARCHAR},</if>
            <if test="isFixed != null">#{isFixed,jdbcType=VARCHAR},</if>
            <if test="params != null">#{params,jdbcType=VARCHAR},</if>
            <if test="createtime != null">#{createtime,jdbcType=TIMESTAMP},</if>
            <if test="updatetime != null">#{updatetime,jdbcType=TIMESTAMP},</if>
            <if test="system != null">#{system,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
            parameterType="com.yeshi.fanli.entity.bus.homemodule.HomeNavbar">update yeshi_ec_home_navbar set br_name = #{name,jdbcType=VARCHAR},br_picture = #{picture,jdbcType=VARCHAR},br_class_id = #{classId,jdbcType=BIGINT},br_swiper_banner_id = #{swiperBannerId,jdbcType=BIGINT},br_url = #{url,jdbcType=VARCHAR},br_type = #{type,jdbcType=VARCHAR},br_orderby = #{orderby,jdbcType=INTEGER},br_order_man = #{orderMan,jdbcType=INTEGER},br_order_woman = #{orderWoman,jdbcType=INTEGER},br_start_time = #{startTime,jdbcType=TIMESTAMP},br_end_time = #{endTime,jdbcType=TIMESTAMP},br_state = #{state,jdbcType=INTEGER},br_is_default = #{isDefault,jdbcType=VARCHAR},br_is_fixed = #{isFixed,jdbcType=VARCHAR},br_params = #{params,jdbcType=VARCHAR},br_createtime = #{createtime,jdbcType=TIMESTAMP},br_updatetime = #{updatetime,jdbcType=TIMESTAMP} ,br_system = #{system,jdbcType=VARCHAR} where br_id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.homemodule.HomeNavbar">update
        yeshi_ec_home_navbar
        <set>
            <if test="name != null">br_name=#{name,jdbcType=VARCHAR},</if>
            <if test="picture != null">br_picture=#{picture,jdbcType=VARCHAR},</if>
            <if test="classId != null">br_class_id=#{classId,jdbcType=BIGINT},</if>
            <if test="swiperBannerId != null">br_swiper_banner_id=#{swiperBannerId,jdbcType=BIGINT},</if>
            <if test="url != null">br_url=#{url,jdbcType=VARCHAR},</if>
            <if test="type != null">br_type=#{type,jdbcType=VARCHAR},</if>
            <if test="orderby != null">br_orderby=#{orderby,jdbcType=INTEGER},</if>
            <if test="orderMan != null">br_order_man=#{orderMan,jdbcType=INTEGER},</if>
            <if test="orderWoman != null">br_order_woman=#{orderWoman,jdbcType=INTEGER},</if>
            <if test="startTime != null">br_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
            <if test="endTime != null">br_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="state != null">br_state=#{state,jdbcType=INTEGER},</if>
            <if test="isDefault != null">br_is_default=#{isDefault,jdbcType=VARCHAR},</if>
            <if test="isFixed != null">br_is_fixed=#{isFixed,jdbcType=VARCHAR},</if>
            <if test="params != null">br_params=#{params,jdbcType=VARCHAR},</if>
            <if test="createtime != null">br_createtime=#{createtime,jdbcType=TIMESTAMP},</if>
            <if test="updatetime != null">br_updatetime=#{updatetime,jdbcType=TIMESTAMP},</if>
            <if test="system != null">br_system=#{system,jdbcType=VARCHAR},</if>
        </set>
        where br_id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/push/PushCouponMapper.xml
@@ -2,101 +2,114 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.push.PushCouponMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.push.PushCoupon">
    <id column="pc_id" property="id" jdbcType="BIGINT"/>
    <result column="pc_title" property="title" jdbcType="VARCHAR"/>
    <result column="pc_content" property="content" jdbcType="VARCHAR"/>
    <result column="pc_amount" property="amount" jdbcType="INTEGER"/>
    <result column="pc_percent" property="percent" jdbcType="DECIMAL"/>
    <result column="pc_uids" property="uids" jdbcType="VARCHAR"/>
    <result column="pc_versions" property="versions" jdbcType="VARCHAR"/>
    <result column="pc_remark" property="remark" jdbcType="VARCHAR"/>
    <result column="pc_start_time" property="startTime" jdbcType="TIMESTAMP"/>
    <result column="pc_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="pc_pushed" property="pushed" jdbcType="VARCHAR"/>
    <result column="pc_push_time" property="pushTime" jdbcType="TIMESTAMP"/>
    <result column="pc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="pc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">pc_id,pc_title,pc_content,pc_amount,pc_percent,pc_uids,pc_versions,pc_remark,pc_start_time,pc_end_time,pc_pushed,pc_push_time,pc_create_time,pc_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_push_coupon where pc_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_push_coupon where pc_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.push.PushCoupon" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_coupon (pc_id,pc_title,pc_content,pc_amount,pc_percent,pc_uids,pc_versions,pc_remark,pc_start_time,pc_end_time,pc_pushed,pc_push_time,pc_create_time,pc_update_time) values (#{id,jdbcType=BIGINT},#{title,jdbcType=VARCHAR},#{content,jdbcType=VARCHAR},#{amount,jdbcType=INTEGER},#{percent,jdbcType=DECIMAL},#{uids,jdbcType=VARCHAR},#{versions,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{pushed,jdbcType=VARCHAR},#{pushTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.push.PushCoupon" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_coupon
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">pc_id,</if>
      <if test="title != null">pc_title,</if>
      <if test="content != null">pc_content,</if>
      <if test="amount != null">pc_amount,</if>
      <if test="percent != null">pc_percent,</if>
      <if test="uids != null">pc_uids,</if>
      <if test="versions != null">pc_versions,</if>
      <if test="remark != null">pc_remark,</if>
      <if test="startTime != null">pc_start_time,</if>
      <if test="endTime != null">pc_end_time,</if>
      <if test="pushed != null">pc_pushed,</if>
      <if test="pushTime != null">pc_push_time,</if>
      <if test="createTime != null">pc_create_time,</if>
      <if test="updateTime != null">pc_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="title != null">#{title,jdbcType=VARCHAR},</if>
      <if test="content != null">#{content,jdbcType=VARCHAR},</if>
      <if test="amount != null">#{amount,jdbcType=INTEGER},</if>
      <if test="percent != null">#{percent,jdbcType=DECIMAL},</if>
      <if test="uids != null">#{uids,jdbcType=VARCHAR},</if>
      <if test="versions != null">#{versions,jdbcType=VARCHAR},</if>
      <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
      <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="pushed != null">#{pushed,jdbcType=VARCHAR},</if>
      <if test="pushTime != null">#{pushTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.push.PushCoupon">update yeshi_ec_push_coupon set pc_title = #{title,jdbcType=VARCHAR},pc_content = #{content,jdbcType=VARCHAR},pc_amount = #{amount,jdbcType=INTEGER},pc_percent = #{percent,jdbcType=DECIMAL},pc_uids = #{uids,jdbcType=VARCHAR},pc_versions = #{versions,jdbcType=VARCHAR},pc_remark = #{remark,jdbcType=VARCHAR},pc_start_time = #{startTime,jdbcType=TIMESTAMP},pc_end_time = #{endTime,jdbcType=TIMESTAMP},pc_pushed = #{pushed,jdbcType=VARCHAR},pc_push_time = #{pushTime,jdbcType=TIMESTAMP},pc_create_time = #{createTime,jdbcType=TIMESTAMP},pc_update_time = #{updateTime,jdbcType=TIMESTAMP} where pc_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.push.PushCoupon">update yeshi_ec_push_coupon
    <set>
      <if test="title != null">pc_title=#{title,jdbcType=VARCHAR},</if>
      <if test="content != null">pc_content=#{content,jdbcType=VARCHAR},</if>
      <if test="amount != null">pc_amount=#{amount,jdbcType=INTEGER},</if>
      <if test="percent != null">pc_percent=#{percent,jdbcType=DECIMAL},</if>
      <if test="uids != null">pc_uids=#{uids,jdbcType=VARCHAR},</if>
      <if test="versions != null">pc_versions=#{versions,jdbcType=VARCHAR},</if>
      <if test="remark != null">pc_remark=#{remark,jdbcType=VARCHAR},</if>
      <if test="startTime != null">pc_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">pc_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="pushed != null">pc_pushed=#{pushed,jdbcType=VARCHAR},</if>
      <if test="pushTime != null">pc_push_time=#{pushTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">pc_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">pc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where pc_id = #{id,jdbcType=BIGINT}
  </update>
  <select id="listQuery" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />  FROM yeshi_ec_push_coupon
        WHERE 1=1
           <if test='key != null and key != ""'>
                  AND pc_uids like '%${key}%'
           </if>
           ORDER BY pc_create_time desc
        LIMIT ${start},${count}
   </select>
   <select id="countQuery" resultType="java.lang.Long">
        SELECT IFNULL(count(pc_id),0)  FROM yeshi_ec_push_coupon
        WHERE 1=1
           <if test='key != null and key != ""'>
                   AND pc_uids like '%${key}%'
           </if>
    </select>
    <select id="listQueryEffective" resultMap="BaseResultMap">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.push.PushCoupon">
        <id column="pc_id" property="id" jdbcType="BIGINT"/>
        <result column="pc_title" property="title" jdbcType="VARCHAR"/>
        <result column="pc_content" property="content" jdbcType="VARCHAR"/>
        <result column="pc_amount" property="amount" jdbcType="INTEGER"/>
        <result column="pc_percent" property="percent" jdbcType="DECIMAL"/>
        <result column="pc_uids" property="uids" jdbcType="VARCHAR"/>
        <result column="pc_versions" property="versions" jdbcType="VARCHAR"/>
        <result column="pc_remark" property="remark" jdbcType="VARCHAR"/>
        <result column="pc_start_time" property="startTime" jdbcType="TIMESTAMP"/>
        <result column="pc_end_time" property="endTime" jdbcType="TIMESTAMP"/>
        <result column="pc_pushed" property="pushed" jdbcType="VARCHAR"/>
        <result column="pc_push_time" property="pushTime" jdbcType="TIMESTAMP"/>
        <result column="pc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="pc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="pc_system" property="system" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">pc_id,pc_title,pc_content,pc_amount,pc_percent,pc_uids,pc_versions,pc_remark,pc_start_time,pc_end_time,pc_pushed,pc_push_time,pc_create_time,pc_update_time,pc_system</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/>from yeshi_ec_push_coupon where pc_id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey"
            parameterType="java.lang.Long">delete from yeshi_ec_push_coupon where pc_id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.push.PushCoupon" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_push_coupon (pc_id,pc_title,pc_content,pc_amount,pc_percent,pc_uids,pc_versions,pc_remark,pc_start_time,pc_end_time,pc_pushed,pc_push_time,pc_create_time,pc_update_time,pc_system) values (#{id,jdbcType=BIGINT},#{title,jdbcType=VARCHAR},#{content,jdbcType=VARCHAR},#{amount,jdbcType=INTEGER},#{percent,jdbcType=DECIMAL},#{uids,jdbcType=VARCHAR},#{versions,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{pushed,jdbcType=VARCHAR},#{pushTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{system,jdbcType=VARCHAR})</insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.push.PushCoupon" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_push_coupon
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">pc_id,</if>
            <if test="title != null">pc_title,</if>
            <if test="content != null">pc_content,</if>
            <if test="amount != null">pc_amount,</if>
            <if test="percent != null">pc_percent,</if>
            <if test="uids != null">pc_uids,</if>
            <if test="versions != null">pc_versions,</if>
            <if test="remark != null">pc_remark,</if>
            <if test="startTime != null">pc_start_time,</if>
            <if test="endTime != null">pc_end_time,</if>
            <if test="pushed != null">pc_pushed,</if>
            <if test="pushTime != null">pc_push_time,</if>
            <if test="createTime != null">pc_create_time,</if>
            <if test="updateTime != null">pc_update_time,</if>
            <if test="system != null">pc_system,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="title != null">#{title,jdbcType=VARCHAR},</if>
            <if test="content != null">#{content,jdbcType=VARCHAR},</if>
            <if test="amount != null">#{amount,jdbcType=INTEGER},</if>
            <if test="percent != null">#{percent,jdbcType=DECIMAL},</if>
            <if test="uids != null">#{uids,jdbcType=VARCHAR},</if>
            <if test="versions != null">#{versions,jdbcType=VARCHAR},</if>
            <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
            <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
            <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="pushed != null">#{pushed,jdbcType=VARCHAR},</if>
            <if test="pushTime != null">#{pushTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="system != null">#{system,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
            parameterType="com.yeshi.fanli.entity.push.PushCoupon">update yeshi_ec_push_coupon set pc_title = #{title,jdbcType=VARCHAR},pc_content = #{content,jdbcType=VARCHAR},pc_amount = #{amount,jdbcType=INTEGER},pc_percent = #{percent,jdbcType=DECIMAL},pc_uids = #{uids,jdbcType=VARCHAR},pc_versions = #{versions,jdbcType=VARCHAR},pc_remark = #{remark,jdbcType=VARCHAR},pc_start_time = #{startTime,jdbcType=TIMESTAMP},pc_end_time = #{endTime,jdbcType=TIMESTAMP},pc_pushed = #{pushed,jdbcType=VARCHAR},pc_push_time = #{pushTime,jdbcType=TIMESTAMP},pc_create_time = #{createTime,jdbcType=TIMESTAMP},pc_update_time = #{updateTime,jdbcType=TIMESTAMP},pc_system = #{system,jdbcType=VARCHAR} where pc_id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.push.PushCoupon">update
        yeshi_ec_push_coupon
        <set>
            <if test="title != null">pc_title=#{title,jdbcType=VARCHAR},</if>
            <if test="content != null">pc_content=#{content,jdbcType=VARCHAR},</if>
            <if test="amount != null">pc_amount=#{amount,jdbcType=INTEGER},</if>
            <if test="percent != null">pc_percent=#{percent,jdbcType=DECIMAL},</if>
            <if test="uids != null">pc_uids=#{uids,jdbcType=VARCHAR},</if>
            <if test="versions != null">pc_versions=#{versions,jdbcType=VARCHAR},</if>
            <if test="remark != null">pc_remark=#{remark,jdbcType=VARCHAR},</if>
            <if test="startTime != null">pc_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
            <if test="endTime != null">pc_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="pushed != null">pc_pushed=#{pushed,jdbcType=VARCHAR},</if>
            <if test="pushTime != null">pc_push_time=#{pushTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">pc_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">pc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="system != null">pc_system=#{system,jdbcType=VARCHAR},</if>
        </set>
        where pc_id = #{id,jdbcType=BIGINT}
    </update>
    <select id="listQuery" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM yeshi_ec_push_coupon
        WHERE 1=1 AND pc_system=#{system}
        <if test='key != null and key != ""'>
            AND pc_uids like '%${key}%'
        </if>
        ORDER BY pc_create_time desc
        LIMIT ${start},${count}
    </select>
    <select id="countQuery" resultType="java.lang.Long">
        SELECT IFNULL(count(pc_id),0) FROM yeshi_ec_push_coupon
        WHERE 1=1 AND pc_system=#{system}
        <if test='key != null and key != ""'>
            AND pc_uids like '%${key}%'
        </if>
    </select>
    <select id="listQueryEffective" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_push_coupon 
        WHERE pc_pushed = 1
        WHERE pc_pushed = 1     AND pc_system=#{system}
            AND DATE_FORMAT(CURDATE(),'%Y%m%d') <![CDATA[ <= ]]>DATE_FORMAT(pc_end_time,'%Y%m%d');
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/push/PushGoodsMapper.xml
@@ -2,146 +2,169 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.push.PushGoodsMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.push.PushGoods">
    <id column="pg_id" property="id" jdbcType="BIGINT"/>
    <result column="pg_alert_title" property="alertTitle" jdbcType="VARCHAR"/>
    <result column="pg_alert_content" property="alertContent" jdbcType="VARCHAR"/>
    <result column="pg_title" property="title" jdbcType="VARCHAR"/>
    <result column="pg_content" property="content" jdbcType="VARCHAR"/>
    <result column="pg_picture" property="picture" jdbcType="VARCHAR"/>
    <result column="pg_uid" property="uid" jdbcType="BIGINT"/>
    <result column="pg_versions" property="versions" jdbcType="VARCHAR"/>
    <result column="pg_remark" property="remark" jdbcType="VARCHAR"/>
    <result column="pg_is_push" property="isPush" jdbcType="INTEGER"/>
    <result column="pg_control_time" property="controlTime" jdbcType="TIMESTAMP"/>
    <result column="pg_push_time" property="pushTime" jdbcType="TIMESTAMP"/>
    <result column="pg_createtime" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="pg_updatetime" property="updateTime" jdbcType="TIMESTAMP"/>
    <result column="pg_type" property="type" jdbcType="INTEGER"/>
    <result column="pg_other_id" property="otherId" jdbcType="VARCHAR"/>
    <result column="pg_scan_num" property="scanNum" jdbcType="INTEGER"/>
  </resultMap>
  <sql id="Base_Column_List">pg_id,pg_alert_title,pg_alert_content,pg_title,pg_content,pg_picture,pg_uid,pg_versions,pg_remark,pg_is_push,pg_control_time,pg_push_time,pg_createtime,pg_updatetime,pg_type,pg_other_id,pg_scan_num</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_push_goods where pg_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_push_goods where pg_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.push.PushGoods" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_goods (pg_id,pg_alert_title,pg_alert_content,pg_title,pg_content,pg_picture,pg_uid,pg_versions,pg_remark,pg_is_push,pg_control_time,pg_push_time,pg_createtime,pg_updatetime,pg_type,pg_other_id,pg_scan_num) values (#{id,jdbcType=BIGINT},#{alertTitle,jdbcType=VARCHAR},#{alertContent,jdbcType=VARCHAR},#{title,jdbcType=VARCHAR},#{content,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{uid,jdbcType=BIGINT},#{versions,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{isPush,jdbcType=INTEGER},#{controlTime,jdbcType=TIMESTAMP},#{pushTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{type,jdbcType=INTEGER},#{otherId,jdbcType=VARCHAR},#{scanNum,jdbcType=INTEGER})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.push.PushGoods" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_goods
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">pg_id,</if>
      <if test="alertTitle != null">pg_alert_title,</if>
      <if test="alertContent != null">pg_alert_content,</if>
      <if test="title != null">pg_title,</if>
      <if test="content != null">pg_content,</if>
      <if test="picture != null">pg_picture,</if>
      <if test="uid != null">pg_uid,</if>
      <if test="versions != null">pg_versions,</if>
      <if test="remark != null">pg_remark,</if>
      <if test="isPush != null">pg_is_push,</if>
      <if test="controlTime != null">pg_control_time,</if>
      <if test="pushTime != null">pg_push_time,</if>
      <if test="createTime != null">pg_createtime,</if>
      <if test="updateTime != null">pg_updatetime,</if>
      <if test="type != null">pg_type,</if>
      <if test="otherId != null">pg_other_id,</if>
      <if test="scanNum != null">pg_scan_num,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="alertTitle != null">#{alertTitle,jdbcType=VARCHAR},</if>
      <if test="alertContent != null">#{alertContent,jdbcType=VARCHAR},</if>
      <if test="title != null">#{title,jdbcType=VARCHAR},</if>
      <if test="content != null">#{content,jdbcType=VARCHAR},</if>
      <if test="picture != null">#{picture,jdbcType=VARCHAR},</if>
      <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
      <if test="versions != null">#{versions,jdbcType=VARCHAR},</if>
      <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
      <if test="isPush != null">#{isPush,jdbcType=INTEGER},</if>
      <if test="controlTime != null">#{controlTime,jdbcType=TIMESTAMP},</if>
      <if test="pushTime != null">#{pushTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
      <if test="type != null">#{type,jdbcType=INTEGER},</if>
      <if test="otherId != null">#{otherId,jdbcType=VARCHAR},</if>
      <if test="scanNum != null">#{scanNum,jdbcType=INTEGER},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.push.PushGoods">update yeshi_ec_push_goods set pg_alert_title = #{alertTitle,jdbcType=VARCHAR},pg_alert_content = #{alertContent,jdbcType=VARCHAR},pg_title = #{title,jdbcType=VARCHAR},pg_content = #{content,jdbcType=VARCHAR},pg_picture = #{picture,jdbcType=VARCHAR},pg_uid = #{uid,jdbcType=BIGINT},pg_versions = #{versions,jdbcType=VARCHAR},pg_remark = #{remark,jdbcType=VARCHAR},pg_is_push = #{isPush,jdbcType=INTEGER},pg_control_time = #{controlTime,jdbcType=TIMESTAMP},pg_push_time = #{pushTime,jdbcType=TIMESTAMP},pg_createtime = #{createTime,jdbcType=TIMESTAMP},pg_updatetime = #{updateTime,jdbcType=TIMESTAMP},pg_type = #{type,jdbcType=INTEGER},pg_other_id = #{otherId,jdbcType=VARCHAR},pg_scan_num = #{scanNum,jdbcType=INTEGER} where pg_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.push.PushGoods">update yeshi_ec_push_goods
    <set>
      <if test="alertTitle != null">pg_alert_title=#{alertTitle,jdbcType=VARCHAR},</if>
      <if test="alertContent != null">pg_alert_content=#{alertContent,jdbcType=VARCHAR},</if>
      <if test="title != null">pg_title=#{title,jdbcType=VARCHAR},</if>
      <if test="content != null">pg_content=#{content,jdbcType=VARCHAR},</if>
      <if test="picture != null">pg_picture=#{picture,jdbcType=VARCHAR},</if>
      <if test="uid != null">pg_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="versions != null">pg_versions=#{versions,jdbcType=VARCHAR},</if>
      <if test="remark != null">pg_remark=#{remark,jdbcType=VARCHAR},</if>
      <if test="isPush != null">pg_is_push=#{isPush,jdbcType=INTEGER},</if>
      <if test="controlTime != null">pg_control_time=#{controlTime,jdbcType=TIMESTAMP},</if>
      <if test="pushTime != null">pg_push_time=#{pushTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">pg_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">pg_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
      <if test="type != null">pg_type=#{type,jdbcType=INTEGER},</if>
      <if test="otherId != null">pg_other_id=#{otherId,jdbcType=VARCHAR},</if>
      <if test="scanNum != null">pg_scan_num=#{scanNum,jdbcType=INTEGER},</if>
    </set> where pg_id = #{id,jdbcType=BIGINT}
  </update>
  <delete id="deleteBatchByPrimaryKey"  parameterType="java.util.List">
        delete from yeshi_ec_push_goods where pg_id in
        <foreach item="item" collection="list" open="(" separator=","
            close=")">#{item}</foreach>
   </delete>
   <select id="listQuery" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />,IF(`pg_control_time` IS NOT NULL,pg_control_time,`pg_createtime`) AS orderyTime  FROM yeshi_ec_push_goods
        WHERE 1=1
           <if test='key != null and key != ""'>
                  AND (pg_alert_title like '%${key}%' or pg_alert_content like '%${key}%')
           </if>
           <if test='state != null'>
                  AND pg_is_push = #{state}
           </if>
           ORDER BY orderyTime DESC
        LIMIT ${start},${count}
   </select>
   <select id="countQuery" resultType="java.lang.Long">
        SELECT IFNULL(count(pg_id),0)  FROM yeshi_ec_push_goods
        WHERE 1=1
           <if test='key != null and key != ""'>
                  AND (pg_alert_title like '%${key}%' or pg_alert_content like '%${key}%')
           </if>
            <if test='state != null'>
                  AND pg_is_push = #{state}
           </if>
    </select>
   <select id="listHistoryByPushTime" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />  FROM yeshi_ec_push_goods
        WHERE pg_is_push = 1   AND <![CDATA[pg_push_time >= #{pushTime}]]>
              AND (pg_uid is null <if test='uid != null'>or pg_uid = #{uid} </if>)
           ORDER BY pg_push_time desc
        LIMIT ${start},${count}
   </select>
   <select id="countHistoryByPushTime" resultType="java.lang.Long">
        SELECT IFNULL(count(pg_id),0)  FROM yeshi_ec_push_goods
        WHERE pg_is_push = 1   AND <![CDATA[pg_push_time >= #{pushTime}]]>
              AND (pg_uid is null <if test='uid != null'>or pg_uid = #{uid} </if>)
   </select>
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.push.PushGoods">
        <id column="pg_id" property="id" jdbcType="BIGINT"/>
        <result column="pg_alert_title" property="alertTitle" jdbcType="VARCHAR"/>
        <result column="pg_alert_content" property="alertContent" jdbcType="VARCHAR"/>
        <result column="pg_title" property="title" jdbcType="VARCHAR"/>
        <result column="pg_content" property="content" jdbcType="VARCHAR"/>
        <result column="pg_picture" property="picture" jdbcType="VARCHAR"/>
        <result column="pg_uid" property="uid" jdbcType="BIGINT"/>
        <result column="pg_versions" property="versions" jdbcType="VARCHAR"/>
        <result column="pg_remark" property="remark" jdbcType="VARCHAR"/>
        <result column="pg_is_push" property="isPush" jdbcType="INTEGER"/>
        <result column="pg_control_time" property="controlTime" jdbcType="TIMESTAMP"/>
        <result column="pg_push_time" property="pushTime" jdbcType="TIMESTAMP"/>
        <result column="pg_createtime" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="pg_updatetime" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="pg_type" property="type" jdbcType="INTEGER"/>
        <result column="pg_other_id" property="otherId" jdbcType="VARCHAR"/>
        <result column="pg_scan_num" property="scanNum" jdbcType="INTEGER"/>
        <result column="pg_system" property="system" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">pg_id,pg_alert_title,pg_alert_content,pg_title,pg_content,pg_picture,pg_uid,pg_versions,pg_remark,pg_is_push,pg_control_time,pg_push_time,pg_createtime,pg_updatetime,pg_type,pg_other_id,pg_scan_num,pg_system</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/>from yeshi_ec_push_goods where pg_id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey"
            parameterType="java.lang.Long">delete from yeshi_ec_push_goods where pg_id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.push.PushGoods" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_push_goods (pg_id,pg_alert_title,pg_alert_content,pg_title,pg_content,pg_picture,pg_uid,pg_versions,pg_remark,pg_is_push,pg_control_time,pg_push_time,pg_createtime,pg_updatetime,pg_type,pg_other_id,pg_scan_num,pg_system) values (#{id,jdbcType=BIGINT},#{alertTitle,jdbcType=VARCHAR},#{alertContent,jdbcType=VARCHAR},#{title,jdbcType=VARCHAR},#{content,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{uid,jdbcType=BIGINT},#{versions,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{isPush,jdbcType=INTEGER},#{controlTime,jdbcType=TIMESTAMP},#{pushTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{type,jdbcType=INTEGER},#{otherId,jdbcType=VARCHAR},#{scanNum,jdbcType=INTEGER},#{system,jdbcType=VARCHAR})</insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.push.PushGoods" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_push_goods
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">pg_id,</if>
            <if test="alertTitle != null">pg_alert_title,</if>
            <if test="alertContent != null">pg_alert_content,</if>
            <if test="title != null">pg_title,</if>
            <if test="content != null">pg_content,</if>
            <if test="picture != null">pg_picture,</if>
            <if test="uid != null">pg_uid,</if>
            <if test="versions != null">pg_versions,</if>
            <if test="remark != null">pg_remark,</if>
            <if test="isPush != null">pg_is_push,</if>
            <if test="controlTime != null">pg_control_time,</if>
            <if test="pushTime != null">pg_push_time,</if>
            <if test="createTime != null">pg_createtime,</if>
            <if test="updateTime != null">pg_updatetime,</if>
            <if test="type != null">pg_type,</if>
            <if test="otherId != null">pg_other_id,</if>
            <if test="scanNum != null">pg_scan_num,</if>
            <if test="system != null">pg_system,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="alertTitle != null">#{alertTitle,jdbcType=VARCHAR},</if>
            <if test="alertContent != null">#{alertContent,jdbcType=VARCHAR},</if>
            <if test="title != null">#{title,jdbcType=VARCHAR},</if>
            <if test="content != null">#{content,jdbcType=VARCHAR},</if>
            <if test="picture != null">#{picture,jdbcType=VARCHAR},</if>
            <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
            <if test="versions != null">#{versions,jdbcType=VARCHAR},</if>
            <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
            <if test="isPush != null">#{isPush,jdbcType=INTEGER},</if>
            <if test="controlTime != null">#{controlTime,jdbcType=TIMESTAMP},</if>
            <if test="pushTime != null">#{pushTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="type != null">#{type,jdbcType=INTEGER},</if>
            <if test="otherId != null">#{otherId,jdbcType=VARCHAR},</if>
            <if test="scanNum != null">#{scanNum,jdbcType=INTEGER},</if>
            <if test="system != null">#{system,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
            parameterType="com.yeshi.fanli.entity.push.PushGoods">update yeshi_ec_push_goods set pg_alert_title = #{alertTitle,jdbcType=VARCHAR},pg_alert_content = #{alertContent,jdbcType=VARCHAR},pg_title = #{title,jdbcType=VARCHAR},pg_content = #{content,jdbcType=VARCHAR},pg_picture = #{picture,jdbcType=VARCHAR},pg_uid = #{uid,jdbcType=BIGINT},pg_versions = #{versions,jdbcType=VARCHAR},pg_remark = #{remark,jdbcType=VARCHAR},pg_is_push = #{isPush,jdbcType=INTEGER},pg_control_time = #{controlTime,jdbcType=TIMESTAMP},pg_push_time = #{pushTime,jdbcType=TIMESTAMP},pg_createtime = #{createTime,jdbcType=TIMESTAMP},pg_updatetime = #{updateTime,jdbcType=TIMESTAMP},pg_type = #{type,jdbcType=INTEGER},pg_other_id = #{otherId,jdbcType=VARCHAR},pg_scan_num = #{scanNum,jdbcType=INTEGER},pg_system = #{system,jdbcType=VARCHAR} where pg_id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.push.PushGoods">update
        yeshi_ec_push_goods
        <set>
            <if test="alertTitle != null">pg_alert_title=#{alertTitle,jdbcType=VARCHAR},</if>
            <if test="alertContent != null">pg_alert_content=#{alertContent,jdbcType=VARCHAR},</if>
            <if test="title != null">pg_title=#{title,jdbcType=VARCHAR},</if>
            <if test="content != null">pg_content=#{content,jdbcType=VARCHAR},</if>
            <if test="picture != null">pg_picture=#{picture,jdbcType=VARCHAR},</if>
            <if test="uid != null">pg_uid=#{uid,jdbcType=BIGINT},</if>
            <if test="versions != null">pg_versions=#{versions,jdbcType=VARCHAR},</if>
            <if test="remark != null">pg_remark=#{remark,jdbcType=VARCHAR},</if>
            <if test="isPush != null">pg_is_push=#{isPush,jdbcType=INTEGER},</if>
            <if test="controlTime != null">pg_control_time=#{controlTime,jdbcType=TIMESTAMP},</if>
            <if test="pushTime != null">pg_push_time=#{pushTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">pg_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">pg_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="type != null">pg_type=#{type,jdbcType=INTEGER},</if>
            <if test="otherId != null">pg_other_id=#{otherId,jdbcType=VARCHAR},</if>
            <if test="scanNum != null">pg_scan_num=#{scanNum,jdbcType=INTEGER},</if>
            <if test="system != null">pg_system=#{system,jdbcType=VARCHAR},</if>
        </set>
        where pg_id = #{id,jdbcType=BIGINT}
    </update>
    <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List">
        delete from yeshi_ec_push_goods where pg_id in
        <foreach item="item" collection="list" open="(" separator=","
                 close=")">#{item}
        </foreach>
    </delete>
    <select id="listQuery" resultMap="BaseResultMap">
        SELECT<include refid="Base_Column_List"/>,IF(`pg_control_time` IS NOT NULL,pg_control_time,`pg_createtime`) AS
        orderyTime FROM yeshi_ec_push_goods
        WHERE 1=1
        AND pg_system=#{system}
        <if test='key != null and key != ""'>
            AND (pg_alert_title like '%${key}%' or pg_alert_content like '%${key}%')
        </if>
        <if test='state != null'>
            AND pg_is_push = #{state}
        </if>
        ORDER BY orderyTime DESC
        LIMIT ${start},${count}
    </select>
    <select id="countQuery" resultType="java.lang.Long">
        SELECT IFNULL(count(pg_id),0) FROM yeshi_ec_push_goods
        WHERE 1=1
        AND pg_system=#{system}
        <if test='key != null and key != ""'>
            AND (pg_alert_title like '%${key}%' or pg_alert_content like '%${key}%')
        </if>
        <if test='state != null'>
            AND pg_is_push = #{state}
        </if>
    </select>
    <select id="listHistoryByPushTime" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM yeshi_ec_push_goods
        WHERE pg_is_push = 1   AND pg_system=#{system} AND <![CDATA[pg_push_time >= #{pushTime}]]>
        AND (pg_uid is null <if test='uid != null'>or pg_uid = #{uid}</if>)
        ORDER BY pg_push_time desc
        LIMIT ${start},${count}
    </select>
    <select id="countHistoryByPushTime" resultType="java.lang.Long">
        SELECT IFNULL(count(pg_id),0) FROM yeshi_ec_push_goods
        WHERE pg_is_push = 1   AND pg_system=#{system} AND <![CDATA[pg_push_time >= #{pushTime}]]>
        AND (pg_uid is null <if test='uid != null'>or pg_uid = #{uid}</if>)
    </select>
    <select id="listByPushState" resultMap="BaseResultMap" parameterType="java.util.List">
        SELECT <include refid="Base_Column_List" />  FROM yeshi_ec_push_goods
        WHERE  pg_is_push = 1 AND  pg_id in
        <foreach item="item" collection="list" open="(" separator=","
            close=")">#{item}</foreach>
   </select>
   <select id="listTask" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM yeshi_ec_push_goods
        WHERE pg_is_push = 1 AND pg_id in
        <foreach item="item" collection="list" open="(" separator=","
                 close=")">#{item}
        </foreach>
    </select>
    <select id="listTask" resultMap="BaseResultMap">
          SELECT * FROM `yeshi_ec_push_goods` p
        WHERE p.`pg_is_push` = 0 AND p.`pg_control_time` IS NOT NULL
        WHERE p.`pg_is_push` = 0   AND pg_system=#{system} AND p.`pg_control_time` IS NOT NULL
              AND p.`pg_control_time` <![CDATA[<=]]> NOW()
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/push/PushInfoMapper.xml
@@ -2,111 +2,124 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.push.PushInfoMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.push.PushInfo">
    <id column="pi_id" property="id" jdbcType="BIGINT"/>
    <result column="pi_title" property="title" jdbcType="VARCHAR"/>
    <result column="pi_content" property="content" jdbcType="VARCHAR"/>
    <result column="pi_uids" property="uids" jdbcType="VARCHAR"/>
    <result column="pi_json_data" property="jsonData" jdbcType="VARCHAR"/>
    <result column="pi_control_time" property="controlTime" jdbcType="TIMESTAMP"/>
    <result column="pi_remark" property="remark" jdbcType="VARCHAR"/>
    <result column="pi_state" property="state" jdbcType="INTEGER"/>
    <result column="pi_push_time" property="pushTime" jdbcType="TIMESTAMP"/>
    <result column="pi_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="pi_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <result column="pi_type" property="type" typeHandler="com.yeshi.fanli.util.mybatishandler.PushTypeEnumHandler" />
  </resultMap>
  <sql id="Base_Column_List">pi_id,pi_title,pi_content,pi_uids,pi_json_data,pi_type,pi_control_time,pi_remark,pi_state,pi_push_time,pi_create_time,pi_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_push_info where pi_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_push_info where pi_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.push.PushInfo" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_info (pi_id,pi_title,pi_content,pi_uids,pi_json_data,pi_type,pi_control_time,pi_remark,pi_state,pi_push_time,pi_create_time,pi_update_time) values (#{id,jdbcType=BIGINT},#{title,jdbcType=VARCHAR},#{content,jdbcType=VARCHAR},#{uids,jdbcType=VARCHAR},#{jsonData,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{controlTime,jdbcType=TIMESTAMP},#{remark,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{pushTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.push.PushInfo" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">pi_id,</if>
      <if test="title != null">pi_title,</if>
      <if test="content != null">pi_content,</if>
      <if test="uids != null">pi_uids,</if>
      <if test="jsonData != null">pi_json_data,</if>
      <if test="type != null">pi_type,</if>
      <if test="controlTime != null">pi_control_time,</if>
      <if test="remark != null">pi_remark,</if>
      <if test="state != null">pi_state,</if>
      <if test="pushTime != null">pi_push_time,</if>
      <if test="createTime != null">pi_create_time,</if>
      <if test="updateTime != null">pi_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="title != null">#{title,jdbcType=VARCHAR},</if>
      <if test="content != null">#{content,jdbcType=VARCHAR},</if>
      <if test="uids != null">#{uids,jdbcType=VARCHAR},</if>
      <if test="jsonData != null">#{jsonData,jdbcType=VARCHAR},</if>
      <if test="type != null">#{type,jdbcType=VARCHAR},</if>
      <if test="controlTime != null">#{controlTime,jdbcType=TIMESTAMP},</if>
      <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
      <if test="pushTime != null">#{pushTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.push.PushInfo">update yeshi_ec_push_info set pi_title = #{title,jdbcType=VARCHAR},pi_content = #{content,jdbcType=VARCHAR},pi_uids = #{uids,jdbcType=VARCHAR},pi_json_data = #{jsonData,jdbcType=VARCHAR},pi_type = #{type,jdbcType=VARCHAR},pi_control_time = #{controlTime,jdbcType=TIMESTAMP},pi_remark = #{remark,jdbcType=VARCHAR},pi_state = #{state,jdbcType=INTEGER},pi_push_time = #{pushTime,jdbcType=TIMESTAMP},pi_create_time = #{createTime,jdbcType=TIMESTAMP},pi_update_time = #{updateTime,jdbcType=TIMESTAMP} where pi_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.push.PushInfo">update yeshi_ec_push_info
    <set>
      <if test="title != null">pi_title=#{title,jdbcType=VARCHAR},</if>
      <if test="content != null">pi_content=#{content,jdbcType=VARCHAR},</if>
      <if test="uids != null">pi_uids=#{uids,jdbcType=VARCHAR},</if>
      <if test="jsonData != null">pi_json_data=#{jsonData,jdbcType=VARCHAR},</if>
      <if test="type != null">pi_type=#{type,jdbcType=VARCHAR},</if>
      <if test="controlTime != null">pi_control_time=#{controlTime,jdbcType=TIMESTAMP},</if>
      <if test="remark != null">pi_remark=#{remark,jdbcType=VARCHAR},</if>
      <if test="state != null">pi_state=#{state,jdbcType=INTEGER},</if>
      <if test="pushTime != null">pi_push_time=#{pushTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">pi_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">pi_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where pi_id = #{id,jdbcType=BIGINT}
  </update>
   <delete id="deleteBatchByPrimaryKey"  parameterType="java.util.List">
        delete from yeshi_ec_push_info where pi_push_time is null AND pi_id in
        <foreach item="item" collection="list" open="(" separator=","
            close=")">#{item}</foreach>
   </delete>
  <select id="listQuery" resultMap="BaseResultMap">
      SELECT p.*,IF(`pi_control_time` IS NOT NULL,pi_control_time,`pi_create_time`) AS orderyTime FROM  yeshi_ec_push_info p
    WHERE pi_type = #{type}
        <if test="key != null and key !='' ">
            <if test="keyType == 1">AND pi_title like '%#{key}%'</if>
            <if test="keyType == 2">AND pi_content like '%#{key}%'</if>
            <if test="keyType == 3">AND pi_uids like '%#{key}%'</if>
        </if>
        <if  test="state != null">
            AND pi_state = #{state}
        </if>
      ORDER BY orderyTime DESC
      LIMIT ${start},${count}
  </select>
  <select id="countQuery" resultType="java.lang.Long">
      SELECT IFNULL(COUNT(pi_id),0) FROM  yeshi_ec_push_info
    WHERE pi_type = #{type}
        <if test="key != null and key !='' ">
            <if test="keyType == 1">AND pi_title like '%#{key}%'</if>
            <if test="keyType == 2">AND pi_content like '%#{key}%'</if>
            <if test="keyType == 3">AND pi_uids like '%#{key}%'</if>
        </if>
        <if test="state != null">
            AND pi_state = #{state}
        </if>
  </select>
  <select id="listTask" resultMap="BaseResultMap">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.push.PushInfo">
        <id column="pi_id" property="id" jdbcType="BIGINT"/>
        <result column="pi_title" property="title" jdbcType="VARCHAR"/>
        <result column="pi_content" property="content" jdbcType="VARCHAR"/>
        <result column="pi_uids" property="uids" jdbcType="VARCHAR"/>
        <result column="pi_json_data" property="jsonData" jdbcType="VARCHAR"/>
        <result column="pi_control_time" property="controlTime" jdbcType="TIMESTAMP"/>
        <result column="pi_remark" property="remark" jdbcType="VARCHAR"/>
        <result column="pi_state" property="state" jdbcType="INTEGER"/>
        <result column="pi_push_time" property="pushTime" jdbcType="TIMESTAMP"/>
        <result column="pi_create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="pi_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="pi_type" property="type" typeHandler="com.yeshi.fanli.util.mybatishandler.PushTypeEnumHandler"/>
        <result column="pi_system" property="system" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">pi_id,pi_title,pi_content,pi_uids,pi_json_data,pi_type,pi_control_time,pi_remark,pi_state,pi_push_time,pi_create_time,pi_update_time,pi_system</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/>from yeshi_ec_push_info where pi_id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey"
            parameterType="java.lang.Long">delete from yeshi_ec_push_info where pi_id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.push.PushInfo" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_push_info (pi_id,pi_title,pi_content,pi_uids,pi_json_data,pi_type,pi_control_time,pi_remark,pi_state,pi_push_time,pi_create_time,pi_update_time,pi_system) values (#{id,jdbcType=BIGINT},#{title,jdbcType=VARCHAR},#{content,jdbcType=VARCHAR},#{uids,jdbcType=VARCHAR},#{jsonData,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{controlTime,jdbcType=TIMESTAMP},#{remark,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{pushTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{system,jdbcType=VARCHAR})</insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.push.PushInfo" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_push_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">pi_id,</if>
            <if test="title != null">pi_title,</if>
            <if test="content != null">pi_content,</if>
            <if test="uids != null">pi_uids,</if>
            <if test="jsonData != null">pi_json_data,</if>
            <if test="type != null">pi_type,</if>
            <if test="controlTime != null">pi_control_time,</if>
            <if test="remark != null">pi_remark,</if>
            <if test="state != null">pi_state,</if>
            <if test="pushTime != null">pi_push_time,</if>
            <if test="createTime != null">pi_create_time,</if>
            <if test="updateTime != null">pi_update_time,</if>
            <if test="system != null">pi_system,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="title != null">#{title,jdbcType=VARCHAR},</if>
            <if test="content != null">#{content,jdbcType=VARCHAR},</if>
            <if test="uids != null">#{uids,jdbcType=VARCHAR},</if>
            <if test="jsonData != null">#{jsonData,jdbcType=VARCHAR},</if>
            <if test="type != null">#{type,jdbcType=VARCHAR},</if>
            <if test="controlTime != null">#{controlTime,jdbcType=TIMESTAMP},</if>
            <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
            <if test="state != null">#{state,jdbcType=INTEGER},</if>
            <if test="pushTime != null">#{pushTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="system != null">#{system,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
            parameterType="com.yeshi.fanli.entity.push.PushInfo">update yeshi_ec_push_info set pi_title = #{title,jdbcType=VARCHAR},pi_content = #{content,jdbcType=VARCHAR},pi_uids = #{uids,jdbcType=VARCHAR},pi_json_data = #{jsonData,jdbcType=VARCHAR},pi_type = #{type,jdbcType=VARCHAR},pi_control_time = #{controlTime,jdbcType=TIMESTAMP},pi_remark = #{remark,jdbcType=VARCHAR},pi_state = #{state,jdbcType=INTEGER},pi_push_time = #{pushTime,jdbcType=TIMESTAMP},pi_create_time = #{createTime,jdbcType=TIMESTAMP},pi_update_time = #{updateTime,jdbcType=TIMESTAMP},pi_system = #{system,jdbcType=VARCHAR} where pi_id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.push.PushInfo">update
        yeshi_ec_push_info
        <set>
            <if test="title != null">pi_title=#{title,jdbcType=VARCHAR},</if>
            <if test="content != null">pi_content=#{content,jdbcType=VARCHAR},</if>
            <if test="uids != null">pi_uids=#{uids,jdbcType=VARCHAR},</if>
            <if test="jsonData != null">pi_json_data=#{jsonData,jdbcType=VARCHAR},</if>
            <if test="type != null">pi_type=#{type,jdbcType=VARCHAR},</if>
            <if test="controlTime != null">pi_control_time=#{controlTime,jdbcType=TIMESTAMP},</if>
            <if test="remark != null">pi_remark=#{remark,jdbcType=VARCHAR},</if>
            <if test="state != null">pi_state=#{state,jdbcType=INTEGER},</if>
            <if test="pushTime != null">pi_push_time=#{pushTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">pi_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">pi_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="system != null">pi_system=#{system,jdbcType=VARCHAR},</if>
        </set>
        where pi_id = #{id,jdbcType=BIGINT}
    </update>
    <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List">
        delete from yeshi_ec_push_info where pi_push_time is null AND pi_id in
        <foreach item="item" collection="list" open="(" separator=","
                 close=")">#{item}
        </foreach>
    </delete>
    <select id="listQuery" resultMap="BaseResultMap">
        SELECT p.*,IF(`pi_control_time` IS NOT NULL,pi_control_time,`pi_create_time`) AS orderyTime FROM
        yeshi_ec_push_info p
        WHERE pi_type = #{type} AND pi_system=#{system}
        <if test="key != null and key !='' ">
            <if test="keyType == 1">AND pi_title like '%#{key}%'</if>
            <if test="keyType == 2">AND pi_content like '%#{key}%'</if>
            <if test="keyType == 3">AND pi_uids like '%#{key}%'</if>
        </if>
        <if test="state != null">
            AND pi_state = #{state}
        </if>
        ORDER BY orderyTime DESC
        LIMIT ${start},${count}
    </select>
    <select id="countQuery" resultType="java.lang.Long">
        SELECT IFNULL(COUNT(pi_id),0) FROM yeshi_ec_push_info
        WHERE pi_type = #{type} AND pi_system=#{system}
        <if test="key != null and key !='' ">
            <if test="keyType == 1">AND pi_title like '%#{key}%'</if>
            <if test="keyType == 2">AND pi_content like '%#{key}%'</if>
            <if test="keyType == 3">AND pi_uids like '%#{key}%'</if>
        </if>
        <if test="state != null">
            AND pi_state = #{state}
        </if>
    </select>
    <select id="listTask" resultMap="BaseResultMap">
      SELECT * FROM `yeshi_ec_push_info` p
    WHERE p.`pi_state` = 0 AND p.`pi_control_time` IS NOT NULL
    WHERE p.`pi_state` = 0 AND pi_system=#{system} AND p.`pi_control_time` IS NOT NULL
          AND p.`pi_control_time` <![CDATA[<=]]> NOW()
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassServiceImpl.java
@@ -5,6 +5,9 @@
import javax.annotation.Resource;
import com.yeshi.fanli.dao.mybatis.brand.BrandClassSystemMapMapper;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.brand.BrandClassSystemMap;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
@@ -18,154 +21,168 @@
@Service
public class BrandClassServiceImpl implements BrandClassService {
    @Resource
    private BrandClassMapper brandClassMapper;
    @Resource
    private GoodsClassService goodsClassService;
    @Resource
    private BrandClassShopService brandClassShopService;
    @Override
    public BrandClass selectByPrimaryKey(Long id) {
         return brandClassMapper.selectByPrimaryKey(id);
    }
    @Override
    public List<BrandClass> listEffective() {
        return brandClassMapper.listEffective();
    }
    @Resource
    private BrandClassMapper brandClassMapper;
    @Override
    @Cacheable(value = "brandCache", key = "'listBrandClassEffectiveCache'")
    public List<BrandClass> listBrandClassEffectiveCache() {
        return brandClassMapper.listEffective();
    }
    @Resource
    private GoodsClassService goodsClassService;
    @Override
    public void saveObject(BrandClass record) throws BrandClassException, Exception{
        Long gcid = record.getGcid();
        if (gcid != null)
            record.setGoodsClass(new GoodsClass(gcid));
        String name = record.getName();
        if (name == null || name.trim().length() == 0)
            throw new BrandClassException(1, "名称和分类不能同时为空");
        Integer state = record.getState();
        if (state == null)
            record.setState(0);
        record.setUpdateTime(new Date());
        Long id = record.getId();
        if (id == null) {
            record.setOrderBy(brandClassMapper.getMaxOrder() + 1);
            record.setCreateTime(new Date());
            brandClassMapper.insert(record);
        } else {
            BrandClass resultObj = brandClassMapper.selectByPrimaryKey(id);
            if (resultObj == null)
                throw new BrandClassException(1, "修改内容已不存在");
            record.setOrderBy(resultObj.getOrderBy());
            record.setCreateTime(resultObj.getCreateTime());
            brandClassMapper.updateByPrimaryKey(record);
        }
    }
    @Override
    public void switchState(Long id) throws BrandClassException {
        if (id == null) {
            throw new BrandClassException(1, "请传递正确参数");
        }
        BrandClass resultObj = brandClassMapper.selectByPrimaryKey(id);
        if (resultObj == null) {
            throw new BrandClassException(1, "此内容已不存在");
        }
        Integer state = resultObj.getState();
        if (state == null || state == 0) {
            state = 1;
        } else {
            state = 0;
        }
        BrandClass updateObj = new BrandClass();
        updateObj.setId(id);
        updateObj.setState(state);
        brandClassMapper.updateByPrimaryKeySelective(updateObj);
    }
    @Override
    public void updateOrder(Long id, Integer moveType) throws BrandClassException, Exception{
        if (moveType == null || (!moveType.equals(1) && !moveType.equals(-1)))
            throw new BrandClassException(1, "传递的类型不正确");
        if (id == null)
            throw new BrandClassException(1, "ID不能为空");
        BrandClass resultObj = brandClassMapper.selectByPrimaryKey(id);
        if (resultObj == null)
            throw new BrandClassException(1, "操作数据已不存在");
        Integer oldOrder = resultObj.getOrderBy();
        BrandClass changeObj = brandClassMapper.getByAdjoinOrder(oldOrder, moveType);
        if (changeObj == null )
            throw new BrandClassException(1, "已经在最边缘,无可交换的位置");
        // 交换排序序号
        resultObj.setOrderBy(changeObj.getOrderBy());
        changeObj.setOrderBy(oldOrder);
        brandClassMapper.updateByPrimaryKeySelective(changeObj);
        brandClassMapper.updateByPrimaryKeySelective(resultObj);
    }
    @Override
    public int deleteBatchByPrimaryKey(List<Long> list) {
        return brandClassMapper.deleteBatchByPrimaryKey(list);
    }
    @Override
    public List<BrandClass> listQuery(long start, int count, String key, Integer state) {
        List<BrandClass> listQuery = brandClassMapper.listQuery(start, count, key, state);
        if (listQuery == null || listQuery.size() == 0) {
            return listQuery;
        }
        for (BrandClass brandClass : listQuery) {
            GoodsClass goodsClass = brandClass.getGoodsClass();
            if (goodsClass != null) {
                GoodsClass baseClass = goodsClassService.selectByPrimaryKey(goodsClass.getId());
                if(baseClass != null) {
                    brandClass.setGcid(goodsClass.getId());
                    brandClass.setGcName(baseClass.getName());
                }
            }
        }
        return listQuery;
    }
    @Resource
    private BrandClassSystemMapMapper brandClassSystemMapMapper;
    @Override
    public long countQuery(String key, Integer state) {
        return brandClassMapper.countQuery(key, state);
    }
    @Override
    public BrandClass selectByPrimaryKey(Long id) {
        return brandClassMapper.selectByPrimaryKey(id);
    }
    @Override
    public List<BrandClass> listEffective(SystemEnum system) {
        return brandClassMapper.listEffective(system);
    }
    @Override
    @Cacheable(value = "brandCache", key = "'listBrandClassEffectiveCache-'+#system")
    public List<BrandClass> listBrandClassEffectiveCache(SystemEnum system) {
        return listEffective(system);
    }
    @Override
    public void saveObject(BrandClass record, List<SystemEnum> systemList) throws BrandClassException, Exception {
        Long gcid = record.getGcid();
        if (gcid != null)
            record.setGoodsClass(new GoodsClass(gcid));
        String name = record.getName();
        if (name == null || name.trim().length() == 0)
            throw new BrandClassException(1, "名称和分类不能同时为空");
        Integer state = record.getState();
        if (state == null)
            record.setState(0);
        record.setUpdateTime(new Date());
        Long id = record.getId();
        if (id == null) {
            record.setOrderBy(brandClassMapper.getMaxOrder() + 1);
            record.setCreateTime(new Date());
            brandClassMapper.insert(record);
            //添加映射
            if (systemList != null)
                for (SystemEnum system : systemList) {
                    BrandClassSystemMap map=new BrandClassSystemMap();
                    map.setBrandClass(record);
                    map.setCreateTime(new Date());
                    map.setSystem(system);
                    brandClassSystemMapMapper.insertSelective(map);
                }
        } else {
            BrandClass resultObj = brandClassMapper.selectByPrimaryKey(id);
            if (resultObj == null)
                throw new BrandClassException(1, "修改内容已不存在");
            record.setOrderBy(resultObj.getOrderBy());
            record.setCreateTime(resultObj.getCreateTime());
            brandClassMapper.updateByPrimaryKey(record);
        }
    }
    @Override
    public void switchState(Long id) throws BrandClassException {
        if (id == null) {
            throw new BrandClassException(1, "请传递正确参数");
        }
        BrandClass resultObj = brandClassMapper.selectByPrimaryKey(id);
        if (resultObj == null) {
            throw new BrandClassException(1, "此内容已不存在");
        }
        Integer state = resultObj.getState();
        if (state == null || state == 0) {
            state = 1;
        } else {
            state = 0;
        }
        BrandClass updateObj = new BrandClass();
        updateObj.setId(id);
        updateObj.setState(state);
        brandClassMapper.updateByPrimaryKeySelective(updateObj);
    }
    @Override
    public void updateOrder(Long id, Integer moveType, SystemEnum system) throws BrandClassException, Exception {
        if (moveType == null || (!moveType.equals(1) && !moveType.equals(-1)))
            throw new BrandClassException(1, "传递的类型不正确");
        if (id == null)
            throw new BrandClassException(1, "ID不能为空");
        BrandClass resultObj = brandClassMapper.selectByPrimaryKey(id);
        if (resultObj == null)
            throw new BrandClassException(1, "操作数据已不存在");
        Integer oldOrder = resultObj.getOrderBy();
        BrandClass changeObj = brandClassMapper.getByAdjoinOrder(oldOrder, moveType);
        if (changeObj == null)
            throw new BrandClassException(1, "已经在最边缘,无可交换的位置");
        // 交换排序序号
        resultObj.setOrderBy(changeObj.getOrderBy());
        changeObj.setOrderBy(oldOrder);
        brandClassMapper.updateByPrimaryKeySelective(changeObj);
        brandClassMapper.updateByPrimaryKeySelective(resultObj);
    }
    @Override
    public int deleteBatchByPrimaryKey(List<Long> list) {
        return brandClassMapper.deleteBatchByPrimaryKey(list);
    }
    @Override
    public void deleteSystemMapBatch(List<Long> list, SystemEnum system) {
        List<BrandClassSystemMap> mapList = brandClassSystemMapMapper.listByClassIdsAndSystem(list, system);
        if (mapList != null) {
            for (BrandClassSystemMap map : mapList)
                brandClassSystemMapMapper.deleteByPrimaryKey(map.getId());
        }
    }
    @Override
    public List<BrandClass> listQuery(long start, int count, String key, Integer state, SystemEnum system) {
        List<BrandClass> listQuery = brandClassMapper.listQuery(start, count, key, state,system);
        if (listQuery == null || listQuery.size() == 0) {
            return listQuery;
        }
        for (BrandClass brandClass : listQuery) {
            GoodsClass goodsClass = brandClass.getGoodsClass();
            if (goodsClass != null) {
                GoodsClass baseClass = goodsClassService.selectByPrimaryKey(goodsClass.getId());
                if (baseClass != null) {
                    brandClass.setGcid(goodsClass.getId());
                    brandClass.setGcName(baseClass.getName());
                }
            }
        }
        return listQuery;
    }
    @Override
    public long countQuery(String key, Integer state, SystemEnum system) {
        return brandClassMapper.countQuery(key, state,system);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java
@@ -8,6 +8,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Service;
@@ -186,7 +187,7 @@
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    BrandInfo numInfo = brandGoodsCaheService.addBrandGoods(record);
                    BrandInfo numInfo = brandGoodsCaheService.addBrandGoods(record, SystemEnum.blks);
                    BrandInfo update = new BrandInfo();
                    update.setId(record.getId());
@@ -413,7 +414,7 @@
                if (StringUtil.isNullOrEmpty(name) && StringUtil.isNullOrEmpty(searchKey))
                    continue;
                // 添加商品
                BrandInfo numInfo = brandGoodsCaheService.addBrandGoods(brandInfo);
                BrandInfo numInfo = brandGoodsCaheService.addBrandGoods(brandInfo, SystemEnum.blks);
                BrandInfo updateInfo = new BrandInfo();
                updateInfo.setId(brandInfo.getId());
fanli/src/main/java/com/yeshi/fanli/service/impl/common/CommonConfigServiceImpl.java
New file
@@ -0,0 +1,30 @@
package com.yeshi.fanli.service.impl.common;
import com.yeshi.fanli.dao.mybatis.common.CommonConfigMapper;
import com.yeshi.fanli.entity.config.CommonConfig;
import com.yeshi.fanli.service.inter.common.CommonConfigService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class CommonConfigServiceImpl implements CommonConfigService {
    @Resource
    private CommonConfigMapper commonConfigMapper;
    @Override
    public String getValue(String key) {
        CommonConfig config = commonConfigMapper.selectByKey(key);
        if (config == null)
            return null;
        return config.getValue();
    }
    @Cacheable(value = "config", key = "'Common-getValue-'+#key")
    @Override
    public String getValueCache(String key) {
        return getValue(key);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
Diff too large
fanli/src/main/java/com/yeshi/fanli/service/impl/help/AppPageNotificationServiceImpl.java
@@ -8,6 +8,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -38,20 +39,20 @@
    private AdActivityVersionControlService adActivityVersionControlService;
    @Override
    public AppPageNotification getAppPageNotificationByType(String type) {
    public AppPageNotification getAppPageNotificationByType(String type, SystemEnum system) {
        return appPageNotificationMapper.selectByType(type);
        return appPageNotificationMapper.selectByType(type,system);
    }
    @Cacheable(value = "configCache", key = "'getValidNotificationByTypeCache-'+#type+'-'+ #platform+'-'+#versionCode")
    @Cacheable(value = "configCache", key = "'getValidNotificationByTypeCache-'+#type+'-'+ #platform+'-'+#versionCode+'-'+#system")
    @Override
    public AppPageNotification getValidNotificationByTypeCache(String type, String platform, Integer versionCode) {
        List<AppPageNotification> recordList = appPageNotificationMapper.listValidByType(type);
    public AppPageNotification getValidNotificationByTypeCache(String type, String platform, Integer versionCode, SystemEnum system) {
        List<AppPageNotification> recordList = appPageNotificationMapper.listValidByType(type,system);
        if (recordList == null || recordList.size() == 0)
            return null;
        // 过滤版本
        AppVersionInfo app = appVersionService.getClientVersion(platform, versionCode);
        AppVersionInfo app = appVersionService.getClientVersion(platform, versionCode,system);
        if (app == null) {
            return null;
        }
@@ -80,7 +81,7 @@
            return;
        if (apn.getType() == null)
            throw new Exception("类型为空");
        AppPageNotification old = getAppPageNotificationByType(apn.getType().name());
        AppPageNotification old = getAppPageNotificationByType(apn.getType().name(),apn.getSystem());
        if (old != null)
            throw new Exception("已存在改类型");
@@ -117,13 +118,13 @@
    }
    @Override
    public List<AppPageNotification> listQuery(long start, int count, String key, Integer show, Integer canClose) {
        return appPageNotificationMapper.listQuery(start, count, key, show, canClose);
    public List<AppPageNotification> listQuery(long start, int count, String key, Integer show, Integer canClose, SystemEnum system) {
        return appPageNotificationMapper.listQuery(start, count, key, show, canClose,system);
    }
    @Override
    public long countQuery(String key, Integer show, Integer canClose) {
        return appPageNotificationMapper.countQuery(key, show, canClose);
    public long countQuery(String key, Integer show, Integer canClose, SystemEnum system) {
        return appPageNotificationMapper.countQuery(key, show, canClose,system);
    }
    @Transactional(rollbackFor = Exception.class)
fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpCenterServiceImpl.java
@@ -11,6 +11,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -260,19 +261,19 @@
    }
    @Override
    public List<HelpCenter> query(int pageIndex, int pageSize, String key, Long cid, Integer orderMode, Integer state) {
        return helpCenterMapper.query(pageIndex, pageSize, key, cid, orderMode, state);
    public List<HelpCenter> query(int pageIndex, int pageSize, String key, Long cid, Integer orderMode, Integer state, SystemEnum system) {
        return helpCenterMapper.query(pageIndex, pageSize, key, cid, orderMode, state,system);
    }
    @Override
    public long countQuery(String key, Long cid, Integer state) {
        return helpCenterMapper.countQuery(key, cid, state);
    public long countQuery(String key, Long cid, Integer state, SystemEnum system) {
        return helpCenterMapper.countQuery(key, cid, state,system);
    }
    @Override
    @Cacheable(value = "helpCenterCache", key = "'queryIdAndTitle-'+#pageId+'-'+#key+'-'+#cid")
    public List<HelpCenter> listValid(long pageId, int pageSize, String key, Long cid) {
        return helpCenterMapper.listValid(pageId, pageSize, key, cid);
    @Cacheable(value = "helpCenterCache", key = "'queryIdAndTitle-'+#pageId+'-'+#key+'-'+#cid+'-'+#system")
    public List<HelpCenter> listValid(long pageId, int pageSize, String key, Long cid, SystemEnum system) {
        return helpCenterMapper.listValid(pageId, pageSize, key, cid,system);
    }
    @Override
fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpClassServiceImpl.java
@@ -12,6 +12,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@@ -174,7 +175,7 @@
    
    
    @Override
    public void updateSort(Integer moveType, Long id) throws HelpClassException {
    public void updateSort(Integer moveType, Long id, SystemEnum system) throws HelpClassException {
        
        if (id == null || moveType == null) {
            throw new HelpClassException(1, "传递参数不能为空");
@@ -185,7 +186,7 @@
            throw new HelpClassException(1, "更新数据已不存在");
        }
        
        HelpClass changeObjct = helpClassMapper.getChangeOrder(moveType, helpClass.getSort());
        HelpClass changeObjct = helpClassMapper.getChangeOrder(moveType, helpClass.getSort(),system);
        
        if (changeObjct == null) {
            throw new HelpClassException(1, "已经是最边缘位置");
@@ -237,24 +238,24 @@
    
    
    @Override
    public List<HelpClass> query(int start, int count, String key, Integer state)
    public List<HelpClass> query(int start, int count, String key, Integer state, SystemEnum system)
            throws HelpClassException {
        return helpClassMapper.listQuery(start, count, key, state);
        return helpClassMapper.listQuery(start, count, key, state,system);
    }
    @Override
    public long countQuery(String key, Integer state) {
        return helpClassMapper.countQuery(key, state);
    public long countQuery(String key, Integer state, SystemEnum system) {
        return helpClassMapper.countQuery(key, state,system);
    }
    
    @Override
    public List<HelpClass> getClassByState(Integer state) throws HelpClassException {
        return helpClassMapper.getClassByState(state);
    public List<HelpClass> getClassByState(Integer state, SystemEnum system) throws HelpClassException {
        return helpClassMapper.getClassByState(state,system);
    }
    
    @Override
    public List<HelpClass> getProvidedClass() throws HelpClassException {
        return helpClassMapper.getProvidedClass();
    public List<HelpClass> getProvidedClass(SystemEnum system) throws HelpClassException {
        return helpClassMapper.getProvidedClass(system);
    }
    
    
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/HomeNavbarServiceImpl.java
@@ -8,6 +8,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -187,7 +188,7 @@
    /**
     * 删除图片-不更新数据库
     * @param record
     * @param picture
     * @throws Exception
     */
    public void removePicture(String picture) throws Exception {
@@ -283,9 +284,9 @@
    
    @Override
    public List<HomeNavbar> listQuery(long start, int count, String key, Integer sex) {
    public List<HomeNavbar> listQuery(long start, int count, String key, Integer sex, SystemEnum system) {
        
        List<HomeNavbar> listObj = homeNavbarMapper.listQuery(start, count, key, sex);
        List<HomeNavbar> listObj = homeNavbarMapper.listQuery(start, count, key, sex,system);
        if (listObj == null || listObj.size() == 0) {
            return null;
        }
@@ -330,33 +331,33 @@
    }
    
    @Override
    public long countlistQuery(String key, Integer sex) {
        return homeNavbarMapper.countListQuery(key, sex);
    public long countlistQuery(String key, Integer sex, SystemEnum system) {
        return homeNavbarMapper.countListQuery(key, sex,system);
    }
    @Override
    @Cacheable(value = "configCache", key = "'listQueryEffectiveNavbar'")
    public List<HomeNavbar> listQueryEffectiveNavbar() {
        return homeNavbarMapper.listQueryEffective();
    public List<HomeNavbar> listQueryEffectiveNavbar(SystemEnum system) {
        return homeNavbarMapper.listQueryEffective(system);
    }
    
    
    @Override
    @Cacheable(value = "configCache", key = "'listQueryDefaultNavbar-'+#sex")
    public List<HomeNavbar> listQueryDefaultNavbar(Integer sex) {
        return homeNavbarMapper.listQueryDefaultNavbar(sex);
    public List<HomeNavbar> listQueryDefaultNavbar(Integer sex, SystemEnum system) {
        return homeNavbarMapper.listQueryDefaultNavbar(sex,system);
    }
    
    
    @Override
    @Cacheable(value = "configCache", key = "'listQueryFixedNavbar'")
    public List<HomeNavbar> listQueryFixedNavbar() {
        return homeNavbarMapper.listQueryFixedNavbar();
    public List<HomeNavbar> listQueryFixedNavbar(SystemEnum system) {
        return homeNavbarMapper.listQueryFixedNavbar(system);
    }
    @Override
    public HomeNavbar getEffectiveByClassId(Long classId) {
        return homeNavbarMapper.getEffectiveByClassId(classId);
    public HomeNavbar getEffectiveByClassId(Long classId, SystemEnum system) {
        return homeNavbarMapper.getEffectiveByClassId(classId,system);
    }
    
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/HomeNavbarUserServiceImpl.java
@@ -6,6 +6,8 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.mybatis.homemodule.HomeNavbarUserMapper;
@@ -22,246 +24,251 @@
@Service
public class HomeNavbarUserServiceImpl implements HomeNavbarUserService {
    @Resource
    private HomeNavbarUserMapper homeNavbarUserMapper;
    @Resource
    private HomeNavbarUserMapper homeNavbarUserMapper;
    @Resource
    private HomeNavbarService homeNavbarService;
    @Resource
    private HomeNavbarService homeNavbarService;
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @Override
    public List<HomeNavbar> listEffectiveNavbar(Long uid, String device, Integer sex) {
        List<HomeNavbar> list = new ArrayList<HomeNavbar>();
    @Resource
    private UserInfoService userInfoService;
        if (sex == null || sex == 0) {
            if (uid != null || !StringUtil.isNullOrEmpty(device)) {
                if (uid != null) {
                    device = null;
                }
                // 自定义导航
                List<HomeNavbarUser> listUserNavbar = homeNavbarUserMapper.listEffectiveNavbars(uid, device);
                if (listUserNavbar != null && listUserNavbar.size() > 0) {
                    // 固定导航
                    List<HomeNavbar> listFixed = homeNavbarService.listQueryFixedNavbar();
                    if (listFixed != null && listFixed.size() > 0) {
                        list.addAll(listFixed);
                    }
                    // 遍历用户自定义
                    for (HomeNavbarUser uomeNavbarUser : listUserNavbar) {
                        HomeNavbar homeNavbar = uomeNavbarUser.getHomeNavbar();
                        if (homeNavbar == null) {
                            continue;
                        }
                        // 是否是固定项
                        boolean notExist = true;
                        if (listFixed != null && listFixed.size() > 0) {
                            long id = homeNavbar.getId();
                            for (HomeNavbar fixedbar : listFixed) {
                                long fixedId = fixedbar.getId();
                                if (fixedId == id) {
                                    notExist = false;
                                    listFixed.remove(fixedbar);
                                    break;
                                }
                            }
                        }
    @Override
    public List<HomeNavbar> listEffectiveNavbar(Long uid, String device, Integer sex) {
        List<HomeNavbar> list = new ArrayList<HomeNavbar>();
                        if (notExist) {
                            list.add(homeNavbar);
                        }
                    }
                }
            }
            if (list.size() == 0) {
                List<HomeNavbar> listDefault = homeNavbarService.listQueryDefaultNavbar(sex);
                if (listDefault != null) {
                    list.addAll(listDefault);
                }
            }
        } else {
            List<HomeNavbar> listDefault = homeNavbarService.listQueryDefaultNavbar(sex);
            if (listDefault != null) {
                list.addAll(listDefault);
            }
        }
        return list;
    }
        SystemEnum system = userInfoService.getUserSystem(uid);
    @Override
    public List<HomeNavbarUser> listUserNavbar(Long uid, String device) throws HomeNavbarUserException {
        if (uid == null && StringUtil.isNullOrEmpty(device)) {
            throw new HomeNavbarUserException(1, "参数不正确");
        }
        if (sex == null || sex == 0) {
            if (uid != null || !StringUtil.isNullOrEmpty(device)) {
                if (uid != null) {
                    device = null;
                }
                // 自定义导航
                List<HomeNavbarUser> listUserNavbar = homeNavbarUserMapper.listEffectiveNavbars(uid, device);
        if (uid != null && !StringUtil.isNullOrEmpty(device)) {
            device = null;
        }
                if (listUserNavbar != null && listUserNavbar.size() > 0) {
                    // 固定导航
                    List<HomeNavbar> listFixed = homeNavbarService.listQueryFixedNavbar(system);
                    if (listFixed != null && listFixed.size() > 0) {
                        list.addAll(listFixed);
                    }
        return homeNavbarUserMapper.listEffectiveNavbars(uid, device);
    }
                    // 遍历用户自定义
                    for (HomeNavbarUser uomeNavbarUser : listUserNavbar) {
                        HomeNavbar homeNavbar = uomeNavbarUser.getHomeNavbar();
                        if (homeNavbar == null) {
                            continue;
                        }
    @Override
    public void addNavbarUser(Long uid, String device, List<Long> list) throws HomeNavbarUserException {
        if (uid == null && StringUtil.isNullOrEmpty(device)) {
            throw new HomeNavbarUserException(1, "参数不正确");
        }
                        // 是否是固定项
                        boolean notExist = true;
        if (list == null || list.size() < 6) {
            throw new HomeNavbarUserException(1, "至少保留6个分类");
        }
                        if (listFixed != null && listFixed.size() > 0) {
                            long id = homeNavbar.getId();
                            for (HomeNavbar fixedbar : listFixed) {
                                long fixedId = fixedbar.getId();
                                if (fixedId == id) {
                                    notExist = false;
                                    listFixed.remove(fixedbar);
                                    break;
                                }
                            }
                        }
        if (list.size() > 16) {
            throw new HomeNavbarUserException(1, "最多显示16个分类");
        }
                        if (notExist) {
                            list.add(homeNavbar);
                        }
                    }
                }
            }
        // 登录之后 以uid为准
        if (uid != null && !StringUtil.isNullOrEmpty(device)) {
            device = null;
        }
            if (list.size() == 0) {
                List<HomeNavbar> listDefault = homeNavbarService.listQueryDefaultNavbar(sex, system);
                if (listDefault != null) {
                    list.addAll(listDefault);
                }
            }
        } else {
            List<HomeNavbar> listDefault = homeNavbarService.listQueryDefaultNavbar(sex, system);
            if (listDefault != null) {
                list.addAll(listDefault);
            }
        }
        return list;
    }
        // 设置已同步
        UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
        if (userInfoExtra != null && !userInfoExtra.getSynchNavbar()) {
            try {
                UserInfoExtra updateExtra = new UserInfoExtra();
                updateExtra.setSynchNavbar(true);
                updateExtra.setId(userInfoExtra.getId());
                userInfoExtraService.saveUserInfoExtra(updateExtra);
            } catch (UserInfoExtraException e) {
                e.printStackTrace();
            }
        }
    @Override
    public List<HomeNavbarUser> listUserNavbar(Long uid, String device) throws HomeNavbarUserException {
        if (uid == null && StringUtil.isNullOrEmpty(device)) {
            throw new HomeNavbarUserException(1, "参数不正确");
        }
        List<HomeNavbarUser> listInsert = new ArrayList<HomeNavbarUser>();
        List<HomeNavbarUser> listUpdate = new ArrayList<HomeNavbarUser>();
        if (uid != null && !StringUtil.isNullOrEmpty(device)) {
            device = null;
        }
        // 之前已经定义的导航数据
        List<HomeNavbarUser> listMyNavbars = homeNavbarUserMapper.listMyNavbars(uid, device);
        return homeNavbarUserMapper.listEffectiveNavbars(uid, device);
    }
        for (int i = 0; i < list.size(); i++) {
            HomeNavbarUser navbarUser = null;
            if (list.get(i) == null) {
                i--;
                continue;
            }
            long homeId = list.get(i);
    @Override
    public void addNavbarUser(Long uid, String device, List<Long> list) throws HomeNavbarUserException {
        if (uid == null && StringUtil.isNullOrEmpty(device)) {
            throw new HomeNavbarUserException(1, "参数不正确");
        }
            if (listMyNavbars != null && listMyNavbars.size() > 0) {
                for (int j = 0; j < listMyNavbars.size(); j++) {
                    HomeNavbarUser homeNavbarUser = listMyNavbars.get(j);
                    HomeNavbar homeNavbar = homeNavbarUser.getHomeNavbar();
        if (list == null || list.size() < 6) {
            throw new HomeNavbarUserException(1, "至少保留6个分类");
        }
                    if (homeNavbar == null) {
                        listMyNavbars.remove(homeNavbarUser);
                        j--;
                        continue;
                    }
        if (list.size() > 16) {
            throw new HomeNavbarUserException(1, "最多显示16个分类");
        }
                    long id = homeNavbar.getId();
                    if (homeId == id) {
                        navbarUser = new HomeNavbarUser();
                        navbarUser.setId(homeNavbarUser.getId());
                        navbarUser.setOrder(homeNavbarUser.getOrder());
                        listMyNavbars.remove(homeNavbarUser);
                        break;
                    }
                }
            }
        // 登录之后 以uid为准
        if (uid != null && !StringUtil.isNullOrEmpty(device)) {
            device = null;
        }
            if (navbarUser != null) {
                Integer order = navbarUser.getOrder();
                if (order != null && i + 1 == order.intValue()) {
                    continue;
                }
                navbarUser.setOrder(i + 1);
                listUpdate.add(navbarUser);
            } else {
                navbarUser = new HomeNavbarUser();
                navbarUser.setOrder(i + 1);
                navbarUser.setUid(uid);
                navbarUser.setDevice(device);
                navbarUser.setHomeNavbar(new HomeNavbar(homeId));
                navbarUser.setCreateTime(new Date());
                listInsert.add(navbarUser);
            }
        }
        // 设置已同步
        UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
        if (userInfoExtra != null && !userInfoExtra.getSynchNavbar()) {
            try {
                UserInfoExtra updateExtra = new UserInfoExtra();
                updateExtra.setSynchNavbar(true);
                updateExtra.setId(userInfoExtra.getId());
                userInfoExtraService.saveUserInfoExtra(updateExtra);
            } catch (UserInfoExtraException e) {
                e.printStackTrace();
            }
        }
        // 更新
        if (listUpdate.size() > 0) {
            homeNavbarUserMapper.updateSelectiveBatch(listUpdate);
        }
        List<HomeNavbarUser> listInsert = new ArrayList<HomeNavbarUser>();
        List<HomeNavbarUser> listUpdate = new ArrayList<HomeNavbarUser>();
        // 新增
        if (listInsert.size() > 0) {
            homeNavbarUserMapper.insertBatch(listInsert);
        }
        // 之前已经定义的导航数据
        List<HomeNavbarUser> listMyNavbars = homeNavbarUserMapper.listMyNavbars(uid, device);
        // 删除
        if (listMyNavbars != null && listMyNavbars.size() > 0) {
            List<Long> listId = new ArrayList<Long>();
            for (HomeNavbarUser homeNavbarUser : listMyNavbars) {
                listId.add(homeNavbarUser.getId());
            }
            homeNavbarUserMapper.deleteByPrimaryKeyBatch(listId);
        }
    }
        for (int i = 0; i < list.size(); i++) {
            HomeNavbarUser navbarUser = null;
            if (list.get(i) == null) {
                i--;
                continue;
            }
            long homeId = list.get(i);
    @Override
    public List<HomeNavbar> restoreSystemDefault(Long uid, String device) throws HomeNavbarUserException {
        if (uid == null && StringUtil.isNullOrEmpty(device)) {
            throw new HomeNavbarUserException(1, "参数不正确");
        }
            if (listMyNavbars != null && listMyNavbars.size() > 0) {
                for (int j = 0; j < listMyNavbars.size(); j++) {
                    HomeNavbarUser homeNavbarUser = listMyNavbars.get(j);
                    HomeNavbar homeNavbar = homeNavbarUser.getHomeNavbar();
        // 删除用户自定义导航
        if (uid != null) {
            homeNavbarUserMapper.deleteByUid(uid);
        } else {
            homeNavbarUserMapper.deleteByDevice(device);
        }
        // 返回有效的
        return homeNavbarService.listQueryEffectiveNavbar();
    }
                    if (homeNavbar == null) {
                        listMyNavbars.remove(homeNavbarUser);
                        j--;
                        continue;
                    }
    @Override
    public void synchroDeviceToUser(Long uid, String device) {
        UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
        if (userInfoExtra == null) {
            userInfoExtra = new UserInfoExtra();
        } else if (userInfoExtra.getSynchNavbar()) {
            return;
        }
                    long id = homeNavbar.getId();
                    if (homeId == id) {
                        navbarUser = new HomeNavbarUser();
                        navbarUser.setId(homeNavbarUser.getId());
                        navbarUser.setOrder(homeNavbarUser.getOrder());
                        listMyNavbars.remove(homeNavbarUser);
                        break;
                    }
                }
            }
        List<HomeNavbarUser> listDevice = homeNavbarUserMapper.listMyNavbars(null, device);
        if (listDevice == null || listDevice.size() == 0) {
            return;
        }
            if (navbarUser != null) {
                Integer order = navbarUser.getOrder();
                if (order != null && i + 1 == order.intValue()) {
                    continue;
                }
                navbarUser.setOrder(i + 1);
                listUpdate.add(navbarUser);
            } else {
                navbarUser = new HomeNavbarUser();
                navbarUser.setOrder(i + 1);
                navbarUser.setUid(uid);
                navbarUser.setDevice(device);
                navbarUser.setHomeNavbar(new HomeNavbar(homeId));
                navbarUser.setCreateTime(new Date());
                listInsert.add(navbarUser);
            }
        }
        // 同步设备定义导航
        for (HomeNavbarUser homeNavbarUser : listDevice) {
            homeNavbarUser.setId(null);
            homeNavbarUser.setDevice(null);
            homeNavbarUser.setUid(uid);
            homeNavbarUser.setCreateTime(new Date());
        }
        homeNavbarUserMapper.insertBatch(listDevice);
        // 更新
        if (listUpdate.size() > 0) {
            homeNavbarUserMapper.updateSelectiveBatch(listUpdate);
        }
        // 已同步
        try {
            UserInfoExtra updateExtra = new UserInfoExtra();
            updateExtra.setSynchNavbar(true);
            updateExtra.setId(userInfoExtra.getId());
            userInfoExtraService.saveUserInfoExtra(updateExtra);
        } catch (UserInfoExtraException e) {
            e.printStackTrace();
        }
    }
        // 新增
        if (listInsert.size() > 0) {
            homeNavbarUserMapper.insertBatch(listInsert);
        }
        // 删除
        if (listMyNavbars != null && listMyNavbars.size() > 0) {
            List<Long> listId = new ArrayList<Long>();
            for (HomeNavbarUser homeNavbarUser : listMyNavbars) {
                listId.add(homeNavbarUser.getId());
            }
            homeNavbarUserMapper.deleteByPrimaryKeyBatch(listId);
        }
    }
    @Override
    public List<HomeNavbar> restoreSystemDefault(Long uid, String device,SystemEnum system) throws HomeNavbarUserException {
        if (uid == null && StringUtil.isNullOrEmpty(device)) {
            throw new HomeNavbarUserException(1, "参数不正确");
        }
        // 删除用户自定义导航
        if (uid != null) {
            homeNavbarUserMapper.deleteByUid(uid);
        } else {
            homeNavbarUserMapper.deleteByDevice(device);
        }
        // 返回有效的
        return homeNavbarService.listQueryEffectiveNavbar(system);
    }
    @Override
    public void synchroDeviceToUser(Long uid, String device) {
        UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
        if (userInfoExtra == null) {
            userInfoExtra = new UserInfoExtra();
        } else if (userInfoExtra.getSynchNavbar()) {
            return;
        }
        List<HomeNavbarUser> listDevice = homeNavbarUserMapper.listMyNavbars(null, device);
        if (listDevice == null || listDevice.size() == 0) {
            return;
        }
        // 同步设备定义导航
        for (HomeNavbarUser homeNavbarUser : listDevice) {
            homeNavbarUser.setId(null);
            homeNavbarUser.setDevice(null);
            homeNavbarUser.setUid(uid);
            homeNavbarUser.setCreateTime(new Date());
        }
        homeNavbarUserMapper.insertBatch(listDevice);
        // 已同步
        try {
            UserInfoExtra updateExtra = new UserInfoExtra();
            updateExtra.setSynchNavbar(true);
            updateExtra.setId(userInfoExtra.getId());
            userInfoExtraService.saveUserInfoExtra(updateExtra);
        } catch (UserInfoExtraException e) {
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SuperHomeNavbarServiceImpl.java
@@ -48,40 +48,6 @@
    public int updateByPrimaryKey(SuperHomeNavbar record) {
        return superHomeNavbarMapper.updateByPrimaryKey(record);
    }
    @Override
    public List<SuperHomeNavbar> listBySystem(Long systemId) {
        return superHomeNavbarMapper.listBySystem(systemId);
    }
    @Cacheable(value = "configCache", key = "'listBySystemCache-'+#systemId")
    @Override
    public List<SuperHomeNavbar> listBySystemCache(Long systemId) {
        return listBySystem(systemId);
    }
    @Override
    public List<SuperHomeNavbar> listByNavbarIds(List<Long> list) {
        return superHomeNavbarMapper.listByNavbarIds(list);
    }
    @Override
    public void deleteBatchByNavbarIds(List<Long> list) {
         superHomeNavbarMapper.deleteBatchByNavbarIds(list);
    }
    @Override
    public List<SuperHomeNavbar> querybyNavbarId(Long navbarId, Long systemId) {
        return superHomeNavbarMapper.querybyNavbarId(navbarId, systemId);
    }
    @Override
    public int deletebyNavbarId(Long navbarId, Long systemId) {
        return superHomeNavbarMapper.deletebyNavbarId(navbarId, systemId);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/money/msg/UserMoneyMsgNotificationServiceImpl.java
@@ -5,6 +5,8 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dto.push.PushContentDTO;
@@ -26,245 +28,258 @@
@Service
public class UserMoneyMsgNotificationServiceImpl implements UserMoneyMsgNotificationService {
    @Resource
    private MsgMoneyDetailService msgMoneyDetailService;
    @Resource
    private PushService pushService;
    @Resource
    private MsgMoneyDetailService msgMoneyDetailService;
    @Resource
    private PushService pushService;
    @Resource
    private MsgExtraService msgExtraService;
    @Resource
    private MsgExtraService msgExtraService;
    @Override
    public void extractApplay(Extract extract) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createExtractMsg("人工审核中", extract.getUserInfo().getId(), extract,
                null, null, "审核将会在24小时内完成");
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
    @Resource
    private UserInfoService userInfoService;
    @Override
    public void extractFail(Extract extract, String reason) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createExtractMsg("提现失败", extract.getUserInfo().getId(), extract,
                reason, null, "如有疑问请联系人工客服");
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void extractApplay(Extract extract) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createExtractMsg("人工审核中", extract.getUserInfo().getId(), extract,
                null, null, "审核将会在24小时内完成");
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void extractSuccess(Extract extract, String alipayNo) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createExtractMsg("提现成功", extract.getUserInfo().getId(), extract,
                null, alipayNo, "如有疑问请联系人工客服");
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
        PushContentDTO dto = PushMsgFactory.createMoneyExtractSuccess(new Date(extract.getExtractTime()),
                extract.getMoney(), extract.getAccount());
        try {
            pushService.pushZNX(extract.getUserInfo().getId(), dto.getTitle(), dto.getContent(), null, null);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (PushException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void extractFail(Extract extract, String reason) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createExtractMsg("提现失败", extract.getUserInfo().getId(), extract,
                reason, null, "如有疑问请联系人工客服");
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void alipayAccountValid(AlipayAccountValidNormalHistory history, String limitDay, boolean change) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createAlipayAccountValidMsg(history, history.getUid(),
                Constant.alipayConfig.getAccountName(), new BigDecimal("0.1"), limitDay, change);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void extractSuccess(Extract extract, String alipayNo) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createExtractMsg("提现成功", extract.getUserInfo().getId(), extract,
                null, alipayNo, "如有疑问请联系人工客服");
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    @Override
    public void alipayAccountValidFail(AlipayAccountValidNormalHistory history, int limitDay, boolean change) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createAlipayAccountValidFail(history, history.getUid(),
                Constant.systemCommonConfig.getProjectChineseName(), new BigDecimal("0.1"), limitDay, change);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
        SystemEnum system = userInfoService.getUserSystem(extract.getUserInfo().getId());
    @Override
    public void fanliOrderReceived(Long uid, String orderId, int orderType, int goodsCount, BigDecimal money,
            BigDecimal balance, Date downTime) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.fanLiOrderReceivedMsg(money, balance, orderId, orderType,
                goodsCount, uid, downTime, false);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
        PushContentDTO dto = PushMsgFactory.createMoneyExtractSuccess(new Date(extract.getExtractTime()),
                extract.getMoney(), extract.getAccount());
        try {
            pushService.pushZNX(extract.getUserInfo().getId(), dto.getTitle(), dto.getContent(), null, null,system);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (PushException e) {
            e.printStackTrace();
        }
    }
        PushContentDTO dto = PushMsgFactory.createMoneyFanliRecieved(orderType, orderId, money);
        try {
            pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (PushException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void alipayAccountValid(AlipayAccountValidNormalHistory history, String limitDay, boolean change) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createAlipayAccountValidMsg(history, history.getUid(),
                Constant.alipayConfig.getAccountName(), new BigDecimal("0.1"), limitDay, change);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void rewardCounponReceived(Long uid, String orderId, int orderType, int goodsCount, BigDecimal money,
            BigDecimal balance, Date downTime) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.fanLiOrderReceivedMsg(money, balance, orderId, orderType,
                goodsCount, uid, downTime, true);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    @Override
    public void alipayAccountValidFail(AlipayAccountValidNormalHistory history, int limitDay, boolean change) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createAlipayAccountValidFail(history, history.getUid(),
                Constant.systemCommonConfig.getProjectChineseName(), new BigDecimal("0.1"), limitDay, change);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
        PushContentDTO dto = PushMsgFactory.createMoneyFanliRecieved(orderType, orderId, money);
        try {
            pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (PushException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void fanliOrderReceived(Long uid, String orderId, int orderType, int goodsCount, BigDecimal money,
                                   BigDecimal balance, Date downTime) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.fanLiOrderReceivedMsg(money, balance, orderId, orderType,
                goodsCount, uid, downTime, false);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    @Override
    public void fanliOrderWeiQuan(Long uid, String orderId, int orderType, BigDecimal money, BigDecimal fanliMoney,
            int goodsCount, Date downTime) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createOrderWeiQuanMsg(uid, orderId, orderType, money, fanliMoney,
                goodsCount, downTime, Constant.TYPE_REBATE);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
        SystemEnum system = userInfoService.getUserSystem(uid);
    @Override
    public void shareOrderReceived(Long uid, int orderType, BigDecimal money, BigDecimal balance, Date receivedDate) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.shareOrderReceivedMsg(money, balance, orderType, uid,
                receivedDate);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
        PushContentDTO dto = PushMsgFactory.createMoneyFanliRecieved(orderType, orderId, money);
        try {
            pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null,system);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (PushException e) {
            e.printStackTrace();
        }
    }
        PushContentDTO dto = PushMsgFactory.createMoneyShareRecieved(orderType, money);
        try {
            pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (PushException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void rewardCounponReceived(Long uid, String orderId, int orderType, int goodsCount, BigDecimal money,
                                      BigDecimal balance, Date downTime) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.fanLiOrderReceivedMsg(money, balance, orderId, orderType,
                goodsCount, uid, downTime, true);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    @Override
    public void shareOrderWeiQuan(Long uid, String orderId, int orderType, BigDecimal money, BigDecimal fanliMoney,
            int goodsCount, Date downTime) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createOrderWeiQuanMsg(uid, orderId, orderType, money, fanliMoney,
                goodsCount, downTime, Constant.TYPE_SHAER);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
        SystemEnum system = userInfoService.getUserSystem(uid);
    @Override
    public void systemEqualize(Long uid, String reason, BigDecimal money, BigDecimal balance) {
        // MsgMoneyDetail detail =
        // MsgMoneyDetailFactory.createSystemEqualizeMsg(uid, reason, money,
        // balance, null);
        // try {
        // msgMoneyDetailService.addMsgMoneyDetail(detail);
        // } catch (MsgMoneyDetailException e) {
        // e.printStackTrace();
        // }
        //
        // PushContentDTO dto =
        // PushMsgFactory.createMoneySystemCompensate(reason, money);
        // try {
        // pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null,
        // null);
        // } catch (NumberFormatException e) {
        // e.printStackTrace();
        // } catch (PushException e) {
        // e.printStackTrace();
        // }
    }
        PushContentDTO dto = PushMsgFactory.createMoneyFanliRecieved(orderType, orderId, money);
        try {
            pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null,system);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (PushException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void redPackMsg(Long uid, MsgTypeMoneyTypeEnum type, String content, String beiZhu) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createRedPackMsg(uid, type, content, beiZhu);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void fanliOrderWeiQuan(Long uid, String orderId, int orderType, BigDecimal money, BigDecimal fanliMoney,
                                  int goodsCount, Date downTime) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createOrderWeiQuanMsg(uid, orderId, orderType, money, fanliMoney,
                goodsCount, downTime, Constant.TYPE_REBATE);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void teamRedPackRewardMsg(Long uid, MsgTypeMoneyTypeEnum type, BigDecimal money, String stateDesc,
            String content) {
        MsgMoneyDetail detail = new MsgMoneyDetail();
        detail.setRead(false);
        detail.setMoney(money);
        detail.setMsgType(type);
        detail.setContent(content);
        detail.setStateDesc(stateDesc);
        detail.setUser(new UserInfo(uid));
        detail.setBeiZhu("系统已下发到“我的-红包”中");
        detail.setCreateTime(new Date());
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void shareOrderReceived(Long uid, int orderType, BigDecimal money, BigDecimal balance, Date receivedDate) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.shareOrderReceivedMsg(money, balance, orderType, uid,
                receivedDate);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    @Override
    public void teamRewardReceive(Long uid, BigDecimal money, BigDecimal balance, Date receivedDate) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createTeamReceivedMsg(uid, money, balance, receivedDate, "团队奖金");
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
        SystemEnum system = userInfoService.getUserSystem(uid);
    @Override
    public void teamDividend(Long uid, BigDecimal money, BigDecimal balance, Date receivedDate) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createTeamReceivedMsg(uid, money, balance, receivedDate, "团队分红");
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
        PushContentDTO dto = PushMsgFactory.createMoneyShareRecieved(orderType, money);
        try {
            pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null,system);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (PushException e) {
            e.printStackTrace();
        }
    }
        // 推送消息
        PushContentDTO dto = PushMsgFactory.createMoneyTeamDividents(money);
        try {
            pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (PushException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void shareOrderWeiQuan(Long uid, String orderId, int orderType, BigDecimal money, BigDecimal fanliMoney,
                                  int goodsCount, Date downTime) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createOrderWeiQuanMsg(uid, orderId, orderType, money, fanliMoney,
                goodsCount, downTime, Constant.TYPE_SHAER);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void systemEqualize(Long uid, String reason, BigDecimal money, BigDecimal balance) {
        // MsgMoneyDetail detail =
        // MsgMoneyDetailFactory.createSystemEqualizeMsg(uid, reason, money,
        // balance, null);
        // try {
        // msgMoneyDetailService.addMsgMoneyDetail(detail);
        // } catch (MsgMoneyDetailException e) {
        // e.printStackTrace();
        // }
        //
        // PushContentDTO dto =
        // PushMsgFactory.createMoneySystemCompensate(reason, money);
        // try {
        // pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null,
        // null);
        // } catch (NumberFormatException e) {
        // e.printStackTrace();
        // } catch (PushException e) {
        // e.printStackTrace();
        // }
    }
    @Override
    public void redPackMsg(Long uid, MsgTypeMoneyTypeEnum type, String content, String beiZhu) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createRedPackMsg(uid, type, content, beiZhu);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void teamRedPackRewardMsg(Long uid, MsgTypeMoneyTypeEnum type, BigDecimal money, String stateDesc,
                                     String content) {
        MsgMoneyDetail detail = new MsgMoneyDetail();
        detail.setRead(false);
        detail.setMoney(money);
        detail.setMsgType(type);
        detail.setContent(content);
        detail.setStateDesc(stateDesc);
        detail.setUser(new UserInfo(uid));
        detail.setBeiZhu("系统已下发到“我的-红包”中");
        detail.setCreateTime(new Date());
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void teamRewardReceive(Long uid, BigDecimal money, BigDecimal balance, Date receivedDate) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createTeamReceivedMsg(uid, money, balance, receivedDate, "团队奖金");
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void teamDividend(Long uid, BigDecimal money, BigDecimal balance, Date receivedDate) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createTeamReceivedMsg(uid, money, balance, receivedDate, "团队分红");
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
        SystemEnum system = userInfoService.getUserSystem(uid);
        // 推送消息
        PushContentDTO dto = PushMsgFactory.createMoneyTeamDividents(money);
        try {
            pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null,system);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (PushException e) {
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/order/msg/UserOrderMsgNotificationServiceImpl.java
@@ -5,6 +5,8 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -22,143 +24,151 @@
@Service
public class UserOrderMsgNotificationServiceImpl implements UserOrderMsgNotificationService {
    @Resource
    private MsgOrderDetailService msgOrderDetailService;
    @Resource
    private MsgOrderDetailService msgOrderDetailService;
    @Resource
    private PushService pushService;
    @Resource
    private PushService pushService;
    @Override
    public void orderFanLiStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
            int goodsCount, int orderState, Date downTime) {
        // 是否通知
        boolean needNotify = (payMoney != null && payMoney.compareTo(new BigDecimal(0)) > 0) ? true : false;
        // 保存消息明细消息
        addOrderStatistics(uid, orderId, orderType, Constant.TYPE_REBATE, goodsCount, payMoney, money, downTime, null, needNotify);
        if (needNotify) {
            PushContentDTO dto = PushMsgFactory.createFanLiOrderStatisticed(orderType, orderId, money);
            try {
                pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
            } catch (NumberFormatException e) {
                e.printStackTrace();
            } catch (PushException e) {
                e.printStackTrace();
            }
        }
    }
    @Resource
    private UserInfoService userInfoService;
    @Override
    public void orderShareStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
            int goodsCount, int orderState, Date downTime) {
        // 是否通知
        boolean needNotify = (payMoney != null && payMoney.compareTo(new BigDecimal(0)) > 0) ? true : false;
        // 保存消息明细消息
        addOrderStatistics(uid, orderId, orderType, Constant.TYPE_SHAER, goodsCount, payMoney, money, downTime, null, needNotify);
    @Override
    public void orderFanLiStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
                                    int goodsCount, int orderState, Date downTime) {
        // 是否通知
        boolean needNotify = (payMoney != null && payMoney.compareTo(new BigDecimal(0)) > 0) ? true : false;
        // 保存消息明细消息
        addOrderStatistics(uid, orderId, orderType, Constant.TYPE_REBATE, goodsCount, payMoney, money, downTime, null, needNotify);
        PushContentDTO dto = PushMsgFactory.createShareOrderStatisticed(orderType, orderId, money);
        try {
            pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (PushException e) {
            e.printStackTrace();
        }
        SystemEnum system = userInfoService.getUserSystem(uid);
    }
        if (needNotify) {
            PushContentDTO dto = PushMsgFactory.createFanLiOrderStatisticed(orderType, orderId, money);
            try {
                pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null, system);
            } catch (NumberFormatException e) {
                e.printStackTrace();
            } catch (PushException e) {
                e.printStackTrace();
            }
        }
    }
    @Override
    public void orderInviteStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
            BigDecimal subsidy, int goodsCount, int orderState, Date downTime) {
        BigDecimal totalMoney = new BigDecimal(0);
        if (money != null) {
            totalMoney = totalMoney.add(money);
        }
        if (subsidy != null) {
            totalMoney = totalMoney.add(subsidy);
        }
        if (totalMoney.compareTo(new BigDecimal(0)) <= 0) {
            return;
        }
        // 保存消息明细消息
        addOrderStatistics(uid, orderId, orderType, Constant.TYPE_INVITE, goodsCount, payMoney, totalMoney, downTime, null, true);
    @Override
    public void orderShareStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
                                    int goodsCount, int orderState, Date downTime) {
        // 是否通知
        boolean needNotify = (payMoney != null && payMoney.compareTo(new BigDecimal(0)) > 0) ? true : false;
        // 保存消息明细消息
        addOrderStatistics(uid, orderId, orderType, Constant.TYPE_SHAER, goodsCount, payMoney, money, downTime, null, needNotify);
        PushContentDTO dto = PushMsgFactory.createInviteOrderStatisticed(orderType, orderId, money);
        try {
            pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (PushException e) {
            e.printStackTrace();
        }
    }
    /**
     * 创建订单被统计消息
     * @param uid
     * @param orderId 订单号
     * @param source  订单来源:淘宝、京东、天猫
     * @param type    订单类型:自购、分享、团队
     * @param goodsCount 商品数量
     * @param payMoney  付款金额
     * @param money     返利金额
     * @param downTime  下单时间
     * @param beiZhu 备注信息 - 非必填
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    private void addOrderStatistics(Long uid, String orderId, int source, int type, int goodsCount,
        BigDecimal payMoney, BigDecimal money, Date downTime, String beiZhu, boolean needNotify) {
        try {
            MsgOrderDetail detail = MsgOrderDetailFactory.createOrderStatistics(uid, orderId, source, type, goodsCount, payMoney, money, downTime, beiZhu);
            // 消息
            msgOrderDetailService.addMsgOrderDetail(detail, needNotify);
        } catch (MsgOrderDetailException e) {
            e.printStackTrace();
        }
    }
        SystemEnum system = userInfoService.getUserSystem(uid);
        PushContentDTO dto = PushMsgFactory.createShareOrderStatisticed(orderType, orderId, money);
        try {
            pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null, system);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (PushException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void orderInviteStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
                                     BigDecimal subsidy, int goodsCount, int orderState, Date downTime) {
        BigDecimal totalMoney = new BigDecimal(0);
        if (money != null) {
            totalMoney = totalMoney.add(money);
        }
        if (subsidy != null) {
            totalMoney = totalMoney.add(subsidy);
        }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void orderFoundSuccess(Long uid, String orderId, int orderSource, int type, BigDecimal payMoney, BigDecimal money, int goodsCount, Date submitTime) {
        try {
            MsgOrderDetail detail = MsgOrderDetailFactory.createOrderFoundSuccess(uid, orderId, orderSource, type, goodsCount, payMoney, money, submitTime, "");
            // 消息
            msgOrderDetailService.addMsgOrderDetail(detail, true);
        } catch (MsgOrderDetailException e) {
            e.printStackTrace();
        }
    }
        if (totalMoney.compareTo(new BigDecimal(0)) <= 0) {
            return;
        }
    @Override
    public void orderFoundFail(Long uid, String orderId) {
        try {
            MsgOrderDetail detail = MsgOrderDetailFactory.createOrderFoundFail(uid, orderId, "");
            // 消息
            msgOrderDetailService.addMsgOrderDetail(detail, true);
        } catch (MsgOrderDetailException e) {
            e.printStackTrace();
        }
    }
        SystemEnum system = userInfoService.getUserSystem(uid);
    @Override
    public void orderInvalidToBusinessRunning(Long uid, String orderId, int orderSource, int type) {
        try {
            MsgOrderDetail detail = MsgOrderDetailFactory.orderInvalidToBusinessRunning(uid, orderId, orderSource, type);
            // 消息
            msgOrderDetailService.addMsgOrderDetail(detail, true);
        } catch (MsgOrderDetailException e) {
            e.printStackTrace();
        }
    }
        // 保存消息明细消息
        addOrderStatistics(uid, orderId, orderType, Constant.TYPE_INVITE, goodsCount, payMoney, totalMoney, downTime, null, true);
        PushContentDTO dto = PushMsgFactory.createInviteOrderStatisticed(orderType, orderId, money);
        try {
            pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null, system);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (PushException e) {
            e.printStackTrace();
        }
    }
    /**
     * 创建订单被统计消息
     *
     * @param uid
     * @param orderId    订单号
     * @param source     订单来源:淘宝、京东、天猫
     * @param type       订单类型:自购、分享、团队
     * @param goodsCount 商品数量
     * @param payMoney   付款金额
     * @param money      返利金额
     * @param downTime   下单时间
     * @param beiZhu     备注信息 - 非必填
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    private void addOrderStatistics(Long uid, String orderId, int source, int type, int goodsCount,
                                    BigDecimal payMoney, BigDecimal money, Date downTime, String beiZhu, boolean needNotify) {
        try {
            MsgOrderDetail detail = MsgOrderDetailFactory.createOrderStatistics(uid, orderId, source, type, goodsCount, payMoney, money, downTime, beiZhu);
            // 消息
            msgOrderDetailService.addMsgOrderDetail(detail, needNotify);
        } catch (MsgOrderDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void orderFoundSuccess(Long uid, String orderId, int orderSource, int type, BigDecimal payMoney, BigDecimal money, int goodsCount, Date submitTime) {
        try {
            MsgOrderDetail detail = MsgOrderDetailFactory.createOrderFoundSuccess(uid, orderId, orderSource, type, goodsCount, payMoney, money, submitTime, "");
            // 消息
            msgOrderDetailService.addMsgOrderDetail(detail, true);
        } catch (MsgOrderDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void orderFoundFail(Long uid, String orderId) {
        try {
            MsgOrderDetail detail = MsgOrderDetailFactory.createOrderFoundFail(uid, orderId, "");
            // 消息
            msgOrderDetailService.addMsgOrderDetail(detail, true);
        } catch (MsgOrderDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void orderInvalidToBusinessRunning(Long uid, String orderId, int orderSource, int type) {
        try {
            MsgOrderDetail detail = MsgOrderDetailFactory.orderInvalidToBusinessRunning(uid, orderId, orderSource, type);
            // 消息
            msgOrderDetailService.addMsgOrderDetail(detail, true);
        } catch (MsgOrderDetailException e) {
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/push/HWPushServiceImpl.java
@@ -8,6 +8,8 @@
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;
@@ -28,212 +30,210 @@
@Service
public class HWPushServiceImpl implements HWPushService {
    @Resource
    private DeviceTokenHWService deviceTokenHWService;
    @Resource
    private DeviceTokenHWService deviceTokenHWService;
    @Resource
    private AppVersionService appVersionService;
    @Resource
    private AppVersionService appVersionService;
    @Resource
    private UserCustomSettingsService userCustomSettingsService;
    @Resource
    private UserCustomSettingsService userCustomSettingsService;
    private List<Integer> getVersionCodeList(List<Integer> versionCodeList) {
        List<Integer> versionList = new ArrayList<>();
        if (versionCodeList == null) {// 全推
            List<AppVersionInfo> appInfoList = appVersionService.listByPlatformAndMinVersionCode("android", 46);
            if (appInfoList != null)
                for (AppVersionInfo version : appInfoList) {
                    versionList.add(version.getVersionCode());
                }
    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);
            if (appInfoList != null)
                for (AppVersionInfo version : appInfoList) {
                    versionList.add(version.getVersionCode());
                }
        } else {// 按版本推送
            for (Integer versionCode : versionCodeList) {
                if (versionCode.intValue() >= 46) {
                    versionList.add(versionCode);
                }
            }
        }
        return versionList;
    }
        } else {// 按版本推送
            for (Integer versionCode : versionCodeList) {
                if (versionCode.intValue() >= 46) {
                    versionList.add(versionCode);
                }
            }
        }
        return versionList;
    }
    @Async("pushExecutor")
    @Override
    public void pushGoods(Long uid, Long auctionId, String title, String content, List<Integer> versionCodeList)
            throws PushException {
        push(PushTypeEnum.goodsdetail, uid, title, content, null, null, auctionId, versionCodeList);
    }
    @Async("pushExecutor")
    @Override
    public void pushGoods(Long uid, Long auctionId, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.goodsdetail, uid, null, null, auctionId, baseContent);
    }
    @Async("pushExecutor")
    @Override
    public void pushUrl(Long uid, String url, String title, String content, List<Integer> versionCodeList)
            throws PushException {
        push(PushTypeEnum.url, uid, title, content, null, url, null, versionCodeList);
    }
    @Async("pushExecutor")
    @Override
    public void pushUrl(Long uid, String url, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.url, uid, null, url, null, baseContent);
    }
    @Async("pushExecutor")
    @Override
    public void pushZNX(Long uid, String title, String content, List<Integer> versionCodeList) throws PushException {
        push(PushTypeEnum.ZNX, uid, title, content, null, null, null, versionCodeList);
    }
    @Async("pushExecutor")
    @Override
    public void pushZNX(Long uid, PushBaseContent baseContent) throws PushException {
        push(PushTypeEnum.ZNX, uid, null, null, null, baseContent);
    }
    @Async("pushExecutor")
    @Override
    public void pushWEEX(Long uid, String title, String content, String weexUrl, List<Integer> versionCodeList)
            throws PushException {
        push(PushTypeEnum.weex, uid, title, content, weexUrl, null, null, versionCodeList);
    }
    @Async("pushExecutor")
    @Override
    public void pushWEEX(Long uid, String weexUrl, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.weex, uid, weexUrl, null, null, baseContent);
    }
    @Async("pushExecutor")
    @Override
    public void pushBaiChuanUrl(Long uid, String title, String content, String url, List<Integer> versionCodeList)
            throws PushException {
    @Async("pushExecutor")
    @Override
    public void pushBaiChuanUrl(Long uid, String url, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.baichuan, uid, title, content, null, url, null, versionCodeList);
    }
        push(PushTypeEnum.baichuan, uid, null, url, null, baseContent);
    }
    @Async("pushExecutor")
    @Override
    public void pushWelfareCenter(Long uid, String title, String content, List<Integer> versionCodeList)
            throws PushException {
        push(PushTypeEnum.welfare, uid, title, content, null, null, null, versionCodeList);
    }
    @Async("pushExecutor")
    @Override
    public void pushWelfareCenter(Long uid, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.welfare, uid, null, null, null, baseContent);
    }
    @Override
    public void pushUserSignInNotification(Long uid, String title, String content, List<Integer> versionCodeList)
            throws PushException {
        push(PushTypeEnum.signin, uid, title, content, null, null, null, versionCodeList);
    }
    @Override
    public void pushUserSignInNotification(Long uid, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.signin, uid, null, null, null, baseContent);
    }
    private List<DeviceTokenHW> filterDeviceToken(List<DeviceTokenHW> hwDeviceList, int hour) {
        // TODO 暂时不处理消息免打扰
        if (1 > 0)
            return hwDeviceList;
        // 处理消息免打扰
        if (hour >= 20 || hour < 8) {
            Set<Long> uidSets = new HashSet<>();
            for (DeviceTokenHW dt : hwDeviceList)
                if (dt.getUser() != null)
                    uidSets.add(dt.getUser().getId());
            List<Long> uidList = new ArrayList<>();
            uidList.addAll(uidSets);
            List<UserCustomSettings> settingList = userCustomSettingsService.listByUidListAndTypeAndState(uidList,
                    UserSettingTypeEnum.cancelNotice.name(), UserCustomSettings.STATE_VALID);
            uidSets.clear();
            if (settingList != null) {
                for (UserCustomSettings seeting : settingList)
                    uidSets.add(seeting.getUserInfo().getId());
            }
            if (uidSets.size() > 0)
                for (int i = 0; i < hwDeviceList.size(); i++) {
                    if (hwDeviceList.get(i).getUser() != null
                            && uidSets.contains(hwDeviceList.get(i).getUser().getId())) {
                        hwDeviceList.remove(i--);
                    }
                }
        }
        return hwDeviceList;
    }
    private List<DeviceTokenHW> filterDeviceToken(List<DeviceTokenHW> hwDeviceList, int hour) {
        // TODO 暂时不处理消息免打扰
        if (1 > 0)
            return hwDeviceList;
        // 处理消息免打扰
        if (hour >= 20 || hour < 8) {
            Set<Long> uidSets = new HashSet<>();
            for (DeviceTokenHW dt : hwDeviceList)
                if (dt.getUser() != null)
                    uidSets.add(dt.getUser().getId());
            List<Long> uidList = new ArrayList<>();
            uidList.addAll(uidSets);
            List<UserCustomSettings> settingList = userCustomSettingsService.listByUidListAndTypeAndState(uidList,
                    UserSettingTypeEnum.cancelNotice.name(), UserCustomSettings.STATE_VALID);
            uidSets.clear();
            if (settingList != null) {
                for (UserCustomSettings seeting : settingList)
                    uidSets.add(seeting.getUserInfo().getId());
            }
            if (uidSets.size() > 0)
                for (int i = 0; i < hwDeviceList.size(); i++) {
                    if (hwDeviceList.get(i).getUser() != null
                            && uidSets.contains(hwDeviceList.get(i).getUser().getId())) {
                        hwDeviceList.remove(i--);
                    }
                }
        }
        return hwDeviceList;
    }
    /**
     * 推送
     *
     * @param type
     * @param uid
     * @param title
     * @param content
     * @param url
     * @param webUrl
     * @param versionCodeList
     */
    private void push(PushTypeEnum type, Long uid, String title, String content, String url, String webUrl,
            Long goodsId, List<Integer> versionCodeList) throws PushException {
        int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
        List<Integer> newVersionList = getVersionCodeList(versionCodeList);
        // 1.6.5后开始推送
        for (int i = 0; i < newVersionList.size(); i++) {
            if (newVersionList.get(i) < 47)
                newVersionList.remove(i--);
        }
    /**
     * 推送
     *
     * @param type
     * @param uid
     * @param content
     * @param url
     * @param webUrl
     */
    private void push(PushTypeEnum type, Long uid, String url, String webUrl,
                      Long goodsId, PushBaseContent content) throws PushException {
        int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
        List<Integer> newVersionList = getVersionCodeList(content.getVersionCodeList(),content.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);
            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);
                hwDeviceList = filterDeviceToken(hwDeviceList, hour);
        if (uid == null || uid == 0) {
            long deviceCount = deviceTokenHWService.countDeviceToken(newVersionList);
            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);
                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)
                            throw new PushException(2, "参数不完整");
                        HWPushUtil.pushGoods(tokenList, title, content, 1, goodsId);
                    } else if (type == PushTypeEnum.url) {// 链接
                        if (StringUtil.isNullOrEmpty(webUrl))
                            throw new PushException(2, "参数不完整");
                        HWPushUtil.pushUrl(tokenList, title, content, webUrl);
                    } else if (type == PushTypeEnum.ZNX) {// 站内信
                        HWPushUtil.pushZNX(tokenList, title, content);
                    } else if (type == PushTypeEnum.weex) {// weex
                        if (StringUtil.isNullOrEmpty(url))
                            throw new PushException(2, "参数不完整");
                        HWPushUtil.pushWEEX(tokenList, title, content, url);
                    } else if (type == PushTypeEnum.baichuan) {// 百川链接
                        if (StringUtil.isNullOrEmpty(webUrl))
                            throw new PushException(2, "参数不完整");
                        HWPushUtil.pushBaiChuanUrl(tokenList, title, content, webUrl);
                    } else if (type == PushTypeEnum.welfare) {// 福利中心
                        HWPushUtil.pushWelfareCenter(tokenList, title, content);
                    } else if (type == PushTypeEnum.signin) {// 签到
                        HWPushUtil.pushUserSignInNotification(tokenList, title, content);
                    }
                } catch (Exception e) {
                    PushLogHelper.hwError(e);
                }
                List<String> tokenList = new ArrayList<>();
                for (DeviceTokenHW token : hwDeviceList)
                    tokenList.add(token.getDeviceToken());
                try {
                    if (type == PushTypeEnum.goodsdetail) {// 商品详情
                        if (goodsId == null)
                            throw new PushException(2, "参数不完整");
                        HWPushUtil.pushGoods(tokenList, content.getTitle(), content.getContent(), 1, goodsId);
                    } else if (type == PushTypeEnum.url) {// 链接
                        if (StringUtil.isNullOrEmpty(webUrl))
                            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))
                            throw new PushException(2, "参数不完整");
                        HWPushUtil.pushWEEX(tokenList, content.getTitle(), content.getContent(), url);
                    } else if (type == PushTypeEnum.baichuan) {// 百川链接
                        if (StringUtil.isNullOrEmpty(webUrl))
                            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());
                    }
                } catch (Exception e) {
                    PushLogHelper.hwError(e);
                }
            }
        } else {
            // 华为单推
            List<DeviceTokenHW> hwDeviceList = deviceTokenHWService.getDeviceTokenByUid(uid, newVersionList);
            List<String> tokenList = new ArrayList<>();
            if (hwDeviceList != null) {
                hwDeviceList = filterDeviceToken(hwDeviceList, hour);
                for (DeviceTokenHW token : hwDeviceList)
                    tokenList.add(token.getDeviceToken());
            }
            if (tokenList.size() == 0)
                return;
            }
        } else {
            // 华为单推
            List<DeviceTokenHW> hwDeviceList = deviceTokenHWService.getDeviceTokenByUid(uid, newVersionList);
            List<String> tokenList = new ArrayList<>();
            if (hwDeviceList != null) {
                hwDeviceList = filterDeviceToken(hwDeviceList, hour);
                for (DeviceTokenHW token : hwDeviceList)
                    tokenList.add(token.getDeviceToken());
            }
            if (tokenList.size() == 0)
                return;
            try {
                if (type == PushTypeEnum.goodsdetail) {// 商品详情
                    if (goodsId == null)
                        throw new PushException(2, "参数不完整");
                    HWPushUtil.pushGoods(tokenList, title, content, 1, goodsId);
                } else if (type == PushTypeEnum.url) {// 链接
                    if (StringUtil.isNullOrEmpty(webUrl))
                        throw new PushException(2, "参数不完整");
                    HWPushUtil.pushUrl(tokenList, title, content, webUrl);
                } else if (type == PushTypeEnum.ZNX) {// 站内信
                    HWPushUtil.pushZNX(tokenList, title, content);
                } else if (type == PushTypeEnum.weex) {// weex
                    if (StringUtil.isNullOrEmpty(url))
                        throw new PushException(2, "参数不完整");
                    HWPushUtil.pushWEEX(tokenList, title, content, url);
                } else if (type == PushTypeEnum.baichuan) {// 百川链接
                    if (StringUtil.isNullOrEmpty(webUrl))
                        throw new PushException(2, "参数不完整");
                    HWPushUtil.pushBaiChuanUrl(tokenList, title, content, webUrl);
                } else if (type == PushTypeEnum.welfare) {// 福利中心
                    HWPushUtil.pushWelfareCenter(tokenList, title, content);
                } else if (type == PushTypeEnum.signin) {// 签到
                    HWPushUtil.pushUserSignInNotification(tokenList, title, content);
                }
            } catch (Exception e) {
                PushLogHelper.hwError(e);
            }
            try {
                if (type == PushTypeEnum.goodsdetail) {// 商品详情
                    if (goodsId == null)
                        throw new PushException(2, "参数不完整");
                    HWPushUtil.pushGoods(tokenList, content.getTitle(), content.getContent(), 1, goodsId);
                } else if (type == PushTypeEnum.url) {// 链接
                    if (StringUtil.isNullOrEmpty(webUrl))
                        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))
                        throw new PushException(2, "参数不完整");
                    HWPushUtil.pushWEEX(tokenList, content.getTitle(), content.getContent(), url);
                } else if (type == PushTypeEnum.baichuan) {// 百川链接
                    if (StringUtil.isNullOrEmpty(webUrl))
                        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());
                }
            } catch (Exception e) {
                PushLogHelper.hwError(e);
            }
        }
    }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/push/OPPOPushServiceImpl.java
@@ -8,6 +8,8 @@
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;
@@ -37,10 +39,10 @@
    @Resource
    private UserCustomSettingsService userCustomSettingsService;
    private List<Integer> getVersionCodeList(List<Integer> versionCodeList) {
    private List<Integer> getVersionCodeList(List<Integer> versionCodeList,SystemEnum system) {
        List<Integer> versionList = new ArrayList<>();
        if (versionCodeList == null) {// 全推
            List<AppVersionInfo> appInfoList = appVersionService.listByPlatformAndMinVersionCode("android", 51);
            List<AppVersionInfo> appInfoList = appVersionService.listByPlatformAndMinVersionCode("android", 51,system);
            if (appInfoList != null)
                for (AppVersionInfo version : appInfoList) {
                    versionList.add(version.getVersionCode());
@@ -58,50 +60,49 @@
    @Async("pushExecutor")
    @Override
    public void pushGoods(Long uid, Long auctionId, String title, String content, List<Integer> versionCodeList)
    public void pushGoods(Long uid, Long auctionId, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.goodsdetail, uid, title, content, null, null, auctionId, versionCodeList);
        push(PushTypeEnum.goodsdetail, uid, null, null, auctionId, baseContent);
    }
    @Async("pushExecutor")
    @Override
    public void pushUrl(Long uid, String url, String title, String content, List<Integer> versionCodeList)
    public void pushUrl(Long uid, String url,  PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.url, uid, title, content, null, url, null, versionCodeList);
        push(PushTypeEnum.url, uid, null, url, null, baseContent);
    }
    @Async("pushExecutor")
    @Override
    public void pushZNX(Long uid, String title, String content, List<Integer> versionCodeList) throws PushException {
        push(PushTypeEnum.ZNX, uid, title, content, null, null, null, versionCodeList);
    public void pushZNX(Long uid,  PushBaseContent baseContent) throws PushException {
        push(PushTypeEnum.ZNX, uid,  null, null, null, baseContent);
    }
    @Async("pushExecutor")
    @Override
    public void pushWEEX(Long uid, String title, String content, String weexUrl, List<Integer> versionCodeList)
    public void pushWEEX(Long uid,String weexUrl, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.weex, uid, title, content, weexUrl, null, null, versionCodeList);
        push(PushTypeEnum.weex, uid,  weexUrl, null, null, baseContent);
    }
    @Async("pushExecutor")
    @Override
    public void pushBaiChuanUrl(Long uid, String title, String content, String url, List<Integer> versionCodeList)
    public void pushBaiChuanUrl(Long uid,String url, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.baichuan, uid, title, content, null, url, null, versionCodeList);
        push(PushTypeEnum.baichuan, uid, null, url, null, baseContent);
    }
    @Async("pushExecutor")
    @Override
    public void pushWelfareCenter(Long uid, String title, String content, List<Integer> versionCodeList)
    public void pushWelfareCenter(Long uid, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.welfare, uid, title, content, null, null, null, versionCodeList);
        push(PushTypeEnum.welfare, uid, null, null, null, baseContent);
    }
    @Override
    public void pushUserSignInNotification(Long uid, String title, String content, List<Integer> versionCodeList)
    public void pushUserSignInNotification(Long uid, PushBaseContent baseContent)
            throws PushException {
        push(PushTypeEnum.signin, uid, title, content, null, null, null, versionCodeList);
        push(PushTypeEnum.signin, uid,  null, null, null, baseContent);
    }
    private List<DeviceTokenOPPO> filterDeviceToken(List<DeviceTokenOPPO> deviceList, int hour) {
@@ -140,16 +141,14 @@
     * 
     * @param type
     * @param uid
     * @param title
     * @param content
     * @param url
     * @param webUrl
     * @param versionCodeList
     */
    private void push(PushTypeEnum type, Long uid, String title, String content, String url, String webUrl,
            Long goodsId, List<Integer> versionCodeList) throws PushException {
    private void push(PushTypeEnum type, Long uid, String url, String webUrl,
                      Long goodsId,PushBaseContent content) throws PushException {
        int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
        List<Integer> newVersionList = getVersionCodeList(versionCodeList);
        List<Integer> newVersionList = getVersionCodeList(content.getVersionCodeList(),content.getSystem());
        // 1.6.5后开始推送
        for (int i = 0; i < newVersionList.size(); i++) {
            if (newVersionList.get(i) < 47)
@@ -171,25 +170,25 @@
                    if (type == PushTypeEnum.goodsdetail) {// 商品详情
                        if (goodsId == null)
                            throw new PushException(2, "参数不完整");
                        OPPOPushUtil.pushGoods(tokenList, title, content, 1, goodsId);
                        OPPOPushUtil.pushGoods(tokenList, content.getTitle(), content.getContent(), 1, goodsId);
                    } else if (type == PushTypeEnum.url) {// 链接
                        if (StringUtil.isNullOrEmpty(webUrl))
                            throw new PushException(2, "参数不完整");
                        OPPOPushUtil.pushUrl(tokenList, title, content, webUrl);
                        OPPOPushUtil.pushUrl(tokenList, content.getTitle(), content.getContent(), webUrl);
                    } else if (type == PushTypeEnum.ZNX) {// 站内信
                        OPPOPushUtil.pushZNX(tokenList, title, content);
                        OPPOPushUtil.pushZNX(tokenList, content.getTitle(), content.getContent());
                    } else if (type == PushTypeEnum.weex) {// weex
                        if (StringUtil.isNullOrEmpty(url))
                            throw new PushException(2, "参数不完整");
                        OPPOPushUtil.pushWEEX(tokenList, title, content, url);
                        OPPOPushUtil.pushWEEX(tokenList,content.getTitle(), content.getContent(), url);
                    } else if (type == PushTypeEnum.baichuan) {// 百川链接
                        if (StringUtil.isNullOrEmpty(webUrl))
                            throw new PushException(2, "参数不完整");
                        OPPOPushUtil.pushBaiChuanUrl(tokenList, title, content, webUrl);
                        OPPOPushUtil.pushBaiChuanUrl(tokenList,content.getTitle(), content.getContent(), webUrl);
                    } else if (type == PushTypeEnum.welfare) {// 福利中心
                        OPPOPushUtil.pushWelfareCenter(tokenList, title, content);
                        OPPOPushUtil.pushWelfareCenter(tokenList,content.getTitle(), content.getContent());
                    } else if (type == PushTypeEnum.signin) {// 签到
                        OPPOPushUtil.pushUserSignInNotification(tokenList, title, content);
                        OPPOPushUtil.pushUserSignInNotification(tokenList, content.getTitle(), content.getContent());
                    }
                } catch (Exception e) {
                    PushLogHelper.hwError(e);
@@ -212,25 +211,25 @@
                if (type == PushTypeEnum.goodsdetail) {// 商品详情
                    if (goodsId == null)
                        throw new PushException(2, "参数不完整");
                    OPPOPushUtil.pushGoods(tokenList, title, content, 1, goodsId);
                    OPPOPushUtil.pushGoods(tokenList, content.getTitle(), content.getContent(), 1, goodsId);
                } else if (type == PushTypeEnum.url) {// 链接
                    if (StringUtil.isNullOrEmpty(webUrl))
                        throw new PushException(2, "参数不完整");
                    OPPOPushUtil.pushUrl(tokenList, title, content, webUrl);
                    OPPOPushUtil.pushUrl(tokenList, content.getTitle(), content.getContent(), webUrl);
                } else if (type == PushTypeEnum.ZNX) {// 站内信
                    OPPOPushUtil.pushZNX(tokenList, title, content);
                    OPPOPushUtil.pushZNX(tokenList, content.getTitle(), content.getContent());
                } else if (type == PushTypeEnum.weex) {// weex
                    if (StringUtil.isNullOrEmpty(url))
                        throw new PushException(2, "参数不完整");
                    OPPOPushUtil.pushWEEX(tokenList, title, content, url);
                    OPPOPushUtil.pushWEEX(tokenList, content.getTitle(), content.getContent(), url);
                } else if (type == PushTypeEnum.baichuan) {// 百川链接
                    if (StringUtil.isNullOrEmpty(webUrl))
                        throw new PushException(2, "参数不完整");
                    OPPOPushUtil.pushBaiChuanUrl(tokenList, title, content, webUrl);
                    OPPOPushUtil.pushBaiChuanUrl(tokenList, content.getTitle(), content.getContent(), webUrl);
                } else if (type == PushTypeEnum.welfare) {// 福利中心
                    OPPOPushUtil.pushWelfareCenter(tokenList, title, content);
                    OPPOPushUtil.pushWelfareCenter(tokenList, content.getTitle(), content.getContent());
                } else if (type == PushTypeEnum.signin) {// 签到
                    OPPOPushUtil.pushUserSignInNotification(tokenList, title, content);
                    OPPOPushUtil.pushUserSignInNotification(tokenList, content.getTitle(), content.getContent());
                }
            } catch (Exception e) {
                PushLogHelper.oppoError(e);
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushCouponServiceImpl.java
@@ -7,6 +7,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -28,111 +29,105 @@
@Service
public class PushCouponServiceImpl implements PushCouponService {
    @Resource
    private PushService pushService;
    @Resource
    private PushService pushService;
    @Resource
    private ConfigService configService;
    @Resource
    private PushCouponMapper pushCouponMapper;
    @Resource
    private PushCouponMapper pushCouponMapper;
    @Resource
    private PushCouponRecordService pushCouponRecordService;
    @Resource
    private UserSystemCouponService userSystemCouponService;
    @Override
    public int deleteByPrimaryKey(Long id) {
        return pushCouponMapper.deleteByPrimaryKey(id);
    }
    @Resource
    private PushCouponRecordService pushCouponRecordService;
    @Override
    public int insert(PushCoupon record) {
        return pushCouponMapper.insert(record);
    }
    @Override
    public int deleteByPrimaryKey(Long id) {
        return pushCouponMapper.deleteByPrimaryKey(id);
    }
    @Override
    public int insertSelective(PushCoupon record) {
        return pushCouponMapper.insertSelective(record);
    }
    @Override
    public int insert(PushCoupon record) {
        return pushCouponMapper.insert(record);
    }
    @Override
    public PushCoupon selectByPrimaryKey(Long id) {
        return pushCouponMapper.selectByPrimaryKey(id);
    }
    @Override
    public int insertSelective(PushCoupon record) {
        return pushCouponMapper.insertSelective(record);
    }
    @Override
    public int updateByPrimaryKeySelective(PushCoupon record) {
        return pushCouponMapper.updateByPrimaryKeySelective(record);
    }
    @Override
    public PushCoupon selectByPrimaryKey(Long id) {
        return pushCouponMapper.selectByPrimaryKey(id);
    }
    @Override
    public int updateByPrimaryKey(PushCoupon record) {
        return pushCouponMapper.updateByPrimaryKey(record);
    }
    @Override
    public int updateByPrimaryKeySelective(PushCoupon record) {
        return pushCouponMapper.updateByPrimaryKeySelective(record);
    }
    @Override
    public int updateByPrimaryKey(PushCoupon record) {
        return pushCouponMapper.updateByPrimaryKey(record);
    }
    @Override
    public List<PushCoupon> listQuery(long start, int count, String key, Integer state) {
        return pushCouponMapper.listQuery(start, count, key, state);
    }
    @Override
    public List<PushCoupon> listQuery(long start, int count, String key, Integer state, SystemEnum system) {
        return pushCouponMapper.listQuery(start, count, key, state, system);
    }
    @Override
    public long countQuery(String key, Integer state) {
        return pushCouponMapper.countQuery(key, state);
    }
    @Override
    public long countQuery(String key, Integer state, SystemEnum system) {
        return pushCouponMapper.countQuery(key, state, system);
    }
    @Override
    @Transactional(rollbackFor=Exception.class)
    public void save(PushCoupon record) throws PushCouponException,Exception {
        if (record == null) {
            throw new PushCouponException(1, "参数不正确");
        }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void save(PushCoupon record) throws PushCouponException, Exception {
        if (record == null) {
            throw new PushCouponException(1, "参数不正确");
        }
        String uids = record.getUids();
        if (StringUtil.isNullOrEmpty(uids)) {
            throw new PushCouponException(1, "发放用户不能为空");
        }
        Integer amount = record.getAmount();
        if (amount == null) {
            throw new PushCouponException(1, "券数量不能为空");
        } else if (amount < 1 || amount > 5) {
            throw new PushCouponException(1, "券数量范围是 1~5");
        }
        String uids = record.getUids();
        if (StringUtil.isNullOrEmpty(uids)) {
            throw new PushCouponException(1, "发放用户不能为空");
        }
        Long id = record.getId();
        if (id == null) {
            // 新增
            record.setCreateTime(new Date());
            record.setUpdateTime(new Date());
            // 插入数据
            pushCouponMapper.insert(record);
            String[] uidArray = uids.split(",");
            if (uidArray != null) {
                for (int i = 0; i < uidArray.length; i++) {
        Integer amount = record.getAmount();
        if (amount == null) {
            throw new PushCouponException(1, "券数量不能为空");
        } else if (amount < 1 || amount > 5) {
            throw new PushCouponException(1, "券数量范围是 1~5");
        }
                    Long uid = Long.parseLong(uidArray[i]);
                    // 插入记录
                    PushCouponRecord pushCouponRecord = new PushCouponRecord();
                    pushCouponRecord.setPushCoupon(record);
                    pushCouponRecord.setUid(uid);
                    pushCouponRecord.setCreateTime(new Date());
                    // 插入领取记录
                    //pushCouponRecordService.insertSelective(pushCouponRecord);
                    // 直接发送券
                    //userSystemCouponService.randomRewardCoupon(amount, uid, UserSystemCoupon.SOURCE_SYSTEM_PUSH);
                }
            }
        } else {
        Long id = record.getId();
        if (id == null) {
            // 新增
            record.setCreateTime(new Date());
            record.setUpdateTime(new Date());
            // 插入数据
            pushCouponMapper.insert(record);
            String[] uidArray = uids.split(",");
            if (uidArray != null) {
                for (int i = 0; i < uidArray.length; i++) {
                    Long uid = Long.parseLong(uidArray[i]);
                    // 插入记录
                    PushCouponRecord pushCouponRecord = new PushCouponRecord();
                    pushCouponRecord.setPushCoupon(record);
                    pushCouponRecord.setUid(uid);
                    pushCouponRecord.setCreateTime(new Date());
                    // 插入领取记录
                    //pushCouponRecordService.insertSelective(pushCouponRecord);
                    // 直接发送券
                    //userSystemCouponService.randomRewardCoupon(amount, uid, UserSystemCoupon.SOURCE_SYSTEM_PUSH);
                }
            }
        } else {
//            
//            // 修改
//            PushCoupon current = selectByPrimaryKey(id);
@@ -149,110 +144,110 @@
//            current.setUpdateTime(new Date());
//            // 更新数据
//            updateByPrimaryKey(current);
        }
    }
        }
    }
    @Override
    @Transactional(rollbackFor=Exception.class)
    public void executePush(Long id) throws Exception, PushCouponException, PushException {
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void executePush(Long id) throws Exception, PushCouponException, PushException {
        PushCoupon pushCoupon = selectByPrimaryKey(id);
        if (pushCoupon == null) {
            throw new PushCouponException(1, "推送信息已不存在");
        }
        if(pushCoupon.isPushed()) {
            throw new PushCouponException(1, "该信息不能重复推送");
        }
        String versions = pushCoupon.getVersions();
        if (versions == null || versions.trim().length() == 0 ) {
            throw new PushCouponException(1, "推送版本不能为空");
        }
        PushCoupon pushCoupon = selectByPrimaryKey(id);
        if (pushCoupon == null) {
            throw new PushCouponException(1, "推送信息已不存在");
        }
        String title = pushCoupon.getTitle();
        String content = pushCoupon.getContent();
        if (title == null || title.trim().length() == 0 || content == null || content.trim().length() == 0) {
            throw new PushCouponException(1, "标题或内容不能为空");
        }
        List<String> listuid = null;
        String uids = pushCoupon.getUids();
        if (uids != null && uids.trim().length() > 0) {
            listuid = Arrays.asList(uids.split(","));
            if (listuid == null || listuid.size() == 0) {
                throw new PushCouponException(1, "用户id格式不正确");
            }
        }
        List<String> listIOS = new ArrayList<String>();
        JSONObject json = JSONObject.fromObject(versions);
        String versionsIOS = json.getString("IOS");
        if (versionsIOS != null && versionsIOS.trim().length() > 0) {
            if (versionsIOS.contains("全推")) {
                listIOS = null;
            } else {
                listIOS = Arrays.asList(versionsIOS.split(","));
            }
        }
        List<String> listAndroid = new ArrayList<String>();
        String versionsAndroid  = json.getString("Android");
        if (versionsAndroid != null && versionsAndroid.trim().length() > 0) {
            if (versionsAndroid.contains("全推")) {
                listAndroid = null;
            } else {
                listAndroid = Arrays.asList(versionsAndroid.split(","));
            }
        }
        if (listuid == null) {
            // 全推
            pushService.pushWelfareCenter(null, title, content, listIOS, listAndroid);
        } else {
            // 指定用户推送
            for (String str_uid: listuid) {
                if (str_uid != null && str_uid.trim().length() > 0) {
                    pushService.pushWelfareCenter(Long.parseLong(str_uid), title, content, listIOS, listAndroid);
                }
            }
        }
        // 已推送
        pushCoupon.setPushed(true);
        // 推送时间
        pushCoupon.setPushTime(new Date());
        // 更新时间
        pushCoupon.setUpdateTime(new Date());
        updateByPrimaryKeySelective(pushCoupon);
    }
        if (pushCoupon.isPushed()) {
            throw new PushCouponException(1, "该信息不能重复推送");
        }
        String versions = pushCoupon.getVersions();
        if (versions == null || versions.trim().length() == 0) {
            throw new PushCouponException(1, "推送版本不能为空");
        }
    @Override
    @Transactional
    public void deleteBatchByPrimaryKey(List<Long> list) {
        if (list == null || list.size() == 0) {
            return;
        }
        for (Long id: list) {
            long receivedCount = pushCouponRecordService.countByPushId(id);
            // 领取数量
            if (receivedCount > 0) {
                continue;
            }
            pushCouponMapper.deleteByPrimaryKey(id);
        }
    }
    @Override
    public List<PushCoupon> listQueryEffective() {
        return pushCouponMapper.listQueryEffective();
    }
        String title = pushCoupon.getTitle();
        String content = pushCoupon.getContent();
        if (title == null || title.trim().length() == 0 || content == null || content.trim().length() == 0) {
            throw new PushCouponException(1, "标题或内容不能为空");
        }
        List<String> listuid = null;
        String uids = pushCoupon.getUids();
        if (uids != null && uids.trim().length() > 0) {
            listuid = Arrays.asList(uids.split(","));
            if (listuid == null || listuid.size() == 0) {
                throw new PushCouponException(1, "用户id格式不正确");
            }
        }
        List<String> listIOS = new ArrayList<String>();
        JSONObject json = JSONObject.fromObject(versions);
        String versionsIOS = json.getString("IOS");
        if (versionsIOS != null && versionsIOS.trim().length() > 0) {
            if (versionsIOS.contains("全推")) {
                listIOS = null;
            } else {
                listIOS = Arrays.asList(versionsIOS.split(","));
            }
        }
        List<String> listAndroid = new ArrayList<String>();
        String versionsAndroid = json.getString("Android");
        if (versionsAndroid != null && versionsAndroid.trim().length() > 0) {
            if (versionsAndroid.contains("全推")) {
                listAndroid = null;
            } else {
                listAndroid = Arrays.asList(versionsAndroid.split(","));
            }
        }
        if (listuid == null) {
            // 全推
            pushService.pushWelfareCenter(null, title, content, listIOS, listAndroid, pushCoupon.getSystem());
        } else {
            // 指定用户推送
            for (String str_uid : listuid) {
                if (str_uid != null && str_uid.trim().length() > 0) {
                    pushService.pushWelfareCenter(Long.parseLong(str_uid), title, content, listIOS, listAndroid, pushCoupon.getSystem());
                }
            }
        }
        // 已推送
        pushCoupon.setPushed(true);
        // 推送时间
        pushCoupon.setPushTime(new Date());
        // 更新时间
        pushCoupon.setUpdateTime(new Date());
        updateByPrimaryKeySelective(pushCoupon);
    }
    @Override
    @Transactional
    public void deleteBatchByPrimaryKey(List<Long> list) {
        if (list == null || list.size() == 0) {
            return;
        }
        for (Long id : list) {
            long receivedCount = pushCouponRecordService.countByPushId(id);
            // 领取数量
            if (receivedCount > 0) {
                continue;
            }
            pushCouponMapper.deleteByPrimaryKey(id);
        }
    }
    @Override
    public List<PushCoupon> listQueryEffective(SystemEnum system) {
        return pushCouponMapper.listQueryEffective(system);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushGoodsServiceImpl.java
@@ -8,6 +8,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -297,29 +298,29 @@
    }
    @Override
    public List<PushGoods> listQuery(long start, int count, String key, Integer state) {
        return pushGoodsMapper.listQuery(start, count, key, state);
    public List<PushGoods> listQuery(long start, int count, String key, Integer state, SystemEnum system) {
        return pushGoodsMapper.listQuery(start, count, key, state,system);
    }
    @Override
    public long countQuery(String key, Integer state) {
        return pushGoodsMapper.countQuery(key, state);
    public long countQuery(String key, Integer state, SystemEnum system) {
        return pushGoodsMapper.countQuery(key, state,system);
    }
    @Override
    public List<PushGoods> listHistoryByPushTime(long start, int count, Long uid, Date pushTime) {
        return pushGoodsMapper.listHistoryByPushTime(start, count, uid, pushTime);
    public List<PushGoods> listHistoryByPushTime(long start, int count, Long uid, Date pushTime, SystemEnum system) {
        return pushGoodsMapper.listHistoryByPushTime(start, count, uid, pushTime,system);
    }
    @Override
    public long countHistoryByPushTime(Long uid, Date pushTime) {
        return pushGoodsMapper.countHistoryByPushTime(uid, pushTime);
    public long countHistoryByPushTime(Long uid, Date pushTime, SystemEnum system) {
        return pushGoodsMapper.countHistoryByPushTime(uid, pushTime,system);
    }
    
    @Override
    public List<PushGoods> listTask() {
        return pushGoodsMapper.listTask();
    public List<PushGoods> listTask( SystemEnum system) {
        return pushGoodsMapper.listTask(system);
    }
    
    
@@ -441,13 +442,13 @@
            }
        }
        
        String url = configService.get(ConfigKeyEnum.pushActivityLink.getKey());
        String url = configService.getValue(ConfigKeyEnum.pushActivityLink.getKey(),pushGoods.getSystem());
        if (StringUtil.isNullOrEmpty(url)) {
            throw new PushGoodsException(1, "推送页面链接不存在");
        }
        url = url + "?id=" + pushGoods.getId();
        // h活动全推
        pushService.pushUrl(pushGoods.getUid(), pushGoods.getTitle(), pushGoods.getContent(), url, listIOS, listAndroid);
        pushService.pushUrl(pushGoods.getUid(), pushGoods.getTitle(), pushGoods.getContent(), url, listIOS, listAndroid,pushGoods.getSystem());
    }
    
    
@@ -501,16 +502,16 @@
            Long goodsId = commonGoods.getGoodsId();
            String url = "https://item.taobao.com/item.htm?id=" + goodsId;
            pushService.pushGoods(pushGoods.getUid(), pushGoods.getTitle(), pushGoods.getContent(), url,listIOS, listAndroid);
            pushService.pushGoods(pushGoods.getUid(), pushGoods.getTitle(), pushGoods.getContent(), url,listIOS, listAndroid,pushGoods.getSystem());
        } else {
            /*   多个商品推送    */
            String url = configService.get(ConfigKeyEnum.pushGoodsDetails.getKey());
            String url = configService.getValue(ConfigKeyEnum.pushGoodsDetails.getKey(),pushGoods.getSystem());
            if (StringUtil.isNullOrEmpty(url)) {
                throw new PushGoodsException(1, "推送页面链接不存在");
            }
            // 生成链接
            url = url + "?id=" + id;
            pushService.pushUrl(pushGoods.getUid(), pushGoods.getTitle(), pushGoods.getContent(), url, listIOS, listAndroid);
            pushService.pushUrl(pushGoods.getUid(), pushGoods.getTitle(), pushGoods.getContent(), url, listIOS, listAndroid,pushGoods.getSystem());
        }
    }
    
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushInfoServiceImpl.java
@@ -8,6 +8,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -31,347 +32,338 @@
@Service
public class PushInfoServiceImpl implements PushInfoService {
    @Resource
    private PushService pushService;
    @Resource
    private PushService pushService;
    @Resource
    private UserSystemMsgService userSystemMsgService;
    @Resource
    private UserSystemMsgService userSystemMsgService;
    @Resource
    private ConfigService configService;
    @Resource
    private PushInfoMapper pushInfoMapper;
    @Resource
    private PushInfoMapper pushInfoMapper;
    @Override
    public void save(PushInfo record) throws PushInfoException, Exception {
        if (record == null) {
            throw new PushInfoException(1, "参数不正确");
        }
    @Override
    public void save(PushInfo record) throws PushInfoException, Exception {
        if (record == null) {
            throw new PushInfoException(1, "参数不正确");
        }
        PushTypeEnum type = record.getType();
        if (type == null) {
            throw new PushInfoException(1, "推送类型不能为空");
        }
        PushTypeEnum type = record.getType();
        if (type == null) {
            throw new PushInfoException(1, "推送类型不能为空");
        }
        String title = record.getTitle();
        if (title == null || title.trim().length() == 0) {
            throw new PushInfoException(1, "标题不能为空");
        }
        String title = record.getTitle();
        if (title == null || title.trim().length() == 0) {
            throw new PushInfoException(1, "标题不能为空");
        }
        String arrayAndroid = record.getArrayAndroid();
        String arrayIOS = record.getArrayIOS();
        if (StringUtil.isNullOrEmpty(arrayIOS) && StringUtil.isNullOrEmpty(arrayAndroid)) {
            throw new PushInfoException(1, "推送版本不能为空");
        }
        String arrayAndroid = record.getArrayAndroid();
        String arrayIOS = record.getArrayIOS();
        if (StringUtil.isNullOrEmpty(arrayIOS) && StringUtil.isNullOrEmpty(arrayAndroid)) {
            throw new PushInfoException(1, "推送版本不能为空");
        }
        // 定时时间
        Boolean timeTask = record.isTimeTask();
        if (timeTask != null && timeTask) {
            String controlTime_str = record.getControlTime_str();
            if (controlTime_str == null || controlTime_str.trim().length() == 0) {
                throw new PushInfoException(1, "预设时间不能为空");
            }
        // 定时时间
        Boolean timeTask = record.isTimeTask();
        if (timeTask != null && timeTask) {
            String controlTime_str = record.getControlTime_str();
            if (controlTime_str == null || controlTime_str.trim().length() == 0) {
                throw new PushInfoException(1, "预设时间不能为空");
            }
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            controlTime_str = controlTime_str.replaceAll("T", " ");
            record.setControlTime(format.parse(controlTime_str));
        } else {
            record.setControlTime(null);
        }
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            controlTime_str = controlTime_str.replaceAll("T", " ");
            record.setControlTime(format.parse(controlTime_str));
        } else {
            record.setControlTime(null);
        }
        String url = record.getUrl();
        String content = record.getContent();
        if (StringUtil.isNullOrEmpty(url) && StringUtil.isNullOrEmpty(content)) {
            throw new PushInfoException(1, "推送内容或URL不能为空");
        }
        String url = record.getUrl();
        String content = record.getContent();
        if (StringUtil.isNullOrEmpty(url) && StringUtil.isNullOrEmpty(content)) {
            throw new PushInfoException(1, "推送内容或URL不能为空");
        }
        if (url != null && (url.trim().length() == 0 || url.equalsIgnoreCase("null"))) {
            record.setUrl(null);
        }
        if (url != null && (url.trim().length() == 0 || url.equalsIgnoreCase("null"))) {
            record.setUrl(null);
        }
        if (content != null && (content.trim().length() == 0 || content.equalsIgnoreCase("null"))) {
            record.setContent(null);
        }
        if (content != null && (content.trim().length() == 0 || content.equalsIgnoreCase("null"))) {
            record.setContent(null);
        }
        String uids = record.getUids();
        if (uids != null && (uids.trim().length() == 0 || uids.equalsIgnoreCase("null"))) {
            record.setUids(null);
        }
        String uids = record.getUids();
        if (uids != null && (uids.trim().length() == 0 || uids.equalsIgnoreCase("null"))) {
            record.setUids(null);
        }
        // 数据转换json
        convertJson(record);
        record.setState(PushInfo.STATE_INIT);
        // 数据转换json
        convertJson(record);
        record.setState(PushInfo.STATE_INIT);
        Long id = record.getId();
        if (id == null) {
            record.setCreateTime(new Date());
            record.setUpdateTime(new Date());
            pushInfoMapper.insert(record);
        } else {
            // 修改
            PushInfo current = pushInfoMapper.selectByPrimaryKey(id);
            if (current == null) {
                throw new PushInfoException(1, "该记录已不存在");
            }
        Long id = record.getId();
        if (id == null) {
            record.setCreateTime(new Date());
            record.setUpdateTime(new Date());
            pushInfoMapper.insert(record);
        } else {
            // 修改
            PushInfo current = pushInfoMapper.selectByPrimaryKey(id);
            if (current == null) {
                throw new PushInfoException(1, "该记录已不存在");
            }
            if (PushInfo.STATE_SUCCESS == current.getState()) {
                throw new PushInfoException(1, "已推送成功的信息不能修改");
            }
            record.setCreateTime(current.getCreateTime());
            record.setUpdateTime(new Date());
            pushInfoMapper.updateByPrimaryKey(record);
        }
    }
            if (PushInfo.STATE_SUCCESS == current.getState()) {
                throw new PushInfoException(1, "已推送成功的信息不能修改");
            }
            record.setCreateTime(current.getCreateTime());
            record.setUpdateTime(new Date());
            pushInfoMapper.updateByPrimaryKey(record);
        }
    }
    /**
     * 转换json
     *
     * @param pushGoods
     */
    public void convertJson(PushInfo record) {
        JSONObject json = new JSONObject();
        String url = record.getUrl();
        if (StringUtil.isNullOrEmpty(url)) {
            url = "";
        }
        json.put("url", url);
        json.put("ios", convertVersion(record.getArrayIOS()));
        json.put("android", convertVersion(record.getArrayAndroid()));
        record.setJsonData(json.toString());
    }
    /**
     * 转换json
     */
    public void convertJson(PushInfo record) {
        JSONObject json = new JSONObject();
        String url = record.getUrl();
        if (StringUtil.isNullOrEmpty(url)) {
            url = "";
        }
        json.put("url", url);
        json.put("ios", convertVersion(record.getArrayIOS()));
        json.put("android", convertVersion(record.getArrayAndroid()));
        record.setJsonData(json.toString());
    }
    /**
     * 转换list
     *
     * @param pushGoods
     */
    public String convertVersion(String array) {
        String versions = "";
        if (array != null && array.trim().length() > 0) {
            Gson gson = new Gson();
            List<String> list = gson.fromJson(array, new TypeToken<ArrayList<String>>() {
            }.getType());
            if (list != null && list.size() > 0) {
                for (String version: list) {
                    versions += version + ",";
                }
                if (versions.endsWith(",")) {
                    versions = versions.substring(0, versions.length() - 1);
                }
            }
        }
        return versions;
    }
    @Override
    public void deleteBatchByPrimaryKey(List<Long> list) {
        pushInfoMapper.deleteBatchByPrimaryKey(list);
    }
    /**
     * 转换list
     */
    public String convertVersion(String array) {
        String versions = "";
        if (array != null && array.trim().length() > 0) {
            Gson gson = new Gson();
            List<String> list = gson.fromJson(array, new TypeToken<ArrayList<String>>() {
            }.getType());
    @Override
    public List<PushInfo> listQuery(long start, int count, String key, Integer keyType, Integer state, String type) {
        List<PushInfo> list = pushInfoMapper.listQuery(start, count, key, keyType, state, type);
        if (list == null || list.size() == 0) {
            return list;
        }
        for (PushInfo pushInfo: list) {
            Date controlTime = pushInfo.getControlTime();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
            if (controlTime == null) {
                pushInfo.setTimeTask(false);
                pushInfo.setControlTime_str("");
            } else {
                pushInfo.setTimeTask(true);
                pushInfo.setControlTime_str(sdf.format(controlTime));
            }
            String jsonData = pushInfo.getJsonData();
            JSONObject json = JSONObject.fromObject(jsonData);
            String url = json.getString("url");
            pushInfo.setUrl(url);
            List<String> listIOS = new ArrayList<String>();
            String versionsIOS = json.getString("ios");
            if (versionsIOS != null && versionsIOS.trim().length() > 0) {
                listIOS = Arrays.asList(versionsIOS.split(","));
            }
            pushInfo.setListIOS(listIOS);
            if (list != null && list.size() > 0) {
            List<String> listAndroid = new ArrayList<String>();
            String versionsAndroid = json.getString("android");
            if (versionsAndroid != null && versionsAndroid.trim().length() > 0) {
                listAndroid = Arrays.asList(versionsAndroid.split(","));
            }
            pushInfo.setListAndroid(listAndroid);
        }
        return list;
    }
                for (String version : list) {
                    versions += version + ",";
                }
                if (versions.endsWith(",")) {
                    versions = versions.substring(0, versions.length() - 1);
                }
            }
        }
        return versions;
    }
    @Override
    public long countQuery(String key, Integer keyType, Integer state, String type) {
        return pushInfoMapper.countQuery(key, keyType, state, type);
    }
    @Override
    public void deleteBatchByPrimaryKey(List<Long> list) {
        pushInfoMapper.deleteBatchByPrimaryKey(list);
    }
    @Override
    public List<PushInfo> listTask() {
        return pushInfoMapper.listTask();
    }
    @Override
    public void handPush(Long id) throws Exception, PushInfoException, PushException {
        PushInfo record = pushInfoMapper.selectByPrimaryKey(id);
        if (record == null) {
            throw new PushInfoException(1, "推送信息已不存在");
        }
        // 执行推送
        executePush(record);
        record.setState(PushInfo.STATE_SUCCESS);
        record.setPushTime(new Date());
        record.setUpdateTime(new Date());
        pushInfoMapper.updateByPrimaryKey(record);
    }
    @Override
    public void taskPush(PushInfo record) {
        String msg = null;
        int state = PushInfo.STATE_FAIL;
        try {
            // 执行推送
            executePush(record);
            state = PushInfo.STATE_SUCCESS;
        } catch (PushInfoException e) {
            msg = e.getMsg();
        } catch (PushException e) {
            msg = e.getMsg();
        } catch (Exception e) {
            msg = "系统推送失败";
        }
        record.setState(state);
        record.setPushTime(new Date());
        record.setRemark(msg);
        record.setUpdateTime(new Date());
        pushInfoMapper.updateByPrimaryKey(record);
    }
    @Override
    @Transactional(rollbackFor=Exception.class)
    public void executePush(PushInfo record) throws Exception, PushInfoException, PushException {
    @Override
    public List<PushInfo> listQuery(long start, int count, String key, Integer keyType, Integer state, String type, SystemEnum system) {
        if (PushInfo.STATE_SUCCESS == record.getState()) {
            throw new PushInfoException(1, "该信息不能重复推送");
        }
        List<PushInfo> list = pushInfoMapper.listQuery(start, count, key, keyType, state, type, system);
        if (list == null || list.size() == 0) {
            return list;
        }
        String title = record.getTitle();
        if (title == null || title.trim().length() == 0) {
            throw new PushInfoException(1, "标题不能为空");
        }
        for (PushInfo pushInfo : list) {
            Date controlTime = pushInfo.getControlTime();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
            if (controlTime == null) {
                pushInfo.setTimeTask(false);
                pushInfo.setControlTime_str("");
            } else {
                pushInfo.setTimeTask(true);
                pushInfo.setControlTime_str(sdf.format(controlTime));
            }
        String jsonData = record.getJsonData();
        if (StringUtil.isNullOrEmpty(jsonData) && StringUtil.isNullOrEmpty(jsonData)) {
            throw new PushInfoException(1, "推送版本不能为空");
        }
            String jsonData = pushInfo.getJsonData();
            JSONObject json = JSONObject.fromObject(jsonData);
            String url = json.getString("url");
            pushInfo.setUrl(url);
        JSONObject json = JSONObject.fromObject(jsonData);
        String url = json.getString("url");
        String content = record.getContent();
        if (StringUtil.isNullOrEmpty(url) && StringUtil.isNullOrEmpty(content)) {
            throw new PushInfoException(1, "推送内容或URL不能为空");
        }
            List<String> listIOS = new ArrayList<String>();
            String versionsIOS = json.getString("ios");
            if (versionsIOS != null && versionsIOS.trim().length() > 0) {
                listIOS = Arrays.asList(versionsIOS.split(","));
            }
            pushInfo.setListIOS(listIOS);
        List<String> listIOS = new ArrayList<String>();
        String versionsIOS = json.getString("ios");
        if (versionsIOS != null && versionsIOS.trim().length() > 0) {
            if (versionsIOS.contains("全推")) {
                listIOS = null;
            } else {
                listIOS = Arrays.asList(versionsIOS.split(","));
            }
        }
            List<String> listAndroid = new ArrayList<String>();
            String versionsAndroid = json.getString("android");
            if (versionsAndroid != null && versionsAndroid.trim().length() > 0) {
                listAndroid = Arrays.asList(versionsAndroid.split(","));
            }
            pushInfo.setListAndroid(listAndroid);
        }
        List<String> listAndroid = new ArrayList<String>();
        String versionsAndroid = json.getString("android");
        if (versionsAndroid != null && versionsAndroid.trim().length() > 0) {
            if (versionsAndroid.contains("全推")) {
                listAndroid = null;
            } else {
                listAndroid = Arrays.asList(versionsAndroid.split(","));
            }
        }
        return list;
    }
        List<String> listuid = null;
        String uids = record.getUids();
        if (uids != null && uids.trim().length() > 0) {
            listuid = Arrays.asList(uids.split(","));
            if (listuid == null || listuid.size() == 0) {
                throw new PushInfoException(1, "用户id格式不正确");
            }
        }
    @Override
    public long countQuery(String key, Integer keyType, Integer state, String type, SystemEnum system) {
        return pushInfoMapper.countQuery(key, keyType, state, type, system);
    }
        PushTypeEnum type = record.getType();
        if (type == null) {
            throw new PushInfoException(1, "推送类型不能为空");
        }
    @Override
    public List<PushInfo> listTask(SystemEnum system) {
        return pushInfoMapper.listTask(system);
    }
        int pushWay = 0;
        if (PushTypeEnum.ZNX == type) {
            pushWay = 1;
        } else if (PushTypeEnum.URL == type) {
            pushWay = 2;
        } else if (PushTypeEnum.BAICHUAN == type) {
            pushWay = 3;
        } else {
            throw new PushInfoException(1, "推送类型不匹配");
        }
    @Override
    public void handPush(Long id) throws Exception, PushInfoException, PushException {
        PushInfo record = pushInfoMapper.selectByPrimaryKey(id);
        if (record == null) {
            throw new PushInfoException(1, "推送信息已不存在");
        }
        // 执行推送
        executePush(record);
        if (listuid == null) { // 全推
            switch (pushWay) {
            case 1: // 站内信
                pushService.pushZNX(null, title, content, listIOS, listAndroid);
                break;
            case 2: // 网页推送
                pushService.pushUrl(null, title, content, url, listIOS, listAndroid);
                break;
            case 3: // 百川
                pushService.pushBaiChuanUrl(null, title, content, url, listIOS, listAndroid);
                break;
            default:
                throw new PushInfoException(1, "推送类型不匹配");
            }
        record.setState(PushInfo.STATE_SUCCESS);
        record.setPushTime(new Date());
        record.setUpdateTime(new Date());
        pushInfoMapper.updateByPrimaryKey(record);
    }
        } else {
            for (String str_uid : listuid) {
                if (str_uid != null && str_uid.trim().length() > 0) {
                    long uid = Long.parseLong(str_uid);
                    switch (pushWay) {
                    case 1: // 站内信
                        pushService.pushZNX(uid, title, content, listIOS, listAndroid);
                        userSystemMsgService.addUserSystemMsg(uid, UserSystemMsgTypeEnum.question, title, content,
                                UserSystemMsg.TIME_TAG_COMMON, null);
                        break;
                    case 2: // 网页推送
                        pushService.pushUrl(uid, title, content, url, listIOS, listAndroid);
                        break;
                    case 3: // 百川
                        pushService.pushBaiChuanUrl(uid, title, content, url, listIOS, listAndroid);
                        break;
                    default:
                        throw new PushInfoException(1, "推送类型不匹配");
                    }
                }
            }
        }
    }
    @Override
    public void taskPush(PushInfo record) {
        String msg = null;
        int state = PushInfo.STATE_FAIL;
        try {
            // 执行推送
            executePush(record);
            state = PushInfo.STATE_SUCCESS;
        } catch (PushInfoException e) {
            msg = e.getMsg();
        } catch (PushException e) {
            msg = e.getMsg();
        } catch (Exception e) {
            msg = "系统推送失败";
        }
        record.setState(state);
        record.setPushTime(new Date());
        record.setRemark(msg);
        record.setUpdateTime(new Date());
        pushInfoMapper.updateByPrimaryKey(record);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void executePush(PushInfo record) throws Exception, PushInfoException, PushException {
        if (PushInfo.STATE_SUCCESS == record.getState()) {
            throw new PushInfoException(1, "该信息不能重复推送");
        }
        String title = record.getTitle();
        if (title == null || title.trim().length() == 0) {
            throw new PushInfoException(1, "标题不能为空");
        }
        String jsonData = record.getJsonData();
        if (StringUtil.isNullOrEmpty(jsonData) && StringUtil.isNullOrEmpty(jsonData)) {
            throw new PushInfoException(1, "推送版本不能为空");
        }
        JSONObject json = JSONObject.fromObject(jsonData);
        String url = json.getString("url");
        String content = record.getContent();
        if (StringUtil.isNullOrEmpty(url) && StringUtil.isNullOrEmpty(content)) {
            throw new PushInfoException(1, "推送内容或URL不能为空");
        }
        List<String> listIOS = new ArrayList<String>();
        String versionsIOS = json.getString("ios");
        if (versionsIOS != null && versionsIOS.trim().length() > 0) {
            if (versionsIOS.contains("全推")) {
                listIOS = null;
            } else {
                listIOS = Arrays.asList(versionsIOS.split(","));
            }
        }
        List<String> listAndroid = new ArrayList<String>();
        String versionsAndroid = json.getString("android");
        if (versionsAndroid != null && versionsAndroid.trim().length() > 0) {
            if (versionsAndroid.contains("全推")) {
                listAndroid = null;
            } else {
                listAndroid = Arrays.asList(versionsAndroid.split(","));
            }
        }
        List<String> listuid = null;
        String uids = record.getUids();
        if (uids != null && uids.trim().length() > 0) {
            listuid = Arrays.asList(uids.split(","));
            if (listuid == null || listuid.size() == 0) {
                throw new PushInfoException(1, "用户id格式不正确");
            }
        }
        PushTypeEnum type = record.getType();
        if (type == null) {
            throw new PushInfoException(1, "推送类型不能为空");
        }
        int pushWay = 0;
        if (PushTypeEnum.ZNX == type) {
            pushWay = 1;
        } else if (PushTypeEnum.URL == type) {
            pushWay = 2;
        } else if (PushTypeEnum.BAICHUAN == type) {
            pushWay = 3;
        } else {
            throw new PushInfoException(1, "推送类型不匹配");
        }
        if (listuid == null) { // 全推
            switch (pushWay) {
                case 1: // 站内信
                    pushService.pushZNX(null, title, content, listIOS, listAndroid, record.getSystem());
                    break;
                case 2: // 网页推送
                    pushService.pushUrl(null, title, content, url, listIOS, listAndroid, record.getSystem());
                    break;
                case 3: // 百川
                    pushService.pushBaiChuanUrl(null, title, content, url, listIOS, listAndroid, record.getSystem());
                    break;
                default:
                    throw new PushInfoException(1, "推送类型不匹配");
            }
        } else {
            for (String str_uid : listuid) {
                if (str_uid != null && str_uid.trim().length() > 0) {
                    long uid = Long.parseLong(str_uid);
                    switch (pushWay) {
                        case 1: // 站内信
                            pushService.pushZNX(uid, title, content, listIOS, listAndroid, record.getSystem());
                            userSystemMsgService.addUserSystemMsg(uid, UserSystemMsgTypeEnum.question, title, content,
                                    UserSystemMsg.TIME_TAG_COMMON, null);
                            break;
                        case 2: // 网页推送
                            pushService.pushUrl(uid, title, content, url, listIOS, listAndroid, record.getSystem());
                            break;
                        case 3: // 百川
                            pushService.pushBaiChuanUrl(uid, title, content, url, listIOS, listAndroid, record.getSystem());
                            break;
                        default:
                            throw new PushInfoException(1, "推送类型不匹配");
                    }
                }
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushServiceImpl.java
@@ -1,617 +1,609 @@
package com.yeshi.fanli.service.impl.push;
import java.util.List;
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.mybatis.AccountMessageMapper;
import com.yeshi.fanli.dao.mybatis.push.PushRecordMapper;
import com.yeshi.fanli.dto.push.PushBaseContent;
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.AccountMessage;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.system.SystemZnx;
import com.yeshi.fanli.entity.xinge.PushRecord;
import com.yeshi.fanli.exception.push.PushException;
import com.yeshi.fanli.service.inter.config.AppVersionService;
import com.yeshi.fanli.service.inter.push.DeviceTokenHWService;
import com.yeshi.fanli.service.inter.push.HWPushService;
import com.yeshi.fanli.service.inter.push.IOSPushService;
import com.yeshi.fanli.service.inter.push.OPPOPushService;
import com.yeshi.fanli.service.inter.push.PushRecordService;
import com.yeshi.fanli.service.inter.push.PushService;
import com.yeshi.fanli.service.inter.push.VIVOPushService;
import com.yeshi.fanli.service.inter.push.XMPushService;
import com.yeshi.fanli.service.inter.push.*;
import com.yeshi.fanli.service.inter.user.SystemZnxService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class PushServiceImpl implements PushService {
    static String IOSBundleId = "";
    static String PROJECT_NAME = "";
    static String IOSBundleId = "";
    static String PROJECT_NAME = "";
    static {
        IOSBundleId = Constant.systemCommonConfig.getIosBundleId();
        PROJECT_NAME = Constant.systemCommonConfig.getProjectChineseName();
    }
    static {
        IOSBundleId = Constant.systemCommonConfig.getIosBundleId();
        PROJECT_NAME = Constant.systemCommonConfig.getProjectChineseName();
    }
    @Resource
    private PushRecordService pushRecordService;
    @Resource
    private PushRecordService pushRecordService;
    @Resource
    private SystemZnxService systemZnxService;
    @Resource
    private SystemZnxService systemZnxService;
    @Resource
    private DeviceTokenHWService deviceTokenHWService;
    @Resource
    private DeviceTokenHWService deviceTokenHWService;
    @Resource
    private IOSPushService iosPushService;
    @Resource
    private IOSPushService iosPushService;
    @Resource
    private HWPushService hwPushService;
    @Resource
    private HWPushService hwPushService;
    @Resource
    private XMPushService xmPushService;
    @Resource
    private XMPushService xmPushService;
    @Resource
    private OPPOPushService oPPOPushService;
    @Resource
    private OPPOPushService oPPOPushService;
    @Resource
    private VIVOPushService vIVOPushService;
    @Resource
    private VIVOPushService vIVOPushService;
    @Resource
    private PushRecordMapper pushRecordMapper;
    @Resource
    private PushRecordMapper pushRecordMapper;
    @Resource
    private AccountMessageMapper accountMessageMapper;
    @Resource
    private AccountMessageMapper accountMessageMapper;
    @Resource
    private AppVersionService appVersionService;
    @Resource
    private AppVersionService appVersionService;
    @Override
    public void pushGoods(Long uid, String title, String content, String url, List<String> listIOS,
            List<String> listAndroid, SystemEnum system) throws PushException {
        String gids = url.split("id=")[1];
        String gid = gids.split("&")[0];
        if (StringUtil.isNullOrEmpty(gid))
            throw new PushException(1, "商品解析失败");
        if (StringUtil.isNullOrEmpty(title))
            throw new PushException(1, "请填写推送标题");
        if (StringUtil.isNullOrEmpty(content))
            throw new PushException(1, "请填写推送内容");
    @Override
    public void pushGoods(Long uid, String title, String content, String url, List<String> listIOS,
                          List<String> listAndroid, SystemEnum system) throws PushException {
        String gids = url.split("id=")[1];
        String gid = gids.split("&")[0];
        if (StringUtil.isNullOrEmpty(gid))
            throw new PushException(1, "商品解析失败");
        if (StringUtil.isNullOrEmpty(title))
            throw new PushException(1, "请填写推送标题");
        if (StringUtil.isNullOrEmpty(content))
            throw new PushException(1, "请填写推送内容");
        /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listIOS == null || listIOS.size() > 0) {
            // 限制推送版本号:0
            String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS,system);
            if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) {
                iosPushService.pushGoods(uid, Long.parseLong(gid), title, content, codes);
            }
        }
        /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listIOS == null || listIOS.size() > 0) {
            // 限制推送版本号:0
            String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS, system);
            if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) {
                iosPushService.pushGoods(uid, Long.parseLong(gid), title, content, codes);
            }
        }
        /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listAndroid == null || listAndroid.size() > 0) {
            // 限制推送版本号:0
            String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid,system);
            if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) {
                xmPushService.pushGoods(uid, Long.parseLong(gid), title, content, versions);
            }
            // 华为推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
                hwPushService.pushGoods(uid, Long.parseLong(gid), title, content, versionCodeList);
            }
        /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listAndroid == null || listAndroid.size() > 0) {
            // 限制推送版本号:0
            String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid, system);
            if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) {
                xmPushService.pushGoods(uid, Long.parseLong(gid), title, content, versions);
            }
            // 华为推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
                hwPushService.pushGoods(uid, Long.parseLong(gid), new PushBaseContent(title, content, versionCodeList, system));
            }
            // OPPO推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
                oPPOPushService.pushGoods(uid, Long.parseLong(gid), title, content, versionCodeList);
            }
            // VIVO推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
                vIVOPushService.pushGoods(uid, Long.parseLong(gid), title, content, versionCodeList);
            }
            // OPPO推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
                oPPOPushService.pushGoods(uid, Long.parseLong(gid), new PushBaseContent(title, content, versionCodeList, system));
            }
            // VIVO推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
                vIVOPushService.pushGoods(uid, Long.parseLong(gid), new PushBaseContent(title, content, versionCodeList, system));
            }
        }
        }
        PushRecord pushRecord = new PushRecord();
        pushRecord.setUid(uid);
        pushRecord.setState(1);
        pushRecord.setType(PushTypeEnum.goodsdetail.getCode()); // 都成功
        pushRecord.setUrl(url);
        pushRecord.setTitle(title);
        pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
        pushRecord.setAccount(1);
        pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
        pushRecordMapper.insertSelective(pushRecord);
    }
        PushRecord pushRecord = new PushRecord();
        pushRecord.setUid(uid);
        pushRecord.setState(1);
        pushRecord.setType(PushTypeEnum.goodsdetail.getCode()); // 都成功
        pushRecord.setUrl(url);
        pushRecord.setTitle(title);
        pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
        pushRecord.setAccount(1);
        pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
        pushRecordMapper.insertSelective(pushRecord);
    }
    @Override
    public void pushUrl(Long uid, String title, String content, String url, List<String> listIOS,
            List<String> listAndroid, SystemEnum system) throws PushException {
    @Override
    public void pushUrl(Long uid, String title, String content, String url, List<String> listIOS,
                        List<String> listAndroid, SystemEnum system) throws PushException {
        if (StringUtil.isNullOrEmpty(url))
            throw new PushException(1, "无推送链接");
        if (StringUtil.isNullOrEmpty(title))
            throw new PushException(1, "无推送标题");
        if (StringUtil.isNullOrEmpty(content))
            throw new PushException(1, "无推送内容");
        if (StringUtil.isNullOrEmpty(url))
            throw new PushException(1, "无推送链接");
        if (StringUtil.isNullOrEmpty(title))
            throw new PushException(1, "无推送标题");
        if (StringUtil.isNullOrEmpty(content))
            throw new PushException(1, "无推送内容");
        /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listIOS == null || listIOS.size() > 0) {
            // 限制推送版本号:0
            String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS,system);
            if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) {
                iosPushService.pushUrl(uid, url, title, content, codes);
            }
        }
        /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listIOS == null || listIOS.size() > 0) {
            // 限制推送版本号:0
            String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS, system);
            if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) {
                iosPushService.pushUrl(uid, url, title, content, codes);
            }
        }
        /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listAndroid == null || listAndroid.size() > 0) {
            // 限制推送版本号:0
            String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid,system);
            if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) {
                xmPushService.pushUrl(uid, url, title, content, versions);
            }
        /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listAndroid == null || listAndroid.size() > 0) {
            // 限制推送版本号:0
            String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid, system);
            if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) {
                xmPushService.pushUrl(uid, url, title, content, versions);
            }
            // 华为推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
                hwPushService.pushUrl(uid, url, title, content, versionCodeList);
            }
            // 华为推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
                hwPushService.pushUrl(uid, url, new PushBaseContent(title, content, versionCodeList, system));
            }
            // OPPO推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
                oPPOPushService.pushUrl(uid, url, title, content, versionCodeList);
            }
            // OPPO推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
                oPPOPushService.pushUrl(uid, url, new PushBaseContent(title, content, versionCodeList, system));
            }
            // VIVO推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
                vIVOPushService.pushUrl(uid, url, title, content, versionCodeList);
            }
            // VIVO推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
                vIVOPushService.pushUrl(uid, url, new PushBaseContent(title, content, versionCodeList, system));
            }
        }
        }
        PushRecord pushRecord = new PushRecord();
        pushRecord.setUid(uid);
        pushRecord.setState(1);
        pushRecord.setType(PushTypeEnum.url.getCode());
        pushRecord.setUrl(url);
        pushRecord.setTitle(title);
        pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
        pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
        pushRecordMapper.insertSelective(pushRecord);
    }
        PushRecord pushRecord = new PushRecord();
        pushRecord.setUid(uid);
        pushRecord.setState(1);
        pushRecord.setType(PushTypeEnum.url.getCode());
        pushRecord.setUrl(url);
        pushRecord.setTitle(title);
        pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
        pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
        pushRecordMapper.insertSelective(pushRecord);
    }
    @Override
    public void pushZNX(Long uId, String title, String content, List<String> listIOS, List<String> listAndroid, SystemEnum system)
            throws PushException {
        if (StringUtil.isNullOrEmpty(title))
            throw new PushException(1, "无推送标题");
        if (StringUtil.isNullOrEmpty(content))
            throw new PushException(1, "无推送内容");
    @Override
    public void pushZNX(Long uId, String title, String content, List<String> listIOS, List<String> listAndroid, SystemEnum system)
            throws PushException {
        if (StringUtil.isNullOrEmpty(title))
            throw new PushException(1, "无推送标题");
        if (StringUtil.isNullOrEmpty(content))
            throw new PushException(1, "无推送内容");
        SystemZnx systemZnx = null;
        AccountMessage accountMessage = null;
        SystemZnx systemZnx = null;
        AccountMessage accountMessage = null;
        /* 无uid , 广播 数据插入系统表 */
        if (uId == null || uId == 0) {
            // 插入数据库(系统站内信数据)
            systemZnx = new SystemZnx();
            systemZnx.setTitle(title);
            systemZnx.setContent(content);
            systemZnx.setCreateTime(System.currentTimeMillis());
            systemZnxService.save(systemZnx);
        } else {
            accountMessage = new AccountMessage();
            accountMessage.setCreateTime(System.currentTimeMillis());
            accountMessage.setIsOpen(false);
            accountMessage.setUserInfo(new UserInfo(uId));
            accountMessage.setTitle(title);
            accountMessage.setContent(content);
            accountMessageMapper.insertSelective(accountMessage);
        }
        /* 无uid , 广播 数据插入系统表 */
        if (uId == null || uId == 0) {
            // 插入数据库(系统站内信数据)
            systemZnx = new SystemZnx();
            systemZnx.setTitle(title);
            systemZnx.setContent(content);
            systemZnx.setCreateTime(System.currentTimeMillis());
            systemZnxService.save(systemZnx);
        } else {
            accountMessage = new AccountMessage();
            accountMessage.setCreateTime(System.currentTimeMillis());
            accountMessage.setIsOpen(false);
            accountMessage.setUserInfo(new UserInfo(uId));
            accountMessage.setTitle(title);
            accountMessage.setContent(content);
            accountMessageMapper.insertSelective(accountMessage);
        }
        /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listIOS == null || listIOS.size() > 0) {
            // 限制推送版本号:0
            String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS,system);
            if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) {
                iosPushService.pushZNX(uId, accountMessage, systemZnx, codes);
            }
        }
        /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listIOS == null || listIOS.size() > 0) {
            // 限制推送版本号:0
            String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS, system);
            if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) {
                iosPushService.pushZNX(uId, accountMessage, systemZnx, codes);
            }
        }
        /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listAndroid == null || listAndroid.size() > 0) {
            // 限制推送版本号:0
            String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid,system);
            if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) {
                xmPushService.pushZNX(uId, accountMessage, systemZnx, versions);
            }
        /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listAndroid == null || listAndroid.size() > 0) {
            // 限制推送版本号:0
            String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid, system);
            if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) {
                xmPushService.pushZNX(uId, accountMessage, systemZnx, versions);
            }
            // 华为推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
                hwPushService.pushZNX(uId, title, content, versionCodeList);
            }
            // 华为推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
                hwPushService.pushZNX(uId, new PushBaseContent(title, content, versionCodeList, system));
            }
            // OPPO推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
                oPPOPushService.pushZNX(uId, title, content, versionCodeList);
            }
            // OPPO推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
                oPPOPushService.pushZNX(uId, new PushBaseContent(title, content, versionCodeList, system));
            }
            // VIVO推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
                vIVOPushService.pushZNX(uId, title, content, versionCodeList);
            }
        }
            // VIVO推送
            if (listAndroid == null || listAndroid.size() > 0) {
                List<Integer> versionCodeList = null;
                if (listAndroid != null)
                    versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
                vIVOPushService.pushZNX(uId, new PushBaseContent(title, content, versionCodeList, system));
            }
        }
        // 插入推送记录
        PushRecord pushRecord = new PushRecord();
        pushRecord.setUid(uId);
        pushRecord.setTitle(title);
        pushRecord.setState(1); // 成功
        pushRecord.setType(PushTypeEnum.ZNX.getCode()); // 类型:站内信
        pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
        pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
        pushRecordMapper.insertSelective(pushRecord);
    }
        // 插入推送记录
        PushRecord pushRecord = new PushRecord();
        pushRecord.setUid(uId);
        pushRecord.setTitle(title);
        pushRecord.setState(1); // 成功
        pushRecord.setType(PushTypeEnum.ZNX.getCode()); // 类型:站内信
        pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
        pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
        pushRecordMapper.insertSelective(pushRecord);
    }
    @Override
    public void pushWEEX(Long uid, String title, String content, String weexUrl, List<String> listIOS,
            List<String> listAndroid, SystemEnum system) throws PushException {
        if (StringUtil.isNullOrEmpty(title))
            throw new PushException(1, "无推送标题");
        if (StringUtil.isNullOrEmpty(content))
            throw new PushException(1, "无推送内容");
    @Override
    public void pushWEEX(Long uid, String title, String content, String weexUrl, List<String> listIOS,
                         List<String> listAndroid, SystemEnum system) throws PushException {
        if (StringUtil.isNullOrEmpty(title))
            throw new PushException(1, "无推送标题");
        if (StringUtil.isNullOrEmpty(content))
            throw new PushException(1, "无推送内容");
        // 适用版本 1.4.8及以后 推送weex页面
        // 适用版本 1.4.8及以后 推送weex页面
        /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listIOS == null || listIOS.size() > 0) {
            // 限制推送版本号:0
            String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS,system);
            if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) {
                iosPushService.pushWEEX(uid, title, content, weexUrl, codes);
            }
        }
        /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listIOS == null || listIOS.size() > 0) {
            // 限制推送版本号:0
            String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS, system);
            if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) {
                iosPushService.pushWEEX(uid, title, content, weexUrl, codes);
            }
        }
        /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listAndroid == null || listAndroid.size() > 0) {
            // 限制推送版本号:31
            String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid,system);
            if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) {
                xmPushService.pushWEEX(uid, title, content, weexUrl, versions);
            }
        }
        /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listAndroid == null || listAndroid.size() > 0) {
            // 限制推送版本号:31
            String versions = getEffectiveVersions(0, AppVersionInfo.PLATFORM_ANDROID, listAndroid, system);
            if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) {
                xmPushService.pushWEEX(uid, title, content, weexUrl, versions);
            }
        }
        // 华为推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
            hwPushService.pushWEEX(uid, title, content, weexUrl, versionCodeList);
        }
        // 华为推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
            hwPushService.pushWEEX(uid, weexUrl, new PushBaseContent(title, content, versionCodeList, system));
        }
        // OPPO推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
            oPPOPushService.pushWEEX(uid, title, content, weexUrl, versionCodeList);
        }
        // OPPO推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
            oPPOPushService.pushWEEX(uid, weexUrl, new PushBaseContent(title, content, versionCodeList, system));
        }
        // VIVO推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
            vIVOPushService.pushWEEX(uid, title, content, weexUrl, versionCodeList);
        }
        // VIVO推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
            vIVOPushService.pushWEEX(uid, weexUrl, new PushBaseContent(title, content, versionCodeList, system));
        }
        // 插入推送记录
        PushRecord pushRecord = new PushRecord();
        pushRecord.setTitle(title);
        pushRecord.setUid(uid);
        pushRecord.setState(1); // 成功
        pushRecord.setType(PushTypeEnum.weex.getCode()); // 类型:WEEX
        pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
        pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
        pushRecordMapper.insertSelective(pushRecord);
    }
        // 插入推送记录
        PushRecord pushRecord = new PushRecord();
        pushRecord.setTitle(title);
        pushRecord.setUid(uid);
        pushRecord.setState(1); // 成功
        pushRecord.setType(PushTypeEnum.weex.getCode()); // 类型:WEEX
        pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
        pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
        pushRecordMapper.insertSelective(pushRecord);
    }
    @Override
    public void pushBaiChuanUrl(Long uid, String title, String content, String url, List<String> listIOS,
            List<String> listAndroid, SystemEnum system) throws PushException {
    @Override
    public void pushBaiChuanUrl(Long uid, String title, String content, String url, List<String> listIOS,
                                List<String> listAndroid, SystemEnum system) throws PushException {
        if (StringUtil.isNullOrEmpty(title))
            throw new PushException(1, "无推送标题");
        if (StringUtil.isNullOrEmpty(content))
            throw new PushException(1, "无推送内容");
        if (StringUtil.isNullOrEmpty(title))
            throw new PushException(1, "无推送标题");
        if (StringUtil.isNullOrEmpty(content))
            throw new PushException(1, "无推送内容");
        // 适用版本 1.4.8及以后 推送百川网页
        // 适用版本 1.4.8及以后 推送百川网页
        /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listIOS == null || listIOS.size() > 0) {
            // 限制推送版本号:0
            String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS,system);
            if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) {
                iosPushService.pushBaiChuanUrl(uid, title, content, url, codes);
            }
        }
        /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listIOS == null || listIOS.size() > 0) {
            // 限制推送版本号:0
            String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS, system);
            if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) {
                iosPushService.pushBaiChuanUrl(uid, title, content, url, codes);
            }
        }
        /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listAndroid == null || listAndroid.size() > 0) {
            // 限制推送版本号:31
            String versions = getEffectiveVersions(31, AppVersionInfo.PLATFORM_ANDROID, listAndroid,system);
            if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) {
                xmPushService.pushBaiChuanUrl(uid, title, content, url, versions);
            }
        }
        /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listAndroid == null || listAndroid.size() > 0) {
            // 限制推送版本号:31
            String versions = getEffectiveVersions(31, AppVersionInfo.PLATFORM_ANDROID, listAndroid, system);
            if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) {
                xmPushService.pushBaiChuanUrl(uid, title, content, url, versions);
            }
        }
        // 华为推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
            hwPushService.pushBaiChuanUrl(uid, title, content, url, versionCodeList);
        }
        // 华为推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
            hwPushService.pushBaiChuanUrl(uid, url, new PushBaseContent(title, content, versionCodeList, system));
        }
        // OPPO推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
            oPPOPushService.pushBaiChuanUrl(uid, title, content, url, versionCodeList);
        }
        // OPPO推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
            oPPOPushService.pushBaiChuanUrl(uid, url, new PushBaseContent(title, content, versionCodeList, system));
        }
        // VIVO推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
            vIVOPushService.pushBaiChuanUrl(uid, title, content, url, versionCodeList);
        }
        // VIVO推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
            vIVOPushService.pushBaiChuanUrl(uid, url, new PushBaseContent(title, content, versionCodeList, system));
        }
        // 插入推送记录
        PushRecord pushRecord = new PushRecord();
        pushRecord.setUrl(url);
        pushRecord.setTitle(title);
        pushRecord.setUid(uid);
        pushRecord.setState(1); // 成功
        pushRecord.setType(PushTypeEnum.baichuan.getCode()); // 类型:百川
        pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
        pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
        pushRecordMapper.insertSelective(pushRecord);
    }
        // 插入推送记录
        PushRecord pushRecord = new PushRecord();
        pushRecord.setUrl(url);
        pushRecord.setTitle(title);
        pushRecord.setUid(uid);
        pushRecord.setState(1); // 成功
        pushRecord.setType(PushTypeEnum.baichuan.getCode()); // 类型:百川
        pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
        pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
        pushRecordMapper.insertSelective(pushRecord);
    }
    @Override
    public void pushWelfareCenter(Long uid, String title, String content, List<String> listIOS,
            List<String> listAndroid, SystemEnum system) throws PushException {
    @Override
    public void pushWelfareCenter(Long uid, String title, String content, List<String> listIOS,
                                  List<String> listAndroid, SystemEnum system) throws PushException {
        if (StringUtil.isNullOrEmpty(title))
            throw new PushException(1, "无推送标题");
        if (StringUtil.isNullOrEmpty(content))
            throw new PushException(1, "无推送内容");
        if (StringUtil.isNullOrEmpty(title))
            throw new PushException(1, "无推送标题");
        if (StringUtil.isNullOrEmpty(content))
            throw new PushException(1, "无推送内容");
        /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listIOS == null || listIOS.size() > 0) {
            // 限制推送版本号:0
            String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS,system);
            if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) {
                iosPushService.pushWelfareCenter(uid, title, content, codes);
            }
        }
        /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listIOS == null || listIOS.size() > 0) {
            // 限制推送版本号:0
            String codes = getEffectiveVersionCodes(0, AppVersionInfo.PLATFORM_IOS, listIOS, system);
            if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) {
                iosPushService.pushWelfareCenter(uid, title, content, codes);
            }
        }
        /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listAndroid == null || listAndroid.size() > 0) {
            // 限制推送版本号:36
            String versions = getEffectiveVersions(36, AppVersionInfo.PLATFORM_ANDROID, listAndroid,system);
            if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) {
                xmPushService.pushWelfareCenter(uid, title, content, versions);
            }
        }
        /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listAndroid == null || listAndroid.size() > 0) {
            // 限制推送版本号:36
            String versions = getEffectiveVersions(36, AppVersionInfo.PLATFORM_ANDROID, listAndroid, system);
            if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) {
                xmPushService.pushWelfareCenter(uid, title, content, versions);
            }
        }
        // 华为推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
            hwPushService.pushWelfareCenter(uid, title, content, versionCodeList);
        }
        // 华为推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
            hwPushService.pushWelfareCenter(uid, new PushBaseContent(title, content, versionCodeList, system));
        }
        // OPPO推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
            oPPOPushService.pushWelfareCenter(uid, title, content, versionCodeList);
        }
        // OPPO推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
            oPPOPushService.pushWelfareCenter(uid, new PushBaseContent(title, content, versionCodeList, system));
        }
        // VIVO推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
            vIVOPushService.pushWelfareCenter(uid, title, content, versionCodeList);
        }
        // VIVO推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
            vIVOPushService.pushWelfareCenter(uid, new PushBaseContent(title, content, versionCodeList, system));
        }
        // 插入推送记录
        PushRecord pushRecord = new PushRecord();
        pushRecord.setTitle(title);
        pushRecord.setUid(uid);
        pushRecord.setState(1); // 成功
        pushRecord.setType(PushTypeEnum.welfare.getCode()); // 类型:百川
        pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
        pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
        pushRecordMapper.insertSelective(pushRecord);
    }
        // 插入推送记录
        PushRecord pushRecord = new PushRecord();
        pushRecord.setTitle(title);
        pushRecord.setUid(uid);
        pushRecord.setState(1); // 成功
        pushRecord.setType(PushTypeEnum.welfare.getCode()); // 类型:百川
        pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
        pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
        pushRecordMapper.insertSelective(pushRecord);
    }
    /**
     * 查询能推送版本号
     *
     * @param listVersion
     * @return
     */
    private String getEffectiveVersions(int minCode, String type, List<String> listVersion, SystemEnum system) throws PushException {
    /**
     * 查询能推送版本号
     *
     * @param listVersion
     * @return
     */
    private String getEffectiveVersions(int minCode, String type, List<String> listVersion, SystemEnum system) throws PushException {
        if (minCode == 0 && listVersion == null) {
            return null;
        }
        if (minCode == 0 && listVersion == null) {
            return null;
        }
        String versions = "";
        if (listVersion == null) {
            List<AppVersionInfo> list = appVersionService.listByPlatformAndMinVersionCode(type, minCode,system);
            if (list != null) {
                for (AppVersionInfo appVersion : list) {
                    versions += appVersion.getVersion() + ",";
                }
            }
        } else {
            List<AppVersionInfo> list = appVersionService.listByVersions(type, listVersion,system);
            if (list != null) {
                for (AppVersionInfo appVersion : list) {
                    Integer code = appVersion.getVersionCode();
                    if (code != null && code >= minCode) {
                        versions += appVersion.getVersion() + ",";
                    }
                }
            }
        }
        String versions = "";
        if (listVersion == null) {
            List<AppVersionInfo> list = appVersionService.listByPlatformAndMinVersionCode(type, minCode, system);
            if (list != null) {
                for (AppVersionInfo appVersion : list) {
                    versions += appVersion.getVersion() + ",";
                }
            }
        } else {
            List<AppVersionInfo> list = appVersionService.listByVersions(type, listVersion, system);
            if (list != null) {
                for (AppVersionInfo appVersion : list) {
                    Integer code = appVersion.getVersionCode();
                    if (code != null && code >= minCode) {
                        versions += appVersion.getVersion() + ",";
                    }
                }
            }
        }
        if (versions.endsWith(",")) {
            versions = versions.substring(0, versions.length() - 1);
        }
        if (versions.endsWith(",")) {
            versions = versions.substring(0, versions.length() - 1);
        }
        return versions;
    }
        return versions;
    }
    /**
     * 查询能推送版本号code
     *
     * @param listVersion
     * @return
     */
    private String getEffectiveVersionCodes(int minCode, String type, List<String> listVersion,SystemEnum system) throws PushException {
    /**
     * 查询能推送版本号code
     *
     * @param listVersion
     * @return
     */
    private String getEffectiveVersionCodes(int minCode, String type, List<String> listVersion, SystemEnum system) throws PushException {
        if (minCode == 0 && listVersion == null) {
            return null;
        }
        if (minCode == 0 && listVersion == null) {
            return null;
        }
        String versionCodes = "";
        if (listVersion == null) {
            List<AppVersionInfo> list = appVersionService.listByPlatformAndMinVersionCode(type, minCode,system);
            if (list != null) {
                for (AppVersionInfo appVersion : list) {
                    versionCodes += appVersion.getVersionCode() + ",";
                }
            }
        } else {
            List<AppVersionInfo> list = appVersionService.listByVersions(type, listVersion,system);
            if (list != null) {
                for (AppVersionInfo appVersion : list) {
                    Integer code = appVersion.getVersionCode();
                    if (code != null && code >= minCode) {
                        versionCodes += appVersion.getVersionCode() + ",";
                    }
                }
            }
        }
        String versionCodes = "";
        if (listVersion == null) {
            List<AppVersionInfo> list = appVersionService.listByPlatformAndMinVersionCode(type, minCode, system);
            if (list != null) {
                for (AppVersionInfo appVersion : list) {
                    versionCodes += appVersion.getVersionCode() + ",";
                }
            }
        } else {
            List<AppVersionInfo> list = appVersionService.listByVersions(type, listVersion, system);
            if (list != null) {
                for (AppVersionInfo appVersion : list) {
                    Integer code = appVersion.getVersionCode();
                    if (code != null && code >= minCode) {
                        versionCodes += appVersion.getVersionCode() + ",";
                    }
                }
            }
        }
        if (versionCodes.endsWith(",")) {
            versionCodes = versionCodes.substring(0, versionCodes.length() - 1);
        }
        if (versionCodes.endsWith(",")) {
            versionCodes = versionCodes.substring(0, versionCodes.length() - 1);
        }
        return versionCodes;
    }
        return versionCodes;
    }
    @Override
    public void pushUserSignInNotification(Long uid, String title, String content, List<String> listIOS,
            List<String> listAndroid,SystemEnum system) throws PushException {
        if (StringUtil.isNullOrEmpty(title))
            throw new PushException(1, "无推送标题");
        if (StringUtil.isNullOrEmpty(content))
            throw new PushException(1, "无推送内容");
    @Override
    public void pushUserSignInNotification(Long uid, String title, String content, List<String> listIOS,
                                           List<String> listAndroid, SystemEnum system) throws PushException {
        if (StringUtil.isNullOrEmpty(title))
            throw new PushException(1, "无推送标题");
        if (StringUtil.isNullOrEmpty(content))
            throw new PushException(1, "无推送内容");
        /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listIOS == null || listIOS.size() > 0) {
            // 限制推送版本号:1.6.5以后
            String codes = getEffectiveVersionCodes(60, AppVersionInfo.PLATFORM_IOS, listIOS,system);
            if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) {
                iosPushService.pushUserSignInNotification(uid, title, content, codes);
            }
        }
        /* IOS端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listIOS == null || listIOS.size() > 0) {
            // 限制推送版本号:1.6.5以后
            String codes = getEffectiveVersionCodes(60, AppVersionInfo.PLATFORM_IOS, listIOS, system);
            if (listIOS == null || (listIOS.size() > 0 && codes != null && codes.trim().length() > 0)) {
                iosPushService.pushUserSignInNotification(uid, title, content, codes);
            }
        }
        /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listAndroid == null || listAndroid.size() > 0) {
            // 限制推送版本号:1.6.5以后
            String versions = getEffectiveVersions(47, AppVersionInfo.PLATFORM_ANDROID, listAndroid,system);
            if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) {
                xmPushService.pushUserSignInNotification(uid, title, content, versions);
            }
        }
        /* Android端推送 (注明:list等于 'null' 时全推, size等于0 不做推送) */
        if (listAndroid == null || listAndroid.size() > 0) {
            // 限制推送版本号:1.6.5以后
            String versions = getEffectiveVersions(47, AppVersionInfo.PLATFORM_ANDROID, listAndroid, system);
            if (listAndroid == null || (listAndroid.size() > 0 && versions != null && versions.trim().length() > 0)) {
                xmPushService.pushUserSignInNotification(uid, title, content, versions);
            }
        }
        // 华为推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
            hwPushService.pushUserSignInNotification(uid, title, content, versionCodeList);
        }
        // 华为推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
            hwPushService.pushUserSignInNotification(uid, new PushBaseContent(title, content, versionCodeList, system));
        }
        // OPPO推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
            oPPOPushService.pushUserSignInNotification(uid, title, content, versionCodeList);
        }
        // OPPO推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
            oPPOPushService.pushUserSignInNotification(uid, new PushBaseContent(title, content, versionCodeList, system));
        }
        // VIVO推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid,system);
            vIVOPushService.pushUserSignInNotification(uid, title, content, versionCodeList);
        }
        // VIVO推送
        if (listAndroid == null || listAndroid.size() > 0) {
            List<Integer> versionCodeList = null;
            if (listAndroid != null)
                versionCodeList = appVersionService.listVersionCodeByVersions("android", listAndroid, system);
            vIVOPushService.pushUserSignInNotification(uid, new PushBaseContent(title, content, versionCodeList, system));
        }
        // 插入推送记录
        PushRecord pushRecord = new PushRecord();
        pushRecord.setTitle(title);
        pushRecord.setUid(uid);
        pushRecord.setState(1); // 成功
        pushRecord.setType(PushTypeEnum.signin.getCode()); // 类型:百川
        pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
        pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
        pushRecordMapper.insertSelective(pushRecord);
    }
        // 插入推送记录
        PushRecord pushRecord = new PushRecord();
        pushRecord.setTitle(title);
        pushRecord.setUid(uid);
        pushRecord.setState(1); // 成功
        pushRecord.setType(PushTypeEnum.signin.getCode()); // 类型:百川
        pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
        pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
        pushRecordMapper.insertSelective(pushRecord);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/push/VIVOPushServiceImpl.java
@@ -8,6 +8,8 @@
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;
@@ -37,10 +39,10 @@
    @Resource
    private UserCustomSettingsService userCustomSettingsService;
    private List<Integer> getVersionCodeList(List<Integer> versionCodeList) {
    private List<Integer> getVersionCodeList(List<Integer> versionCodeList, SystemEnum system) {
        List<Integer> versionList = new ArrayList<>();
        if (versionCodeList == null) {// 全推
            List<AppVersionInfo> appInfoList = appVersionService.listByPlatformAndMinVersionCode("android", 51);
            List<AppVersionInfo> appInfoList = appVersionService.listByPlatformAndMinVersionCode("android", 51,system);
            if (appInfoList != null)
                for (AppVersionInfo version : appInfoList) {
                    versionList.add(version.getVersionCode());
@@ -58,50 +60,50 @@
    @Async("pushExecutor")
    @Override
    public void pushGoods(Long uid, Long auctionId, String title, String content, List<Integer> versionCodeList)
    public void pushGoods(Long uid, Long auctionId, PushBaseContent content)
            throws PushException {
        push(PushTypeEnum.goodsdetail, uid, title, content, null, null, auctionId, versionCodeList);
        push(PushTypeEnum.goodsdetail, uid,  null, null, auctionId, content);
    }
    @Async("pushExecutor")
    @Override
    public void pushUrl(Long uid, String url, String title, String content, List<Integer> versionCodeList)
    public void pushUrl(Long uid, String url, PushBaseContent content)
            throws PushException {
        push(PushTypeEnum.url, uid, title, content, null, url, null, versionCodeList);
        push(PushTypeEnum.url, uid, null, url, null, content);
    }
    @Async("pushExecutor")
    @Override
    public void pushZNX(Long uid, String title, String content, List<Integer> versionCodeList) throws PushException {
        push(PushTypeEnum.ZNX, uid, title, content, null, null, null, versionCodeList);
    public void pushZNX(Long uid, PushBaseContent content) throws PushException {
        push(PushTypeEnum.ZNX, uid,  null, null, null, content);
    }
    @Async("pushExecutor")
    @Override
    public void pushWEEX(Long uid, String title, String content, String weexUrl, List<Integer> versionCodeList)
    public void pushWEEX(Long uid,  String weexUrl, PushBaseContent content)
            throws PushException {
        push(PushTypeEnum.weex, uid, title, content, weexUrl, null, null, versionCodeList);
        push(PushTypeEnum.weex, uid,  weexUrl, null, null, content);
    }
    @Async("pushExecutor")
    @Override
    public void pushBaiChuanUrl(Long uid, String title, String content, String url, List<Integer> versionCodeList)
    public void pushBaiChuanUrl(Long uid, String url, PushBaseContent content)
            throws PushException {
        push(PushTypeEnum.baichuan, uid, title, content, null, url, null, versionCodeList);
        push(PushTypeEnum.baichuan, uid,  null, url, null, content);
    }
    @Async("pushExecutor")
    @Override
    public void pushWelfareCenter(Long uid, String title, String content, List<Integer> versionCodeList)
    public void pushWelfareCenter(Long uid, PushBaseContent content)
            throws PushException {
        push(PushTypeEnum.welfare, uid, title, content, null, null, null, versionCodeList);
        push(PushTypeEnum.welfare, uid,  null, null, null, content);
    }
    @Override
    public void pushUserSignInNotification(Long uid, String title, String content, List<Integer> versionCodeList)
    public void pushUserSignInNotification(Long uid, PushBaseContent content)
            throws PushException {
        push(PushTypeEnum.signin, uid, title, content, null, null, null, versionCodeList);
        push(PushTypeEnum.signin, uid, null, null, null, content);
    }
    private List<DeviceTokenVIVO> filterDeviceToken(List<DeviceTokenVIVO> deviceList, int hour) {
@@ -138,16 +140,14 @@
     * 
     * @param type
     * @param uid
     * @param title
     * @param content
     * @param url
     * @param webUrl
     * @param versionCodeList
     */
    private void push(PushTypeEnum type, Long uid, String title, String content, String url, String webUrl,
            Long goodsId, List<Integer> versionCodeList) throws PushException {
    private void push(PushTypeEnum type, Long uid, String url, String webUrl,
            Long goodsId, PushBaseContent content) throws PushException {
        int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
        List<Integer> newVersionList = getVersionCodeList(versionCodeList);
        List<Integer> newVersionList = getVersionCodeList(content.getVersionCodeList(),content.getSystem());
        // 2.0.1后开始推送
        for (int i = 0; i < newVersionList.size(); i++) {
            if (newVersionList.get(i) < 51)
@@ -169,25 +169,25 @@
                    if (type == PushTypeEnum.goodsdetail) {// 商品详情
                        if (goodsId == null)
                            throw new PushException(2, "参数不完整");
                        VIVOPushUtil.pushGoods(tokenList, title, content, 1, goodsId);
                        VIVOPushUtil.pushGoods(tokenList, content.getTitle(),content.getContent(), 1, goodsId);
                    } else if (type == PushTypeEnum.url) {// 链接
                        if (StringUtil.isNullOrEmpty(webUrl))
                            throw new PushException(2, "参数不完整");
                        VIVOPushUtil.pushUrl(tokenList, title, content, webUrl);
                        VIVOPushUtil.pushUrl(tokenList,  content.getTitle(),content.getContent(),  webUrl);
                    } else if (type == PushTypeEnum.ZNX) {// 站内信
                        VIVOPushUtil.pushZNX(tokenList, title, content);
                        VIVOPushUtil.pushZNX(tokenList,  content.getTitle(),content.getContent());
                    } else if (type == PushTypeEnum.weex) {// weex
                        if (StringUtil.isNullOrEmpty(url))
                            throw new PushException(2, "参数不完整");
                        VIVOPushUtil.pushWEEX(tokenList, title, content, url);
                        VIVOPushUtil.pushWEEX(tokenList,  content.getTitle(),content.getContent(),  url);
                    } else if (type == PushTypeEnum.baichuan) {// 百川链接
                        if (StringUtil.isNullOrEmpty(webUrl))
                            throw new PushException(2, "参数不完整");
                        VIVOPushUtil.pushBaiChuanUrl(tokenList, title, content, webUrl);
                        VIVOPushUtil.pushBaiChuanUrl(tokenList,  content.getTitle(),content.getContent(),  webUrl);
                    } else if (type == PushTypeEnum.welfare) {// 福利中心
                        VIVOPushUtil.pushWelfareCenter(tokenList, title, content);
                        VIVOPushUtil.pushWelfareCenter(tokenList,  content.getTitle(),content.getContent());
                    } else if (type == PushTypeEnum.signin) {// 签到
                        VIVOPushUtil.pushUserSignInNotification(tokenList, title, content);
                        VIVOPushUtil.pushUserSignInNotification(tokenList,  content.getTitle(),content.getContent());
                    }
                } catch (Exception e) {
                    PushLogHelper.hwError(e);
@@ -210,25 +210,25 @@
                if (type == PushTypeEnum.goodsdetail) {// 商品详情
                    if (goodsId == null)
                        throw new PushException(2, "参数不完整");
                    VIVOPushUtil.pushGoods(tokenList, title, content, 1, goodsId);
                    VIVOPushUtil.pushGoods(tokenList, content.getTitle(), content.getContent(), 1, goodsId);
                } else if (type == PushTypeEnum.url) {// 链接
                    if (StringUtil.isNullOrEmpty(webUrl))
                        throw new PushException(2, "参数不完整");
                    VIVOPushUtil.pushUrl(tokenList, title, content, webUrl);
                    VIVOPushUtil.pushUrl(tokenList, content.getTitle(), content.getContent(), webUrl);
                } else if (type == PushTypeEnum.ZNX) {// 站内信
                    VIVOPushUtil.pushZNX(tokenList, title, content);
                    VIVOPushUtil.pushZNX(tokenList, content.getTitle(), content.getContent());
                } else if (type == PushTypeEnum.weex) {// weex
                    if (StringUtil.isNullOrEmpty(url))
                        throw new PushException(2, "参数不完整");
                    VIVOPushUtil.pushWEEX(tokenList, title, content, url);
                    VIVOPushUtil.pushWEEX(tokenList, content.getTitle(), content.getContent(), url);
                } else if (type == PushTypeEnum.baichuan) {// 百川链接
                    if (StringUtil.isNullOrEmpty(webUrl))
                        throw new PushException(2, "参数不完整");
                    VIVOPushUtil.pushBaiChuanUrl(tokenList, title, content, webUrl);
                    VIVOPushUtil.pushBaiChuanUrl(tokenList, content.getTitle(), content.getContent(), webUrl);
                } else if (type == PushTypeEnum.welfare) {// 福利中心
                    VIVOPushUtil.pushWelfareCenter(tokenList, title, content);
                    VIVOPushUtil.pushWelfareCenter(tokenList, content.getTitle(), content.getContent());
                } else if (type == PushTypeEnum.signin) {// 签到
                    VIVOPushUtil.pushUserSignInNotification(tokenList, title, content);
                    VIVOPushUtil.pushUserSignInNotification(tokenList,content.getTitle(), content.getContent());
                }
            } catch (Exception e) {
                PushLogHelper.vivoError(e);
fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderPayServiceImpl.java
@@ -6,6 +6,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yeshi.utils.NumberUtil;
@@ -55,385 +56,389 @@
@Service
public class BanLiShopOrderPayServiceImpl implements BanLiShopOrderPayService {
    @Resource
    private BanLiShopGoodsSetService banLiShopGoodsSetService;
    @Resource
    private BanLiShopGoodsSetService banLiShopGoodsSetService;
    @Resource
    private BanLiShopGoodsService banLiShopGoodsService;
    @Resource
    private BanLiShopGoodsService banLiShopGoodsService;
    @Resource
    private BanLiShopGoodsClassService banLiShopGoodsClassService;
    @Resource
    private BanLiShopGoodsClassService banLiShopGoodsClassService;
    @Resource
    private RedPackBalanceService redPackBalanceService;
    @Resource
    private RedPackBalanceService redPackBalanceService;
    @Resource
    private BanLiShopOrderService banLiShopOrderService;
    @Resource
    private BanLiShopOrderService banLiShopOrderService;
    @Resource
    private RedPackDetailService redPackDetailService;
    @Resource
    private RedPackDetailService redPackDetailService;
    @Resource
    private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
    @Resource
    private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
    @Resource
    private ConfigService configService;
    @Resource
    private ConfigService configService;
    @Resource
    private AdminUserService adminUserService;
    @Resource
    private AdminUserService adminUserService;
    @Resource
    private RocketMQManager rocketMQManager;
    @Resource
    private RocketMQManager rocketMQManager;
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void payOrderByHongBao(Long orderId) throws BanLiShopOrderException, RedPackBalanceException {
        BanLiShopOrder order = banLiShopOrderService.selectByPrimaryKeyForUpdate(orderId);
        if (order == null) {
            throw new BanLiShopOrderException(1, "订单不存在");
        }
        if (order.getHongBaoPayment() == null)
            return;
    @Resource
    private UserInfoService userInfoService;
        if (order.getHongBaoPaymentState() != null && order.getHongBaoPaymentState() == BanLiShopOrder.PAY_STATE_PAID) {
            throw new BanLiShopOrderException(3, "重复支付");
        }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void payOrderByHongBao(Long orderId) throws BanLiShopOrderException, RedPackBalanceException {
        BanLiShopOrder order = banLiShopOrderService.selectByPrimaryKeyForUpdate(orderId);
        if (order == null) {
            throw new BanLiShopOrderException(1, "订单不存在");
        }
        if (order.getHongBaoPayment() == null)
            return;
        BanLiShopGoods goods = banLiShopGoodsService.selectByPrimaryKey(order.getGoods().getId());
        BanLiShopGoodsClass goodsClass = banLiShopGoodsClassService.selectByPrimaryKey(goods.getGoodsClass().getId());
        BanLiShopGoodsSets set = banLiShopGoodsSetService.selectByPrimaryKey(order.getGoodsSet().getId());
        RedPackDetail detail = null;
        try {
            detail = RedPackDetailFactory.createUseByShopOrder(orderId, order.getUid(), goodsClass.getName(),
                    set.getName(), order.getHongBaoPayment());
        } catch (RedPackDetailException e) {
            e.printStackTrace();
        }
        if (order.getHongBaoPaymentState() != null && order.getHongBaoPaymentState() == BanLiShopOrder.PAY_STATE_PAID) {
            throw new BanLiShopOrderException(3, "重复支付");
        }
        if (detail == null)
            throw new RedPackBalanceException(4, "红包详情失败");
        redPackBalanceService.subRedPack(order.getUid(), order.getHongBaoPayment(), detail);
        BanLiShopGoods goods = banLiShopGoodsService.selectByPrimaryKey(order.getGoods().getId());
        BanLiShopGoodsClass goodsClass = banLiShopGoodsClassService.selectByPrimaryKey(goods.getGoodsClass().getId());
        BanLiShopGoodsSets set = banLiShopGoodsSetService.selectByPrimaryKey(order.getGoodsSet().getId());
        RedPackDetail detail = null;
        try {
            detail = RedPackDetailFactory.createUseByShopOrder(orderId, order.getUid(), goodsClass.getName(),
                    set.getName(), order.getHongBaoPayment());
        } catch (RedPackDetailException e) {
            e.printStackTrace();
        }
        BanLiShopOrder update = new BanLiShopOrder();
        update.setId(order.getId());
        update.setHongBaoPaymentState(BanLiShopOrder.PAY_STATE_PAID);
        // 判断其他待支付项是否已经支付
        update.setUpdateTime(new Date());
        if (order.getState() == BanLiShopOrder.STATE_NO_PAY)
            if ((order.getBalancePaymentState() == null
                    || order.getBalancePaymentState() == BanLiShopOrder.PAY_STATE_PAID)
                    && (order.getMoneyPaymentState() == null
                            || order.getMoneyPaymentState() == BanLiShopOrder.PAY_STATE_PAID))// 其他待支付项已经支付
            {
                update.setState(BanLiShopOrder.STATE_PAID);
                update.setStateDesc("支付成功");
            }
        banLiShopOrderService.udpateSelectiveByPrimaryKey(update);
        if (update.getState() != null && update.getState() == BanLiShopOrder.STATE_PAID) {
            paySuccess(order);
        }
    }
        if (detail == null)
            throw new RedPackBalanceException(4, "红包详情失败");
        redPackBalanceService.subRedPack(order.getUid(), order.getHongBaoPayment(), detail);
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void payOrderByMoney(Long orderId, BigDecimal money) throws BanLiShopOrderException {
        BanLiShopOrder order = banLiShopOrderService.selectByPrimaryKeyForUpdate(orderId);
        if (order == null) {
            throw new BanLiShopOrderException(1, "订单不存在");
        }
        if (order.getMoneyPayment() == null)
            throw new BanLiShopOrderException(2, "不需要采用现金支付");
        BanLiShopOrder update = new BanLiShopOrder();
        update.setId(order.getId());
        update.setHongBaoPaymentState(BanLiShopOrder.PAY_STATE_PAID);
        // 判断其他待支付项是否已经支付
        update.setUpdateTime(new Date());
        if (order.getState() == BanLiShopOrder.STATE_NO_PAY)
            if ((order.getBalancePaymentState() == null
                    || order.getBalancePaymentState() == BanLiShopOrder.PAY_STATE_PAID)
                    && (order.getMoneyPaymentState() == null
                    || order.getMoneyPaymentState() == BanLiShopOrder.PAY_STATE_PAID))// 其他待支付项已经支付
            {
                update.setState(BanLiShopOrder.STATE_PAID);
                update.setStateDesc("支付成功");
            }
        banLiShopOrderService.udpateSelectiveByPrimaryKey(update);
        if (update.getState() != null && update.getState() == BanLiShopOrder.STATE_PAID) {
            paySuccess(order);
        }
    }
        if (order.getMoneyPaymentState() != null && order.getMoneyPaymentState() != BanLiShopOrder.PAY_STATE_NOPAY) {
            throw new BanLiShopOrderException(3, "重复支付");
        }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void payOrderByMoney(Long orderId, BigDecimal money) throws BanLiShopOrderException {
        BanLiShopOrder order = banLiShopOrderService.selectByPrimaryKeyForUpdate(orderId);
        if (order == null) {
            throw new BanLiShopOrderException(1, "订单不存在");
        }
        if (order.getMoneyPayment() == null)
            throw new BanLiShopOrderException(2, "不需要采用现金支付");
        if (order.getMoneyPayment().compareTo(money) > 0) {
            throw new BanLiShopOrderException(4, "支付金额不够");
        }
        if (order.getMoneyPaymentState() != null && order.getMoneyPaymentState() != BanLiShopOrder.PAY_STATE_NOPAY) {
            throw new BanLiShopOrderException(3, "重复支付");
        }
        // 支付成功
        BanLiShopOrder update = new BanLiShopOrder();
        update.setId(order.getId());
        update.setMoneyPaymentState(BanLiShopOrder.PAY_STATE_PAID);
        // 判断其他待支付项是否已经支付
        update.setUpdateTime(new Date());
        if (order.getState() == BanLiShopOrder.STATE_NO_PAY)
            if ((order.getBalancePaymentState() == null
                    || order.getBalancePaymentState() == BanLiShopOrder.PAY_STATE_PAID)
                    && (order.getHongBaoPaymentState() == null
                            || order.getHongBaoPaymentState() == BanLiShopOrder.PAY_STATE_PAID))// 其他待支付项已经支付
            {
                update.setState(BanLiShopOrder.STATE_PAID);
                update.setStateDesc("支付成功");
            }
        banLiShopOrderService.udpateSelectiveByPrimaryKey(update);
        if (update.getState() != null && update.getState() == BanLiShopOrder.STATE_PAID) {
            paySuccess(order);
        }
    }
        if (order.getMoneyPayment().compareTo(money) > 0) {
            throw new BanLiShopOrderException(4, "支付金额不够");
        }
    /**
     * 支付成功
     */
    private void paySuccess(BanLiShopOrder order) {
        ThreadUtil.run(new Runnable() {
        // 支付成功
        BanLiShopOrder update = new BanLiShopOrder();
        update.setId(order.getId());
        update.setMoneyPaymentState(BanLiShopOrder.PAY_STATE_PAID);
        // 判断其他待支付项是否已经支付
        update.setUpdateTime(new Date());
        if (order.getState() == BanLiShopOrder.STATE_NO_PAY)
            if ((order.getBalancePaymentState() == null
                    || order.getBalancePaymentState() == BanLiShopOrder.PAY_STATE_PAID)
                    && (order.getHongBaoPaymentState() == null
                    || order.getHongBaoPaymentState() == BanLiShopOrder.PAY_STATE_PAID))// 其他待支付项已经支付
            {
                update.setState(BanLiShopOrder.STATE_PAID);
                update.setStateDesc("支付成功");
            }
        banLiShopOrderService.udpateSelectiveByPrimaryKey(update);
        if (update.getState() != null && update.getState() == BanLiShopOrder.STATE_PAID) {
            paySuccess(order);
        }
    }
            @Override
            public void run() {
                long[] targetUids = new long[] { 3L, 4L };
                Config config = configService.getConfig(ConfigKeyEnum.extractCodeEmailFrom.getKey(), SystemEnum.blks);
                String[] sts = config.getValue().split(",");
                String account = sts[0];
                String pwd = sts[1];
                for (long adminId : targetUids) {
                    AdminUser adminUser = adminUserService.selectByPrimaryKey(adminId);
                    String msg = "有新的红包商城订单";
                    boolean isS = MailSenderUtil.sendEmail(adminUser.getEmail(), account, pwd, "有新的红包商城订单", msg);
                }
            }
        });
    /**
     * 支付成功
     */
    private void paySuccess(BanLiShopOrder order) {
        ThreadUtil.run(new Runnable() {
    }
            @Override
            public void run() {
                SystemEnum system = userInfoService.getUserSystem(order.getUid());
                long[] targetUids = new long[]{3L, 4L};
                Config config = configService.getConfig(ConfigKeyEnum.extractCodeEmailFrom.getKey(),system);
                String[] sts = config.getValue().split(",");
                String account = sts[0];
                String pwd = sts[1];
                for (long adminId : targetUids) {
                    AdminUser adminUser = adminUserService.selectByPrimaryKey(adminId);
                    String msg = "有新的红包商城订单";
                    boolean isS = MailSenderUtil.sendEmail(adminUser.getEmail(), account, pwd, "有新的红包商城订单", msg);
                }
            }
        });
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void refund(Long orderId) throws BanLiShopOrderException {
        // 订单退款
        // 查询订单是否已经被拒绝
        BanLiShopOrder order = banLiShopOrderService.selectByPrimaryKeyForUpdate(orderId);
        if (order == null)
            throw new BanLiShopOrderException(1, "订单不存在");
        if (order.getState() == BanLiShopOrder.STATE_REJECT_REFUND_FAIL
                || order.getState() == BanLiShopOrder.STATE_REJECT_REFUND_SUCCESS)
            throw new BanLiShopOrderException(2, "订单未被拒绝/订单已退款");
    }
        BanLiShopOrder update = new BanLiShopOrder();
        update.setId(order.getId());
        if (order.getHongBaoPaymentState() != null && order.getHongBaoPaymentState() == BanLiShopOrder.PAY_STATE_PAID) {
            BanLiShopGoods goods = banLiShopGoodsService.selectByPrimaryKey(order.getGoods().getId());
            BanLiShopGoodsClass goodsClass = banLiShopGoodsClassService
                    .selectByPrimaryKey(goods.getGoodsClass().getId());
            BanLiShopGoodsSets set = banLiShopGoodsSetService.selectByPrimaryKey(order.getGoodsSet().getId());
            // 红包退款
            RedPackDetail detail = null;
            try {
                detail = RedPackDetailFactory.createShopOrderDrawBack(orderId, order.getUid(), goodsClass.getName(),
                        set.getName(), order.getHongBaoPayment());
            } catch (RedPackDetailException e) {
                e.printStackTrace();
            }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void refund(Long orderId) throws BanLiShopOrderException {
        // 订单退款
        // 查询订单是否已经被拒绝
        BanLiShopOrder order = banLiShopOrderService.selectByPrimaryKeyForUpdate(orderId);
        if (order == null)
            throw new BanLiShopOrderException(1, "订单不存在");
        if (order.getState() == BanLiShopOrder.STATE_REJECT_REFUND_FAIL
                || order.getState() == BanLiShopOrder.STATE_REJECT_REFUND_SUCCESS)
            throw new BanLiShopOrderException(2, "订单未被拒绝/订单已退款");
            if (detail == null)
                throw new BanLiShopOrderException(4, "红包详情失败");
            try {
                redPackBalanceService.addRedPack(order.getUid(), order.getHongBaoPayment(), detail);
            } catch (RedPackBalanceException e) {
                throw new BanLiShopOrderException(5, "红包退款失败");
            }
            update.setHongBaoPaymentState(BanLiShopOrder.PAY_STATE_REFUND);
            order.setHongBaoPaymentState(BanLiShopOrder.PAY_STATE_REFUND);
        }
        BanLiShopOrder update = new BanLiShopOrder();
        update.setId(order.getId());
        if (order.getHongBaoPaymentState() != null && order.getHongBaoPaymentState() == BanLiShopOrder.PAY_STATE_PAID) {
            BanLiShopGoods goods = banLiShopGoodsService.selectByPrimaryKey(order.getGoods().getId());
            BanLiShopGoodsClass goodsClass = banLiShopGoodsClassService
                    .selectByPrimaryKey(goods.getGoodsClass().getId());
            BanLiShopGoodsSets set = banLiShopGoodsSetService.selectByPrimaryKey(order.getGoodsSet().getId());
            // 红包退款
            RedPackDetail detail = null;
            try {
                detail = RedPackDetailFactory.createShopOrderDrawBack(orderId, order.getUid(), goodsClass.getName(),
                        set.getName(), order.getHongBaoPayment());
            } catch (RedPackDetailException e) {
                e.printStackTrace();
            }
        if (order.getMoneyPaymentState() != null && order.getMoneyPaymentState() == BanLiShopOrder.PAY_STATE_PAID) {
            try {
                boolean success = BanLiShopWXPayUtil.refund(order.getOrderNo(), order.getMoneyPayment());
                if (success) {
                    update.setMoneyPaymentState(BanLiShopOrder.PAY_STATE_REFUNDING);
                    order.setMoneyPaymentState(BanLiShopOrder.PAY_STATE_REFUNDING);
                    // 发送退款消息
                    BanLiShopOrderMQMsg msg = new BanLiShopOrderMQMsg(order.getId(), order.getUid());
                    Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER,
                            OrderTopicTagEnum.banLiShopOrderRefund, msg);
                    SendResult result = rocketMQManager.sendNormalMsg(message, 1000 * 60 * 5L,null);
                    if (result == null) {
                        throw new BanLiShopOrderException(8, "消息发送失败");
                    }
                } else
                    throw new BanLiShopOrderException(6, "微信支付退款失败");
            } catch (WXOrderException e) {
                throw new BanLiShopOrderException(6, "微信支付退款失败");
            }
        }
        // 检查 是否退款成功
        if (order.getMoneyPaymentState() != null
                && order.getMoneyPaymentState() == BanLiShopOrder.PAY_STATE_REFUNDING) {
            try {
                boolean isS = BanLiShopWXPayUtil.isRefundSuccess(order.getOrderNo());
                if (isS) {
                    update.setMoneyPaymentState(BanLiShopOrder.PAY_STATE_REFUND);
                    order.setMoneyPaymentState(BanLiShopOrder.PAY_STATE_REFUND);
                }
            } catch (WXOrderException e) {
                throw new BanLiShopOrderException(7, "微信支付退款查询失败");
            }
        }
            if (detail == null)
                throw new BanLiShopOrderException(4, "红包详情失败");
            try {
                redPackBalanceService.addRedPack(order.getUid(), order.getHongBaoPayment(), detail);
            } catch (RedPackBalanceException e) {
                throw new BanLiShopOrderException(5, "红包退款失败");
            }
            update.setHongBaoPaymentState(BanLiShopOrder.PAY_STATE_REFUND);
            order.setHongBaoPaymentState(BanLiShopOrder.PAY_STATE_REFUND);
        }
        if (update.getHongBaoPaymentState() != null || update.getMoneyPaymentState() != null) {
            // 获取整个订单的退款状态
            int state = getRefundState(order);
            update.setState(state);
            update.setUpdateTime(new Date());
            banLiShopOrderService.udpateSelectiveByPrimaryKey(update);
        }
    }
        if (order.getMoneyPaymentState() != null && order.getMoneyPaymentState() == BanLiShopOrder.PAY_STATE_PAID) {
            try {
                boolean success = BanLiShopWXPayUtil.refund(order.getOrderNo(), order.getMoneyPayment());
                if (success) {
                    update.setMoneyPaymentState(BanLiShopOrder.PAY_STATE_REFUNDING);
                    order.setMoneyPaymentState(BanLiShopOrder.PAY_STATE_REFUNDING);
                    // 发送退款消息
                    BanLiShopOrderMQMsg msg = new BanLiShopOrderMQMsg(order.getId(), order.getUid());
                    Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER,
                            OrderTopicTagEnum.banLiShopOrderRefund, msg);
                    SendResult result = rocketMQManager.sendNormalMsg(message, 1000 * 60 * 5L, null);
                    if (result == null) {
                        throw new BanLiShopOrderException(8, "消息发送失败");
                    }
                } else
                    throw new BanLiShopOrderException(6, "微信支付退款失败");
            } catch (WXOrderException e) {
                throw new BanLiShopOrderException(6, "微信支付退款失败");
            }
        }
        // 检查 是否退款成功
        if (order.getMoneyPaymentState() != null
                && order.getMoneyPaymentState() == BanLiShopOrder.PAY_STATE_REFUNDING) {
            try {
                boolean isS = BanLiShopWXPayUtil.isRefundSuccess(order.getOrderNo());
                if (isS) {
                    update.setMoneyPaymentState(BanLiShopOrder.PAY_STATE_REFUND);
                    order.setMoneyPaymentState(BanLiShopOrder.PAY_STATE_REFUND);
                }
            } catch (WXOrderException e) {
                throw new BanLiShopOrderException(7, "微信支付退款查询失败");
            }
        }
    /**
     * 获取整个退款状态
     *
     * @param order
     * @return
     */
    private int getRefundState(BanLiShopOrder order) {
        int refundCount = 0;
        int refundSuccessCount = 0;
        if (update.getHongBaoPaymentState() != null || update.getMoneyPaymentState() != null) {
            // 获取整个订单的退款状态
            int state = getRefundState(order);
            update.setState(state);
            update.setUpdateTime(new Date());
            banLiShopOrderService.udpateSelectiveByPrimaryKey(update);
        }
    }
        if (order.getHongBaoPayment() != null) {
            refundCount++;
            if (order.getHongBaoPaymentState() != null
                    && order.getHongBaoPaymentState() == BanLiShopOrder.PAY_STATE_REFUND)
                refundSuccessCount++;
        }
    /**
     * 获取整个退款状态
     *
     * @param order
     * @return
     */
    private int getRefundState(BanLiShopOrder order) {
        int refundCount = 0;
        int refundSuccessCount = 0;
        if (order.getBalancePayment() != null) {
            refundCount++;
            if (order.getBalancePaymentState() != null
                    && order.getBalancePaymentState() == BanLiShopOrder.PAY_STATE_REFUND)
                refundSuccessCount++;
        }
        if (order.getHongBaoPayment() != null) {
            refundCount++;
            if (order.getHongBaoPaymentState() != null
                    && order.getHongBaoPaymentState() == BanLiShopOrder.PAY_STATE_REFUND)
                refundSuccessCount++;
        }
        if (order.getMoneyPayment() != null) {
            refundCount++;
            if (order.getMoneyPaymentState() != null && order.getMoneyPaymentState() == BanLiShopOrder.PAY_STATE_REFUND)
                refundSuccessCount++;
        }
        if (order.getBalancePayment() != null) {
            refundCount++;
            if (order.getBalancePaymentState() != null
                    && order.getBalancePaymentState() == BanLiShopOrder.PAY_STATE_REFUND)
                refundSuccessCount++;
        }
        if (refundCount == refundSuccessCount)
            return BanLiShopOrder.STATE_REJECT_REFUND_SUCCESS;// 退款成功
        else {
            if (refundSuccessCount == 0)
                return BanLiShopOrder.STATE_REJECT;// 退款中
            else
                return BanLiShopOrder.STATE_REJECT_REFUND_PART_SUCCESS;// 部分退款成功
        }
    }
        if (order.getMoneyPayment() != null) {
            refundCount++;
            if (order.getMoneyPaymentState() != null && order.getMoneyPaymentState() == BanLiShopOrder.PAY_STATE_REFUND)
                refundSuccessCount++;
        }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void charge(Long orderId) throws BanLiShopOrderException {
        BanLiShopOrder order = banLiShopOrderService.selectByPrimaryKey(orderId);
        if (order == null)
            throw new BanLiShopOrderException(1, "订单不存在");
        if (order.getState() != BanLiShopOrder.STATE_PAID) {
            throw new BanLiShopOrderException(100, "订单不是处于付款状态");
        }
        if (order.getChargeAccountType() == ChargeTypeEnum.phone) {
            if (!StringUtil.isMobile(order.getChargeAccount())) {
                throw new BanLiShopOrderException(101, "电话号码格式不正确");
            }
        } else if (order.getChargeAccountType() == ChargeTypeEnum.qq) {
            if (!NumberUtil.isNumeric(order.getChargeAccount())) {
                throw new BanLiShopOrderException(101, "QQ号格式错误");
            }
        } else {
            throw new BanLiShopOrderException(102, "非充值商品");
        }
        // 获取福禄的套餐
        BanLiShopGoodsSets set = banLiShopGoodsSetService.selectByPrimaryKey(order.getGoodsSet().getId());
        if (set == null) {
            throw new BanLiShopOrderException(104, "商品套餐已下线");
        }
        if (refundCount == refundSuccessCount)
            return BanLiShopOrder.STATE_REJECT_REFUND_SUCCESS;// 退款成功
        else {
            if (refundSuccessCount == 0)
                return BanLiShopOrder.STATE_REJECT;// 退款中
            else
                return BanLiShopOrder.STATE_REJECT_REFUND_PART_SUCCESS;// 部分退款成功
        }
    }
        if (StringUtil.isNullOrEmpty(set.getChargeFuLuNum())) {
            throw new BanLiShopOrderException(105, "福禄充值ID为空");
        }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void charge(Long orderId) throws BanLiShopOrderException {
        BanLiShopOrder order = banLiShopOrderService.selectByPrimaryKey(orderId);
        if (order == null)
            throw new BanLiShopOrderException(1, "订单不存在");
        if (order.getState() != BanLiShopOrder.STATE_PAID) {
            throw new BanLiShopOrderException(100, "订单不是处于付款状态");
        }
        if (order.getChargeAccountType() == ChargeTypeEnum.phone) {
            if (!StringUtil.isMobile(order.getChargeAccount())) {
                throw new BanLiShopOrderException(101, "电话号码格式不正确");
            }
        } else if (order.getChargeAccountType() == ChargeTypeEnum.qq) {
            if (!NumberUtil.isNumeric(order.getChargeAccount())) {
                throw new BanLiShopOrderException(101, "QQ号格式错误");
            }
        } else {
            throw new BanLiShopOrderException(102, "非充值商品");
        }
        // 获取福禄的套餐
        BanLiShopGoodsSets set = banLiShopGoodsSetService.selectByPrimaryKey(order.getGoodsSet().getId());
        if (set == null) {
            throw new BanLiShopOrderException(104, "商品套餐已下线");
        }
        // 改变状态为成功
        BanLiShopOrder update = new BanLiShopOrder(order.getId());
        update.setState(BanLiShopOrder.STATE_SUCCESS);
        update.setStateDesc("充值成功");
        update.setUpdateTime(new Date());
        update.setSuccessTime(new Date());
        banLiShopOrderService.udpateSelectiveByPrimaryKey(update);
        if (StringUtil.isNullOrEmpty(set.getChargeFuLuNum())) {
            throw new BanLiShopOrderException(105, "福禄充值ID为空");
        }
        if (order.getHongBaoPayment() != null && order.getHongBaoPayment().compareTo(new BigDecimal(0)) > 0) {
            // 将红包明细外显
            RedPackDetail detail = null;
            try {
                detail = RedPackDetailFactory.createUseByShopOrder(order.getId(), order.getUid(), "", "",
                        order.getHongBaoPayment());
            } catch (RedPackDetailException e) {
                e.printStackTrace();
            }
        // 改变状态为成功
        BanLiShopOrder update = new BanLiShopOrder(order.getId());
        update.setState(BanLiShopOrder.STATE_SUCCESS);
        update.setStateDesc("充值成功");
        update.setUpdateTime(new Date());
        update.setSuccessTime(new Date());
        banLiShopOrderService.udpateSelectiveByPrimaryKey(update);
            if (detail != null) {
                redPackDetailService.changeDisplayByIdentifyCode(detail.getIdentifyCode(), true);
            }
        }
        if (order.getHongBaoPayment() != null && order.getHongBaoPayment().compareTo(new BigDecimal(0)) > 0) {
            // 将红包明细外显
            RedPackDetail detail = null;
            try {
                detail = RedPackDetailFactory.createUseByShopOrder(order.getId(), order.getUid(), "", "",
                        order.getHongBaoPayment());
            } catch (RedPackDetailException e) {
                e.printStackTrace();
            }
        // 消息发送
        MsgRedPackUseContentDTO dto = new MsgRedPackUseContentDTO();
        dto.setGoodsSetName(order.getOrderGoods().getSetName());
        dto.setHongBao(order.getHongBaoPayment());
        dto.setMoney(order.getMoneyPayment());
        dto.setTime(new Date());
        userMoneyMsgNotificationService.redPackMsg(order.getUid(), MsgTypeMoneyTypeEnum.redPackUseSuccess,
                new Gson().toJson(dto), null);
            if (detail != null) {
                redPackDetailService.changeDisplayByIdentifyCode(detail.getIdentifyCode(), true);
            }
        }
        try {
            if (Constant.IS_TEST) {
                FuLuChargeApiUtil.shaXiangCharge(set.getChargeFuLuNum(), "banlishop" + order.getOrderNo(),
                        order.getChargeAccount());
            } else
                FuLuChargeApiUtil.charge(set.getChargeFuLuNum(), "banlishop" + order.getOrderNo(),
                        order.getChargeAccount());
        } catch (FuLuChargeException e) {
            throw new BanLiShopOrderException(e.getCode(), e.getMsg());
        }
    }
        // 消息发送
        MsgRedPackUseContentDTO dto = new MsgRedPackUseContentDTO();
        dto.setGoodsSetName(order.getOrderGoods().getSetName());
        dto.setHongBao(order.getHongBaoPayment());
        dto.setMoney(order.getMoneyPayment());
        dto.setTime(new Date());
        userMoneyMsgNotificationService.redPackMsg(order.getUid(), MsgTypeMoneyTypeEnum.redPackUseSuccess,
                new Gson().toJson(dto), null);
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void invalidOrderByOrderId(Long orderId, String stateDesc) throws BanLiShopOrderException {
        try {
            if (Constant.IS_TEST) {
                FuLuChargeApiUtil.shaXiangCharge(set.getChargeFuLuNum(), "banlishop" + order.getOrderNo(),
                        order.getChargeAccount());
            } else
                FuLuChargeApiUtil.charge(set.getChargeFuLuNum(), "banlishop" + order.getOrderNo(),
                        order.getChargeAccount());
        } catch (FuLuChargeException e) {
            throw new BanLiShopOrderException(e.getCode(), e.getMsg());
        }
    }
        BanLiShopOrder order = banLiShopOrderService.selectByPrimaryKeyForUpdate(orderId);
        if (order == null)
            return;
        // 退款
        if (order.getState() == BanLiShopOrder.STATE_NO_PAY) {// 状态还是未支付
            // 退款红包
            if (order.getHongBaoPaymentState() != null
                    && order.getHongBaoPaymentState() == BanLiShopOrder.PAY_STATE_PAID) {
                BanLiShopGoods goods = banLiShopGoodsService.selectByPrimaryKey(order.getGoods().getId());
                BanLiShopGoodsClass goodsClass = banLiShopGoodsClassService
                        .selectByPrimaryKey(goods.getGoodsClass().getId());
                BanLiShopGoodsSets set = banLiShopGoodsSetService.selectByPrimaryKey(order.getGoodsSet().getId());
                // 红包退款
                RedPackDetail detail = null;
                try {
                    detail = RedPackDetailFactory.createShopOrderDrawBack(orderId, order.getUid(), goodsClass.getName(),
                            set.getName(), order.getHongBaoPayment());
                } catch (RedPackDetailException e) {
                    e.printStackTrace();
                }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void invalidOrderByOrderId(Long orderId, String stateDesc) throws BanLiShopOrderException {
                if (detail == null)
                    throw new BanLiShopOrderException(4, "红包详情失败");
                try {
                    redPackBalanceService.addRedPack(order.getUid(), order.getHongBaoPayment(), detail);
                } catch (RedPackBalanceException e) {
                    throw new BanLiShopOrderException(5, "红包退款失败");
                }
        BanLiShopOrder order = banLiShopOrderService.selectByPrimaryKeyForUpdate(orderId);
        if (order == null)
            return;
        // 退款
        if (order.getState() == BanLiShopOrder.STATE_NO_PAY) {// 状态还是未支付
            // 退款红包
            if (order.getHongBaoPaymentState() != null
                    && order.getHongBaoPaymentState() == BanLiShopOrder.PAY_STATE_PAID) {
                BanLiShopGoods goods = banLiShopGoodsService.selectByPrimaryKey(order.getGoods().getId());
                BanLiShopGoodsClass goodsClass = banLiShopGoodsClassService
                        .selectByPrimaryKey(goods.getGoodsClass().getId());
                BanLiShopGoodsSets set = banLiShopGoodsSetService.selectByPrimaryKey(order.getGoodsSet().getId());
                // 红包退款
                RedPackDetail detail = null;
                try {
                    detail = RedPackDetailFactory.createShopOrderDrawBack(orderId, order.getUid(), goodsClass.getName(),
                            set.getName(), order.getHongBaoPayment());
                } catch (RedPackDetailException e) {
                    e.printStackTrace();
                }
                BanLiShopOrder update = new BanLiShopOrder(order.getId());
                update.setHongBaoPaymentState(BanLiShopOrder.PAY_STATE_REFUND);
                update.setUpdateTime(new Date());
                banLiShopOrderService.udpateSelectiveByPrimaryKey(update);
            }
                if (detail == null)
                    throw new BanLiShopOrderException(4, "红包详情失败");
                try {
                    redPackBalanceService.addRedPack(order.getUid(), order.getHongBaoPayment(), detail);
                } catch (RedPackBalanceException e) {
                    throw new BanLiShopOrderException(5, "红包退款失败");
                }
            banLiShopOrderService.invalidOrderByOrderId(orderId, stateDesc);
        }
                BanLiShopOrder update = new BanLiShopOrder(order.getId());
                update.setHongBaoPaymentState(BanLiShopOrder.PAY_STATE_REFUND);
                update.setUpdateTime(new Date());
                banLiShopOrderService.udpateSelectiveByPrimaryKey(update);
            }
    }
            banLiShopOrderService.invalidOrderByOrderId(orderId, stateDesc);
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/ShamUserServiceImpl.java
@@ -7,6 +7,8 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.service.inter.common.CommonConfigService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -22,192 +24,195 @@
@Service
public class ShamUserServiceImpl implements ShamUserService {
    @Resource
    private ShamUserMapper shamUserMapper;
    @Resource
    private ShamUserMapper shamUserMapper;
    @Resource
    private ConfigService configService;
    @Resource
    private ConfigService configService;
    @Resource
    private CommonConfigService commonConfigService;
    @Transactional
    public void addShamUser(ShamUser shamUser) {
        shamUserMapper.insertSelective(shamUser);
    }
    @Transactional
    public void addShamUser(ShamUser shamUser) {
        shamUserMapper.insertSelective(shamUser);
    }
    public List<ShamUser> getAll() {
        return shamUserMapper.listAll();
    }
    public List<ShamUser> getAll() {
        return shamUserMapper.listAll();
    }
    public List<ShamUser> findShamUserList(int sum) {
        return shamUserMapper.listShamUserByKey(0, sum, null);
    }
    public List<ShamUser> findShamUserList(int sum) {
        return shamUserMapper.listShamUserByKey(0, sum, null);
    }
    @Override
    public int deleteByPrimaryKey(Long id) {
        return shamUserMapper.deleteByPrimaryKey(id);
    }
    @Override
    public int deleteByPrimaryKey(Long id) {
        return shamUserMapper.deleteByPrimaryKey(id);
    }
    @Override
    public int insert(ShamUser record) {
        return shamUserMapper.insert(record);
    }
    @Override
    public int insert(ShamUser record) {
        return shamUserMapper.insert(record);
    }
    @Override
    public int insertSelective(ShamUser record) {
        return shamUserMapper.insertSelective(record);
    }
    @Override
    public int insertSelective(ShamUser record) {
        return shamUserMapper.insertSelective(record);
    }
    @Override
    public ShamUser selectByPrimaryKey(Long id) {
        return shamUserMapper.selectByPrimaryKey(id);
    }
    @Override
    public ShamUser selectByPrimaryKey(Long id) {
        return shamUserMapper.selectByPrimaryKey(id);
    }
    @Override
    public int updateByPrimaryKeySelective(ShamUser record) {
        return shamUserMapper.updateByPrimaryKeySelective(record);
    }
    @Override
    public int updateByPrimaryKeySelective(ShamUser record) {
        return shamUserMapper.updateByPrimaryKeySelective(record);
    }
    @Override
    public int updateByPrimaryKey(ShamUser record) {
        return shamUserMapper.updateByPrimaryKey(record);
    }
    @Override
    public int updateByPrimaryKey(ShamUser record) {
        return shamUserMapper.updateByPrimaryKey(record);
    }
    @Override
    public List<ShamUser> listDistinctPicUrl(long start, int count) {
        return shamUserMapper.listByDistinctPicUrl(start, count);
    }
    @Override
    public List<ShamUser> listDistinctPicUrl(long start, int count) {
        return shamUserMapper.listByDistinctPicUrl(start, count);
    }
    @Override
    public int insertBatch(List<ShamUser> list) {
        return shamUserMapper.insertBatch(list);
    }
    @Override
    public int insertBatch(List<ShamUser> list) {
        return shamUserMapper.insertBatch(list);
    }
    @Override
    public int updateBatchSelective(List<ShamUser> list) {
        return shamUserMapper.updateBatchSelective(list);
    }
    @Override
    public int updateBatchSelective(List<ShamUser> list) {
        return shamUserMapper.updateBatchSelective(list);
    }
    @Override
    public List<ShamUser> listRandCouponUser(int count, int smallTime, int largeTime) {
        List<Integer> listTime = new ArrayList<Integer>();
    @Override
    public List<ShamUser> listRandCouponUser(int count, int smallTime, int largeTime) {
        List<Integer> listTime = new ArrayList<Integer>();
        while (listTime.size() < count) {
            int time = smallTime + (int) (Math.random() * (largeTime - smallTime + 1));
            if (!listTime.contains(Integer.valueOf(time))) {
                listTime.add(Integer.valueOf(time));
            }
        }
        while (listTime.size() < count) {
            int time = smallTime + (int) (Math.random() * (largeTime - smallTime + 1));
            if (!listTime.contains(Integer.valueOf(time))) {
                listTime.add(Integer.valueOf(time));
            }
        }
        Collections.sort(listTime);
        Collections.sort(listTime);
        List<ShamUser> listRand = shamUserMapper.listRand(count);
        List<ShamUser> listRand = shamUserMapper.listRand(count);
        for (int i = 1; i <= count; i++) {
            ShamUser shamUser = (ShamUser) listRand.get(i - 1);
        for (int i = 1; i <= count; i++) {
            ShamUser shamUser = (ShamUser) listRand.get(i - 1);
            transformId(shamUser);
            transformId(shamUser);
            shamUser.setMsg(listTime.get(listTime.size() - i) + "秒前购买了此商品");
        }
            shamUser.setMsg(listTime.get(listTime.size() - i) + "秒前购买了此商品");
        }
        return listRand;
    }
        return listRand;
    }
    @Override
    public List<ShamUser> listRandShareUser(int count, BigDecimal shareMoney, int small, int large) {
    @Override
    public List<ShamUser> listRandShareUser(int count, BigDecimal shareMoney, int small, int large) {
        List<Integer> listMultiple = new ArrayList<Integer>();
        List<Integer> listMultiple = new ArrayList<Integer>();
        while (listMultiple.size() < count) {
            int Multiple = small + (int) (Math.random() * (large - small + 1));
            listMultiple.add(Integer.valueOf(Multiple));
        }
        while (listMultiple.size() < count) {
            int Multiple = small + (int) (Math.random() * (large - small + 1));
            listMultiple.add(Integer.valueOf(Multiple));
        }
        List<String> imgList = new ArrayList<String>();
        String value = configService.get(ConfigKeyEnum.shareBonusPicture.getKey());
        List<String> imgList = new ArrayList<String>();
        String value = commonConfigService.getValue(ConfigKeyEnum.shareBonusPicture.getKey());
        if (!StringUtil.isNullOrEmpty(value)) {
            JSONArray array = JSONArray.fromObject(value);
            if (array != null) {
                for (int n = 0; n < array.size(); n++) {
                    imgList.add(array.optString(n));
                }
            }
        if (!StringUtil.isNullOrEmpty(value)) {
            JSONArray array = JSONArray.fromObject(value);
            if (array != null) {
                for (int n = 0; n < array.size(); n++) {
                    imgList.add(array.optString(n));
                }
            }
        }
        }
        List<ShamUser> listRand = shamUserMapper.listRand(count);
        List<ShamUser> listRand = shamUserMapper.listRand(count);
        for (int i = 0; i < count; i++) {
            ShamUser shamUser = (ShamUser) listRand.get(i);
        for (int i = 0; i < count; i++) {
            ShamUser shamUser = (ShamUser) listRand.get(i);
            transformId(shamUser);
            transformId(shamUser);
            if (imgList.size() > 0) {
                int randBonusPic = (int) (Math.random() * imgList.size());
                shamUser.setShareBonusPic((String) imgList.get(randBonusPic));
            }
            if (imgList.size() > 0) {
                int randBonusPic = (int) (Math.random() * imgList.size());
                shamUser.setShareBonusPic((String) imgList.get(randBonusPic));
            }
            BigDecimal money = shareMoney.multiply(new BigDecimal(((Integer) listMultiple.get(i)).intValue()))
                    .setScale(2, 1);
            // 必须包含 【奖金¥】 这3个符号, 用于前端颜色区分
            shamUser.setMsg("分享了这个商品,累计获得奖金¥" + money);
        }
            BigDecimal money = shareMoney.multiply(new BigDecimal(((Integer) listMultiple.get(i)).intValue()))
                    .setScale(2, 1);
            // 必须包含 【奖金¥】 这3个符号, 用于前端颜色区分
            shamUser.setMsg("分享了这个商品,累计获得奖金¥" + money);
        }
        return listRand;
    }
        return listRand;
    }
    public void transformId(ShamUser shamUser) {
        String id = shamUser.getId() + "";
        if (id.length() == 1) {
            shamUser.setShowId("2****" + id);
        } else {
            shamUser.setShowId(id.substring(0, 1) + "****" + id.substring(id.length() - 2, id.length() - 1));
        }
        String name = shamUser.getName();
        if(StringUtil.isNullOrEmpty(name)) {
            // 名字为空时
            String start = randomName();
            String end = randomName();
            shamUser.setName(start + "**" +end);
        } else if (name.length() == 1) {
            // 一个字
            String start = name;
            if (start.trim().length() == 0 || start.equals("*")) {
                start = randomName();
            }
            String end = randomName();
            shamUser.setName(start + "**" +end);
        } else {
            // 两个字及其以上
            String start = name.substring(0, 1);
            String end = name.substring(name.length() - 2, name.length() - 1);
            if (start.trim().length() == 0 || start.equals("*")) {
                start = randomName();
            }
            if (end.trim().length() == 0 || end.equals("*")) {
                end = randomName();
            }
            shamUser.setName(start + "**" +end);
        }
    }
    /**
     * 随机名称
     * @return
     */
    public String randomName() {
        String[] array = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
                "我","半","士","思","一","成","城","罗","落","花","化","夫","福","扶","浮","生","若","梦","你","繁","华","三","起","七","易","已","意","衣",
                "且","听","风","峰","枫","音","吟","绝","倔","空","离","丽","厘","留","六","流","瘤","陆","鏐","陸","紅","誰","為","美","陳","塵","車","晨",
                "光","零","鱗","藺","離","口","了","酒","舊","傷","賞","殤","橋","巧","喬","愛","啊","嗄","譚","談","貪","銀","汗","航","孔","名","明","明","闵"
                ,"铭","鸣","冥","飞","费","非","废","达","去","曲","渠","小","笑","晓","消","校","西","妖","娆","破","眸","凉","微","兮","つ","越","黑","舊","素",
                "憾","无","っ","つ","烟","東","烁","弃","绕","雪","月","航"};
        return array[(int) (Math.random() * array.length-1)];
    }
    public void transformId(ShamUser shamUser) {
        String id = shamUser.getId() + "";
        if (id.length() == 1) {
            shamUser.setShowId("2****" + id);
        } else {
            shamUser.setShowId(id.substring(0, 1) + "****" + id.substring(id.length() - 2, id.length() - 1));
        }
    @Override
    public List<ShamUser> listRandUser(int count) {
        return shamUserMapper.listRand(count);
    }
        String name = shamUser.getName();
        if (StringUtil.isNullOrEmpty(name)) {
            // 名字为空时
            String start = randomName();
            String end = randomName();
            shamUser.setName(start + "**" + end);
        } else if (name.length() == 1) {
            // 一个字
            String start = name;
            if (start.trim().length() == 0 || start.equals("*")) {
                start = randomName();
            }
            String end = randomName();
            shamUser.setName(start + "**" + end);
        } else {
            // 两个字及其以上
            String start = name.substring(0, 1);
            String end = name.substring(name.length() - 2, name.length() - 1);
            if (start.trim().length() == 0 || start.equals("*")) {
                start = randomName();
            }
            if (end.trim().length() == 0 || end.equals("*")) {
                end = randomName();
            }
            shamUser.setName(start + "**" + end);
        }
    }
    /**
     * 随机名称
     *
     * @return
     */
    public String randomName() {
        String[] array = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
                "我", "半", "士", "思", "一", "成", "城", "罗", "落", "花", "化", "夫", "福", "扶", "浮", "生", "若", "梦", "你", "繁", "华", "三", "起", "七", "易", "已", "意", "衣",
                "且", "听", "风", "峰", "枫", "音", "吟", "绝", "倔", "空", "离", "丽", "厘", "留", "六", "流", "瘤", "陆", "鏐", "陸", "紅", "誰", "為", "美", "陳", "塵", "車", "晨",
                "光", "零", "鱗", "藺", "離", "口", "了", "酒", "舊", "傷", "賞", "殤", "橋", "巧", "喬", "愛", "啊", "嗄", "譚", "談", "貪", "銀", "汗", "航", "孔", "名", "明", "明", "闵"
                , "铭", "鸣", "冥", "飞", "费", "非", "废", "达", "去", "曲", "渠", "小", "笑", "晓", "消", "校", "西", "妖", "娆", "破", "眸", "凉", "微", "兮", "つ", "越", "黑", "舊", "素",
                "憾", "无", "っ", "つ", "烟", "東", "烁", "弃", "绕", "雪", "月", "航"};
        return array[(int) (Math.random() * array.length - 1)];
    }
    @Override
    public List<ShamUser> listRandUser(int count) {
        return shamUserMapper.listRand(count);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java
@@ -8,6 +8,8 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.service.inter.user.*;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -44,10 +46,6 @@
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.user.UserAccountService;
import com.yeshi.fanli.service.inter.user.UserGoodsStorageService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
import com.yeshi.fanli.service.inter.user.integral.IntegralGetService;
import com.yeshi.fanli.util.AESUtil;
import com.yeshi.fanli.util.Constant;
@@ -66,1022 +64,1015 @@
@Service
public class UserShareGoodsRecordServiceImpl implements UserShareGoodsRecordService {
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    @Resource
    private ConfigService configService;
    @Resource
    private ConfigService configService;
    @Resource
    private RedisManager redisManager;
    @Resource
    private RedisManager redisManager;
    @Resource
    private UserInfoMapper userInfoMapper;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserAccountService userAccountService;
    @Resource
    private UserAccountService userAccountService;
    @Resource
    private UserShareGoodsRecordMapper userShareGoodsRecordMapper;
    @Resource
    private UserShareGoodsRecordMapper userShareGoodsRecordMapper;
    @Resource
    private CommonGoodsService commonGoodsService;
    @Resource
    private CommonGoodsService commonGoodsService;
    @Resource
    private UserShareGoodsGroupService userShareGoodsGroupService;
    @Resource
    private UserShareGoodsGroupService userShareGoodsGroupService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private UserGoodsStorageService userGoodsStorageService;
    @Resource
    private UserGoodsStorageService userGoodsStorageService;
    @Resource
    private IntegralGetService integralGetService;
    @Resource
    private IntegralGetService integralGetService;
    @Override
    public int insert(UserShareGoodsRecord record) {
        return userShareGoodsRecordMapper.insert(record);
    }
    @Override
    public int insert(UserShareGoodsRecord record) {
        return userShareGoodsRecordMapper.insert(record);
    }
    @Override
    public int insertSelective(UserShareGoodsRecord record) {
        return userShareGoodsRecordMapper.insertSelective(record);
    }
    @Override
    public int insertSelective(UserShareGoodsRecord record) {
        return userShareGoodsRecordMapper.insertSelective(record);
    }
    @Override
    public UserShareGoodsRecord selectByPrimaryKey(Long id) {
        return userShareGoodsRecordMapper.selectByPrimaryKey(id);
    }
    @Override
    public UserShareGoodsRecord selectByPrimaryKey(Long id) {
        return userShareGoodsRecordMapper.selectByPrimaryKey(id);
    }
    @Override
    public int updateByPrimaryKeySelective(UserShareGoodsRecord record) {
        return userShareGoodsRecordMapper.updateByPrimaryKeySelective(record);
    }
    @Override
    public int updateByPrimaryKeySelective(UserShareGoodsRecord record) {
        return userShareGoodsRecordMapper.updateByPrimaryKeySelective(record);
    }
    @Override
    public List<UserShareGoodsRecord> listQueryByUid(long start, int count, Long uid, String source) {
        return userShareGoodsRecordMapper.listQueryByUid(start, count, uid, source);
    }
    @Override
    public List<UserShareGoodsRecord> listQueryByUid(long start, int count, Long uid, String source) {
        return userShareGoodsRecordMapper.listQueryByUid(start, count, uid, source);
    }
    @Override
    public long countQueryByUid(Long uid, String source) {
        return userShareGoodsRecordMapper.countQueryByUid(uid, source);
    }
    @Override
    public long countQueryByUid(Long uid, String source) {
        return userShareGoodsRecordMapper.countQueryByUid(uid, source);
    }
    @Override
    public List<UserShareGoodsGroup> listByRecordId(Long shareId) {
        return userShareGoodsGroupService.listByRecordId(shareId, true);
    }
    @Override
    public List<UserShareGoodsGroup> listByRecordId(Long shareId) {
        return userShareGoodsGroupService.listByRecordId(shareId, true);
    }
    @Override
    public List<UserShareGoodsRecord> listCountRecord(List<Long> list) {
        return userShareGoodsRecordMapper.listCountRecord(list);
    }
    @Override
    public List<UserShareGoodsRecord> listCountRecord(List<Long> list) {
        return userShareGoodsRecordMapper.listCountRecord(list);
    }
    @Override
    public List<UserShareGoodsRecord> getMyShareGoodsRecords(long start, int count, Long uid, String source) {
    @Override
    public List<UserShareGoodsRecord> getMyShareGoodsRecords(long start, int count, Long uid, String source) {
        List<UserShareGoodsRecord> list = listQueryByUid(start, count, uid, source);
        if (list == null) {
            list = new ArrayList<UserShareGoodsRecord>();
        }
        List<UserShareGoodsRecord> list = listQueryByUid(start, count, uid, source);
        if (list == null) {
            list = new ArrayList<UserShareGoodsRecord>();
        }
        if (list.size() > 0) {
            List<Long> listId = new ArrayList<Long>();
        if (list.size() > 0) {
            List<Long> listId = new ArrayList<Long>();
            for (UserShareGoodsRecord userShareGoodsRecord : list) {
                userShareGoodsRecord.setShareTime(userShareGoodsRecord.getUpdateTime().getTime());
                userShareGoodsRecord.setCreateTime(null);
                userShareGoodsRecord.setUpdateTime(null);
                listId.add(userShareGoodsRecord.getId());
            for (UserShareGoodsRecord userShareGoodsRecord : list) {
                userShareGoodsRecord.setShareTime(userShareGoodsRecord.getUpdateTime().getTime());
                userShareGoodsRecord.setCreateTime(null);
                userShareGoodsRecord.setUpdateTime(null);
                listId.add(userShareGoodsRecord.getId());
                // 改变图片尺寸
                String pictUrl = userShareGoodsRecord.getPicture();
                if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
                    userShareGoodsRecord.setPicture(TbImgUtil.getTBSize320Img(pictUrl));
                }
                // 改变图片尺寸
                String pictUrl = userShareGoodsRecord.getPicture();
                if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
                    userShareGoodsRecord.setPicture(TbImgUtil.getTBSize320Img(pictUrl));
                }
            }
            }
            // 今日浏览统计
            List<UserShareGoodsRecord> listTodayBrowse = userShareGoodsRecordMapper.listCountTodayBrowse(listId);
            // 今日浏览统计
            List<UserShareGoodsRecord> listTodayBrowse = userShareGoodsRecordMapper.listCountTodayBrowse(listId);
            // 订单、浏览数量、金额统计
            List<UserShareGoodsRecord> listCountRecord = listCountRecord(listId);
            // 订单、浏览数量、金额统计
            List<UserShareGoodsRecord> listCountRecord = listCountRecord(listId);
            if ((listCountRecord != null && listCountRecord.size() > 0)
                    || (listTodayBrowse != null && listTodayBrowse.size() > 0)) {
            if ((listCountRecord != null && listCountRecord.size() > 0)
                    || (listTodayBrowse != null && listTodayBrowse.size() > 0)) {
                for (UserShareGoodsRecord shareRecord : list) {
                    Long id = shareRecord.getId();
                for (UserShareGoodsRecord shareRecord : list) {
                    Long id = shareRecord.getId();
                    if (listTodayBrowse != null && listTodayBrowse.size() > 0) {
                        for (UserShareGoodsRecord goodsRecord : listTodayBrowse) {
                            Long recordId = goodsRecord.getId();
                            if (id == recordId || id.equals(recordId)) {
                                shareRecord.setTodayBrowse(goodsRecord.getTodayBrowse());
                                break;
                            }
                        }
                    }
                    if (listTodayBrowse != null && listTodayBrowse.size() > 0) {
                        for (UserShareGoodsRecord goodsRecord : listTodayBrowse) {
                            Long recordId = goodsRecord.getId();
                            if (id == recordId || id.equals(recordId)) {
                                shareRecord.setTodayBrowse(goodsRecord.getTodayBrowse());
                                break;
                            }
                        }
                    }
                    if (listCountRecord != null && listCountRecord.size() > 0) {
                        for (UserShareGoodsRecord goodsRecord : listCountRecord) {
                            Long recordId = goodsRecord.getId();
                            if (id == recordId || id.equals(recordId)) {
                                shareRecord.setTotalBrowse(goodsRecord.getTotalBrowse());
                                shareRecord.setTotalOrder(goodsRecord.getTotalOrder());
                    if (listCountRecord != null && listCountRecord.size() > 0) {
                        for (UserShareGoodsRecord goodsRecord : listCountRecord) {
                            Long recordId = goodsRecord.getId();
                            if (id == recordId || id.equals(recordId)) {
                                shareRecord.setTotalBrowse(goodsRecord.getTotalBrowse());
                                shareRecord.setTotalOrder(goodsRecord.getTotalOrder());
                                BigDecimal totalMoney = goodsRecord.getTotalMoney();
                                if (totalMoney != null && totalMoney.compareTo(new BigDecimal(0)) > 0) {
                                    shareRecord.setTotalMoney(goodsRecord.getTotalMoney());
                                } else {
                                    shareRecord.setTotalMoney(goodsRecord.getRevenueMoney());
                                }
                                shareRecord.setRevenueMoney(null);
                                BigDecimal totalMoney = goodsRecord.getTotalMoney();
                                if (totalMoney != null && totalMoney.compareTo(new BigDecimal(0)) > 0) {
                                    shareRecord.setTotalMoney(goodsRecord.getTotalMoney());
                                } else {
                                    shareRecord.setTotalMoney(goodsRecord.getRevenueMoney());
                                }
                                shareRecord.setRevenueMoney(null);
                                Integer totalGoods = goodsRecord.getTotalGoods();
                                shareRecord.setTotalGoods(totalGoods);
                                if (totalGoods > 1) {
                                    shareRecord.setShareType(UserShareGoodsRecord.SHARETYPE_GROUP);
                                } else {
                                    shareRecord.setShareType(UserShareGoodsRecord.SHARETYPE_SINGLE);
                                }
                                break;
                            }
                        }
                    }
                                Integer totalGoods = goodsRecord.getTotalGoods();
                                shareRecord.setTotalGoods(totalGoods);
                                if (totalGoods > 1) {
                                    shareRecord.setShareType(UserShareGoodsRecord.SHARETYPE_GROUP);
                                } else {
                                    shareRecord.setShareType(UserShareGoodsRecord.SHARETYPE_SINGLE);
                                }
                                break;
                            }
                        }
                    }
                    String shareType = shareRecord.getShareType();
                    if (StringUtil.isNullOrEmpty(shareType)) {
                        shareRecord.setShareType(UserShareGoodsRecord.SHARETYPE_SINGLE);
                    }
                    String shareType = shareRecord.getShareType();
                    if (StringUtil.isNullOrEmpty(shareType)) {
                        shareRecord.setShareType(UserShareGoodsRecord.SHARETYPE_SINGLE);
                    }
                    BigDecimal totalMoney = shareRecord.getTotalMoney();
                    if (totalMoney == null) {
                        shareRecord.setTotalMoney(new BigDecimal(0));
                    }
                }
            } else {
                for (UserShareGoodsRecord shareRecord : list) {
                    String shareType = shareRecord.getShareType();
                    if (StringUtil.isNullOrEmpty(shareType)) {
                        shareRecord.setShareType(UserShareGoodsRecord.SHARETYPE_SINGLE);
                    }
                    BigDecimal totalMoney = shareRecord.getTotalMoney();
                    if (totalMoney == null) {
                        shareRecord.setTotalMoney(new BigDecimal(0));
                    }
                }
            } else {
                for (UserShareGoodsRecord shareRecord : list) {
                    String shareType = shareRecord.getShareType();
                    if (StringUtil.isNullOrEmpty(shareType)) {
                        shareRecord.setShareType(UserShareGoodsRecord.SHARETYPE_SINGLE);
                    }
                    BigDecimal totalMoney = shareRecord.getTotalMoney();
                    if (totalMoney == null) {
                        shareRecord.setTotalMoney(new BigDecimal(0));
                    }
                }
            }
        }
                    BigDecimal totalMoney = shareRecord.getTotalMoney();
                    if (totalMoney == null) {
                        shareRecord.setTotalMoney(new BigDecimal(0));
                    }
                }
            }
        }
        return list;
    }
        return list;
    }
    @Override
    public void saveSingleShareRecord(Long uid, Long goodsId, Integer goodsType) throws UserShareGoodsRecordException {
        if (goodsId == null) {
            throw new UserShareGoodsRecordException(1, "分享商品不能为空");
        }
    @Override
    public void saveSingleShareRecord(Long uid, Long goodsId, Integer goodsType) throws UserShareGoodsRecordException {
        if (goodsId == null) {
            throw new UserShareGoodsRecordException(1, "分享商品不能为空");
        }
        if (uid == null) {
            throw new UserShareGoodsRecordException(1, "用户ID不能为空");
        }
        if (uid == null) {
            throw new UserShareGoodsRecordException(1, "用户ID不能为空");
        }
        if (goodsType == null) {
            goodsType = Constant.SOURCE_TYPE_TAOBAO;
        }
        if (goodsType == null) {
            goodsType = Constant.SOURCE_TYPE_TAOBAO;
        }
        CommonGoods convertGoods = null;
        if (goodsType == Constant.SOURCE_TYPE_JD) {
            JDGoods jdGoods = redisManager.getJDGoods(goodsId);
            if (jdGoods == null) {
                throw new UserShareGoodsRecordException(1, "商品已下架");
            }
            convertGoods = CommonGoodsFactory.create(jdGoods);
        } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
            PDDGoodsDetail pddGoods = redisManager.getPDDGoodsDetail(goodsId);
            if (pddGoods == null) {
                throw new UserShareGoodsRecordException(1, "商品已下架");
            }
            convertGoods = CommonGoodsFactory.create(pddGoods);
        } else {
            TaoBaoGoodsBrief goodsBrief = null;
            try {
                goodsBrief = redisManager.getTaoBaoGoodsBrief(goodsId);
            } catch (TaobaoGoodsDownException e) {
                throw new UserShareGoodsRecordException(1, "商品已下架");
            }
            convertGoods = CommonGoodsFactory.create(goodsBrief);
        }
        CommonGoods convertGoods = null;
        if (goodsType == Constant.SOURCE_TYPE_JD) {
            JDGoods jdGoods = redisManager.getJDGoods(goodsId);
            if (jdGoods == null) {
                throw new UserShareGoodsRecordException(1, "商品已下架");
            }
            convertGoods = CommonGoodsFactory.create(jdGoods);
        } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
            PDDGoodsDetail pddGoods = redisManager.getPDDGoodsDetail(goodsId);
            if (pddGoods == null) {
                throw new UserShareGoodsRecordException(1, "商品已下架");
            }
            convertGoods = CommonGoodsFactory.create(pddGoods);
        } else {
            TaoBaoGoodsBrief goodsBrief = null;
            try {
                goodsBrief = redisManager.getTaoBaoGoodsBrief(goodsId);
            } catch (TaobaoGoodsDownException e) {
                throw new UserShareGoodsRecordException(1, "商品已下架");
            }
            convertGoods = CommonGoodsFactory.create(goodsBrief);
        }
        UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
        userShareGoodsRecord.setUid(uid);
        userShareGoodsRecord.setSource(ShareSourceTypeEnum.goodsDetail);
        userShareGoodsRecord.setShareState(1);
        UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
        userShareGoodsRecord.setUid(uid);
        userShareGoodsRecord.setSource(ShareSourceTypeEnum.goodsDetail);
        userShareGoodsRecord.setShareState(1);
        convertGoods.setState(0);
        CommonGoods resultCommonGoods = null;
        try {
            resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(convertGoods);
        } catch (CommonGoodsException e) {
            throw new UserShareGoodsRecordException(1, "商品存入失败");
        }
        convertGoods.setState(0);
        CommonGoods resultCommonGoods = null;
        try {
            resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(convertGoods);
        } catch (CommonGoodsException e) {
            throw new UserShareGoodsRecordException(1, "商品存入失败");
        }
        UserShareGoodsGroup singleGoods = userShareGoodsGroupService.getSingleGoods(resultCommonGoods.getId(),
                userShareGoodsRecord.getUid());
        UserShareGoodsGroup singleGoods = userShareGoodsGroupService.getSingleGoods(resultCommonGoods.getId(),
                userShareGoodsRecord.getUid());
        if (singleGoods != null) {
            // 单个商品多次分享
            userShareGoodsRecord.setPicture(resultCommonGoods.getPicture());
            userShareGoodsRecord.setId(singleGoods.getRecordId());
            userShareGoodsRecord.setUpdateTime(new Date());
            userShareGoodsRecordMapper.updateByPrimaryKeySelective(userShareGoodsRecord);
        if (singleGoods != null) {
            // 单个商品多次分享
            userShareGoodsRecord.setPicture(resultCommonGoods.getPicture());
            userShareGoodsRecord.setId(singleGoods.getRecordId());
            userShareGoodsRecord.setUpdateTime(new Date());
            userShareGoodsRecordMapper.updateByPrimaryKeySelective(userShareGoodsRecord);
            // 最新商品
            singleGoods.setUpdateTime(new Date());
            userShareGoodsGroupService.updateByPrimaryKeySelective(singleGoods);
            // 最新商品
            singleGoods.setUpdateTime(new Date());
            userShareGoodsGroupService.updateByPrimaryKeySelective(singleGoods);
        } else {
            // 单个商品第一次分享
            Date date = new Date();
            userShareGoodsRecord.setPicture(resultCommonGoods.getPicture());
            userShareGoodsRecord.setCreateTime(date);
            userShareGoodsRecord.setUpdateTime(date);
            userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord);
        } else {
            // 单个商品第一次分享
            Date date = new Date();
            userShareGoodsRecord.setPicture(resultCommonGoods.getPicture());
            userShareGoodsRecord.setCreateTime(date);
            userShareGoodsRecord.setUpdateTime(date);
            userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord);
            singleGoods = new UserShareGoodsGroup();
            singleGoods.setTotalOrder(0);
            singleGoods.setTotalBrowse(0);
            singleGoods.setTodayBrowse(0);
            singleGoods.setTotalMoney(new BigDecimal(0));
            singleGoods.setCreateTime(date);
            singleGoods.setUpdateTime(date);
            singleGoods.setCommonGoods(resultCommonGoods);
            singleGoods.setRecordId(userShareGoodsRecord.getId());
            userShareGoodsGroupService.insertSelective(singleGoods);
        }
    }
            singleGoods = new UserShareGoodsGroup();
            singleGoods.setTotalOrder(0);
            singleGoods.setTotalBrowse(0);
            singleGoods.setTodayBrowse(0);
            singleGoods.setTotalMoney(new BigDecimal(0));
            singleGoods.setCreateTime(date);
            singleGoods.setUpdateTime(date);
            singleGoods.setCommonGoods(resultCommonGoods);
            singleGoods.setRecordId(userShareGoodsRecord.getId());
            userShareGoodsGroupService.insertSelective(singleGoods);
        }
    }
    /**
     * 多个商品分享生成记录
     *
     * @param userShareGoodsRecord
     * @param listGoods
     */
    @Transactional(rollbackFor = Exception.class)
    public void multipleGoodsShareRecord(Long shareId, List<CommonGoods> listGoods)
            throws UserShareGoodsRecordException {
        // 分享记录
        Date date = new Date();
        List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
        List<UserShareGoodsGroup> listGroup = new ArrayList<UserShareGoodsGroup>();
    /**
     * 多个商品分享生成记录
     *
     * @param listGoods
     */
    @Transactional(rollbackFor = Exception.class)
    public void multipleGoodsShareRecord(Long shareId, List<CommonGoods> listGoods)
            throws UserShareGoodsRecordException {
        // 分享记录
        Date date = new Date();
        List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
        List<UserShareGoodsGroup> listGroup = new ArrayList<UserShareGoodsGroup>();
        for (CommonGoods commonGoods : listGoods) {
            try {
                CommonGoods resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods);
        for (CommonGoods commonGoods : listGoods) {
            try {
                CommonGoods resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods);
                if (resultCommonGoods != null) {
                    TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(resultCommonGoods);
                    listGoodsBrief.add(goodsBrief);
                }
                if (resultCommonGoods != null) {
                    TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(resultCommonGoods);
                    listGoodsBrief.add(goodsBrief);
                }
                UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup();
                shareGoodsGroup.setTotalOrder(0);
                shareGoodsGroup.setTotalBrowse(0);
                shareGoodsGroup.setTodayBrowse(0);
                shareGoodsGroup.setTotalMoney(new BigDecimal(0));
                shareGoodsGroup.setCreateTime(date);
                shareGoodsGroup.setUpdateTime(date);
                shareGoodsGroup.setCommonGoods(resultCommonGoods);
                shareGoodsGroup.setRecordId(shareId);
                listGroup.add(shareGoodsGroup);
            } catch (CommonGoodsException e) {
                e.printStackTrace();
            }
        }
                UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup();
                shareGoodsGroup.setTotalOrder(0);
                shareGoodsGroup.setTotalBrowse(0);
                shareGoodsGroup.setTodayBrowse(0);
                shareGoodsGroup.setTotalMoney(new BigDecimal(0));
                shareGoodsGroup.setCreateTime(date);
                shareGoodsGroup.setUpdateTime(date);
                shareGoodsGroup.setCommonGoods(resultCommonGoods);
                shareGoodsGroup.setRecordId(shareId);
                listGroup.add(shareGoodsGroup);
            } catch (CommonGoodsException e) {
                e.printStackTrace();
            }
        }
        if (listGroup.size() > 0) {
            userShareGoodsGroupService.insertBatch(listGroup);
        }
    }
        if (listGroup.size() > 0) {
            userShareGoodsGroupService.insertBatch(listGroup);
        }
    }
    /**
     * 多个商品分享生成记录
     *
     * @param userShareGoodsRecord
     * @param listGoods
     */
    @Transactional(rollbackFor = Exception.class)
    public FileUploadResult multipleGoodsShare(UserShareGoodsRecord userShareGoodsRecord,
            List<TaoBaoGoodsBrief> listGoods) throws UserShareGoodsRecordException {
    /**
     * 多个商品分享生成记录
     *
     * @param userShareGoodsRecord
     * @param listGoods
     */
    @Transactional(rollbackFor = Exception.class)
    public FileUploadResult multipleGoodsShare(UserShareGoodsRecord userShareGoodsRecord,
                                               List<TaoBaoGoodsBrief> listGoods) throws UserShareGoodsRecordException {
        // 分享记录
        Date date = new Date();
        // 分享记录
        Date date = new Date();
        List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
        List<UserShareGoodsGroup> listGroup = new ArrayList<UserShareGoodsGroup>();
        List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
        List<UserShareGoodsGroup> listGroup = new ArrayList<UserShareGoodsGroup>();
        for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoods) {
            CommonGoods commonGoods = CommonGoodsFactory.create(taoBaoGoodsBrief);
            commonGoods.setState(taoBaoGoodsBrief.getState());
            try {
                CommonGoods resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods);
        for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoods) {
            CommonGoods commonGoods = CommonGoodsFactory.create(taoBaoGoodsBrief);
            commonGoods.setState(taoBaoGoodsBrief.getState());
            try {
                CommonGoods resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods);
                if (resultCommonGoods != null) {
                    TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(resultCommonGoods);
                    listGoodsBrief.add(goodsBrief);
                }
                if (resultCommonGoods != null) {
                    TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(resultCommonGoods);
                    listGoodsBrief.add(goodsBrief);
                }
                UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup();
                shareGoodsGroup.setTotalOrder(0);
                shareGoodsGroup.setTotalBrowse(0);
                shareGoodsGroup.setTodayBrowse(0);
                shareGoodsGroup.setTotalMoney(new BigDecimal(0));
                shareGoodsGroup.setCreateTime(date);
                shareGoodsGroup.setUpdateTime(date);
                shareGoodsGroup.setCommonGoods(resultCommonGoods);
                shareGoodsGroup.setRecordId(userShareGoodsRecord.getId());
                UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup();
                shareGoodsGroup.setTotalOrder(0);
                shareGoodsGroup.setTotalBrowse(0);
                shareGoodsGroup.setTodayBrowse(0);
                shareGoodsGroup.setTotalMoney(new BigDecimal(0));
                shareGoodsGroup.setCreateTime(date);
                shareGoodsGroup.setUpdateTime(date);
                shareGoodsGroup.setCommonGoods(resultCommonGoods);
                shareGoodsGroup.setRecordId(userShareGoodsRecord.getId());
                listGroup.add(shareGoodsGroup);
                listGroup.add(shareGoodsGroup);
            } catch (CommonGoodsException e) {
                e.printStackTrace();
                continue;
            }
        }
            } catch (CommonGoodsException e) {
                e.printStackTrace();
                continue;
            }
        }
        FileUploadResult shareImg = createShareImg(userShareGoodsRecord, listGoodsBrief);
        FileUploadResult shareImg = createShareImg(userShareGoodsRecord, listGoodsBrief);
        if (listGroup.size() > 0) {
            userShareGoodsGroupService.insertBatch(listGroup);
        }
        if (listGroup.size() > 0) {
            userShareGoodsGroupService.insertBatch(listGroup);
        }
        return shareImg;
    }
        return shareImg;
    }
    /**
     * 生成分享图
     *
     * @param uid
     *            用户id
     * @param shareId
     *            分享记录id
     * @param source
     *            来源
     * @param listGoods
     * @return
     * @throws UserShareGoodsRecordException
     */
    public FileUploadResult createShareImg(UserShareGoodsRecord shareRecord, List<TaoBaoGoodsBrief> listGoods)
            throws UserShareGoodsRecordException {
    /**
     * 生成分享图
     *
     * @param listGoods
     * @return
     * @throws UserShareGoodsRecordException
     */
    public FileUploadResult createShareImg(UserShareGoodsRecord shareRecord, List<TaoBaoGoodsBrief> listGoods)
            throws UserShareGoodsRecordException {
        Long uid = shareRecord.getUid();
        Long shareId = shareRecord.getId();
        String source = shareRecord.getSource().name();
        Long uid = shareRecord.getUid();
        Long shareId = shareRecord.getId();
        String source = shareRecord.getSource().name();
        String url = String.format("http://%s/share_mushGoods.html?uid=%s&shareId=%s&source=%s",
                configService.getH5Host(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), shareRecord.getId() + "",
                source + "");
        SystemEnum system = userInfoService.getUserSystem(uid);
        String shortLink = HttpUtil.getShortLink(url);
        if (!StringUtil.isNullOrEmpty(shortLink)) {
            url = shortLink;
        }
        InputStream erCodeInputStream = null;
        String url = String.format("http://%s/share_mushGoods.html?uid=%s&shareId=%s&source=%s",
                configService.getH5Host(system), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), shareRecord.getId() + "",
                source + "");
        // 生成链接二维码
        try {
            erCodeInputStream = QRCodeUtil.getInstance(500).encode(url);
        } catch (Exception e) {
            e.printStackTrace();
        }
        String shortLink = HttpUtil.getShortLink(url);
        if (!StringUtil.isNullOrEmpty(shortLink)) {
            url = shortLink;
        }
        InputStream erCodeInputStream = null;
        // 获取到用户的头像
        UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
        if (user == null) {
            throw new UserShareGoodsRecordException(1, "用户信息不存在");
        }
        // 生成链接二维码
        try {
            erCodeInputStream = QRCodeUtil.getInstance(500).encode(url);
        } catch (Exception e) {
            e.printStackTrace();
        }
        InputStream portrait = null;
        // 获取到用户的头像
        UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
        if (user == null) {
            throw new UserShareGoodsRecordException(1, "用户信息不存在");
        }
        if (!StringUtil.isNullOrEmpty(user.getPortrait())) {
            try {
                portrait = HttpUtil.downLoadImg(user.getPortrait());
            } catch (HttpException e) {
                String portraitUrl = userAccountService.repairPortrait(uid);
                if (StringUtil.isNullOrEmpty(portraitUrl))
                    throw new UserShareGoodsRecordException(1, "获取头像出错");
                else {
                    // 再次获取头像
                    try {
                        portrait = HttpUtil.downLoadImg(portraitUrl);
                    } catch (HttpException e1) {
                        throw new UserShareGoodsRecordException(1, "获取头像出错");
                    }
                }
            }
        }
        InputStream portrait = null;
        InputStream inputStream = ImageUtil.drawGoodsShareBigImg(erCodeInputStream, portrait, listGoods);
        if (!StringUtil.isNullOrEmpty(user.getPortrait())) {
            try {
                portrait = HttpUtil.downLoadImg(user.getPortrait());
            } catch (HttpException e) {
                String portraitUrl = userAccountService.repairPortrait(uid);
                if (StringUtil.isNullOrEmpty(portraitUrl))
                    throw new UserShareGoodsRecordException(1, "获取头像出错");
                else {
                    // 再次获取头像
                    try {
                        portrait = HttpUtil.downLoadImg(portraitUrl);
                    } catch (HttpException e1) {
                        throw new UserShareGoodsRecordException(1, "获取头像出错");
                    }
                }
            }
        }
        FileUploadResult shareImg = COSManager.getInstance().uploadInputStream(inputStream,
                FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + shareId + "_" + System.currentTimeMillis()
                        + ".png");
        InputStream inputStream = ImageUtil.drawGoodsShareBigImg(erCodeInputStream, portrait, listGoods);
        return shareImg;
    }
        FileUploadResult shareImg = COSManager.getInstance().uploadInputStream(inputStream,
                FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + shareId + "_" + System.currentTimeMillis()
                        + ".png");
    @Override
    public JSONObject getGoodsGroup(Long recordId) throws UserShareGoodsRecordException {
        return shareImg;
    }
        JSONArray array = new JSONArray();
    @Override
    public JSONObject getGoodsGroup(Long recordId) throws UserShareGoodsRecordException {
        List<UserShareGoodsGroup> list = userShareGoodsGroupService.listByRecordId(recordId, true);
        JSONArray array = new JSONArray();
        List<Long> listGid = new ArrayList<Long>();
        for (UserShareGoodsGroup goodsGroup : list) {
            CommonGoods commonGoods = goodsGroup.getCommonGoods();
            if (commonGoods == null) {
                continue;
            }
            listGid.add(commonGoods.getGoodsId());
        }
        List<UserShareGoodsGroup> list = userShareGoodsGroupService.listByRecordId(recordId, true);
        // API网络接口验证是否在售
        List<TaoBaoGoodsBrief> listTaoKeGoods = null;
        try {
            listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
        } catch (TaoKeApiException e) {
            e.printStackTrace();
        } catch (TaobaoGoodsDownException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        List<Long> listGid = new ArrayList<Long>();
        for (UserShareGoodsGroup goodsGroup : list) {
            CommonGoods commonGoods = goodsGroup.getCommonGoods();
            if (commonGoods == null) {
                continue;
            }
            listGid.add(commonGoods.getGoodsId());
        }
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        // API网络接口验证是否在售
        List<TaoBaoGoodsBrief> listTaoKeGoods = null;
        try {
            listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
        } catch (TaoKeApiException e) {
            e.printStackTrace();
        } catch (TaobaoGoodsDownException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        BigDecimal shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
                java.lang.System.currentTimeMillis());
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        for (UserShareGoodsGroup goodsGroup : list) {
            CommonGoods commonGoods = goodsGroup.getCommonGoods();
            if (commonGoods == null) {
                continue;
            }
        BigDecimal shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
                java.lang.System.currentTimeMillis());
            if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
                int state = 1; // 默认停售
                Long goodsId = commonGoods.getGoodsId();
                for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
                    Long auctionId = taoKeGoods.getAuctionId();
                    if (goodsId == auctionId || goodsId.equals(auctionId)) {
                        state = 0; // 在售
                        break;
                    }
                }
                commonGoods.setState(state);
            }
        for (UserShareGoodsGroup goodsGroup : list) {
            CommonGoods commonGoods = goodsGroup.getCommonGoods();
            if (commonGoods == null) {
                continue;
            }
            TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
            if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
                int state = 1; // 默认停售
                Long goodsId = commonGoods.getGoodsId();
                for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
                    Long auctionId = taoKeGoods.getAuctionId();
                    if (goodsId == auctionId || goodsId.equals(auctionId)) {
                        state = 0; // 在售
                        break;
                    }
                }
                commonGoods.setState(state);
            }
            // 今日浏览记录处理
            Date date = new Date();
            Date browseTime = goodsGroup.getBrowseTime();
            if (!DateUtil.isSameDay(browseTime, date)) {
                goodsGroup.setTodayBrowse(0); // 不是同一天浏览记录设置0
            }
            TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
            JSONObject dataObject = new JSONObject();
            dataObject.put("todayBrowse", goodsGroup.getTodayBrowse());
            dataObject.put("totalBrowse", goodsGroup.getTotalBrowse());
            dataObject.put("totalOrder", goodsGroup.getTotalOrder());
            dataObject.put("totalMoney", "¥" + goodsGroup.getTotalMoney());
            dataObject.put("goods", gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, shareRate + "", null)));
            array.add(dataObject);
        }
            // 今日浏览记录处理
            Date date = new Date();
            Date browseTime = goodsGroup.getBrowseTime();
            if (!DateUtil.isSameDay(browseTime, date)) {
                goodsGroup.setTodayBrowse(0); // 不是同一天浏览记录设置0
            }
        String title = "";
        UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordMapper.selectByPrimaryKey(recordId);
        if (userShareGoodsRecord != null) {
            title = userShareGoodsRecord.getTitle();
        }
            JSONObject dataObject = new JSONObject();
            dataObject.put("todayBrowse", goodsGroup.getTodayBrowse());
            dataObject.put("totalBrowse", goodsGroup.getTotalBrowse());
            dataObject.put("totalOrder", goodsGroup.getTotalOrder());
            dataObject.put("totalMoney", "¥" + goodsGroup.getTotalMoney());
            dataObject.put("goods", gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, shareRate + "", null)));
            array.add(dataObject);
        }
        JSONObject data = new JSONObject();
        data.put("title", title);
        data.put("count", list.size());
        data.put("result_list", array);
        return data;
    }
        String title = "";
        UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordMapper.selectByPrimaryKey(recordId);
        if (userShareGoodsRecord != null) {
            title = userShareGoodsRecord.getTitle();
        }
    @Override
    public JSONObject getGoodsGroupDetail(Long recordId) throws UserShareGoodsRecordException {
        JSONObject data = new JSONObject();
        data.put("title", title);
        data.put("count", list.size());
        data.put("result_list", array);
        return data;
    }
        JSONArray array = new JSONArray();
    @Override
    public JSONObject getGoodsGroupDetail(Long recordId) throws UserShareGoodsRecordException {
        JSONArray array = new JSONArray();
        List<UserShareGoodsGroup> list = userShareGoodsGroupService.listByRecordId(recordId, true);
        List<UserShareGoodsGroup> list = userShareGoodsGroupService.listByRecordId(recordId, true);
        if (list != null && list.size() > 0) {
        if (list != null && list.size() > 0) {
            List<Long> listGid = new ArrayList<Long>();
            for (UserShareGoodsGroup goodsGroup : list) {
                CommonGoods commonGoods = goodsGroup.getCommonGoods();
                if (commonGoods == null) {
                    continue;
                }
                listGid.add(commonGoods.getGoodsId());
            }
            List<Long> listGid = new ArrayList<Long>();
            for (UserShareGoodsGroup goodsGroup : list) {
                CommonGoods commonGoods = goodsGroup.getCommonGoods();
                if (commonGoods == null) {
                    continue;
                }
                listGid.add(commonGoods.getGoodsId());
            }
            // API网络接口验证是否在售
            List<TaoBaoGoodsBrief> listTaoKeGoods = null;
            try {
                listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
            } catch (TaoKeApiException e) {
                e.printStackTrace();
            } catch (TaobaoGoodsDownException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
            // API网络接口验证是否在售
            List<TaoBaoGoodsBrief> listTaoKeGoods = null;
            try {
                listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
            } catch (TaoKeApiException e) {
                e.printStackTrace();
            } catch (TaobaoGoodsDownException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            BigDecimal shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
                    java.lang.System.currentTimeMillis());
            BigDecimal shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
                    java.lang.System.currentTimeMillis());
            for (UserShareGoodsGroup goodsGroup : list) {
                CommonGoods commonGoods = goodsGroup.getCommonGoods();
                if (commonGoods == null) {
                    continue;
                }
            for (UserShareGoodsGroup goodsGroup : list) {
                CommonGoods commonGoods = goodsGroup.getCommonGoods();
                if (commonGoods == null) {
                    continue;
                }
                if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
                    int state = 1; // 默认停售
                    Long goodsId = commonGoods.getGoodsId();
                    for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
                        Long auctionId = taoKeGoods.getAuctionId();
                        if (goodsId == auctionId || goodsId.equals(auctionId)) {
                            state = 0; // 在售
                            break;
                        }
                    }
                    commonGoods.setState(state);
                }
                if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
                    int state = 1; // 默认停售
                    Long goodsId = commonGoods.getGoodsId();
                    for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
                        Long auctionId = taoKeGoods.getAuctionId();
                        if (goodsId == auctionId || goodsId.equals(auctionId)) {
                            state = 0; // 在售
                            break;
                        }
                    }
                    commonGoods.setState(state);
                }
                TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
                TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
                if (goodsBrief.getCouponLeftCount() < 1 || StringUtil.isNullOrEmpty(goodsBrief.getCouponInfo())) {
                    goodsBrief.setState(1); // 已抢光
                }
                if (goodsBrief.getCouponLeftCount() < 1 || StringUtil.isNullOrEmpty(goodsBrief.getCouponInfo())) {
                    goodsBrief.setState(1); // 已抢光
                }
                TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief,
                        shareRate + "", null);
                array.add(gson.toJson(taoBaoGoodsBriefExtra));
            }
                TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief,
                        shareRate + "", null);
                array.add(gson.toJson(taoBaoGoodsBriefExtra));
            }
        }
        }
        String title = "";
        UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordMapper.selectByPrimaryKey(recordId);
        if (userShareGoodsRecord != null) {
            title = userShareGoodsRecord.getTitle();
        }
        String title = "";
        UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordMapper.selectByPrimaryKey(recordId);
        if (userShareGoodsRecord != null) {
            title = userShareGoodsRecord.getTitle();
        }
        JSONObject data = new JSONObject();
        data.put("title", title);
        data.put("count", list.size());
        data.put("result_list", array);
        JSONObject data = new JSONObject();
        data.put("title", title);
        data.put("count", list.size());
        data.put("result_list", array);
        return data;
    }
        return data;
    }
    @Override
    public long countShareRecordByUid(Long uid) {
        return userShareGoodsRecordMapper.countQueryByUid(uid, null);
    }
    @Override
    public long countShareRecordByUid(Long uid) {
        return userShareGoodsRecordMapper.countQueryByUid(uid, null);
    }
    @Override
    public ShareGoodsRecordDTO addRecordGoodsDetail(Long uid, Long auctionId, Integer goodsType, boolean isTaolijin)
            throws UserShareGoodsRecordException {
        if (auctionId == null || uid == null || uid <= 0) {
            throw new UserShareGoodsRecordException(1, "传递参数不正确");
        }
    @Override
    public ShareGoodsRecordDTO addRecordGoodsDetail(Long uid, Long auctionId, Integer goodsType, boolean isTaolijin)
            throws UserShareGoodsRecordException {
        if (auctionId == null || uid == null || uid <= 0) {
            throw new UserShareGoodsRecordException(1, "传递参数不正确");
        }
        ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
        recordDTO.setUid(uid);
        recordDTO.setAuctionId(auctionId);
        recordDTO.setGoodsType(goodsType);
        recordDTO.setTaolijin(isTaolijin);
        recordDTO.setSource(ShareSourceTypeEnum.goodsDetail);
        ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
        recordDTO.setUid(uid);
        recordDTO.setAuctionId(auctionId);
        recordDTO.setGoodsType(goodsType);
        recordDTO.setTaolijin(isTaolijin);
        recordDTO.setSource(ShareSourceTypeEnum.goodsDetail);
        // 分享id
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey,
                StringUtil.Md5(uid + "#GoodsDetail#" + auctionId + "#Type#" + goodsType));
        redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
        recordDTO.setRedisKey(key);
        // 分享id
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey,
                StringUtil.Md5(uid + "#GoodsDetail#" + auctionId + "#Type#" + goodsType));
        redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
        recordDTO.setRedisKey(key);
        return recordDTO;
    }
        return recordDTO;
    }
    @Override
    public ShareGoodsRecordDTO addRecordGoodsStorage(Long uid, List<TaoBaoGoodsBrief> listGoodsBrief,
            List<Long> listStorageID) throws UserShareGoodsRecordException {
        if (uid == null || uid <= 0 || listGoodsBrief == null || listGoodsBrief.size() == 0) {
            throw new UserShareGoodsRecordException(1, "传递参数不正确");
        }
        // 插入记录
        UserShareGoodsRecord record = new UserShareGoodsRecord();
        record.setUid(uid);
        record.setShareState(0); // 初始未分享
        record.setSource(ShareSourceTypeEnum.storage);
        record.setPicture(listGoodsBrief.get(0).getPictUrl()); // 取一个商品图片作为主图
        record.setCreateTime(new Date());
        userShareGoodsRecordMapper.insertSelective(record);
    @Override
    public ShareGoodsRecordDTO addRecordGoodsStorage(Long uid, List<TaoBaoGoodsBrief> listGoodsBrief,
                                                     List<Long> listStorageID) throws UserShareGoodsRecordException {
        if (uid == null || uid <= 0 || listGoodsBrief == null || listGoodsBrief.size() == 0) {
            throw new UserShareGoodsRecordException(1, "传递参数不正确");
        }
        // 插入记录
        UserShareGoodsRecord record = new UserShareGoodsRecord();
        record.setUid(uid);
        record.setShareState(0); // 初始未分享
        record.setSource(ShareSourceTypeEnum.storage);
        record.setPicture(listGoodsBrief.get(0).getPictUrl()); // 取一个商品图片作为主图
        record.setCreateTime(new Date());
        userShareGoodsRecordMapper.insertSelective(record);
        List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
        for (TaoBaoGoodsBrief goodsBrief : listGoodsBrief) {
            listCommonGoods.add(CommonGoodsFactory.create(goodsBrief));
        }
        List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
        for (TaoBaoGoodsBrief goodsBrief : listGoodsBrief) {
            listCommonGoods.add(CommonGoodsFactory.create(goodsBrief));
        }
        Long id = record.getId();
        // 分享链接
        String shareUrl = getShareUrl(record);
        // 分享二维码链接
        FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listCommonGoods);
        Long id = record.getId();
        // 分享链接
        String shareUrl = getShareUrl(record);
        // 分享二维码链接
        FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listCommonGoods);
        ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
        recordDTO.setUid(uid);
        recordDTO.setShareId(id);
        recordDTO.setShareUrl(shareUrl);
        recordDTO.setListId(listStorageID);
        recordDTO.setListGoods(listCommonGoods);
        recordDTO.setSharePictureUrl(uploadResult.getUrl());
        recordDTO.setSource(ShareSourceTypeEnum.storage);
        ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
        recordDTO.setUid(uid);
        recordDTO.setShareId(id);
        recordDTO.setShareUrl(shareUrl);
        recordDTO.setListId(listStorageID);
        recordDTO.setListGoods(listCommonGoods);
        recordDTO.setSharePictureUrl(uploadResult.getUrl());
        recordDTO.setSource(ShareSourceTypeEnum.storage);
        // 缓存分享商品信息
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5(uid + "#GoodsStorage#" + id));
        recordDTO.setRedisKey(key);
        // 缓存分享商品信息
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5(uid + "#GoodsStorage#" + id));
        recordDTO.setRedisKey(key);
        redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
        redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
        return recordDTO;
    }
        return recordDTO;
    }
    @Override
    public ShareGoodsRecordDTO addRecordGoodsStorageV2(Long uid, List<CommonGoods> listGoods, List<Long> listStorageID,
            boolean needDrawPicture) throws UserShareGoodsRecordException {
        if (uid == null || uid <= 0 || listGoods == null || listGoods.size() == 0) {
            throw new UserShareGoodsRecordException(1, "传递参数不正确");
        }
        // 插入记录
        UserShareGoodsRecord record = new UserShareGoodsRecord();
        record.setUid(uid);
        record.setShareState(0); // 初始未分享
        record.setSource(ShareSourceTypeEnum.storage);
        record.setPicture(listGoods.get(0).getPicture()); // 取一个商品图片作为主图
        record.setCreateTime(new Date());
        userShareGoodsRecordMapper.insertSelective(record);
    @Override
    public ShareGoodsRecordDTO addRecordGoodsStorageV2(Long uid, List<CommonGoods> listGoods, List<Long> listStorageID,
                                                       boolean needDrawPicture) throws UserShareGoodsRecordException {
        if (uid == null || uid <= 0 || listGoods == null || listGoods.size() == 0) {
            throw new UserShareGoodsRecordException(1, "传递参数不正确");
        }
        // 插入记录
        UserShareGoodsRecord record = new UserShareGoodsRecord();
        record.setUid(uid);
        record.setShareState(0); // 初始未分享
        record.setSource(ShareSourceTypeEnum.storage);
        record.setPicture(listGoods.get(0).getPicture()); // 取一个商品图片作为主图
        record.setCreateTime(new Date());
        userShareGoodsRecordMapper.insertSelective(record);
        Long id = record.getId();
        // 分享链接
        String shareUrl = getShareUrlV2(record);
        // 分享二维码链接
        Long id = record.getId();
        // 分享链接
        String shareUrl = getShareUrlV2(record);
        // 分享二维码链接
        ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
        recordDTO.setUid(uid);
        recordDTO.setShareId(id);
        recordDTO.setShareUrl(shareUrl);
        recordDTO.setListId(listStorageID);
        recordDTO.setListGoods(listGoods);
        if (needDrawPicture) {
            FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listGoods);
            recordDTO.setSharePictureUrl(uploadResult.getUrl());
        }
        recordDTO.setSource(ShareSourceTypeEnum.storage);
        ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
        recordDTO.setUid(uid);
        recordDTO.setShareId(id);
        recordDTO.setShareUrl(shareUrl);
        recordDTO.setListId(listStorageID);
        recordDTO.setListGoods(listGoods);
        if (needDrawPicture) {
            FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listGoods);
            recordDTO.setSharePictureUrl(uploadResult.getUrl());
        }
        recordDTO.setSource(ShareSourceTypeEnum.storage);
        // 缓存分享商品信息
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5(uid + "#GoodsStorage#" + id));
        recordDTO.setRedisKey(key);
        // 缓存分享商品信息
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5(uid + "#GoodsStorage#" + id));
        recordDTO.setRedisKey(key);
        redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
        redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
        return recordDTO;
    }
        return recordDTO;
    }
    @Override
    public ShareGoodsRecordDTO addRecordActivity(Long uid, List<TaoBaoGoodsBrief> listGoodsBrief)
            throws UserShareGoodsRecordException {
    @Override
    public ShareGoodsRecordDTO addRecordActivity(Long uid, List<TaoBaoGoodsBrief> listGoodsBrief)
            throws UserShareGoodsRecordException {
        if (uid == null || uid <= 0 || listGoodsBrief == null || listGoodsBrief.size() == 0) {
            throw new UserShareGoodsRecordException(1, "传递参数不正确");
        }
        if (uid == null || uid <= 0 || listGoodsBrief == null || listGoodsBrief.size() == 0) {
            throw new UserShareGoodsRecordException(1, "传递参数不正确");
        }
        // 插入记录
        UserShareGoodsRecord record = new UserShareGoodsRecord();
        record.setUid(uid);
        record.setShareState(0); // 初始未分享
        record.setSource(ShareSourceTypeEnum.activity);
        record.setPicture(listGoodsBrief.get(0).getPictUrl()); // 取一个商品图片作为主图
        record.setCreateTime(new Date());
        userShareGoodsRecordMapper.insertSelective(record);
        // 插入记录
        UserShareGoodsRecord record = new UserShareGoodsRecord();
        record.setUid(uid);
        record.setShareState(0); // 初始未分享
        record.setSource(ShareSourceTypeEnum.activity);
        record.setPicture(listGoodsBrief.get(0).getPictUrl()); // 取一个商品图片作为主图
        record.setCreateTime(new Date());
        userShareGoodsRecordMapper.insertSelective(record);
        List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
        for (TaoBaoGoodsBrief goodsBrief : listGoodsBrief) {
            listCommonGoods.add(CommonGoodsFactory.create(goodsBrief));
        }
        List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
        for (TaoBaoGoodsBrief goodsBrief : listGoodsBrief) {
            listCommonGoods.add(CommonGoodsFactory.create(goodsBrief));
        }
        Long id = record.getId();
        // 分享链接
        String shareUrl = getShareUrl(record);
        // 分享二维码链接
        FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listCommonGoods);
        Long id = record.getId();
        // 分享链接
        String shareUrl = getShareUrl(record);
        // 分享二维码链接
        FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listCommonGoods);
        ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
        recordDTO.setUid(uid);
        recordDTO.setShareId(id);
        recordDTO.setListGoods(listCommonGoods);
        recordDTO.setShareUrl(shareUrl);
        recordDTO.setSharePictureUrl(uploadResult.getUrl());
        recordDTO.setSource(ShareSourceTypeEnum.activity);
        // 缓存分享商品信息
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5(uid + "#Activity#" + id));
        recordDTO.setRedisKey(key);
        ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
        recordDTO.setUid(uid);
        recordDTO.setShareId(id);
        recordDTO.setListGoods(listCommonGoods);
        recordDTO.setShareUrl(shareUrl);
        recordDTO.setSharePictureUrl(uploadResult.getUrl());
        recordDTO.setSource(ShareSourceTypeEnum.activity);
        // 缓存分享商品信息
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5(uid + "#Activity#" + id));
        recordDTO.setRedisKey(key);
        redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
        redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
        return recordDTO;
    }
        return recordDTO;
    }
    @Override
    public ShareGoodsRecordDTO addRecordDynamic(Long uid, List<TaoBaoGoodsBrief> listGoodsBrief)
            throws UserShareGoodsRecordException {
        if (uid == null || uid <= 0 || listGoodsBrief == null || listGoodsBrief.size() == 0) {
            throw new UserShareGoodsRecordException(1, "传递参数不正确");
        }
    @Override
    public ShareGoodsRecordDTO addRecordDynamic(Long uid, List<TaoBaoGoodsBrief> listGoodsBrief)
            throws UserShareGoodsRecordException {
        if (uid == null || uid <= 0 || listGoodsBrief == null || listGoodsBrief.size() == 0) {
            throw new UserShareGoodsRecordException(1, "传递参数不正确");
        }
        // 插入记录
        UserShareGoodsRecord record = new UserShareGoodsRecord();
        record.setUid(uid);
        record.setShareState(0); // 初始未分享
        record.setSource(ShareSourceTypeEnum.activity);
        record.setPicture(listGoodsBrief.get(0).getPictUrl()); // 取一个商品图片作为主图
        record.setCreateTime(new Date());
        userShareGoodsRecordMapper.insertSelective(record);
        // 插入记录
        UserShareGoodsRecord record = new UserShareGoodsRecord();
        record.setUid(uid);
        record.setShareState(0); // 初始未分享
        record.setSource(ShareSourceTypeEnum.activity);
        record.setPicture(listGoodsBrief.get(0).getPictUrl()); // 取一个商品图片作为主图
        record.setCreateTime(new Date());
        userShareGoodsRecordMapper.insertSelective(record);
        List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
        for (TaoBaoGoodsBrief goodsBrief : listGoodsBrief) {
            listCommonGoods.add(CommonGoodsFactory.create(goodsBrief));
        }
        List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
        for (TaoBaoGoodsBrief goodsBrief : listGoodsBrief) {
            listCommonGoods.add(CommonGoodsFactory.create(goodsBrief));
        }
        Long id = record.getId();
        // 分享链接
        String shareUrl = getShareUrl(record);
        Long id = record.getId();
        // 分享链接
        String shareUrl = getShareUrl(record);
        ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
        recordDTO.setUid(uid);
        recordDTO.setShareId(id);
        recordDTO.setShareUrl(shareUrl);
        recordDTO.setListGoods(listCommonGoods);
        recordDTO.setSource(ShareSourceTypeEnum.activity);
        ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
        recordDTO.setUid(uid);
        recordDTO.setShareId(id);
        recordDTO.setShareUrl(shareUrl);
        recordDTO.setListGoods(listCommonGoods);
        recordDTO.setSource(ShareSourceTypeEnum.activity);
        // 缓存分享商品信息
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5(uid + "#Dynamic#" + id));
        recordDTO.setRedisKey(key);
        // 缓存分享商品信息
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5(uid + "#Dynamic#" + id));
        recordDTO.setRedisKey(key);
        redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
        redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
        return recordDTO;
    }
        return recordDTO;
    }
    @Override
    public void takeEffectShareRecord(AcceptData acceptData, String shareKey) throws UserShareGoodsRecordException {
        if (StringUtil.isNullOrEmpty(shareKey)) {
            throw new UserShareGoodsRecordException(1, "传递参数不正确");
        }
        ShareGoodsRecordDTO recordDTO = null;
        String redisKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, shareKey);
        String value = redisManager.getCommonString(redisKey);
        if (!StringUtil.isNullOrEmpty(value)) {
            recordDTO = JsonUtil.getSimpleGson().fromJson(value, ShareGoodsRecordDTO.class);
        }
    @Override
    public void takeEffectShareRecord(AcceptData acceptData, String shareKey) throws UserShareGoodsRecordException {
        if (StringUtil.isNullOrEmpty(shareKey)) {
            throw new UserShareGoodsRecordException(1, "传递参数不正确");
        }
        ShareGoodsRecordDTO recordDTO = null;
        String redisKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, shareKey);
        String value = redisManager.getCommonString(redisKey);
        if (!StringUtil.isNullOrEmpty(value)) {
            recordDTO = JsonUtil.getSimpleGson().fromJson(value, ShareGoodsRecordDTO.class);
        }
        if (recordDTO == null) {
            throw new UserShareGoodsRecordException(1, "分享信息不存在");
        }
        if (recordDTO == null) {
            throw new UserShareGoodsRecordException(1, "分享信息不存在");
        }
        Long uid = recordDTO.getUid();
        boolean taolijin = recordDTO.isTaolijin();
        boolean singleGoods = true;
        Long shareId = recordDTO.getShareId();
        ShareSourceTypeEnum source = recordDTO.getSource();
        if (ShareSourceTypeEnum.goodsDetail.equals(source)) {
            // 商品详情分享
            saveSingleShareRecord(recordDTO.getUid(), recordDTO.getAuctionId(), recordDTO.getGoodsType());
        } else if (ShareSourceTypeEnum.activity.equals(source)) {
            // 动态分享
            UserShareGoodsRecord shareRecord = new UserShareGoodsRecord();
            shareRecord.setId(shareId);
            shareRecord.setShareState(1);
            shareRecord.setUpdateTime(new Date());
            updateByPrimaryKeySelective(shareRecord);
        Long uid = recordDTO.getUid();
        boolean taolijin = recordDTO.isTaolijin();
        boolean singleGoods = true;
        Long shareId = recordDTO.getShareId();
        ShareSourceTypeEnum source = recordDTO.getSource();
        if (ShareSourceTypeEnum.goodsDetail.equals(source)) {
            // 商品详情分享
            saveSingleShareRecord(recordDTO.getUid(), recordDTO.getAuctionId(), recordDTO.getGoodsType());
        } else if (ShareSourceTypeEnum.activity.equals(source)) {
            // 动态分享
            UserShareGoodsRecord shareRecord = new UserShareGoodsRecord();
            shareRecord.setId(shareId);
            shareRecord.setShareState(1);
            shareRecord.setUpdateTime(new Date());
            updateByPrimaryKeySelective(shareRecord);
            List<CommonGoods> listGoods = recordDTO.getListGoods();
            if (listGoods != null && listGoods.size() > 1)
                singleGoods = false;
            List<CommonGoods> listGoods = recordDTO.getListGoods();
            if (listGoods != null && listGoods.size() > 1)
                singleGoods = false;
            // 保存商品信息
            multipleGoodsShareRecord(shareId, recordDTO.getListGoods());
            // 保存商品信息
            multipleGoodsShareRecord(shareId, recordDTO.getListGoods());
        } else if (ShareSourceTypeEnum.storage.equals(source)) {
            // 分享库分享
            singleGoods = false;
        } else if (ShareSourceTypeEnum.storage.equals(source)) {
            // 分享库分享
            singleGoods = false;
            UserShareGoodsRecord shareRecord = new UserShareGoodsRecord();
            shareRecord.setId(shareId);
            shareRecord.setShareState(1);
            shareRecord.setUpdateTime(new Date());
            updateByPrimaryKeySelective(shareRecord);
            UserShareGoodsRecord shareRecord = new UserShareGoodsRecord();
            shareRecord.setId(shareId);
            shareRecord.setShareState(1);
            shareRecord.setUpdateTime(new Date());
            updateByPrimaryKeySelective(shareRecord);
            // 保存商品信息
            multipleGoodsShareRecord(shareId, recordDTO.getListGoods());
            // 保存商品信息
            multipleGoodsShareRecord(shareId, recordDTO.getListGoods());
            // 更新选品库商品状态 为已分享
            List<Long> listId = recordDTO.getListId();
            if (listId != null && listId.size() > 0) {
                for (Long id : listId) {
                    UserGoodsStorage userGoodsStorage = new UserGoodsStorage();
                    userGoodsStorage.setId(id);
                    userGoodsStorage.setState(1);
                    userGoodsStorageService.updateByPrimaryKeySelective(userGoodsStorage);
                }
            }
        }
            // 更新选品库商品状态 为已分享
            List<Long> listId = recordDTO.getListId();
            if (listId != null && listId.size() > 0) {
                for (Long id : listId) {
                    UserGoodsStorage userGoodsStorage = new UserGoodsStorage();
                    userGoodsStorage.setId(id);
                    userGoodsStorage.setState(1);
                    userGoodsStorageService.updateByPrimaryKeySelective(userGoodsStorage);
                }
            }
        }
        // 清理缓存
        redisManager.removeCommonString(redisKey);
        // 清理缓存
        redisManager.removeCommonString(redisKey);
        if (singleGoods) {
            if (taolijin) {
                integralGetService.addShareTLJGoods(uid);
            } else {
                integralGetService.addShareSingleGoods(uid);
            }
        } else {
            integralGetService.addShareMultipleGoods(uid);
        }
    }
        if (singleGoods) {
            if (taolijin) {
                integralGetService.addShareTLJGoods(uid);
            } else {
                integralGetService.addShareSingleGoods(uid);
            }
        } else {
            integralGetService.addShareMultipleGoods(uid);
        }
    }
    /**
     * 分享链接
     *
     * @param shareRecord
     * @return
     */
    public String getShareUrl(UserShareGoodsRecord shareRecord) {
        Long uid = shareRecord.getUid();
        Long shareId = shareRecord.getId();
        String source = shareRecord.getSource().name();
    /**
     * 分享链接
     *
     * @param shareRecord
     * @return
     */
    public String getShareUrl(UserShareGoodsRecord shareRecord) {
        Long uid = shareRecord.getUid();
        Long shareId = shareRecord.getId();
        String source = shareRecord.getSource().name();
        String url = String.format("http://%s/share_mushGoods.html?uid=%s&shareId=%s&source=%s",
                configService.getH5Host(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), shareId + "", source + "");
        SystemEnum system = userInfoService.getUserSystem(uid);
        String shortLink = HttpUtil.getShortLink(url);
        if (!StringUtil.isNullOrEmpty(shortLink)) {
            url = shortLink;
        }
        return url;
    }
        String url = String.format("http://%s/share_mushGoods.html?uid=%s&shareId=%s&source=%s",
                configService.getH5Host(system), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), shareId + "", source + "");
    /**
     * 分享链接
     *
     * @param shareRecord
     * @return
     */
    public String getShareUrlV2(UserShareGoodsRecord shareRecord) {
        Long uid = shareRecord.getUid();
        Long shareId = shareRecord.getId();
        String shortLink = HttpUtil.getShortLink(url);
        if (!StringUtil.isNullOrEmpty(shortLink)) {
            url = shortLink;
        }
        return url;
    }
        String url = String.format("http://%s/share_mushGoods_1.6.0.html?uid=%s&shareId=%s", configService.getH5Host(),
                AESUtil.encrypt(uid + "", Constant.UIDAESKEY), shareId + "");
    /**
     * 分享链接
     *
     * @param shareRecord
     * @return
     */
    public String getShareUrlV2(UserShareGoodsRecord shareRecord) {
        Long uid = shareRecord.getUid();
        Long shareId = shareRecord.getId();
        SystemEnum system = userInfoService.getUserSystem(uid);
        String url = String.format("http://%s/share_mushGoods_1.6.0.html?uid=%s&shareId=%s", configService.getH5Host(system),
                AESUtil.encrypt(uid + "", Constant.UIDAESKEY), shareId + "");
        String shortLink = HttpUtil.getShortLink(url);
        if (!StringUtil.isNullOrEmpty(shortLink)) {
            url = shortLink;
        }
        return url;
    }
        String shortLink = HttpUtil.getShortLink(url);
        if (!StringUtil.isNullOrEmpty(shortLink)) {
            url = shortLink;
        }
        return url;
    }
    /**
     * 生成分享图
     *
     * @param uid
     *            用户id
     * @param shareId
     *            分享记录id
     * @param source
     *            来源
     * @param listGoods
     * @return
     * @throws UserShareGoodsRecordException
     */
    public FileUploadResult drawingSharePicture(Long uid, Long shareId, String url, List<CommonGoods> listGoods)
            throws UserShareGoodsRecordException {
    /**
     * 生成分享图
     *
     * @param uid       用户id
     * @param shareId   分享记录id
     * @param listGoods
     * @return
     * @throws UserShareGoodsRecordException
     */
    public FileUploadResult drawingSharePicture(Long uid, Long shareId, String url, List<CommonGoods> listGoods)
            throws UserShareGoodsRecordException {
        InputStream erCodeInputStream = null;
        // 生成链接二维码
        try {
            erCodeInputStream = QRCodeUtil.getInstance(500).encode(url);
        } catch (Exception e) {
            e.printStackTrace();
        }
        InputStream erCodeInputStream = null;
        // 生成链接二维码
        try {
            erCodeInputStream = QRCodeUtil.getInstance(500).encode(url);
        } catch (Exception e) {
            e.printStackTrace();
        }
        // 获取到用户的头像
        UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
        if (user == null) {
            throw new UserShareGoodsRecordException(1, "用户信息不存在");
        }
        // 获取到用户的头像
        UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
        if (user == null) {
            throw new UserShareGoodsRecordException(1, "用户信息不存在");
        }
        InputStream portrait = null;
        if (!StringUtil.isNullOrEmpty(user.getPortrait())) {
            try {
                portrait = HttpUtil.downLoadImg(user.getPortrait());
            } catch (HttpException e) {
                String portraitUrl = userAccountService.repairPortrait(uid);
                if (StringUtil.isNullOrEmpty(portraitUrl))
                    throw new UserShareGoodsRecordException(1, "获取头像出错");
                else {
                    // 再次获取头像
                    try {
                        portrait = HttpUtil.downLoadImg(portraitUrl);
                    } catch (HttpException e1) {
                        throw new UserShareGoodsRecordException(1, "获取头像出错");
                    }
                }
            }
        }
        InputStream portrait = null;
        if (!StringUtil.isNullOrEmpty(user.getPortrait())) {
            try {
                portrait = HttpUtil.downLoadImg(user.getPortrait());
            } catch (HttpException e) {
                String portraitUrl = userAccountService.repairPortrait(uid);
                if (StringUtil.isNullOrEmpty(portraitUrl))
                    throw new UserShareGoodsRecordException(1, "获取头像出错");
                else {
                    // 再次获取头像
                    try {
                        portrait = HttpUtil.downLoadImg(portraitUrl);
                    } catch (HttpException e1) {
                        throw new UserShareGoodsRecordException(1, "获取头像出错");
                    }
                }
            }
        }
        InputStream inputStream = ImageUtil.drawGoodsSharePicture(erCodeInputStream, portrait, listGoods);
        FileUploadResult shareImg = COSManager.getInstance().uploadInputStream(inputStream,
                FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + shareId + "_" + System.currentTimeMillis()
                        + ".png");
        InputStream inputStream = ImageUtil.drawGoodsSharePicture(erCodeInputStream, portrait, listGoods);
        FileUploadResult shareImg = COSManager.getInstance().uploadInputStream(inputStream,
                FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + shareId + "_" + System.currentTimeMillis()
                        + ".png");
        return shareImg;
    }
        return shareImg;
    }
    @Override
    public void saveShareRecord(Long uid, CommonGoods goods) throws UserShareGoodsRecordException {
        if (goods == null || uid == null) {
            throw new UserShareGoodsRecordException(1, "参数缺失");
        }
    @Override
    public void saveShareRecord(Long uid, CommonGoods goods) throws UserShareGoodsRecordException {
        if (goods == null || uid == null) {
            throw new UserShareGoodsRecordException(1, "参数缺失");
        }
        UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
        userShareGoodsRecord.setShareState(1);
        userShareGoodsRecord.setUid(uid);
        userShareGoodsRecord.setSource(ShareSourceTypeEnum.goodsDetail);
        CommonGoods resultCommonGoods = null;
        try {
            resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(goods);
        } catch (CommonGoodsException e) {
            throw new UserShareGoodsRecordException(1, "商品存入失败");
        }
        UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
        userShareGoodsRecord.setShareState(1);
        userShareGoodsRecord.setUid(uid);
        userShareGoodsRecord.setSource(ShareSourceTypeEnum.goodsDetail);
        CommonGoods resultCommonGoods = null;
        try {
            resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(goods);
        } catch (CommonGoodsException e) {
            throw new UserShareGoodsRecordException(1, "商品存入失败");
        }
        UserShareGoodsGroup singleGoods = userShareGoodsGroupService.getSingleGoods(resultCommonGoods.getId(), uid);
        if (singleGoods != null) {
            // 单个商品多次分享
            userShareGoodsRecord.setPicture(resultCommonGoods.getPicture());
            userShareGoodsRecord.setId(singleGoods.getRecordId());
            userShareGoodsRecord.setUpdateTime(new Date());
            userShareGoodsRecordMapper.updateByPrimaryKeySelective(userShareGoodsRecord);
        UserShareGoodsGroup singleGoods = userShareGoodsGroupService.getSingleGoods(resultCommonGoods.getId(), uid);
        if (singleGoods != null) {
            // 单个商品多次分享
            userShareGoodsRecord.setPicture(resultCommonGoods.getPicture());
            userShareGoodsRecord.setId(singleGoods.getRecordId());
            userShareGoodsRecord.setUpdateTime(new Date());
            userShareGoodsRecordMapper.updateByPrimaryKeySelective(userShareGoodsRecord);
            // 最新商品
            singleGoods.setUpdateTime(new Date());
            userShareGoodsGroupService.updateByPrimaryKeySelective(singleGoods);
        } else {
            // 单个商品第一次分享
            Date date = new Date();
            userShareGoodsRecord.setPicture(resultCommonGoods.getPicture());
            userShareGoodsRecord.setCreateTime(date);
            userShareGoodsRecord.setUpdateTime(date);
            userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord);
            // 最新商品
            singleGoods.setUpdateTime(new Date());
            userShareGoodsGroupService.updateByPrimaryKeySelective(singleGoods);
        } else {
            // 单个商品第一次分享
            Date date = new Date();
            userShareGoodsRecord.setPicture(resultCommonGoods.getPicture());
            userShareGoodsRecord.setCreateTime(date);
            userShareGoodsRecord.setUpdateTime(date);
            userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord);
            singleGoods = new UserShareGoodsGroup();
            singleGoods.setTotalOrder(0);
            singleGoods.setTotalBrowse(0);
            singleGoods.setTodayBrowse(0);
            singleGoods.setTotalMoney(new BigDecimal(0));
            singleGoods.setCreateTime(date);
            singleGoods.setUpdateTime(date);
            singleGoods.setCommonGoods(resultCommonGoods);
            singleGoods.setRecordId(userShareGoodsRecord.getId());
            userShareGoodsGroupService.insertSelective(singleGoods);
        }
    }
            singleGoods = new UserShareGoodsGroup();
            singleGoods.setTotalOrder(0);
            singleGoods.setTotalBrowse(0);
            singleGoods.setTodayBrowse(0);
            singleGoods.setTotalMoney(new BigDecimal(0));
            singleGoods.setCreateTime(date);
            singleGoods.setUpdateTime(date);
            singleGoods.setCommonGoods(resultCommonGoods);
            singleGoods.setRecordId(userShareGoodsRecord.getId());
            userShareGoodsGroupService.insertSelective(singleGoods);
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java
@@ -102,1264 +102,1263 @@
@Service
public class UserCloudServiceImpl implements UserCloudService {
    @Resource
    private UserCloudMapper userCloudMapper;
    @Resource
    private UserCloudMapper userCloudMapper;
    @Resource
    private UserCloudGroupService userCloudGroupService;
    @Resource
    private UserCloudGroupService userCloudGroupService;
    @Resource
    private GoodsEvaluateService goodsEvaluateService;
    @Resource
    private GoodsEvaluateService goodsEvaluateService;
    @Resource
    private ConvertLinkManager convertLinkManager;
    @Resource
    private ConvertLinkManager convertLinkManager;
    @Resource
    private UserCloudGoodsService userCloudGoodsService;
    @Resource
    private UserCloudGoodsService userCloudGoodsService;
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @Resource
    private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
    @Resource
    private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private ShareGoodsService shareGoodsService;
    @Resource
    private ShareGoodsService shareGoodsService;
    @Resource
    private ConfigService configService;
    @Resource
    private ConfigService configService;
    @Resource
    private JDGoodsCacheUtil jdGoodsCacheUtil;
    @Resource
    private JDGoodsCacheUtil jdGoodsCacheUtil;
    @Resource
    private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
    @Resource
    private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
    @Resource
    private RedisManager redisManager;
    @Resource
    private RedisManager redisManager;
    @Resource
    private ShareGoodsTextTemplateService shareGoodsTextTemplateService;
    @Resource
    private ShareGoodsTextTemplateService shareGoodsTextTemplateService;
    @Resource
    private UserCloudSendRecordService userCloudSendRecordService;
    @Resource
    private UserCloudSendRecordService userCloudSendRecordService;
    @Resource
    private UserCloudSendContentService userCloudSendContentService;
    @Resource
    private UserCloudSendContentService userCloudSendContentService;
    @Resource
    private UserCloudManageService userCloudManageService;
    @Resource
    private UserCloudManageService userCloudManageService;
    @Resource
    private RocketMQManager rocketMQManager;
    @Resource
    private RocketMQManager rocketMQManager;
    @Resource
    private UserOtherMsgNotificationService userOtherMsgNotificationService;
    @Resource
    private UserOtherMsgNotificationService userOtherMsgNotificationService;
    @Resource
    private PushService pushService;
    @Resource
    private PushService pushService;
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    @Resource
    private TaoBaoLinkManager taoBaoLinkManager;
    @Resource
    private TaoBaoLinkManager taoBaoLinkManager;
    @Override
    public UserCloud getValidByUid(Long uid) {
        return userCloudMapper.getValidByUid(uid);
    }
    @Override
    public UserCloud getValidByUid(Long uid) {
        return userCloudMapper.getValidByUid(uid);
    }
    @Override
    public UserCloud getLastByUid(Long uid) {
        return userCloudMapper.getLastByUid(uid);
    }
    @Override
    public UserCloud getLastByUid(Long uid) {
        return userCloudMapper.getLastByUid(uid);
    }
    @Override
    public long countByUid(Long uid) {
        Long count = userCloudMapper.countByUid(uid);
        return count;
    }
    @Override
    public long countByUid(Long uid) {
        Long count = userCloudMapper.countByUid(uid);
        return count;
    }
    @Override
    public List<UserCloud> query(int page, int count, String key, Integer state) {
        return userCloudMapper.query((page - 1) * count, count, key, state);
    }
    @Override
    public List<UserCloud> query(int page, int count, String key, Integer state) {
        return userCloudMapper.query((page - 1) * count, count, key, state);
    }
    @Override
    public long count(String key, Integer state) {
        Long count = userCloudMapper.count(key, state);
        if (count == null)
            count = 0L;
        return count;
    }
    @Override
    public long count(String key, Integer state) {
        Long count = userCloudMapper.count(key, state);
        if (count == null)
            count = 0L;
        return count;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateWXInfo(Long uid, String wxId, String wxName, String wxPortrait) throws UserCloudException {
        UserCloud userCloud = userCloudMapper.getValidByUid(uid);
        if (userCloud == null)
            throw new UserCloudException(1, "云发单已过期");
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateWXInfo(Long uid, String wxId, String wxName, String wxPortrait) throws UserCloudException {
        UserCloud userCloud = userCloudMapper.getValidByUid(uid);
        if (userCloud == null)
            throw new UserCloudException(1, "云发单已过期");
        // 检测是否需要更新 - 1分钟间隔
        String key = "cloudLogin_" + uid;
        String result = redisManager.getCommonString(key);
        if (!StringUtil.isNullOrEmpty(result)) {
            return;
        }
        redisManager.cacheCommonString(key, "true", 60);
        // 检测是否需要更新 - 1分钟间隔
        String key = "cloudLogin_" + uid;
        String result = redisManager.getCommonString(key);
        if (!StringUtil.isNullOrEmpty(result)) {
            return;
        }
        redisManager.cacheCommonString(key, "true", 60);
        // 更新信息
        UserCloud update = new UserCloud();
        update.setId(userCloud.getId());
        update.setWxId(wxId);
        update.setWxName(wxName);
        update.setWxPortrait(wxPortrait);
        userCloudMapper.updateByPrimaryKeySelective(update);
        // 更新信息
        UserCloud update = new UserCloud();
        update.setId(userCloud.getId());
        update.setWxId(wxId);
        update.setWxName(wxName);
        update.setWxPortrait(wxPortrait);
        userCloudMapper.updateByPrimaryKeySelective(update);
        try {
            userOtherMsgNotificationService.cloudMsg(uid, "云发单微信账号", "微信账号登录成功", "可以开启你的群发单了");
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
        try {
            userOtherMsgNotificationService.cloudMsg(uid, "云发单微信账号", "微信账号登录成功", "可以开启你的群发单了");
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
        // 更新提醒状态
        UserCloudManage cloudManage = userCloudManageService.selectForUpdate(uid);
        if (cloudManage == null) {
            userCloudManageService.save(uid, false, false);
        } else {
            UserCloudManage updateManage = new UserCloudManage();
            updateManage.setId(uid);
            updateManage.setOfflineNotice(false);
            userCloudManageService.updateByPrimaryKeySelective(updateManage);
        }
        // 更新提醒状态
        UserCloudManage cloudManage = userCloudManageService.selectForUpdate(uid);
        if (cloudManage == null) {
            userCloudManageService.save(uid, false, false);
        } else {
            UserCloudManage updateManage = new UserCloudManage();
            updateManage.setId(uid);
            updateManage.setOfflineNotice(false);
            userCloudManageService.updateByPrimaryKeySelective(updateManage);
        }
        // 微信号变化-清空群信息
        if (!wxId.equals(userCloud.getWxId())) {
            userCloudGroupService.deleteGroupByUid(uid);
        }
        // 微信号变化-清空群信息
        if (!wxId.equals(userCloud.getWxId())) {
            userCloudGroupService.deleteGroupByUid(uid);
        }
        // 加入朋友圈
        if (StringUtil.isNullOrEmpty(userCloud.getWxId())) {
            userCloudGroupService.addCircle(uid);
        }
    }
        // 加入朋友圈
        if (StringUtil.isNullOrEmpty(userCloud.getWxId())) {
            userCloudGroupService.addCircle(uid);
        }
    }
    @Override
    public void openCloud(Long uid, Long orderId, CloudOrderMenuEnum menuEnum) throws UserCloudException {
        UserCloud existCloud = userCloudMapper.getByOrderId(orderId);
        if (existCloud != null) {
            return; // 该订单已处理完成
        }
    @Override
    public void openCloud(Long uid, Long orderId, CloudOrderMenuEnum menuEnum) throws UserCloudException {
        UserCloud existCloud = userCloudMapper.getByOrderId(orderId);
        if (existCloud != null) {
            return; // 该订单已处理完成
        }
        boolean renew = false;
        UserCloud userCloud = userCloudMapper.getLastByUid(uid);
        if (userCloud != null) {
            // 续费
            if (userCloud.getEndTime().getTime() > java.lang.System.currentTimeMillis())
                renew = true;
            // 验证套餐是否相同
            if (renew && userCloud.getRobotType() != menuEnum.getRobotType()) {
                LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]已有其他云发单套餐还未结束");
                throw new UserCloudException(1, "已有其他云发单套餐还未结束");
            }
        }
        boolean renew = false;
        UserCloud userCloud = userCloudMapper.getLastByUid(uid);
        if (userCloud != null) {
            // 续费
            if (userCloud.getEndTime().getTime() > java.lang.System.currentTimeMillis())
                renew = true;
            // 验证套餐是否相同
            if (renew && userCloud.getRobotType() != menuEnum.getRobotType()) {
                LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]已有其他云发单套餐还未结束");
                throw new UserCloudException(1, "已有其他云发单套餐还未结束");
            }
        }
        RobotInfoDTO dto = null;
        if (renew) { // 续费
            dto = AitaokerApiUtil.robotRenewals(userCloud.getRobotId(), menuEnum.getMonth());
        } else { // 创建机器人
            dto = AitaokerApiUtil.robotCreate(menuEnum.getMonth(), menuEnum.getRobotType(), "wechatrobot", null);
        }
        RobotInfoDTO dto = null;
        if (renew) { // 续费
            dto = AitaokerApiUtil.robotRenewals(userCloud.getRobotId(), menuEnum.getMonth());
        } else { // 创建机器人
            dto = AitaokerApiUtil.robotCreate(menuEnum.getMonth(), menuEnum.getRobotType(), "wechatrobot", null);
        }
        if (dto == null) {
            LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: 机器人创建失败");
        }
        if (dto == null) {
            LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: 机器人创建失败");
        }
        Integer robotId = dto.getId();
        if (robotId == null) {
            LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: 机器人ID返回为空");
        }
        Integer robotId = dto.getId();
        if (robotId == null) {
            LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: 机器人ID返回为空");
        }
        String endTimeStr = dto.getEndTime();
        if (StringUtil.isNullOrEmpty(endTimeStr)) {
            LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: 返回时间为空");
        }
        String endTimeStr = dto.getEndTime();
        if (StringUtil.isNullOrEmpty(endTimeStr)) {
            LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: 返回时间为空");
        }
        long endTime = 0;
        try {
            endTime = Long.parseLong(endTimeStr);
        } catch (Exception e) {
            LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: 返回时间格式不正确");
        }
        long endTime = 0;
        try {
            endTime = Long.parseLong(endTimeStr);
        } catch (Exception e) {
            LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: 返回时间格式不正确");
        }
        Integer groupNum = dto.getGroupNum();
        if (groupNum == null) {
            LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: groupNum返回为空");
        }
        Integer groupNum = dto.getGroupNum();
        if (groupNum == null) {
            LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: groupNum返回为空");
        }
        UserCloud newCloud = new UserCloud();
        newCloud.setUid(uid);
        newCloud.setOrderId(orderId);
        newCloud.setGroupNum(groupNum);
        newCloud.setRobotId(robotId);
        newCloud.setRobotType(menuEnum.getRobotType());
        if (renew) {
            newCloud.setWxId(userCloud.getWxId());
            newCloud.setWxName(userCloud.getWxName());
            newCloud.setWxPortrait(userCloud.getPortrait());
            newCloud.setStartTime(userCloud.getStartTime());
        } else {
            newCloud.setStartTime(new Date());
        }
        newCloud.setEndTime(new Date(endTime * 1000)); // Unix 转换 普通时间
        newCloud.setCreateTime(new Date());
        userCloudMapper.insertSelective(newCloud);
        UserCloud newCloud = new UserCloud();
        newCloud.setUid(uid);
        newCloud.setOrderId(orderId);
        newCloud.setGroupNum(groupNum);
        newCloud.setRobotId(robotId);
        newCloud.setRobotType(menuEnum.getRobotType());
        if (renew) {
            newCloud.setWxId(userCloud.getWxId());
            newCloud.setWxName(userCloud.getWxName());
            newCloud.setWxPortrait(userCloud.getPortrait());
            newCloud.setStartTime(userCloud.getStartTime());
        } else {
            newCloud.setStartTime(new Date());
        }
        newCloud.setEndTime(new Date(endTime * 1000)); // Unix 转换 普通时间
        newCloud.setCreateTime(new Date());
        userCloudMapper.insertSelective(newCloud);
        // 开启发圈功能
        userCloudManageService.save(uid, null, null);
        // 开启发圈功能
        userCloudManageService.save(uid, null, null);
        try {
            String item = null;
            if (renew) {
                item = "成功续费" + menuEnum.getDescShow();
            } else {
                item = "成功开通" + menuEnum.getDescShow();
            }
            String desc = "完成充值支付" + BigDecimal.valueOf(menuEnum.getMoney()).setScale(2, BigDecimal.ROUND_DOWN) + "元";
            userOtherMsgNotificationService.cloudMsg(uid, "云发单充值", item, desc);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
    }
        try {
            String item = null;
            if (renew) {
                item = "成功续费" + menuEnum.getDescShow();
            } else {
                item = "成功开通" + menuEnum.getDescShow();
            }
            String desc = "完成充值支付" + BigDecimal.valueOf(menuEnum.getMoney()).setScale(2, BigDecimal.ROUND_DOWN) + "元";
            userOtherMsgNotificationService.cloudMsg(uid, "云发单充值", item, desc);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
    }
    @Override
    public void searchGroup(Long uid) throws UserCloudException {
        UserCloud userCloud = userCloudMapper.getValidByUid(uid);
        if (userCloud == null)
            throw new UserCloudException(1, "云发单已过期");
    @Override
    public void searchGroup(Long uid) throws UserCloudException {
        UserCloud userCloud = userCloudMapper.getValidByUid(uid);
        if (userCloud == null)
            throw new UserCloudException(1, "云发单已过期");
        Integer robotId = userCloud.getRobotId();
        if (robotId == null)
            throw new UserCloudException(1, "云发单机器人不存在");
        Integer robotId = userCloud.getRobotId();
        if (robotId == null)
            throw new UserCloudException(1, "云发单机器人不存在");
        List<String> list = AitaokerApiUtil.getContract(robotId);
        if (list == null || list.size() == 0)
            throw new UserCloudException(1, "未检索到对应群");
        List<String> list = AitaokerApiUtil.getContract(robotId);
        if (list == null || list.size() == 0)
            throw new UserCloudException(1, "未检索到对应群");
        String wxId = userCloud.getWxId();
        for (String roomId : list) {
            String key = RedisKeyEnum.cloudMatchGroup.getKey() + StringUtil.Md5(wxId + "_" + roomId);
            String result = redisManager.getCommonString(key);
            if (!StringUtil.isNullOrEmpty(result)) {
                String groupName = null;
                WeiXinGroupDTO groupDetail = AitaokerApiUtil.getGroupDetail(robotId, roomId);
                if (groupDetail != null) {
                    groupName = groupDetail.getGroupName();
                }
                userCloudGroupService.addGroup(uid, roomId, groupName, userCloud.getGroupNum());
            }
        }
    }
        String wxId = userCloud.getWxId();
        for (String roomId : list) {
            String key = RedisKeyEnum.cloudMatchGroup.getKey() + StringUtil.Md5(wxId + "_" + roomId);
            String result = redisManager.getCommonString(key);
            if (!StringUtil.isNullOrEmpty(result)) {
                String groupName = null;
                WeiXinGroupDTO groupDetail = AitaokerApiUtil.getGroupDetail(robotId, roomId);
                if (groupDetail != null) {
                    groupName = groupDetail.getGroupName();
                }
                userCloudGroupService.addGroup(uid, roomId, groupName, userCloud.getGroupNum());
            }
        }
    }
    @Override
    public void cacheMatchGroup(String wxId, String groupId) {
        if (StringUtil.isNullOrEmpty(wxId) || StringUtil.isNullOrEmpty(groupId))
            return;
        String key = RedisKeyEnum.cloudMatchGroup.getKey() + StringUtil.Md5(wxId + "_" + groupId);
        redisManager.cacheCommonString(key, "true", 60 * 20);
    }
    @Override
    public void cacheMatchGroup(String wxId, String groupId) {
        if (StringUtil.isNullOrEmpty(wxId) || StringUtil.isNullOrEmpty(groupId))
            return;
        String key = RedisKeyEnum.cloudMatchGroup.getKey() + StringUtil.Md5(wxId + "_" + groupId);
        redisManager.cacheCommonString(key, "true", 60 * 20);
    }
    @Override
    public void sendByDynamic(Long uid, String id) throws UserCloudException {
        sendCircleByDynamic(uid, id, UserCloudSendRecord.SEND_WAY_MANUAL);
    }
    @Override
    public void sendByDynamic(Long uid, String id) throws UserCloudException {
        sendCircleByDynamic(uid, id, UserCloudSendRecord.SEND_WAY_MANUAL);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void autoSendByDynamic(Long uid, String id) {
        boolean official = false;
        UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
        if (cloudManage != null) {
            if (cloudManage.getOfficial() != null)
                official = cloudManage.getOfficial();
        }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void autoSendByDynamic(Long uid, String id) {
        boolean official = false;
        UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
        if (cloudManage != null) {
            if (cloudManage.getOfficial() != null)
                official = cloudManage.getOfficial();
        }
        if (!official)
            return;
        if (!official)
            return;
        try {
            sendCircleByDynamic(uid, id, UserCloudSendRecord.SEND_WAY_AUTO);
        } catch (UserCloudException e) {
            LogHelper.cloudInfo("autoSendByDynamic - [uid:" + uid + " 动态id:" + id + "]原因:" + e.getMsg());
        }
    }
        try {
            sendCircleByDynamic(uid, id, UserCloudSendRecord.SEND_WAY_AUTO);
        } catch (UserCloudException e) {
            LogHelper.cloudInfo("autoSendByDynamic - [uid:" + uid + " 动态id:" + id + "]原因:" + e.getMsg());
        }
    }
    private void sendCircleByDynamic(Long uid, String id, int way) throws UserCloudException {
        long time1 = java.lang.System.currentTimeMillis();
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        if (user == null)
            throw new UserCloudException(1, "用户信息不存在");
    private void sendCircleByDynamic(Long uid, String id, int way) throws UserCloudException {
        long time1= java.lang.System.currentTimeMillis();
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        if (user == null)
            throw new UserCloudException(1, "用户信息不存在");
        if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
            throw new UserCloudException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
        }
        if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
            throw new UserCloudException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
        }
        String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
        if (StringUtil.isNullOrEmpty(inviteCode))
            throw new UserCloudException(3, "邀请码未激活");
        String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
        if (StringUtil.isNullOrEmpty(inviteCode))
            throw new UserCloudException(3, "邀请码未激活");
        UserExtraTaoBaoInfo taoBaoInfo = userExtraTaoBaoInfoService.getByUid(uid);
        String relationId = null;
        if (taoBaoInfo != null && taoBaoInfo.getRelationId() != null && taoBaoInfo.getRelationValid() != null
                && taoBaoInfo.getRelationValid() == true)
            relationId = taoBaoInfo.getRelationId();
        UserExtraTaoBaoInfo taoBaoInfo = userExtraTaoBaoInfoService.getByUid(uid);
        String relationId = null;
        if (taoBaoInfo != null && taoBaoInfo.getRelationId() != null && taoBaoInfo.getRelationValid() != null
                && taoBaoInfo.getRelationValid() == true)
            relationId = taoBaoInfo.getRelationId();
        if (StringUtil.isNullOrEmpty(relationId))
            throw new UserCloudException(2, "淘宝未授权,请前往\"我的\"绑定淘宝账号");
        if (StringUtil.isNullOrEmpty(relationId))
            throw new UserCloudException(2, "淘宝未授权,请前往\"我的\"绑定淘宝账号");
        long time2= java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByDynamic保验证用户状态:" + (time2 - time1));
        long time2 = java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByDynamic保验证用户状态:" + (time2 - time1));
        // 验证是否开通
        UserCloud userCloud = userCloudMapper.getValidByUid(uid);
        if (userCloud == null)
            throw new UserCloudException(1001, "云发单已过期");
        Integer robotId = userCloud.getRobotId();
        if (robotId == null)
            throw new UserCloudException(1002, "云发单机器人不存在");
        // 验证是否开通
        UserCloud userCloud = userCloudMapper.getValidByUid(uid);
        if (userCloud == null)
            throw new UserCloudException(1001, "云发单已过期");
        String wxId = userCloud.getWxId();
        if (StringUtil.isNullOrEmpty(wxId))
            throw new UserCloudException(1003, "微信号不存在,请先微信登录");
        Integer robotId = userCloud.getRobotId();
        if (robotId == null)
            throw new UserCloudException(1002, "云发单机器人不存在");
        long time3= java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByDynamic验证是否满足开通:" + (time3 - time2));
        String wxId = userCloud.getWxId();
        if (StringUtil.isNullOrEmpty(wxId))
            throw new UserCloudException(1003, "微信号不存在,请先微信登录");
        // 验证开启状态
        List<UserCloudGroup> listGroup = userCloudGroupService.listByUid(uid);
        if (listGroup == null || listGroup.size() == 0)
            throw new UserCloudException(1004, "请先微信登录");
        long time3 = java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByDynamic验证是否满足开通:" + (time3 - time2));
        List<UserCloudGroup> listOpen = new ArrayList<>();
        for (UserCloudGroup cloudGrou : listGroup) {
            if (cloudGrou.getState()) {
                listOpen.add(cloudGrou);
            }
        }
        if (listOpen.size() == 0)
            throw new UserCloudException(1005, "请先开启云发单群功能");
        long time4= java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByDynamic验证是否开启:" + (time4 - time3));
        // 验证发圈是否可行
        GoodsEvaluate evaluate = goodsEvaluateService.getById(id);
        if (evaluate == null || evaluate.getState() == 0)
            throw new UserCloudException(1, "该内容已下架");
        // 验证开启状态
        List<UserCloudGroup> listGroup = userCloudGroupService.listByUid(uid);
        if (listGroup == null || listGroup.size() == 0)
            throw new UserCloudException(1004, "请先微信登录");
        if (evaluate.getType() != EvaluateEnum.single && evaluate.getType() != EvaluateEnum.activity)
            throw new UserCloudException(1, "该内容不支持云发单");
        List<UserCloudGroup> listOpen = new ArrayList<>();
        for (UserCloudGroup cloudGrou : listGroup) {
            if (cloudGrou.getState()) {
                listOpen.add(cloudGrou);
            }
        }
        if (listOpen.size() == 0)
            throw new UserCloudException(1005, "请先开启云发单群功能");
        // 验证是否可转链
        List<CommentInfo> comments = evaluate.getComments();
        if (comments == null || comments.size() == 0)
            throw new UserCloudException(1, "该内容不能转链");
        long time4 = java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByDynamic验证是否开启:" + (time4 - time3));
        long time5= java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByDynamic验证发圈内容是否满足:" + (time5 - time4));
        // 检测微信是否登录状态
        if (!AitaokerApiUtil.onlineCheck(robotId)) {
            // 通知登录微信
            offlineNotification(uid);
        // 验证发圈是否可行
        GoodsEvaluate evaluate = goodsEvaluateService.getById(id);
        if (evaluate == null || evaluate.getState() == 0)
            throw new UserCloudException(1, "该内容已下架");
            throw new UserCloudException(1003, "微信已掉线,需要重新扫描二维码登录");
        }
        if (evaluate.getType() != EvaluateEnum.single && evaluate.getType() != EvaluateEnum.activity)
            throw new UserCloudException(1, "该内容不支持云发单");
        long time6= java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByDynamic验证发是否登录:" + (time6 - time5));
        boolean hasToken = false;
        List<String> listComment = new ArrayList<>();
        for (CommentInfo commentInfo : comments) {
            String comment = null;
            try {
                comment = convertLinkManager.convertLinkFromText(commentInfo.getContent(), uid, true);
                hasToken = true;
            } catch (ConvertLinkExceptionException e) {
                if (e.getCode() != ConvertLinkExceptionException.CODE_NONE) {
                    throw new UserCloudException(1, e.getMsg());
                }
            } catch (Exception e) {
                LogHelper.errorDetailInfo(e);
                throw new UserCloudException(1, "该内容包含可转链口令或链接");
            }
        // 验证是否可转链
        List<CommentInfo> comments = evaluate.getComments();
        if (comments == null || comments.size() == 0)
            throw new UserCloudException(1, "该内容不能转链");
            if (StringUtil.isNullOrEmpty(comment))
                comment = commentInfo.getContent();
        long time5 = java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByDynamic验证发圈内容是否满足:" + (time5 - time4));
            // 替换价格
            if (evaluate.getType() == EvaluateEnum.single) {
                GoodsDetailVO goods = evaluate.getGoods();
                comment = comment.replace("[原价]", MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "");
                if (!goods.isHasCoupon()) {
                    comment = comment.replace("领券抢购", "抢购");
                    comment = comment.replace("【券后价】[券后价]元", "");
                } else {
                    comment = comment.replace("[券后价]", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponPrice()) + "");
                }
                comment = comment.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
            }
        // 检测微信是否登录状态
        if (!AitaokerApiUtil.onlineCheck(robotId)) {
            // 通知登录微信
            offlineNotification(uid);
            listComment.add(comment);
        }
            throw new UserCloudException(1003, "微信已掉线,需要重新扫描二维码登录");
        }
        if (!hasToken)
            throw new UserCloudException(1, "该内容包含可转链口令或链接");
        // 异步执行发送
        executor.execute(new Runnable() {
            @Override
            public void run() {
                sendEvaluate(uid, evaluate, way, userCloud, listOpen, listComment);
            }
        });
    }
        long time6 = java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByDynamic验证发是否登录:" + (time6 - time5));
    private void sendEvaluate(Long uid, GoodsEvaluate evaluate, int way, UserCloud userCloud,
            List<UserCloudGroup> listOpen, List<String> listComment) {
        ImgInfo imgVideo = null;
        List<String> listImg = new ArrayList<>();
        boolean hasToken = false;
        List<String> listComment = new ArrayList<>();
        for (CommentInfo commentInfo : comments) {
            String comment = null;
            try {
                comment = convertLinkManager.convertLinkFromText(commentInfo.getContent(), uid, true);
                hasToken = true;
            } catch (ConvertLinkExceptionException e) {
                if (e.getCode() != ConvertLinkExceptionException.CODE_NONE) {
                    throw new UserCloudException(1, e.getMsg());
                }
            } catch (Exception e) {
                LogHelper.errorDetailInfo(e);
                throw new UserCloudException(1, "该内容包含可转链口令或链接");
            }
        List<ImgInfo> imgs = evaluate.getImgList();
        if (imgs != null && imgs.size() > 0) {
            for (ImgInfo imgInfo : imgs) {
                if (imgInfo.getType() == ImgEnum.video) {
                    imgVideo = imgInfo;
                    continue;
                }
                listImg.add(imgInfo.getUrl());
            }
        }
            if (StringUtil.isNullOrEmpty(comment))
                comment = commentInfo.getContent();
            // 替换价格
            if (evaluate.getType() == EvaluateEnum.single) {
                GoodsDetailVO goods = evaluate.getGoods();
                comment = comment.replace("[原价]", MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "");
                if (!goods.isHasCoupon()) {
                    comment = comment.replace("领券抢购", "抢购");
                    comment = comment.replace("【券后价】[券后价]元", "");
                } else {
                    comment = comment.replace("[券后价]", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponPrice()) + "");
                }
                comment = comment.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
            }
        String wxId = userCloud.getWxId();
        Integer robotId = userCloud.getRobotId();
        // 保存发送记录
        UserCloudSendRecord sendRecord = new UserCloudSendRecord();
        sendRecord.setUid(uid);
        sendRecord.setSendId(evaluate.getId());
        sendRecord.setSendWay(way);
        sendRecord.setWxId(wxId);
        sendRecord.setRobotId(robotId);
        sendRecord.setSendTime(new Date());
        sendRecord.setSendOrigin(UserCloudSendRecord.ORIGIN_EVALUATE);
        UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord);
        String pid = result.getId();
            listComment.add(comment);
        }
        for (UserCloudGroup cloudGroup : listOpen) {
            String title = evaluate.getTitle();
        if (!hasToken)
            throw new UserCloudException(1, "该内容包含可转链口令或链接");
            UserCloudSendContent sendContent = new UserCloudSendContent();
            sendContent.setPid(pid);
            sendContent.setUid(uid);
            sendContent.setGroupId(cloudGroup.getGroupId());
            sendContent.setCreateTime(new Date());
        // 异步执行发送
        executor.execute(new Runnable() {
            @Override
            public void run() {
                sendEvaluate(uid, evaluate, way, userCloud, listOpen, listComment);
            }
        });
    }
            if (cloudGroup.getType() == UserCloudGroup.TYPE_CIRCLE) { // 朋友圈
                String circleId = null;
                sendContent.setType(UserCloudSendContent.TYPE_CIRCLE);
    private void sendEvaluate(Long uid, GoodsEvaluate evaluate, int way, UserCloud userCloud,
                              List<UserCloudGroup> listOpen, List<String> listComment) {
        ImgInfo imgVideo = null;
        List<String> listImg = new ArrayList<>();
                if (imgVideo == null) {
        List<ImgInfo> imgs = evaluate.getImgList();
        if (imgs != null && imgs.size() > 0) {
            for (ImgInfo imgInfo : imgs) {
                if (imgInfo.getType() == ImgEnum.video) {
                    imgVideo = imgInfo;
                    continue;
                }
                listImg.add(imgInfo.getUrl());
            }
        }
                    // 发送图文
                    String picUrl = "";
                    if (listImg.size() > 0) {
                        for (String img : listImg) {
                            picUrl += img + ";";
                        }
                        if (picUrl.endsWith(";"))
                            picUrl = picUrl.substring(0, picUrl.length() - 1);
                    }
                    String picUrlUpload = AitaokerApiUtil.macsendUpload(robotId, picUrl);
                    sendContent.setPicUrlUpload(picUrlUpload);
                    sendContent.setTitle(title);
                    sendContent.setPicUrl(picUrl);
                    circleId = AitaokerApiUtil.macsendCircle(robotId, title, picUrlUpload);
                } else {
                    // 发送视频
                    sendContent.setPicUrl(imgVideo.getUrl());
                    sendContent.setVideoUrl(imgVideo.getVideoUrl());
                    circleId = AitaokerApiUtil.macsendCircleVideo(robotId, imgVideo.getVideoUrl(), imgVideo.getUrl());
                }
                // 评论文本
                if (!StringUtil.isNullOrEmpty(circleId)) {
                    sendContent.setState(true);
                    List<String> list = new ArrayList<>();
                    for (String comment : listComment) {
                        boolean macsend = AitaokerApiUtil.macsendCircleComment(robotId, wxId, circleId, comment);
                        if (macsend) {
                            list.add(comment);
                        }
                    }
                    sendContent.setComments(list);
                }
            } else { // 群
                sendContent.setType(UserCloudSendContent.TYPE_GROUP);
        String wxId = userCloud.getWxId();
        Integer robotId = userCloud.getRobotId();
        // 保存发送记录
        UserCloudSendRecord sendRecord = new UserCloudSendRecord();
        sendRecord.setUid(uid);
        sendRecord.setSendId(evaluate.getId());
        sendRecord.setSendWay(way);
        sendRecord.setWxId(wxId);
        sendRecord.setRobotId(robotId);
        sendRecord.setSendTime(new Date());
        sendRecord.setSendOrigin(UserCloudSendRecord.ORIGIN_EVALUATE);
        UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord);
        String pid = result.getId();
                // 发送文本
                if (!StringUtil.isNullOrEmpty(title)) {
                    boolean macsend = AitaokerApiUtil.macsendText(robotId, cloudGroup.getGroupId(), title);
                    if (macsend)
                        sendContent.setTitle(title);
                }
                SystemEnum system=userInfoService.getUserSystem(uid);
                // 发送图片
                int num = 1;
                String picNum = configService.getValue(ConfigKeyEnum.robotCloudGroupPictureNum.getKey(),system);
                if (!StringUtil.isNullOrEmpty(picNum)) {
                    num = Integer.parseInt(picNum);
                }
                if (listImg.size() > 0)
                    for (int i = 0; i < num && i < listImg.size(); i++) {
                        try {
                            String imgBase64 = ImageToBase64.NetImageToBase64(listImg.get(i));
                            boolean macsend = AitaokerApiUtil.macsendImgBase64(robotId, cloudGroup.getGroupId(),
                                    imgBase64);
                            if (macsend)
                                sendContent.setPicUrl(listImg.get(i));
                        } catch (Exception e) {
                            LogHelper.errorDetailInfo(e);
                        }
                    }
        for (UserCloudGroup cloudGroup : listOpen) {
            String title = evaluate.getTitle();
                // 评论文本
                List<String> list = new ArrayList<>();
                for (String comment : listComment) {
                    boolean macsend = AitaokerApiUtil.macsendText(robotId, cloudGroup.getGroupId(), comment);
                    if (macsend) {
                        list.add(comment);
                    }
                }
                sendContent.setState(true);
                sendContent.setComments(list);
            }
            userCloudSendContentService.save(sendContent);
        }
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void sendCustomGoods(Long uid, Long goodsId, Integer goodsType, Long sellerId) throws UserCloudException {
        sendCircleByGoods(uid, goodsId, goodsType, null, sellerId, UserCloudSendRecord.SEND_WAY_MANUAL);
    }
            UserCloudSendContent sendContent = new UserCloudSendContent();
            sendContent.setPid(pid);
            sendContent.setUid(uid);
            sendContent.setGroupId(cloudGroup.getGroupId());
            sendContent.setCreateTime(new Date());
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void autoSendCustomGoods(Long uid, Long id) {
        boolean custom = false;
        UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
        if (cloudManage != null) {
            if (cloudManage.getCustom() != null)
                custom = cloudManage.getCustom();
        }
            if (cloudGroup.getType() == UserCloudGroup.TYPE_CIRCLE) { // 朋友圈
                String circleId = null;
                sendContent.setType(UserCloudSendContent.TYPE_CIRCLE);
        if (!custom) {
            return;
        }
                if (imgVideo == null) {
        UserCloudGoods cloudGoods = userCloudGoodsService.selectByPrimaryKey(id);
        if (cloudGoods == null) {
            return;
        }
        CommonGoods cgoods = cloudGoods.getCommonGoods();
        if (cgoods == null)
            return;
                    // 发送图文
                    String picUrl = "";
                    if (listImg.size() > 0) {
                        for (String img : listImg) {
                            picUrl += img + ";";
                        }
                        if (picUrl.endsWith(";"))
                            picUrl = picUrl.substring(0, picUrl.length() - 1);
                    }
                    String picUrlUpload = AitaokerApiUtil.macsendUpload(robotId, picUrl);
                    sendContent.setPicUrlUpload(picUrlUpload);
                    sendContent.setTitle(title);
                    sendContent.setPicUrl(picUrl);
                    circleId = AitaokerApiUtil.macsendCircle(robotId, title, picUrlUpload);
                } else {
                    // 发送视频
                    sendContent.setPicUrl(imgVideo.getUrl());
                    sendContent.setVideoUrl(imgVideo.getVideoUrl());
                    circleId = AitaokerApiUtil.macsendCircleVideo(robotId, imgVideo.getVideoUrl(), imgVideo.getUrl());
                }
        try {
            // 发送商品
            sendCircleByGoods(uid, cgoods.getGoodsId(), cgoods.getGoodsType(), id, cgoods.getSellerId(),
                    UserCloudSendRecord.SEND_WAY_AUTO);
        } catch (UserCloudException e) {
            LogHelper.cloudInfo("autoSendCustomGoods - [uid:" + uid + " 库id:" + id + "]原因:" + e.getMsg());
        }
    }
                // 评论文本
                if (!StringUtil.isNullOrEmpty(circleId)) {
                    sendContent.setState(true);
                    List<String> list = new ArrayList<>();
                    for (String comment : listComment) {
                        boolean macsend = AitaokerApiUtil.macsendCircleComment(robotId, wxId, circleId, comment);
                        if (macsend) {
                            list.add(comment);
                        }
                    }
                    sendContent.setComments(list);
                }
            } else { // 群
                sendContent.setType(UserCloudSendContent.TYPE_GROUP);
    private void sendCircleByGoods(Long uid, Long goodsId, Integer goodsType, Long storeId, Long sellerId, int way)
            throws UserCloudException {
        long begainTime = java.lang.System.currentTimeMillis();
        // 验证是否授权
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        if (user == null)
            throw new UserCloudException(1, "用户信息不存在");
                // 发送文本
                if (!StringUtil.isNullOrEmpty(title)) {
                    boolean macsend = AitaokerApiUtil.macsendText(robotId, cloudGroup.getGroupId(), title);
                    if (macsend)
                        sendContent.setTitle(title);
                }
                SystemEnum system = userInfoService.getUserSystem(uid);
                // 发送图片
                int num = 1;
                String picNum = configService.getValue(ConfigKeyEnum.robotCloudGroupPictureNum.getKey(), system);
                if (!StringUtil.isNullOrEmpty(picNum)) {
                    num = Integer.parseInt(picNum);
                }
                if (listImg.size() > 0)
                    for (int i = 0; i < num && i < listImg.size(); i++) {
                        try {
                            String imgBase64 = ImageToBase64.NetImageToBase64(listImg.get(i));
                            boolean macsend = AitaokerApiUtil.macsendImgBase64(robotId, cloudGroup.getGroupId(),
                                    imgBase64);
                            if (macsend)
                                sendContent.setPicUrl(listImg.get(i));
                        } catch (Exception e) {
                            LogHelper.errorDetailInfo(e);
                        }
                    }
                // 评论文本
                List<String> list = new ArrayList<>();
                for (String comment : listComment) {
                    boolean macsend = AitaokerApiUtil.macsendText(robotId, cloudGroup.getGroupId(), comment);
                    if (macsend) {
                        list.add(comment);
                    }
                }
                sendContent.setState(true);
                sendContent.setComments(list);
            }
            userCloudSendContentService.save(sendContent);
        }
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void sendCustomGoods(Long uid, Long goodsId, Integer goodsType, Long sellerId) throws UserCloudException {
        sendCircleByGoods(uid, goodsId, goodsType, null, sellerId, UserCloudSendRecord.SEND_WAY_MANUAL);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void autoSendCustomGoods(Long uid, Long id) {
        boolean custom = false;
        UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
        if (cloudManage != null) {
            if (cloudManage.getCustom() != null)
                custom = cloudManage.getCustom();
        }
        if (!custom) {
            return;
        }
        UserCloudGoods cloudGoods = userCloudGoodsService.selectByPrimaryKey(id);
        if (cloudGoods == null) {
            return;
        }
        CommonGoods cgoods = cloudGoods.getCommonGoods();
        if (cgoods == null)
            return;
        try {
            // 发送商品
            sendCircleByGoods(uid, cgoods.getGoodsId(), cgoods.getGoodsType(), id, cgoods.getSellerId(),
                    UserCloudSendRecord.SEND_WAY_AUTO);
        } catch (UserCloudException e) {
            LogHelper.cloudInfo("autoSendCustomGoods - [uid:" + uid + " 库id:" + id + "]原因:" + e.getMsg());
        }
    }
    private void sendCircleByGoods(Long uid, Long goodsId, Integer goodsType, Long storeId, Long sellerId, int way)
            throws UserCloudException {
        long begainTime = java.lang.System.currentTimeMillis();
        // 验证是否授权
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        if (user == null)
            throw new UserCloudException(1, "用户信息不存在");
        if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
            throw new UserCloudException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
        }
        String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
        if (StringUtil.isNullOrEmpty(inviteCode))
            throw new UserCloudException(3, "邀请码未激活");
        UserExtraTaoBaoInfo taoBaoInfo = userExtraTaoBaoInfoService.getByUid(uid);
        String relationId = null;
        if (taoBaoInfo != null && taoBaoInfo.getRelationId() != null && taoBaoInfo.getRelationValid() != null
                && taoBaoInfo.getRelationValid() == true)
            relationId = taoBaoInfo.getRelationId();
        if (StringUtil.isNullOrEmpty(relationId))
            throw new UserCloudException(2, "淘宝未授权,请前往\"我的\"绑定淘宝账号");
        long time2 = java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByGoods验证用户耗时:" + (time2 - begainTime));
        // 验证是否开通
        UserCloud userCloud = userCloudMapper.getValidByUid(uid);
        if (userCloud == null)
            throw new UserCloudException(1001, "云发单已过期");
        long time3 = java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByGoods验证是否开通:" + (time3 - time2));
        long time4 = time3;
        // 加入我的备选库
        if (storeId == null) {
            try {
                UserCloudGoods cloudGoods = userCloudGoodsService.addGoods(uid, goodsId, goodsType, sellerId);
                if (cloudGoods != null)
                    storeId = cloudGoods.getId();
            } catch (UserCloudGoodsException e) {
                LogHelper.cloudInfo("sendCustomGoods - [uid:" + uid + "goodsId:" + goodsId + "goodsType" + goodsType
                        + "]原因:" + e.getMsg());
                throw new UserCloudException(1, "加入云发单备选库失败");
            }
            time4 = java.lang.System.currentTimeMillis();
            LogHelper.test("sendCircleByGoods加入备选库:" + (time4 - time3));
        }
        // 自选库商品是否打开
        boolean custom = false;
        UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
        if (cloudManage != null) {
            if (cloudManage.getCustom() != null)
                custom = cloudManage.getCustom();
        }
        if (!custom) {
            return;
        }
        Integer robotId = userCloud.getRobotId();
        if (robotId == null)
            throw new UserCloudException(1, "云发单机器人不存在");
        String wxId = userCloud.getWxId();
        if (StringUtil.isNullOrEmpty(wxId))
            throw new UserCloudException(1002, "请先登录微信");
        // 验证开启状态
        List<UserCloudGroup> listGroup = userCloudGroupService.listByUid(uid);
        if (listGroup == null || listGroup.size() == 0)
            throw new UserCloudException(1003, "请先登录微信");
        long time5 = java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByGoods验证是否绑定微信:" + (time5 - time4));
        List<UserCloudGroup> listOpen = new ArrayList<>();
        for (UserCloudGroup cloudGrou : listGroup) {
            if (cloudGrou.getState()) {
                listOpen.add(cloudGrou);
            }
        }
        if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
            throw new UserCloudException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
        }
        if (listOpen.size() == 0)
            throw new UserCloudException(1004, "请先开启云发单群功能");
        String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
        if (StringUtil.isNullOrEmpty(inviteCode))
            throw new UserCloudException(3, "邀请码未激活");
        // 检测微信是否登录状态
        if (!AitaokerApiUtil.onlineCheck(robotId)) {
            // 通知登录微信
            offlineNotification(uid);
        UserExtraTaoBaoInfo taoBaoInfo = userExtraTaoBaoInfoService.getByUid(uid);
        String relationId = null;
        if (taoBaoInfo != null && taoBaoInfo.getRelationId() != null && taoBaoInfo.getRelationValid() != null
                && taoBaoInfo.getRelationValid() == true)
            relationId = taoBaoInfo.getRelationId();
            throw new UserCloudException(1003, "微信已掉线,需要重新扫描二维码登录");
        }
        if (StringUtil.isNullOrEmpty(relationId))
            throw new UserCloudException(2, "淘宝未授权,请前往\"我的\"绑定淘宝账号");
        long time6 = java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByGoods验证是否登录微信:" + (time6 - time5));
        long time2 = java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByGoods验证用户耗时:" + (time2 - begainTime));
        // 验证是否开通
        UserCloud userCloud = userCloudMapper.getValidByUid(uid);
        if (userCloud == null)
            throw new UserCloudException(1001, "云发单已过期");
        long time3= java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByGoods验证是否开通:" + (time3 - time2));
        long time4 = time3;
        // 加入我的备选库
        if (storeId == null) {
            try {
                UserCloudGoods cloudGoods = userCloudGoodsService.addGoods(uid, goodsId, goodsType, sellerId);
                if (cloudGoods != null)
                    storeId = cloudGoods.getId();
            } catch (UserCloudGoodsException e) {
                LogHelper.cloudInfo("sendCustomGoods - [uid:" + uid + "goodsId:" + goodsId + "goodsType" + goodsType
                        + "]原因:" + e.getMsg());
                throw new UserCloudException(1, "加入云发单备选库失败");
            }
            time4= java.lang.System.currentTimeMillis();
            LogHelper.test("sendCircleByGoods加入备选库:" + (time4 - time3));
        }
        // 保存发送记录
        UserCloudSendRecord sendRecord = new UserCloudSendRecord();
        sendRecord.setUid(uid);
        sendRecord.setGoodsId(goodsId + "");
        sendRecord.setGoodsType(goodsType + "");
        sendRecord.setWxId(wxId);
        sendRecord.setRobotId(robotId);
        sendRecord.setSendTime(new Date());
        if (storeId != null) {
            sendRecord.setSendId(storeId + "");
            sendRecord.setSendOrigin(UserCloudSendRecord.ORIGIN_STORE);
            sendRecord.setSendWay(UserCloudSendRecord.SEND_WAY_AUTO);
        } else {
            sendRecord.setSendWay(UserCloudSendRecord.SEND_WAY_MANUAL);
        }
        UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord);
        // 自选库商品是否打开
        boolean custom = false;
        UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
        if (cloudManage != null) {
            if (cloudManage.getCustom() != null)
                custom = cloudManage.getCustom();
        }
        if (!custom) {
            return;
        }
        long time7 = java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByGoods保存发送记录:" + (time7 - time6));
        Integer robotId = userCloud.getRobotId();
        if (robotId == null)
            throw new UserCloudException(1, "云发单机器人不存在");
        try {
            if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
                sendTaoBaoGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
            } else if (goodsType == Constant.SOURCE_TYPE_JD) {
                sendJDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
            } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
                sendPDDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
            } else if (goodsType == Constant.SOURCE_TYPE_VIP) {
                sendVIPGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
            } else if (goodsType == Constant.SOURCE_TYPE_SUNING) {
                sendSuNingGoods(user, robotId, wxId, goodsId, sellerId, relationId, listOpen, result.getId());
            }
            // 更新发单记录
            if (storeId != null) {
                UserCloudGoods record = new UserCloudGoods();
                record.setId(storeId);
                record.setState(UserCloudGoods.STATE_SHARED);
                record.setSendTime(new Date());
                record.setUpdateTime(new Date());
                userCloudGoodsService.updateByPrimaryKeySelective(record);
            }
            long time8 = java.lang.System.currentTimeMillis();
            LogHelper.test("sendCircleByGoods执行发送:" + (time8 - time7));
        } catch (UserCloudException e) {
            LogHelper.cloudInfo("autoSendCustomGoods - [uid:" + uid + " 库id:" + storeId + "]原因:" + e.getMsg());
            // 更新发单记录
            if (storeId != null) {
                UserCloudGoods record = new UserCloudGoods();
                record.setId(storeId);
                record.setState(UserCloudGoods.STATE_INVALID);
                record.setSendTime(new Date());
                record.setUpdateTime(new Date());
                userCloudGoodsService.updateByPrimaryKeySelective(record);
            }
        }
        String wxId = userCloud.getWxId();
        if (StringUtil.isNullOrEmpty(wxId))
            throw new UserCloudException(1002, "请先登录微信");
    }
        // 验证开启状态
        List<UserCloudGroup> listGroup = userCloudGroupService.listByUid(uid);
        if (listGroup == null || listGroup.size() == 0)
            throw new UserCloudException(1003, "请先登录微信");
    /**
     * 淘宝商品信息处理
     *
     * @param user
     * @param robotId
     * @param wxId
     * @param goodsId
     * @param relationId
     * @param listOpen
     * @throws UserCloudException
     */
    private void sendTaoBaoGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId,
                                 List<UserCloudGroup> listOpen, String pid) throws UserCloudException {
        TaoBaoLink taoBaoLink = null;
        try {
            taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(user.getId(), goodsId, relationId, null);
        } catch (TaoBaoConvertLinkException e) {
            LogHelper.errorDetailInfo(e);
            throw new UserCloudException(1, "该商品已下架");
        }
        if (taoBaoLink == null)
            throw new UserCloudException(1, "该商品已下架");
        long time5= java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByGoods验证是否绑定微信:" + (time5 - time4));
        List<UserCloudGroup> listOpen = new ArrayList<>();
        for (UserCloudGroup cloudGrou : listGroup) {
            if (cloudGrou.getState()) {
                listOpen.add(cloudGrou);
            }
        }
        TaoBaoGoodsBrief goods = taoBaoLink.getGoods();
        boolean coupon = false;
        if (!StringUtil.isNullOrEmpty(goods.getCouponInfo())) {
            coupon = true;
        }
        if (listOpen.size() == 0)
            throw new UserCloudException(1004, "请先开启云发单群功能");
        String quanPrice = "";
        String description = "";
        String couponAmount = "";
        if (coupon) {
            description = goods.getDescription();
            quanPrice = TaoBaoUtil.getAfterUseCouplePrice(goods) + "";
            couponAmount = MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()).toString();
        }
        String sales = TaoBaoUtil.getSaleCount(goods.getBiz30day());
        // 检测微信是否登录状态
        if (!AitaokerApiUtil.onlineCheck(robotId)) {
            // 通知登录微信
            offlineNotification(uid);
        SystemEnum system = userInfoService.getUserSystem(user.getId());
            throw new UserCloudException(1003, "微信已掉线,需要重新扫描二维码登录");
        }
        // 获取推荐语
        String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getTitle(), sales,
                couponAmount, description, system);
        // 获取评论语
        String commentText = shareGoodsTextTemplateService.getCommentTextByTaoToken(coupon, taoBaoLink.getTaoToken(),
                goods.getZkPrice().toString(), quanPrice, system);
        long time6= java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByGoods验证是否登录微信:" + (time6 - time5));
        // 保存发送记录
        UserCloudSendRecord sendRecord = new UserCloudSendRecord();
        sendRecord.setUid(uid);
        sendRecord.setGoodsId(goodsId + "");
        sendRecord.setGoodsType(goodsType + "");
        sendRecord.setWxId(wxId);
        sendRecord.setRobotId(robotId);
        sendRecord.setSendTime(new Date());
        if (storeId != null) {
            sendRecord.setSendId(storeId + "");
            sendRecord.setSendOrigin(UserCloudSendRecord.ORIGIN_STORE);
            sendRecord.setSendWay(UserCloudSendRecord.SEND_WAY_AUTO);
        } else {
            sendRecord.setSendWay(UserCloudSendRecord.SEND_WAY_MANUAL);
        }
        UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord);
        long time7= java.lang.System.currentTimeMillis();
        LogHelper.test("sendCircleByGoods保存发送记录:" + (time7 - time6));
        // 异步执行发送
        executor.execute(new Runnable() {
            @Override
            public void run() {
                sendGoods(robotId, wxId, listOpen, recommendText, commentText, goods.getImgList(), user.getId(), pid);
            }
        });
    }
        try {
            if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
                sendTaoBaoGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
            } else if (goodsType == Constant.SOURCE_TYPE_JD) {
                sendJDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
            } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
                sendPDDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
            } else if (goodsType == Constant.SOURCE_TYPE_VIP) {
                sendVIPGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
            } else if (goodsType == Constant.SOURCE_TYPE_SUNING) {
                sendSuNingGoods(user, robotId, wxId, goodsId, sellerId, relationId, listOpen, result.getId());
            }
            // 更新发单记录
            if (storeId != null) {
                UserCloudGoods record = new UserCloudGoods();
                record.setId(storeId);
                record.setState(UserCloudGoods.STATE_SHARED);
                record.setSendTime(new Date());
                record.setUpdateTime(new Date());
                userCloudGoodsService.updateByPrimaryKeySelective(record);
            }
            long time8= java.lang.System.currentTimeMillis();
            LogHelper.test("sendCircleByGoods执行发送:" + (time8 - time7));
        } catch (UserCloudException e) {
            LogHelper.cloudInfo("autoSendCustomGoods - [uid:" + uid + " 库id:" + storeId + "]原因:" + e.getMsg());
            // 更新发单记录
            if (storeId != null) {
                UserCloudGoods record = new UserCloudGoods();
                record.setId(storeId);
                record.setState(UserCloudGoods.STATE_INVALID);
                record.setSendTime(new Date());
                record.setUpdateTime(new Date());
                userCloudGoodsService.updateByPrimaryKeySelective(record);
            }
        }
    /**
     * 京东商品云发单
     *
     * @param user
     * @param robotId
     * @param wxId
     * @param goodsId
     * @param relationId
     * @param listOpen
     * @throws UserCloudException
     */
    private void sendJDGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId,
                             List<UserCloudGroup> listOpen, String pid) throws UserCloudException {
        JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
        if (jdGoods == null)
            throw new UserCloudException(1, "该商品已下架");
    }
        String couponUrl = null;
        JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(jdGoods);
        if (couponInfo != null) {
            couponUrl = couponInfo.getLink();
        }
        String materialId = "https://item.jd.com/" + goodsId + ".html";
        String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",
                user.getId() + "");
    /**
     * 淘宝商品信息处理
     *
     * @param user
     * @param robotId
     * @param wxId
     * @param goodsId
     * @param relationId
     * @param listOpen
     * @throws UserCloudException
     */
    private void sendTaoBaoGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId,
            List<UserCloudGroup> listOpen, String pid) throws UserCloudException {
        TaoBaoLink taoBaoLink = null;
        try {
            taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(user.getId(), goodsId, relationId,null);
        } catch (TaoBaoConvertLinkException e) {
            LogHelper.errorDetailInfo(e);
            throw new UserCloudException(1, "该商品已下架");
        }
        if (taoBaoLink == null)
            throw new UserCloudException(1, "该商品已下架");
        boolean coupon = false;
        if (couponInfo != null) {
            coupon = true;
        }
        TaoBaoGoodsBrief goods = taoBaoLink.getGoods();
        boolean coupon = false;
        if (!StringUtil.isNullOrEmpty(goods.getCouponInfo())) {
            coupon = true;
        }
        String quanPrice = "";
        String couponAmount = "";
        if (coupon) {
            quanPrice = BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(jdGoods)).toString() + "";
            couponAmount = BigDecimalUtil.getWithNoZera(couponInfo.getDiscount()).toString();
        }
        String quanPrice = "";
        String description = "";
        String couponAmount = "";
        if (coupon) {
            description = goods.getDescription();
            quanPrice = TaoBaoUtil.getAfterUseCouplePrice(goods) + "";
            couponAmount = MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()).toString();
        }
        String sales = TaoBaoUtil.getSaleCount(goods.getBiz30day());
        String sales = JDUtil.getSaleCount(jdGoods.getInOrderCount30Days());
        SystemEnum system=userInfoService.getUserSystem(user.getId());
        SystemEnum system = userInfoService.getUserSystem(user.getId());
        // 获取推荐语
        String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getTitle(), sales,
                couponAmount, description,system);
        // 获取评论语
        String commentText = shareGoodsTextTemplateService.getCommentTextByTaoToken(coupon, taoBaoLink.getTaoToken(),
                goods.getZkPrice().toString(), quanPrice,system);
        // 获取推荐语
        String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, jdGoods.getSkuName(), sales,
                couponAmount, null, system);
        // 异步执行发送
        executor.execute(new Runnable() {
            @Override
            public void run() {
                sendGoods(robotId, wxId, listOpen, recommendText, commentText, goods.getImgList(), user.getId(), pid);
            }
        });
    }
        // 获取评论语
        BigDecimal price = jdGoods.getPrice();
        JDPingouInfo pinGouInfo = jdGoods.getPinGouInfo();
        if (pinGouInfo != null) {
            price = pinGouInfo.getPingouPrice();
        }
        String zkPrice = BigDecimalUtil.getWithNoZera(price).toString();
        String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink, zkPrice, quanPrice,
                ConfigKeyEnum.quickShareJDCommentText, system);
    /**
     * 京东商品云发单
     *
     * @param user
     * @param robotId
     * @param wxId
     * @param goodsId
     * @param relationId
     * @param listOpen
     * @throws UserCloudException
     */
    private void sendJDGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId,
            List<UserCloudGroup> listOpen, String pid) throws UserCloudException {
        JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
        if (jdGoods == null)
            throw new UserCloudException(1, "该商品已下架");
        // 异步执行发送
        executor.execute(new Runnable() {
            @Override
            public void run() {
                sendGoods(robotId, wxId, listOpen, recommendText, commentText, jdGoods.getImageList(), user.getId(), pid);
            }
        });
        String couponUrl = null;
        JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(jdGoods);
        if (couponInfo != null) {
            couponUrl = couponInfo.getLink();
        }
        String materialId = "https://item.jd.com/" + goodsId + ".html";
        String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",
                user.getId() + "");
    }
        boolean coupon = false;
        if (couponInfo != null) {
            coupon = true;
        }
    /**
     * 京东商品云发单
     *
     * @param user
     * @param robotId
     * @param wxId
     * @param goodsId
     * @param relationId
     * @param listOpen
     * @throws UserCloudException
     */
    private void sendPDDGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId,
                              List<UserCloudGroup> listOpen, String pid) throws UserCloudException {
        PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
        if (goods == null)
            throw new UserCloudException(1, "该商品已下架");
        String quanPrice = "";
        String couponAmount = "";
        if (coupon) {
            quanPrice = BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(jdGoods)).toString() + "";
            couponAmount = BigDecimalUtil.getWithNoZera(couponInfo.getDiscount()).toString();
        }
        String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", user.getId() + "");
        String sales = JDUtil.getSaleCount(jdGoods.getInOrderCount30Days());
        boolean coupon = true;
        if (goods.getHasCoupon() == null || !goods.getHasCoupon()) {
            coupon = false;
        }
        SystemEnum system=userInfoService.getUserSystem(user.getId());
        String quanPrice = "";
        String couponAmount = "";
        if (coupon) {
            BigDecimal hundred = new BigDecimal(100);
            BigDecimal amount = MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), hundred);
            quanPrice = BigDecimalUtil.getWithNoZera(amount).toString();
            couponAmount = BigDecimalUtil.getWithNoZera(PinDuoDuoUtil.getQuanPrice(goods)).toString();
        }
        // 获取推荐语
        String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, jdGoods.getSkuName(), sales,
                couponAmount, null,system);
        String sales = goods.getSalesTip();
        if (StringUtil.isNullOrEmpty(sales)) {
            sales = "0";
        }
        // 获取评论语
        BigDecimal price = jdGoods.getPrice();
        JDPingouInfo pinGouInfo = jdGoods.getPinGouInfo();
        if (pinGouInfo != null) {
            price = pinGouInfo.getPingouPrice();
        }
        String zkPrice = BigDecimalUtil.getWithNoZera(price).toString();
        String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink, zkPrice, quanPrice,
                ConfigKeyEnum.quickShareJDCommentText,system);
        SystemEnum system = userInfoService.getUserSystem(user.getId());
        // 异步执行发送
        executor.execute(new Runnable() {
            @Override
            public void run() {
                sendGoods(robotId, wxId, listOpen, recommendText, commentText, jdGoods.getImageList(), user.getId(), pid);
            }
        });
    }
        // 获取推荐语
        String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getGoodsName(), sales,
                couponAmount, null, system);
    /**
     * 京东商品云发单
     *
     * @param user
     * @param robotId
     * @param wxId
     * @param goodsId
     * @param relationId
     * @param listOpen
     * @throws UserCloudException
     */
    private void sendPDDGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId,
            List<UserCloudGroup> listOpen, String pid) throws UserCloudException {
        PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
        if (goods == null)
            throw new UserCloudException(1, "该商品已下架");
        // 获取评论语
        String zkPrice = MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100))
                .setScale(2).toString();
        String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink, zkPrice, quanPrice,
                ConfigKeyEnum.quickSharePDDCommentText, system);
        String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", user.getId() + "");
        List<String> list = null;
        String[] goodsGalleryUrls = goods.getGoodsGalleryUrls();
        if (goodsGalleryUrls != null && goodsGalleryUrls.length > 0) {
            list = Arrays.asList(goodsGalleryUrls);
        }
        boolean coupon = true;
        if (goods.getHasCoupon() == null || !goods.getHasCoupon()) {
            coupon = false;
        }
        List<String> list2 = list;
        // 异步执行发送
        executor.execute(new Runnable() {
            @Override
            public void run() {
                sendGoods(robotId, wxId, listOpen, recommendText, commentText, list2, user.getId(), pid);
            }
        });
        String quanPrice = "";
        String couponAmount = "";
        if (coupon) {
            BigDecimal hundred = new BigDecimal(100);
            BigDecimal amount = MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), hundred);
            quanPrice = BigDecimalUtil.getWithNoZera(amount).toString();
            couponAmount = BigDecimalUtil.getWithNoZera(PinDuoDuoUtil.getQuanPrice(goods)).toString();
        }
    }
        String sales = goods.getSalesTip();
        if (StringUtil.isNullOrEmpty(sales)) {
            sales = "0";
        }
    /**
     * 唯品会商品
     *
     * @param user
     * @param robotId
     * @param wxId
     * @param goodsId
     * @param relationId
     * @param listOpen
     * @param pid
     * @throws UserCloudException
     */
    private void sendVIPGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId,
                              List<UserCloudGroup> listOpen, String pid) throws UserCloudException {
        VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(goodsId + "");
        if (goods == null)
            throw new UserCloudException(1, "该商品已下架");
        SystemEnum system=userInfoService.getUserSystem(user.getId());
        VIPConvertResultDTO resultDTO = VipShopApiUtil.convertLink(goodsId + "",
                VipShopUtil.getShareChanTag(user.getId()));
        String jumpLink = resultDTO.getUrl();
        // 获取推荐语
        String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getGoodsName(), sales,
                couponAmount, null,system);
        boolean coupon = false;
        String quanPrice = "";
        String couponAmount = "";
        SystemEnum system = userInfoService.getUserSystem(user.getId());
        // 获取推荐语
        String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getGoodsName(), null,
                couponAmount, null, system);
        // 获取评论语
        String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink,
                goods.getMarketPrice(), quanPrice, ConfigKeyEnum.quickShareVIPCommentText, system);
        // 获取评论语
        String zkPrice = MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100))
                .setScale(2).toString();
        String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink, zkPrice, quanPrice,
                ConfigKeyEnum.quickSharePDDCommentText,system);
        // 异步执行发送
        executor.execute(new Runnable() {
            @Override
            public void run() {
                sendGoods(robotId, wxId, listOpen, recommendText, commentText, goods.getGoodsDetailPictures(), user.getId(),
                        pid);
            }
        });
    }
        List<String> list = null;
        String[] goodsGalleryUrls = goods.getGoodsGalleryUrls();
        if (goodsGalleryUrls != null && goodsGalleryUrls.length > 0) {
            list = Arrays.asList(goodsGalleryUrls);
        }
        List<String> list2 = list;
        // 异步执行发送
        executor.execute(new Runnable() {
            @Override
            public void run() {
                sendGoods(robotId, wxId, listOpen, recommendText, commentText, list2, user.getId(), pid);
            }
        });
    }
    /**
     * 京东商品云发单
     *
     * @param user
     * @param robotId
     * @param wxId
     * @param goodsId
     * @param relationId
     * @param listOpen
     * @throws UserCloudException
     */
    private void sendSuNingGoods(UserInfo user, int robotId, String wxId, Long goodsId, Long sellerId,
                                 String relationId, List<UserCloudGroup> listOpen, String pid) throws UserCloudException {
        SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(goodsId + "", sellerId + "");
        if (goods == null)
            throw new UserCloudException(1, "该商品已下架");
    /**
     * 唯品会商品
     *
     * @param user
     * @param robotId
     * @param wxId
     * @param goodsId
     * @param relationId
     * @param listOpen
     * @param pid
     * @throws UserCloudException
     */
    private void sendVIPGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId,
            List<UserCloudGroup> listOpen, String pid) throws UserCloudException {
        VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(goodsId + "");
        if (goods == null)
            throw new UserCloudException(1, "该商品已下架");
        String couponLink = goods.getCouponInfo().getCouponUrl();
        String jumpLink = SuningApiUtil.convertLink(SuningUtil.getProductUrl(sellerId + "", goodsId + ""),
                StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, SuningApiUtil.PID_SHARE, user.getId() + "");
        VIPConvertResultDTO resultDTO = VipShopApiUtil.convertLink(goodsId + "",
                VipShopUtil.getShareChanTag(user.getId()));
        String jumpLink = resultDTO.getUrl();
        boolean coupon = false;
        String couponAmount = "";
        String sales = null;
        if (goods.getCouponInfo() != null && !StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl())) {// 有券
            couponAmount = new BigDecimal(goods.getCouponInfo().getCouponValue()).toString();
            coupon = true;
        }
        boolean coupon = false;
        String quanPrice = "";
        String couponAmount = "";
        SystemEnum system=userInfoService.getUserSystem(user.getId());
        // 获取推荐语
        String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getGoodsName(), null,
                couponAmount, null,system);
        // 获取评论语
        String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink,
                goods.getMarketPrice(), quanPrice, ConfigKeyEnum.quickShareVIPCommentText,system);
        SystemEnum system = userInfoService.getUserSystem(user.getId());
        // 异步执行发送
        executor.execute(new Runnable() {
            @Override
            public void run() {
                sendGoods(robotId, wxId, listOpen, recommendText, commentText, goods.getGoodsDetailPictures(), user.getId(),
                        pid);
            }
        });
    }
        // 获取推荐语
        String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon,
                goods.getCommodityInfo().getCommodityName(), sales, couponAmount, null, system);
    /**
     * 京东商品云发单
     *
     * @param user
     * @param robotId
     * @param wxId
     * @param goodsId
     * @param relationId
     * @param listOpen
     * @throws UserCloudException
     */
    private void sendSuNingGoods(UserInfo user, int robotId, String wxId, Long goodsId, Long sellerId,
            String relationId, List<UserCloudGroup> listOpen, String pid) throws UserCloudException {
        SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(goodsId + "", sellerId + "");
        if (goods == null)
            throw new UserCloudException(1, "该商品已下架");
        // 生成快捷分享内容
        String template = configService.getValue(ConfigKeyEnum.quickShareSuNingCommentText.getKey(), system);
        String commentText = shareGoodsTextTemplateService.createQuickShareTextSuNing(template, goods, jumpLink);
        String couponLink = goods.getCouponInfo().getCouponUrl();
        String jumpLink = SuningApiUtil.convertLink(SuningUtil.getProductUrl(sellerId + "", goodsId + ""),
                StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, SuningApiUtil.PID_SHARE, user.getId() + "");
        List<String> imgList = new ArrayList<>();
        for (SuningGoodsImg img : goods.getCommodityInfo().getPictureUrl()) {
            imgList.add(img.getPicUrl());
        }
        boolean coupon = false;
        String couponAmount = "";
        String sales = null;
        if (goods.getCouponInfo() != null && !StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl())) {// 有券
            couponAmount = new BigDecimal(goods.getCouponInfo().getCouponValue()).toString();
            coupon = true;
        }
        executor.execute(new Runnable() {
            @Override
            public void run() {
                // 云发单
                sendGoods(robotId, wxId, listOpen, recommendText, commentText, imgList, user.getId(), pid);
            }
        });
    }
        SystemEnum system=userInfoService.getUserSystem(user.getId());
    /**
     * 发送商品
     *
     * @param robotId
     * @param title
     * @param comment
     * @param listImg
     * @param wxId
     * @param listOpen
     */
    private void sendGoods(int robotId, String wxId, List<UserCloudGroup> listOpen, String title, String comment,
                           List<String> listImg, Long uid, String pid) {
        // 遍历群-朋友圈
        for (UserCloudGroup cloudGroup : listOpen) {
            UserCloudSendContent sendContent = new UserCloudSendContent();
            sendContent.setPid(pid);
            sendContent.setUid(uid);
            sendContent.setGroupId(cloudGroup.getGroupId());
            sendContent.setCreateTime(new Date());
        // 获取推荐语
        String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon,
                goods.getCommodityInfo().getCommodityName(), sales, couponAmount, null,system);
            if (cloudGroup.getType() == UserCloudGroup.TYPE_CIRCLE) { // 朋友圈
                sendContent.setType(UserCloudSendContent.TYPE_CIRCLE);
                String picUrl = "";
                if (listImg.size() > 0) {
                    for (String img : listImg) {
                        picUrl += TbImgUtil.getTBSize220Img(img) + ";";
                    }
                    if (picUrl.endsWith(";"))
                        picUrl = picUrl.substring(0, picUrl.length() - 1);
                }
        // 生成快捷分享内容
        String template = configService.getValue(ConfigKeyEnum.quickShareSuNingCommentText.getKey(),system);
        String commentText = shareGoodsTextTemplateService.createQuickShareTextSuNing(template, goods, jumpLink);
                String picUrlUpload = AitaokerApiUtil.macsendUpload(robotId, picUrl);
                sendContent.setPicUrlUpload(picUrlUpload);
                sendContent.setTitle(title);
                sendContent.setPicUrl(picUrl);
                // 发圈内容
                String circleId = AitaokerApiUtil.macsendCircle(robotId, title, picUrlUpload);
                // 评论文本
                if (!StringUtil.isNullOrEmpty(circleId)) {
                    sendContent.setState(true);
                    List<String> list = new ArrayList<>();
                    boolean macsend = AitaokerApiUtil.macsendCircleComment(robotId, wxId, circleId, comment);
                    if (macsend) {
                        list.add(comment);
                    }
                    sendContent.setComments(list);
                }
            } else {
                sendContent.setType(UserCloudSendContent.TYPE_GROUP);
                // 发送文本
                if (!StringUtil.isNullOrEmpty(title)) {
                    boolean macsend = AitaokerApiUtil.macsendText(robotId, cloudGroup.getGroupId(), title);
                    if (macsend)
                        sendContent.setTitle(title);
                }
                SystemEnum system = userInfoService.getUserSystem(uid);
                // 发送图片
                int num = 1;
                String picNum = configService.getValue(ConfigKeyEnum.robotCloudGroupPictureNum.getKey(), system);
                if (!StringUtil.isNullOrEmpty(picNum)) {
                    num = Integer.parseInt(picNum);
                }
        List<String> imgList = new ArrayList<>();
        for (SuningGoodsImg img : goods.getCommodityInfo().getPictureUrl()) {
            imgList.add(img.getPicUrl());
        }
        executor.execute(new Runnable() {
            @Override
            public void run() {
                // 云发单
                sendGoods(robotId, wxId, listOpen, recommendText, commentText, imgList, user.getId(), pid);
            }
        });
    }
                if (listImg.size() > 0)
                    for (int i = 0; i < num && i < listImg.size(); i++) {
                        try {
                            String imgBase64 = ImageToBase64.NetImageToBase64(listImg.get(i));
                            boolean macsend = AitaokerApiUtil.macsendImgBase64(robotId, cloudGroup.getGroupId(),
                                    imgBase64);
                            if (macsend)
                                sendContent.setPicUrl(listImg.get(i));
                        } catch (Exception e) {
                            LogHelper.errorDetailInfo(e);
                        }
                    }
    /**
     * 发送商品
     *
     * @param robotId
     * @param title
     * @param comment
     * @param listImg
     * @param wxId
     * @param listOpen
     */
    private void sendGoods(int robotId, String wxId, List<UserCloudGroup> listOpen, String title, String comment,
            List<String> listImg, Long uid, String pid) {
        // 遍历群-朋友圈
        for (UserCloudGroup cloudGroup : listOpen) {
            UserCloudSendContent sendContent = new UserCloudSendContent();
            sendContent.setPid(pid);
            sendContent.setUid(uid);
            sendContent.setGroupId(cloudGroup.getGroupId());
            sendContent.setCreateTime(new Date());
                // 评论文本
                List<String> list = new ArrayList<>();
                boolean macsend = AitaokerApiUtil.macsendText(robotId, cloudGroup.getGroupId(), comment);
                if (macsend) {
                    list.add(comment);
                }
                sendContent.setState(true);
                sendContent.setComments(list);
            }
            userCloudSendContentService.save(sendContent);
        }
    }
            if (cloudGroup.getType() == UserCloudGroup.TYPE_CIRCLE) { // 朋友圈
                sendContent.setType(UserCloudSendContent.TYPE_CIRCLE);
                String picUrl = "";
                if (listImg.size() > 0) {
                    for (String img : listImg) {
                        picUrl += TbImgUtil.getTBSize220Img(img) + ";";
                    }
                    if (picUrl.endsWith(";"))
                        picUrl = picUrl.substring(0, picUrl.length() - 1);
                }
    @Override
    public void fixedTimeSend(List<GoodsEvaluate> listActivity, List<GoodsEvaluate> listGoods, boolean timeLimit) {
        if (listGoods == null && listActivity == null)
            return;
        // 一个小时之前
        Date lastTime = new Date(java.lang.System.currentTimeMillis() - 1000 * 60 * 60);
        for (int i = 0; i < 1000; i++) {
            // 查询哪些用户开通
            List<Long> listUser = userCloudMapper.listValidUid(i * 1000, 1000);
            if (listUser == null || listUser.size() == 0) {
                break;
            }
                String picUrlUpload = AitaokerApiUtil.macsendUpload(robotId, picUrl);
                sendContent.setPicUrlUpload(picUrlUpload);
                sendContent.setTitle(title);
                sendContent.setPicUrl(picUrl);
                // 发圈内容
                String circleId = AitaokerApiUtil.macsendCircle(robotId, title, picUrlUpload);
                // 评论文本
                if (!StringUtil.isNullOrEmpty(circleId)) {
                    sendContent.setState(true);
                    List<String> list = new ArrayList<>();
                    boolean macsend = AitaokerApiUtil.macsendCircleComment(robotId, wxId, circleId, comment);
                    if (macsend) {
                        list.add(comment);
                    }
                    sendContent.setComments(list);
                }
            } else {
                sendContent.setType(UserCloudSendContent.TYPE_GROUP);
                // 发送文本
                if (!StringUtil.isNullOrEmpty(title)) {
                    boolean macsend = AitaokerApiUtil.macsendText(robotId, cloudGroup.getGroupId(), title);
                    if (macsend)
                        sendContent.setTitle(title);
                }
                SystemEnum system=userInfoService.getUserSystem(uid);
                // 发送图片
                int num = 1;
                String picNum = configService.getValue(ConfigKeyEnum.robotCloudGroupPictureNum.getKey(),system);
                if (!StringUtil.isNullOrEmpty(picNum)) {
                    num = Integer.parseInt(picNum);
                }
            // 遍历用户
            for (Long uid : listUser) {
                try {// 判断是否开通官方采集
                    UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
                    if (cloudManage == null || cloudManage.getOfficial() == null || !cloudManage.getOfficial()) {
                        continue;
                    }
                if (listImg.size() > 0)
                    for (int i = 0; i < num && i < listImg.size(); i++) {
                        try {
                            String imgBase64 = ImageToBase64.NetImageToBase64(listImg.get(i));
                            boolean macsend = AitaokerApiUtil.macsendImgBase64(robotId, cloudGroup.getGroupId(),
                                    imgBase64);
                            if (macsend)
                                sendContent.setPicUrl(listImg.get(i));
                        } catch (Exception e) {
                            LogHelper.errorDetailInfo(e);
                        }
                    }
                    // 时间间隔:是否在一个小时内已发送过
                    if (timeLimit) {
                        UserCloudSendRecord last = userCloudSendRecordService.getLastByUid(uid, lastTime);
                        if (last != null)
                            continue;
                    }
                // 评论文本
                List<String> list = new ArrayList<>();
                boolean macsend = AitaokerApiUtil.macsendText(robotId, cloudGroup.getGroupId(), comment);
                if (macsend) {
                    list.add(comment);
                }
                sendContent.setState(true);
                sendContent.setComments(list);
            }
            userCloudSendContentService.save(sendContent);
        }
    }
    @Override
    public void fixedTimeSend(List<GoodsEvaluate> listActivity, List<GoodsEvaluate> listGoods, boolean timeLimit) {
        if (listGoods == null && listActivity == null)
            return;
        // 一个小时之前
        Date lastTime = new Date(java.lang.System.currentTimeMillis() - 1000 * 60 * 60);
        for (int i = 0; i < 1000; i++) {
            // 查询哪些用户开通
            List<Long> listUser = userCloudMapper.listValidUid(i * 1000, 1000);
            if (listUser == null || listUser.size() == 0) {
                break;
            }
                    String evaluateId = null;
                    // 活动
                    if (listActivity != null && listActivity.size() > 0) {
                        for (GoodsEvaluate evaluate : listActivity) {
                            UserCloudSendRecord record = userCloudSendRecordService.getByUidAndSendId(uid,
                                    evaluate.getId());
                            if (record != null)
                                continue;
            // 遍历用户
            for (Long uid : listUser) {
                try {// 判断是否开通官方采集
                    UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
                    if (cloudManage == null || cloudManage.getOfficial() == null || !cloudManage.getOfficial()) {
                        continue;
                    }
                    // 时间间隔:是否在一个小时内已发送过
                    if (timeLimit) {
                        UserCloudSendRecord last = userCloudSendRecordService.getLastByUid(uid, lastTime);
                        if (last != null)
                            continue;
                    }
                    String evaluateId = null;
                    // 活动
                    if (listActivity != null && listActivity.size() > 0) {
                        for (GoodsEvaluate evaluate : listActivity) {
                            UserCloudSendRecord record = userCloudSendRecordService.getByUidAndSendId(uid,
                                    evaluate.getId());
                            if (record != null)
                                continue;
                            evaluateId = evaluate.getId();
                            break;
                        }
                    }
                    // 单品
                    if (StringUtil.isNullOrEmpty(evaluateId) && listGoods != null && listGoods.size() > 0) {
                        for (GoodsEvaluate evaluate : listGoods) {
                            UserCloudSendRecord record = userCloudSendRecordService.getByUidAndSendId(uid,
                                    evaluate.getId());
                            if (record != null)
                                continue;
                            evaluateId = evaluate.getId();
                            break;
                        }
                    }
                    // 单品
                    if (StringUtil.isNullOrEmpty(evaluateId) && listGoods != null && listGoods.size() > 0) {
                        for (GoodsEvaluate evaluate : listGoods) {
                            UserCloudSendRecord record = userCloudSendRecordService.getByUidAndSendId(uid,
                                    evaluate.getId());
                            if (record != null)
                                continue;
                            evaluateId = evaluate.getId();
                            break;
                        }
                    }
                            evaluateId = evaluate.getId();
                            break;
                        }
                    }
                    if (!StringUtil.isNullOrEmpty(evaluateId)) {
                        UserCloudMQMsg msg = new UserCloudMQMsg(uid, evaluateId, UserCloudMQMsg.TYPE_EVALUATE);
                        Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userCloud,
                                msg);
                        rocketMQManager.sendNormalMsg(message, null);
                    }
                } catch (Exception e) {
                    LogHelper.errorDetailInfo(e);
                }
            }
        }
    }
                    if (!StringUtil.isNullOrEmpty(evaluateId)) {
                        UserCloudMQMsg msg = new UserCloudMQMsg(uid, evaluateId, UserCloudMQMsg.TYPE_EVALUATE);
                        Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userCloud,
                                msg);
                        rocketMQManager.sendNormalMsg(message, null);
                    }
                } catch (Exception e) {
                    LogHelper.errorDetailInfo(e);
                }
            }
        }
    }
    private void offlineNotification(Long uid) {
        UserCloudManage cloudManage = userCloudManageService.selectForUpdate(uid);
        if (cloudManage == null) {
            return;
        }
    private void offlineNotification(Long uid) {
        UserCloudManage cloudManage = userCloudManageService.selectForUpdate(uid);
        if (cloudManage == null) {
            return;
        }
        Boolean offlineNotice = cloudManage.getOfflineNotice();
        if (offlineNotice != null && offlineNotice) {
            return;
        }
        Boolean offlineNotice = cloudManage.getOfflineNotice();
        if (offlineNotice != null && offlineNotice) {
            return;
        }
        try {
            userOtherMsgNotificationService.cloudMsg(uid, "云发单微信账号", "微信账号掉线", "需要你重新扫描二维码登录");
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
        try {
            userOtherMsgNotificationService.cloudMsg(uid, "云发单微信账号", "微信账号掉线", "需要你重新扫描二维码登录");
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
        // 站内信通知
        offlineNotificationZNX(uid);
        // 站内信通知
        offlineNotificationZNX(uid);
        // 延迟10分钟再次提醒
        if (!Constant.IS_TEST) {
            UserCloudMQMsg msg = new UserCloudMQMsg(uid, UserCloudMQMsg.TYPE_PUSH);
            Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userCloud, msg);
            message.setStartDeliverTime(java.lang.System.currentTimeMillis() + 1000 * 60 * 10);
            rocketMQManager.sendNormalMsg(message, null);
        }
        // 延迟10分钟再次提醒
        if (!Constant.IS_TEST) {
            UserCloudMQMsg msg = new UserCloudMQMsg(uid, UserCloudMQMsg.TYPE_PUSH);
            Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userCloud, msg);
            message.setStartDeliverTime(java.lang.System.currentTimeMillis() + 1000 * 60 * 10);
            rocketMQManager.sendNormalMsg(message, null);
        }
        // 更新已提醒
        UserCloudManage updateManage = new UserCloudManage();
        updateManage.setId(uid);
        updateManage.setOfflineNotice(true);
        userCloudManageService.updateByPrimaryKeySelective(updateManage);
    }
        // 更新已提醒
        UserCloudManage updateManage = new UserCloudManage();
        updateManage.setId(uid);
        updateManage.setOfflineNotice(true);
        userCloudManageService.updateByPrimaryKeySelective(updateManage);
    }
    // 站内信通知
    @Override
    public void offlineNotificationZNX(Long uid) {
        // 验证是否开通
        UserCloud userCloud = userCloudMapper.getValidByUid(uid);
        if (userCloud == null)
            return;
    // 站内信通知
    @Override
    public void offlineNotificationZNX(Long uid) {
        // 验证是否开通
        UserCloud userCloud = userCloudMapper.getValidByUid(uid);
        if (userCloud == null)
            return;
        Integer robotId = userCloud.getRobotId();
        if (robotId == null)
            return;
        Integer robotId = userCloud.getRobotId();
        if (robotId == null)
            return;
        // 登录状态
        if (AitaokerApiUtil.onlineCheck(robotId)) {
            return;
        }
        // 登录状态
        if (AitaokerApiUtil.onlineCheck(robotId)) {
            return;
        }
        SystemEnum system = userInfoService.getUserSystem(uid);
        try {
            pushService.pushZNX(uid, "【重要通知】你的云发单微信已掉线。", "需要你重新扫描二维码登录", null, null);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
    }
        try {
            pushService.pushZNX(uid, "【重要通知】你的云发单微信已掉线。", "需要你重新扫描二维码登录", null, null, system);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
    }
}
Diff truncated after the above file
fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandClassService.java fanli/src/main/java/com/yeshi/fanli/service/inter/common/CommonConfigService.java fanli/src/main/java/com/yeshi/fanli/service/inter/dynamic/GoodsEvaluateService.java fanli/src/main/java/com/yeshi/fanli/service/inter/help/AppPageNotificationService.java fanli/src/main/java/com/yeshi/fanli/service/inter/help/HelpCenterService.java fanli/src/main/java/com/yeshi/fanli/service/inter/help/HelpClassService.java fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/HomeNavbarService.java fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/HomeNavbarUserService.java fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/SuperHomeNavbarService.java fanli/src/main/java/com/yeshi/fanli/service/inter/push/HWPushService.java fanli/src/main/java/com/yeshi/fanli/service/inter/push/OPPOPushService.java fanli/src/main/java/com/yeshi/fanli/service/inter/push/PushCouponService.java fanli/src/main/java/com/yeshi/fanli/service/inter/push/PushGoodsService.java fanli/src/main/java/com/yeshi/fanli/service/inter/push/PushInfoService.java fanli/src/main/java/com/yeshi/fanli/service/inter/push/VIVOPushService.java fanli/src/main/java/com/yeshi/fanli/util/cache/HttpGoodsCacheManager.java fanli/src/test/java/org/fanli/AppVersionTest.java fanli/src/test/java/org/fanli/MyBatisProduce.java fanli/src/test/java/org/fanli/config/Test_Brand.java