admin
2020-07-07 c9cbad5f5d18c6b2ac5a063e41007933d7028329
返利配置文件加入系统区分
1个文件已添加
137个文件已修改
21688 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/aspect/AdminLoginAspect.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/CallBackController.java 537 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/ClientJspController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/AppPageNotificationAdminController.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/ConfigAdminController.java 608 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsEvaluateAdminController.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/LostOrderAdminController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/UserInfoAdminController.java 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5PushController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5QualityGoodsController.java 1872 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5ShareController.java 367 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/BrandController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/CommonContentController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsClassController.java 1439 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/HelpController.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/HotSellController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/PushController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java 52 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/S11Controller.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/SearchController.java 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/SystemClientController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserAccountController.java 2225 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5CouponController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5PullNewController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/BrandControllerV2.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConsumerControllerV2.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsClassControllerV2.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java 64 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/HotSellControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/JingDongControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/PinDuoDuoControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java 50 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareStorageControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SuningControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserAccountControllerV2.java 1549 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserCloudControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/VipShopControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/h5/H5ControllerUtil.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/h5/H5RecommendController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/h5/H5SearchController.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/web/TLJFreeBuyGoodsController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/web/WebControllerUtil.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/web/WebRecommendController.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/web/WebSearchController.java 4 ●●●● 补丁 | 查看 | 原始文档 | 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/ConsumerController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/GoodsController.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/RecommendController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/SearchController.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/UserController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/BusinessSystemMapper.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HongBaoManageMapper.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/UserInfoMapper.java 401 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/brand/BrandClassShopMapper.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/brand/BrandInfoMapper.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/LostOrderMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserExtraTaoBaoInfoMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/SystemEnum.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/SystemFunction.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/HongBaoManage.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/system/BusinessSystem.java 260 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/goods/FreeGoodsCouponJob.java 602 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/activity/ActivityServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopServiceImpl.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/config/BusinessSystemServiceImpl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/count/CommonOrderCountServiceImpl.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/DynamicInfoServiceImpl.java 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java 59 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/elme/ElmeOrderProcessServiceImpl.java 206 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java 775 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/SuperGoodsClassServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/TaoBaoGoodsBriefServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/lable/QualityGoodsServiceImpl.java 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/lable/TaoKeGoodsServiceImpl.java 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/HongBaoV2ServiceImpl.java 2015 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/LostOrderServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderHongBaoMoneyComputeServiceImpl.java 656 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderRepairServiceImpl.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/config/HongBaoManageServiceImpl.java 455 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/tb/TaoBaoPunishOrderServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoShopServiceImpl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java 697 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/ThreeSaleSerivceImpl.java 980 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/tb/UserExtraTaoBaoInfoServiceImpl.java 475 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandClassShopService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandInfoService.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/config/BusinessSystemService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/CommonTemplateContentService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/TaoBaoGoodsBriefService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/lable/QualityGoodsService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/lable/TaoKeGoodsService.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/LostOrderService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/OrderHongBaoMoneyComputeService.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/config/HongBaoManageService.java 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/taobao/TaoBaoShopService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserAccountService.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserGoodsStorageService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserInfoService.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserShareGoodsRecordService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/tb/UserExtraTaoBaoInfoService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/manger/order/HongBaoV2AddManager.java 1588 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/manger/order/TeamDividentsSourceManager.java 298 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/SystemInfoUtil.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/aitaoker/AitaokerApiUtil.java 1032 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/cache/HttpGoodsCacheManager.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/order/OrderDividentsMessageListener.java 167 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/InvitePictureChangeMessageListener.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/UserVIPMessageListener.java 189 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/env-dev/mongo.properties 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/mapping/BusinessSystemMapper.xml 165 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/mapping/HongBaoManageMapper.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/mapping/UserInfoMapper.xml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/mapping/brand/BrandClassShopMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/mapping/brand/BrandInfoMapper.xml 464 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/mapping/order/CommonOrderMapper.xml 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/mapping/order/LostOrderMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/mapping/user/UserExtraTaoBaoInfoMapper.xml 288 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/test/java/org/fanli/MyBatisProduce.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/aspect/AdminLoginAspect.java
@@ -129,8 +129,8 @@
            }
        }
        if (acceptData != null)
            acceptData.setSystem(system);
//        if (acceptData != null)
//            acceptData.setSystem(system);
        Object obj = null;
fanli/src/main/java/com/yeshi/fanli/controller/CallBackController.java
@@ -64,321 +64,318 @@
import net.sf.json.JSONObject;
/**
 *
 *
 * @author Administrator
 *
 */
@Controller
@RequestMapping("client/v1/callback")
public class CallBackController {
    @Resource
    private ConfigService configService;
    @Resource
    private ConfigService configService;
    @Resource
    private PushService pushService;
    @Resource
    private PushService pushService;
    @Resource
    private MsgDeviceReadStateService msgDeviceReadStateService;
    @Resource
    private MsgDeviceReadStateService msgDeviceReadStateService;
    @Resource
    private RocketMQManager rocketMQManager;
    @Resource
    private RocketMQManager rocketMQManager;
    @Resource
    private BanLiShopOrderService banLiShopOrderService;
    @Resource
    private BanLiShopOrderService banLiShopOrderService;
    @Resource
    private GoodsEvaluateService goodsEvaluateService;
    @Resource
    private GoodsEvaluateService goodsEvaluateService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
    @Resource
    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
    @Resource
    private ActivityUserService activityUserService;
    @Resource
    private ActivityUserService activityUserService;
    @Resource
    private UserCloudService userCloudService;
    @Resource
    private UserCloudService userCloudService;
    /**
     * 客服消息回调
     *
     * @param response
     */
    @RequestMapping(value = "kefuMsg")
    public void kefuMsg(HttpServletResponse response) {
    /**
     * 客服消息回调
     *
     * @param response
     */
    @RequestMapping(value = "kefuMsg")
    public void kefuMsg(HttpServletResponse response) {
    }
    }
    /**
     * 美洽消息回调
     *
     * @param response
     */
    /**
     * 美洽消息回调
     *
     * @param response
     */
    @RequestMapping(value = "meiQia")
    public void meiQia(HttpServletRequest request, HttpServletResponse response) {
        String auth = request.getHeader("Authorization");
        String queryString = request.getQueryString();
        LogHelper.test("美洽:queryString-" + queryString + "-auth:" + auth);
    @RequestMapping(value = "meiQia")
    public void meiQia(HttpServletRequest request, HttpServletResponse response) {
        String auth = request.getHeader("Authorization");
        String queryString = request.getQueryString();
        LogHelper.test("美洽:queryString-" + queryString + "-auth:" + auth);
        BufferedReader br = null;
        StringBuilder sb = new StringBuilder("");
        try {
            br = request.getReader();
            String str;
            while ((str = br.readLine()) != null) {
                sb.append(str);
            }
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        BufferedReader br = null;
        StringBuilder sb = new StringBuilder("");
        try {
            br = request.getReader();
            String str;
            while ((str = br.readLine()) != null) {
                sb.append(str);
            }
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        LogHelper.test("美洽:body----" + sb.toString());
        LogHelper.test("美洽:body----" + sb.toString());
        String sign = "";
        try {
            sign = sign(sb.toString());
        } catch (SignatureException e) {
            e.printStackTrace();
        }
        String sign = "";
        try {
            sign = sign(sb.toString());
        } catch (SignatureException e) {
            e.printStackTrace();
        }
        if (!auth.equalsIgnoreCase(sign)) {
            LogHelper.test("美洽回调签名错误");
            return;
        }
        JSONObject json = JSONObject.fromObject(sb.toString());
        String msg = "";
        if (json != null) {
            String deviceOS = json.optString("deviceOS");
            String contentType = json.optString("contentType");
            if (contentType.equalsIgnoreCase("text"))
                msg = json.optString("content");
            else if (contentType.equalsIgnoreCase("photo"))
                msg = "[图片]";
            else if (contentType.equalsIgnoreCase("audio"))
                msg = "[语音]";
            String customizedId = json.optJSONObject("customizedData").optString("设备标识");
            String uid = json.optJSONObject("customizedData").optString("用户ID");
            msgDeviceReadStateService.addUnreadDeviceMsg(MsgDeviceReadState.TYPE_KEFU, customizedId,
                    "android".equalsIgnoreCase(deviceOS) ? 1 : 2, 1, msg, new Date());
        }
        if (!auth.equalsIgnoreCase(sign)) {
            LogHelper.test("美洽回调签名错误");
            return;
        }
        JSONObject json = JSONObject.fromObject(sb.toString());
        String msg = "";
        if (json != null) {
            String deviceOS = json.optString("deviceOS");
            String contentType = json.optString("contentType");
            if (contentType.equalsIgnoreCase("text"))
                msg = json.optString("content");
            else if (contentType.equalsIgnoreCase("photo"))
                msg = "[图片]";
            else if (contentType.equalsIgnoreCase("audio"))
                msg = "[语音]";
            String customizedId = json.optJSONObject("customizedData").optString("设备标识");
            String uid = json.optJSONObject("customizedData").optString("用户ID");
            msgDeviceReadStateService.addUnreadDeviceMsg(MsgDeviceReadState.TYPE_KEFU, customizedId,
                    "android".equalsIgnoreCase(deviceOS) ? 1 : 2, 1, msg, new Date());
        }
    }
    }
    public String sign(String raw_body) throws java.security.SignatureException {
        String key = "$2a$12$uC3EG/zSaSI37KKOgt1IgetDRHJY6Q2zEVDBr0DeWcwQbGNU7pewy";
        String result = "";
        try {
            SecretKeySpec signingKey = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA1");
            Mac mac = Mac.getInstance("HmacSHA1");
            mac.init(signingKey);
            byte[] rawHmac = mac.doFinal(raw_body.getBytes("UTF-8"));
            byte[] hexBytes = new org.apache.commons.codec.binary.Hex().encode(rawHmac);
            result = org.apache.commons.codec.binary.Base64.encodeBase64String(hexBytes).trim();
        } catch (Exception e) {
            throw new SignatureException("Failed to generate HMAC : " + e.getMessage());
        }
        return "meiqia_sign:" + result;
    }
    public String sign(String raw_body) throws java.security.SignatureException {
        String key = "$2a$12$uC3EG/zSaSI37KKOgt1IgetDRHJY6Q2zEVDBr0DeWcwQbGNU7pewy";
        String result = "";
        try {
            SecretKeySpec signingKey = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA1");
            Mac mac = Mac.getInstance("HmacSHA1");
            mac.init(signingKey);
            byte[] rawHmac = mac.doFinal(raw_body.getBytes("UTF-8"));
            byte[] hexBytes = new org.apache.commons.codec.binary.Hex().encode(rawHmac);
            result = org.apache.commons.codec.binary.Base64.encodeBase64String(hexBytes).trim();
        } catch (Exception e) {
            throw new SignatureException("Failed to generate HMAC : " + e.getMessage());
        }
        return "meiqia_sign:" + result;
    }
    @RequestMapping(value = "test")
    public void test(PrintWriter out) {
        configService.getConfig(1L);
        out.print("success");
    }
    @RequestMapping(value = "test")
    public void test(PrintWriter out) {
        configService.getConfig(1L);
        out.print("success");
    }
    @RequestMapping(value = "vip")
    public void VIP(PrintWriter out) {
        out.print("success");
    }
    @RequestMapping(value = "vip")
    public void VIP(PrintWriter out) {
        out.print("success");
    }
    /**
     * 支付宝支付回调
     * @Title: alipay
     * @Description:
     * @param out
     * void 返回类型
     * @throws
     */
    @RequestMapping(value = "alipay")
    public void alipay(PrintWriter out) {
        out.print("success");
    }
    /**
     * 支付宝支付回调
     *
     * @param out void 返回类型
     * @throws
     * @Title: alipay
     * @Description:
     */
    @RequestMapping(value = "alipay")
    public void alipay(PrintWriter out) {
        out.print("success");
    }
    @RequestMapping(value = "banlishop/pay")
    public void banLiShopPay(HttpServletRequest request, PrintWriter out) {
    @RequestMapping(value = "banlishop/pay")
    public void banLiShopPay(HttpServletRequest request, PrintWriter out) {
        Map<String, String> map = WXUtil.parseXML(request);
        JSONObject json = JSONObject.fromObject(map);
        LogHelper.test("商城微信支付回调:" + json.toString());
        String sign = map.get("sign");
        map.remove("sign");
        boolean isSuccess = BanLiShopWXPayUtil.signIsRight(map, sign);
        if (isSuccess)
            if (map.get("return_code").equalsIgnoreCase("SUCCESS")
                    && map.get("result_code").equalsIgnoreCase("SUCCESS")) {
                // 商户订单号
                String wxPayOrderNo = map.get("out_trade_no");
                // 订单号
                String orderNo = BanLiShopOrderUtil.getOrderNoFromWXPayOrderNo(wxPayOrderNo);
                if (!StringUtil.isNullOrEmpty(orderNo)) {
                    BanLiShopOrder order = banLiShopOrderService.selectByOrderNo(orderNo);
                    if (order != null) {// 支付成功消息推送
                        BanLiShopOrderMQMsg msg = new BanLiShopOrderMQMsg(order.getId(), order.getUid(),
                                new BigDecimal(map.get("total_fee")).multiply(new BigDecimal("0.01")));
                        Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER,
                                OrderTopicTagEnum.banLiShopOrderPaid, msg);
                        rocketMQManager.sendNormalMsg(message, null,null);
                        Map<String, String> returnMap = new HashMap<>();
                        returnMap.put("return_code", "SUCCESS");
                        returnMap.put("return_msg", "OK");
                        out.print(WXUtil.loadWXMessage(returnMap));
                        out.close();
                    }
                }
            }
    }
        Map<String, String> map = WXUtil.parseXML(request);
        JSONObject json = JSONObject.fromObject(map);
        LogHelper.test("商城微信支付回调:" + json.toString());
        String sign = map.get("sign");
        map.remove("sign");
        boolean isSuccess = BanLiShopWXPayUtil.signIsRight(map, sign);
        if (isSuccess)
            if (map.get("return_code").equalsIgnoreCase("SUCCESS")
                    && map.get("result_code").equalsIgnoreCase("SUCCESS")) {
                // 商户订单号
                String wxPayOrderNo = map.get("out_trade_no");
                // 订单号
                String orderNo = BanLiShopOrderUtil.getOrderNoFromWXPayOrderNo(wxPayOrderNo);
                if (!StringUtil.isNullOrEmpty(orderNo)) {
                    BanLiShopOrder order = banLiShopOrderService.selectByOrderNo(orderNo);
                    if (order != null) {// 支付成功消息推送
                        BanLiShopOrderMQMsg msg = new BanLiShopOrderMQMsg(order.getId(), order.getUid(),
                                new BigDecimal(map.get("total_fee")).multiply(new BigDecimal("0.01")));
                        Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER,
                                OrderTopicTagEnum.banLiShopOrderPaid, msg);
                        rocketMQManager.sendNormalMsg(message, null, null);
                        Map<String, String> returnMap = new HashMap<>();
                        returnMap.put("return_code", "SUCCESS");
                        returnMap.put("return_msg", "OK");
                        out.print(WXUtil.loadWXMessage(returnMap));
                        out.close();
                    }
                }
            }
    }
    /**
     * 联盟好物圈
     * @Title: haoWuQuan
     * @Description:
     * @param request
     * @param out
     * void 返回类型
     * @throws
     */
    @RequestMapping(value = "faquan/haowuquan")
    public void haoWuQuan(HttpServletRequest request, String content, PrintWriter out) {
        // if (!sign.equalsIgnoreCase(StringUtil.Md5(content + "banliapp"))) {
        // out.print(JsonUtil.loadFalseResult("签名错误"));
        // return;
        // }
        String contentDecode = "";
    /**
     * 联盟好物圈
     *
     * @param request
     * @param out     void 返回类型
     * @throws
     * @Title: haoWuQuan
     * @Description:
     */
    @RequestMapping(value = "faquan/haowuquan")
    public void haoWuQuan(HttpServletRequest request, String content, PrintWriter out) {
        // if (!sign.equalsIgnoreCase(StringUtil.Md5(content + "banliapp"))) {
        // out.print(JsonUtil.loadFalseResult("签名错误"));
        // return;
        // }
        String contentDecode = "";
        contentDecode = content.substring(content.indexOf("(") + 1, content.length()).trim();
        if (contentDecode.endsWith(")"))
            contentDecode = contentDecode.substring(0, contentDecode.length() - 1);
        contentDecode = content.substring(content.indexOf("(") + 1, content.length()).trim();
        if (contentDecode.endsWith(")"))
            contentDecode = contentDecode.substring(0, contentDecode.length() - 1);
        System.out.println(contentDecode);
        System.out.println(contentDecode);
        JSONObject data = JSONObject.fromObject(contentDecode).optJSONObject("data");
        JSONObject data = JSONObject.fromObject(contentDecode).optJSONObject("data");
        JSONArray array = data.optJSONObject("recommend").optJSONArray("resultList");
        JSONArray array = data.optJSONObject("recommend").optJSONArray("resultList");
        long startTime = System.currentTimeMillis();
        long startTime = System.currentTimeMillis();
        for (SystemEnum system : SystemEnum.values())
            for (int i = array.size() - 1; i >= 0; i--) {
                JSONObject item = array.optJSONObject(i);
                String title = item.optString("itemName");
                String doc = item.optString("cusShareText");
                long itemId = item.optLong("itemId");
                String publishTime = item.optString("cusPublishTime");
                JSONArray imageArray = item.optJSONArray("imageList");
                List<String> imgList = new ArrayList<>();
                for (int j = 0; j < imageArray.size(); j++) {
                    imgList.add(imageArray.optString(j));
                }
        for (int i = array.size() - 1; i >= 0; i--) {
            JSONObject item = array.optJSONObject(i);
            String title = item.optString("itemName");
            String doc = item.optString("cusShareText");
            long itemId = item.optLong("itemId");
            String publishTime = item.optString("cusPublishTime");
            JSONArray imageArray = item.optJSONArray("imageList");
            List<String> imgList = new ArrayList<>();
            for (int j = 0; j < imageArray.size(); j++) {
                imgList.add(imageArray.optString(j));
            }
                TaoBaoGoodsBrief goodsBrief = null;
                try {
                    goodsBrief = TaoKeApiUtil.searchGoodsDetail(itemId);
                } catch (TaobaoGoodsDownException e) {
                    e.printStackTrace();
                }
                if (goodsBrief == null)
                    continue;
                // 商品VO
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55",system);
                paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(SystemEnum.blks));
                GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO);
            TaoBaoGoodsBrief goodsBrief = null;
            try {
                goodsBrief = TaoKeApiUtil.searchGoodsDetail(itemId);
            } catch (TaobaoGoodsDownException e) {
                e.printStackTrace();
            }
            if (goodsBrief == null)
                continue;
            // 商品VO
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
            GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO);
                if (imgList.size() > 3)
                    imgList = imgList.subList(0, 3);
            if (imgList.size() > 3)
                imgList = imgList.subList(0, 3);
                List<ImgInfo> imageList = new ArrayList<>();
                for (int j = 0; j < imgList.size(); j++) {
                    ImgInfo imgInfo = new ImgInfo();
                    imgInfo.setH(1);
                    imgInfo.setW(1);
                    imgInfo.setLarge(false);
                    imgInfo.setUrl(imgList.get(j));
                    String sourceImg = imgList.get(j);
                    if (!imgInfo.getUrl().startsWith("http")) {
                        sourceImg = "https:" + imgInfo.getUrl();
                    }
                    imgInfo.setUrl(TbImgUtil.getTBSizeImg(sourceImg, 500));
                    imgInfo.setUrlHD(sourceImg);
                    if (j != 0) {
                        imgInfo.setType(ImgEnum.img);
                    } else {
                        imgInfo.setType(ImgEnum.goods);
                        SimpleGoods simpleGoods = new SimpleGoods();
                        simpleGoods.setGoodsId(itemId + "");
                        simpleGoods.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
                        simpleGoods.setState(CommonGoods.STATE_NORMAL);
                        CouponInfoVO couponInfo = goodsVO.getCouponInfo();
                        if (couponInfo == null) {
                            simpleGoods.setPrice(goodsVO.getZkPrice());
                        } else {
                            simpleGoods.setPrice(goodsVO.getCouponPrice());
                            simpleGoods.setAmount(couponInfo.getAmount());
                        }
                        imgInfo.setGoods(simpleGoods);
                        imgInfo.setGoodsVO(goodsVO);
                    }
                    imageList.add(imgInfo);
                }
            List<ImgInfo> imageList = new ArrayList<>();
            for (int j = 0; j < imgList.size(); j++) {
                ImgInfo imgInfo = new ImgInfo();
                imgInfo.setH(1);
                imgInfo.setW(1);
                imgInfo.setLarge(false);
                imgInfo.setUrl(imgList.get(j));
                String sourceImg = imgList.get(j);
                if (!imgInfo.getUrl().startsWith("http")) {
                    sourceImg = "https:" + imgInfo.getUrl();
                }
                imgInfo.setUrl(TbImgUtil.getTBSizeImg(sourceImg, 500));
                imgInfo.setUrlHD(sourceImg);
                if (j != 0) {
                    imgInfo.setType(ImgEnum.img);
                } else {
                    imgInfo.setType(ImgEnum.goods);
                    SimpleGoods simpleGoods = new SimpleGoods();
                    simpleGoods.setGoodsId(itemId + "");
                    simpleGoods.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
                    simpleGoods.setState(CommonGoods.STATE_NORMAL);
                    CouponInfoVO couponInfo = goodsVO.getCouponInfo();
                    if (couponInfo == null) {
                        simpleGoods.setPrice(goodsVO.getZkPrice());
                    } else {
                        simpleGoods.setPrice(goodsVO.getCouponPrice());
                        simpleGoods.setAmount(couponInfo.getAmount());
                    }
                    imgInfo.setGoods(simpleGoods);
                    imgInfo.setGoodsVO(goodsVO);
                }
                imageList.add(imgInfo);
            }
                List<ActivityRuleUser> ruleList = activityUserService.listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20);
            List<ActivityRuleUser> ruleList = activityUserService.listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20);
                ActivityUser user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser();
                try {
            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),system);
            } catch (GoodsEvaluateException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
                    goodsEvaluateService.addGoodsEvaluate(itemId + "", imageList, user, doc, null,
                            new Date(startTime - 1000 * 60 * 20L * i), system);
                } catch (GoodsEvaluateException e) {
                    e.printStackTrace();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
    }
    }
    @RequestMapping(value = "yhg/groupmsg")
    public void groupMsg(HttpServletRequest request, PrintWriter out) {
        StringBuilder stringBuilder = new StringBuilder();
        try {
            byte[] buffer = new byte[2048];
            int readBytes = 0;
            while ((readBytes = request.getInputStream().read(buffer)) > 0) {
                stringBuilder.append(new String(buffer, 0, readBytes));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    @RequestMapping(value = "yhg/groupmsg")
    public void groupMsg(HttpServletRequest request, PrintWriter out) {
        StringBuilder stringBuilder = new StringBuilder();
        try {
            byte[] buffer = new byte[2048];
            int readBytes = 0;
            while ((readBytes = request.getInputStream().read(buffer)) > 0) {
                stringBuilder.append(new String(buffer, 0, readBytes));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            JSONObject root = JSONObject.fromObject(stringBuilder.toString());
            if (root.optInt("messageType") == 9) {
                String content = root.optJSONObject("data").optString("content");
                LogHelper.test("云发单群内容:" + content);
                if (content.trim().equalsIgnoreCase(Constant.YHG_CLOUD_GROUP_AWAKEN_KEY)) {
                    LogHelper.test("云发单群匹配:" + root.optString("wcId") + "-"
                            + root.optJSONObject("data").optString("fromGroup"));
                    userCloudService.cacheMatchGroup(root.optString("wcId"),
                            root.optJSONObject("data").optString("fromGroup"));
                }
            }
        } catch (Exception e) {
        try {
            JSONObject root = JSONObject.fromObject(stringBuilder.toString());
            if (root.optInt("messageType") == 9) {
                String content = root.optJSONObject("data").optString("content");
                LogHelper.test("云发单群内容:" + content);
                if (content.trim().equalsIgnoreCase(Constant.YHG_CLOUD_GROUP_AWAKEN_KEY)) {
                    LogHelper.test("云发单群匹配:" + root.optString("wcId") + "-"
                            + root.optJSONObject("data").optString("fromGroup"));
                    userCloudService.cacheMatchGroup(root.optString("wcId"),
                            root.optJSONObject("data").optString("fromGroup"));
                }
            }
        } catch (Exception e) {
        }
        }
    }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/ClientJspController.java
@@ -10,6 +10,7 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -122,7 +123,7 @@
    public String threeShareRepNew(@PathVariable String uid, String code, String state, String packages,
            String platform, String ios, HttpSession httpSession, HttpServletRequest request) {
        BusinessSystem system = businessSystemService.getBusinessSystem(platform, packages);
        BusinessSystem system = businessSystemService.getBusinessSystem(platform, packages, SystemEnum.blks);
        String wxState = (String) httpSession.getAttribute("wxState");
        // 通过配置参数获取
        String down = DOWNURL2;
fanli/src/main/java/com/yeshi/fanli/controller/admin/AppPageNotificationAdminController.java
@@ -111,6 +111,7 @@
            
            appPageNotification.setCreateTime(new Date());
            appPageNotification.setUpdateTime(new Date());
            appPageNotification.setSystem(acceptData.getSystem());
            appPageNotificationService.insertSelective(appPageNotification);
            
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("添加成功"));
fanli/src/main/java/com/yeshi/fanli/controller/admin/ConfigAdminController.java
@@ -11,7 +11,10 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.accept.AdminAcceptData;
import com.yeshi.fanli.util.annotation.RequestNoLogin;
import net.sf.json.JSONArray;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -41,331 +44,348 @@
@RequestMapping("admin/new/api/v1/config")
public class ConfigAdminController {
    @Resource
    private ConfigService configService;
    @Resource
    private ConfigService configService;
    @Resource
    private AppVersionService appVersionService;
    @Resource
    private AppVersionService appVersionService;
    @Resource
    private EhCacheCacheManager ehCacheCacheManager;
    @Resource
    private EhCacheCacheManager ehCacheCacheManager;
    @Resource
    private ConfigCategoryService configCategoryService;
    /**
     * 查询列表 - 新后台
     *
     * @param callback
     * @param key
     *            查询词 名称
     * @param pageIndex
     * @param out
     */
    @RequestMapping(value = "getNewConfigList")
    public void getNewConfigList(AdminAcceptData acceptData, String callback, String key, Integer pageIndex, PrintWriter out) {
    @Resource
    private ConfigCategoryService configCategoryService;
        try {
            if (pageIndex == null || pageIndex < 0) {
                pageIndex = 1;
            }
    /**
     * 查询列表 - 新后台
     *
     * @param callback
     * @param key       查询词 名称
     * @param pageIndex
     * @param out
     */
    @RequestMapping(value = "getNewConfigList")
    public void getNewConfigList(AdminAcceptData acceptData, String callback, String key, Integer pageIndex, PrintWriter out) {
            List<AppVersionInfo> versionList = appVersionService.getAppVersionInfoListByPlatform("android",acceptData.getSystem());
            Map<Integer, String> androidMapName = new HashMap<>();
            for (AppVersionInfo version : versionList)
                androidMapName.put(version.getVersionCode(), version.getVersion());
        try {
            versionList = appVersionService.getAppVersionInfoListByPlatform("ios",acceptData.getSystem());
            Map<Integer, String> iosMapName = new HashMap<>();
            for (AppVersionInfo version : versionList)
                iosMapName.put(version.getVersionCode(), version.getVersion());
            if (pageIndex == null || pageIndex < 0) {
                pageIndex = 1;
            }
            List<Config> list = configService.listObjects(key, pageIndex,acceptData.getSystem());
            List<AppVersionInfo> versionList = appVersionService.getAppVersionInfoListByPlatform("android", acceptData.getSystem());
            Map<Integer, String> androidMapName = new HashMap<>();
            for (AppVersionInfo version : versionList)
                androidMapName.put(version.getVersionCode(), version.getVersion());
            for (Config config : list) {
                config.setMinAndroidVersion(androidMapName.get(config.getMinAndroidVersionCode()));
                config.setMinIosVersion(iosMapName.get(config.getMinIosVersionCode()));
            }
            versionList = appVersionService.getAppVersionInfoListByPlatform("ios", acceptData.getSystem());
            Map<Integer, String> iosMapName = new HashMap<>();
            for (AppVersionInfo version : versionList)
                iosMapName.put(version.getVersionCode(), version.getVersion());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无更多数据"));
                return;
            }
            List<Config> list = configService.listObjects(key, pageIndex, acceptData.getSystem());
            int pageSize = Constant.PAGE_SIZE;
            for (Config config : list) {
                config.setMinAndroidVersion(androidMapName.get(config.getMinAndroidVersionCode()));
                config.setMinIosVersion(iosMapName.get(config.getMinIosVersionCode()));
            }
            int count = configService.getCount(key,acceptData.getSystem());
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无更多数据"));
                return;
            }
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("result_list", list);
            int pageSize = Constant.PAGE_SIZE;
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
            int count = configService.getCount(key, acceptData.getSystem());
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            e.printStackTrace();
        }
    }
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("result_list", list);
    /**
     * 参数修改 - 新后台
     *
     * @param callback
     * @param config
     * @param out
     */
    @RequestMapping(value = "saveModify")
    public void saveModify(AdminAcceptData acceptData,String callback, Config config, PrintWriter out) {
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        Long id = config.getId();
        if (id == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("ID不能为空"));
            return;
        }
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            e.printStackTrace();
        }
    }
        try {
            Config crentconfig = configService.getConfig(id);
            if (crentconfig == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作数据已不存在"));
                return;
            }
    /**
     * 参数修改 - 新后台
     *
     * @param callback
     * @param config
     * @param out
     */
    @RequestMapping(value = "saveModify")
    public void saveModify(AdminAcceptData acceptData, String callback, Config config, PrintWriter out) {
            if (StringUtil.isNullOrEmpty(config.getName()) || StringUtil.isNullOrEmpty(config.getValue())) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("说明、有效值不能为空"));
                return;
            }
        Long id = config.getId();
        if (id == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("ID不能为空"));
            return;
        }
            crentconfig.setName(config.getName());
            crentconfig.setValue(config.getValue());
        try {
            Config crentconfig = configService.getConfig(id);
            if (crentconfig == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作数据已不存在"));
                return;
            }
            if (!StringUtil.isNullOrEmpty(config.getBeizhu())) {
                crentconfig.setBeizhu(config.getBeizhu());
            }
            if (StringUtil.isNullOrEmpty(config.getName()) || StringUtil.isNullOrEmpty(config.getValue())) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("说明、有效值不能为空"));
                return;
            }
            configService.update(crentconfig);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("修改成功"));
            crentconfig.setName(config.getName());
            crentconfig.setValue(config.getValue());
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("修改失败"));
            e.printStackTrace();
        }
    }
            if (!StringUtil.isNullOrEmpty(config.getBeizhu())) {
                crentconfig.setBeizhu(config.getBeizhu());
            }
    @RequestMapping(value = "getArticleHot")
    public void getArticleHot(AdminAcceptData acceptData, PrintWriter out) {
        JSONObject data = new JSONObject();
        data.put("list", configService.getValue(ConfigKeyEnum.articleHotWords.getKey(),acceptData.getSystem()));
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 版本号信息
     *
     * @param callback
     * @param out
     */
    @RequestMapping(value = "getVersionList")
    public void getVersionList(AdminAcceptData acceptData, String callback, PrintWriter out) {
            configService.update(crentconfig);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("修改成功"));
        try {
            AppVersionInfo appVersionInfo = new AppVersionInfo();
            appVersionInfo.setVersion("全推");
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("修改失败"));
            e.printStackTrace();
        }
    }
            // IOS版本
            List<AppVersionInfo> list1 = appVersionService.getAppVersionInfoListByPlatform(AppVersionInfo.PLATFORM_IOS,acceptData.getSystem());
            if (list1 == null) {
                list1 = new ArrayList<AppVersionInfo>();
            }
            List<AppVersionInfo> listIOS = new ArrayList<AppVersionInfo>();
            listIOS.add(appVersionInfo);
            listIOS.addAll(list1);
            // 安卓版本
            List<AppVersionInfo> list2 = appVersionService
                    .getAppVersionInfoListByPlatform(AppVersionInfo.PLATFORM_ANDROID,acceptData.getSystem());
            if (list2 == null) {
                list2 = new ArrayList<AppVersionInfo>();
            }
            List<AppVersionInfo> listAndroid = new ArrayList<AppVersionInfo>();
            listAndroid.add(appVersionInfo);
            listAndroid.addAll(list2);
            //小程序版本
            List<AppVersionInfo> list3 = appVersionService
                    .getAppVersionInfoListByPlatform(AppVersionInfo.PLATFORM_XCX,acceptData.getSystem());
            if (list3 == null) {
                list3 = new ArrayList<AppVersionInfo>();
            }
            List<AppVersionInfo> listWxmp = new ArrayList<AppVersionInfo>();
            listWxmp.add(appVersionInfo);
            listWxmp.addAll(list3);
    @RequestMapping(value = "getArticleHot")
    public void getArticleHot(AdminAcceptData acceptData, PrintWriter out) {
        JSONObject data = new JSONObject();
        data.put("list", configService.getValue(ConfigKeyEnum.articleHotWords.getKey(), acceptData.getSystem()));
        out.print(JsonUtil.loadTrueResult(data));
    }
            JSONObject data = new JSONObject();
            data.put("android", listAndroid);
            data.put("ios", listIOS);
            data.put("wxmp", listWxmp);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    /**
     * 版本号信息
     *
     * @param callback
     * @param out
     */
    @RequestMapping(value = "getVersionList")
    public void getVersionList(AdminAcceptData acceptData, String callback, PrintWriter out) {
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("版本查询失败"));
            e.printStackTrace();
        }
    }
        try {
            AppVersionInfo appVersionInfo = new AppVersionInfo();
            appVersionInfo.setVersion("全推");
    @RequestMapping(value = "clearCaches")
    public void clearCaches(String callback, PrintWriter out) {
        ehCacheCacheManager.getCacheManager().clearAll();
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(""));
    }
    /**
     * 根据分类查询
     * @param callback
     * @param type
     * @param out
     */
    @RequestMapping(value = "getByCategory")
    public void getByCategory(AdminAcceptData acceptData, String callback, String type, PrintWriter out) {
        try {
            ConfigCategoryEnum categoryEnum = configCategoryService.getCategoryEnum(type);
            if (categoryEnum == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("版本查询失败"));
                return;
            }
            List<ConfigCategory> list = new ArrayList<>();
            List<ConfigCategory> listCategory = configCategoryService.listByType(categoryEnum);
            if (listCategory != null) {
                for (ConfigCategory category: listCategory) {
                    Config config = configService.getConfigBykeyNoCache(category.getKeyEnum().getKey(),acceptData.getSystem());
                    if (config != null) {
                        category.setConfig(config);
                        list.add(category);
                    }
                }
            }
            // IOS版本
            List<AppVersionInfo> list1 = appVersionService.getAppVersionInfoListByPlatform(AppVersionInfo.PLATFORM_IOS, acceptData.getSystem());
            if (list1 == null) {
                list1 = new ArrayList<AppVersionInfo>();
            }
            List<AppVersionInfo> listIOS = new ArrayList<AppVersionInfo>();
            listIOS.add(appVersionInfo);
            listIOS.addAll(list1);
            JSONObject data = new JSONObject();
            data.put("list", list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            e.printStackTrace();
        }
    }
    /**
     * 保存信息
     * @param callback
     * @param listConfig
     * @param out
     */
    @RequestMapping(value = "saveConfig")
    public void saveConfig(String callback, ListConfig listConfig, PrintWriter out) {
        try {
            if (listConfig == null || listConfig.getConfig() == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未接收到保存的信息"));
                return;
            }
            configService.update(listConfig.getConfig());
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("修改成功"));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("修改失败"));
            e.printStackTrace();
        }
    }
            // 安卓版本
            List<AppVersionInfo> list2 = appVersionService
                    .getAppVersionInfoListByPlatform(AppVersionInfo.PLATFORM_ANDROID, acceptData.getSystem());
            if (list2 == null) {
                list2 = new ArrayList<AppVersionInfo>();
            }
            List<AppVersionInfo> listAndroid = new ArrayList<AppVersionInfo>();
            listAndroid.add(appVersionInfo);
            listAndroid.addAll(list2);
            //小程序版本
            List<AppVersionInfo> list3 = appVersionService
                    .getAppVersionInfoListByPlatform(AppVersionInfo.PLATFORM_XCX, acceptData.getSystem());
            if (list3 == null) {
                list3 = new ArrayList<AppVersionInfo>();
            }
            List<AppVersionInfo> listWxmp = new ArrayList<AppVersionInfo>();
            listWxmp.add(appVersionInfo);
            listWxmp.addAll(list3);
    /**
     * 查询品牌背景图片
     * @param callback
     * @param type
     * @param out
     */
    @RequestMapping(value = "getBrandBgImg")
    public void getBrandBgImg(AdminAcceptData acceptData,String callback, String type, PrintWriter out) {
        try {
            Config config = configService.getConfigBykeyNoCache(ConfigKeyEnum.brandBackgroundPicture.getKey(),acceptData.getSystem());
            JSONObject data = new JSONObject();
            if (config == null || StringUtil.isNullOrEmpty(config.getValue())) {
                data.put("pic", "");
            } else {
                data.put("pic", config.getValue());
            }
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            e.printStackTrace();
        }
    }
    /**
     *  修改品牌背景图片
     * @param callback
     * @param out
     */
    @RequestMapping(value = "changeBrandBgImg")
    public void changeBrandBgImg(AdminAcceptData acceptData,String callback,  HttpServletRequest request, Long id,  PrintWriter out) {
        try {
            MultipartFile file = null;
            if (request instanceof MultipartHttpServletRequest) {
                MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
                file = fileRequest.getFile("file");
            }
            if (file == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请上传图片文件"));
                return;
            }
            Config config = configService.getConfigBykeyNoCache(ConfigKeyEnum.brandBackgroundPicture.getKey(),acceptData.getSystem());
            if (config == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("品牌对象不存在"));
                return;
            }
            String oldpic = config.getValue();
            // 文件解析
            InputStream inputStream = file.getInputStream();
            String contentType = file.getContentType();
            String type = contentType.substring(contentType.indexOf("/") + 1);
            // 文件路径
            String filePath= FilePathEnum.brand.getPath() +UUID.randomUUID().toString().replace("-", "") + "." + type;
            // 执行上传
            String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
            if (StringUtil.isNullOrEmpty(fileLink)) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("文件上传失败"));
                return;
            }
            config.setValue(fileLink);
            configService.update(config);
            if(!Constant.IS_TEST) {
                if (oldpic != null && oldpic.trim().length() > 0) {
                    COSManager.getInstance().deleteFile(oldpic);
                }
            }
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("修改成功"));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("修改失败"));
            e.printStackTrace();
        }
    }
            JSONObject data = new JSONObject();
            data.put("android", listAndroid);
            data.put("ios", listIOS);
            data.put("wxmp", listWxmp);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("版本查询失败"));
            e.printStackTrace();
        }
    }
    @RequestMapping(value = "clearCaches")
    public void clearCaches(String callback, PrintWriter out) {
        ehCacheCacheManager.getCacheManager().clearAll();
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(""));
    }
    /**
     * 根据分类查询
     *
     * @param callback
     * @param type
     * @param out
     */
    @RequestMapping(value = "getByCategory")
    public void getByCategory(AdminAcceptData acceptData, String callback, String type, PrintWriter out) {
        try {
            ConfigCategoryEnum categoryEnum = configCategoryService.getCategoryEnum(type);
            if (categoryEnum == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("版本查询失败"));
                return;
            }
            List<ConfigCategory> list = new ArrayList<>();
            List<ConfigCategory> listCategory = configCategoryService.listByType(categoryEnum);
            if (listCategory != null) {
                for (ConfigCategory category : listCategory) {
                    Config config = configService.getConfigBykeyNoCache(category.getKeyEnum().getKey(), acceptData.getSystem());
                    if (config != null) {
                        category.setConfig(config);
                        list.add(category);
                    }
                }
            }
            JSONObject data = new JSONObject();
            data.put("list", list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            e.printStackTrace();
        }
    }
    /**
     * 保存信息
     *
     * @param callback
     * @param listConfig
     * @param out
     */
    @RequestMapping(value = "saveConfig")
    public void saveConfig(String callback, ListConfig listConfig, PrintWriter out) {
        try {
            if (listConfig == null || listConfig.getConfig() == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未接收到保存的信息"));
                return;
            }
            configService.update(listConfig.getConfig());
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("修改成功"));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("修改失败"));
            e.printStackTrace();
        }
    }
    /**
     * 查询品牌背景图片
     *
     * @param callback
     * @param type
     * @param out
     */
    @RequestMapping(value = "getBrandBgImg")
    public void getBrandBgImg(AdminAcceptData acceptData, String callback, String type, PrintWriter out) {
        try {
            Config config = configService.getConfigBykeyNoCache(ConfigKeyEnum.brandBackgroundPicture.getKey(), acceptData.getSystem());
            JSONObject data = new JSONObject();
            if (config == null || StringUtil.isNullOrEmpty(config.getValue())) {
                data.put("pic", "");
            } else {
                data.put("pic", config.getValue());
            }
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            e.printStackTrace();
        }
    }
    /**
     * 修改品牌背景图片
     *
     * @param callback
     * @param out
     */
    @RequestMapping(value = "changeBrandBgImg")
    public void changeBrandBgImg(AdminAcceptData acceptData, String callback, HttpServletRequest request, Long id, PrintWriter out) {
        try {
            MultipartFile file = null;
            if (request instanceof MultipartHttpServletRequest) {
                MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
                file = fileRequest.getFile("file");
            }
            if (file == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请上传图片文件"));
                return;
            }
            Config config = configService.getConfigBykeyNoCache(ConfigKeyEnum.brandBackgroundPicture.getKey(), acceptData.getSystem());
            if (config == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("品牌对象不存在"));
                return;
            }
            String oldpic = config.getValue();
            // 文件解析
            InputStream inputStream = file.getInputStream();
            String contentType = file.getContentType();
            String type = contentType.substring(contentType.indexOf("/") + 1);
            // 文件路径
            String filePath = FilePathEnum.brand.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
            // 执行上传
            String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
            if (StringUtil.isNullOrEmpty(fileLink)) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("文件上传失败"));
                return;
            }
            config.setValue(fileLink);
            configService.update(config);
            if (!Constant.IS_TEST) {
                if (oldpic != null && oldpic.trim().length() > 0) {
                    COSManager.getInstance().deleteFile(oldpic);
                }
            }
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("修改成功"));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("修改失败"));
            e.printStackTrace();
        }
    }
    @RequestNoLogin
    @RequestMapping(value = "getSystem")
    public void getSystem(AdminAcceptData acceptData, String callback, PrintWriter out) {
        JSONArray array = new JSONArray();
        for (SystemEnum system : SystemEnum.values()) {
            JSONObject item = new JSONObject();
            item.put("name", system.getName());
            item.put("key", system.name());
            array.add(item);
        }
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(array.toString()));
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsEvaluateAdminController.java
@@ -730,9 +730,9 @@
                return;
            }
            GoodsDetailVO goodsDetail = null;
            BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
            BigDecimal shareRate = hongBaoManageService.getShareRate();
            BigDecimal vipFanLiRate = hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP);
            BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(acceptData.getSystem());
            BigDecimal shareRate = hongBaoManageService.getShareRate(acceptData.getSystem());
            BigDecimal vipFanLiRate = hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem());
            ConfigParamsDTO params = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE, vipFanLiRate);
            if (commonGoods.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
fanli/src/main/java/com/yeshi/fanli/controller/admin/LostOrderAdminController.java
@@ -50,7 +50,7 @@
        
        try {
            
            List<LostOrder> list = lostOrderService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state, handleType, type);
            List<LostOrder> list = lostOrderService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state, handleType, type,acceptData.getSystem());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无更多数据"));
                return;
@@ -99,7 +99,7 @@
                }
            }
            
            long count = lostOrderService.countQuery(key, state, handleType, type);
            long count = lostOrderService.countQuery(key, state, handleType, type,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/OrderAdminController.java
@@ -204,11 +204,11 @@
            // 查询列表
            List<CommonOrderVO> list = commonOrderService.listQuery((pageIndex - 1) * pageSize, pageSize, keyType, key,
                    state, type, orderState, startTime, endTime, sourceType, listShopId, listGoodsId, minTime, money, payment);
                    state, type, orderState, startTime, endTime, sourceType, listShopId, listGoodsId, minTime, money, payment,acceptData.getSystem());
            // 统计总数
            long count = commonOrderService.countQuery(keyType, key, state, type, orderState, startTime, endTime,
                    sourceType, listShopId, listGoodsId, minTime, money, payment);
                    sourceType, listShopId, listGoodsId, minTime, money, payment,acceptData.getSystem());
            for (CommonOrderVO order : list) {
                
fanli/src/main/java/com/yeshi/fanli/controller/admin/UserInfoAdminController.java
@@ -211,7 +211,7 @@
            }
            List<UserInfoVO> userList = userInfoService.query((pageIndex - 1) * pageSize, pageSize, type, key, keyType,
                    userRank, days, startTime, endTime, orderField, orderMode, userType, level, activeCode);
                    userRank, days, startTime, endTime, orderField, orderMode, userType, level, activeCode,acceptData.getSystem());
            if (userList == null || userList.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无相关数据"));
@@ -219,7 +219,7 @@
            }
            long count = userInfoService.queryCount(type, key, keyType, userRank, days, startTime, endTime, userType,
                    level, activeCode);
                    level, activeCode,acceptData.getSystem());
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
@@ -288,7 +288,7 @@
            }
            List<UserInfoVO> userList = userInfoService.queryInfo((pageIndex - 1) * pageSize, pageSize, state, key,
                    keyType, userRank, days, startTime, endTime, userType, level, activeCode);
                    keyType, userRank, days, startTime, endTime, userType, level, activeCode,acceptData.getSystem());
            if (userList == null || userList.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无相关数据"));
@@ -296,7 +296,7 @@
            }
            long count = userInfoService.countInfo(state, key, keyType, userRank, days, startTime, endTime, userType,
                    level, activeCode);
                    level, activeCode,acceptData.getSystem());
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
@@ -394,15 +394,14 @@
        }
    }
    /**
     * 用户粉丝统计
     *
     * @param callback
     * @param pageIndex
     * @param pageSize
     * @param id
     * @param out
     */
    /**
     * 用户粉丝统计
     * @param acceptData
     * @param callback
     * @param uid
     * @param out
     */
    @RequestMapping(value = "countTeamFans")
    public void countTeamFans(AdminAcceptData acceptData,String callback, Long uid, PrintWriter out) {
        JSONObject data = new JSONObject();
@@ -687,12 +686,14 @@
        }
    }
    /**
     *
     * @param data
     * @param uid  用户ID
     * @param type 需要解绑的账户类型
     */
    /**
     *
     * @param acceptData
     * @param callback
     * @param uid
     * @param typeArray
     * @param out
     */
    @RequestMapping("unBindUserInfo")
    public void unBindUserInfo(AdminAcceptData acceptData,String callback, Long uid, String typeArray, PrintWriter out) {
        try {
@@ -965,7 +966,6 @@
     * 队员关系
     * 
     * @param pageIndex
     * @param key
     * @param state
     * @param startTime
     * @param endTime
@@ -1070,7 +1070,6 @@
     * @param callback
     * @param pageIndex
     * @param pageSize
     * @param id
     * @param out
     */
    @RequestMapping(value = "getAccountDetails")
@@ -1470,7 +1469,6 @@
     * @param callback
     * @param pageIndex
     * @param pageSize
     * @param type
     * @param out
     */
    @RequestMapping(value = "getGoldCoinRecord")
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5PushController.java
@@ -95,8 +95,8 @@
            if (list != null && list.size() > 0) {
                Map<String, String> map = manageService.convertMap();
                BigDecimal proportion = hongBaoManageService.getFanLiRate();
                Map<String, String> map = manageService.convertMap(acceptData.getSystem());
                BigDecimal proportion = hongBaoManageService.getFanLiRate(acceptData.getSystem());
                for (PushGoodsGroup pushGoodsGroup : list) {
                    CommonGoods commonGoods = pushGoodsGroup.getCommonGoods();
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5QualityGoodsController.java
@@ -55,1166 +55,1174 @@
@Controller
@RequestMapping("api/apph5/v1/quality")
public class AppH5QualityGoodsController {
    @Resource
    private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
    @Resource
    private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
    @Resource
    private TaobaoMeterialService taobaoMeterialService;
    @Resource
    private TaobaoMeterialService taobaoMeterialService;
    @Resource
    private TaoKeGoodsService taoKeGoodsService;
    @Resource
    private TaoKeGoodsService taoKeGoodsService;
    @Resource
    private HongBaoManageService manageService;
    @Resource
    private HongBaoManageService manageService;
    @Resource
    private MergeClassService mergeClassService;
    @Resource
    private MergeClassService mergeClassService;
    @Resource
    private QualityGoodsService qualityGoodsService;
    @Resource
    private QualityGoodsService qualityGoodsService;
    @Resource
    private QualityFlashSaleService qualityFlashSaleService;
    @Resource
    private QualityFlashSaleService qualityFlashSaleService;
    @Resource
    private CollectionGoodsV2Service collectionGoodsV2Service;
    @Resource
    private CollectionGoodsV2Service collectionGoodsV2Service;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private TaoBaoGoodsActivityService taoBaoGoodsActivityService;
    @Resource
    private TaoBaoGoodsActivityService taoBaoGoodsActivityService;
    @Resource
    private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
    @Resource
    private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
    /**
     * 9.9商品
     *
     * @param callback
     * @param page
     * @param mcid
     * @param out
     */
    @RequestMapping(value = "get9k9")
    public void get9k9(AcceptData acceptData, String callback, Integer page, Long mcid, PrintWriter out) {
        get9k9ClassGoods(acceptData, callback, out, page, 500, new BigDecimal(209.9), new BigDecimal(0), new BigDecimal(9.9), mcid);
    /**
     * 9.9商品
     * @param callback
     * @param page
     * @param mcid
     * @param out
     */
    @RequestMapping(value = "get9k9")
    public void get9k9(String callback, Integer page, Long mcid, PrintWriter out) {
        get9k9ClassGoods(callback, out, page, 500, new BigDecimal(209.9), new BigDecimal(0), new BigDecimal(9.9), mcid);
    }
    }
    /**
     * 19.9商品
     *
     * @param callback
     * @param page
     * @param mcid
     * @param out
     */
    @RequestMapping(value = "get19k9")
    public void get19k9(AcceptData acceptData,String callback, Integer page, Long mcid, PrintWriter out) {
        get9k9ClassGoods(acceptData,callback, out, page, 500, new BigDecimal(319.9), new BigDecimal(9.9), new BigDecimal(19.9),
                mcid);
    /**
     * 19.9商品
     * @param callback
     * @param page
     * @param mcid
     * @param out
     */
    @RequestMapping(value = "get19k9")
    public void get19k9(String callback, Integer page, Long mcid, PrintWriter out) {
        get9k9ClassGoods(callback, out, page, 500, new BigDecimal(319.9), new BigDecimal(9.9), new BigDecimal(19.9),
                mcid);
    }
    }
    /**
     * 29.9商品
     *
     * @param callback
     * @param page
     * @param mcid
     * @param out
     */
    @RequestMapping(value = "get29k9")
    public void get29k9(AcceptData acceptData,String callback, Integer page, Long mcid, PrintWriter out) {
        get9k9ClassGoods(acceptData,callback, out, page, 500, new BigDecimal(429.9), new BigDecimal(19.9), new BigDecimal(29.9),
                mcid);
    /**
     * 29.9商品
     * @param callback
     * @param page
     * @param mcid
     * @param out
     */
    @RequestMapping(value = "get29k9")
    public void get29k9(String callback, Integer page, Long mcid, PrintWriter out) {
        get9k9ClassGoods(callback, out, page, 500, new BigDecimal(429.9), new BigDecimal(19.9), new BigDecimal(29.9),
                mcid);
    }
    }
    /**
     * 49.9商品
     *
     * @param callback
     * @param page
     * @param mcid
     * @param out
     */
    @RequestMapping(value = "get49k9")
    public void get49k9(AcceptData acceptData,String callback, Integer page, Long mcid, PrintWriter out) {
        get9k9ClassGoods(acceptData,callback, out, page, 500, new BigDecimal(549.9), new BigDecimal(29.9), new BigDecimal(49.9),
                mcid);
    }
    /**
     * 49.9商品
     * @param callback
     * @param page
     * @param mcid
     * @param out
     */
    @RequestMapping(value = "get49k9")
    public void get49k9(String callback, Integer page, Long mcid, PrintWriter out) {
        get9k9ClassGoods(callback, out, page, 500, new BigDecimal(549.9), new BigDecimal(29.9), new BigDecimal(49.9),
                mcid);
    }
    /**
     * 9k9类型的商品查询
     *
     * @param callback
     * @param out
     * @param page
     * @param biz30day
     * @param zkPrice
     * @param minQuanPrice
     * @param maxQuanPrice
     * @param mcid
     */
    public void get9k9ClassGoods(AcceptData acceptData, String callback, PrintWriter out, Integer page, Integer biz30day, BigDecimal zkPrice,
                                 BigDecimal minQuanPrice, BigDecimal maxQuanPrice, Long mcid) {
        try {
            if (page == null || page <= 0) {
                page = 1;
            }
    /**
     * 9k9类型的商品查询
     * @param callback
     * @param out
     * @param page
     * @param biz30day
     * @param zkPrice
     * @param minQuanPrice
     * @param maxQuanPrice
     * @param mcid
     */
    public void get9k9ClassGoods(String callback, PrintWriter out, Integer page, Integer biz30day, BigDecimal zkPrice,
            BigDecimal minQuanPrice, BigDecimal maxQuanPrice, Long mcid) {
        try {
            if (page == null || page <= 0) {
                page = 1;
            }
            int pageSize = Constant.PAGE_SIZE;
            int pageSize = Constant.PAGE_SIZE;
            String mergeCids = null;
            if (mcid != null && (!mcid.equals(0) || mcid != 0)) {
                MergeClass mergeClass = mergeClassService.selectByPrimaryKeyCache(mcid);
                if (mergeClass != null) {
                    // 分类id,隔开
                    mergeCids = mergeClass.getMergeCids();
                }
            }
            String mergeCids = null;
            if (mcid != null && (!mcid.equals(0) || mcid != 0)) {
                MergeClass mergeClass = mergeClassService.selectByPrimaryKeyCache(mcid);
                if (mergeClass != null) {
                    // 分类id,隔开
                    mergeCids = mergeClass.getMergeCids();
                }
            }
            // 根据标签id 查询数据
            List<QualityFactory> listQuery = qualityGoodsService.get9k9ClassGoods((page - 1) * pageSize, pageSize,
                    biz30day, zkPrice, minQuanPrice, maxQuanPrice, mergeCids);
            if (listQuery == null || listQuery.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
                return;
            }
            // 根据标签id 查询数据
            List<QualityFactory> listQuery = qualityGoodsService.get9k9ClassGoods((page - 1) * pageSize, pageSize,
                    biz30day, zkPrice, minQuanPrice, maxQuanPrice, mergeCids);
            if (listQuery == null || listQuery.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
                return;
            }
            // 总条数
            long count = qualityGoodsService.count9k9ClassGoods(biz30day, zkPrice, minQuanPrice, maxQuanPrice,
                    mergeCids);
            // 总条数
            long count = qualityGoodsService.count9k9ClassGoods(biz30day, zkPrice, minQuanPrice, maxQuanPrice,
                    mergeCids);
            JSONArray array = new JSONArray();
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            JSONArray array = new JSONArray();
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            BigDecimal proportion = hongBaoManageService.getFanLiRate(acceptData.getSystem());
            /* 遍历列表数据 */
            for (QualityFactory selectionGoods : listQuery) {
                TaoBaoGoodsBrief goodsBrief = selectionGoods.getTaoBaoGoodsBrief();
                if (goodsBrief == null) {
                    continue;
                }
                array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion.toString(), null)));
            }
            BigDecimal proportion = hongBaoManageService.getFanLiRate();
            /* 遍历列表数据 */
            for (QualityFactory selectionGoods : listQuery) {
                TaoBaoGoodsBrief goodsBrief = selectionGoods.getTaoBaoGoodsBrief();
                if (goodsBrief == null) {
                    continue;
                }
                array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion.toString(), null)));
            }
            // 618活动
            if (System.currentTimeMillis() < TimeUtil.convertToTimeTemp("2019-06-19", "yyyy-MM-dd")) {
                if (mcid == null || mcid == 0) {
                    count = taoBaoGoodsActivityService.countByPrice(minQuanPrice,
                            maxQuanPrice.add(new BigDecimal("0.1")));
                    List<TaoBaoGoodsBrief> goodsList = taoBaoGoodsActivityService.listByPrice(minQuanPrice,
                            maxQuanPrice.add(new BigDecimal("0.1")), page, pageSize);
                    if (goodsList != null) {
                        array.clear();
                        for (TaoBaoGoodsBrief goods : goodsList) {
                            array.add(gson
                                    .toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, proportion.toString(), null)));
                        }
                    }
                }
            }
            // 618活动
            if (System.currentTimeMillis() < TimeUtil.convertToTimeTemp("2019-06-19", "yyyy-MM-dd")) {
                if (mcid == null || mcid == 0) {
                    count = taoBaoGoodsActivityService.countByPrice(minQuanPrice,
                            maxQuanPrice.add(new BigDecimal("0.1")));
                    List<TaoBaoGoodsBrief> goodsList = taoBaoGoodsActivityService.listByPrice(minQuanPrice,
                            maxQuanPrice.add(new BigDecimal("0.1")), page, pageSize);
                    if (goodsList != null) {
                        array.clear();
                        for (TaoBaoGoodsBrief goods : goodsList) {
                            array.add(gson
                                    .toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, proportion.toString(), null)));
                        }
                    }
                }
            }
            JSONObject data = new JSONObject();
            data.put("count", count);
            data.put("result_list", array);
            JSONObject data = new JSONObject();
            data.put("count", count);
            data.put("result_list", array);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            LogHelper.errorDetailInfo(e);
        }
    }
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            LogHelper.errorDetailInfo(e);
        }
    }
    /**
     * 9.9商品-每日必抢
     *
     * @param callback
     * @param page
     * @param mcid
     * @param out
     */
    @RequestMapping(value = "get9k9EverydayRob")
    public void get9k9EverydayRob(AcceptData acceptData,String callback, Integer page, Long mcid, PrintWriter out) {
        queryEverydayRob(acceptData,callback, out, page, new BigDecimal(209.9), new BigDecimal(0), new BigDecimal(9.9));
    /**
     * 9.9商品-每日必抢
     * @param callback
     * @param page
     * @param mcid
     * @param out
     */
    @RequestMapping(value = "get9k9EverydayRob")
    public void get9k9EverydayRob(String callback, Integer page, Long mcid, PrintWriter out) {
        queryEverydayRob(callback, out, page, new BigDecimal(209.9), new BigDecimal(0), new BigDecimal(9.9));
    }
    }
    /**
     * 19.9商品-每日必抢
     *
     * @param callback
     * @param page
     * @param mcid
     * @param out
     */
    @RequestMapping(value = "get19k9EverydayRob")
    public void get19k9EverydayRob(AcceptData acceptData,String callback, Integer page, Long mcid, PrintWriter out) {
        queryEverydayRob(acceptData,callback, out, page, new BigDecimal(319.9), new BigDecimal(9.9), new BigDecimal(19.9));
    }
    /**
     * 19.9商品-每日必抢
     * @param callback
     * @param page
     * @param mcid
     * @param out
     */
    @RequestMapping(value = "get19k9EverydayRob")
    public void get19k9EverydayRob(String callback, Integer page, Long mcid, PrintWriter out) {
        queryEverydayRob(callback, out, page, new BigDecimal(319.9), new BigDecimal(9.9), new BigDecimal(19.9));
    }
    /**
     * 29.9商品-每日必抢
     *
     * @param callback
     * @param page
     * @param mcid
     * @param out
     */
    @RequestMapping(value = "get29k9EverydayRob")
    public void get29k9EverydayRob(AcceptData acceptData,String callback, Integer page, Long mcid, PrintWriter out) {
        queryEverydayRob(acceptData,callback, out, page, new BigDecimal(429.9), new BigDecimal(19.9), new BigDecimal(29.9));
    /**
     * 29.9商品-每日必抢
     * @param callback
     * @param page
     * @param mcid
     * @param out
     */
    @RequestMapping(value = "get29k9EverydayRob")
    public void get29k9EverydayRob(String callback, Integer page, Long mcid, PrintWriter out) {
        queryEverydayRob(callback, out, page, new BigDecimal(429.9), new BigDecimal(19.9), new BigDecimal(29.9));
    }
    }
    /**
     * 49.9商品-每日必抢
     *
     * @param callback
     * @param page
     * @param mcid
     * @param out
     */
    @RequestMapping(value = "get49k9EverydayRob")
    public void get49k9EverydayRob(AcceptData acceptData,String callback, Integer page, Long mcid, PrintWriter out) {
        queryEverydayRob(acceptData,callback, out, page, new BigDecimal(549.9), new BigDecimal(29.9), new BigDecimal(49.9));
    /**
     * 49.9商品-每日必抢
     * @param callback
     * @param page
     * @param mcid
     * @param out
     */
    @RequestMapping(value = "get49k9EverydayRob")
    public void get49k9EverydayRob(String callback, Integer page, Long mcid, PrintWriter out) {
        queryEverydayRob(callback, out, page, new BigDecimal(549.9), new BigDecimal(29.9), new BigDecimal(49.9));
    }
    }
    /**
     * 每日必抢
     *
     * @param callback
     * @param out
     * @param page
     * @param zkPrice
     * @param minQuanPrice
     * @param maxQuanPrice
     */
    public void queryEverydayRob(AcceptData acceptData, String callback, PrintWriter out, Integer page, BigDecimal zkPrice,
                                 BigDecimal minQuanPrice, BigDecimal maxQuanPrice) {
    /**
     *  每日必抢
     * @param callback
     * @param out
     * @param page
     * @param zkPrice
     * @param minQuanPrice
     * @param maxQuanPrice
     */
    public void queryEverydayRob(String callback, PrintWriter out, Integer page, BigDecimal zkPrice,
            BigDecimal minQuanPrice, BigDecimal maxQuanPrice) {
        if (page == null)
            page = 1;
        if (page == null)
            page = 1;
        // 20 条一页请求到3页结束今日新品
        if (page > 3) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
            return;
        }
        // 20 条一页请求到3页结束今日新品
        if (page > 3) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
            return;
        }
        try {
            int pageSize = Constant.PAGE_SIZE;
            List<QualityFactory> listQuery = qualityGoodsService.listQueryEverydayRob((page - 1) * pageSize, pageSize,
                    zkPrice, minQuanPrice, maxQuanPrice);
            if (listQuery == null || listQuery.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
                return;
            }
        try {
            int pageSize = Constant.PAGE_SIZE;
            List<QualityFactory> listQuery = qualityGoodsService.listQueryEverydayRob((page - 1) * pageSize, pageSize,
                    zkPrice, minQuanPrice, maxQuanPrice);
            if (listQuery == null || listQuery.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
                return;
            }
            JSONArray array = new JSONArray();
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            JSONArray array = new JSONArray();
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
            for (QualityFactory selectionGoods : listQuery) {
                TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
                if (taoBaoGoodsBrief == null) {
                    continue;
                }
                array.add(gson
                        .toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
            }
            BigDecimal proportion = manageService.getFanLiRate();
            for (QualityFactory selectionGoods : listQuery) {
                TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
                if (taoBaoGoodsBrief == null) {
                    continue;
                }
                array.add(gson
                        .toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
            }
            long count = qualityGoodsService.countQueryEverydayRob(zkPrice, minQuanPrice, maxQuanPrice);
            if (count < 50) {
                count = listQuery.size();
            } else {
                count = 50;
            }
            long count = qualityGoodsService.countQueryEverydayRob(zkPrice, minQuanPrice, maxQuanPrice);
            if (count < 50) {
                count = listQuery.size();
            } else {
                count = 50;
            }
            JSONObject data = new JSONObject();
            data.put("count", count);
            data.put("result_list", array);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            LogHelper.errorDetailInfo(e);
        }
    }
            JSONObject data = new JSONObject();
            data.put("count", count);
            data.put("result_list", array);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            LogHelper.errorDetailInfo(e);
        }
    }
    /**
     * 品牌购 (官方推荐【品牌券】接口)
     *
     * @param page
     * @param out
     */
    @RequestMapping(value = "getBrandsGoods")
    public void getBrandsGoods(AcceptData acceptData,  String callback, Integer page, String subName, PrintWriter out) {
    /**
     * 品牌购 (官方推荐【品牌券】接口)
     *
     * @param page
     * @param out
     */
    @RequestMapping(value = "getBrandsGoods")
    public void getBrandsGoods(String callback, Integer page, String subName, PrintWriter out) {
        try {
        try {
            List<TaobaoMeterial> list = taobaoMeterialService.selectByClassNameAndSuperNameCache(subName, "品牌券");
            List<TaobaoMeterial> list = taobaoMeterialService.selectByClassNameAndSuperNameCache(subName, "品牌券");
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            TaobaoMeterial taobaoMeterial = list.get(0);
            Integer materialId = taobaoMeterial.getMaterialId();
            if (materialId == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检索到数据"));
                return;
            }
            TaobaoMeterial taobaoMeterial = list.get(0);
            Integer materialId = taobaoMeterial.getMaterialId();
            if (materialId == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检索到数据"));
                return;
            }
            if (page == null)
                page = 1;
            if (page == null)
                page = 1;
            int pageSize = Constant.PAGE_SIZE;
            int pageSize = Constant.PAGE_SIZE;
            JSONObject jsonObject = taoKeGoodsService.getBrandsGoods(materialId, page, pageSize,acceptData.getSystem());
            JSONObject jsonObject = taoKeGoodsService.getBrandsGoods(materialId, page, pageSize);
            if (jsonObject == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
                return;
            }
            if (jsonObject == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
                return;
            }
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonObject));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonObject));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    /**
     * 品牌购 (官方推荐【品牌券】接口)
     *
     * @param page
     * @param out
     */
    @RequestMapping(value = "getBrandsShops")
    public void getBrandsShops(String callback, Integer page, PrintWriter out) {
    /**
     * 品牌购 (官方推荐【品牌券】接口)
     *
     * @param page
     * @param out
     */
    @RequestMapping(value = "getBrandsShops")
    public void getBrandsShops(String callback, Integer page, PrintWriter out) {
        try {
            String subName = "综合";
            List<TaobaoMeterial> list = taobaoMeterialService.selectByClassNameAndSuperNameCache(subName, "品牌券");
        try {
            String subName = "综合";
            List<TaobaoMeterial> list = taobaoMeterialService.selectByClassNameAndSuperNameCache(subName, "品牌券");
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            TaobaoMeterial taobaoMeterial = list.get(0);
            Integer materialId = taobaoMeterial.getMaterialId();
            if (materialId == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检索到数据"));
                return;
            }
            TaobaoMeterial taobaoMeterial = list.get(0);
            Integer materialId = taobaoMeterial.getMaterialId();
            if (materialId == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检索到数据"));
                return;
            }
            if (page == null)
                page = 1;
            if (page == null)
                page = 1;
            int pageSize = Constant.PAGE_SIZE;
            int pageSize = Constant.PAGE_SIZE;
            JSONObject jsonObject = taoKeGoodsService.getBrandsShops(materialId, page, pageSize);
            JSONObject jsonObject = taoKeGoodsService.getBrandsShops(materialId, page, pageSize);
            if (jsonObject == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
                return;
            }
            if (jsonObject == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
                return;
            }
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonObject));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonObject));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    /**
     * 大额券 (官方推荐中的【特惠】)
     *
     * @param page
     * @param out
     */
    @RequestMapping(value = "getPreferential", method = RequestMethod.POST)
    public void getPreferential(AcceptData acceptData,int page, PrintWriter out) {
    /**
     * 大额券 (官方推荐中的【特惠】)
     *
     * @param page
     * @param out
     */
    @RequestMapping(value = "getPreferential", method = RequestMethod.POST)
    public void getPreferential(int page, PrintWriter out) {
        try {
        try {
            List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache(null, "特惠");
            List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache(null, "特惠");
            if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
                out.print(JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
                out.print(JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            TaobaoMeterial meterial = taobaoMeterials.get(0);
            Integer materialId = meterial.getMaterialId();
            if (materialId == null) {
                out.print(JsonUtil.loadFalseResult("未检索到数据"));
                return;
            }
            TaobaoMeterial meterial = taobaoMeterials.get(0);
            Integer materialId = meterial.getMaterialId();
            if (materialId == null) {
                out.print(JsonUtil.loadFalseResult("未检索到数据"));
                return;
            }
            if (page < 1)
                page = 1;
            if (page < 1)
                page = 1;
            int pageSize = Constant.PAGE_SIZE;
            int pageSize = Constant.PAGE_SIZE;
            JSONObject jsonObject = queryMaterialGoods(acceptData,page, pageSize, materialId);
            JSONObject jsonObject = queryMaterialGoods(page, pageSize, materialId);
            if (jsonObject == null) {
                out.print(JsonUtil.loadFalseResult(2, "暂无更多数据"));
            }
            out.print(JsonUtil.loadTrueResult(jsonObject));
            if (jsonObject == null) {
                out.print(JsonUtil.loadFalseResult(2, "暂无更多数据"));
            }
            out.print(JsonUtil.loadTrueResult(jsonObject));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("查询失败"));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("查询失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    /**
     * 超高奖金(官方推荐中的【有好货】)
     *
     * @param page
     * @param out
     */
    @RequestMapping(value = "getSuperiors", method = RequestMethod.POST)
    public void getSuperiors(AcceptData acceptData, int page, PrintWriter out) {
    /**
     * 超高奖金(官方推荐中的【有好货】)
     *
     * @param page
     * @param out
     */
    @RequestMapping(value = "getSuperiors", method = RequestMethod.POST)
    public void getSuperiors(int page, PrintWriter out) {
        try {
        try {
            List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache(null,
                    "有好货");
            List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache(null,
                    "有好货");
            if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
                out.print(JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
                out.print(JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            TaobaoMeterial meterial = taobaoMeterials.get(0);
            Integer materialId = meterial.getMaterialId();
            if (materialId == null) {
                out.print(JsonUtil.loadFalseResult("未检索到数据"));
                return;
            }
            TaobaoMeterial meterial = taobaoMeterials.get(0);
            Integer materialId = meterial.getMaterialId();
            if (materialId == null) {
                out.print(JsonUtil.loadFalseResult("未检索到数据"));
                return;
            }
            if (page < 1)
                page = 1;
            if (page < 1)
                page = 1;
            int pageSize = Constant.PAGE_SIZE;
            int pageSize = Constant.PAGE_SIZE;
            JSONObject jsonObject = queryMaterialGoods(acceptData, page, pageSize, materialId);
            JSONObject jsonObject = queryMaterialGoods(page, pageSize, materialId);
            if (jsonObject == null) {
                out.print(JsonUtil.loadFalseResult(2, "暂无更多数据"));
            }
            out.print(JsonUtil.loadTrueResult(jsonObject));
            if (jsonObject == null) {
                out.print(JsonUtil.loadFalseResult(2, "暂无更多数据"));
            }
            out.print(JsonUtil.loadTrueResult(jsonObject));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("查询失败"));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("查询失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    /**
     * 今日新品【(官方推荐【好券直播】接口)
     *
     * @param page
     * @param subName 子类名称
     */
    @RequestMapping(value = "todayNew")
    public void todayNew(AcceptData acceptData, String callback, Integer page, String subName, String uid, PrintWriter out) {
    /**
     * 今日新品【(官方推荐【好券直播】接口)
     *
     * @param page
     * @param subName
     *            子类名称
     */
    @RequestMapping(value = "todayNew")
    public void todayNew(String callback, Integer page, String subName, String uid, PrintWriter out) {
        try {
        try {
            List<TaobaoMeterial> list = taobaoMeterialService.selectByClassNameAndSuperNameCache(subName, "好券直播");
            List<TaobaoMeterial> list = taobaoMeterialService.selectByClassNameAndSuperNameCache(subName, "好券直播");
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            TaobaoMeterial taobaoMeterial = list.get(0);
            Integer materialId = taobaoMeterial.getMaterialId();
            if (materialId == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检索到数据"));
                return;
            }
            TaobaoMeterial taobaoMeterial = list.get(0);
            Integer materialId = taobaoMeterial.getMaterialId();
            if (materialId == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检索到数据"));
                return;
            }
            if (page == null)
                page = 1;
            if (page == null)
                page = 1;
            int pageSize = Constant.PAGE_SIZE;
            int pageSize = Constant.PAGE_SIZE;
            List<TaoBaoGoodsBrief> listMaterial = taoKeGoodsService.listByMaterial(materialId, page, pageSize);
            List<TaoBaoGoodsBrief> listMaterial = taoKeGoodsService.listByMaterial(materialId, page, pageSize);
            if (listMaterial == null || listMaterial.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
                return;
            }
            if (listMaterial == null || listMaterial.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
                return;
            }
            JSONArray array = new JSONArray();
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            JSONArray array = new JSONArray();
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
            BigDecimal proportion = manageService.getFanLiRate();
            /* 遍历列表数据 */
            for (TaoBaoGoodsBrief taoBaoGoodsBrief : listMaterial) {
            /* 遍历列表数据 */
            for (TaoBaoGoodsBrief taoBaoGoodsBrief : listMaterial) {
                int biz30day = taoBaoGoodsBrief.getBiz30day();
                if (biz30day >= 10000) {
                    double sales = biz30day;
                    String salesCountMidea = String.format("%.1f", sales / 10000);
                    taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
                } else {
                    taoBaoGoodsBrief.setSalesCount(biz30day + "");
                }
                int biz30day = taoBaoGoodsBrief.getBiz30day();
                if (biz30day >= 10000) {
                    double sales = biz30day;
                    String salesCountMidea = String.format("%.1f", sales / 10000);
                    taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
                } else {
                    taoBaoGoodsBrief.setSalesCount(biz30day + "");
                }
                // 改变图片尺寸 大图更清晰
                String pictUrl = taoBaoGoodsBrief.getPictUrl();
                pictUrl = pictUrl.replaceAll("320x320", "640x640");
                taoBaoGoodsBrief.setPictUrl(pictUrl);
                // 改变图片尺寸 大图更清晰
                String pictUrl = taoBaoGoodsBrief.getPictUrl();
                pictUrl = pictUrl.replaceAll("320x320", "640x640");
                taoBaoGoodsBrief.setPictUrl(pictUrl);
                int collected = 0;
                // 判断收藏
                if (!StringUtil.isNullOrEmpty(uid)) {
                    CollectionGoodsV2 collectionGoods = collectionGoodsV2Service
                            .findByUidAndAuctionId(Long.parseLong(uid), taoBaoGoodsBrief.getAuctionId(), Constant.SOURCE_TYPE_TAOBAO);
                    if (collectionGoods != null) {
                        collected = 1;
                    }
                }
                int collected = 0;
                // 判断收藏
                if (!StringUtil.isNullOrEmpty(uid)) {
                    CollectionGoodsV2 collectionGoods = collectionGoodsV2Service
                            .findByUidAndAuctionId(Long.parseLong(uid), taoBaoGoodsBrief.getAuctionId(),Constant.SOURCE_TYPE_TAOBAO);
                    if (collectionGoods != null) {
                        collected = 1;
                    }
                }
                TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief,
                        proportion.toString(), null);
                taoBaoGoodsBriefExtra.setCollected(collected);
                TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief,
                        proportion.toString(), null);
                taoBaoGoodsBriefExtra.setCollected(collected);
                array.add(gson.toJson(taoBaoGoodsBriefExtra));
            }
                array.add(gson.toJson(taoBaoGoodsBriefExtra));
            }
            JSONObject data = new JSONObject();
            data.put("result_list", array);
            data.put("count", 1000);
            JSONObject data = new JSONObject();
            data.put("result_list", array);
            data.put("count", 1000);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    /**
     * 潮品热卖(官方推荐中的【潮流范】)
     *
     * @param page
     * @param out
     */
    @RequestMapping(value = "getFashions")
    public void getFashions(String callback, Integer page, PrintWriter out) {
    /**
     * 潮品热卖(官方推荐中的【潮流范】)
     *
     * @param page
     * @param out
     */
    @RequestMapping(value = "getFashions")
    public void getFashions(AcceptData acceptData, String callback, Integer page, PrintWriter out) {
        try {
        try {
            List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache(null,
                    "潮流范");
            List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache(null,
                    "潮流范");
            if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            TaobaoMeterial meterial = taobaoMeterials.get(0);
            Integer materialId = meterial.getMaterialId();
            if (materialId == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检索到数据"));
                return;
            }
            TaobaoMeterial meterial = taobaoMeterials.get(0);
            Integer materialId = meterial.getMaterialId();
            if (materialId == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检索到数据"));
                return;
            }
            if (page == null) {
                page = 1;
            }
            if (page == null) {
                page = 1;
            }
            int pageSize = Constant.PAGE_SIZE;
            int pageSize = Constant.PAGE_SIZE;
            JSONObject jsonObject = queryMaterialGoods(page, pageSize, materialId);
            JSONObject jsonObject = queryMaterialGoods(acceptData, page, pageSize, materialId);
            if (jsonObject == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
                return;
            }
            if (jsonObject == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
                return;
            }
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonObject));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonObject));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    /**
     * 母婴精选(官方推荐中的【母婴主题】)
     *
     * @param page
     * @param out
     */
    @RequestMapping(value = "getPregnantBaby")
    public void getPregnantBaby(AcceptData acceptData, String callback, Integer page, String subName, PrintWriter out) {
    /**
     * 母婴精选(官方推荐中的【母婴主题】)
     *
     * @param page
     * @param out
     */
    @RequestMapping(value = "getPregnantBaby")
    public void getPregnantBaby(AcceptData acceptData, String callback, Integer page, String subName, PrintWriter out) {
        try {
        try {
            List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache(subName,
                    "母婴主题");
            List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache(subName,
                    "母婴主题");
            if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            TaobaoMeterial meterial = taobaoMeterials.get(0);
            Integer materialId = meterial.getMaterialId();
            if (materialId == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检索到数据"));
                return;
            }
            TaobaoMeterial meterial = taobaoMeterials.get(0);
            Integer materialId = meterial.getMaterialId();
            if (materialId == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检索到数据"));
                return;
            }
            if (page == null) {
                page = 1;
            }
            int pageSize = Constant.PAGE_SIZE;
            if (page == null) {
                page = 1;
            }
            int pageSize = Constant.PAGE_SIZE;
            JSONObject jsonObject = queryMaterialGoods(page, pageSize, materialId);
            JSONObject jsonObject = queryMaterialGoods(acceptData, page, pageSize, materialId);
            if (jsonObject == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
            }
            if (jsonObject == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
            }
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonObject));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonObject));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    /**
     * 推荐查询接口对接-公用方法
     *
     * @param page
     * @param pageSize
     * @param materialId
     * @return
     * @throws Exception
     */
    public JSONObject queryMaterialGoods(int page, int pageSize, Integer materialId) throws Exception {
    /**
     * 推荐查询接口对接-公用方法
     *
     * @param page
     * @param pageSize
     * @param materialId
     * @return
     * @throws Exception
     */
    public JSONObject queryMaterialGoods(AcceptData acceptData, int page, int pageSize, Integer materialId) throws Exception {
        List<TaoBaoGoodsBrief> listBrands = taoKeGoodsService.listByMaterial(materialId, page, pageSize);
        List<TaoBaoGoodsBrief> listBrands = taoKeGoodsService.listByMaterial(materialId, page, pageSize);
        if (listBrands == null || listBrands.size() == 0) {
            return null;
        }
        if (listBrands == null || listBrands.size() == 0) {
            return null;
        }
        JSONArray array = new JSONArray();
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        JSONArray array = new JSONArray();
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        BigDecimal proportion = manageService.getFanLiRate();
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        /* 遍历列表数据 */
        for (TaoBaoGoodsBrief taoBaoGoodsBrief : listBrands) {
        /* 遍历列表数据 */
        for (TaoBaoGoodsBrief taoBaoGoodsBrief : listBrands) {
            int biz30day = taoBaoGoodsBrief.getBiz30day();
            if (biz30day >= 10000) {
                double sales = biz30day;
                String salesCountMidea = String.format("%.1f", sales / 10000);
                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
            } else {
                taoBaoGoodsBrief.setSalesCount(biz30day + "");
            }
            int biz30day = taoBaoGoodsBrief.getBiz30day();
            if (biz30day >= 10000) {
                double sales = biz30day;
                String salesCountMidea = String.format("%.1f", sales / 10000);
                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
            } else {
                taoBaoGoodsBrief.setSalesCount(biz30day + "");
            }
            // 改变图片尺寸
            String pictUrl = taoBaoGoodsBrief.getPictUrl();
            if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
                taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
            }
            // 改变图片尺寸
            String pictUrl = taoBaoGoodsBrief.getPictUrl();
            if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
                taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
            }
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
        }
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
        }
        JSONObject data = new JSONObject();
        data.put("result_list", array);
        data.put("count", 1000);
        JSONObject data = new JSONObject();
        data.put("result_list", array);
        data.put("count", 1000);
        return data;
        return data;
    }
    }
    /**
     * 限时抢购
     *
     * @param callback
     * @param page
     * @param out
     */
    @RequestMapping("getFlashSale")
    public void getFlashSale(String callback, Integer page, Long auctionId, PrintWriter out) {
    /**
     * 限时抢购
     *
     * @param callback
     * @param page
     * @param out
     */
    @RequestMapping("getFlashSale")
    public void getFlashSale(AcceptData acceptData, String callback, Integer page, Long auctionId, PrintWriter out) {
        if (page == null)
            page = 1;
        if (page == null)
            page = 1;
        int pageSize = Constant.PAGE_SIZE;
        int type = qualityFlashSaleService.getNowType();
        int pageSize = Constant.PAGE_SIZE;
        int type = qualityFlashSaleService.getNowType();
        TaoBaoGoodsBrief goodsBrief = null;
        if (page == 1 && auctionId != null) {
            List<TaoBaoGoodsBrief> list = taoBaoGoodsBriefService.queryByAuctionId(auctionId);
            if (list != null && list.size() > 0) {
                goodsBrief = list.get(0);
            }
        }
        TaoBaoGoodsBrief goodsBrief = null;
        if (page == 1 && auctionId != null) {
            List<TaoBaoGoodsBrief> list = taoBaoGoodsBriefService.queryByAuctionId(auctionId);
            if (list != null && list.size() > 0) {
                goodsBrief = list.get(0);
            }
        }
        if (goodsBrief != null) {
            pageSize = pageSize - 1;
        }
        if (goodsBrief != null) {
            pageSize = pageSize - 1;
        }
        List<QualityFactory> listQuery = qualityGoodsService.listQueryByFlashSale((page - 1) * pageSize, pageSize);
        List<QualityFactory> listQuery = qualityGoodsService.listQueryByFlashSale((page - 1) * pageSize, pageSize);
        // 精选库数据为空
        if (listQuery == null || listQuery.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
            return;
        }
        // 精选库数据为空
        if (listQuery == null || listQuery.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
            return;
        }
        long count = 3000;
        long count = 3000;
        // 精选库数据处理返回 前端
        JSONArray array = new JSONArray();
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        // 精选库数据处理返回 前端
        JSONArray array = new JSONArray();
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        BigDecimal proportion = manageService.getFanLiRate();
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        if (goodsBrief != null) {
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion.toString(), null)));
        }
        if (goodsBrief != null) {
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion.toString(), null)));
        }
        // 遍历列表数据
        for (QualityFactory quality : listQuery) {
        // 遍历列表数据
        for (QualityFactory quality : listQuery) {
            TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief();
            if (taoBaoGoodsBrief == null) {
                continue;
            }
            TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief();
            if (taoBaoGoodsBrief == null) {
                continue;
            }
            if (goodsBrief != null && auctionId.equals(taoBaoGoodsBrief.getAuctionId())) {
                continue;
            }
            if (goodsBrief != null && auctionId.equals(taoBaoGoodsBrief.getAuctionId())) {
                continue;
            }
            int biz30day = taoBaoGoodsBrief.getBiz30day();
            if (biz30day >= 10000) {
                double sales = biz30day;
                String salesCountMidea = String.format("%.1f", sales / 10000);
                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
            } else {
                taoBaoGoodsBrief.setSalesCount(biz30day + "");
            }
            int biz30day = taoBaoGoodsBrief.getBiz30day();
            if (biz30day >= 10000) {
                double sales = biz30day;
                String salesCountMidea = String.format("%.1f", sales / 10000);
                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
            } else {
                taoBaoGoodsBrief.setSalesCount(biz30day + "");
            }
            // 改变图片尺寸
            String pictUrl = taoBaoGoodsBrief.getPictUrl();
            if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
                taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
            }
            // 改变图片尺寸
            String pictUrl = taoBaoGoodsBrief.getPictUrl();
            if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
                taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
            }
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
        }
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
        }
        JSONObject data = new JSONObject();
        data.put("count", count);
        data.put("type", type);
        data.put("result_list", array);
        JSONObject data = new JSONObject();
        data.put("count", count);
        data.put("type", type);
        data.put("result_list", array);
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
    @RequestMapping("getFlashSaleNew")
    public void getFlashSaleNew(String callback, Integer page, Long auctionId, String time, PrintWriter out) {
        List<DaTaoKeDetailV2> detailList0 = daTaoKeGoodsDetailV2Service.getDingDongQiangData(time);
        if (detailList0 == null)
            detailList0 = new ArrayList<>();
        List<DaTaoKeDetailV2> detailList = new ArrayList<>();
        detailList.addAll(detailList0);
        JSONArray array = new JSONArray();
        if (page == 1) {
            if (auctionId != null && detailList != null)
                for (int i = 0; i < detailList.size(); i++) {
                    if (detailList.get(i).getGoodsId().longValue() == auctionId) {
                        DaTaoKeDetailV2 goods = detailList.get(i);
                        detailList.remove(i);
                        detailList.add(0, goods);
                        break;
                    }
                }
    @RequestMapping("getFlashSaleNew")
    public void getFlashSaleNew(AcceptData acceptData, String callback, Integer page, Long auctionId, String time, PrintWriter out) {
        List<DaTaoKeDetailV2> detailList0 = daTaoKeGoodsDetailV2Service.getDingDongQiangData(time);
        if (detailList0 == null)
            detailList0 = new ArrayList<>();
        List<DaTaoKeDetailV2> detailList = new ArrayList<>();
        detailList.addAll(detailList0);
        JSONArray array = new JSONArray();
        if (page == 1) {
            if (auctionId != null && detailList != null)
                for (int i = 0; i < detailList.size(); i++) {
                    if (detailList.get(i).getGoodsId().longValue() == auctionId) {
                        DaTaoKeDetailV2 goods = detailList.get(i);
                        detailList.remove(i);
                        detailList.add(0, goods);
                        break;
                    }
                }
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            if (detailList != null)
                for (DaTaoKeDetailV2 detail : detailList) {
                    array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(TaoBaoUtil.convert(detail),
                            hongBaoManageService.getFanLiRate() + "", null)));
                }
        }
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            if (detailList != null)
                for (DaTaoKeDetailV2 detail : detailList) {
                    array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(TaoBaoUtil.convert(detail),
                            hongBaoManageService.getFanLiRate(acceptData.getSystem()) + "", null)));
                }
        }
        JSONObject data = new JSONObject();
        data.put("count", detailList.size());
        data.put("result_list", array);
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
        JSONObject data = new JSONObject();
        data.put("count", detailList.size());
        data.put("result_list", array);
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
    /**
     * 大额券(券面值范围)
     *
     * @param callback
     * @param amount
     * @param page
     * @param out
     */
    @RequestMapping("choiceCouponAmount")
    public void choiceCouponAmount(String callback, Integer amount, Integer page, PrintWriter out) {
    /**
     * 大额券(券面值范围)
     *
     * @param callback
     * @param amount
     * @param page
     * @param out
     */
    @RequestMapping("choiceCouponAmount")
    public void choiceCouponAmount(AcceptData acceptData, String callback, Integer amount, Integer page, PrintWriter out) {
        if (page == null)
            page = 1;
        if (page == null)
            page = 1;
        int pageSize = Constant.PAGE_SIZE;
        int pageSize = Constant.PAGE_SIZE;
        Integer startAmount = null;
        Integer endAmount = null;
        Integer startAmount = null;
        Integer endAmount = null;
        if (amount.equals(1)) {
            startAmount = 5;
            endAmount = 10;
        } else if (amount.equals(2)) {
            startAmount = 10;
            endAmount = 30;
        } else if (amount.equals(3)) {
            startAmount = 30;
            endAmount = 50;
        } else if (amount.equals(4)) {
            startAmount = 50;
        }
        if (amount.equals(1)) {
            startAmount = 5;
            endAmount = 10;
        } else if (amount.equals(2)) {
            startAmount = 10;
            endAmount = 30;
        } else if (amount.equals(3)) {
            startAmount = 30;
            endAmount = 50;
        } else if (amount.equals(4)) {
            startAmount = 50;
        }
        Integer startPropor = 20;
        Integer startPropor = 20;
        List<QualityFactory> listQuery = qualityGoodsService.listQueryByCouponAmount((page - 1) * pageSize, pageSize,
                startAmount, endAmount, startPropor);
        List<QualityFactory> listQuery = qualityGoodsService.listQueryByCouponAmount((page - 1) * pageSize, pageSize,
                startAmount, endAmount, startPropor);
        if (listQuery == null || listQuery.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
            return;
        }
        if (listQuery == null || listQuery.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
            return;
        }
        long count = qualityGoodsService.countQueryByCouponAmount(startAmount, endAmount, startPropor);
        long count = qualityGoodsService.countQueryByCouponAmount(startAmount, endAmount, startPropor);
        // 精选库数据处理返回 前端
        JSONArray array = new JSONArray();
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        // 精选库数据处理返回 前端
        JSONArray array = new JSONArray();
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        BigDecimal proportion = manageService.getFanLiRate();
        // 遍历列表数据
        for (QualityFactory selectionGoods : listQuery) {
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        // 遍历列表数据
        for (QualityFactory selectionGoods : listQuery) {
            TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
            TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
            if (taoBaoGoodsBrief == null) {
                continue;
            }
            if (taoBaoGoodsBrief == null) {
                continue;
            }
            int biz30day = taoBaoGoodsBrief.getBiz30day();
            if (biz30day >= 10000) {
                double sales = biz30day;
                String salesCountMidea = String.format("%.1f", sales / 10000);
                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
            } else {
                taoBaoGoodsBrief.setSalesCount(biz30day + "");
            }
            int biz30day = taoBaoGoodsBrief.getBiz30day();
            if (biz30day >= 10000) {
                double sales = biz30day;
                String salesCountMidea = String.format("%.1f", sales / 10000);
                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
            } else {
                taoBaoGoodsBrief.setSalesCount(biz30day + "");
            }
            // 改变图片尺寸
            String pictUrl = taoBaoGoodsBrief.getPictUrl();
            if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
                taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
            }
            // 改变图片尺寸
            String pictUrl = taoBaoGoodsBrief.getPictUrl();
            if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
                taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
            }
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
        }
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
        }
        JSONObject data = new JSONObject();
        data.put("count", count);
        data.put("result", array);
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
        JSONObject data = new JSONObject();
        data.put("count", count);
        data.put("result", array);
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
    /**
     * 超高奖金
     *
     * @param callback
     * @param page
     * @param type
     * @param out
     */
    @RequestMapping("choiceRebate")
    public void choiceRebate(String callback, Integer page, Integer type, PrintWriter out) {
    /**
     * 超高奖金
     *
     * @param callback
     * @param page
     * @param type
     * @param out
     */
    @RequestMapping("choiceRebate")
    public void choiceRebate(AcceptData acceptData, String callback, Integer page, Integer type, PrintWriter out) {
        if (page == null)
            page = 1;
        if (page == null)
            page = 1;
        int pageSize = Constant.PAGE_SIZE;
        int pageSize = Constant.PAGE_SIZE;
        Integer startAmount = null;
        Integer endAmount = null;
        Integer startAmount = null;
        Integer endAmount = null;
        if (type.equals(1)) {
            startAmount = 1;
            endAmount = 5;
        } else if (type.equals(2)) {
            startAmount = 5;
            endAmount = 10;
        } else if (type.equals(3)) {
            startAmount = 10;
            endAmount = 15;
        } else if (type.equals(4)) {
            startAmount = 15;
        }
        if (type.equals(1)) {
            startAmount = 1;
            endAmount = 5;
        } else if (type.equals(2)) {
            startAmount = 5;
            endAmount = 10;
        } else if (type.equals(3)) {
            startAmount = 10;
            endAmount = 15;
        } else if (type.equals(4)) {
            startAmount = 15;
        }
        double tkRate = 20.00;
        double tkRate = 20.00;
        BigDecimal proportion = manageService.getFanLiRate();
        List<QualityFactory> listQuery = qualityGoodsService.listQueryByRebateAmount((page - 1) * pageSize, pageSize,
                proportion.toString(), startAmount, endAmount, tkRate);
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        List<QualityFactory> listQuery = qualityGoodsService.listQueryByRebateAmount((page - 1) * pageSize, pageSize,
                proportion.toString(), startAmount, endAmount, tkRate);
        if (listQuery == null || listQuery.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
            return;
        }
        if (listQuery == null || listQuery.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
            return;
        }
        long count = qualityGoodsService.countQueryByRebateAmount(proportion.toString(), startAmount, endAmount,
                tkRate);
        long count = qualityGoodsService.countQueryByRebateAmount(proportion.toString(), startAmount, endAmount,
                tkRate);
        // 精选库数据处理返回 前端
        JSONArray array = new JSONArray();
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        // 精选库数据处理返回 前端
        JSONArray array = new JSONArray();
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        // 遍历列表数据
        for (QualityFactory quality : listQuery) {
        // 遍历列表数据
        for (QualityFactory quality : listQuery) {
            TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief();
            TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief();
            if (taoBaoGoodsBrief == null) {
                continue;
            }
            if (taoBaoGoodsBrief == null) {
                continue;
            }
            int biz30day = taoBaoGoodsBrief.getBiz30day();
            if (biz30day >= 10000) {
                double sales = biz30day;
                String salesCountMidea = String.format("%.1f", sales / 10000);
                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
            } else {
                taoBaoGoodsBrief.setSalesCount(biz30day + "");
            }
            int biz30day = taoBaoGoodsBrief.getBiz30day();
            if (biz30day >= 10000) {
                double sales = biz30day;
                String salesCountMidea = String.format("%.1f", sales / 10000);
                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
            } else {
                taoBaoGoodsBrief.setSalesCount(biz30day + "");
            }
            // 改变图片尺寸
            String pictUrl = taoBaoGoodsBrief.getPictUrl();
            if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
                taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
            }
            // 改变图片尺寸
            String pictUrl = taoBaoGoodsBrief.getPictUrl();
            if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
                taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
            }
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
        }
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
        }
        JSONObject data = new JSONObject();
        data.put("count", count);
        data.put("result_list", array);
        JSONObject data = new JSONObject();
        data.put("count", count);
        data.put("result_list", array);
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
    /**
     * 超高奖金
     *
     * @param callback
     * @param page
     * @param out
     */
    @RequestMapping("recommendToIndex")
    public void recommendToIndex(String callback, Integer page, PrintWriter out) {
    /**
     * 超高奖金
     *
     * @param callback
     * @param page
     * @param out
     */
    @RequestMapping("recommendToIndex")
    public void recommendToIndex(AcceptData acceptData, String callback, Integer page, PrintWriter out) {
        if (page == null)
            page = 1;
        if (page == null)
            page = 1;
        int pageSize = Constant.PAGE_SIZE;
        int pageSize = Constant.PAGE_SIZE;
        BigDecimal proportion = manageService.getFanLiRate();
        JSONArray array = qualityGoodsService.getRecommendToIndex((page - 1) * pageSize, pageSize,
                proportion.toString());
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        JSONArray array = qualityGoodsService.getRecommendToIndex((page - 1) * pageSize, pageSize,
                proportion.toString());
        if (array == null) {
            out.print(JsonUtil.loadFalseResult("没有更多了"));
            return;
        }
        if (array == null) {
            out.print(JsonUtil.loadFalseResult("没有更多了"));
            return;
        }
        long count = qualityGoodsService.countRecommendToIndex(proportion.toString());
        long count = qualityGoodsService.countRecommendToIndex(proportion.toString());
        JSONObject data = new JSONObject();
        data.put("count", count);
        data.put("result_list", array);
        JSONObject data = new JSONObject();
        data.put("count", count);
        data.put("result_list", array);
        out.print(JsonUtil.loadTrueResult(data));
        return;
    }
        out.print(JsonUtil.loadTrueResult(data));
        return;
    }
    /**
     * 超高奖金
     *
     * @param callback
     * @param page
     * @param out
     */
    @RequestMapping("freeGoods")
    public void freeGoods(String callback, Integer page, PrintWriter out) {
        try {
            if (page == null || page < 1)
                page = 1;
    /**
     * 超高奖金
     *
     * @param callback
     * @param page
     * @param out
     */
    @RequestMapping("freeGoods")
    public void freeGoods(AcceptData acceptData, String callback, Integer page, PrintWriter out) {
        try {
            if (page == null || page < 1)
                page = 1;
            int pageSize = Constant.PAGE_SIZE;
            int pageSize = Constant.PAGE_SIZE;
            List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
            if (listQuery == null || listQuery.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
                return;
            }
            List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
            if (listQuery == null || listQuery.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
                return;
            }
            List<Long> listGid = new ArrayList<Long>();
            for (QualityFactory qualityFactory : listQuery) {
                TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
            List<Long> listGid = new ArrayList<Long>();
            for (QualityFactory qualityFactory : listQuery) {
                TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
                if (taoBaoGoodsBrief == null) {
                    continue;
                }
                listGid.add(taoBaoGoodsBrief.getAuctionId());
            }
                if (taoBaoGoodsBrief == null) {
                    continue;
                }
                listGid.add(taoBaoGoodsBrief.getAuctionId());
            }
            // 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();
            }
            JSONArray array = new JSONArray();
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            JSONArray array = new JSONArray();
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            BigDecimal proportion = manageService.getFanLiRate();
            /* 遍历列表数据 */
            for (QualityFactory selectionGoods : listQuery) {
            BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
            /* 遍历列表数据 */
            for (QualityFactory selectionGoods : listQuery) {
                TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
                TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
                if (taoBaoGoodsBrief == null) {
                    continue;
                }
                if (taoBaoGoodsBrief == null) {
                    continue;
                }
                if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
                    boolean stateSale = false; // 默认停售
                    Long goodsId = taoBaoGoodsBrief.getAuctionId();
                    for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
                        Long auctionId = taoKeGoods.getAuctionId();
                        if (goodsId == auctionId || goodsId.equals(auctionId)) {
                            stateSale = true; // 在售
                            break;
                        }
                    }
                if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
                    boolean stateSale = false; // 默认停售
                    Long goodsId = taoBaoGoodsBrief.getAuctionId();
                    for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
                        Long auctionId = taoKeGoods.getAuctionId();
                        if (goodsId == auctionId || goodsId.equals(auctionId)) {
                            stateSale = true; // 在售
                            break;
                        }
                    }
                    if (!stateSale) {
                        continue;
                    }
                }
                    if (!stateSale) {
                        continue;
                    }
                }
                BigDecimal couplePrice = TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief);
                if (couplePrice.compareTo(new BigDecimal("9.9")) == 1) {
                    continue; // 券后价大于10
                }
                BigDecimal couplePrice = TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief);
                if (couplePrice.compareTo(new BigDecimal("9.9")) == 1) {
                    continue; // 券后价大于10
                }
                TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief,
                        proportion.toString(), null);
                // 将返利改为券后价
                TaoBaoHongBaoInfo taoBaoHongBaoInfo = extra.getTaoBaoHongBaoInfo();
                if (taoBaoHongBaoInfo != null) {
                    taoBaoHongBaoInfo.setHongbao(extra.getQuanPrice());
                    taoBaoHongBaoInfo.setRate("¥" + extra.getQuanPrice());
                }
                TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief,
                        proportion.toString(), null);
                // 将返利改为券后价
                TaoBaoHongBaoInfo taoBaoHongBaoInfo = extra.getTaoBaoHongBaoInfo();
                if (taoBaoHongBaoInfo != null) {
                    taoBaoHongBaoInfo.setHongbao(extra.getQuanPrice());
                    taoBaoHongBaoInfo.setRate("¥" + extra.getQuanPrice());
                }
                array.add(gson.toJson(extra));
            }
                array.add(gson.toJson(extra));
            }
            long count = qualityGoodsService.countFreeGoods();
            long count = qualityGoodsService.countFreeGoods();
            JSONObject data = new JSONObject();
            if (page == 1) {
                // 抽奖规则
                data.put("ruleLink", "");
            }
            JSONObject data = new JSONObject();
            if (page == 1) {
                // 抽奖规则
                data.put("ruleLink", "");
            }
            data.put("count", count);
            data.put("result_list", array);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("数据暂未提供"));
            LogHelper.errorDetailInfo(e);
        }
    }
            data.put("count", count);
            data.put("result_list", array);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("数据暂未提供"));
            LogHelper.errorDetailInfo(e);
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5ShareController.java
@@ -7,6 +7,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.accept.AcceptData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
@@ -41,207 +42,203 @@
@RequestMapping("api/apph5/v1/share")
public class AppH5ShareController {
    @Resource
    private UserShareGoodsRecordService userShareGoodsRecordService;
    @Resource
    private UserShareGoodsRecordService userShareGoodsRecordService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    /**
     * 分享商品详情
     *
     * @param callback
     * @param shareId
     *            分享id
     * @param source
     *            来源
     * @param out
     */
    @RequestMapping(value = "getDetail")
    public void getDetail(String callback, Long shareId, String source, String fingerprint, PrintWriter out) {
        try {
            if (shareId == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("传递参数不正确"));
                return;
            }
    /**
     * 分享商品详情
     *
     * @param callback
     * @param shareId  分享id
     * @param source   来源
     * @param out
     */
    @RequestMapping(value = "getDetail")
    public void getDetail(AcceptData acceptData, String callback, Long shareId, String source, String fingerprint, PrintWriter out) {
        try {
            if (shareId == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("传递参数不正确"));
                return;
            }
            // 获取商品信息
            JSONObject data = userShareGoodsRecordService.getGoodsGroupDetail(shareId);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("获取失败"));
            e.printStackTrace();
        }
    }
            // 获取商品信息
            JSONObject data = userShareGoodsRecordService.getGoodsGroupDetail(shareId,acceptData.getSystem());
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("获取失败"));
            e.printStackTrace();
        }
    }
    /**
     * 分享商品列表
     *
     * @param callback
     * @param shareId
     *            分享id
     * @param source
     *            来源
     * @param out
     */
    @RequestMapping(value = "getList")
    public void getList(String callback, Long shareId, PrintWriter out) {
        try {
            if (shareId == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("传递参数不正确"));
                return;
            }
    /**
     * 分享商品列表
     *
     * @param callback
     * @param shareId  分享id
     * @param source   来源
     * @param out
     */
    @RequestMapping(value = "getList")
    public void getList(AcceptData acceptData, String callback, Long shareId, PrintWriter out) {
        try {
            if (shareId == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("传递参数不正确"));
                return;
            }
            JSONArray array = new JSONArray();
            JSONArray array = new JSONArray();
            List<UserShareGoodsGroup> list = userShareGoodsRecordService.listByRecordId(shareId);
            if (list != null && list.size() > 0) {
                List<Long> listIdTB = new ArrayList<Long>();
                List<Long> listIdJD = new ArrayList<Long>();
                List<Long> listIdPDD = new ArrayList<Long>();
            List<UserShareGoodsGroup> list = userShareGoodsRecordService.listByRecordId(shareId);
            if (list != null && list.size() > 0) {
                List<Long> listIdTB = new ArrayList<Long>();
                List<Long> listIdJD = new ArrayList<Long>();
                List<Long> listIdPDD = new ArrayList<Long>();
                for (int i = 0; i < list.size(); i++) {
                    CommonGoods commonGoods = list.get(i).getCommonGoods();
                    if (commonGoods == null) {
                        continue;
                    }
                for (int i = 0; i < list.size(); i++) {
                    CommonGoods commonGoods = list.get(i).getCommonGoods();
                    if (commonGoods == null) {
                        continue;
                    }
                    Integer goodsType = commonGoods.getGoodsType();
                    if (goodsType == null) {
                        continue;
                    }
                    Integer goodsType = commonGoods.getGoodsType();
                    if (goodsType == null) {
                        continue;
                    }
                    if (Constant.SOURCE_TYPE_TAOBAO == goodsType) {
                        listIdTB.add(commonGoods.getGoodsId());
                    } else if (Constant.SOURCE_TYPE_JD == goodsType) {
                        listIdJD.add(commonGoods.getGoodsId());
                    } else if (Constant.SOURCE_TYPE_PDD == goodsType) {
                        listIdPDD.add(commonGoods.getGoodsId());
                    }
                }
                    if (Constant.SOURCE_TYPE_TAOBAO == goodsType) {
                        listIdTB.add(commonGoods.getGoodsId());
                    } else if (Constant.SOURCE_TYPE_JD == goodsType) {
                        listIdJD.add(commonGoods.getGoodsId());
                    } else if (Constant.SOURCE_TYPE_PDD == goodsType) {
                        listIdPDD.add(commonGoods.getGoodsId());
                    }
                }
                // 淘宝验证是否在售
                List<TaoBaoGoodsBrief> listTB = null;
                if (listIdTB.size() > 0) {
                    try {
                        listTB = TaoKeApiUtil.getBatchGoodsInfo(listIdTB);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                // 淘宝验证是否在售
                List<TaoBaoGoodsBrief> listTB = null;
                if (listIdTB.size() > 0) {
                    try {
                        listTB = TaoKeApiUtil.getBatchGoodsInfo(listIdTB);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                // 京东验证是否在售
                List<JDGoods> listJD = null;
                if (listIdJD.size() > 0) {
                    try {
                        JDFilter filter = new JDFilter();
                        filter.setListId(listIdJD);
                        filter.setPageIndex(1);
                        filter.setPageSize(100);
                        JDSearchResult result = JDApiUtil.queryByKey(filter);
                        if (result != null) {
                            listJD = result.getGoodsList();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                // 京东验证是否在售
                List<JDGoods> listJD = null;
                if (listIdJD.size() > 0) {
                    try {
                        JDFilter filter = new JDFilter();
                        filter.setListId(listIdJD);
                        filter.setPageIndex(1);
                        filter.setPageSize(100);
                        JDSearchResult result = JDApiUtil.queryByKey(filter);
                        if (result != null) {
                            listJD = result.getGoodsList();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                // 拼多多验证是否在售
                List<PDDGoodsDetail> listPDD = null;
                if (listIdPDD.size() > 0) {
                    try {
                        Long[] ids = new Long[list.size()];
                        PDDSearchFilter sf = new PDDSearchFilter();
                        sf.setPage(1);
                        sf.setPageSize(100);
                        sf.setGoodsIdList(listIdPDD.toArray(ids));
                        PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(sf);
                        if (result != null) {
                            listPDD = result.getGoodsList();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                // 拼多多验证是否在售
                List<PDDGoodsDetail> listPDD = null;
                if (listIdPDD.size() > 0) {
                    try {
                        Long[] ids = new Long[list.size()];
                        PDDSearchFilter sf = new PDDSearchFilter();
                        sf.setPage(1);
                        sf.setPageSize(100);
                        sf.setGoodsIdList(listIdPDD.toArray(ids));
                        PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(sf);
                        if (result != null) {
                            listPDD = result.getGoodsList();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                        .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
                BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
                BigDecimal shareRate = hongBaoManageService.getShareRate();
                ConfigParamsDTO configParamsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,
                        hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP));
                for (UserShareGoodsGroup goodsGroup : list) {
                    CommonGoods commonGoods = goodsGroup.getCommonGoods();
                    if (commonGoods == null) {
                        continue;
                    }
                    Integer goodsType = commonGoods.getGoodsType();
                    if (goodsType == null) {
                        goodsType = Constant.SOURCE_TYPE_TAOBAO;
                    }
                    Long commonGid = commonGoods.getGoodsId();
                Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                        .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
                BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(acceptData.getSystem());
                BigDecimal shareRate = hongBaoManageService.getShareRate(acceptData.getSystem());
                ConfigParamsDTO configParamsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,
                        hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP, acceptData.getSystem()));
                    if (goodsType == Constant.SOURCE_TYPE_TAOBAO && listTB != null && listTB.size() > 0) {
                        int state = 1; // 默认停售
                        for (TaoBaoGoodsBrief goodsDetail : listTB) {
                            Long goodsId = goodsDetail.getAuctionId();
                            if (goodsId == commonGid || goodsId.equals(commonGid)) {
                                state = 0; // 在售
                                break;
                            }
                        }
                        commonGoods.setState(state);
                    }
                    if (goodsType == Constant.SOURCE_TYPE_JD && listJD != null && listJD.size() > 0) {
                        int state = 1; // 默认停售
                        for (JDGoods goodsDetail : listJD) {
                            Long goodsId = goodsDetail.getSkuId();
                            if (goodsId == commonGid || goodsId.equals(commonGid)) {
                                state = 0; // 在售
                                break;
                            }
                        }
                        commonGoods.setState(state);
                    }
                for (UserShareGoodsGroup goodsGroup : list) {
                    CommonGoods commonGoods = goodsGroup.getCommonGoods();
                    if (commonGoods == null) {
                        continue;
                    }
                    Integer goodsType = commonGoods.getGoodsType();
                    if (goodsType == null) {
                        goodsType = Constant.SOURCE_TYPE_TAOBAO;
                    }
                    Long commonGid = commonGoods.getGoodsId();
                    if (goodsType == Constant.SOURCE_TYPE_PDD && listPDD != null && listPDD.size() > 0) {
                        int state = 1; // 默认停售
                        for (PDDGoodsDetail goodsDetail : listPDD) {
                            Long goodsId = goodsDetail.getGoodsId();
                            if (goodsId == commonGid || goodsId.equals(commonGid)) {
                                state = 0; // 在售
                                break;
                            }
                        }
                        commonGoods.setState(state);
                    }
                    GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, configParamsDTO);
                    if (!detailVO.isHasCoupon()) {
                        detailVO.setState(1);
                        ; // 已抢光
                    }
                    array.add(gson.toJson(detailVO));
                }
            }
                    if (goodsType == Constant.SOURCE_TYPE_TAOBAO && listTB != null && listTB.size() > 0) {
                        int state = 1; // 默认停售
                        for (TaoBaoGoodsBrief goodsDetail : listTB) {
                            Long goodsId = goodsDetail.getAuctionId();
                            if (goodsId == commonGid || goodsId.equals(commonGid)) {
                                state = 0; // 在售
                                break;
                            }
                        }
                        commonGoods.setState(state);
                    }
            String title = "";
            UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordService.selectByPrimaryKey(shareId);
            if (userShareGoodsRecord != null) {
                title = userShareGoodsRecord.getTitle();
            }
                    if (goodsType == Constant.SOURCE_TYPE_JD && listJD != null && listJD.size() > 0) {
                        int state = 1; // 默认停售
                        for (JDGoods goodsDetail : listJD) {
                            Long goodsId = goodsDetail.getSkuId();
                            if (goodsId == commonGid || goodsId.equals(commonGid)) {
                                state = 0; // 在售
                                break;
                            }
                        }
                        commonGoods.setState(state);
                    }
            JSONObject data = new JSONObject();
            data.put("title", title);
            data.put("count", list.size());
            data.put("result_list", array);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("获取失败"));
            e.printStackTrace();
        }
    }
                    if (goodsType == Constant.SOURCE_TYPE_PDD && listPDD != null && listPDD.size() > 0) {
                        int state = 1; // 默认停售
                        for (PDDGoodsDetail goodsDetail : listPDD) {
                            Long goodsId = goodsDetail.getGoodsId();
                            if (goodsId == commonGid || goodsId.equals(commonGid)) {
                                state = 0; // 在售
                                break;
                            }
                        }
                        commonGoods.setState(state);
                    }
                    GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, configParamsDTO);
                    if (!detailVO.isHasCoupon()) {
                        detailVO.setState(1);
                        ; // 已抢光
                    }
                    array.add(gson.toJson(detailVO));
                }
            }
            String title = "";
            UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordService.selectByPrimaryKey(shareId);
            if (userShareGoodsRecord != null) {
                title = userShareGoodsRecord.getTitle();
            }
            JSONObject data = new JSONObject();
            data.put("title", title);
            data.put("count", list.size());
            data.put("result_list", array);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("获取失败"));
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/BrandController.java
@@ -229,7 +229,7 @@
            if (page == null || page < 1) {
                page = 1;
            }
            JSONObject data = brandClassShopService.listEffectiveCache(page, cid);
            JSONObject data = brandClassShopService.listEffectiveCache(page, cid,acceptData.getSystem());
            out.print(JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            e.printStackTrace();
@@ -342,7 +342,7 @@
                Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                        .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
                BigDecimal proportion = manageService.getFanLiRate(UserLevelEnum.daRen);
                BigDecimal proportion = manageService.getFanLiRate(UserLevelEnum.daRen,acceptData.getSystem());
                for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
                    if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/CommonContentController.java
@@ -92,7 +92,7 @@
        }
        CommonContentResult result = commonTemplateContentService.getContentList(CommonContentTypeEnum.valueOf(key),
                cid, page, 10);
                cid, page, 10,acceptData.getSystem());
        // 保留暂时不开启,待后续开启
        List<SwiperPicture> bannerList = new ArrayList<>();
@@ -103,7 +103,7 @@
        JSONArray array = new JSONArray();
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
        BigDecimal pro = hongBaoManageService.getFanLiRate();
        BigDecimal pro = hongBaoManageService.getFanLiRate(acceptData.getSystem());
        if (CommonContentTypeEnum.valueOf(key) == CommonContentTypeEnum.mianDan)// 免单商品
            pro = new BigDecimal(100);
        List<TaoBaoGoodsBrief> goodsList = result.getGoodsList();
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsClassController.java
@@ -66,859 +66,848 @@
@RequestMapping("api/v1/class")
public class GoodsClassController<E> {
    @Resource
    private SuperGoodsClassService superGoodsClassService;
    @Resource
    private SuperGoodsClassService superGoodsClassService;
    @Resource
    private GoodsSecondClassService goodsSecondClassService;
    @Resource
    private GoodsSecondClassService goodsSecondClassService;
    @Resource
    private GoodsClassService goodsClassService;
    @Resource
    private GoodsClassService goodsClassService;
    @Resource
    private SearchController searchController;
    @Resource
    private SearchController searchController;
    @Resource
    private TaoBaoCouponService taoBaoCouponService;
    @Resource
    private TaoBaoCouponService taoBaoCouponService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private HongBaoManageService manageService;
    @Resource
    private HongBaoManageService manageService;
    @Resource
    private BusinessSystemService businessSystemService;
    @Resource
    private BusinessSystemService businessSystemService;
    @Resource
    private RedisManager redisManager;
    @Resource
    private RedisManager redisManager;
    @Resource
    private QualityFactoryService selectionGoodsService;
    @Resource
    private TaoKeGoodsService taoKeGoodsService;
    @Resource
    private GoodsSubClassService goodsSubClassService;
    @Resource
    private TaoBaoClassService taoBaoClassService;
    @Resource
    private LabelClassService labelClassService;
    @Resource
    private QualityFactoryService selectionGoodsService;
    @Resource
    private TaoKeGoodsService taoKeGoodsService;
    @Resource
    private GoodsSubClassService goodsSubClassService;
    @Resource
    private TaoBaoClassService taoBaoClassService;
    @Resource
    private LabelClassService labelClassService;
    @Resource
    private QualityGoodsService qualityGoodsService;
    @Resource
    private QualityGoodsService qualityGoodsService;
    @Resource
    private MonitorService monitorService;
    @Resource
    private MonitorService monitorService;
    @Resource
    private HomeNavbarService homeNavbarService;
    @Resource
    private SwiperPictureService swiperPictureService;
    @Resource
    private HomeNavbarService homeNavbarService;
    @Resource
    private SwiperPictureService swiperPictureService;
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    /**
     * 获取主类目
     *
     * @param acceptData
     * @param out
     */
    @RequestMapping(value = "getgoodsclass", method = RequestMethod.POST)
    public void getGoodsClass(AcceptData acceptData, PrintWriter out) {
    /**
     * 获取主类目
     *
     * @param acceptData
     * @param out
     */
    @RequestMapping(value = "getgoodsclass", method = RequestMethod.POST)
    public void getGoodsClass(AcceptData acceptData, PrintWriter out) {
        try {
            List<GoodsClass> goodsClassList = goodsClassService.getEffectiveClassCache();
            if (goodsClassList == null || goodsClassList.size() == 0) {
                out.print(JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
        try {
            List<GoodsClass> goodsClassList = goodsClassService.getEffectiveClassCache();
            if (goodsClassList == null || goodsClassList.size() == 0) {
                out.print(JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            JSONObject data = new JSONObject();
            data.put("count", goodsClassList.size());
            data.put("goodsClassList", JsonUtil.getApiCommonGson().toJson(goodsClassList));
            JSONObject data = new JSONObject();
            data.put("count", goodsClassList.size());
            data.put("goodsClassList", JsonUtil.getApiCommonGson().toJson(goodsClassList));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("获取失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
            out.print(JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("获取失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    }
    /**
     * 获取二级子类目
     *
     * @param acceptData
     * @param gcid
     * @param out
     */
    @RequestMapping(value = "getgoodssecondclass", method = RequestMethod.POST)
    public void getGoodsSecondClass(AcceptData acceptData, long gcid, Long swpid, PrintWriter out) {
        try {
            GoodsClass goodsClass = goodsClassService.getGoodsClassCache(gcid);
            if (goodsClass == null) {
                out.print(JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
    /**
     * 获取二级子类目
     *
     * @param acceptData
     * @param gcid
     * @param out
     */
    @RequestMapping(value = "getgoodssecondclass", method = RequestMethod.POST)
    public void getGoodsSecondClass(AcceptData acceptData, long gcid, Long swpid, PrintWriter out) {
        try {
            GoodsClass goodsClass = goodsClassService.getGoodsClassCache(gcid);
            if (goodsClass == null) {
                out.print(JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            // 轮播图
            List<BannerVO> picList = null;
            if (swpid != null) {
                picList = swiperPictureService.getByBannerId(swpid, acceptData.getPlatform(),
                        Integer.parseInt(acceptData.getVersion()),acceptData.getSystem());
            }
            if (picList == null) {
                picList = new ArrayList<BannerVO>();
            }
            // 轮播图
            List<BannerVO> picList = null;
            if (swpid != null) {
                picList = swiperPictureService.getByBannerId(swpid, acceptData.getPlatform(),
                        Integer.parseInt(acceptData.getVersion()), acceptData.getSystem());
            }
            if (picList == null) {
                picList = new ArrayList<BannerVO>();
            }
            List<GoodsSubClass> goodsSubClassList = goodsSubClassService.getSubClassCache(gcid, 1,
                    Calendar.getInstance().get(Calendar.MONTH) + 1);
            if (goodsSubClassList == null) {
                goodsSubClassList = new ArrayList<GoodsSubClass>();
            }
            List<GoodsSubClass> goodsSubClassList = goodsSubClassService.getSubClassCache(gcid, 1,
                    Calendar.getInstance().get(Calendar.MONTH) + 1);
            if (goodsSubClassList == null) {
                goodsSubClassList = new ArrayList<GoodsSubClass>();
            }
            boolean changePicture = false;
            String version = acceptData.getVersion();
            int tversion = Integer.parseInt(version);
            String platform = acceptData.getPlatform();
            if ("android".equalsIgnoreCase(platform) && tversion > 38) {
                changePicture = true;
            } else if (tversion > 47) {
                changePicture = true;
            }
            boolean changePicture = false;
            String version = acceptData.getVersion();
            int tversion = Integer.parseInt(version);
            String platform = acceptData.getPlatform();
            if ("android".equalsIgnoreCase(platform) && tversion > 38) {
                changePicture = true;
            } else if (tversion > 47) {
                changePicture = true;
            }
            // 1.5.3新版图片替换
            if (changePicture) {
                for (GoodsSubClass goodsSubClass : goodsSubClassList) {
                    String pictureSecond = goodsSubClass.getPictureSecond();
                    if (pictureSecond != null && pictureSecond.trim().length() > 0) {
                        goodsSubClass.setPicture(pictureSecond);
                    }
                }
            }
            // 1.5.3新版图片替换
            if (changePicture) {
                for (GoodsSubClass goodsSubClass : goodsSubClassList) {
                    String pictureSecond = goodsSubClass.getPictureSecond();
                    if (pictureSecond != null && pictureSecond.trim().length() > 0) {
                        goodsSubClass.setPicture(pictureSecond);
                    }
                }
            }
            JSONObject data = new JSONObject();
            data.put("picList", JsonUtil.getApiCommonGson().toJson(picList));
            data.put("count", goodsSubClassList.size());
            data.put("goodsSecondClassList", JsonUtil.getApiCommonGson().toJson(goodsSubClassList));
            out.print(JsonUtil.loadTrueResult(data));
            JSONObject data = new JSONObject();
            data.put("picList", JsonUtil.getApiCommonGson().toJson(picList));
            data.put("count", goodsSubClassList.size());
            data.put("goodsSecondClassList", JsonUtil.getApiCommonGson().toJson(goodsSubClassList));
            out.print(JsonUtil.loadTrueResult(data));
            // 更新分类点击次数
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    if ("android".equalsIgnoreCase(acceptData.getPlatform())) {
                        Long androidClick = goodsClass.getAndroidClick();
                        if (androidClick != null) {
                            goodsClass.setAndroidClick(androidClick + 1);
                        } else {
                            goodsClass.setAndroidClick(1L);
                        }
                    } else if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
                        Long iosClick = goodsClass.getIosClick();
                        if (iosClick != null) {
                            goodsClass.setIosClick(iosClick + 1);
                        } else {
                            goodsClass.setIosClick(1L);
                        }
                    }
            // 更新分类点击次数
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    if ("android".equalsIgnoreCase(acceptData.getPlatform())) {
                        Long androidClick = goodsClass.getAndroidClick();
                        if (androidClick != null) {
                            goodsClass.setAndroidClick(androidClick + 1);
                        } else {
                            goodsClass.setAndroidClick(1L);
                        }
                    } else if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
                        Long iosClick = goodsClass.getIosClick();
                        if (iosClick != null) {
                            goodsClass.setIosClick(iosClick + 1);
                        } else {
                            goodsClass.setIosClick(1L);
                        }
                    }
                    GoodsClass gc = new GoodsClass();
                    gc.setId(goodsClass.getId());
                    gc.setIosClick(goodsClass.getIosClick());
                    gc.setAndroidClick(goodsClass.getAndroidClick());
                    goodsClassService.updateByPrimaryKeySelective(gc);
                }
            });
                    GoodsClass gc = new GoodsClass();
                    gc.setId(goodsClass.getId());
                    gc.setIosClick(goodsClass.getIosClick());
                    gc.setAndroidClick(goodsClass.getAndroidClick());
                    goodsClassService.updateByPrimaryKeySelective(gc);
                }
            });
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("暂无数据"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("暂无数据"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    }
    @RequestMapping(value = "getCouponGoods", method = RequestMethod.POST)
    public void getCouponGoods(AcceptData acceptData, int page, long gcid, PrintWriter out) {
        // GoodsClass goodsClass = goodsClassService.getGoodsClass(gcid);
    @RequestMapping(value = "getCouponGoods", method = RequestMethod.POST)
    public void getCouponGoods(AcceptData acceptData, int page, long gcid, PrintWriter out) {
        // GoodsClass goodsClass = goodsClassService.getGoodsClass(gcid);
        List<GoodsSecondClass> secondClassList = goodsSecondClassService.getGoodsSecondClassByGoodsClassId(gcid);
        List<String> searchKeys = new ArrayList<String>();
        for (GoodsSecondClass secondClass : secondClassList) {
            String key = secondClass.getKey();
            if (key == null || "".equals(key.trim())) {
                searchKeys.add(secondClass.getName());
            } else {
                searchKeys.add(secondClass.getKey());
            }
        }
        List<TaoBaoCoupon> taoBaoCoupons = taoBaoCouponService.getTaoBaoCouponListBykeys(searchKeys, page);
        int count = taoBaoCouponService.getCount(searchKeys);
        setTaoBaoCouponHongBao(taoBaoCoupons);
        JSONObject data = new JSONObject();
        long currentTimeMillis = java.lang.System.currentTimeMillis();
        String time = TimeUtil.getGernalTime(currentTimeMillis);
        data.put("time", time);
        data.put("count", count);
        data.put("taoBaoCoupons", Utils.imgListSize(
                JsonUtil.getApiCommonGson().toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtraList(taoBaoCoupons))));
        out.print(JsonUtil.loadTrueResult(data));
    }
        List<GoodsSecondClass> secondClassList = goodsSecondClassService.getGoodsSecondClassByGoodsClassId(gcid);
        List<String> searchKeys = new ArrayList<String>();
        for (GoodsSecondClass secondClass : secondClassList) {
            String key = secondClass.getKey();
            if (key == null || "".equals(key.trim())) {
                searchKeys.add(secondClass.getName());
            } else {
                searchKeys.add(secondClass.getKey());
            }
        }
        List<TaoBaoCoupon> taoBaoCoupons = taoBaoCouponService.getTaoBaoCouponListBykeys(searchKeys, page);
        int count = taoBaoCouponService.getCount(searchKeys);
        setTaoBaoCouponHongBao(acceptData, taoBaoCoupons);
        JSONObject data = new JSONObject();
        long currentTimeMillis = java.lang.System.currentTimeMillis();
        String time = TimeUtil.getGernalTime(currentTimeMillis);
        data.put("time", time);
        data.put("count", count);
        data.put("taoBaoCoupons", Utils.imgListSize(
                JsonUtil.getApiCommonGson().toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtraList(taoBaoCoupons))));
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 获取子类目商品
     *
     * @param acceptData
     * @param page
     * @param scid
     * @param filter
     * @param order
     *            销量由高到低:0 价格从高到低:2 价格从低到高:3 淘客佣金比率高到低:4 其他:默认1
     * @param startprice
     *            起始价格
     * @param endprice
     *            结束价格
     * @param fastFilter
     *            fastFilter 有券 [{"type":"quantype"}] 天猫商品 [{"type":"shoptype"}]
     * @param totalSales
     *            销量以上
     * @param out
     */
    @RequestMapping(value = "getgoods", method = RequestMethod.POST)
    public void getGoods(AcceptData acceptData, int page, long scid, String filter, String order, String startprice,
            String endprice, String fastFilter, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        GoodsSubClass goodsSubClass = goodsSubClassService.selectByPrimaryKey(scid);
        String name2 = goodsSubClass.getName();
        String name1 = goodsSubClass.getKey();
        if (name1 != null && !"".equals(name1.trim())) {
            name2 = name1;
        }
        if (!StringUtil.isNullOrEmpty(fastFilter)) {
            if (!StringUtil.isNullOrEmpty(filter)) {
                JSONArray filterArray = JSONArray.fromObject(filter);
                JSONArray fastFilterArray = JSONArray.fromObject(fastFilter);
                filterArray.addAll(fastFilterArray);
                filter = filterArray.toString();
            } else {
                filter = fastFilter;
            }
        }
    /**
     * 获取子类目商品
     *
     * @param acceptData
     * @param page
     * @param scid
     * @param filter
     * @param order      销量由高到低:0 价格从高到低:2 价格从低到高:3 淘客佣金比率高到低:4 其他:默认1
     * @param startprice 起始价格
     * @param endprice   结束价格
     * @param fastFilter fastFilter 有券 [{"type":"quantype"}] 天猫商品 [{"type":"shoptype"}]
     * @param totalSales 销量以上
     * @param out
     */
    @RequestMapping(value = "getgoods", method = RequestMethod.POST)
    public void getGoods(AcceptData acceptData, int page, long scid, String filter, String order, String startprice,
                         String endprice, String fastFilter, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages(), acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        GoodsSubClass goodsSubClass = goodsSubClassService.selectByPrimaryKey(scid);
        String name2 = goodsSubClass.getName();
        String name1 = goodsSubClass.getKey();
        if (name1 != null && !"".equals(name1.trim())) {
            name2 = name1;
        }
        if (!StringUtil.isNullOrEmpty(fastFilter)) {
            if (!StringUtil.isNullOrEmpty(filter)) {
                JSONArray filterArray = JSONArray.fromObject(filter);
                JSONArray fastFilterArray = JSONArray.fromObject(fastFilter);
                filterArray.addAll(fastFilterArray);
                filter = filterArray.toString();
            } else {
                filter = fastFilter;
            }
        }
        SearchFilter sf = new SearchFilter();
        if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(order)) {
            if (Integer.parseInt(order) == 1) {
                sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
            } else if (Integer.parseInt(order) == 2) {
                sf.setSort(TaoBaoUtil.SORT_PRICE_HIGH_TO_LOW);
            } else if (Integer.parseInt(order) == 3) {
                sf.setSort(TaoBaoUtil.SORT_PRICE_LOW_TO_HIGH);
            }
        } else {
            // 默认销量从高到低排序
            sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
        }
        SearchFilter sf = new SearchFilter();
        if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(order)) {
            if (Integer.parseInt(order) == 1) {
                sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
            } else if (Integer.parseInt(order) == 2) {
                sf.setSort(TaoBaoUtil.SORT_PRICE_HIGH_TO_LOW);
            } else if (Integer.parseInt(order) == 3) {
                sf.setSort(TaoBaoUtil.SORT_PRICE_LOW_TO_HIGH);
            }
        } else {
            // 默认销量从高到低排序
            sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
        }
        sf.setKey(name2);
        sf.setBaoYou(true);
        /* 起始价格 */
        Integer start_price = null;
        if (!StringUtil.isNullOrEmpty(startprice)) {
            start_price = Integer.parseInt(startprice);
            sf.setStartPrice(new BigDecimal(start_price));
        }
        sf.setKey(name2);
        sf.setBaoYou(true);
        /* 起始价格 */
        Integer start_price = null;
        if (!StringUtil.isNullOrEmpty(startprice)) {
            start_price = Integer.parseInt(startprice);
            sf.setStartPrice(new BigDecimal(start_price));
        }
        sf.setQuan(1);
        sf.setQuan(1);
        if (fastFilter != null && fastFilter.contains("shoptype")) {
            sf.setTmall(true);
        }
        if (fastFilter != null && fastFilter.contains("shoptype")) {
            sf.setTmall(true);
        }
        /* 结束价格 */
        Integer end_price = null;
        if (!StringUtil.isNullOrEmpty(endprice)) {
            end_price = Integer.parseInt(endprice);
            sf.setEndPrice(new BigDecimal(end_price));
        }
        sf.setPageSize(20);
        sf.setPage(page + 1);
        sf.setMaterialId("6707");
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        JSONArray array = new JSONArray();
        List<TaoBaoGoodsBrief> taobaoList = taoKeGoodsService.searchWuLiaoList(sf);
        BigDecimal proportion = manageService.getFanLiRate();
        for (TaoBaoGoodsBrief taoBaoGoodsBrief : taobaoList) {
            int biz30day = taoBaoGoodsBrief.getBiz30day();
            if (biz30day >= 10000) {
                double sales = biz30day;
                String salesCountMidea = String.format("%.1f", sales / 10000);
                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
            } else {
                taoBaoGoodsBrief.setSalesCount(biz30day + "");
            }
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
        }
        JSONObject data = new JSONObject();
        data.put("nav", new JSONArray());
        data.put("count", 1000);
        data.put("result", array);
        out.print(JsonUtil.loadTrueResult(data));
    }
        /* 结束价格 */
        Integer end_price = null;
        if (!StringUtil.isNullOrEmpty(endprice)) {
            end_price = Integer.parseInt(endprice);
            sf.setEndPrice(new BigDecimal(end_price));
        }
        sf.setPageSize(20);
        sf.setPage(page + 1);
        sf.setMaterialId("6707");
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        JSONArray array = new JSONArray();
        List<TaoBaoGoodsBrief> taobaoList = taoKeGoodsService.searchWuLiaoList(sf,acceptData.getSystem());
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        for (TaoBaoGoodsBrief taoBaoGoodsBrief : taobaoList) {
            int biz30day = taoBaoGoodsBrief.getBiz30day();
            if (biz30day >= 10000) {
                double sales = biz30day;
                String salesCountMidea = String.format("%.1f", sales / 10000);
                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
            } else {
                taoBaoGoodsBrief.setSalesCount(biz30day + "");
            }
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
        }
        JSONObject data = new JSONObject();
        data.put("nav", new JSONArray());
        data.put("count", 1000);
        data.put("result", array);
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 获取二级分类商品
     *
     * @param acceptData
     * @param page
     * @param scid
     * @param filter
     * @param order
     *            来源:【推荐:0 | 综合:4 、综合只看有券 1 、综合只看天猫 1 | 价格:低到高3 高到低2 | 销量:1】
     *            排序值:【销量由高到低: 1 ; 销量由低到高 5; 价格从高到低: 2 ; 价格从低到高:3 ; 推广量高到低:4 ;
     *            其他默认: 销量由高到低】
     *
     * @param startprice
     *            起始价格
     * @param endprice
     *            结束价格
     * @param fastFilter
     *            fastFilter 有券 [{"type":"quantype"}] 天猫商品 [{"type":"shoptype"}]
     * @param totalSales
     *            销量以上
     * @param out
     */
    @RequestMapping(value = "getsecondclassgoods", method = RequestMethod.POST)
    public void getSecondClassGoods(AcceptData acceptData, int page, long scid, String filter, String order,
            String startprice, String endprice, String fastFilter, Integer totalSales, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
    /**
     * 获取二级分类商品
     *
     * @param acceptData
     * @param page
     * @param scid
     * @param filter
     * @param order      来源:【推荐:0 | 综合:4 、综合只看有券 1 、综合只看天猫 1 | 价格:低到高3 高到低2 | 销量:1】
     *                   排序值:【销量由高到低: 1 ; 销量由低到高 5; 价格从高到低: 2 ; 价格从低到高:3 ; 推广量高到低:4 ;
     *                   其他默认: 销量由高到低】
     * @param startprice 起始价格
     * @param endprice   结束价格
     * @param fastFilter fastFilter 有券 [{"type":"quantype"}] 天猫商品 [{"type":"shoptype"}]
     * @param totalSales 销量以上
     * @param out
     */
    @RequestMapping(value = "getsecondclassgoods", method = RequestMethod.POST)
    public void getSecondClassGoods(AcceptData acceptData, int page, long scid, String filter, String order,
                                    String startprice, String endprice, String fastFilter, Integer totalSales, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages(), acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        try {
        try {
            GoodsSubClass goodsSubClass = goodsSubClassService.getSubClassByPrimaryKeyCache(scid);
            if (goodsSubClass == null) {
                out.print(JsonUtil.loadFalseResult("不存在该分类"));
                return;
            }
            GoodsSubClass goodsSubClass = goodsSubClassService.getSubClassByPrimaryKeyCache(scid);
            if (goodsSubClass == null) {
                out.print(JsonUtil.loadFalseResult("不存在该分类"));
                return;
            }
            if (page == 0) {
                // 统计点击量
                goodsSubClassService.countClick(acceptData, goodsSubClass);
            }
            if (page == 0) {
                // 统计点击量
                goodsSubClassService.countClick(acceptData, goodsSubClass);
            }
            SearchFilter sf = new SearchFilter();
            String catesId = "";
            // 查询是否有淘宝分类ID
            List<TaoBaoClass> tbClassList = taoBaoClassService.listBySystemSubCid(0, 10, goodsSubClass.getId());
            if (tbClassList != null && tbClassList.size() > 0)
                for (TaoBaoClass tbc : tbClassList) {
                    catesId += tbc.getCategoryId() + ",";
                }
            if (catesId.endsWith(","))
                catesId = catesId.substring(0, catesId.length() - 1);
            sf.setCateIds(catesId);
            if (!StringUtil.isNullOrEmpty(catesId))// 按分类名称搜索
            {
                String searchParam = goodsSubClass.getSearchJson();
                Gson gs = new Gson();
                SearchFilter searchfilter = gs.fromJson(searchParam, SearchFilter.class);
                searchfilter.setCateIds(catesId);
                searchfilter.setPage(page);
                searchfilter.setPageSize(20);
                if (Integer.parseInt(order) == 0)
                    searchfilter.setMaterialId("6707");
                taoKeGoodsService.setSearchFilter(searchfilter, filter, order, startprice, endprice, fastFilter,
                        totalSales);
                TaoBaoSearchResult searchResult = TaoKeApiUtil.searchWuLiao(searchfilter);
                long count = searchResult.getPageEntity().getTotalCount();
            SearchFilter sf = new SearchFilter();
            String catesId = "";
            // 查询是否有淘宝分类ID
            List<TaoBaoClass> tbClassList = taoBaoClassService.listBySystemSubCid(0, 10, goodsSubClass.getId());
            if (tbClassList != null && tbClassList.size() > 0)
                for (TaoBaoClass tbc : tbClassList) {
                    catesId += tbc.getCategoryId() + ",";
                }
            if (catesId.endsWith(","))
                catesId = catesId.substring(0, catesId.length() - 1);
            sf.setCateIds(catesId);
            if (!StringUtil.isNullOrEmpty(catesId))// 按分类名称搜索
            {
                String searchParam = goodsSubClass.getSearchJson();
                Gson gs = new Gson();
                SearchFilter searchfilter = gs.fromJson(searchParam, SearchFilter.class);
                searchfilter.setCateIds(catesId);
                searchfilter.setPage(page);
                searchfilter.setPageSize(20);
                if (Integer.parseInt(order) == 0)
                    searchfilter.setMaterialId("6707");
                taoKeGoodsService.setSearchFilter(searchfilter, filter, order, startprice, endprice, fastFilter,
                        totalSales);
                TaoBaoSearchResult searchResult = TaoKeApiUtil.searchWuLiao(searchfilter);
                long count = searchResult.getPageEntity().getTotalCount();
                JSONObject result = new JSONObject();
                JSONObject result = new JSONObject();
                BigDecimal rate = hongBaoManageService.getFanLiRate();
                BigDecimal rate = hongBaoManageService.getFanLiRate(acceptData.getSystem());
                List<TaoBaoGoodsBrief> resultGoodsList = searchResult.getTaoBaoGoodsBriefs();
                // 查询是否超过了最大的商品数
                if ((resultGoodsList == null || resultGoodsList.size() < 20)
                        && !StringUtil.isNullOrEmpty(goodsSubClass.getKey())) {
                    if (resultGoodsList == null)
                        resultGoodsList = new ArrayList<>();
                List<TaoBaoGoodsBrief> resultGoodsList = searchResult.getTaoBaoGoodsBriefs();
                // 查询是否超过了最大的商品数
                if ((resultGoodsList == null || resultGoodsList.size() < 20)
                        && !StringUtil.isNullOrEmpty(goodsSubClass.getKey())) {
                    if (resultGoodsList == null)
                        resultGoodsList = new ArrayList<>();
                    // 需要根据关键字查询
                    searchfilter.setCateIds(null);
                    searchfilter.setPage((int) (count % 20 == 0 ? count / 20 - 1 : count / 20));
                    searchfilter.setPageSize(20);
                    searchfilter.setKey(goodsSubClass.getKey());
                    TaoBaoSearchResult searchResult2 = TaoKeApiUtil.searchWuLiao(searchfilter);
                    if (searchResult2 != null) {
                        List<TaoBaoGoodsBrief> resultListTemp = searchResult2.getTaoBaoGoodsBriefs();
                        if (resultListTemp != null)
                            resultGoodsList.addAll(resultListTemp);
                    }
                }
                JSONArray array = new JSONArray();
                Gson gson2 = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                        .excludeFieldsWithoutExposeAnnotation().create();
                if (resultGoodsList != null)
                    for (TaoBaoGoodsBrief goods : resultGoodsList) {
                        array.add(gson2.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, rate + "", null)));
                    }
                result.put("result", array);
                result.put("count", result.optLong("count") + count);
                out.print(JsonUtil.loadTrueResult(result));
                return;
            } else {
                String searchParam = goodsSubClass.getSearchJson();
                Gson gs = new Gson();
                SearchFilter searchfilter = gs.fromJson(searchParam, SearchFilter.class);
                searchfilter.setCateIds(catesId);
                searchfilter.setPage(page);
                searchfilter.setPageSize(20);
                if (Integer.parseInt(order) == 0)
                    searchfilter.setMaterialId("6707");
                searchfilter.setKey(goodsSubClass.getKey());
                taoKeGoodsService.setSearchFilter(searchfilter, filter, order, startprice, endprice, fastFilter,
                        totalSales);
                JSONObject result = taoKeGoodsService.searchWuLiao(searchfilter);
                if (1 > 0) {
                    out.print(JsonUtil.loadTrueResult(result));
                    return;
                }
            }
            /* 搜索关键词 */
            String searchKey = goodsSubClass.getName();
            String key = goodsSubClass.getKey();
            if (key != null && !"".equals(key.trim())) {
                searchKey = key;
            }
                    // 需要根据关键字查询
                    searchfilter.setCateIds(null);
                    searchfilter.setPage((int) (count % 20 == 0 ? count / 20 - 1 : count / 20));
                    searchfilter.setPageSize(20);
                    searchfilter.setKey(goodsSubClass.getKey());
                    TaoBaoSearchResult searchResult2 = TaoKeApiUtil.searchWuLiao(searchfilter);
                    if (searchResult2 != null) {
                        List<TaoBaoGoodsBrief> resultListTemp = searchResult2.getTaoBaoGoodsBriefs();
                        if (resultListTemp != null)
                            resultGoodsList.addAll(resultListTemp);
                    }
                }
                JSONArray array = new JSONArray();
                Gson gson2 = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                        .excludeFieldsWithoutExposeAnnotation().create();
                if (resultGoodsList != null)
                    for (TaoBaoGoodsBrief goods : resultGoodsList) {
                        array.add(gson2.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, rate + "", null)));
                    }
                result.put("result", array);
                result.put("count", result.optLong("count") + count);
                out.print(JsonUtil.loadTrueResult(result));
                return;
            } else {
                String searchParam = goodsSubClass.getSearchJson();
                Gson gs = new Gson();
                SearchFilter searchfilter = gs.fromJson(searchParam, SearchFilter.class);
                searchfilter.setCateIds(catesId);
                searchfilter.setPage(page);
                searchfilter.setPageSize(20);
                if (Integer.parseInt(order) == 0)
                    searchfilter.setMaterialId("6707");
                searchfilter.setKey(goodsSubClass.getKey());
                taoKeGoodsService.setSearchFilter(searchfilter, filter, order, startprice, endprice, fastFilter,
                        totalSales);
                JSONObject result = taoKeGoodsService.searchWuLiao(searchfilter,acceptData.getSystem());
                if (1 > 0) {
                    out.print(JsonUtil.loadTrueResult(result));
                    return;
                }
            }
            /* 搜索关键词 */
            String searchKey = goodsSubClass.getName();
            String key = goodsSubClass.getKey();
            if (key != null && !"".equals(key.trim())) {
                searchKey = key;
            }
            /* 商品系统分类id */
            Long systemCid = null;
            GoodsClass rootClass = goodsSubClass.getRootClass();
            if (rootClass != null) {
                systemCid = rootClass.getId();
            }
            /* 商品系统分类id */
            Long systemCid = null;
            GoodsClass rootClass = goodsSubClass.getRootClass();
            if (rootClass != null) {
                systemCid = rootClass.getId();
            }
            // page从1开始
            page += 1;
            // 请求淘宝接口页码
            int pageNo = page;
            // page从1开始
            page += 1;
            // 请求淘宝接口页码
            int pageNo = page;
            int pageSize = Constant.PAGE_SIZE;
            int pageSize = Constant.PAGE_SIZE;
            /* 查询推荐模块 清空其他非必要筛选项和排序项 */
            if (!StringUtil.isNullOrEmpty(order) && Integer.parseInt(order) == 0) {
            /* 查询推荐模块 清空其他非必要筛选项和排序项 */
            if (!StringUtil.isNullOrEmpty(order) && Integer.parseInt(order) == 0) {
                // 分类关联标签id集合
                List<Long> listLabId = labelClassService.getRelationLabIds((page - 1) * pageSize, pageSize,
                        goodsSubClass.getId());
                // 分类关联标签id集合
                List<Long> listLabId = labelClassService.getRelationLabIds((page - 1) * pageSize, pageSize,
                        goodsSubClass.getId());
                /* 计算精选库数据 总页数 */
                long incount = taoKeGoodsService.countByQuality(searchKey, systemCid, listLabId);
                /* 计算精选库数据 总页数 */
                long incount = taoKeGoodsService.countByQuality(searchKey, systemCid, listLabId);
                int totalPage = (int) (incount % pageSize == 0 ? incount / pageSize : incount / pageSize + 1);
                int totalPage = (int) (incount % pageSize == 0 ? incount / pageSize : incount / pageSize + 1);
                pageNo = page - totalPage;
                pageNo = page - totalPage;
                /* 查询精选库数据 */
                if (pageNo <= 0) {
                /* 查询精选库数据 */
                if (pageNo <= 0) {
                    List<QualityFactory> listQuality = taoKeGoodsService.queryByQuality((page - 1) * pageSize, pageSize,
                            searchKey, systemCid, listLabId);
                    List<QualityFactory> listQuality = taoKeGoodsService.queryByQuality((page - 1) * pageSize, pageSize,
                            searchKey, systemCid, listLabId);
                    List<TaoBaoGoodsBrief> searchWuLiaoList = null;
                    List<TaoBaoGoodsBrief> searchWuLiaoList = null;
                    /* 精选库数据不足10条 */
                    if (listQuality != null && listQuality.size() != 0 && listQuality.size() < 10) {
                    /* 精选库数据不足10条 */
                    if (listQuality != null && listQuality.size() != 0 && listQuality.size() < 10) {
                        String searchParam = goodsSubClass.getSearchJson();
                        String searchParam = goodsSubClass.getSearchJson();
                        Gson gs = new Gson();
                        SearchFilter searchfilter = gs.fromJson(searchParam, SearchFilter.class);
                        Gson gs = new Gson();
                        SearchFilter searchfilter = gs.fromJson(searchParam, SearchFilter.class);
                        int quanfilter = searchfilter.getQuan();
                        if (quanfilter != 1) {
                            searchfilter.setQuan(1);
                        }
                        int quanfilter = searchfilter.getQuan();
                        if (quanfilter != 1) {
                            searchfilter.setQuan(1);
                        }
                        BigDecimal endPricefilter = searchfilter.getEndPrice();
                        if (endPricefilter == null) {
                            searchfilter.setEndPrice(new BigDecimal(220));
                        }
                        BigDecimal endPricefilter = searchfilter.getEndPrice();
                        if (endPricefilter == null) {
                            searchfilter.setEndPrice(new BigDecimal(220));
                        }
                        boolean includeGoodRate = searchfilter.isIncludeGoodRate();
                        if (!includeGoodRate) {
                            searchfilter.setIncludeGoodRate(true);
                        }
                        boolean includeGoodRate = searchfilter.isIncludeGoodRate();
                        if (!includeGoodRate) {
                            searchfilter.setIncludeGoodRate(true);
                        }
                        // 请求第一页数据
                        searchfilter.setPage(1);
                        searchfilter.setPageSize(pageSize);
                        searchfilter.setKey(searchKey);
                        searchfilter.setMaterialId("6707");
                        // 请求第一页数据
                        searchfilter.setPage(1);
                        searchfilter.setPageSize(pageSize);
                        searchfilter.setKey(searchKey);
                        searchfilter.setMaterialId("6707");
                        searchWuLiaoList = taoKeGoodsService.searchWuLiaoList(searchfilter);
                    }
                        searchWuLiaoList = taoKeGoodsService.searchWuLiaoList(searchfilter,acceptData.getSystem());
                    }
                    Map<String, String> map = manageService.convertMap();
                    Map<String, String> map = manageService.convertMap(acceptData.getSystem());
                    JSONObject data = taoKeGoodsService.listQualityGoods(listQuality, searchWuLiaoList, map);
                    JSONObject data = taoKeGoodsService.listQualityGoods(listQuality, searchWuLiaoList, map,acceptData.getSystem());
                    out.print(JsonUtil.loadTrueResult(data));
                    out.print(JsonUtil.loadTrueResult(data));
                    return;
                }
                    return;
                }
                if (pageNo > 0 && totalPage > 0) {
                    List<QualityFactory> list = taoKeGoodsService.queryByQuality((totalPage - 1) * pageSize, pageSize,
                            searchKey, systemCid, listLabId);
                if (pageNo > 0 && totalPage > 0) {
                    List<QualityFactory> list = taoKeGoodsService.queryByQuality((totalPage - 1) * pageSize, pageSize,
                            searchKey, systemCid, listLabId);
                    if (list != null && list.size() != 0 && list.size() < 10) {
                        // 页码+ 1 已请求一次淘宝接口
                        pageNo += 1;
                    }
                }
            }
                    if (list != null && list.size() != 0 && list.size() < 10) {
                        // 页码+ 1 已请求一次淘宝接口
                        pageNo += 1;
                    }
                }
            }
            /* 网络请求 */
            SearchFilter searchfilter = null;
            String searchParam = goodsSubClass.getSearchJson();
            /* 网络请求 */
            SearchFilter searchfilter = null;
            String searchParam = goodsSubClass.getSearchJson();
            if (!StringUtil.isNullOrEmpty(searchParam) && !StringUtil.isNullOrEmpty(order)
                    && Integer.parseInt(order) == 0) {
                // 推荐 使用子分类默认查询条件
                Gson gs = new Gson();
                searchfilter = gs.fromJson(searchParam, SearchFilter.class);
            if (!StringUtil.isNullOrEmpty(searchParam) && !StringUtil.isNullOrEmpty(order)
                    && Integer.parseInt(order) == 0) {
                // 推荐 使用子分类默认查询条件
                Gson gs = new Gson();
                searchfilter = gs.fromJson(searchParam, SearchFilter.class);
                int quanfilter = searchfilter.getQuan();
                if (quanfilter != 1) {
                    searchfilter.setQuan(1);
                }
                int quanfilter = searchfilter.getQuan();
                if (quanfilter != 1) {
                    searchfilter.setQuan(1);
                }
                BigDecimal endPricefilter = searchfilter.getEndPrice();
                if (endPricefilter == null) {
                    searchfilter.setEndPrice(new BigDecimal(220));
                }
                BigDecimal endPricefilter = searchfilter.getEndPrice();
                if (endPricefilter == null) {
                    searchfilter.setEndPrice(new BigDecimal(220));
                }
                boolean includeGoodRate = searchfilter.isIncludeGoodRate();
                if (!includeGoodRate) {
                    searchfilter.setIncludeGoodRate(true);
                }
                boolean includeGoodRate = searchfilter.isIncludeGoodRate();
                if (!includeGoodRate) {
                    searchfilter.setIncludeGoodRate(true);
                }
            } else {
                searchfilter = new SearchFilter();
                // 设置SearchFilter
                taoKeGoodsService.setSearchFilter(searchfilter, filter, order, startprice, endprice, fastFilter,
                        totalSales);
            } else {
                searchfilter = new SearchFilter();
                // 设置SearchFilter
                taoKeGoodsService.setSearchFilter(searchfilter, filter, order, startprice, endprice, fastFilter,
                        totalSales);
                // 用户未输入最高价格时 最高价格限制99999
                if (searchfilter.getEndPrice() == null) {
                    searchfilter.setEndPrice(new BigDecimal(99999));
                }
            }
                // 用户未输入最高价格时 最高价格限制99999
                if (searchfilter.getEndPrice() == null) {
                    searchfilter.setEndPrice(new BigDecimal(99999));
                }
            }
            searchfilter.setPage(pageNo);
            searchfilter.setPageSize(pageSize);
            searchfilter.setKey(searchKey);
            searchfilter.setPage(pageNo);
            searchfilter.setPageSize(pageSize);
            searchfilter.setKey(searchKey);
            if (!StringUtil.isNullOrEmpty(order) && Integer.parseInt(order) != 4) {
                searchfilter.setMaterialId("6707");
            }
            if (!StringUtil.isNullOrEmpty(order) && Integer.parseInt(order) != 4) {
                searchfilter.setMaterialId("6707");
            }
            // 查询物料接口
            JSONObject result = taoKeGoodsService.searchWuLiao(searchfilter);
            out.print(JsonUtil.loadTrueResult(result));
            // 查询物料接口
            JSONObject result = taoKeGoodsService.searchWuLiao(searchfilter,acceptData.getSystem());
            out.print(JsonUtil.loadTrueResult(result));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 分类下的精选商品
     */
    @RequestMapping("choiceGoods")
    public void choiceGoods(AcceptData acceptData, long gcid, int page, PrintWriter out) {
    /**
     * 分类下的精选商品
     */
    @RequestMapping("choiceGoods")
    public void choiceGoods(AcceptData acceptData, long gcid, int page, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages(), acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        GoodsClass goodsClass = goodsClassService.getGoodsClassCache(gcid);
        if (goodsClass == null) {
            out.print(JsonUtil.loadFalseResult("不存在该分类"));
            return;
        }
        GoodsClass goodsClass = goodsClassService.getGoodsClassCache(gcid);
        if (goodsClass == null) {
            out.print(JsonUtil.loadFalseResult("不存在该分类"));
            return;
        }
        if (page < 1)
            page = 1;
        if (page < 1)
            page = 1;
        int pageSize = Constant.PAGE_SIZE;
        int pageSize = Constant.PAGE_SIZE;
        List<QualityFactory> listQuery = qualityGoodsService.listQueryByClassId((page - 1) * pageSize, pageSize, gcid);
        // 总条数
        long counttotal = 5000;
        List<QualityFactory> listQuery = qualityGoodsService.listQueryByClassId((page - 1) * pageSize, pageSize, gcid);
        // 总条数
        long counttotal = 5000;
        // 精选库数据为空时,网络进行查询
        if (listQuery == null || listQuery.size() == 0 || listQuery.size() < 10) {
            long count = qualityGoodsService.countQueryClassId(gcid);
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            page = page - totalPage;
            if (page < 1)
                page = 1;
        // 精选库数据为空时,网络进行查询
        if (listQuery == null || listQuery.size() == 0 || listQuery.size() < 10) {
            long count = qualityGoodsService.countQueryClassId(gcid);
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            page = page - totalPage;
            if (page < 1)
                page = 1;
            // 淘宝类目id
            String taoBaoCatIds = taoBaoClassService.getTaoBaoCatIds(gcid);
            // 淘宝类目id
            String taoBaoCatIds = taoBaoClassService.getTaoBaoCatIds(gcid);
            SearchFilter filter = null;
            SearchFilter filter = null;
            String searchParam = goodsClass.getSearchParam();
            if (!StringUtil.isNullOrEmpty(searchParam)) {
                Gson gs = new Gson();
                filter = gs.fromJson(searchParam, SearchFilter.class);
            } else {
                filter = new SearchFilter();
            }
            String searchParam = goodsClass.getSearchParam();
            if (!StringUtil.isNullOrEmpty(searchParam)) {
                Gson gs = new Gson();
                filter = gs.fromJson(searchParam, SearchFilter.class);
            } else {
                filter = new SearchFilter();
            }
            filter.setMaterialId("6707");
            filter.setPage(page);
            filter.setPageSize(pageSize);
            filter.setCateIds(taoBaoCatIds);
            filter.setMaterialId("6707");
            filter.setPage(page);
            filter.setPageSize(pageSize);
            filter.setCateIds(taoBaoCatIds);
            JSONObject result = taoKeGoodsService.searchWuLiao(filter);
            out.print(JsonUtil.loadTrueResult(result));
            JSONObject result = taoKeGoodsService.searchWuLiao(filter,acceptData.getSystem());
            out.print(JsonUtil.loadTrueResult(result));
            return;
        }
            return;
        }
        // 精选库数据处理返回 前端
        JSONArray array = new JSONArray();
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        // 精选库数据处理返回 前端
        JSONArray array = new JSONArray();
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        BigDecimal proportion = manageService.getFanLiRate();
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        // 遍历列表数据
        for (QualityFactory selectionGoods : listQuery) {
        // 遍历列表数据
        for (QualityFactory selectionGoods : listQuery) {
            TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
            TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
            if (taoBaoGoodsBrief == null) {
                continue;
            }
            if (taoBaoGoodsBrief == null) {
                continue;
            }
            int biz30day = taoBaoGoodsBrief.getBiz30day();
            if (biz30day >= 10000) {
                double sales = biz30day;
                String salesCountMidea = String.format("%.1f", sales / 10000);
                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
            } else {
                taoBaoGoodsBrief.setSalesCount(biz30day + "");
            }
            int biz30day = taoBaoGoodsBrief.getBiz30day();
            if (biz30day >= 10000) {
                double sales = biz30day;
                String salesCountMidea = String.format("%.1f", sales / 10000);
                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
            } else {
                taoBaoGoodsBrief.setSalesCount(biz30day + "");
            }
            // 白底图测试
            // if
            // (!StringUtil.isNullOrEmpty(taoBaoGoodsBrief.getPictUrlWhite()))
            // taoBaoGoodsBrief.setPictUrl(taoBaoGoodsBrief.getPictUrlWhite());
            // 白底图测试
            // if
            // (!StringUtil.isNullOrEmpty(taoBaoGoodsBrief.getPictUrlWhite()))
            // taoBaoGoodsBrief.setPictUrl(taoBaoGoodsBrief.getPictUrlWhite());
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
        }
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
        }
        JSONObject data = new JSONObject();
        data.put("nav", null);
        data.put("count", counttotal);
        data.put("result", array);
        out.print(JsonUtil.loadTrueResult(data));
        JSONObject data = new JSONObject();
        data.put("nav", null);
        data.put("count", counttotal);
        data.put("result", array);
        out.print(JsonUtil.loadTrueResult(data));
    }
    }
    @RequestMapping("getCouponList")
    public void getCouponList(AcceptData acceptData, int page, HttpServletRequest request, PrintWriter out) {
        page = page > 0 ? page : 1;
        List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = taoBaoCouponService.getTaoBaoCouponList(page);
        BigDecimal proportion = manageService.getFanLiRate();
        JSONArray array = new JSONArray();
        TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra;
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
    @RequestMapping("getCouponList")
    public void getCouponList(AcceptData acceptData, int page, HttpServletRequest request, PrintWriter out) {
        page = page > 0 ? page : 1;
        List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = taoBaoCouponService.getTaoBaoCouponList(page);
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        JSONArray array = new JSONArray();
        TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra;
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
        for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
            taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "");
            array.add(gson.toJson(taoBaoGoodsBriefExtra));
        }
        int count = 10000;
        JSONObject data = new JSONObject();
        data.put("taoBaoCoupons", array);
        data.put("count", count);
        out.print(JsonUtil.loadTrueResult(data));
        for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
            taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "");
            array.add(gson.toJson(taoBaoGoodsBriefExtra));
        }
        int count = 10000;
        JSONObject data = new JSONObject();
        data.put("taoBaoCoupons", array);
        data.put("count", count);
        out.print(JsonUtil.loadTrueResult(data));
        try {
            monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, null));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
        try {
            monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, null));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 通过分类获取券
     *
     * @param acceptData
     * @param page
     * @param out
     */
    @RequestMapping("getCouponListByClass")
    public void getCouponListByClass(AcceptData acceptData, Long id, int page, PrintWriter out) {
    /**
     * 通过分类获取券
     *
     * @param acceptData
     * @param page
     * @param out
     */
    @RequestMapping("getCouponListByClass")
    public void getCouponListByClass(AcceptData acceptData, Long id, int page, PrintWriter out) {
        // SearchFilter sf = new SearchFilter();
        // sf.setQuan(1);
        // sf.setPage(page);
        // TaoKeApiUtil.getMaterialByMaterialId(3786, page, 20);
        if (id == null)
            return;
        page = page < 1 ? 1 : page;
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.couponByClass, id + "-" + page);
        String resultStr = "";
        // SearchFilter sf = new SearchFilter();
        // sf.setQuan(1);
        // sf.setPage(page);
        // TaoKeApiUtil.getMaterialByMaterialId(3786, page, 20);
        if (id == null)
            return;
        page = page < 1 ? 1 : page;
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.couponByClass, id + "-" + page);
        String resultStr = "";
        if (Constant.IS_OUTNET)
            resultStr = redisManager.getCommonString(key);
        if (!StringUtil.isNullOrEmpty(resultStr)) {
            out.print(resultStr);
            return;
        }
        if (Constant.IS_OUTNET)
            resultStr = redisManager.getCommonString(key);
        if (!StringUtil.isNullOrEmpty(resultStr)) {
            out.print(resultStr);
            return;
        }
        int meterialId = 0;
        Map<Long, Integer> paramMap = new HashMap<>();
        paramMap.put(10L, 3767);// 女装
        paramMap.put(11L, 3760);// 母婴
        paramMap.put(28L, 3764);// 男装
        paramMap.put(27L, 3758);// 家居家装
        paramMap.put(1L, 3759);// 家电数码
        paramMap.put(6L, 3765);// 内衣
        paramMap.put(30L, 3763);// 美妆
        int meterialId = 0;
        Map<Long, Integer> paramMap = new HashMap<>();
        paramMap.put(10L, 3767);// 女装
        paramMap.put(11L, 3760);// 母婴
        paramMap.put(28L, 3764);// 男装
        paramMap.put(27L, 3758);// 家居家装
        paramMap.put(1L, 3759);// 家电数码
        paramMap.put(6L, 3765);// 内衣
        paramMap.put(30L, 3763);// 美妆
        paramMap.put(31L, 3766);// 运动户外
        paramMap.put(31L, 3766);// 运动户外
        paramMap.put(32L, 3761);// 美食
        paramMap.put(32L, 3761);// 美食
        if (paramMap.get(id) != null)
            meterialId = paramMap.get(id);
        if (paramMap.get(id) != null)
            meterialId = paramMap.get(id);
        TaoBaoSearchResult result = null;
        TaoBaoSearchResult result = null;
        // 不生效
        meterialId = 0;
        if (meterialId > 0)
            result = TaoKeApiUtil.getMaterialByMaterialId(meterialId, page, 20);
        else {
            SearchFilter sf = new SearchFilter();
            sf.setPage(page);
            sf.setPageSize(20);
            sf.setQuan(1);
            sf.setKey(goodsClassService.getKeysById(id));
        // 不生效
        meterialId = 0;
        if (meterialId > 0)
            result = TaoKeApiUtil.getMaterialByMaterialId(meterialId, page, 20);
        else {
            SearchFilter sf = new SearchFilter();
            sf.setPage(page);
            sf.setPageSize(20);
            sf.setQuan(1);
            sf.setKey(goodsClassService.getKeysById(id));
            result = TaoKeApiUtil.searchWuLiao(sf);
            result = TaoKeApiUtil.searchWuLiao(sf);
        }
        List<TaoBaoSearchNav> navList = TaoBaoUtil.getBaseNav();
        if (result != null && result.getNavList() != null)
            navList.addAll(result.getNavList());
        }
        List<TaoBaoSearchNav> navList = TaoBaoUtil.getBaseNav();
        if (result != null && result.getNavList() != null)
            navList.addAll(result.getNavList());
        if (navList == null)
            navList = new ArrayList<>();
        if (navList == null)
            navList = new ArrayList<>();
        Gson gson = new GsonBuilder().create();
        JSONObject data = new JSONObject();
        data.put("nav", gson.toJson(navList));
        List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>();
        List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs();
        BigDecimal proportion = manageService.getFanLiRate();
        TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra;
        for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
            taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "");
            re.add(taoBaoGoodsBriefExtra);
        }
        Gson gson = new GsonBuilder().create();
        JSONObject data = new JSONObject();
        data.put("nav", gson.toJson(navList));
        List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>();
        List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs();
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra;
        for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
            taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "");
            re.add(taoBaoGoodsBriefExtra);
        }
        Gson gson2 = JsonUtil.getConvertBigDecimalToStringBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().create();
        data.put("result", gson2.toJson(re));
        data.put("count", result.getTaoBaoHead().getDocsfound());
        resultStr = JsonUtil.loadTrueResult(0, data);
        try {
            if (Constant.IS_OUTNET)
                redisManager.cacheCommonString(key, resultStr, 120);
        } catch (Exception e) {
        }
        Gson gson2 = JsonUtil.getConvertBigDecimalToStringBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().create();
        data.put("result", gson2.toJson(re));
        data.put("count", result.getTaoBaoHead().getDocsfound());
        resultStr = JsonUtil.loadTrueResult(0, data);
        try {
            if (Constant.IS_OUTNET)
                redisManager.cacheCommonString(key, resultStr, 120);
        } catch (Exception e) {
        }
        out.print(resultStr);
    }
        out.print(resultStr);
    }
    /**
     * 设置红包进去
     *
     * @param taoBaoCoupons
     */
    private void setTaoBaoCouponHongBao(List<TaoBaoCoupon> taoBaoCoupons) {
        if (taoBaoCoupons.size() > 0) {
            BigDecimal proportion = hongBaoManageService.getFanLiRate();
    /**
     * 设置红包进去
     *
     * @param taoBaoCoupons
     */
    private void setTaoBaoCouponHongBao(AcceptData acceptData, List<TaoBaoCoupon> taoBaoCoupons) {
        if (taoBaoCoupons.size() > 0) {
            BigDecimal proportion = hongBaoManageService.getFanLiRate(acceptData.getSystem());
            for (TaoBaoCoupon taoBaoCoupon : taoBaoCoupons) {
                BigDecimal hb = TaoBaoUtil.getCouponHongBaoInfo(taoBaoCoupon, proportion);
                taoBaoCoupon.setHongbao(hb);
            }
        }
    }
            for (TaoBaoCoupon taoBaoCoupon : taoBaoCoupons) {
                BigDecimal hb = TaoBaoUtil.getCouponHongBaoInfo(taoBaoCoupon, proportion);
                taoBaoCoupon.setHongbao(hb);
            }
        }
    }
    @RequestMapping(value = { "getcategory" }, method = { org.springframework.web.bind.annotation.RequestMethod.POST })
    public void getcategory(AcceptData acceptData, PrintWriter out) {
        try {
    @RequestMapping(value = {"getcategory"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST})
    public void getcategory(AcceptData acceptData, PrintWriter out) {
        try {
            boolean changePicture = false;
            String version = acceptData.getVersion();
            int tversion = Integer.parseInt(version);
            String platform = acceptData.getPlatform();
            if ("android".equalsIgnoreCase(platform) && tversion > 38) {
                changePicture = true;
            } else if (tversion > 47) {
                changePicture = true;
            }
            boolean changePicture = false;
            String version = acceptData.getVersion();
            int tversion = Integer.parseInt(version);
            String platform = acceptData.getPlatform();
            if ("android".equalsIgnoreCase(platform) && tversion > 38) {
                changePicture = true;
            } else if (tversion > 47) {
                changePicture = true;
            }
            List<Map<String, Object>> listCache = goodsClassService.getClassListAllCache(changePicture);
            if (listCache == null) {
                listCache = new ArrayList<Map<String, Object>>();
            }
            List<Map<String, Object>> listCache = goodsClassService.getClassListAllCache(changePicture);
            if (listCache == null) {
                listCache = new ArrayList<Map<String, Object>>();
            }
            JSONObject data = new JSONObject();
            data.put("categoryList", listCache);
            JSONObject data = new JSONObject();
            data.put("categoryList", listCache);
            out.print(JsonUtil.loadTrueResult(data));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("获取失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("获取失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/HelpController.java
@@ -126,7 +126,7 @@
        Collections.reverse(levelList);
        BigDecimal fanLiRate = orderHongBaoMoneyComputeService.getFanliRate(levelList.get(0), new Date());
        BigDecimal fanLiRate = orderHongBaoMoneyComputeService.getFanliRate(levelList.get(0), new Date(),acceptData.getSystem());
        moneyBigDecial = MoneyBigDecimalUtil.divUp(moneyBigDecial.multiply(new BigDecimal(100)), fanLiRate);
@@ -146,7 +146,7 @@
        // 计算二级外分红
        List<UserTeamRate> moreThan2LevelList = orderHongBaoMoneyComputeService
                .getTeamRewardMoreThan2LevelRates(levelList.get(0), bossList, date);
                .getTeamRewardMoreThan2LevelRates(levelList.get(0), bossList, date,acceptData.getSystem());
        if (moreThan2LevelList != null)
            for (UserTeamRate rate : moreThan2LevelList) {
                teamReward2Map.put(rate.getUid(), rate);
@@ -154,25 +154,25 @@
        // 计算一级奖金
        if (bossList.size() >= 1) {
            UserTeamRate rate = orderHongBaoMoneyComputeService.getTeamRewardRate(levelList.get(0), bossList, date, 1);
            UserTeamRate rate = orderHongBaoMoneyComputeService.getTeamRewardRate(levelList.get(0), bossList, date, 1,acceptData.getSystem());
            if (rate != null)
                teamRewardMap.put(rate.getUid(), rate);
        }
        // 计算二级奖金
        if (bossList.size() >= 2) {
            UserTeamRate rate = orderHongBaoMoneyComputeService.getTeamRewardRate(levelList.get(0), bossList, date, 2);
            UserTeamRate rate = orderHongBaoMoneyComputeService.getTeamRewardRate(levelList.get(0), bossList, date, 2,acceptData.getSystem());
            if (rate != null)
                teamRewardMap.put(rate.getUid(), rate);
        }
        // 计算分红
        rateList = orderHongBaoMoneyComputeService.getTeamDividentsRates(levelList.get(0), bossList, date);
        rateList = orderHongBaoMoneyComputeService.getTeamDividentsRates(levelList.get(0), bossList, date,acceptData.getSystem());
        if (rateList != null)
            for (UserTeamRate rate : rateList) {
                teamDividentsMap.put(rate.getUid(), rate);
            }
        BigDecimal fanliRate = orderHongBaoMoneyComputeService.getFanliRate(levelList.get(0), date);
        BigDecimal fanliRate = orderHongBaoMoneyComputeService.getFanliRate(levelList.get(0), date,acceptData.getSystem());
        List<String> resultList = new ArrayList<>();
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/HotSellController.java
@@ -120,7 +120,7 @@
            LogHelper.test("大淘客商品数据:" + detailList.size());
            List<TaoBaoGoodsBriefExtra> list = new ArrayList<TaoBaoGoodsBriefExtra>();
            BigDecimal proportion = hongBaoManageService.getFanLiRate();
            BigDecimal proportion = hongBaoManageService.getFanLiRate(acceptData.getSystem());
            if (detailList != null)
                for (DaTaoKeDetailV2 detail : detailList) {
                    goods = TaoBaoUtil.getTaoBaoGoodsBriefExtra(TaoBaoUtil.convert(detail), proportion.toString(),
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/PushController.java
@@ -114,7 +114,7 @@
    @RequestMapping(value = "callback", method = RequestMethod.POST)
    public void callback(AcceptData acceptData, String pushId, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("不存在该系统"));
            return;
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java
@@ -439,7 +439,7 @@
    public void getRecommendSpecial(AcceptData acceptData, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
@@ -485,7 +485,7 @@
    public void guessLike(AcceptData acceptData, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
@@ -505,7 +505,7 @@
            }
        }
        BigDecimal proportion = manageService.getFanLiRate();
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        JSONArray array = new JSONArray();
        TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra;
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
@@ -524,7 +524,7 @@
    public void getRecommendBanner(AcceptData acceptData, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        JSONObject json = new JSONObject();
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
@@ -592,7 +592,7 @@
            return;
        }
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
@@ -658,7 +658,7 @@
            Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
            JSONObject data = new JSONObject();
            TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(tb, configList.get(0));
            TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(tb, configList.get(0),acceptData.getSystem());
            if (!StringUtil.isNullOrEmpty(tb.getCouponLink()) && taoBaoGoodsBriefExtra.getTaoBaoQuanInfo() != null)
                taoBaoGoodsBriefExtra.getTaoBaoQuanInfo().setCouponLink(tb.getCouponLink());
            taoBaoGoodsBriefExtra.setAuctionUrl(tb.getAuctionUrl());
@@ -709,9 +709,9 @@
                            + taoBaoGoodsBriefExtra.getTaoBaoHongBaoInfo().getHongbao() + "元    "
                            + taoBaoGoodsBriefExtra.getTitle() + shareSinaContent);
            data.put("sharemoney", "分享奖金 ¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb) + "元");
            data.put("sharemoney", "分享奖金 ¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb,acceptData.getSystem()) + "元");
            data.put("shareHongBao", "¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb));
            data.put("shareHongBao", "¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb,acceptData.getSystem()));
            out.print(JsonUtil.loadTrueResult(data));
            final TaoBaoGoodsBrief tbb = tb;
@@ -746,7 +746,7 @@
            return;
        }
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
@@ -905,7 +905,7 @@
        goods.put("price", tb.getReservePrice().toString());
        goods.put("zkPrice", tb.getZkPrice().toString());
        BigDecimal proportion = manageService.getFanLiRate();
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        String hongBao = TaoBaoUtil.getGoodsHongBaoInfo(tb, proportion,false);
        goods.put("hongBao", hongBao);
@@ -919,7 +919,7 @@
        String jumpUrl = "https://item.taobao.com/item.htm?id=" + tb.getAuctionId();
        // 分享赚
        data.put("shareMoney", "¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb));
        data.put("shareMoney", "¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb,acceptData.getSystem()));
        // 判断收藏
        if (!StringUtil.isNullOrEmpty(uid)) {
@@ -1070,7 +1070,7 @@
    @RequestMapping(value = "getgoodsrecommend", method = RequestMethod.POST)
    public void getGoodsRecommend(final AcceptData acceptData, long id, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
@@ -1130,7 +1130,7 @@
        List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>();
        BigDecimal proportion = manageService.getFanLiRate();
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        if (recommendGoodsList != null)
            for (TaoBaoGoodsBrief taoBaoGoodsBrief : recommendGoodsList) {
                if (taoBaoGoodsBrief == null)
@@ -1198,7 +1198,7 @@
        }
        page = page + 1;
        BusinessSystem sys = businessSystemService.getBusinessSystem(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (sys == null) {
            out.print(JsonUtil.loadFalseResult(1, "不存在该系统"));
            return;
@@ -1232,7 +1232,7 @@
            Gson gson = gsonBuilder.create();
            if (list != null) {
                BigDecimal proportion = manageService.getFanLiRate();
                BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
                for (ScanHistoryV2 sh : list) {
                    TaoBaoGoodsBrief goods = TaoBaoUtil.convert(sh.getCommonGoods());
                    goods.setId(sh.getId());
@@ -1257,7 +1257,7 @@
    @RequestMapping(value = "deletescanhistory", method = RequestMethod.POST)
    public void deleteScanHistory(AcceptData acceptData, String type, String uid, String ids, PrintWriter out) {
        BusinessSystem sys = businessSystemService.getBusinessSystem(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (sys == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
@@ -1362,7 +1362,7 @@
                }
            }
            BigDecimal rate = hongBaoManageService.getFanLiRate();
            BigDecimal rate = hongBaoManageService.getFanLiRate(acceptData.getSystem());
            for (TaoBaoGoodsBrief goods : goodsList) {
                TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, rate + "", null);
                if (page < 3)
@@ -1413,7 +1413,7 @@
        // 从推荐来
        if (page <= 1) {
            array.clear();
            BigDecimal proportion = manageService.getFanLiRate();
            BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
            if (!StringUtil.isNullOrEmpty(imei) || !StringUtil.isNullOrEmpty(idfa)) {
                long startTime = java.lang.System.currentTimeMillis();
@@ -1473,7 +1473,7 @@
                    proportion.toString());
            array.addAll(localArray);
        } else {// 从精选库来
            BigDecimal proportion = manageService.getFanLiRate();
            BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
            array = qualityGoodsService.getRecommendToIndex((page - 1) * pageSize, pageSize, proportion.toString());
            if (array == null) {
                out.print(JsonUtil.loadFalseResult("没有更多了"));
@@ -1497,7 +1497,7 @@
    public void getRecommendHomeInfo(AcceptData acceptData, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
@@ -1731,7 +1731,7 @@
        if (array == null) {
            array = new JSONArray();
            BigDecimal proportion = manageService.getFanLiRate();
            BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
@@ -1813,7 +1813,7 @@
        }
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
@@ -1977,7 +1977,7 @@
        goodsJson.put("salesCount", TaoBaoUtil.getSaleCount(tb.getBiz30day()));
        // 分享赚
        BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb);
        BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb,acceptData.getSystem());
        data.put("shareMoney", "¥" + shareMoney);
        // 分享赚人提示
        List<ShamUser> listShareUser = new ArrayList<ShamUser>();
@@ -2069,9 +2069,9 @@
        // 红包
        if (hongBao == null) {
            BigDecimal proportion = manageService.getFanLiRate();
            BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
            if ("taolijin".equalsIgnoreCase(from))
                proportion = manageService.getTLJShareRate(System.currentTimeMillis());
                proportion = manageService.getTLJShareRate(System.currentTimeMillis(),acceptData.getSystem());
            hongBao = TaoBaoUtil.getGoodsHongBaoInfo(tb, proportion,false);
        }
        goodsJson.put("hongBao", hongBao);
@@ -2362,7 +2362,7 @@
                goodsList = new ArrayList<TaoBaoGoodsBrief>();
            }
            BigDecimal proportion = manageService.getFanLiRate();
            BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
            List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>();
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/S11Controller.java
@@ -99,7 +99,7 @@
        List<TaoBaoGoodsBrief> list = s11Service.getPreSaleGoodsCache(page);
        JSONArray array = new JSONArray();
        if (list != null) {
            BigDecimal proportion = hongBaoManageService.getFanLiRate();
            BigDecimal proportion = hongBaoManageService.getFanLiRate(acceptData.getSystem());
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
            boolean is11 = System.currentTimeMillis() > TimeUtil.convertToTimeTemp("2018-11-11", "yyyy-MM-dd") ? true
                    : false;
@@ -121,7 +121,7 @@
        List<TaoBaoGoodsBrief> list = s11Service.getPreSaleGoodsByType(key, page);
        JSONArray array = new JSONArray();
        if (list != null) {
            BigDecimal proportion = hongBaoManageService.getFanLiRate();
            BigDecimal proportion = hongBaoManageService.getFanLiRate(acceptData.getSystem());
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
            boolean is11 = System.currentTimeMillis() > TimeUtil.convertToTimeTemp("2018-11-11", "yyyy-MM-dd") ? true
                    : false;
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/SearchController.java
@@ -149,7 +149,7 @@
        data.put("nav", gson.toJson(navList));
        List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>();
        List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs();
        BigDecimal proportion = manageService.getFanLiRate();
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        for (TaoBaoGoodsBrief bf : taoBaoGoodsBriefs) {
            re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), ""));
        }
@@ -174,7 +174,7 @@
        String bid = getHistorySearchBid(acceptData);
        historySearchService.addHistorySearch(kw, bid);
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
@@ -195,7 +195,7 @@
                filter = fastFilter;
            }
        }
        JSONObject data = search(kw, page, filter, order, startprice, endprice);
        JSONObject data = search(acceptData, kw, page, filter, order, startprice, endprice);
        out.print(JsonUtil.loadTrueResult(data));
    }
@@ -203,11 +203,11 @@
    public JSONObject searchClass(AcceptData acceptData, String kw, int page, String filter, String order,
            String startprice, String endprice, String md5) {
        java.lang.System.out.println("searchClass");
        JSONObject data = search(kw, page, filter, order, startprice, endprice);
        JSONObject data = search(acceptData, kw, page, filter, order, startprice, endprice);
        return data;
    }
    private JSONObject search(String kw, int page, String filter, String order, String startprice, String endprice) {
    private JSONObject search(AcceptData acceptData, String kw, int page, String filter, String order, String startprice, String endprice) {
        page = page + 1;
        SearchFilter sf = new SearchFilter();
@@ -323,7 +323,7 @@
        int fq = sf.getQuan();
        int fh = sf.getHongbao();
        boolean ft = sf.isTmall();
        BigDecimal proportion = manageService.getFanLiRate();
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        if (fq == 0 && fh == 0 && !ft) {
            if (result != null && result.getTaoBaoGoodsBriefs() != null)
                for (TaoBaoGoodsBrief bf : result.getTaoBaoGoodsBriefs()) {
@@ -457,12 +457,12 @@
        JSONObject data = null;
        if (!recommend) {
            // 淘宝接口请求
            data = searchGoods(kw, page, filter, order, startprice, endprice,acceptData.getSystem());
            data = searchGoods(acceptData, kw, page, filter, order, startprice, endprice,acceptData.getSystem());
        } else {
            // 推荐:精选库
            // data = searchQualityGoods(kw, page, filter, order, startprice,
            // endprice);
            data = searchDaTaoKeGoods(kw, page, filter, order, startprice, endprice);
            data = searchDaTaoKeGoods(acceptData, kw, page, filter, order, startprice, endprice);
        }
        // 获取推荐词
@@ -474,7 +474,7 @@
                listRecommendWords = new ArrayList<String>();
            }
            List<TaoBaoShopVO> listShop =taoBaoShopService.getShopByKey(kw);
            List<TaoBaoShopVO> listShop =taoBaoShopService.getShopByKey(kw,acceptData.getSystem());
            if (listShop != null && listShop.size() > 0 && listShop.get(0).getListGoods() != null
                    && listShop.get(0).getListGoods().size() > 2) {
                data.put("shop", JsonUtil.getApiCommonGson().toJson(listShop.get(0)));
@@ -499,7 +499,7 @@
     * @param endprice
     * @return
     */
    private JSONObject searchGoods(String kw, int page, String filter, String order, String startprice,
    private JSONObject searchGoods(AcceptData acceptData, String kw, int page, String filter, String order, String startprice,
            String endprice,SystemEnum system) {
        page = page + 1;
@@ -682,7 +682,7 @@
        int fq = sf.getQuan();
        int fh = sf.getHongbao();
        boolean ft = sf.isTmall();
        BigDecimal proportion = manageService.getFanLiRate();
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        if (fq == 0 && fh == 0 && !ft) {
            if (result != null && taoBaoGoodsBriefs != null)
                for (TaoBaoGoodsBrief bf : taoBaoGoodsBriefs) {
@@ -735,7 +735,7 @@
     * @param endprice
     * @return
     */
    private JSONObject searchQualityGoods(String key, int page, String filter, String order, String startprice,
    private JSONObject searchQualityGoods(AcceptData acceptData, String key, int page, String filter, String order, String startprice,
                                          String endprice, SystemEnum system) {
        Integer hasQuan = null;
@@ -873,7 +873,7 @@
                userType, start_Price, end_Price, startTkRate, endTkRate, sort);
        List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>();
        BigDecimal proportion = manageService.getFanLiRate();
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        /* 遍历列表数据 */
        if (listQuery != null && listQuery.size() > 0) {
            for (QualityFactory selectionGoods : listQuery) {
@@ -942,7 +942,7 @@
        return data;
    }
    private JSONObject searchDaTaoKeGoods(String key, int page, String filter, String order, String startprice,
    private JSONObject searchDaTaoKeGoods(AcceptData acceptData, String key, int page, String filter, String order, String startprice,
            String endprice) {
        page = page + 1;
        int sort = DaTaoKeApiUtil.SORT_DEFAULT;
@@ -957,7 +957,7 @@
        }
        List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>();
        BigDecimal proportion = manageService.getFanLiRate();
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        DaTaoKeGoodsResult result = DaTaoKeApiUtil.search(key, null, null, null, page, 20, sort);
        if (result != null && result.getGoodsList() != null)
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java
@@ -262,7 +262,7 @@
            data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(),acceptData.getSystem()));
            // 添加分享记录
            BigDecimal rate = hongBaoManageService.getShareRate();
            BigDecimal rate = hongBaoManageService.getShareRate(acceptData.getSystem());
            BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
            data.put("shareMoney", "¥" + shareMoney.toString());
@@ -430,7 +430,7 @@
            data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(),system));
            // 添加分享记录
            BigDecimal rate = hongBaoManageService.getShareRate();
            BigDecimal rate = hongBaoManageService.getShareRate(system);
            BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
            data.put("shareMoney", "¥" + shareMoney.toString());
@@ -560,7 +560,7 @@
        }
        try {
            JSONObject data = userShareGoodsRecordService.getGoodsGroup(recordId);
            JSONObject data = userShareGoodsRecordService.getGoodsGroup(recordId,acceptData.getSystem());
            out.print(JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("加载失败"));
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/SystemClientController.java
@@ -64,7 +64,7 @@
    public void getSystemClientParams(AcceptData acceptData, Long uid, String mac, HttpServletRequest request,
            PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print("系统不存在");
            return;
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserAccountController.java
@@ -1,31 +1,12 @@
package com.yeshi.fanli.controller.client.v1;
import java.io.PrintWriter;
import java.math.BigDecimal;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import com.yeshi.fanli.util.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.encrypt.DESUtil;
import com.alipay.api.AlipayApiException;
import com.google.gson.Gson;
import com.yeshi.fanli.dto.wx.WXAccountInfoDTO;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.BindingAccount;
import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode;
import com.yeshi.fanli.entity.bus.user.*;
import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode.ForbiddenUserIdentifyCodeTypeEnum;
import com.yeshi.fanli.entity.bus.user.LoginResult;
import com.yeshi.fanli.entity.bus.user.SMSHistory;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord.ModifyTypeEnum;
import com.yeshi.fanli.entity.bus.user.WeiXinUser;
import com.yeshi.fanli.entity.push.DeviceActive;
import com.yeshi.fanli.entity.system.BusinessSystem;
import com.yeshi.fanli.entity.taobao.ClientTBPid;
@@ -35,1303 +16,1253 @@
import com.yeshi.fanli.exception.user.AlipayAccountException;
import com.yeshi.fanli.exception.user.AlipayTransferException;
import com.yeshi.fanli.exception.user.UserAccountException;
import com.yeshi.fanli.exception.user.UserInfoException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.config.BusinessSystemService;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.homemodule.HomeNavbarUserService;
import com.yeshi.fanli.service.inter.money.UserMoneyService;
import com.yeshi.fanli.service.inter.money.extract.BindingAccountService;
import com.yeshi.fanli.service.inter.money.extract.ExtractService;
import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
import com.yeshi.fanli.service.inter.order.LostOrderService;
import com.yeshi.fanli.service.inter.order.OrderService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.push.DeviceActiveService;
import com.yeshi.fanli.service.inter.push.DeviceTokenHWService;
import com.yeshi.fanli.service.inter.push.DeviceTokenOPPOService;
import com.yeshi.fanli.service.inter.push.DeviceTokenVIVOService;
import com.yeshi.fanli.service.inter.push.DeviceTokenXMService;
import com.yeshi.fanli.service.inter.push.*;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
import com.yeshi.fanli.service.inter.user.ForbiddenUserIdentifyCodeService;
import com.yeshi.fanli.service.inter.user.ShamUserService;
import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
import com.yeshi.fanli.service.inter.user.TBPidService;
import com.yeshi.fanli.service.inter.user.UserAccountBindingHistoryService;
import com.yeshi.fanli.service.inter.user.UserAccountService;
import com.yeshi.fanli.service.inter.user.UserInfoDeleteRecordService;
import com.yeshi.fanli.service.inter.user.UserInfoModifyRecordService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
import com.yeshi.fanli.service.inter.user.*;
import com.yeshi.fanli.util.*;
import com.yeshi.fanli.util.account.UserUtil;
import com.yeshi.fanli.util.wx.WXLoginUtil;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.encrypt.DESUtil;
import org.yeshi.utils.entity.ProxyIP;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.PrintWriter;
import java.math.BigDecimal;
/**
 * 账户系统
 *
 * @author Administrator
 *
 * @author Administrator
 */
@Controller
@RequestMapping("api/v1/user")
public class UserAccountController {
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private OrderService orderService;
    @Resource
    private HongBaoV2Service hongBaoV2Service;
    @Resource
    private HongBaoV2Service hongBaoV2Service;
    @Resource
    private BindingAccountService bindingAccountService;
    @Resource
    private BindingAccountService bindingAccountService;
    @Resource
    private ExtractService extractService;
    @Resource
    private ConfigService configService;
    @Resource
    private ConfigService configService;
    @Resource
    private BusinessSystemService businessSystemService;
    @Resource
    private BusinessSystemService businessSystemService;
    @Resource
    private ShamUserService shamUserService;
    @Resource
    private ThreeSaleSerivce threeSaleSerivce;
    @Resource
    private UserAccountService userAccountService;
    @Resource
    private LostOrderService lostOrderService;
    @Resource
    private RedisManager redisManager;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private TBPidService tbPidService;
    @Resource
    private UserAccountService userAccountService;
    @Resource
    private DeviceTokenHWService deviceTokenHWService;
    @Resource
    private RedisManager redisManager;
    @Resource
    private DeviceTokenOPPOService deviceTokenOPPOService;
    @Resource
    private TBPidService tbPidService;
    @Resource
    private DeviceTokenXMService deviceTokenXMService;
    @Resource
    private DeviceTokenHWService deviceTokenHWService;
    @Resource
    private DeviceTokenVIVOService deviceTokenVIVOService;
    @Resource
    private DeviceTokenOPPOService deviceTokenOPPOService;
    @Resource
    private TaoBaoUnionConfigService taoBaoUnionConfigService;
    @Resource
    private DeviceTokenXMService deviceTokenXMService;
    @Resource
    private SpreadUserImgService spreadUserImgService;
    @Resource
    private DeviceTokenVIVOService deviceTokenVIVOService;
    @Resource
    private UserShareGoodsRecordService userShareGoodsRecordService;
    @Resource
    private TaoBaoUnionConfigService taoBaoUnionConfigService;
    @Resource
    private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService;
    @Resource
    private SpreadUserImgService spreadUserImgService;
    @Resource
    private UserShareGoodsRecordService userShareGoodsRecordService;
    @Resource
    private UserMoneyService userMoneyService;
    @Resource
    private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService;
    @Resource
    private UserSystemCouponService userSystemCouponService;
    @Resource
    private HomeNavbarUserService homeNavbarUserService;
    @Resource
    private UserMoneyService userMoneyService;
    @Resource
    private UserAccountBindingHistoryService userAccountBindingHistoryService;
    @Resource
    private UserInfoModifyRecordService userInfoModifyRecordService;
    @Resource
    private HomeNavbarUserService homeNavbarUserService;
    @Resource
    private DeviceActiveService deviceActiveService;
    @Resource
    private UserInfoDeleteRecordService userInfoDeleteRecordService;
    private BusinessSystem getSystem(AcceptData acceptData) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages(), acceptData.getSystem());
        return system;
    }
    @Resource
    private UserTaoLiJinOriginService userTaoLiJinOriginService;
    /**
     * @param acceptData
     * @param code
     * @param vcode
     * @param phone
     * @param wxinstall
     * @param tbOpenid
     * @param tbNickName
     * @param tbPortrait
     * @param tbSession(淘宝session数据,加密)
     * @param out
     */
    @RequestMapping(value = "login")
    public void login(AcceptData acceptData, String code, String vcode, String phone, boolean wxinstall,
                      String tbOpenid, String tbNickName, String tbPortrait, String tbSession, int loginType, Boolean first,
                      HttpSession session, HttpServletRequest request, PrintWriter out) {
    @Resource
    private UserInfoModifyRecordService userInfoModifyRecordService;
        // 2.0以下版本不允许登录
        if (!VersionUtil.greaterThan_2_0(acceptData.getPlatform(), acceptData.getVersion())) {
            out.print("请升级到最新版本");
            return;
        }
    @Resource
    private DeviceActiveService deviceActiveService;
        BusinessSystem system =getSystem(acceptData);
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
    /**
     *
     * @param acceptData
     * @param code
     * @param vcode
     * @param phone
     * @param wxinstall
     * @param tbOpenid
     * @param tbNickName
     * @param tbPortrait
     * @param tbSession(淘宝session数据,加密)
     * @param out
     */
    @RequestMapping(value = "login")
    public void login(AcceptData acceptData, String code, String vcode, String phone, boolean wxinstall,
            String tbOpenid, String tbNickName, String tbPortrait, String tbSession, int loginType, Boolean first,
            HttpSession session, HttpServletRequest request, PrintWriter out) {
        if (loginType == 3 && !Constant.IS_TEST)// 验证短信验证码
        {
            // 苹果应用商店上线测试号码
            if ("17316780233".equalsIgnoreCase(phone) && "258168".equalsIgnoreCase(vcode)) {
                ;
            } else {
                String oldVcode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_LOGIN);
                if (StringUtil.isNullOrEmpty(oldVcode) || !oldVcode.equalsIgnoreCase(vcode)) {
                    out.print(JsonUtil.loadFalseResult(90001, "验证码错误"));
                    return;
                }
            }
        // 2.0以下版本不允许登录
        if (!VersionUtil.greaterThan_2_0(acceptData.getPlatform(), acceptData.getVersion())) {
            out.print("请升级到最新版本");
            return;
        }
            redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_LOGIN);
        }
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        UserInfo tbUserInfo = new UserInfo();
        if (!StringUtil.isNullOrEmpty(tbSession)) {
            try {
                tbSession = DESUtil.decode(tbSession.replace("\n", ""), StringUtil.getBase64String("YeShiFANLI889*+"),
                        StringUtil.getBase64String("*M#34f?,"));
            } catch (Exception e) {
                e.printStackTrace();
            }
            JSONObject tbs = JSONObject.fromObject(tbSession);
            tbOpenid = tbs.optString("openId");
            tbNickName = tbs.optString("nick");
            tbPortrait = tbs.optString("avatarUrl");
            // 淘宝ID
            tbUserInfo.setTaoBaoUid(tbs.optString("taobao_user_id"));
        }
        if (loginType == 3 && !Constant.IS_TEST)// 验证短信验证码
        {
            // 苹果应用商店上线测试号码
            if ("17316780233".equalsIgnoreCase(phone) && "258168".equalsIgnoreCase(vcode)) {
                ;
            } else {
                String oldVcode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_LOGIN);
                if (StringUtil.isNullOrEmpty(oldVcode) || !oldVcode.equalsIgnoreCase(vcode)) {
                    out.print(JsonUtil.loadFalseResult(90001, "验证码错误"));
                    return;
                }
            }
        tbUserInfo.setOpenid(tbOpenid);
        tbUserInfo.setTbName(tbNickName);
        tbUserInfo.setTbPic(tbPortrait);
            redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_LOGIN);
        }
        try {
            LoginResult result = userAccountService.login(request, acceptData, first, system.getAppid(), code, phone,
                    tbUserInfo, wxinstall, loginType);
            if (result == null)
                LogHelper.error("login-result为空值");
        UserInfo tbUserInfo = new UserInfo();
        if (!StringUtil.isNullOrEmpty(tbSession)) {
            try {
                tbSession = DESUtil.decode(tbSession.replace("\n", ""), StringUtil.getBase64String("YeShiFANLI889*+"),
                        StringUtil.getBase64String("*M#34f?,"));
            } catch (Exception e) {
                e.printStackTrace();
            }
            JSONObject tbs = JSONObject.fromObject(tbSession);
            tbOpenid = tbs.optString("openId");
            tbNickName = tbs.optString("nick");
            tbPortrait = tbs.optString("avatarUrl");
            // 淘宝ID
            tbUserInfo.setTaoBaoUid(tbs.optString("taobao_user_id"));
        }
            // if (result.getUser() != null)
            // userAccountService.clearUserPortrait(result.getUser().getId());
        tbUserInfo.setOpenid(tbOpenid);
        tbUserInfo.setTbName(tbNickName);
        tbUserInfo.setTbPic(tbPortrait);
            JSONObject data = new JSONObject();
            data.put("user", GsonUtil.toJsonExpose(UserUtil.filterForClientUser(result.getUser())));
            if (result.getType() == LoginResult.TYPE_CONNECT) {
                data.put("mainUser", GsonUtil.toJsonExpose(UserUtil.filterForClientUser(result.getMainUser())));
                data.put("lessUser", GsonUtil.toJsonExpose(UserUtil.filterForClientUser(result.getLessUser())));
            }
            JSONObject root = new JSONObject();
            root.put("type", result.getType());
            root.put("data", data);
            out.print(JsonUtil.loadTrueResult(root));
        try {
            LoginResult result = userAccountService.login(request, acceptData, first, system.getAppid(), code, phone,
                    tbUserInfo, wxinstall, loginType);
            if (result == null)
                LogHelper.error("login-result为空值");
            final UserInfo uuser = result.getUser();
            ThreadUtil.run(new Runnable() {
                public void run() {
                    try {
                        // 绑定oppo,vivo推送
                        DeviceActive active = deviceActiveService.getFirstActiveInfo(acceptData.getDevice());
                        if (active != null) {
                            deviceTokenOPPOService.bindUid(uuser.getId(), active.getId());
                            deviceTokenVIVOService.bindUid(uuser.getId(), active.getId());
                            deviceTokenXMService.bindUid(active.getId(), uuser.getId());
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
            // if (result.getUser() != null)
            // userAccountService.clearUserPortrait(result.getUser().getId());
        } catch (UserAccountException e) {
            try {
                LogHelper.error("登录出错:" + e.getCode() + "-" + e.getMessage());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
            JSONObject data = new JSONObject();
            data.put("user", GsonUtil.toJsonExpose(UserUtil.filterForClientUser(result.getUser())));
            if (result.getType() == LoginResult.TYPE_CONNECT) {
                data.put("mainUser", GsonUtil.toJsonExpose(UserUtil.filterForClientUser(result.getMainUser())));
                data.put("lessUser", GsonUtil.toJsonExpose(UserUtil.filterForClientUser(result.getLessUser())));
            }
            JSONObject root = new JSONObject();
            root.put("type", result.getType());
            root.put("data", data);
            out.print(JsonUtil.loadTrueResult(root));
    }
            final UserInfo uuser = result.getUser();
            ThreadUtil.run(new Runnable() {
                public void run() {
                    try {
                        // 绑定oppo,vivo推送
                        DeviceActive active = deviceActiveService.getFirstActiveInfo(acceptData.getDevice());
                        if (active != null) {
                            deviceTokenOPPOService.bindUid(uuser.getId(), active.getId());
                            deviceTokenVIVOService.bindUid(uuser.getId(), active.getId());
                            deviceTokenXMService.bindUid(active.getId(), uuser.getId());
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
    /**
     * 账号注册
     *
     * @param acceptData
     * @param tbOpenid
     * @param tbNickName
     * @param tbPortrait
     * @param vcode
     * @param phone
     * @param session
     * @param out
     */
    @RequestMapping(value = "register")
    public void register(AcceptData acceptData, String tbOpenid, String tbNickName, String tbPortrait, String vcode,
                         String phone, HttpServletRequest request, HttpSession session, PrintWriter out) {
        // 2.0以下版本不允许登录
        if (!VersionUtil.greaterThan_2_0(acceptData.getPlatform(), acceptData.getVersion())) {
            out.print("请升级到最新版本");
            return;
        }
        } catch (UserAccountException e) {
            try {
                LogHelper.error("登录出错:" + e.getCode() + "-" + e.getMessage());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
        BusinessSystem system = getSystem(acceptData);
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
    }
        if (!StringUtil.isNullOrEmpty(phone))// 验证短信验证码
        {
            String oldVcode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_LOGIN);
            if (StringUtil.isNullOrEmpty(oldVcode) || !oldVcode.equalsIgnoreCase(vcode)) {
                out.print(JsonUtil.loadFalseResult(90001, "验证码错误"));
                return;
            }
    /**
     * 账号注册
     *
     * @param acceptData
     * @param tbOpenid
     * @param tbNickName
     * @param tbPortrait
     * @param vcode
     * @param phone
     * @param session
     * @param out
     */
    @RequestMapping(value = "register")
    public void register(AcceptData acceptData, String tbOpenid, String tbNickName, String tbPortrait, String vcode,
            String phone, HttpServletRequest request, HttpSession session, PrintWriter out) {
        // 2.0以下版本不允许登录
        if (!VersionUtil.greaterThan_2_0(acceptData.getPlatform(), acceptData.getVersion())) {
            out.print("请升级到最新版本");
            return;
        }
            redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_LOGIN);
        }
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        if (StringUtil.isNullOrEmpty(phone) && StringUtil.isNullOrEmpty(tbOpenid)) {
            out.print(JsonUtil.loadFalseResult(5, "请上传注册信息"));
            return;
        }
        if (!StringUtil.isNullOrEmpty(phone))// 验证短信验证码
        {
            String oldVcode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_LOGIN);
            if (StringUtil.isNullOrEmpty(oldVcode) || !oldVcode.equalsIgnoreCase(vcode)) {
                out.print(JsonUtil.loadFalseResult(90001, "验证码错误"));
                return;
            }
        UserInfo user = new UserInfo();
        user.setOpenid(tbOpenid);
        user.setTbName(tbNickName);
        user.setTbPic(tbPortrait);
            redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_LOGIN);
        }
        user.setNickName(tbNickName);
        user.setPortrait(tbPortrait);
        if (StringUtil.isNullOrEmpty(phone) && StringUtil.isNullOrEmpty(tbOpenid)) {
            out.print(JsonUtil.loadFalseResult(5, "请上传注册信息"));
            return;
        }
        user.setPhone(phone);
        user.setAppId(system.getAppid());
        user.setLastLoginIp(request.getRemoteHost());
        user.setLastLoginTime(java.lang.System.currentTimeMillis());
        if (!StringUtil.isNullOrEmpty(phone))
            user.setLoginType(3);
        else
            user.setLoginType(1);
        try {
            userAccountService.register(user);
            user = userInfoService.getUserByIdWithMybatis(user.getId());
            JSONObject data = new JSONObject();
            data.put("user", GsonUtil.toJsonExpose(UserUtil.filterForClientUser(user)));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
    }
        UserInfo user = new UserInfo();
        user.setOpenid(tbOpenid);
        user.setTbName(tbNickName);
        user.setTbPic(tbPortrait);
    /**
     * 获取用户ID
     *
     * @param acceptData
     * @param code
     * @param tbOpenid
     * @param phone
     * @param out
     */
    @RequestMapping(value = "getuid")
    public void getUid(AcceptData acceptData, String code, String tbOpenid, String phone, PrintWriter out) {
        BusinessSystem system = getSystem(acceptData);
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        UserInfo user = null;
        if (!StringUtil.isNullOrEmpty(code)) {
            WXAccountInfoDTO accountInfo = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
        user.setNickName(tbNickName);
        user.setPortrait(tbPortrait);
            WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, accountInfo.getAppId(),
                    accountInfo.getAppSecret());
            if (weiXinUser == null) {
                out.print(JsonUtil.loadFalseResult(1, "获取微信用户信息失败"));
                return;
            }
            try {
                user = userAccountService.getUserInfoByWXUnionId(SystemInfoUtil.getSystem(acceptData), weiXinUser.getUnionid());
            } catch (UserAccountException e) {
                try {
                    LogHelper.errorDetailInfo(e, null, "获取用户信息出错");
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        } else if (!StringUtil.isNullOrEmpty(tbOpenid)) {
            try {
                user = userAccountService.getUserInfoByTaoBaoOpenId(SystemInfoUtil.getSystem(acceptData), tbOpenid);
            } catch (UserAccountException e) {
                try {
                    LogHelper.errorDetailInfo(e);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        } else if (!StringUtil.isNullOrEmpty(phone)) {
            try {
                user = userAccountService.getUserInfoByPhone(SystemInfoUtil.getSystem(acceptData), phone);
            } catch (UserAccountException e) {
                try {
                    LogHelper.errorDetailInfo(e);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        }
        user.setPhone(phone);
        user.setAppId(system.getAppid());
        user.setLastLoginIp(request.getRemoteHost());
        user.setLastLoginTime(java.lang.System.currentTimeMillis());
        if (!StringUtil.isNullOrEmpty(phone))
            user.setLoginType(3);
        else
            user.setLoginType(1);
        try {
            userAccountService.register(user);
            user = userInfoService.getUserByIdWithMybatis(user.getId());
            JSONObject data = new JSONObject();
            data.put("user", GsonUtil.toJsonExpose(UserUtil.filterForClientUser(user)));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
    }
        if (user == null) {
            out.print(JsonUtil.loadFalseResult(2, "用户尚未绑定"));
            return;
        } else {
            JSONObject data = new JSONObject();
            data.put("uid", user.getId());
            out.print(JsonUtil.loadTrueResult(data));
            return;
        }
    }
    /**
     * 获取用户ID
     *
     * @param acceptData
     * @param code
     * @param tbOpenid
     * @param phone
     * @param out
     */
    @RequestMapping(value = "getuid")
    public void getUid(AcceptData acceptData, String code, String tbOpenid, String phone, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        UserInfo user = null;
        if (!StringUtil.isNullOrEmpty(code)) {
            WXAccountInfoDTO accountInfo = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
    /**
     * 绑定电话号码
     *
     * @param acceptData
     * @param vcode
     * @param phone
     * @param out
     */
    @RequestMapping(value = "bindPhone")
    public void bindPhone(AcceptData acceptData, Long uid, String vcode, String phone, PrintWriter out) {
        BusinessSystem system = getSystem(acceptData);
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
            WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, accountInfo.getAppId(),
                    accountInfo.getAppSecret());
            if (weiXinUser == null) {
                out.print(JsonUtil.loadFalseResult(1, "获取微信用户信息失败"));
                return;
            }
            try {
                user = userAccountService.getUserInfoByWXUnionId(SystemInfoUtil.getSystem(acceptData), weiXinUser.getUnionid());
            } catch (UserAccountException e) {
                try {
                    LogHelper.errorDetailInfo(e, null, "获取用户信息出错");
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        } else if (!StringUtil.isNullOrEmpty(tbOpenid)) {
            try {
                user = userAccountService.getUserInfoByTaoBaoOpenId(SystemInfoUtil.getSystem(acceptData), tbOpenid);
            } catch (UserAccountException e) {
                try {
                    LogHelper.errorDetailInfo(e);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        } else if (!StringUtil.isNullOrEmpty(phone)) {
            try {
                user = userAccountService.getUserInfoByPhone(SystemInfoUtil.getSystem(acceptData), phone);
            } catch (UserAccountException e) {
                try {
                    LogHelper.errorDetailInfo(e);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        }
        if (StringUtil.isNullOrEmpty(vcode)) {
            out.print(JsonUtil.loadFalseResult(3, "请上传验证码"));
            return;
        }
        if (user == null) {
            out.print(JsonUtil.loadFalseResult(2, "用户尚未绑定"));
            return;
        } else {
            JSONObject data = new JSONObject();
            data.put("uid", user.getId());
            out.print(JsonUtil.loadTrueResult(data));
            return;
        }
    }
        if (StringUtil.isNullOrEmpty(phone)) {
            out.print(JsonUtil.loadFalseResult(3, "请上传电话号码"));
            return;
        }
    /**
     * 绑定电话号码
     *
     * @param acceptData
     * @param vcode
     * @param phone
     * @param out
     */
    @RequestMapping(value = "bindPhone")
    public void bindPhone(AcceptData acceptData, Long uid, String vcode, String phone, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        String oldVCode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_LOGIN);
        if (StringUtil.isNullOrEmpty(vcode)) {
            out.print(JsonUtil.loadFalseResult(3, "请上传验证码"));
            return;
        }
        if (Constant.IS_OUTNET) {
            if (!vcode.equalsIgnoreCase(oldVCode)) {
                out.print(JsonUtil.loadFalseResult(90001, "验证码错误"));
                return;
            }
            redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_LOGIN);
        }
        try {
            userAccountService.bindPhone(uid, phone);
            UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
            // 判断电话号码是否已经封禁
            ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
                    .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, phone);
            if (ic != null && ic.getEffective() != null && ic.getEffective()) {
                out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
                // 封禁用户
                // 封禁绑定的正常用户
                if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
                    userAccountService.forbiddenUser(uid, "封禁:绑定被封禁的电话号码");
                }
                return;
            }
        if (StringUtil.isNullOrEmpty(phone)) {
            out.print(JsonUtil.loadFalseResult(3, "请上传电话号码"));
            return;
        }
            JSONObject data = new JSONObject();
            data.put("user", UserUtil.filterForClientUser(user));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
        String oldVCode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_LOGIN);
    }
        if (Constant.IS_OUTNET) {
            if (!vcode.equalsIgnoreCase(oldVCode)) {
                out.print(JsonUtil.loadFalseResult(90001, "验证码错误"));
                return;
            }
            redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_LOGIN);
        }
        try {
            userAccountService.bindPhone(uid, phone);
            UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
            // 判断电话号码是否已经封禁
            ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
                    .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, phone);
            if (ic != null && ic.getEffective() != null && ic.getEffective()) {
                out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
                // 封禁用户
                // 封禁绑定的正常用户
                if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
                    userAccountService.forbiddenUser(uid, "封禁:绑定被封禁的电话号码");
                }
                return;
            }
    /**
     * 解绑电话号码
     *
     * @param acceptData
     * @param uid
     * @param phone
     * @param out
     */
    @RequestMapping(value = "unBindPhone")
    public void unBindPhone(AcceptData acceptData, Long uid, String phone, PrintWriter out) {
        BusinessSystem system = getSystem(acceptData);
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
            JSONObject data = new JSONObject();
            data.put("user", UserUtil.filterForClientUser(user));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
        if (StringUtil.isNullOrEmpty(phone)) {
            out.print(JsonUtil.loadFalseResult(3, "请上传电话号码"));
            return;
        }
    }
        try {
            userAccountService.unBindPhone(uid, phone);
            out.print(JsonUtil.loadTrueResult("解绑成功"));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
    /**
     * 解绑电话号码
     *
     * @param acceptData
     * @param uid
     * @param phone
     * @param out
     */
    @RequestMapping(value = "unBindPhone")
    public void unBindPhone(AcceptData acceptData, Long uid, String phone, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
    }
        if (StringUtil.isNullOrEmpty(phone)) {
            out.print(JsonUtil.loadFalseResult(3, "请上传电话号码"));
            return;
        }
    /**
     * 绑定淘宝
     *
     * @param acceptData
     * @param uid
     * @param tbOpenid
     * @param tbNickName
     * @param tbPortrait
     * @param tbSession  -淘宝授权session
     * @param out
     */
        try {
            userAccountService.unBindPhone(uid, phone);
            out.print(JsonUtil.loadTrueResult("解绑成功"));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
    @RequestMapping(value = "bindTaoBao")
    public void bindTaoBao(AcceptData acceptData, Long uid, String tbOpenid, String tbNickName, String tbPortrait,
                           String tbSession, PrintWriter out) {
        BusinessSystem system = getSystem(acceptData);
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
    }
        String taoBaoUid = "";
    /**
     * 绑定淘宝
     *
     * @param acceptData
     * @param uid
     * @param tbOpenid
     * @param tbNickName
     * @param tbPortrait
     * @param tbSession
     *            -淘宝授权session
     * @param out
     */
        if (!StringUtil.isNullOrEmpty(tbSession)) {
            try {
                tbSession = DESUtil.decode(tbSession.replace("\n", ""), StringUtil.getBase64String("YeShiFANLI889*+"),
                        StringUtil.getBase64String("*M#34f?,"));
            } catch (Exception e) {
                e.printStackTrace();
            }
            JSONObject session = JSONObject.fromObject(tbSession);
            tbOpenid = session.optString("openId");
            tbNickName = session.optString("nick");
            tbPortrait = session.optString("avatarUrl");
            taoBaoUid = session.optString("taobao_user_id");
        }
    @RequestMapping(value = "bindTaoBao")
    public void bindTaoBao(AcceptData acceptData, Long uid, String tbOpenid, String tbNickName, String tbPortrait,
            String tbSession, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        try {
            userAccountService.bindTaoBao(uid, tbOpenid, tbNickName, tbPortrait);
            UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        String taoBaoUid = "";
            // 判断taoBaoUid是否已经封禁
            if (!StringUtil.isNullOrEmpty(taoBaoUid)) {
                ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
                        .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.taobaoUid, taoBaoUid);
                if (ic != null && ic.getEffective() != null && ic.getEffective()) {
                    out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER,
                            Constant.FORBIDDEN_USER_REASON_DESC));
                    // 封禁用户
                    // 封禁绑定的正常用户
                    if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
                        userAccountService.forbiddenUser(uid, "封禁:绑定被封禁的淘宝号");
                    }
                    return;
                }
            }
        if (!StringUtil.isNullOrEmpty(tbSession)) {
            try {
                tbSession = DESUtil.decode(tbSession.replace("\n", ""), StringUtil.getBase64String("YeShiFANLI889*+"),
                        StringUtil.getBase64String("*M#34f?,"));
            } catch (Exception e) {
                e.printStackTrace();
            }
            JSONObject session = JSONObject.fromObject(tbSession);
            tbOpenid = session.optString("openId");
            tbNickName = session.optString("nick");
            tbPortrait = session.optString("avatarUrl");
            taoBaoUid = session.optString("taobao_user_id");
        }
            JSONObject data = new JSONObject();
            data.put("user", UserUtil.filterForClientUser(user));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
    }
        try {
            userAccountService.bindTaoBao(uid, tbOpenid, tbNickName, tbPortrait);
            UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
    /**
     * 解绑淘宝
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "unBindTaoBao")
    public void unBindTaoBao(AcceptData acceptData, Long uid, PrintWriter out) {
        BusinessSystem system = getSystem(acceptData);
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
            // 判断taoBaoUid是否已经封禁
            if (!StringUtil.isNullOrEmpty(taoBaoUid)) {
                ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
                        .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.taobaoUid, taoBaoUid);
                if (ic != null && ic.getEffective() != null && ic.getEffective()) {
                    out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER,
                            Constant.FORBIDDEN_USER_REASON_DESC));
                    // 封禁用户
                    // 封禁绑定的正常用户
                    if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
                        userAccountService.forbiddenUser(uid, "封禁:绑定被封禁的淘宝号");
                    }
                    return;
                }
            }
        try {
            userAccountService.unBindTaoBao(uid);
            out.print(JsonUtil.loadTrueResult("解绑成功"));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
    }
            JSONObject data = new JSONObject();
            data.put("user", UserUtil.filterForClientUser(user));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
    }
    /**
     * 更改微信
     *
     * @param acceptData
     * @param uid
     * @param code
     * @param out
     */
    @RequestMapping(value = "changeWX")
    public void changeWX(AcceptData acceptData, Long uid, String code, PrintWriter out) {
        BusinessSystem system = getSystem(acceptData);
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
    /**
     * 解绑淘宝
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "unBindTaoBao")
    public void unBindTaoBao(AcceptData acceptData, Long uid, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        if (StringUtil.isNullOrEmpty(code)) {
            out.print(JsonUtil.loadFalseResult(3, "请上传code"));
            return;
        }
        try {
            userAccountService.unBindTaoBao(uid);
            out.print(JsonUtil.loadTrueResult("解绑成功"));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
    }
        try {
            userAccountService.changeWXBind(acceptData, uid, code);
            UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
            // 判断taoBaoUid是否已经封禁
            ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
                    .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.wxUnionId, user.getWxUnionId());
            if (ic != null && ic.getEffective() != null && ic.getEffective()) {
                out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
                // 封禁用户
                // 封禁绑定的正常用户
                if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
                    userAccountService.forbiddenUser(uid, "封禁:绑定被封禁的微信号");
                }
                return;
            }
    /**
     * 更改微信
     *
     * @param acceptData
     * @param uid
     * @param code
     * @param out
     */
    @RequestMapping(value = "changeWX")
    public void changeWX(AcceptData acceptData, Long uid, String code, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
            JSONObject data = new JSONObject();
            data.put("user", UserUtil.filterForClientUser(user));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
    }
        if (StringUtil.isNullOrEmpty(code)) {
            out.print(JsonUtil.loadFalseResult(3, "请上传code"));
            return;
        }
    /**
     * 获取电话号码
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "getphone")
    public void getPhone(AcceptData acceptData, Long uid, PrintWriter out) {
        BusinessSystem system = getSystem(acceptData);
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        try {
            userAccountService.changeWXBind(acceptData, uid, code);
            UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
            // 判断taoBaoUid是否已经封禁
            ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
                    .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.wxUnionId, user.getWxUnionId());
            if (ic != null && ic.getEffective() != null && ic.getEffective()) {
                out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
                // 封禁用户
                // 封禁绑定的正常用户
                if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
                    userAccountService.forbiddenUser(uid, "封禁:绑定被封禁的微信号");
                }
                return;
            }
        if (uid == null || uid == 0) {
            out.print(JsonUtil.loadFalseResult(1, "请上传用户ID"));
            return;
        }
            JSONObject data = new JSONObject();
            data.put("user", UserUtil.filterForClientUser(user));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
    }
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        user = UserUtil.filterForClientUser(user);
        JSONObject data = new JSONObject();
        data.put("phone", user.getPhone());
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 获取电话号码
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "getphone")
    public void getPhone(AcceptData acceptData, Long uid, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
    @RequestMapping(value = "verifyvcodeforbind")
    public void verifyVcodeForbind(AcceptData acceptData, Long uid, String vcode, PrintWriter out) {
        BusinessSystem system = getSystem(acceptData);
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        if (uid == null || uid == 0) {
            out.print(JsonUtil.loadFalseResult(1, "请上传用户ID"));
            return;
        }
        if (uid == null || uid == 0) {
            out.print(JsonUtil.loadFalseResult(1, "请上传用户ID"));
            return;
        }
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        user = UserUtil.filterForClientUser(user);
        JSONObject data = new JSONObject();
        data.put("phone", user.getPhone());
        out.print(JsonUtil.loadTrueResult(data));
    }
        if (StringUtil.isNullOrEmpty(vcode)) {
            out.print(JsonUtil.loadFalseResult(1, "请上传验证码"));
            return;
        }
    @RequestMapping(value = "verifyvcodeforbind")
    public void verifyVcodeForbind(AcceptData acceptData, Long uid, String vcode, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        UserInfo user = userInfoService.getUserById(uid);
        if (uid == null || uid == 0) {
            out.print(JsonUtil.loadFalseResult(1, "请上传用户ID"));
            return;
        }
        if (StringUtil.isNullOrEmpty(user.getPhone())) {
            out.print(JsonUtil.loadFalseResult(1, "没有绑定电话号码"));
            return;
        }
        if (StringUtil.isNullOrEmpty(vcode)) {
            out.print(JsonUtil.loadFalseResult(1, "请上传验证码"));
            return;
        }
        String code = redisManager.getSMSVCode(user.getPhone(), SMSHistory.TYPE_LOGIN);
        if (code == null || !code.equalsIgnoreCase(vcode)) {
            out.print(JsonUtil.loadFalseResult(90001, "验证码错误"));
            return;
        }
        redisManager.clearSMSFrequencyLimit(user.getPhone(), SMSHistory.TYPE_LOGIN);
        redisManager.saveBindAlipayAccountSMSState(user.getPhone());
        out.print(JsonUtil.loadTrueResult(""));
    }
        UserInfo user = userInfoService.getUserById(uid);
    /**
     * 支付宝绑定
     *
     * @param acceptData
     * @param uid-用户ID
     * @param name-支付宝实名名称
     * @param account      -支付宝账号
     * @param out
     */
    @RequestMapping(value = "bindalipay")
    public void bindAlipay(AcceptData acceptData, Long uid, String name, String account, PrintWriter out) {
        BusinessSystem system = getSystem(acceptData);
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        if (StringUtil.isNullOrEmpty(user.getPhone())) {
            out.print(JsonUtil.loadFalseResult(1, "没有绑定电话号码"));
            return;
        }
        String code = redisManager.getSMSVCode(user.getPhone(), SMSHistory.TYPE_LOGIN);
        if (code == null || !code.equalsIgnoreCase(vcode)) {
            out.print(JsonUtil.loadFalseResult(90001, "验证码错误"));
            return;
        }
        redisManager.clearSMSFrequencyLimit(user.getPhone(), SMSHistory.TYPE_LOGIN);
        redisManager.saveBindAlipayAccountSMSState(user.getPhone());
        out.print(JsonUtil.loadTrueResult(""));
    }
    /**
     * 支付宝绑定
     *
     * @param acceptData
     * @param uid-用户ID
     * @param name-支付宝实名名称
     * @param account
     *            -支付宝账号
     * @param out
     */
    @RequestMapping(value = "bindalipay")
    public void bindAlipay(AcceptData acceptData, Long uid, String name, String account, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        if (uid == null || uid == 0) {
            out.print(JsonUtil.loadFalseResult(1, "请上传用户ID"));
            return;
        }
        if (uid == null || uid == 0) {
            out.print(JsonUtil.loadFalseResult(1, "请上传用户ID"));
            return;
        }
        if (StringUtil.isNullOrEmpty(name)) {
            out.print(JsonUtil.loadFalseResult(1, "请上传支付宝实名名称"));
            return;
        }
        if (StringUtil.isNullOrEmpty(name)) {
            out.print(JsonUtil.loadFalseResult(1, "请上传支付宝实名名称"));
            return;
        }
        if (StringUtil.isNullOrEmpty(account)) {
            out.print(JsonUtil.loadFalseResult(1, "请上传支付宝账号"));
            return;
        }
        if (StringUtil.isNullOrEmpty(account)) {
            out.print(JsonUtil.loadFalseResult(1, "请上传支付宝账号"));
            return;
        }
        UserInfo user = userInfoService.getUserById(uid);
        UserInfo user = userInfoService.getUserById(uid);
        boolean bind = redisManager.isBindAlipayAccountSMSStateValid(user.getPhone());
        if (!bind) {
            out.print(JsonUtil.loadFalseResult(90002, "手机验证超时"));
            return;
        }
        boolean bind = redisManager.isBindAlipayAccountSMSStateValid(user.getPhone());
        if (!bind) {
            out.print(JsonUtil.loadFalseResult(90002, "手机验证超时"));
            return;
        }
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.bindAlipay, uid + "");
        if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
            out.print(JsonUtil.loadFalseResult(2, "服务器繁忙,请稍后重试"));
            return;
        }
        redisManager.cacheCommonString(key, "1", 120);
        // 更换绑定
        try {
            BindingAccount bindingAccount = bindingAccountService.changeAlipayBinding(uid, name, account);
            out.print(JsonUtil.loadTrueResult(JsonUtil.getGson().toJson(bindingAccount)));
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            out.print(JsonUtil.loadFalseResult(3, "服务器内部错误"));
        } finally {
            redisManager.removeCommonString(key);
        }
    }
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.bindAlipay, uid + "");
        if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
            out.print(JsonUtil.loadFalseResult(2, "服务器繁忙,请稍后重试"));
            return;
        }
        redisManager.cacheCommonString(key, "1", 120);
        // 更换绑定
        try {
            BindingAccount bindingAccount = bindingAccountService.changeAlipayBinding(uid, name, account);
            out.print(JsonUtil.loadTrueResult(JsonUtil.getGson().toJson(bindingAccount)));
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            out.print(JsonUtil.loadFalseResult(3, "服务器内部错误"));
        } finally {
            redisManager.removeCommonString(key);
        }
    }
    @RequestMapping(value = "bindalipaywithverify")
    public void bindAlipayWithVerify(AcceptData acceptData, Long uid, String name, String account, PrintWriter out) {
    @RequestMapping(value = "bindalipaywithverify")
    public void bindAlipayWithVerify(AcceptData acceptData, Long uid, String name, String account, PrintWriter out) {
        BusinessSystem system = getSystem(acceptData);
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        if (uid == null || uid == 0) {
            out.print(JsonUtil.loadFalseResult(1, "请上传用户ID"));
            return;
        }
        if (uid == null || uid == 0) {
            out.print(JsonUtil.loadFalseResult(1, "请上传用户ID"));
            return;
        }
        if (StringUtil.isNullOrEmpty(name)) {
            out.print(JsonUtil.loadFalseResult(1, "请上传支付宝实名名称"));
            return;
        }
        if (StringUtil.isNullOrEmpty(name)) {
            out.print(JsonUtil.loadFalseResult(1, "请上传支付宝实名名称"));
            return;
        }
        if (StringUtil.isNullOrEmpty(account)) {
            out.print(JsonUtil.loadFalseResult(1, "请上传支付宝账号"));
            return;
        }
        if (StringUtil.isNullOrEmpty(account)) {
            out.print(JsonUtil.loadFalseResult(1, "请上传支付宝账号"));
            return;
        }
        UserInfo user = userInfoService.getUserById(uid);
        UserInfo user = userInfoService.getUserById(uid);
        boolean bind = redisManager.isBindAlipayAccountSMSStateValid(user.getPhone());
        if (!bind) {
            out.print(JsonUtil.loadFalseResult(90002, "手机验证超时"));
            return;
        }
        boolean bind = redisManager.isBindAlipayAccountSMSStateValid(user.getPhone());
        if (!bind) {
            out.print(JsonUtil.loadFalseResult(90002, "手机验证超时"));
            return;
        }
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.bindAlipay, uid + "");
        if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
            out.print(JsonUtil.loadFalseResult(1001, "服务器繁忙,请稍后重试"));
            return;
        }
        redisManager.cacheCommonString(key, "1", 120);
        // 可以展示给用户看的错误码
        String[] ALIPAY_CODES = new String[]{"SYSTEM_ERROR", "PERMIT_CHECK_PERM_LIMITED", "PERM_AML_NOT_REALNAME_REV",
                "PERM_AML_NOT_REALNAME_REV", "PAYEE_USER_INFO_ERROR", "PAYEE_ACC_OCUPIED",
                "PERMIT_CHECK_PERM_IDENTITY_THEFT", "PERMIT_NON_BANK_LIMIT_PAYEE", "EXCEED_LIMIT_UNRN_DM_AMOUNT"};
        try {
            BindingAccount bindingAccount = bindingAccountService.changeAlipayBindingWithVerify(uid, name, account);
            out.print(JsonUtil.loadTrue(0, JsonUtil.getGson().toJson(bindingAccount), "您的支付宝账号通过验证,可以正常提现"));
        } catch (AlipayTransferException e1) {
            if (e1.getSubCode().equalsIgnoreCase("PAYEE_NOT_EXIST")) {
                String msg = "无法搜索到该账号\n①请检查一下支付宝帐号和姓名是否填写正确。\n ②请在支付宝隐私设置中检查是否已开启“通过邮箱/手机号/会员名找到我”选项。";
                out.print(JsonUtil.loadFalseResult(1, msg));
            } else {
                for (String st : ALIPAY_CODES) {
                    if (st.equalsIgnoreCase(e1.getSubCode())) {
                        out.print(JsonUtil.loadFalseResult(2, e1.getMsg()));
                        return;
                    }
                }
                out.print(JsonUtil.loadFalseResult(3, "支付宝接口出错,验证失败,请联系客服。"));
                return;
            }
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.bindAlipay, uid + "");
        if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
            out.print(JsonUtil.loadFalseResult(1001, "服务器繁忙,请稍后重试"));
            return;
        }
        redisManager.cacheCommonString(key, "1", 120);
        // 可以展示给用户看的错误码
        String[] ALIPAY_CODES = new String[] { "SYSTEM_ERROR", "PERMIT_CHECK_PERM_LIMITED", "PERM_AML_NOT_REALNAME_REV",
                "PERM_AML_NOT_REALNAME_REV", "PAYEE_USER_INFO_ERROR", "PAYEE_ACC_OCUPIED",
                "PERMIT_CHECK_PERM_IDENTITY_THEFT", "PERMIT_NON_BANK_LIMIT_PAYEE", "EXCEED_LIMIT_UNRN_DM_AMOUNT" };
        try {
            BindingAccount bindingAccount = bindingAccountService.changeAlipayBindingWithVerify(uid, name, account);
            out.print(JsonUtil.loadTrue(0, JsonUtil.getGson().toJson(bindingAccount), "您的支付宝账号通过验证,可以正常提现"));
        } catch (AlipayTransferException e1) {
            if (e1.getSubCode().equalsIgnoreCase("PAYEE_NOT_EXIST")) {
                String msg = "无法搜索到该账号\n①请检查一下支付宝帐号和姓名是否填写正确。\n ②请在支付宝隐私设置中检查是否已开启“通过邮箱/手机号/会员名找到我”选项。";
                out.print(JsonUtil.loadFalseResult(1, msg));
            } else {
                for (String st : ALIPAY_CODES) {
                    if (st.equalsIgnoreCase(e1.getSubCode())) {
                        out.print(JsonUtil.loadFalseResult(2, e1.getMsg()));
                        return;
                    }
                }
                out.print(JsonUtil.loadFalseResult(3, "支付宝接口出错,验证失败,请联系客服。"));
                return;
            }
        } catch (AlipayApiException e2) {
            out.print(JsonUtil.loadFalseResult(4, e2.getErrMsg()));
            return;
        } catch (AlipayAccountException e3) {
            // 账户无余额
            if (e3.getCode() == AlipayAccountException.CODE_NO_MONEY) {
                out.print(JsonUtil.loadFalseResult(5, e3.getMsg()));
                return;
                // 提现次数限制
            } else if (e3.getCode() == AlipayAccountException.CODE_TIMES_LIMIT) {
                out.print(JsonUtil.loadFalseResult(6, e3.getMsg()));
                return;
            } else {
                out.print(JsonUtil.loadFalseResult(7, e3.getMsg()));
                return;
            }
        } catch (AlipayApiException e2) {
            out.print(JsonUtil.loadFalseResult(4, e2.getErrMsg()));
            return;
        } catch (AlipayAccountException e3) {
            // 账户无余额
            if (e3.getCode() == AlipayAccountException.CODE_NO_MONEY) {
                out.print(JsonUtil.loadFalseResult(5, e3.getMsg()));
                return;
                // 提现次数限制
            } else if (e3.getCode() == AlipayAccountException.CODE_TIMES_LIMIT) {
                out.print(JsonUtil.loadFalseResult(6, e3.getMsg()));
                return;
            } else {
                out.print(JsonUtil.loadFalseResult(7, e3.getMsg()));
                return;
            }
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            out.print(JsonUtil.loadFalseResult(8, "服务器内部错误,验证失败,请联系客服。"));
        } finally {
            redisManager.removeCommonString(key);
        }
    }
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            out.print(JsonUtil.loadFalseResult(8, "服务器内部错误,验证失败,请联系客服。"));
        } finally {
            redisManager.removeCommonString(key);
        }
    }
    @RequestMapping(value = "bindalipaywithverifynew")
    public void bindAlipayWithVerifyNew(AcceptData acceptData, Long uid, String name, String account, PrintWriter out) {
    @RequestMapping(value = "bindalipaywithverifynew")
    public void bindAlipayWithVerifyNew(AcceptData acceptData, Long uid, String name, String account, PrintWriter out) {
        BusinessSystem system = getSystem(acceptData);
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        if (uid == null || uid == 0) {
            out.print(JsonUtil.loadFalseResult(1, "请上传用户ID"));
            return;
        }
        if (uid == null || uid == 0) {
            out.print(JsonUtil.loadFalseResult(1, "请上传用户ID"));
            return;
        }
        if (StringUtil.isNullOrEmpty(name)) {
            out.print(JsonUtil.loadFalseResult(1, "请上传支付宝实名名称"));
            return;
        }
        if (StringUtil.isNullOrEmpty(name)) {
            out.print(JsonUtil.loadFalseResult(1, "请上传支付宝实名名称"));
            return;
        }
        if (StringUtil.isNullOrEmpty(account)) {
            out.print(JsonUtil.loadFalseResult(1, "请上传支付宝账号"));
            return;
        }
        if (StringUtil.isNullOrEmpty(account)) {
            out.print(JsonUtil.loadFalseResult(1, "请上传支付宝账号"));
            return;
        }
        UserInfo user = userInfoService.getUserById(uid);
        UserInfo user = userInfoService.getUserById(uid);
        boolean bind = redisManager.isBindAlipayAccountSMSStateValid(user.getPhone());
        if (!bind) {
            out.print(JsonUtil.loadFalseResult(90002, "手机验证超时"));
            return;
        }
        boolean bind = redisManager.isBindAlipayAccountSMSStateValid(user.getPhone());
        if (!bind) {
            out.print(JsonUtil.loadFalseResult(90002, "手机验证超时"));
            return;
        }
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.bindAlipay, uid + "");
        if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
            out.print(JsonUtil.loadFalseResult(1001, "服务器繁忙,请稍后重试"));
            return;
        }
        redisManager.cacheCommonString(key, "1", 120);
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.bindAlipay, uid + "");
        if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
            out.print(JsonUtil.loadFalseResult(1001, "服务器繁忙,请稍后重试"));
            return;
        }
        redisManager.cacheCommonString(key, "1", 120);
        // 支付宝绑定
        ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
                .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.alipayAccount, account);
        if (ic != null && ic.getEffective() != null && ic.getEffective()) {
            out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
            // 封禁用户
            // 封禁绑定的正常用户
            if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
                userAccountService.forbiddenUser(uid, "封禁:绑定被封禁的支付宝");
            }
            return;
        }
        // 支付宝绑定
        ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
                .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.alipayAccount, account);
        if (ic != null && ic.getEffective() != null && ic.getEffective()) {
            out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
            // 封禁用户
            // 封禁绑定的正常用户
            if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
                userAccountService.forbiddenUser(uid, "封禁:绑定被封禁的支付宝");
            }
            return;
        }
        // 可以展示给用户看的错误码
        String[] ALIPAY_CODES = new String[]{"SYSTEM_ERROR", "PERMIT_CHECK_PERM_LIMITED", "PERM_AML_NOT_REALNAME_REV",
                "PERM_AML_NOT_REALNAME_REV", "PAYEE_USER_INFO_ERROR", "PAYEE_ACC_OCUPIED",
                "PERMIT_CHECK_PERM_IDENTITY_THEFT", "PERMIT_NON_BANK_LIMIT_PAYEE", "EXCEED_LIMIT_UNRN_DM_AMOUNT"};
        BindingAccount oldBindingAccount = bindingAccountService.getBindingAccountByUidAndType(uid,
                BindingAccount.TYPE_ALIPAY);
        try {
            BigDecimal balance = user.getMyHongBao();
            BindingAccount bindingAccount = bindingAccountService.changeAlipayBindingWithVerify(uid, name, account);
            // 余额充足
            if (balance.compareTo(new BigDecimal("0.1")) >= 0)
                out.print(JsonUtil.loadTrue(0, JsonUtil.getGson().toJson(bindingAccount),
                        "系统已成功转账0.1元到提现账号中,提现账号验证通过,恭喜你!可以提现了。"));
            else
                out.print(JsonUtil.loadTrue(0, JsonUtil.getGson().toJson(bindingAccount),
                        "系统已成功转账0.1元到提现账号中,提现账号验证通过,恭喜你!可以提现了。注:此0.1元将会在后续产生的余额中合理扣除,敬请知晓。"));
        // 可以展示给用户看的错误码
        String[] ALIPAY_CODES = new String[] { "SYSTEM_ERROR", "PERMIT_CHECK_PERM_LIMITED", "PERM_AML_NOT_REALNAME_REV",
                "PERM_AML_NOT_REALNAME_REV", "PAYEE_USER_INFO_ERROR", "PAYEE_ACC_OCUPIED",
                "PERMIT_CHECK_PERM_IDENTITY_THEFT", "PERMIT_NON_BANK_LIMIT_PAYEE", "EXCEED_LIMIT_UNRN_DM_AMOUNT" };
        BindingAccount oldBindingAccount = bindingAccountService.getBindingAccountByUidAndType(uid,
                BindingAccount.TYPE_ALIPAY);
        try {
            BigDecimal balance = user.getMyHongBao();
            BindingAccount bindingAccount = bindingAccountService.changeAlipayBindingWithVerify(uid, name, account);
            // 余额充足
            if (balance.compareTo(new BigDecimal("0.1")) >= 0)
                out.print(JsonUtil.loadTrue(0, JsonUtil.getGson().toJson(bindingAccount),
                        "系统已成功转账0.1元到提现账号中,提现账号验证通过,恭喜你!可以提现了。"));
            else
                out.print(JsonUtil.loadTrue(0, JsonUtil.getGson().toJson(bindingAccount),
                        "系统已成功转账0.1元到提现账号中,提现账号验证通过,恭喜你!可以提现了。注:此0.1元将会在后续产生的余额中合理扣除,敬请知晓。"));
            userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindAlipay, account);
        } catch (AlipayTransferException e1) {
            LogHelper.error("支付宝验证出错:" + new Gson().toJson(e1));
            if (e1.getSubCode().equalsIgnoreCase("PAYEE_NOT_EXIST")) {
                String msg = "系统未能成功转账0.1元,提现账号信息有误,请核对后重新填写。";
                out.print(JsonUtil.loadFalseResult(1, msg));
            } else {
                for (String st : ALIPAY_CODES) {
                    if (st.equalsIgnoreCase(e1.getSubCode())) {
                        out.print(JsonUtil.loadFalseResult(2, e1.getMsg()));
                        return;
                    }
                }
                out.print(JsonUtil.loadFalseResult(3, "支付宝接口出错,验证失败,请联系客服。"));
                return;
            }
            userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindAlipay, account);
        } catch (AlipayTransferException e1) {
            LogHelper.error("支付宝验证出错:"+new Gson().toJson(e1));
            if (e1.getSubCode().equalsIgnoreCase("PAYEE_NOT_EXIST")) {
                String msg = "系统未能成功转账0.1元,提现账号信息有误,请核对后重新填写。";
                out.print(JsonUtil.loadFalseResult(1, msg));
            } else {
                for (String st : ALIPAY_CODES) {
                    if (st.equalsIgnoreCase(e1.getSubCode())) {
                        out.print(JsonUtil.loadFalseResult(2, e1.getMsg()));
                        return;
                    }
                }
                out.print(JsonUtil.loadFalseResult(3, "支付宝接口出错,验证失败,请联系客服。"));
                return;
            }
        } catch (AlipayApiException e2) {
            out.print(JsonUtil.loadFalseResult(4, e2.getErrMsg()));
            return;
        } catch (AlipayAccountException e3) {
            // 账户无余额
            if (e3.getCode() == AlipayAccountException.CODE_NO_MONEY) {
                if (oldBindingAccount != null) {
                    out.print(JsonUtil.loadFalseResult(5, "当前账户没有余额,无需修改,请有余额后修改"));
                } else {
                    out.print(JsonUtil.loadFalseResult(5, "当前账户没有余额,请有余额后绑定"));
                }
                return;
                // 提现次数限制
            } else if (e3.getCode() == AlipayAccountException.CODE_TIMES_LIMIT) {
                out.print(JsonUtil.loadFalseResult(6, "每月仅可修改1次提现账号,请下月再试吧。"));
                return;
            } else {
                out.print(JsonUtil.loadFalseResult(7, e3.getMsg()));
                return;
            }
        } catch (AlipayApiException e2) {
            out.print(JsonUtil.loadFalseResult(4, e2.getErrMsg()));
            return;
        } catch (AlipayAccountException e3) {
            // 账户无余额
            if (e3.getCode() == AlipayAccountException.CODE_NO_MONEY) {
                if (oldBindingAccount != null) {
                    out.print(JsonUtil.loadFalseResult(5, "当前账户没有余额,无需修改,请有余额后修改"));
                } else {
                    out.print(JsonUtil.loadFalseResult(5, "当前账户没有余额,请有余额后绑定"));
                }
                return;
                // 提现次数限制
            } else if (e3.getCode() == AlipayAccountException.CODE_TIMES_LIMIT) {
                out.print(JsonUtil.loadFalseResult(6, "每月仅可修改1次提现账号,请下月再试吧。"));
                return;
            } else {
                out.print(JsonUtil.loadFalseResult(7, e3.getMsg()));
                return;
            }
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            out.print(JsonUtil.loadFalseResult(8, "服务器内部错误,验证失败,请联系客服。"));
        } finally {
            redisManager.removeCommonString(key);
        }
    }
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            out.print(JsonUtil.loadFalseResult(8, "服务器内部错误,验证失败,请联系客服。"));
        } finally {
            redisManager.removeCommonString(key);
        }
    }
    /**
     * 获取用户资金详情
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "getusermoney")
    public void getMoneyDetail(AcceptData acceptData, Long uid, PrintWriter out) {
    /**
     * 获取用户资金详情
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "getusermoney")
    public void getMoneyDetail(AcceptData acceptData, Long uid, PrintWriter out) {
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        if (user == null) {
            out.print(JsonUtil.loadFalseResult(2, "用户不存在"));
            return;
        }
        BigDecimal moneyToday = userMoneyService.getMoneyToday(uid);
        if (moneyToday == null) {
            moneyToday = new BigDecimal(0);
        }
        BigDecimal moneyMonth = userMoneyService.getMoneyMonth(uid);
        if (moneyMonth == null) {
            moneyMonth = new BigDecimal(0);
        }
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        if (user == null) {
            out.print(JsonUtil.loadFalseResult(2, "用户不存在"));
            return;
        }
        BigDecimal moneyToday = userMoneyService.getMoneyToday(uid);
        if (moneyToday == null) {
            moneyToday = new BigDecimal(0);
        }
        BigDecimal moneyMonth = userMoneyService.getMoneyMonth(uid);
        if (moneyMonth == null) {
            moneyMonth = new BigDecimal(0);
        }
        BigDecimal moneyLastMonth = userMoneyService.getMoneyLastMonth(uid);
        BigDecimal unOpenmoney = hongBaoV2Service.getUnRecievedFanLiMoney(uid);
        BigDecimal totalFanMoney = hongBaoV2Service.getTotalFanLiMoney(uid);
        JSONObject data = new JSONObject();
        int spreadImgCount = spreadUserImgService.countUserSpreadImg(uid);
        long shareCount = userShareGoodsRecordService.countShareRecordByUid(uid);
        BigDecimal moneyLastMonth = userMoneyService.getMoneyLastMonth(uid);
        BigDecimal unOpenmoney = hongBaoV2Service.getUnRecievedFanLiMoney(uid);
        BigDecimal totalFanMoney = hongBaoV2Service.getTotalFanLiMoney(uid);
        JSONObject data = new JSONObject();
        int spreadImgCount = spreadUserImgService.countUserSpreadImg(uid);
        long shareCount = userShareGoodsRecordService.countShareRecordByUid(uid);
        // IOS端数字按照字符串处理
        if ("ios".equalsIgnoreCase(acceptData.getPlatform()) && Integer.parseInt(acceptData.getVersion()) > 33) {
            data.put("moneyToday", moneyToday.setScale(2, BigDecimal.ROUND_DOWN).toString());
            data.put("moneyMonth", moneyMonth.setScale(2, BigDecimal.ROUND_DOWN).toString());
            data.put("moneyLastMonth", moneyLastMonth.setScale(2, BigDecimal.ROUND_DOWN).toString());
            data.put("money", user.getMyHongBao().setScale(2, BigDecimal.ROUND_DOWN).toString());
            data.put("unGetMoney", unOpenmoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
            data.put("totalFanLiMoney", totalFanMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());// 累计返利
            data.put("totalTiChengMoney",
                    hongBaoV2Service.getTotalTiChengMoney(uid).setScale(2, BigDecimal.ROUND_DOWN).toString());// 累计提成
            data.put("totalUnGetTiChengMoney",
                    hongBaoV2Service.getUnGetTiChengMoney(uid).setScale(2, BigDecimal.ROUND_DOWN).toString()); // 未到账提成
            // 展示提成数据
            if (configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), SystemInfoUtil.getSystem(acceptData)))
                data.put("showTiCheng", false);
            else
                data.put("showTiCheng", spreadImgCount + shareCount > 0);
        } else {
            data.put("moneyToday", moneyToday.setScale(2, BigDecimal.ROUND_DOWN));
            data.put("moneyMonth", moneyMonth.setScale(2, BigDecimal.ROUND_DOWN));
            data.put("moneyLastMonth", moneyLastMonth.setScale(2, BigDecimal.ROUND_DOWN));
            data.put("money", user.getMyHongBao().setScale(2, BigDecimal.ROUND_DOWN));
            data.put("unGetMoney", unOpenmoney.setScale(2, BigDecimal.ROUND_DOWN));
            data.put("totalFanLiMoney", totalFanMoney.setScale(2, BigDecimal.ROUND_DOWN));// 累计返利
            data.put("totalTiChengMoney",
                    hongBaoV2Service.getTotalTiChengMoney(uid).setScale(2, BigDecimal.ROUND_DOWN));// 累计提成
            data.put("totalUnGetTiChengMoney",
                    hongBaoV2Service.getUnGetTiChengMoney(uid).setScale(2, BigDecimal.ROUND_DOWN)); // 未到账提成
            // 展示提成数据
            data.put("showTiCheng", spreadImgCount + shareCount > 0);
        }
        // IOS端数字按照字符串处理
        if ("ios".equalsIgnoreCase(acceptData.getPlatform()) && Integer.parseInt(acceptData.getVersion()) > 33) {
            data.put("moneyToday", moneyToday.setScale(2, BigDecimal.ROUND_DOWN).toString());
            data.put("moneyMonth", moneyMonth.setScale(2, BigDecimal.ROUND_DOWN).toString());
            data.put("moneyLastMonth", moneyLastMonth.setScale(2, BigDecimal.ROUND_DOWN).toString());
            data.put("money", user.getMyHongBao().setScale(2, BigDecimal.ROUND_DOWN).toString());
            data.put("unGetMoney", unOpenmoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
            data.put("totalFanLiMoney", totalFanMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());// 累计返利
            data.put("totalTiChengMoney",
                    hongBaoV2Service.getTotalTiChengMoney(uid).setScale(2, BigDecimal.ROUND_DOWN).toString());// 累计提成
            data.put("totalUnGetTiChengMoney",
                    hongBaoV2Service.getUnGetTiChengMoney(uid).setScale(2, BigDecimal.ROUND_DOWN).toString()); // 未到账提成
            // 展示提成数据
            if (configService.iosOnLining(Integer.parseInt(acceptData.getVersion()),SystemInfoUtil.getSystem(acceptData)))
                data.put("showTiCheng", false);
            else
                data.put("showTiCheng", spreadImgCount + shareCount > 0);
        } else {
            data.put("moneyToday", moneyToday.setScale(2, BigDecimal.ROUND_DOWN));
            data.put("moneyMonth", moneyMonth.setScale(2, BigDecimal.ROUND_DOWN));
            data.put("moneyLastMonth", moneyLastMonth.setScale(2, BigDecimal.ROUND_DOWN));
            data.put("money", user.getMyHongBao().setScale(2, BigDecimal.ROUND_DOWN));
            data.put("unGetMoney", unOpenmoney.setScale(2, BigDecimal.ROUND_DOWN));
            data.put("totalFanLiMoney", totalFanMoney.setScale(2, BigDecimal.ROUND_DOWN));// 累计返利
            data.put("totalTiChengMoney",
                    hongBaoV2Service.getTotalTiChengMoney(uid).setScale(2, BigDecimal.ROUND_DOWN));// 累计提成
            data.put("totalUnGetTiChengMoney",
                    hongBaoV2Service.getUnGetTiChengMoney(uid).setScale(2, BigDecimal.ROUND_DOWN)); // 未到账提成
            // 展示提成数据
            data.put("showTiCheng", spreadImgCount + shareCount > 0);
        }
        user.setNoOpenHongBao(unOpenmoney);
        out.print(JsonUtil.loadTrueResult(data));
    }
        user.setNoOpenHongBao(unOpenmoney);
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 获取用户的PID信息
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "gettbpidinfo")
    public void getUserPid(AcceptData acceptData, String uid, PrintWriter out) {
        ClientTBPid clientTBPid = null;
        // 用户已经登录
        if (!StringUtil.isNullOrEmpty(uid)) {
            TBPid tbPid = null;
            if (acceptData.getPlatform().equalsIgnoreCase("android")) {
                tbPid = tbPidService.getTBPid(Long.parseLong(uid), PidUser.TYPE_FANLI_ANDROID);
                if (tbPid != null) {
                    String siteId = tbPid.getPid().split("_")[2];
                    String adzoneId = tbPid.getPid().split("_")[3];
                    TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
                    clientTBPid = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId);
                } else {
                    clientTBPid = tbPidService.getAndroidDefault();
                }
    /**
     * 获取用户的PID信息
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "gettbpidinfo")
    public void getUserPid(AcceptData acceptData, String uid, PrintWriter out) {
        ClientTBPid clientTBPid = null;
        // 用户已经登录
        if (!StringUtil.isNullOrEmpty(uid)) {
            TBPid tbPid = null;
            if (acceptData.getPlatform().equalsIgnoreCase("android")) {
                tbPid = tbPidService.getTBPid(Long.parseLong(uid), PidUser.TYPE_FANLI_ANDROID);
                if (tbPid != null) {
                    String siteId = tbPid.getPid().split("_")[2];
                    String adzoneId = tbPid.getPid().split("_")[3];
                    TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
                    clientTBPid = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId);
                } else {
                    clientTBPid = tbPidService.getAndroidDefault();
                }
            } else {
            } else {
                clientTBPid = tbPidService.getIOSDefault();
                clientTBPid = tbPidService.getIOSDefault();
            }
            }
        } else {
            if (acceptData.getPlatform().equalsIgnoreCase("android"))
                clientTBPid = tbPidService.getAndroidDefault();
            else
                clientTBPid = tbPidService.getIOSDefault();
        }
        } else {
            if (acceptData.getPlatform().equalsIgnoreCase("android"))
                clientTBPid = tbPidService.getAndroidDefault();
            else
                clientTBPid = tbPidService.getIOSDefault();
        }
        JSONObject data = new JSONObject();
        data.put("pidInfo", clientTBPid);
        out.print(JsonUtil.loadTrueResult(data));
    }
        JSONObject data = new JSONObject();
        data.put("pidInfo", clientTBPid);
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 退出登录
     *
     * @param acceptData
     * @param uid        -用户ID
     * @param out
     */
    @RequestMapping(value = "logout")
    public void logOut(AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid == 0)
            return;
        if ("android".equalsIgnoreCase(acceptData.getPlatform())) {
            DeviceActive deviceActive = deviceActiveService.getFirstActiveInfo(acceptData.getDevice());
            // 需要解绑HW推送的用户绑定
            deviceTokenHWService.unBindDeviceToken(acceptData.getDevice());
            if (deviceActive != null) {
                // 解绑OPPO推送的用户绑定
                deviceTokenOPPOService.unBindUid(uid, deviceActive.getId());
                // 解绑VIVO推送的用户绑定
                deviceTokenVIVOService.unBindUid(uid, deviceActive.getId());
                // 解绑XM推送的用户绑定
                deviceTokenXMService.unBindUid(deviceActive.getId());
            }
        }
        out.print(JsonUtil.loadTrueResult(""));
    }
    /**
     * 退出登录
     *
     * @param acceptData
     * @param uid
     *            -用户ID
     * @param out
     */
    @RequestMapping(value = "logout")
    public void logOut(AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid == 0)
            return;
        if ("android".equalsIgnoreCase(acceptData.getPlatform())) {
            DeviceActive deviceActive = deviceActiveService.getFirstActiveInfo(acceptData.getDevice());
            // 需要解绑HW推送的用户绑定
            deviceTokenHWService.unBindDeviceToken(acceptData.getDevice());
            if (deviceActive != null) {
                // 解绑OPPO推送的用户绑定
                deviceTokenOPPOService.unBindUid(uid, deviceActive.getId());
                // 解绑VIVO推送的用户绑定
                deviceTokenVIVOService.unBindUid(uid, deviceActive.getId());
                // 解绑XM推送的用户绑定
                deviceTokenXMService.unBindUid(deviceActive.getId());
            }
        }
        out.print(JsonUtil.loadTrueResult(""));
    }
    /**
     * 新版登录 V1.5.3
     *
     * @param acceptData
     * @param vcode
     * @param phone
     * @param code
     * @param loginType  登录方式: 1-手机登录 2-微信登录
     * @param request
     * @param out
     */
    @RequestMapping(value = "loginNew", method = RequestMethod.POST)
    public void loginNew(AcceptData acceptData, String vcode, String phone, String code, int loginType,
                         HttpServletRequest request, PrintWriter out) {
    /**
     * 新版登录 V1.5.3
     *
     * @param acceptData
     * @param vcode
     * @param phone
     * @param code
     * @param loginType
     *            登录方式: 1-手机登录 2-微信登录
     * @param request
     * @param out
     */
    @RequestMapping(value = "loginNew", method = RequestMethod.POST)
    public void loginNew(AcceptData acceptData, String vcode, String phone, String code, int loginType,
            HttpServletRequest request, PrintWriter out) {
        // 2.0以下版本不允许登录
        if (!VersionUtil.greaterThan_2_0(acceptData.getPlatform(), acceptData.getVersion())) {
            out.print("请升级到最新版本");
            return;
        }
        // 2.0以下版本不允许登录
        if (!VersionUtil.greaterThan_2_0(acceptData.getPlatform(), acceptData.getVersion())) {
            out.print("请升级到最新版本");
            return;
        }
        try {
            BusinessSystem system = getSystem(acceptData);
            if (system == null) {
                out.print(JsonUtil.loadFalseResult("系统不存在"));
                return;
            }
        try {
            BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                    acceptData.getPackages());
            if (system == null) {
                out.print(JsonUtil.loadFalseResult("系统不存在"));
                return;
            }
            UserInfo userInfo = null;
            // 手机登录
            if (loginType == 1) {
                userInfo = userAccountService.loginPhone(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, vcode, phone, system);
            }
            UserInfo userInfo = null;
            // 手机登录
            if (loginType == 1) {
                userInfo = userAccountService.loginPhone(new ProxyIP(request.getRemoteHost(),request.getRemotePort()), acceptData, loginType, vcode, phone, system.getAppid());
            }
            // 微信登录
            if (loginType == 2) {
                userInfo = userAccountService.loginWeiXin(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, code, system);
            }
            // 微信登录
            if (loginType == 2) {
                userInfo = userAccountService.loginWinXin(new ProxyIP(request.getRemoteHost(),request.getRemotePort()), acceptData, loginType, code, system.getAppid());
            }
            if (userInfo == null) {
                out.print(JsonUtil.loadFalseResult("登录失败"));
            } else {
                JSONObject data = new JSONObject();
                data.put("userInfo", UserUtil.filterForClientUser(userInfo));
                out.print(JsonUtil.loadTrueResult(data));
            if (userInfo == null) {
                out.print(JsonUtil.loadFalseResult("登录失败"));
            } else {
                JSONObject data = new JSONObject();
                data.put("userInfo", UserUtil.filterForClientUser(userInfo));
                out.print(JsonUtil.loadTrueResult(data));
                final UserInfo uuser = userInfo;
                ThreadUtil.run(new Runnable() {
                    public void run() {
                        String device = acceptData.getDevice();
                        try {
                            // 同步自定义导航
                            homeNavbarUserService.synchroDeviceToUser(uuser.getId(), device);
                        } catch (Exception e) {
                            LogHelper.errorDetailInfo(e);
                        }
                final UserInfo uuser = userInfo;
                ThreadUtil.run(new Runnable() {
                    public void run() {
                        String device = acceptData.getDevice();
                        try {
                            // 同步自定义导航
                            homeNavbarUserService.synchroDeviceToUser(uuser.getId(), device);
                        } catch (Exception e) {
                            LogHelper.errorDetailInfo(e);
                        }
                        // 绑定oppo推送
                        DeviceActive active = deviceActiveService.getFirstActiveInfo(acceptData.getDevice());
                        if (active != null) {
                            deviceTokenOPPOService.bindUid(uuser.getId(), active.getId());
                            deviceTokenVIVOService.bindUid(uuser.getId(), active.getId());
                            deviceTokenXMService.bindUid(active.getId(), uuser.getId());
                        }
                    }
                });
            }
                        // 绑定oppo推送
                        DeviceActive active = deviceActiveService.getFirstActiveInfo(acceptData.getDevice());
                        if (active != null) {
                            deviceTokenOPPOService.bindUid(uuser.getId(), active.getId());
                            deviceTokenVIVOService.bindUid(uuser.getId(), active.getId());
                            deviceTokenXMService.bindUid(active.getId(), uuser.getId());
                        }
                    }
                });
            }
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
            try {
                LogHelper.error("登录出错:" + e.getCode() + "-" + e.getMessage());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("登录失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
            try {
                LogHelper.error("登录出错:" + e.getCode() + "-" + e.getMessage());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("登录失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    /**
     * 绑定电话号码 V1.5.3
     *
     * @param acceptData
     * @param vcode
     * @param phone
     * @param out
     */
    @RequestMapping(value = "bindPhoneNew")
    public void bindPhoneNew(AcceptData acceptData, Long uid, String vcode, String phone, PrintWriter out) {
    /**
     * 绑定电话号码 V1.5.3
     *
     * @param acceptData
     * @param vcode
     * @param phone
     * @param out
     */
    @RequestMapping(value = "bindPhoneNew")
    public void bindPhoneNew(AcceptData acceptData, Long uid, String vcode, String phone, PrintWriter out) {
        BusinessSystem system = getSystem(acceptData);
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        if (StringUtil.isNullOrEmpty(vcode)) {
            out.print(JsonUtil.loadFalseResult("验证码不能为空"));
            return;
        }
        if (StringUtil.isNullOrEmpty(vcode)) {
            out.print(JsonUtil.loadFalseResult("验证码不能为空"));
            return;
        }
        if (StringUtil.isNullOrEmpty(phone)) {
            out.print(JsonUtil.loadFalseResult("电话号码不能为空"));
            return;
        }
        if (StringUtil.isNullOrEmpty(phone)) {
            out.print(JsonUtil.loadFalseResult("电话号码不能为空"));
            return;
        }
        phone = phone.replaceAll(" ", "");
        phone = phone.replaceAll(" ", "");
        String oldVCode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_BIND);
        if (Constant.IS_OUTNET) {
            if (!vcode.equalsIgnoreCase(oldVCode)) {
                out.print(JsonUtil.loadFalseResult(9001, "验证码错误,重新输入"));
                return;
            }
            redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_BIND);
        }
        String oldVCode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_BIND);
        if (Constant.IS_OUTNET) {
            if (!vcode.equalsIgnoreCase(oldVCode)) {
                out.print(JsonUtil.loadFalseResult(9001, "验证码错误,重新输入"));
                return;
            }
            redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_BIND);
        }
        try {
            // 绑定用户
            userAccountService.bindPhoneNew(uid, phone);
        try {
            // 绑定用户
            userAccountService.bindPhoneNew(uid, phone);
            UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
            // 判断电话号码是否已经封禁
            ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
                    .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, phone);
            if (ic != null && ic.getEffective() != null && ic.getEffective()) {
                out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
                // 封禁用户
                // 封禁绑定的正常用户
                if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
                    userAccountService.forbiddenUser(uid, "封禁:绑定被封禁的电话号码");
                }
                return;
            }
            UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
            // 判断电话号码是否已经封禁
            ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
                    .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, phone);
            if (ic != null && ic.getEffective() != null && ic.getEffective()) {
                out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
                // 封禁用户
                // 封禁绑定的正常用户
                if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
                    userAccountService.forbiddenUser(uid, "封禁:绑定被封禁的电话号码");
                }
                return;
            }
            JSONObject data = new JSONObject();
            data.put("userInfo", UserUtil.filterForClientUser(user));
            out.print(JsonUtil.loadTrueResult(data));
            JSONObject data = new JSONObject();
            data.put("userInfo", UserUtil.filterForClientUser(user));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult(1, "绑定失败"));
        }
    }
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult(1, "绑定失败"));
        }
    }
    /**
     * 更改微信
     *
     * @param acceptData
     * @param uid
     * @param code
     * @param out
     */
    @RequestMapping(value = "bindWeiXin")
    public void bindWeiXin(AcceptData acceptData, Long uid, String code, PrintWriter out) {
        BusinessSystem system = getSystem(acceptData);
    /**
     * 更改微信
     *
     * @param acceptData
     * @param uid
     * @param code
     * @param out
     */
    @RequestMapping(value = "bindWeiXin")
    public void bindWeiXin(AcceptData acceptData, Long uid, String code, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        if (StringUtil.isNullOrEmpty(code)) {
            out.print(JsonUtil.loadFalseResult("请上传code"));
            return;
        }
        if (StringUtil.isNullOrEmpty(code)) {
            out.print(JsonUtil.loadFalseResult("请上传code"));
            return;
        }
        try {
            userAccountService.bindWeiXin(acceptData, uid, code);
        try {
            userAccountService.bindWeiXin(acceptData, uid, code);
            UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
            // 判断taoBaoUid是否已经封禁
            ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
                    .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.wxUnionId, user.getWxUnionId());
            if (ic != null && ic.getEffective() != null && ic.getEffective()) {
                out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
                // 封禁用户
                // 封禁绑定的正常用户
                if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
                    userAccountService.forbiddenUser(uid, "封禁:绑定被封禁的微信号");
                }
                return;
            }
            UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
            // 判断taoBaoUid是否已经封禁
            ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
                    .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.wxUnionId, user.getWxUnionId());
            if (ic != null && ic.getEffective() != null && ic.getEffective()) {
                out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
                // 封禁用户
                // 封禁绑定的正常用户
                if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
                    userAccountService.forbiddenUser(uid, "封禁:绑定被封禁的微信号");
                }
                return;
            }
            JSONObject data = new JSONObject();
            data.put("userInfo", UserUtil.filterForClientUser(user));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
    }
            JSONObject data = new JSONObject();
            data.put("userInfo", UserUtil.filterForClientUser(user));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java
@@ -324,7 +324,7 @@
        }
        // 不是用ID的登陆的事就多了
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
@@ -515,7 +515,7 @@
        }
        // 不是用ID的登陆的事就多了
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
@@ -1155,7 +1155,7 @@
        }
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            LogHelper.userInfo("提现时,不存在该系统");
            out.print(JsonUtil.loadFalseResult("系统不存在"));
@@ -1502,7 +1502,7 @@
        List<TaoBaoGoodsBrief> listTaoKeGoods = new ArrayList<TaoBaoGoodsBrief>();
        if (collectionGoodsList != null && collectionGoodsList.size() > 0) {
            BigDecimal proportion = hongBaoManageService.getFanLiRate();
            BigDecimal proportion = hongBaoManageService.getFanLiRate(acceptData.getSystem());
            List<Long> listGid = new ArrayList<Long>();
            for (CollectionGoodsV2 collectionGoodsV2 : collectionGoodsList) {
@@ -2050,7 +2050,7 @@
    public void getuserinfoNew(AcceptData acceptData, Long uid, HttpServletRequest requst, PrintWriter out) {
        try {
            BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                    acceptData.getPackages());
                    acceptData.getPackages(),acceptData.getSystem());
            if (system == null) {
                out.print(JsonUtil.loadFalseResult("系统不存在"));
                return;
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5CouponController.java
@@ -104,7 +104,7 @@
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        ConfigParamsDTO configParamsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                acceptData.getVersion(), UserLevelEnum.daRen);
                acceptData.getVersion(), UserLevelEnum.daRen,acceptData.getSystem());
        /* 遍历列表数据 */
        for (QualityFactory selectionGoods : listQuery) {
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5PullNewController.java
@@ -84,8 +84,8 @@
        if (list != null && list.size() > 0) {
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                    acceptData.getVersion());
            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
                    acceptData.getVersion(),acceptData.getSystem());
            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem()));
            
            for (PullNewGoods goods : list) {
                array.add(gson.toJson(GoodsDetailVOFactory.convertTaoBao(TaoBaoGoodsFactory.create(goods),paramsDTO)));
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/BrandControllerV2.java
@@ -5,6 +5,7 @@
import java.util.List;
import javax.annotation.Resource;
import javax.swing.colorchooser.AbstractColorChooserPanel;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -58,10 +59,6 @@
@Controller
@RequestMapping("api/v2/brand")
public class BrandControllerV2 {
    @Resource
    private BrandClassService brandClassService;
    @Resource
    private BrandClassShopService brandClassShopService;
@@ -110,7 +107,7 @@
        if (page == null || page < 1) {
            page = 1;
        }
        JSONObject data = brandClassShopService.listEffectiveCacheV2(page, cid,acceptData.getPlatform(),acceptData.getVersion());
        JSONObject data = brandClassShopService.listEffectiveCacheV2(page, cid,acceptData.getPlatform(),acceptData.getVersion(),acceptData.getSystem());
        out.print(JsonUtil.loadTrueResult(data));
    }
@@ -308,7 +305,7 @@
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                    acceptData.getVersion());
                    acceptData.getVersion(),acceptData.getSystem());
            // 商品信息过滤
            listGoodsBrief = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(listGoodsBrief);
@@ -373,7 +370,7 @@
        
        JSONObject data = new JSONObject();
        if (page == 1 && cid != null) {
            List<BrandInfo> brandlist = brandInfoService.listValidBrandInfoCache(cid);
            List<BrandInfo> brandlist = brandInfoService.listValidBrandInfoCache(cid,acceptData.getSystem());
            if(brandlist == null)
                brandlist = new ArrayList<BrandInfo>();
            data.put("brandlist", JsonUtil.getApiCommonGson().toJson(brandlist));
@@ -382,7 +379,7 @@
        
        long count = brandInfoService.countBrandInfo(cid);
        
        List<BrandInfoVO> list = brandInfoService.listBrandInfoCache((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, cid,acceptData.getPlatform(),acceptData.getVersion());
        List<BrandInfoVO> list = brandInfoService.listBrandInfoCache((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, cid,acceptData.getPlatform(),acceptData.getVersion(),acceptData.getSystem());
        if (list == null)
            list = new ArrayList<BrandInfoVO>();
        
@@ -532,7 +529,7 @@
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                    acceptData.getVersion());
                    acceptData.getVersion(),acceptData.getSystem());
            // 商品信息过滤
            listGoodsBrief = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(listGoodsBrief);
@@ -676,15 +673,15 @@
        }
        
        if (page == 1 && cid != null) {
            List<BrandInfo> brandlist = brandInfoService.listValidByCidToApp(cid);
            List<BrandInfo> brandlist = brandInfoService.listValidByCidToApp(cid,acceptData.getSystem());
            if(brandlist == null)
                brandlist = new ArrayList<BrandInfo>();
            data.put("brandlist", JsonUtil.getApiCommonGson().toJson(brandlist));
        }
        
        long count = brandInfoService.countValidByCidToApp(cid);
        long count = brandInfoService.countValidByCidToApp(cid,acceptData.getSystem());
        
        List<BrandInfoVO> list = brandInfoService.listValidToApp((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, cid,acceptData.getPlatform(),acceptData.getVersion());
        List<BrandInfoVO> list = brandInfoService.listValidToApp((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, cid,acceptData.getPlatform(),acceptData.getVersion(), acceptData.getSystem());
        if (list == null)
            list = new ArrayList<BrandInfoVO>();
        
@@ -722,7 +719,7 @@
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        
        ConfigParamsDTO paramsDTO =  orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                acceptData.getVersion());
                acceptData.getVersion(),acceptData.getSystem());
        JSONArray array = new JSONArray();
        
        List<BrandGoodsCahe> listGoods = brandGoodsCaheService.getByBrandId((page - 1) * 50, 50,id);
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java
@@ -149,7 +149,7 @@
            result = guessLikeDeviceTB(idfa, imei, acceptData.getUtdid(), page);
        } else {
            // 大淘客页码只能为10,50,100,200
            result = commonTemplateContentService.getContentList(type, cid, page, 10);
            result = commonTemplateContentService.getContentList(type, cid, page, 10,acceptData.getSystem());
        }
        JSONObject root = new JSONObject();
@@ -166,7 +166,7 @@
            goodsList = result.getGoodsList();
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                acceptData.getVersion());
                acceptData.getVersion(),acceptData.getSystem());
        for (TaoBaoGoodsBrief taoBaoGoodsBrief : goodsList) {
            GoodsDetailVO vo = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO);
            if (type == CommonContentTypeEnum.mianDan)// 免单商品
@@ -215,7 +215,7 @@
                Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                        .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                for (JDGoods goods : goodsList) {
                    array.add(gson.toJson(GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO)));
@@ -266,7 +266,7 @@
                Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                        .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                for (PDDGoodsDetail goods : goodsList) {
                    array.add(gson.toJson(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO)));
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConsumerControllerV2.java
@@ -270,7 +270,7 @@
            }
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                    acceptData.getVersion());
                    acceptData.getVersion(),acceptData.getSystem());
            for (CollectionGoodsV2 collectionGoodsV2 : collectionGoodsList) {
                CommonGoods commonGoods = collectionGoodsV2.getCommonGoods();
@@ -389,7 +389,7 @@
        if (list != null && list.size() > 0) {
            Gson gson = gsonBuilder.create();
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                    acceptData.getVersion());
                    acceptData.getVersion(),acceptData.getSystem());
            for (ScanHistoryV2 sh : list) {
                CommonGoods commonGoods = sh.getCommonGoods();
                if (commonGoods == null) {
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsClassControllerV2.java
@@ -1,6 +1,7 @@
package com.yeshi.fanli.controller.client.v2;
import java.io.PrintWriter;
import java.security.AccessControlContext;
import java.util.ArrayList;
import java.util.List;
@@ -99,7 +100,6 @@
     * 二级分类、标签
     * 
     * @param acceptData
     * @param gcid
     * @param out
     */
    @RequestMapping(value = "listSubMap", method = RequestMethod.POST)
@@ -167,7 +167,7 @@
            filter.setPageSize(pageSize);
            filter.setCateIds(taoBaoCatIds);
            JSONObject result = taoKeGoodsService.searchWuLiaoV2(filter,acceptData.getPlatform(),acceptData.getVersion());
            JSONObject result = taoKeGoodsService.searchWuLiaoV2(filter,acceptData.getPlatform(),acceptData.getVersion(), acceptData.getSystem());
            out.print(JsonUtil.loadTrueResult(result));
            return;
        }
@@ -176,7 +176,7 @@
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                acceptData.getVersion());
                acceptData.getVersion(),acceptData.getSystem());
        
        // 精选库数据
        JSONArray array = new JSONArray();
@@ -292,7 +292,7 @@
                JSONArray array = new JSONArray();
                if (resultGoodsList != null) {
                    ConfigParamsDTO paramsDTO =  orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                            acceptData.getVersion());
                            acceptData.getVersion(),acceptData.getSystem());
                    for (TaoBaoGoodsBrief goods : resultGoodsList) {
                        GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO);
                        array.add(gson2.toJson(goodsDetailVO));
@@ -316,7 +316,7 @@
                taoKeGoodsService.setSearchFilter(searchfilter, filter, order, startprice, endprice, fastFilter,
                        totalSales);
                JSONObject result = taoKeGoodsService.searchWuLiaoV2(searchfilter,acceptData.getPlatform(),acceptData.getVersion());
                JSONObject result = taoKeGoodsService.searchWuLiaoV2(searchfilter,acceptData.getPlatform(),acceptData.getVersion(),acceptData.getSystem());
                out.print(JsonUtil.loadTrueResult(result));
                return;
            }
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -9,6 +9,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.json.simple.JSONArray;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -226,7 +227,7 @@
    @Resource
    private HongBaoManageService hongBaoManageService;
    private ConfigParamsDTO getParamsDTO(String platform, String version, Long uid) {
    private ConfigParamsDTO getParamsDTO(String platform, String version, Long uid, SystemEnum system) {
        UserLevelEnum level = UserLevelEnum.daRen;
        if (uid != null && uid > 0) {
            level = userLevelManager.getUserLevel(uid);
@@ -237,7 +238,8 @@
        }
        if (level == null)
            level = UserLevelEnum.daRen;
        return orderHongBaoMoneyComputeService.getShowComputeRate(platform, version, level);
        return orderHongBaoMoneyComputeService.getShowComputeRate(platform, version, level,system);
    }
    private TaoBaoGoodsBrief filterDaTaoKeGoodsInfo(TaoBaoGoodsBrief goods) {
@@ -289,7 +291,7 @@
        }
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
@@ -447,14 +449,14 @@
            LogHelper.errorDetailInfo(e);
        }
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid,acceptData.getSystem());
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(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));
                    hongBaoManageService.getShareRate(UserLevelEnum.superVIP,acceptData.getSystem()), true));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
@@ -696,7 +698,7 @@
        // uid=2255993L;
        // 系统验证
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
@@ -722,13 +724,13 @@
        // 保存缓存
        jdGoodsCacheUtil.saveGoodsInfo(jdGoods);
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid,acceptData.getSystem());
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem()));
        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)));
                    + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getShareRate(UserLevelEnum.superVIP,acceptData.getSystem())));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
@@ -752,12 +754,12 @@
                    jdGoods.setCommissionPlus(threeClass.getSelfComm());
                    // plus返利
                    BigDecimal fanliMoneyPlus = JDUtil.getGoodsFanLiMoneyPlus(jdGoods,
                            hongBaoManageService.getFanLiRate());
                            hongBaoManageService.getFanLiRate(acceptData.getSystem()));
                    otherInfo.setFanliMoneyPlus("京东plus返¥" + fanliMoneyPlus);
                    // 使用奖励券最高返
                    if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
                        maxMoneyPlus = "(京东plus返¥" + JDUtil.getGoodsFanLiMoneyPlus(jdGoods,
                                hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)) + ")";
                                hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem())) + ")";
                    } else
                        maxMoneyPlus = "(京东plus最高返¥"
                                + fanliMoneyPlus.add(MoneyBigDecimalUtil.mul(fanliMoneyPlus, Constant.MAX_REWARD_RATE))
@@ -924,7 +926,7 @@
    public void getDetialPDD(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
        // 系统验证
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
@@ -936,14 +938,14 @@
            return;
        }
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid,acceptData.getSystem());
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem()));
        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)));
                    hongBaoManageService.getShareRate(UserLevelEnum.superVIP,acceptData.getSystem())));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
@@ -1122,7 +1124,7 @@
    public void getDetialVIP(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
        // 系统验证
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
@@ -1134,14 +1136,14 @@
            return;
        }
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid,acceptData.getSystem());
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem()));
        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)));
                    hongBaoManageService.getShareRate(UserLevelEnum.superVIP,acceptData.getSystem())));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
@@ -1251,7 +1253,7 @@
    public void getDetialSuning(AcceptData acceptData, String id, Long uid, String from, PrintWriter out) {
        // 系统验证
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
                acceptData.getPackages(),acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
@@ -1266,14 +1268,14 @@
            return;
        }
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid,acceptData.getSystem());
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem()));
        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)));
                    hongBaoManageService.getShareRate(UserLevelEnum.superVIP,acceptData.getSystem())));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
@@ -1464,7 +1466,7 @@
                    list = list.subList(0, 10);
                }
                ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null);
                ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null,acceptData.getSystem());
                List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
                for (JDGoods goods : list) {
@@ -1506,7 +1508,7 @@
                            }
                            ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(),
                                    null);
                                    null,acceptData.getSystem());
                            for (PDDGoodsDetail goods : goodsList) {
                                listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO));
                            }
@@ -1552,7 +1554,7 @@
                if (resultList != null) {
                    if (resultList != null && resultList.size() > 0) {
                        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                                acceptData.getVersion());
                                acceptData.getVersion(),acceptData.getSystem());
                        for (SuningGoodsInfo goods : resultList) {
                            GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertSuningGoods(goods, paramsDTO);
@@ -1575,7 +1577,7 @@
            }
            List<GoodsDetailVO> listExtra = new ArrayList<GoodsDetailVO>();
            ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null);
            ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null,acceptData.getSystem());
            goodsList.parallelStream().forEach(goods -> {
                if (goods != null) {
                    listExtra.add(GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO));
@@ -1940,9 +1942,9 @@
        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(acceptData.getSystem()),
                hongBaoManageService.getShareRate(acceptData.getSystem()), new BigDecimal(80),
                hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem()));
        if (tbGoodsList.size() > 0) {
            List<TaoBaoGoodsBrief> goodsList = null;
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/HotSellControllerV2.java
@@ -98,7 +98,7 @@
            List<GoodsDetailVO> list = new ArrayList<GoodsDetailVO>();
            if (detailList != null) {
                ConfigParamsDTO paramsDTO =  orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                for (DaTaoKeDetailV2 detail : detailList) {
                    TaoBaoGoodsBrief taoBaoGoodsBrief = TaoBaoUtil.convert(detail);
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/JingDongControllerV2.java
@@ -118,7 +118,7 @@
            JSONArray array = new JSONArray();
            if (goodsList != null && goodsList.size() > 0) {
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                        .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/PinDuoDuoControllerV2.java
@@ -109,7 +109,7 @@
            if (goodsList != null && goodsList.size() > 0) {
                Gson gson = JsonUtil.getApiCommonGson();
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                for (PDDGoodsDetail goods : goodsList) {
                    GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO);
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java
@@ -282,7 +282,7 @@
            /* 遍历列表数据 */
            ConfigParamsDTO configParamsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                    acceptData.getVersion());
                    acceptData.getVersion(),acceptData.getSystem());
            for (DaTaoKeDetailV2 detail : listGoods) {
                TaoBaoGoodsBrief taoBaoGoodsBrief = TaoBaoUtil.convert(detail);
@@ -409,7 +409,7 @@
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        if (detailList != null) {
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                    acceptData.getVersion());
                    acceptData.getVersion(),acceptData.getSystem());
            for (DaTaoKeDetailV2 detail : detailList) {
                array.add(gson.toJson(GoodsDetailVOFactory.convertTaoBao(TaoBaoUtil.convert(detail), paramsDTO)));
@@ -552,7 +552,7 @@
            }
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                    acceptData.getVersion());
                    acceptData.getVersion(),acceptData.getSystem());
            for (TaoBaoGoodsBrief goods : goodsList) {
                GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO);
@@ -571,7 +571,7 @@
                if (list != null && list.size() > 0) {
                    BigDecimal rateBuy = TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE;
                    ConfigParamsDTO paramsBuy = new ConfigParamsDTO(rateBuy, rateBuy, Constant.MAX_REWARD_RATE,
                            hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP));
                            hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem()));
                    for (int i = list.size() - 1; i >= 0; i--) {
                        TLJBuyGoods goods = list.get(i);
                        GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(goods.getGoods(), paramsBuy);
@@ -628,7 +628,7 @@
                    // 设备推荐
                    if (gList != null) {
                        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                                acceptData.getVersion());
                                acceptData.getVersion(),acceptData.getSystem());
                        for (TaoBaoGoodsBrief goods : gList) {
                            if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null
                                    && goods.getCouponAmount().compareTo(new BigDecimal("5")) >= 0
@@ -663,10 +663,10 @@
                    }
                }
            }
            JSONArray localArray = qualityGoodsService.getRecommendToIndexV2((page - 1) * pageSize, pageSize,acceptData.getPlatform(),acceptData.getVersion());
            JSONArray localArray = qualityGoodsService.getRecommendToIndexV2((page - 1) * pageSize, pageSize,acceptData.getPlatform(),acceptData.getVersion(),acceptData.getSystem());
            array.addAll(localArray);
        } else {// 从精选库来
            array = qualityGoodsService.getRecommendToIndexV2((page - 1) * pageSize, pageSize,acceptData.getPlatform(),acceptData.getVersion());
            array = qualityGoodsService.getRecommendToIndexV2((page - 1) * pageSize, pageSize,acceptData.getPlatform(),acceptData.getVersion(),acceptData.getSystem());
            if (array == null) {
                out.print(JsonUtil.loadFalseResult("没有更多了"));
                return;
@@ -700,7 +700,7 @@
            List<JDGoods> goodsList = result.getGoodsList();
            if (goodsList != null && goodsList.size() > 0) {
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                        .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
@@ -733,7 +733,7 @@
            List<PDDGoodsDetail> goodsList = result.getGoodsList();
            if (goodsList != null && goodsList.size() > 0) {
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                for (PDDGoodsDetail goods : goodsList) {
                    GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO);
@@ -767,7 +767,7 @@
            if (arrayKeys != null && arrayKeys.size() > 0) {
                count = arrayKeys.size();
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                int j = 1;
                for (int i = (page - 1) * 3; i < arrayKeys.size(); i++) {
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
@@ -292,7 +292,7 @@
                                                        GoodsDetailVOFactory.convertCommonGoods(goods,
                                                                orderHongBaoMoneyComputeService.getShowComputeRate(
                                                                        acceptData.getPlatform(),
                                                                        acceptData.getVersion()))));
                                                                        acceptData.getVersion(),acceptData.getSystem()))));
                                        // 跳转详情
                                        if (VersionUtil.greaterThan_2_1_3(acceptData.getPlatform(),
                                                acceptData.getVersion())) {
@@ -312,7 +312,7 @@
                                                    GoodsDetailVOFactory.convertCommonGoods(goods,
                                                            orderHongBaoMoneyComputeService.getShowComputeRate(
                                                                    acceptData.getPlatform(),
                                                                    acceptData.getVersion()))));
                                                                    acceptData.getVersion(),acceptData.getSystem()))));
                                    // if
                                    // (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(),
                                    // acceptData.getVersion())) {
@@ -696,7 +696,7 @@
        List<GoodsDetailVO> list = new ArrayList<GoodsDetailVO>();
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                acceptData.getVersion());
                acceptData.getVersion(),acceptData.getSystem());
        for (TaoBaoGoodsBrief goods : taoBaoGoodsBriefs) {
            list.add(GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO));
@@ -717,14 +717,14 @@
                BrandInfoVO brandInfoVO = null;
                try {
                    brandInfoVO = brandInfoService.listByAlikeName(key, acceptData.getPlatform(),
                            acceptData.getVersion());
                            acceptData.getVersion(),acceptData.getSystem());
                } catch (Exception e) {
                }
                if (brandInfoVO != null)
                    data.put("shop", JsonUtil.getApiCommonGson().toJson(brandInfoVO));
            } else {
                List<TaoBaoShopVO> listShop = taoBaoShopService.getShopByKeyV2(key, acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                if (listShop != null && listShop.size() > 0 && listShop.get(0).getListGoodsVO() != null
                        && listShop.get(0).getListGoodsVO().size() > 2) {
                    TaoBaoShopVO taoBaoShop = listShop.get(0);
@@ -912,7 +912,7 @@
                Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                        .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                for (JDGoods goods : goodsList) {
                    GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO);
                    if (hasCoupon) {
@@ -994,7 +994,7 @@
            List<PDDGoodsDetail> goodsList = result.getGoodsList();
            if (goodsList != null && goodsList.size() > 0) {
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                for (PDDGoodsDetail goods : goodsList) {
                    GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO);
@@ -1072,7 +1072,7 @@
            List<VIPGoodsInfo> goodsList = result.getGoodsList();
            if (goodsList != null && goodsList.size() > 0) {
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                for (VIPGoodsInfo goods : goodsList) {
                    GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertVIPGoods(goods, paramsDTO);
@@ -1176,7 +1176,7 @@
            Gson gson = JsonUtil.getApiCommonGson();
            if (resultList != null && resultList.size() > 0) {
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                for (SuningGoodsInfo goods : resultList) {
                    GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertSuningGoods(goods, paramsDTO);
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
@@ -452,7 +452,7 @@
            shareInfo.setNotifyDesc(configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(),system));
            // 添加分享记录
            BigDecimal rate = hongBaoManageService.getShareRate();
            BigDecimal rate = hongBaoManageService.getShareRate(acceptData.getSystem());
            BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(goods, rate);
            shareInfo.setShareMoney("¥" + shareMoney.toString());
            try {
@@ -512,7 +512,7 @@
            TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(uid, goodsId, relationId,null);
            if (taoBaoLink != null && taoBaoLink.getGoods() != null && needGoods) {
                ConfigParamsDTO dto = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version);
                ConfigParamsDTO dto = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version,acceptData.getSystem());
                GoodsDetailVO goodsInfo = GoodsDetailVOFactory.convertTaoBao(taoBaoLink.getGoods(), dto);
                shareInfo.setGoodsInfo(goodsInfo);
            }
@@ -605,7 +605,7 @@
            shareInfo.setNotifyDesc(configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(),system));
            // 分享金额
            BigDecimal rate = hongBaoManageService.getShareRate();
            BigDecimal rate = hongBaoManageService.getShareRate(acceptData.getSystem());
            BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
            shareInfo.setShareMoney("¥" + shareMoney.toString());
@@ -671,7 +671,7 @@
            // 设置评论文本选项
            shareInfo.setCommentTextChoiceList(
                    getCommentChoiceList(shareInfo.getCommentText(), null, inviteCode, TaoBaoUtil.getGoodsHongBaoMoney(
                            taoBaoLink.getGoods(), hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP), false)));
                            taoBaoLink.getGoods(), hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem()), false)));
            out.print(JsonUtil.loadTrueResult(
                    JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo)));
@@ -751,7 +751,7 @@
        if (needGoods)
            shareInfo.setGoodsInfo(GoodsDetailVOFactory.convertJDGoods(jdGoods, orderHongBaoMoneyComputeService
                    .getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion())));
                    .getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion(),acceptData.getSystem())));
        boolean hasCoupon = false;
        if (couponInfo != null) {
@@ -782,7 +782,7 @@
        shareInfo.setNotifyDesc(configService.getValue(ConfigKeyEnum.goodsShareNotifyJD.getKey(),SystemInfoUtil.getSystem(acceptData)));
        // 添加分享记录
        BigDecimal shareRate = hongBaoManageService.getShareRate();
        BigDecimal shareRate = hongBaoManageService.getShareRate(acceptData.getSystem());
        BigDecimal shareMoney = JDUtil.getGoodsFanLiMoney(jdGoods, shareRate);
        shareInfo.setShareMoney("¥" + shareMoney.toString());
        try {
@@ -840,7 +840,7 @@
        // 设置评论文本选项
        shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode,
                JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
                JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem()))));
        out.print(JsonUtil.loadTrueResult(
                JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo)));
@@ -916,9 +916,9 @@
        if (needGoods) {
            shareInfo
                    .setGoodsInfo(GoodsDetailVOFactory.convertPDDGoods(goods,
                            new ConfigParamsDTO(hongBaoManageService.getFanLiRate(),
                                    hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE,
                                    hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
                            new ConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()),
                                    hongBaoManageService.getShareRate(acceptData.getSystem()), Constant.MAX_REWARD_RATE,
                                    hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem()))));
        }
        // 创建口令
@@ -953,7 +953,7 @@
        shareInfo.setNotifyDesc(configService.getValue(ConfigKeyEnum.goodsShareNotifyPDD.getKey(),system));
        // 添加分享记录
        BigDecimal shareRate = hongBaoManageService.getShareRate();
        BigDecimal shareRate = hongBaoManageService.getShareRate(acceptData.getSystem());
        BigDecimal shareMoney = PinDuoDuoUtil.getGoodsFanLiMoney(goods, shareRate);
        shareInfo.setShareMoney("¥" + shareMoney.toString());
@@ -1015,7 +1015,7 @@
        // 设置评论文本选项
        shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode,
                PinDuoDuoUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
                PinDuoDuoUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem()))));
        out.print(JsonUtil.loadTrueResult(
                JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo)));
@@ -1084,9 +1084,9 @@
        if (needGoods) {
            shareInfo
                    .setGoodsInfo(GoodsDetailVOFactory.convertVIPGoods(goods,
                            new ConfigParamsDTO(hongBaoManageService.getFanLiRate(),
                                    hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE,
                                    hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
                            new ConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()),
                                    hongBaoManageService.getShareRate(acceptData.getSystem()), Constant.MAX_REWARD_RATE,
                                    hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem()))));
        }
        String template = shareGoodsTextTemplateService.getTextTemplateByVIP(uid);
@@ -1108,7 +1108,7 @@
        shareInfo.setNotifyDesc(configService.getValue(ConfigKeyEnum.goodsShareNotifyVIP.getKey(),system));
        // 添加分享记录
        BigDecimal shareRate = hongBaoManageService.getShareRate();
        BigDecimal shareRate = hongBaoManageService.getShareRate(acceptData.getSystem());
        BigDecimal shareMoney = VipShopUtil.getGoodsFanLiMoney(goods, shareRate);
        shareInfo.setShareMoney("¥" + shareMoney.toString());
@@ -1144,7 +1144,7 @@
        // 设置评论文本选项
        shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode,
                VipShopUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
                VipShopUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem()))));
        out.print(JsonUtil.loadTrueResult(
                JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo)));
@@ -1219,9 +1219,9 @@
        if (needGoods) {
            shareInfo
                    .setGoodsInfo(GoodsDetailVOFactory.convertSuningGoods(goods,
                            new ConfigParamsDTO(hongBaoManageService.getFanLiRate(),
                                    hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE,
                                    hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
                            new ConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()),
                                    hongBaoManageService.getShareRate(acceptData.getSystem()), Constant.MAX_REWARD_RATE,
                                    hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem()))));
        }
        String template = shareGoodsTextTemplateService.getTextTemplateBySuNing(uid);
@@ -1251,7 +1251,7 @@
        shareInfo.setNotifyDesc(configService.getValue(ConfigKeyEnum.goodsShareNotifySuning.getKey(),system));
        // 添加分享记录
        BigDecimal shareRate = hongBaoManageService.getShareRate();
        BigDecimal shareRate = hongBaoManageService.getShareRate(acceptData.getSystem());
        BigDecimal shareMoney = SuningUtil.getGoodsFanLiMoney(goods, shareRate);
        shareInfo.setShareMoney("¥" + shareMoney.toString());
@@ -1325,7 +1325,7 @@
        // 设置评论文本选项
        shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode,
                SuningUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
                SuningUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem()))));
        out.print(JsonUtil.loadTrueResult(
                JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo)));
@@ -1846,7 +1846,7 @@
        }
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                acceptData.getVersion());
                acceptData.getVersion(),acceptData.getSystem());
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
@@ -1918,8 +1918,8 @@
        GoodsDetailVO goodsDetail = null;
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                acceptData.getVersion());
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
                acceptData.getVersion(),acceptData.getSystem());
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem()));
        if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
            TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(Long.parseLong(goodsId));
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareStorageControllerV2.java
@@ -211,7 +211,7 @@
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        ConfigParamsDTO paramsDTO =  orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                acceptData.getVersion());
                acceptData.getVersion(),acceptData.getSystem());
        for (UserGoodsStorage userGoodsStorage : listStorage) {
            CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SuningControllerV2.java
@@ -97,7 +97,7 @@
            JSONArray array = new JSONArray();
            if (goodsList != null && goodsList.size() > 0) {
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                        .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java
@@ -418,7 +418,7 @@
            }
        }
        BigDecimal proportion = hongBaoManageService.getTLJShareRate(System.currentTimeMillis());
        BigDecimal proportion = hongBaoManageService.getTLJShareRate(System.currentTimeMillis(),acceptData.getSystem());
        for (ShareHotGoods hotGoods : listHot) {
            TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods();
            if (taoBaoGoodsBrief == null) {
@@ -493,7 +493,7 @@
        }
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                acceptData.getVersion());
                acceptData.getVersion(),acceptData.getSystem());
        for (ShareHotGoods hotGoods : listHot) {
            TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods();
@@ -652,7 +652,7 @@
        BigDecimal proportion = TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE;
        ConfigParamsDTO paramsDTO = new ConfigParamsDTO(proportion, proportion, Constant.MAX_REWARD_RATE,
                hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP));
                hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem()));
        for (TLJBuyGoods hotGoods : listHot) {
            TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods();
            if (taoBaoGoodsBrief == null) {
@@ -793,7 +793,7 @@
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                acceptData.getVersion());
                acceptData.getVersion(),acceptData.getSystem());
        for (TLJFreeBuyGoods freeGoods : listFree) {
            TaoBaoGoodsBrief goods = freeGoods.getGoods();
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserAccountControllerV2.java
@@ -13,6 +13,8 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.yeshi.fanli.entity.SystemFunction;
import com.yeshi.fanli.util.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -84,921 +86,880 @@
import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.ThreadUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.account.UserUtil;
import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
import com.yeshi.fanli.util.user.UserLevelUtil;
import com.yeshi.fanli.vo.user.UserVipRateVO;
import net.sf.json.JSONObject;
import org.yeshi.utils.SystemUtil;
import org.yeshi.utils.entity.ProxyIP;
/**
 * 账户系统
 *
 * @author Administrator
 *
 * @author Administrator
 */
@Controller
@RequestMapping("api/v2/user")
public class UserAccountControllerV2 {
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private BusinessSystemService businessSystemService;
    @Resource
    private BusinessSystemService businessSystemService;
    @Resource
    private ShamUserService shamUserService;
    @Resource
    private ThreeSaleSerivce threeSaleSerivce;
    @Resource
    private ThreeSaleSerivce threeSaleSerivce;
    @Resource
    private LostOrderService lostOrderService;
    @Resource
    private UserAccountService userAccountService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private RedisManager redisManager;
    @Resource
    private UserAccountService userAccountService;
    @Resource
    private RedisManager redisManager;
    @Resource
    private DeviceTokenOPPOService deviceTokenOPPOService;
    @Resource
    private TBPidService tbPidService;
    @Resource
    private DeviceTokenXMService deviceTokenXMService;
    @Resource
    private DeviceTokenHWService deviceTokenHWService;
    @Resource
    private DeviceTokenVIVOService deviceTokenVIVOService;
    @Resource
    private DeviceTokenOPPOService deviceTokenOPPOService;
    @Resource
    private HomeNavbarUserService homeNavbarUserService;
    @Resource
    private DeviceTokenXMService deviceTokenXMService;
    @Resource
    private DeviceTokenVIVOService deviceTokenVIVOService;
    @Resource
    private DeviceActiveService deviceActiveService;
    @Resource
    private TaoBaoUnionConfigService taoBaoUnionConfigService;
    @Resource
    private BindRemindService bindRemindService;
    @Resource
    private SpreadUserImgService spreadUserImgService;
    @Resource
    private UserVIPInfoService userVIPInfoService;
    @Resource
    private UserShareGoodsRecordService userShareGoodsRecordService;
    @Resource
    private HongBaoV2CountService hongBaoV2CountService;
    @Resource
    private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService;
    @Resource
    private IntegralDetailService integralDetailService;
    @Resource
    private UserSystemCouponService userSystemCouponService;
    @Resource
    private BanLiShopOrderService banLiShopOrderService;
    @Resource
    private UserMoneyService userMoneyService;
    @Resource
    private ConfigService configService;
    @Resource
    private UserAccountBindingHistoryService userAccountBindingHistoryService;
    @Resource
    private UserVipConfigService userVipConfigService;
    @Resource
    private HomeNavbarUserService homeNavbarUserService;
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @Resource
    private UserInfoDeleteRecordService userInfoDeleteRecordService;
    @Resource
    private UserMoneyDetailService userMoneyDetailService;
    @Resource
    private UserTaoLiJinOriginService userTaoLiJinOriginService;
    @Resource
    private UserInviteService userInviteService;
    @Resource
    private UserInfoModifyRecordService userInfoModifyRecordService;
    @Resource
    private UserInviteValidNumService userInviteValidNumService;
    @Resource
    private DeviceActiveService deviceActiveService;
    @Resource
    private CommonOrderService commonOrderService;
    @Resource
    private BindRemindService bindRemindService;
    @Resource
    private TearcherService tearcherService;
    @Resource
    private UserVIPInfoService userVIPInfoService;
    @Resource
    private UserVIPPreInfoService userVIPPreInfoService;
    @Resource
    private HongBaoV2CountService hongBaoV2CountService;
    @Resource
    private HongBaoV2Service hongBaoV2Service;
    @Resource
    private IntegralDetailService integralDetailService;
    @Resource
    private OrderMoneyDailyCountService orderMoneyDailyCountService;
    @Resource
    private BanLiShopOrderService banLiShopOrderService;
    @Resource
    private ConfigService configService;
    /**
     * 新版登录 V1.5.3
     *
     * @param acceptData
     * @param vcode
     * @param phone
     * @param code
     * @param loginType  登录方式: 1-手机登录 2-微信登录
     * @param request
     * @param out
     */
    @RequestMapping(value = "login", method = RequestMethod.POST)
    public void login(AcceptData acceptData, int loginType, String vcode, String phone, String code,
                      HttpServletRequest request, PrintWriter out) {
        try {
            BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                    acceptData.getPackages(), acceptData.getSystem());
            if (system == null) {
                out.print(JsonUtil.loadFalseResult("系统不存在"));
                return;
            }
    @Resource
    private UserVipConfigService userVipConfigService;
            UserInfo userInfo = null;
            // 手机登录
            if (loginType == 1) {
                userInfo = userAccountService.loginPhone(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, vcode, phone, system);
            }
    @Resource
    private UserInfoExtraService userInfoExtraService;
            // 微信登录
            if (loginType == 2) {
                //需要绑定电话号码
                if (SystemInfoUtil.hasFunctions(system.getSystem(), SystemFunction.bindPhone))
                    userInfo = userAccountService.loginWeiXinNew(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, code, system);
                    //不需要绑定电话号码
                else
                    userInfo = userAccountService.loginWeiXin(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, code, system);
            }
    @Resource
    private UserMoneyDetailService userMoneyDetailService;
            if (userInfo == null) {
                out.print(JsonUtil.loadFalseResult("登录失败"));
            } else {
                JSONObject data = new JSONObject();
                data.put("userInfo", UserUtil.filterForClientUser(userInfo));
                data.put("inviteCode", userInfoExtraService.getInviteCodeByUid(userInfo.getId()));
                out.print(JsonUtil.loadTrueResult(data));
    @Resource
    private UserInviteService userInviteService;
                final UserInfo uuser = userInfo;
                ThreadUtil.run(new Runnable() {
                    public void run() {
                        String device = acceptData.getDevice();
                        try {
                            // 同步自定义导航
                            homeNavbarUserService.synchroDeviceToUser(uuser.getId(), device);
                        } catch (Exception e) {
                            LogHelper.errorDetailInfo(e);
                        }
    @Resource
    private UserInviteValidNumService userInviteValidNumService;
                        // 绑定oppo,VIVO推送
                        DeviceActive active = deviceActiveService.getFirstActiveInfo(acceptData.getDevice());
                        if (active != null) {
                            deviceTokenOPPOService.bindUid(uuser.getId(), active.getId());
                            deviceTokenVIVOService.bindUid(uuser.getId(), active.getId());
                            deviceTokenXMService.bindUid(active.getId(), uuser.getId());
                        }
                    }
                });
            }
    @Resource
    private CommonOrderService commonOrderService;
        } catch (UserAccountException e) {
            int errorCode = e.getCode();
            if (errorCode == 101) { // 需要绑定手机号
                JSONObject data = new JSONObject();
                data.put("key", e.getMsg());
                JSONObject object = new JSONObject();
                object.put("code", errorCode);
                object.put("data", data);
                out.print(object.toString());
            } else if (errorCode == 102) { // 需要绑定微信号
                JSONObject data = new JSONObject();
                data.put("key", e.getMsg());
                JSONObject object = new JSONObject();
                object.put("code", errorCode);
                object.put("data", data);
                out.print(object.toString());
            } else {
                out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
                try {
                    LogHelper.error("登录出错:" + e.getCode() + "-" + e.getMessage());
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
    @Resource
    private TearcherService tearcherService;
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("登录失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    @Resource
    private UserVIPPreInfoService userVIPPreInfoService;
    /**
     * 绑定电话号码 V2.0.1 微信登录
     *
     * @param acceptData
     * @param vcode
     * @param phone
     * @param out
     */
    @RequestSerializableByKey(key = "'bindPhoneLogin-'+#phone")
    @RequestMapping(value = "bindPhoneLogin")
    public void bindPhoneLogin(AcceptData acceptData, String vcode, String phone, String key,
                               HttpServletRequest request, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages(), acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
    @Resource
    private HongBaoV2Service hongBaoV2Service;
    @Resource
    private OrderMoneyDailyCountService orderMoneyDailyCountService;
        if (StringUtil.isNullOrEmpty(vcode)) {
            out.print(JsonUtil.loadFalseResult("验证码不能为空"));
            return;
        }
    /**
     * 新版登录 V1.5.3
     *
     * @param acceptData
     * @param vcode
     * @param phone
     * @param code
     * @param loginType
     *            登录方式: 1-手机登录 2-微信登录
     * @param request
     * @param out
     */
    @RequestMapping(value = "login", method = RequestMethod.POST)
    public void login(AcceptData acceptData, int loginType, String vcode, String phone, String code,
            HttpServletRequest request, PrintWriter out) {
        try {
            BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                    acceptData.getPackages());
            if (system == null) {
                out.print(JsonUtil.loadFalseResult("系统不存在"));
                return;
            }
        if (StringUtil.isNullOrEmpty(phone)) {
            out.print(JsonUtil.loadFalseResult("电话号码不能为空"));
            return;
        }
            UserInfo userInfo = null;
            // 手机登录
            if (loginType == 1) {
                userInfo = userAccountService.loginPhone(new ProxyIP(request.getRemoteHost(),request.getRemotePort()),acceptData, loginType, vcode, phone, system.getAppid());
            }
        if (StringUtil.isNullOrEmpty(key)) {
            out.print(JsonUtil.loadFalseResult("key值不能为空"));
            return;
        }
            // 微信登录
            if (loginType == 2) {
                userInfo = userAccountService.loginWeiXinNew(new ProxyIP(request.getRemoteHost(),request.getRemotePort()), acceptData, loginType, code, system.getAppid());
            }
        phone = phone.replaceAll(" ", "");
            if (userInfo == null) {
                out.print(JsonUtil.loadFalseResult("登录失败"));
            } else {
                JSONObject data = new JSONObject();
                data.put("userInfo", UserUtil.filterForClientUser(userInfo));
                data.put("inviteCode", userInfoExtraService.getInviteCodeByUid(userInfo.getId()));
                out.print(JsonUtil.loadTrueResult(data));
        String oldVCode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_BIND);
        if (Constant.IS_OUTNET) {
            if (!vcode.equalsIgnoreCase(oldVCode)) {
                out.print(JsonUtil.loadFalseResult(9001, "验证码错误,重新输入"));
                return;
            }
            redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_BIND);
        }
                final UserInfo uuser = userInfo;
                ThreadUtil.run(new Runnable() {
                    public void run() {
                        String device = acceptData.getDevice();
                        try {
                            // 同步自定义导航
                            homeNavbarUserService.synchroDeviceToUser(uuser.getId(), device);
                        } catch (Exception e) {
                            LogHelper.errorDetailInfo(e);
                        }
        try {
            UserInfo userInfo = userAccountService.bindPhoneToLogin(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), acceptData, phone, key);
                        // 绑定oppo,VIVO推送
                        DeviceActive active = deviceActiveService.getFirstActiveInfo(acceptData.getDevice());
                        if (active != null) {
                            deviceTokenOPPOService.bindUid(uuser.getId(), active.getId());
                            deviceTokenVIVOService.bindUid(uuser.getId(), active.getId());
                            deviceTokenXMService.bindUid(active.getId(), uuser.getId());
                        }
                    }
                });
            }
            JSONObject data = new JSONObject();
            data.put("userInfo", UserUtil.filterForClientUser(userInfo));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult(1, "绑定失败"));
        }
    }
        } catch (UserAccountException e) {
            int errorCode = e.getCode();
            if (errorCode == 101) { // 需要绑定手机号
                JSONObject data = new JSONObject();
                data.put("key", e.getMsg());
                JSONObject object = new JSONObject();
                object.put("code", errorCode);
                object.put("data", data);
                out.print(object.toString());
            } else if (errorCode == 102) { // 需要绑定微信号
                JSONObject data = new JSONObject();
                data.put("key", e.getMsg());
                JSONObject object = new JSONObject();
                object.put("code", errorCode);
                object.put("data", data);
                out.print(object.toString());
            } else {
                out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
                try {
                    LogHelper.error("登录出错:" + e.getCode() + "-" + e.getMessage());
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("登录失败"));
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    /**
     * 绑定微信V2.1.3 电话号码 登录
     *
     * @param acceptData
     * @param uid
     * @param code
     * @param key
     * @param request
     * @param out
     */
    @RequestSerializableByKey(key = "'bindWXLogin-'+#code")
    @RequestMapping(value = "bindWXLogin")
    public void bindWXLogin(AcceptData acceptData, Long uid, String code, String key, HttpServletRequest request,
                            PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages(), acceptData.getSystem());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
    /**
     * 绑定电话号码 V2.0.1 微信登录
     *
     * @param acceptData
     * @param vcode
     * @param phone
     * @param out
     */
    @RequestSerializableByKey(key = "'bindPhoneLogin-'+#phone")
    @RequestMapping(value = "bindPhoneLogin")
    public void bindPhoneLogin(AcceptData acceptData, String vcode, String phone, String key,
            HttpServletRequest request, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        if (StringUtil.isNullOrEmpty(code)) {
            out.print(JsonUtil.loadFalseResult("请上传code"));
            return;
        }
        if (StringUtil.isNullOrEmpty(vcode)) {
            out.print(JsonUtil.loadFalseResult("验证码不能为空"));
            return;
        }
        if (StringUtil.isNullOrEmpty(key)) {
            out.print(JsonUtil.loadFalseResult("key值不能为空"));
            return;
        }
        if (StringUtil.isNullOrEmpty(phone)) {
            out.print(JsonUtil.loadFalseResult("电话号码不能为空"));
            return;
        }
        try {
            UserInfo userInfo = userAccountService.bindWXToLogin(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), acceptData, code, system.getAppid(), key);
            JSONObject data = new JSONObject();
            data.put("userInfo", UserUtil.filterForClientUser(userInfo));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
        if (StringUtil.isNullOrEmpty(key)) {
            out.print(JsonUtil.loadFalseResult("key值不能为空"));
            return;
        }
    }
        phone = phone.replaceAll(" ", "");
        String oldVCode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_BIND);
        if (Constant.IS_OUTNET) {
            if (!vcode.equalsIgnoreCase(oldVCode)) {
                out.print(JsonUtil.loadFalseResult(9001, "验证码错误,重新输入"));
                return;
            }
            redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_BIND);
        }
    /**
     * 绑定电话号码 V2.0.1 微信登录
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "recordBind")
    public void recordBind(AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult("用户id为空"));
            return;
        }
        bindRemindService.addBindPhone(uid);
        out.print(JsonUtil.loadTrueResult("记录成功"));
    }
        try {
            UserInfo userInfo = userAccountService.bindPhoneToLogin(new ProxyIP(request.getRemoteHost(),request.getRemotePort()),acceptData, phone, key);
    /**
     * 获取vip信息
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "getVIPInfo")
    public void getVIPInfo(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
            JSONObject data = new JSONObject();
            data.put("userInfo", UserUtil.filterForClientUser(userInfo));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult(1, "绑定失败"));
        }
    }
        UserInfo userInfo = userInfoService.selectByPKey(uid);
        if (userInfo == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "该用户不存在"));
            return;
        }
        //
        String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
        UserVipRateVO vo = new UserVipRateVO();
        vo.setId(uid);
        vo.setInviteCode(inviteCode);
        vo.setNickName(userInfo.getNickName());
        vo.setPortrait(userInfo.getPortrait());
        vo.setHelpLink(userVipConfigService.getValueByKey("help_link_vip_h5"));
        vo.setCsdLink(configService.getValue(ConfigKeyEnum.customerServiceLink.getKey(), acceptData.getSystem()));
    /**
     * 绑定微信V2.1.3 电话号码 登录
     * @param acceptData
     * @param uid
     * @param code
     * @param key
     * @param request
     * @param out
     */
    @RequestSerializableByKey(key = "'bindWXLogin-'+#code")
    @RequestMapping(value = "bindWXLogin")
    public void bindWXLogin(AcceptData acceptData, Long uid, String code, String key, HttpServletRequest request,
            PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        Date now = new Date();
        Date start = new Date(0);
        if (StringUtil.isNullOrEmpty(code)) {
            out.print(JsonUtil.loadFalseResult("请上传code"));
            return;
        }
        // 返利订单、奖励券提成
        List<UserMoneyDetailTypeEnum> typeFanli = new ArrayList<>();
        typeFanli.add(UserMoneyDetailTypeEnum.fanli);
        typeFanli.add(UserMoneyDetailTypeEnum.orderReward);
        BigDecimal finishMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeFanli, start, now)
                .abs();
        if (StringUtil.isNullOrEmpty(key)) {
            out.print(JsonUtil.loadFalseResult("key值不能为空"));
            return;
        }
        // 邀请订单、分享订单、补贴
        List<UserMoneyDetailTypeEnum> typeList = new ArrayList<>();
        typeList.add(UserMoneyDetailTypeEnum.share);
        typeList.add(UserMoneyDetailTypeEnum.invite);
        typeList.add(UserMoneyDetailTypeEnum.inviteAndShare);
        typeList.add(UserMoneyDetailTypeEnum.systemEqualize);
        typeList.add(UserMoneyDetailTypeEnum.subsidy);
        BigDecimal rewardMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, start, now).abs();
        try {
            UserInfo userInfo = userAccountService.bindWXToLogin(new ProxyIP(request.getRemoteHost(),request.getRemotePort()), acceptData, code, system.getAppid(), key);
            JSONObject data = new JSONObject();
            data.put("userInfo", UserUtil.filterForClientUser(userInfo));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
        UserVIPInfo userVIPInfo = userVIPInfoService.selectByUid(uid);
        vo.setVipInfo(userVIPInfo);
        String leftTime = "";
        if (userVIPInfo != null && userVIPInfo.getApplyTime() != null) {
            // TODO 计算时间
            long s = 48 * 60 * 60 - ((System.currentTimeMillis() - userVIPInfo.getApplyTime().getTime()) / 1000);
            if (s > 3600) {
                leftTime = s / 3600 + "小时";
                leftTime = "还剩" + leftTime;
            } else if (s >= 60) {
                leftTime = s / 60 + "分钟";
                leftTime = "还剩" + leftTime;
            } else if (s > 0) {
                leftTime = s + "秒";
                leftTime = "还剩" + leftTime;
            }
        }
        vo.setLeftTime(leftTime);
    }
        if (userVIPInfo != null && userVIPInfo.getState() != null
                && userVIPInfo.getState() == UserVIPInfo.STATE_SUCCESS) { // VIP
            vo.setSuccessTime(TimeUtil.getGernalTime(userVIPInfo.getSuccessTime().getTime(), "yyyy.MM.dd"));
            vo.setConserveMoney(finishMoney);
            vo.setEarnMoney(rewardMoney);
        } else {
            BigDecimal rate = new BigDecimal("0.409");
            vo.setConserveMoney(MoneyBigDecimalUtil.mul2(finishMoney, rate));
            vo.setEarnMoney(MoneyBigDecimalUtil.mul2(rewardMoney, rate));
        }
        vo.setFinishMoney(hongBaoV2CountService.getRewardMoneyBySelf(uid));
        List<Integer> list = new ArrayList<Integer>();
        list.add(BanLiShopOrder.STATE_SUCCESS);
        BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay"));
    /**
     * 绑定电话号码 V2.0.1 微信登录
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "recordBind")
    public void recordBind(AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult("用户id为空"));
            return;
        }
        bindRemindService.addBindPhone(uid);
        out.print(JsonUtil.loadTrueResult("记录成功"));
    }
        vo.setFinishGoldCoin(Long.parseLong(integralDetailService.getCumulativeMoney(uid).setScale(0).toString()));
    /**
     * 获取vip信息
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "getVIPInfo")
    public void getVIPInfo(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        // vo.setFinishTeam(hongBaoV2CountService.countValidOrderTeamUserByUid(uid,
        // , payMoney));
        UserInfo userInfo = userInfoService.selectByPKey(uid);
        if (userInfo == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "该用户不存在"));
            return;
        }
        //
        String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
        int finishTeam = 0;
        long vipBegin = TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME);
        List<ThreeSale> listThreeSale = threeSaleSerivce.getValidWorkerIdsByTime(uid, vipBegin);
        if (listThreeSale != null && listThreeSale.size() > 0) {
            for (ThreeSale three : listThreeSale) {
                UserInfo worker = three.getWorker();
                if (worker == null || worker.getId() == null) {
                    continue;
                }
                // 1、邀请关系成功后;2、单(分享 + 自购)实付款大于1元
                long countValid = commonOrderService.countOrderByUidAndSettled(worker.getId(), payMoney);
                if (countValid > 0) {
                    finishTeam++;
                }
            }
        }
        vo.setFinishTeam(finishTeam);
        vo.setFinishHongBao(banLiShopOrderService.countByUidAndState(uid, list));
        UserVipRateVO vo = new UserVipRateVO();
        vo.setId(uid);
        vo.setInviteCode(inviteCode);
        vo.setNickName(userInfo.getNickName());
        vo.setPortrait(userInfo.getPortrait());
        vo.setHelpLink(userVipConfigService.getValueByKey("help_link_vip_h5"));
        vo.setCsdLink(configService.getValue(ConfigKeyEnum.customerServiceLink.getKey(),acceptData.getSystem()));
        // 区分老用户和新用户
        String limtDate = userVipConfigService.getValueByKey("vip_execute_time");
        Date executeDate = null;
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd");
            executeDate = format.parse(limtDate);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(uid);
        if (extra != null
                && (extra.getFirstLoginTime() == null || extra.getFirstLoginTime().getTime() < executeDate.getTime())) {
            vo.setLimitTeam(Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_old_user")));
        } else {
            vo.setLimitTeam(Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_new_user")));
        }
        vo.setLimitHongBao(Long.parseLong(userVipConfigService.getValueByKey("require_shop_buy")));
        vo.setLimitMoney(new BigDecimal(userVipConfigService.getValueByKey("require_fan_money")));
        vo.setLimitgoldCoin(Long.parseLong(userVipConfigService.getValueByKey("require_gold_coin")));
        Date now = new Date();
        Date start = new Date(0);
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() {
            @Override
            public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) {
                if (value == null) {
                    return new JsonPrimitive("");
                } else {
                    // 保留2位小数
                    value = value.setScale(2);
                    return new JsonPrimitive(value.toString());
                }
            }
        });
        Gson gson = gsonBuilder.create();
        if (!StringUtil.isNullOrEmpty(callback)) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(gson.toJson(vo))));
        } else {
            out.print(JsonUtil.loadTrueResult(gson.toJson(vo)));
        }
    }
    /**
     * 开通VIP
     *
     * @param callback
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "applyVip")
    public void applyVip(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        try {
            userVIPInfoService.applyVIP(uid);
        } catch (UserVIPInfoException e) {
            if (!StringUtil.isNullOrEmpty(callback)) {
                out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMsg())));
            } else {
                out.print(JsonUtil.loadFalseResult(e.getMsg()));
            }
            return;
        }
        if (!StringUtil.isNullOrEmpty(callback)) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("申请成功,正在受理中")));
        } else {
            out.print(JsonUtil.loadTrueResult("申请成功,正在受理中"));
        }
    }
    /**
     * 获取vip信息
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "getVIPInfoV2")
    public void getVIPInfoV2(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        // 用户信息
        UserInfo userInfo = userInfoService.selectByPKey(uid);
        if (userInfo == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "该用户不存在"));
            return;
        }
        // 获取等级
        UserInviteLevelEnum level = userInviteService.getUserInviteLevelNew(uid);
        // 达人
        long limitOrder = 0;
        long limitFirst = 0;
        long limitSecond = 0;
        if (level == UserInviteLevelEnum.actived || level == UserInviteLevelEnum.noActive) {
            String orderCount = userVipConfigService.getValueByKey("vip_pre_7_order_count");
            if (!StringUtil.isNullOrEmpty(orderCount)) {
                limitOrder = Long.parseLong(orderCount);
            }
            String first = userVipConfigService.getValueByKey("vip_pre_7_first_level_team_count");
            if (!StringUtil.isNullOrEmpty(first)) {
                limitFirst = Long.parseLong(first);
            }
            String second = userVipConfigService.getValueByKey("vip_pre_7_second_level_team_count");
            if (!StringUtil.isNullOrEmpty(second)) {
                limitSecond = Long.parseLong(second);
            }
        } else if (level == UserInviteLevelEnum.highVIP || level == UserInviteLevelEnum.vipApply) {
            String orderCount = userVipConfigService.getValueByKey("vip_pre_10_order_count");
            if (!StringUtil.isNullOrEmpty(orderCount)) {
                limitOrder = Long.parseLong(orderCount);
            }
            String first = userVipConfigService.getValueByKey("vip_pre_10_first_level_team_count");
            if (!StringUtil.isNullOrEmpty(first)) {
                limitFirst = Long.parseLong(first);
            }
            String second = userVipConfigService.getValueByKey("vip_pre_10_second_level_team_count");
            if (!StringUtil.isNullOrEmpty(second)) {
                limitSecond = Long.parseLong(second);
            }
        } else if (level == UserInviteLevelEnum.vip || level == UserInviteLevelEnum.tearcherApply) {
            // TODO 比例
        // 返利订单、奖励券提成
        List<UserMoneyDetailTypeEnum> typeFanli = new ArrayList<>();
        typeFanli.add(UserMoneyDetailTypeEnum.fanli);
        typeFanli.add(UserMoneyDetailTypeEnum.orderReward);
        BigDecimal finishMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeFanli, start, now)
                .abs();
        } else if (level == UserInviteLevelEnum.tearcher) {
            // TODO
        }
        // 邀请订单、分享订单、补贴
        List<UserMoneyDetailTypeEnum> typeList = new ArrayList<>();
        typeList.add(UserMoneyDetailTypeEnum.share);
        typeList.add(UserMoneyDetailTypeEnum.invite);
        typeList.add(UserMoneyDetailTypeEnum.inviteAndShare);
        typeList.add(UserMoneyDetailTypeEnum.systemEqualize);
        typeList.add(UserMoneyDetailTypeEnum.subsidy);
        BigDecimal rewardMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, start, now).abs();
        // 自购订单
        long doneOrder = hongBaoV2CountService.countMyDirectOrderByCashArrival(uid, Constant.VIP_ORDER_PAY);
        // 有效粉丝
        int doneFirst = 0;
        int doneSecond = 0;
        UserInviteValidNum userInviteValidNum = userInviteValidNumService.selectByPrimaryKey(uid);
        if (userInviteValidNum != null) {
            doneFirst = userInviteValidNum.getNumFirst() == null ? 0 : userInviteValidNum.getNumFirst();
            doneSecond = userInviteValidNum.getNumSecond() == null ? 0 : userInviteValidNum.getNumSecond();
        }
        UserVIPInfo userVIPInfo = userVIPInfoService.selectByUid(uid);
        vo.setVipInfo(userVIPInfo);
        String leftTime = "";
        if (userVIPInfo != null && userVIPInfo.getApplyTime() != null) {
            // TODO 计算时间
            long s = 48 * 60 * 60 - ((System.currentTimeMillis() - userVIPInfo.getApplyTime().getTime()) / 1000);
            if (s > 3600) {
                leftTime = s / 3600 + "小时";
                leftTime = "还剩" + leftTime;
            } else if (s >= 60) {
                leftTime = s / 60 + "分钟";
                leftTime = "还剩" + leftTime;
            } else if (s > 0) {
                leftTime = s + "秒";
                leftTime = "还剩" + leftTime;
            }
        }
        vo.setLeftTime(leftTime);
        Date now = new Date();
        Date start = new Date(0);
        // 省钱: ---返利订单、奖励券提成
        List<UserMoneyDetailTypeEnum> typeFanli = new ArrayList<>();
        typeFanli.add(UserMoneyDetailTypeEnum.fanli);
        typeFanli.add(UserMoneyDetailTypeEnum.orderReward);
        BigDecimal saveMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeFanli, start, now).abs();
        if (userVIPInfo != null && userVIPInfo.getState() != null
                && userVIPInfo.getState() == UserVIPInfo.STATE_SUCCESS) { // VIP
            vo.setSuccessTime(TimeUtil.getGernalTime(userVIPInfo.getSuccessTime().getTime(), "yyyy.MM.dd"));
            vo.setConserveMoney(finishMoney);
            vo.setEarnMoney(rewardMoney);
        } else {
            BigDecimal rate = new BigDecimal("0.409");
            vo.setConserveMoney(MoneyBigDecimalUtil.mul2(finishMoney, rate));
            vo.setEarnMoney(MoneyBigDecimalUtil.mul2(rewardMoney, rate));
        }
        vo.setFinishMoney(hongBaoV2CountService.getRewardMoneyBySelf(uid));
        // 赚钱: 邀请订单、分享订单、补贴
        List<UserMoneyDetailTypeEnum> typeList = new ArrayList<>();
        typeList.add(UserMoneyDetailTypeEnum.share);
        typeList.add(UserMoneyDetailTypeEnum.invite);
        typeList.add(UserMoneyDetailTypeEnum.inviteAndShare);
        typeList.add(UserMoneyDetailTypeEnum.systemEqualize);
        typeList.add(UserMoneyDetailTypeEnum.subsidy);
        BigDecimal earnMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, start, now).abs();
        if (level != UserInviteLevelEnum.vip) {
            BigDecimal rate = new BigDecimal("0.409");
            saveMoney = MoneyBigDecimalUtil.mul2(saveMoney, rate);
            earnMoney = MoneyBigDecimalUtil.mul2(earnMoney, rate);
        }
        List<Integer> list = new ArrayList<Integer>();
        list.add(BanLiShopOrder.STATE_SUCCESS);
        BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay"));
        String shareRate = "可享佣金的<label style=\"color:#E5005C;\">%s</label>";
        String teamRate = "最高佣金的<label style=\"color:#E5005C;\">%s</label>";
        // 达人版
        JSONObject jsonrRed1 = new JSONObject();
        jsonrRed1.put("enjoyRate", String.format(shareRate, "145%"));
        jsonrRed1.put("teamRate", String.format(teamRate, "25%"));
        jsonrRed1.put("teamIncome", "高级会员以上专属");
        vo.setFinishGoldCoin(Long.parseLong(integralDetailService.getCumulativeMoney(uid).setScale(0).toString()));
        // 高级会员
        JSONObject jsonrRed2 = new JSONObject();
        jsonrRed2.put("enjoyRate", String.format(shareRate, "195%"));
        jsonrRed2.put("teamRate", String.format(teamRate, "50%"));
        jsonrRed2.put("teamIncome", "享高级团队收益");
        // vo.setFinishTeam(hongBaoV2CountService.countValidOrderTeamUserByUid(uid,
        // , payMoney));
        // 超级会员
        JSONObject jsonrRed3 = new JSONObject();
        jsonrRed3.put("enjoyRate", String.format(shareRate, "210%"));
        jsonrRed3.put("teamRate", String.format(teamRate, "110%"));
        jsonrRed3.put("teamIncome", "享超级团队收益");
        int finishTeam = 0;
        long vipBegin = TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME);
        List<ThreeSale> listThreeSale = threeSaleSerivce.getValidWorkerIdsByTime(uid, vipBegin);
        if (listThreeSale != null && listThreeSale.size() > 0) {
            for (ThreeSale three : listThreeSale) {
                UserInfo worker = three.getWorker();
                if (worker == null || worker.getId() == null) {
                    continue;
                }
                // 1、邀请关系成功后;2、单(分享 + 自购)实付款大于1元
                long countValid = commonOrderService.countOrderByUidAndSettled(worker.getId(), payMoney);
                if (countValid > 0) {
                    finishTeam++;
                }
            }
        }
        vo.setFinishTeam(finishTeam);
        vo.setFinishHongBao(banLiShopOrderService.countByUidAndState(uid, list));
        JSONObject json = new JSONObject();
        json.put("level", level.name());
        json.put("nickName", userInfo.getNickName());
        json.put("portrait", userInfo.getPortrait());
        json.put("ruleLink", userVipConfigService.getValueByKey("help_link_vip_h5"));
        json.put("saveMoney", saveMoney);
        json.put("earnMoney", earnMoney);
        // 区分老用户和新用户
        String limtDate = userVipConfigService.getValueByKey("vip_execute_time");
        Date executeDate = null;
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd");
            executeDate = format.parse(limtDate);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(uid);
        if (extra != null
                && (extra.getFirstLoginTime() == null || extra.getFirstLoginTime().getTime() < executeDate.getTime())) {
            vo.setLimitTeam(Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_old_user")));
        } else {
            vo.setLimitTeam(Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_new_user")));
        }
        vo.setLimitHongBao(Long.parseLong(userVipConfigService.getValueByKey("require_shop_buy")));
        vo.setLimitMoney(new BigDecimal(userVipConfigService.getValueByKey("require_fan_money")));
        vo.setLimitgoldCoin(Long.parseLong(userVipConfigService.getValueByKey("require_gold_coin")));
        String tearcherWX = "";
        TearcherInfo tearcherInfo = tearcherService.selectByUid(uid);
        if (tearcherInfo != null && !StringUtil.isNullOrEmpty(tearcherInfo.getWxID())) {
            tearcherWX = tearcherInfo.getWxID();
        }
        json.put("tearcherWX", tearcherWX);
        json.put("tearcherTip", "我是你的导师,为你在省赚过程中解难答疑,对你一对一辅导,倾听你的需求总结并反馈给板栗快省官方运营团队,快来添加我吧。");
        json.put("newerGongLue", configService.getValue(ConfigKeyEnum.newerGonglue.getKey(), acceptData.getSystem()));
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() {
            @Override
            public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) {
                if (value == null) {
                    return new JsonPrimitive("");
                } else {
                    // 保留2位小数
                    value = value.setScale(2);
                    return new JsonPrimitive(value.toString());
                }
            }
        });
        Gson gson = gsonBuilder.create();
        // 已完成
        json.put("doneOrder", doneOrder);
        json.put("doneFirst", doneFirst);
        json.put("doneSecond", doneSecond);
        if (!StringUtil.isNullOrEmpty(callback)) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(gson.toJson(vo))));
        } else {
            out.print(JsonUtil.loadTrueResult(gson.toJson(vo)));
        }
    }
        // 标准
        json.put("limitOrder", limitOrder);
        json.put("limitFirst", limitFirst);
        json.put("limitSecond", limitSecond);
    /**
     * 开通VIP
     *
     * @param callback
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "applyVip")
    public void applyVip(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        // 已完成
        json.put("daRen", jsonrRed1);
        json.put("highVIP", jsonrRed2);
        json.put("superVIP", jsonrRed3);
        try {
            userVIPInfoService.applyVIP(uid);
        } catch (UserVIPInfoException e) {
            if (!StringUtil.isNullOrEmpty(callback)) {
                out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMsg())));
            } else {
                out.print(JsonUtil.loadFalseResult(e.getMsg()));
            }
            return;
        }
        // 人工客服链接
        json.put("csdLink", configService.getValue(ConfigKeyEnum.customerServiceLink.getKey(), acceptData.getSystem()));
        if (!StringUtil.isNullOrEmpty(callback)) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("申请成功,正在受理中")));
        } else {
            out.print(JsonUtil.loadTrueResult("申请成功,正在受理中"));
        }
    }
        UserVIPInfo userVIPInfo = userVIPInfoService.selectByUid(uid);
        String leftTime = "";
        if (userVIPInfo != null && userVIPInfo.getState() == UserVIPInfo.STATE_VERIFING
                && userVIPInfo.getApplyTime() != null) {
            long s = 48 * 60 * 60 - ((System.currentTimeMillis() - userVIPInfo.getApplyTime().getTime()) / 1000);
            if (s > 3600) {
                leftTime = s / 3600 + "小时";
                leftTime = "还剩" + leftTime;
            } else if (s >= 60) {
                leftTime = s / 60 + "分钟";
                leftTime = "还剩" + leftTime;
            } else if (s > 0) {
                leftTime = s + "秒";
                leftTime = "还剩" + leftTime;
            } else {
                leftTime = "还剩0秒";
            }
        }
        json.put("leftTime", leftTime);
        if (!StringUtil.isNullOrEmpty(callback)) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(json)));
        } else {
            out.print(JsonUtil.loadTrueResult(json));
        }
    }
    /**
     * 获取vip信息
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "getVIPInfoV2")
    public void getVIPInfoV2(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
    /**
     * 获取vip信息
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "getVIPSuccessInfo")
    public void getVIPSuccessInfo(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        // 用户信息
        UserInfo userInfo = userInfoService.selectByPKey(uid);
        if (userInfo == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "该用户不存在"));
            return;
        }
        // 获取等级
        UserInviteLevelEnum level = userInviteService.getUserInviteLevelNew(uid);
        UserVIPPreInfo vipInfo = userVIPPreInfoService.getLatestProcessInfo(uid);
        if (vipInfo == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "还未升级成为会员"));
            return;
        }
        // 达人
        long limitOrder = 0;
        long limitFirst = 0;
        long limitSecond = 0;
        if (level == UserInviteLevelEnum.actived || level == UserInviteLevelEnum.noActive) {
            String orderCount = userVipConfigService.getValueByKey("vip_pre_7_order_count");
            if (!StringUtil.isNullOrEmpty(orderCount)) {
                limitOrder = Long.parseLong(orderCount);
            }
            String first = userVipConfigService.getValueByKey("vip_pre_7_first_level_team_count");
            if (!StringUtil.isNullOrEmpty(first)) {
                limitFirst = Long.parseLong(first);
            }
            String second = userVipConfigService.getValueByKey("vip_pre_7_second_level_team_count");
            if (!StringUtil.isNullOrEmpty(second)) {
                limitSecond = Long.parseLong(second);
            }
        } else if (level == UserInviteLevelEnum.highVIP || level == UserInviteLevelEnum.vipApply) {
            String orderCount = userVipConfigService.getValueByKey("vip_pre_10_order_count");
            if (!StringUtil.isNullOrEmpty(orderCount)) {
                limitOrder = Long.parseLong(orderCount);
            }
            String first = userVipConfigService.getValueByKey("vip_pre_10_first_level_team_count");
            if (!StringUtil.isNullOrEmpty(first)) {
                limitFirst = Long.parseLong(first);
            }
            String second = userVipConfigService.getValueByKey("vip_pre_10_second_level_team_count");
            if (!StringUtil.isNullOrEmpty(second)) {
                limitSecond = Long.parseLong(second);
            }
        } else if (level == UserInviteLevelEnum.vip || level == UserInviteLevelEnum.tearcherApply) {
            // TODO 比例
        UserLevelEnum level = UserLevelUtil.getByLevel(vipInfo.getProcess());
        if (level == null) {
            level = UserLevelEnum.daRen;
        }
        UserLevelEnum showLevel = UserLevelUtil.getShowLevel(level);
        } else if (level == UserInviteLevelEnum.tearcher) {
            // TODO
        }
        String desc = "你于" + TimeUtil.formatDateDot(vipInfo.getCreateTime()) + "升级为" + showLevel.getName();
        // 自购订单
        long doneOrder = hongBaoV2CountService.countMyDirectOrderByCashArrival(uid, Constant.VIP_ORDER_PAY);
        // 有效粉丝
        int doneFirst = 0;
        int doneSecond = 0;
        UserInviteValidNum userInviteValidNum = userInviteValidNumService.selectByPrimaryKey(uid);
        if (userInviteValidNum != null) {
            doneFirst = userInviteValidNum.getNumFirst() == null ? 0 : userInviteValidNum.getNumFirst();
            doneSecond = userInviteValidNum.getNumSecond() == null ? 0 : userInviteValidNum.getNumSecond();
        }
        JSONObject json = new JSONObject();
        json.put("desc", desc);
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json));
    }
        Date now = new Date();
        Date start = new Date(0);
        // 省钱: ---返利订单、奖励券提成
        List<UserMoneyDetailTypeEnum> typeFanli = new ArrayList<>();
        typeFanli.add(UserMoneyDetailTypeEnum.fanli);
        typeFanli.add(UserMoneyDetailTypeEnum.orderReward);
        BigDecimal saveMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeFanli, start, now).abs();
    @RequestMapping(value = "getTearcherWX")
    public void getTearcherWX(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        TearcherInfo tearcher = tearcherService.selectByUid(uid);
        if (tearcher == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("无导师"));
            return;
        } else {
            JSONObject data = new JSONObject();
            data.put("wx", tearcher.getWxID());
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
            return;
        }
    }
        // 赚钱: 邀请订单、分享订单、补贴
        List<UserMoneyDetailTypeEnum> typeList = new ArrayList<>();
        typeList.add(UserMoneyDetailTypeEnum.share);
        typeList.add(UserMoneyDetailTypeEnum.invite);
        typeList.add(UserMoneyDetailTypeEnum.inviteAndShare);
        typeList.add(UserMoneyDetailTypeEnum.systemEqualize);
        typeList.add(UserMoneyDetailTypeEnum.subsidy);
        BigDecimal earnMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, start, now).abs();
        if (level != UserInviteLevelEnum.vip) {
            BigDecimal rate = new BigDecimal("0.409");
            saveMoney = MoneyBigDecimalUtil.mul2(saveMoney, rate);
            earnMoney = MoneyBigDecimalUtil.mul2(earnMoney, rate);
        }
    //获取电话号码
    @RequestMapping(value = "getPhone")
    public void getPhone(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
        if (user == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "用户不存在"));
            return;
        }
        String shareRate = "可享佣金的<label style=\"color:#E5005C;\">%s</label>";
        String teamRate = "最高佣金的<label style=\"color:#E5005C;\">%s</label>";
        // 达人版
        JSONObject jsonrRed1 = new JSONObject();
        jsonrRed1.put("enjoyRate", String.format(shareRate, "145%"));
        jsonrRed1.put("teamRate", String.format(teamRate, "25%"));
        jsonrRed1.put("teamIncome", "高级会员以上专属");
        JSONObject data = new JSONObject();
        data.put("phone", user.getPhone());
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
        // 高级会员
        JSONObject jsonrRed2 = new JSONObject();
        jsonrRed2.put("enjoyRate", String.format(shareRate, "195%"));
        jsonrRed2.put("teamRate", String.format(teamRate, "50%"));
        jsonrRed2.put("teamIncome", "享高级团队收益");
        // 超级会员
        JSONObject jsonrRed3 = new JSONObject();
        jsonrRed3.put("enjoyRate", String.format(shareRate, "210%"));
        jsonrRed3.put("teamRate", String.format(teamRate, "110%"));
        jsonrRed3.put("teamIncome", "享超级团队收益");
    /**
     * 账户注销
     *
     * @param acceptData
     * @param callback
     * @param uid
     * @param out
     */
    @RequestMapping("accountRemove")
    public void accountRemove(AcceptData acceptData, String callback, Long uid, String vcode, PrintWriter out) {
        if (uid == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
            return;
        }
        JSONObject json = new JSONObject();
        json.put("level", level.name());
        json.put("nickName", userInfo.getNickName());
        json.put("portrait", userInfo.getPortrait());
        json.put("ruleLink", userVipConfigService.getValueByKey("help_link_vip_h5"));
        json.put("saveMoney", saveMoney);
        json.put("earnMoney", earnMoney);
        if (StringUtil.isNullOrEmpty(vcode)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请输入验证码"));
            return;
        }
        String tearcherWX = "";
        TearcherInfo tearcherInfo = tearcherService.selectByUid(uid);
        if (tearcherInfo != null && !StringUtil.isNullOrEmpty(tearcherInfo.getWxID())) {
            tearcherWX = tearcherInfo.getWxID();
        }
        json.put("tearcherWX", tearcherWX);
        json.put("tearcherTip", "我是你的导师,为你在省赚过程中解难答疑,对你一对一辅导,倾听你的需求总结并反馈给板栗快省官方运营团队,快来添加我吧。");
        json.put("newerGongLue", configService.getValue(ConfigKeyEnum.newerGonglue.getKey(),acceptData.getSystem()));
        UserInfo userInfo = userInfoService.selectByPKey(uid);
        if (userInfo == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
            return;
        }
        // 已完成
        json.put("doneOrder", doneOrder);
        json.put("doneFirst", doneFirst);
        json.put("doneSecond", doneSecond);
        if (userInfo.getState() == UserInfo.STATE_FORBIDDEN) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
            return;
        }
        // 标准
        json.put("limitOrder", limitOrder);
        json.put("limitFirst", limitFirst);
        json.put("limitSecond", limitSecond);
        if (userInfo.getState() == UserInfo.STATE_DELETE || userInfo.getState() == UserInfo.STATE_DELETE_OUT_OF_DATE) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, "帐户已被注销,请重新登录"));
            return;
        }
        // 已完成
        json.put("daRen", jsonrRed1);
        json.put("highVIP", jsonrRed2);
        json.put("superVIP", jsonrRed3);
        String phone = userInfo.getPhone();
        if (StringUtil.isNullOrEmpty(phone)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未绑定有效电话号码"));
            return;
        }
        // 人工客服链接
        json.put("csdLink", configService.getValue(ConfigKeyEnum.customerServiceLink.getKey(),acceptData.getSystem()));
        if (!Constant.IS_TEST) {
            String oldVcode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_REMVOE);
            if (StringUtil.isNullOrEmpty(oldVcode) || !oldVcode.equalsIgnoreCase(vcode)) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("验证码错误,重新输入"));
                return;
            }
            redisManager.clearSMSVCode(phone, SMSHistory.TYPE_REMVOE);
        }
        UserVIPInfo userVIPInfo = userVIPInfoService.selectByUid(uid);
        String leftTime = "";
        if (userVIPInfo != null && userVIPInfo.getState() == UserVIPInfo.STATE_VERIFING
                && userVIPInfo.getApplyTime() != null) {
            long s = 48 * 60 * 60 - ((System.currentTimeMillis() - userVIPInfo.getApplyTime().getTime()) / 1000);
            if (s > 3600) {
                leftTime = s / 3600 + "小时";
                leftTime = "还剩" + leftTime;
            } else if (s >= 60) {
                leftTime = s / 60 + "分钟";
                leftTime = "还剩" + leftTime;
            } else if (s > 0) {
                leftTime = s + "秒";
                leftTime = "还剩" + leftTime;
            } else {
                leftTime = "还剩0秒";
            }
        }
        json.put("leftTime", leftTime);
        if (!StringUtil.isNullOrEmpty(callback)) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(json)));
        } else {
            out.print(JsonUtil.loadTrueResult(json));
        }
    }
        userAccountService.forbiddenUserAll(uid, "用户主动注销账户");
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("注销成功"));
    }
    /**
     * 获取vip信息
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "getVIPSuccessInfo")
    public void getVIPSuccessInfo(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        UserVIPPreInfo vipInfo = userVIPPreInfoService.getLatestProcessInfo(uid);
        if (vipInfo == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "还未升级成为会员"));
            return;
        }
    /**
     * 注销账户数据
     *
     * @param acceptData
     * @param callback
     * @param uid
     * @param out
     */
    @RequestMapping("getAccountData")
    public void getAccountData(AcceptData acceptData, String callback, Long uid, PrintWriter out) {
        if (uid == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
            return;
        }
        UserLevelEnum level = UserLevelUtil.getByLevel(vipInfo.getProcess());
        if (level == null) {
            level = UserLevelEnum.daRen;
        }
        UserLevelEnum showLevel = UserLevelUtil.getShowLevel(level);
        UserInfo user = userInfoService.getUserById(uid);
        if (user == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
            return;
        }
        String desc = "你于" + TimeUtil.formatDateDot(vipInfo.getCreateTime()) + "升级为" + showLevel.getName();
        Date minDate = null;
        Date maxDate = null;
        long timeStamp = System.currentTimeMillis();
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(timeStamp);
        JSONObject json = new JSONObject();
        json.put("desc", desc);
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json));
    }
        // 全部未到账
        minDate = new Date(0);
        maxDate = new Date(timeStamp);
        BigDecimal totalMoney = hongBaoV2Service.getUnRecievedMoneyWithCreateTime(uid, minDate, maxDate);
        if (totalMoney == null)
            totalMoney = BigDecimal.ZERO;
        totalMoney = totalMoney.add(user.getMyHongBao());
    @RequestMapping(value = "getTearcherWX")
    public void getTearcherWX(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        TearcherInfo tearcher = tearcherService.selectByUid(uid);
        if (tearcher == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("无导师"));
            return;
        } else {
            JSONObject data = new JSONObject();
            data.put("wx", tearcher.getWxID());
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
            return;
        }
    }
        // 本月预估
        maxDate = new Date(timeStamp);
        calendar = Calendar.getInstance();
        minDate = new Date(TimeUtil.convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
        calendar.add(Calendar.MONTH, -1);
        BigDecimal monthMoney = getMoney(orderMoneyDailyCountService.query(uid, minDate, maxDate));
    //获取电话号码
    @RequestMapping(value = "getPhone")
    public void getPhone(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
        if(user==null){
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "用户不存在"));
            return;
        }
        JSONObject data=new JSONObject();
        data.put("phone", user.getPhone());
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
        // 上月预估
        maxDate = new Date(TimeUtil
                .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
        calendar.add(Calendar.MONTH, -1);
        minDate = new Date(TimeUtil
                .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
        BigDecimal lastMoney = getMoney(orderMoneyDailyCountService.query(uid, minDate, maxDate));
    /**
     * 账户注销
     * @param acceptData
     * @param callback
     * @param uid
     * @param out
     */
    @RequestMapping("accountRemove")
    public void accountRemove(AcceptData acceptData, String callback, Long uid, String vcode, PrintWriter out) {
        if (uid == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
            return;
        }
        if (StringUtil.isNullOrEmpty(vcode)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请输入验证码"));
            return;
        }
        UserInfo userInfo = userInfoService.selectByPKey(uid);
        if (userInfo == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
            return;
        }
        if (userInfo.getState() == UserInfo.STATE_FORBIDDEN) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
            return;
        }
        JSONObject data = new JSONObject();
        data.put("totalMoney", totalMoney.setScale(2, BigDecimal.ROUND_DOWN));
        data.put("monthMoney", monthMoney.setScale(2, BigDecimal.ROUND_DOWN));
        data.put("lastMoney", lastMoney.setScale(2, BigDecimal.ROUND_DOWN));
        data.put("link", configService.getValue(ConfigKeyEnum.accountLogoutProtocolLink.getKey(), acceptData.getSystem()));
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
        if (userInfo.getState() == UserInfo.STATE_DELETE || userInfo.getState() == UserInfo.STATE_DELETE_OUT_OF_DATE) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, "帐户已被注销,请重新登录"));
            return;
        }
        String phone = userInfo.getPhone();
        if (StringUtil.isNullOrEmpty(phone)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未绑定有效电话号码"));
            return;
        }
        if (!Constant.IS_TEST) {
            String oldVcode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_REMVOE);
            if (StringUtil.isNullOrEmpty(oldVcode) || !oldVcode.equalsIgnoreCase(vcode)) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("验证码错误,重新输入"));
                return;
            }
            redisManager.clearSMSVCode(phone, SMSHistory.TYPE_REMVOE);
        }
        userAccountService.forbiddenUserAll(uid, "用户主动注销账户");
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("注销成功"));
    }
    /**
     * 注销账户数据
     * @param acceptData
     * @param callback
     * @param uid
     * @param out
     */
    @RequestMapping("getAccountData")
    public void getAccountData(AcceptData acceptData, String callback, Long uid, PrintWriter out) {
        if (uid == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
            return;
        }
        UserInfo user = userInfoService.getUserById(uid);
        if (user == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
            return;
        }
        Date minDate = null;
        Date maxDate = null;
        long timeStamp = System.currentTimeMillis();
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(timeStamp);
        // 全部未到账
        minDate = new Date(0);
        maxDate = new Date(timeStamp);
        BigDecimal totalMoney = hongBaoV2Service.getUnRecievedMoneyWithCreateTime(uid, minDate, maxDate);
        if (totalMoney == null)
            totalMoney = BigDecimal.ZERO;
        totalMoney = totalMoney.add(user.getMyHongBao());
        // 本月预估
        maxDate = new Date(timeStamp);
        calendar = Calendar.getInstance();
        minDate = new Date(TimeUtil.convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
        calendar.add(Calendar.MONTH, -1);
        BigDecimal monthMoney = getMoney(orderMoneyDailyCountService.query(uid, minDate, maxDate));
        // 上月预估
        maxDate = new Date(TimeUtil
                .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
        calendar.add(Calendar.MONTH, -1);
        minDate = new Date(TimeUtil
                .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
        BigDecimal lastMoney = getMoney(orderMoneyDailyCountService.query(uid, minDate, maxDate));
        JSONObject data = new JSONObject();
        data.put("totalMoney", totalMoney.setScale(2, BigDecimal.ROUND_DOWN));
        data.put("monthMoney", monthMoney.setScale(2, BigDecimal.ROUND_DOWN));
        data.put("lastMoney", lastMoney.setScale(2, BigDecimal.ROUND_DOWN));
        data.put("link", configService.getValue(ConfigKeyEnum.accountLogoutProtocolLink.getKey(),acceptData.getSystem()));
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
    private BigDecimal getMoney(List<OrderMoneyDailyCount> list) {
        BigDecimal money = BigDecimal.ZERO;
        BigDecimal hundred = BigDecimal.valueOf(100);
        if (list != null && list.size() > 0) {
            for (OrderMoneyDailyCount dailyCount : list) {
                if (dailyCount.getIncome() != null)
                    money = money.add(MoneyBigDecimalUtil.div(BigDecimal.valueOf(dailyCount.getIncome()), hundred));
                if (dailyCount.getIncomeTeam() != null)
                    money = money.add(MoneyBigDecimalUtil.div(BigDecimal.valueOf(dailyCount.getIncomeTeam()), hundred));
            }
        }
        return money;
    }
    private BigDecimal getMoney(List<OrderMoneyDailyCount> list) {
        BigDecimal money = BigDecimal.ZERO;
        BigDecimal hundred = BigDecimal.valueOf(100);
        if (list != null && list.size() > 0) {
            for (OrderMoneyDailyCount dailyCount : list) {
                if (dailyCount.getIncome() != null)
                    money = money.add(MoneyBigDecimalUtil.div(BigDecimal.valueOf(dailyCount.getIncome()), hundred));
                if (dailyCount.getIncomeTeam() != null)
                    money = money.add(MoneyBigDecimalUtil.div(BigDecimal.valueOf(dailyCount.getIncomeTeam()), hundred));
            }
        }
        return money;
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserCloudControllerV2.java
@@ -581,7 +581,7 @@
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                    acceptData.getVersion());
                    acceptData.getVersion(),acceptData.getSystem());
            for (UserCloudGoods cloudGoods : list) {
                CommonGoods commonGoods = cloudGoods.getCommonGoods();
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/VipShopControllerV2.java
@@ -97,7 +97,7 @@
            JSONArray array = new JSONArray();
            if (goodsList != null && goodsList.size() > 0) {
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                        .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
fanli/src/main/java/com/yeshi/fanli/controller/h5/H5ControllerUtil.java
@@ -23,7 +23,7 @@
    BusinessSystem getSystem(AcceptData acceptData) {
        String platform = acceptData.getPlatform();
        String packages = acceptData.getPackages();
        BusinessSystem system = businessSystemService.getBusinessSystem(platform, packages);
        BusinessSystem system = businessSystemService.getBusinessSystem(platform, packages,acceptData.getSystem());
        return system;
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/h5/H5RecommendController.java
@@ -122,7 +122,7 @@
    public void getRecommendBanner(AcceptData acceptData, String callback, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystem("WEB",
                Constant.systemCommonConfig.getH5PackageName());
                Constant.systemCommonConfig.getH5PackageName(),acceptData.getSystem());
        JSONObject json = new JSONObject();
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, H5ControllerUtil.NOSYSTEM));
fanli/src/main/java/com/yeshi/fanli/controller/h5/H5SearchController.java
@@ -89,11 +89,11 @@
                filter = fastFilter;
            }
        }
        JSONObject data = search(kw, page, filter, order, startprice, endprice);
        JSONObject data = search(acceptData, kw, page, filter, order, startprice, endprice);
        out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
    }
    private JSONObject search(String kw, int page, String filter, String order, String startprice, String endprice) {
    private JSONObject search(AcceptData acceptData, String kw, int page, String filter, String order, String startprice, String endprice) {
        SearchFilter sf = new SearchFilter();
        sf.setKey(kw);
@@ -209,7 +209,7 @@
        int fq = sf.getQuan();
        int fh = sf.getHongbao();
        boolean ft = sf.isTmall();
        BigDecimal proportion = manageService.getFanLiRate();
        BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
        if (fq == 0 && fh == 0 && !ft) {
            for (TaoBaoGoodsBrief bf : result.getTaoBaoGoodsBriefs()) {
                re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), ""));
fanli/src/main/java/com/yeshi/fanli/controller/web/TLJFreeBuyGoodsController.java
@@ -49,7 +49,7 @@
        List<TaoBaoGoodsBrief> list = tljFreeBuyGoodsService.listPreGoods(kw, page);
        JSONArray array = new JSONArray();
        Gson gson = new Gson();
        BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
        BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(acceptData.getSystem());
        for (TaoBaoGoodsBrief goods : list) {
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, fanLiRate.toString(), null)));
        }
@@ -112,7 +112,7 @@
        List<TLJFreeBuyGoods> listGoods = tljFreeBuyGoodsService.listByDay(day, 100);
        
        JSONArray array = new JSONArray();
        BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
        BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(acceptData.getSystem());
        
        for (TLJFreeBuyGoods sh : listGoods) {
            TaoBaoGoodsBriefExtra item = TaoBaoUtil.getTaoBaoGoodsBriefExtra(sh.getGoods(), fanLiRate.toString(), null);
fanli/src/main/java/com/yeshi/fanli/controller/web/WebControllerUtil.java
@@ -21,7 +21,7 @@
    BusinessSystem getSystem(AcceptData acceptData) {
        String platform = acceptData.getPlatform();
        String packages = acceptData.getPackages();
        BusinessSystem system= businessSystemService.getBusinessSystem(platform, packages);
        BusinessSystem system= businessSystemService.getBusinessSystem(platform, packages,acceptData.getSystem());
        return system;
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/web/WebRecommendController.java
@@ -87,7 +87,7 @@
    public void getRecommendBanner(AcceptData acceptData, String callback, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystem("WEB",
                Constant.systemCommonConfig.getH5PackageName());
                Constant.systemCommonConfig.getH5PackageName(),acceptData.getSystem());
        JSONObject json = new JSONObject();
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, WebControllerUtil.NOSYSTEM));
@@ -176,7 +176,7 @@
            else
                type = 2;
            List<TaoBaoUnionConfig> config = taoBaoUnionConfigService.getConfigByTypeCache(type);
            TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(tb, config.get(0));
            TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(tb, config.get(0),acceptData.getSystem());
            if (!StringUtil.isNullOrEmpty(tb.getCouponLink()) && taoBaoGoodsBriefExtra.getTaoBaoQuanInfo() != null)
                taoBaoGoodsBriefExtra.getTaoBaoQuanInfo().setCouponLink(tb.getCouponLink());
@@ -212,7 +212,7 @@
                            + taoBaoGoodsBriefExtra.getTaoBaoHongBaoInfo().getHongbao() + "元    "
                            + taoBaoGoodsBriefExtra.getTitle() + shareSinaContent);
            data.put("sharemoney", "分享奖金 ¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb) + "元");
            data.put("sharemoney", "分享奖金 ¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb,acceptData.getSystem()) + "元");
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
            final TaoBaoGoodsBrief tbb = tb;
fanli/src/main/java/com/yeshi/fanli/controller/web/WebSearchController.java
@@ -132,7 +132,7 @@
                    StringUtil.isNullOrEmpty(endprice) ? null : Double.parseDouble(endprice),
                    StringUtil.isNullOrEmpty(rate) ? null : Double.parseDouble(rate), null, 1);
            BigDecimal proportion = manageService.getFanLiRate();
            BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
            /* 遍历列表数据 */
            if (listQuery != null && listQuery.size() > 0) {
                for (QualityFactory selectionGoods : listQuery) {
@@ -173,7 +173,7 @@
                int fq = sf.getQuan();
                int fh = sf.getHongbao();
                boolean ft = sf.isTmall();
                BigDecimal proportion = manageService.getFanLiRate();
                BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
                if (fq == 0 && fh == 0 && !ft) {
                    if (taoBaoGoodsBriefs != null)
                        for (TaoBaoGoodsBrief bf : taoBaoGoodsBriefs) {
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/ConfigController.java
@@ -69,7 +69,7 @@
    @RequestMapping("getSystemClientConfig")
    public void getOpenId(WXMPAcceptData acceptData, HttpServletRequest request, PrintWriter out) {
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getAppId());
                acceptData.getAppId(),acceptData.getSystem());
        if (system == null) {
            out.print("系统不存在");
            return;
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/ConsumerController.java
@@ -234,7 +234,7 @@
            }
            ConfigParamsDTO paramsDTO =  orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                    acceptData.getVersion());
                    acceptData.getVersion(),acceptData.getSystem());
            
            for (CollectionGoodsV2 collectionGoodsV2 : collectionGoodsList) {
@@ -350,7 +350,7 @@
        if (list != null && list.size() > 0) {
            Gson gson = gsonBuilder.create();
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                    acceptData.getVersion());
                    acceptData.getVersion(),acceptData.getSystem());
            for (ScanHistoryV2 sh : list) {
                CommonGoods commonGoods = sh.getCommonGoods();
                if (commonGoods == null) {
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/GoodsController.java
@@ -236,7 +236,7 @@
                Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                        .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                for (JDGoods goods : goodsList) {
                    GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO);
                    if (goodsDetailVO.isHasCoupon()) {
@@ -317,13 +317,13 @@
        jdGoodsCacheUtil.saveGoodsInfo(jdGoods);
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                acceptData.getVersion());
                acceptData.getVersion(),acceptData.getSystem());
        paramsDTO.setMaxRewardRate(null);
        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)));
                    .setShareMoney("¥" + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getShareRate(UserLevelEnum.superVIP,acceptData.getSystem())));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
@@ -348,12 +348,12 @@
                    jdGoods.setCommissionPlus(threeClass.getSelfComm());
                    // plus返利
                    BigDecimal fanliMoneyPlus = JDUtil.getGoodsFanLiMoneyPlus(jdGoods,
                            hongBaoManageService.getFanLiRate());
                            hongBaoManageService.getFanLiRate(acceptData.getSystem()));
                    otherInfo.setFanliMoneyPlus("京东plus返¥" + fanliMoneyPlus);
                    // 使用奖励券最高返
                    maxMoneyPlus = "(京东plus返¥"
                            + JDUtil.getGoodsFanLiMoneyPlus(jdGoods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)) + ")";
                            + JDUtil.getGoodsFanLiMoneyPlus(jdGoods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem())) + ")";
                }
            }
@@ -487,13 +487,13 @@
        }
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                acceptData.getVersion());
                acceptData.getVersion(),acceptData.getSystem());
        paramsDTO.setMaxRewardRate(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)));
                    "¥" + PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, hongBaoManageService.getShareRate(UserLevelEnum.superVIP,acceptData.getSystem())));
        }
        if (goodsDetail.getCouponInfo() != null) {
@@ -646,7 +646,7 @@
                }
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
                for (JDGoods goods : list) {
@@ -688,7 +688,7 @@
                            }
                            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService
                                    .getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion());
                                    .getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion(),acceptData.getSystem());
                            for (PDDGoodsDetail goods : goodsList) {
                                listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO));
                            }
@@ -874,7 +874,7 @@
            return;
        }
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                acceptData.getVersion());
                acceptData.getVersion(),acceptData.getSystem());
        GoodsDetailVO goods = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
        String scene = goodsType + "#" + goodsId + "#" + inviteCode;
@@ -932,7 +932,7 @@
            return;
        }
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                acceptData.getVersion());
                acceptData.getVersion(),acceptData.getSystem());
        GoodsDetailVO goods = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO);
        String scene = goodsType + "#" + goodsId + "#" + inviteCode;
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/RecommendController.java
@@ -245,7 +245,7 @@
            List<JDGoods> goodsList = result.getGoodsList();
            if (goodsList != null && goodsList.size() > 0) {
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                        .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
@@ -279,7 +279,7 @@
            List<PDDGoodsDetail> goodsList = result.getGoodsList();
            if (goodsList != null && goodsList.size() > 0) {
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                for (PDDGoodsDetail goods : goodsList) {
                    GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO);
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/SearchController.java
@@ -198,7 +198,7 @@
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        data.put("type", type);
        data.put("goods", gson.toJson(GoodsDetailVOFactory.convertCommonGoods(commonGoods,
                orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion()))));
                orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion(),acceptData.getSystem()))));
        out.print(JsonUtil.loadTrueResult(data));
        return;
    }
@@ -480,7 +480,7 @@
                Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                        .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                for (JDGoods goods : goodsList) {
                    GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO);
                    if (hasCoupon) {
@@ -562,7 +562,7 @@
            List<PDDGoodsDetail> goodsList = result.getGoodsList();
            if (goodsList != null && goodsList.size() > 0) {
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                        acceptData.getVersion(),acceptData.getSystem());
                for (PDDGoodsDetail goods : goodsList) {
                    GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO);
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/UserController.java
@@ -242,7 +242,7 @@
    public void getuserinfoNew(WXMPAcceptData acceptData, Long uid, HttpServletRequest requst, PrintWriter out) {
        try {
            BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                    acceptData.getAppId());
                    acceptData.getAppId(),acceptData.getSystem());
            if (system == null) {
                out.print(JsonUtil.loadFalseResult("系统不存在"));
                return;
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/BusinessSystemMapper.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,6 +25,6 @@
     * @return
     */
    List<BusinessSystem> listByPlatformAndPackage(@Param("platform") int platform,
            @Param("packageName") String packageName);
            @Param("packageName") String packageName,@Param("system") SystemEnum system);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HongBaoManageMapper.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.user.HongBaoManage;
@@ -16,25 +17,26 @@
    HongBaoManage selectByPrimaryKey(Long id);
    HongBaoManage selectByKey(String key);
    HongBaoManage selectByKey(@Param("key") String key,@Param("system")  SystemEnum system);
    int updateByPrimaryKeySelective(HongBaoManage record);
    int updateByPrimaryKey(HongBaoManage record);
    /**
     * 按最大有效时间搜索红包对象
     *
     *  按最大有效时间搜索红包对象
     * @param key
     * @param timeStamp
     * @param system
     * @return
     */
    HongBaoManage selectByKeyAndMaxValidTime(@Param("key") String key, @Param("timeStamp") long timeStamp);
    HongBaoManage selectByKeyAndMaxValidTime(@Param("key") String key, @Param("timeStamp") long timeStamp,@Param("system")  SystemEnum system);
    /**
     * 获取所有的配置
     *
     * @param system
     * @return
     */
    List<HongBaoManage> listAll();
    List<HongBaoManage> listAll(@Param("system")  SystemEnum system);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/UserInfoMapper.java
@@ -12,246 +12,241 @@
public interface UserInfoMapper {
    int deleteByPrimaryKey(Long id);
    int deleteByPrimaryKey(Long id);
    int insert(UserInfo record);
    int insert(UserInfo record);
    int insertSelective(UserInfo record);
    int insertSelective(UserInfo record);
    UserInfo selectByPrimaryKey(Long id);
    UserInfo selectByPrimaryKey(Long id);
    /**
     * 查询有效的
     *
     * @param id
     * @return
     */
    UserInfo selectAvailableByPrimaryKey(Long id);
    /**
     * 查询有效的
     *
     * @param id
     * @return
     */
    UserInfo selectAvailableByPrimaryKey(Long id);
    UserInfo selectByPrimaryKeyForUpdate(Long id);
    UserInfo selectByPrimaryKeyForUpdate(Long id);
    int updateByPrimaryKeySelective(UserInfo record);
    int updateByPrimaryKeySelective(UserInfo record);
    int updateByPrimaryKey(UserInfo record);
    int updateByPrimaryKey(UserInfo record);
    // 减掉用户红包金额
    int subHongBaoByUid(@Param("uid") long uid, @Param("money") BigDecimal money);
    // 减掉用户红包金额
    int subHongBaoByUid(@Param("uid") long uid, @Param("money") BigDecimal money);
    // 增加用户红包金额
    int addHongBaoByUid(@Param("uid") long uid, @Param("money") BigDecimal money);
    // 增加用户红包金额
    int addHongBaoByUid(@Param("uid") long uid, @Param("money") BigDecimal money);
    void cleanPassword(long id);
    void cleanPassword(long id);
    BigDecimal getNewPeopleHB(Long id);
    BigDecimal getNewPeopleHB(Long id);
    BigDecimal getMyHB(Long id);
    BigDecimal getMyHB(Long id);
    // 根据AppId与微信unionID获取用户
    // 根据AppId与微信unionID获取用户
    /**
     * 根据系统与微信unionId获取用户
     * @param system
     * @param unionId
     * @return
     */
    List<UserInfo> listBySystemAndWXUnionId(@Param("system") SystemEnum system, @Param("unionId") String unionId);
    /**
     * 根据系统与微信unionId获取用户
     *
     * @param system
     * @param unionId
     * @return
     */
    List<UserInfo> listBySystemAndWXUnionId(@Param("system") SystemEnum system, @Param("unionId") String unionId);
    /**
     * 根据系统与淘宝的openid获取用户
     * @param system
     * @param openId
     * @return
     */
    List<UserInfo> listBySystemAndTaoBaoOpenId(@Param("system") SystemEnum system, @Param("openId") String openId);
    /**
     * 根据系统与淘宝的openid获取用户
     *
     * @param system
     * @param openId
     * @return
     */
    List<UserInfo> listBySystemAndTaoBaoOpenId(@Param("system") SystemEnum system, @Param("openId") String openId);
    /**
     * 根据系统与电话号码获取用户
     * @param system
     * @param phone
     * @return
     */
    List<UserInfo> listBySystemAndPhone(@Param("system") SystemEnum system, @Param("phone") String phone);
    /**
     * 根据系统与电话号码获取用户
     *
     * @param system
     * @param phone
     * @return
     */
    List<UserInfo> listBySystemAndPhone(@Param("system") SystemEnum system, @Param("phone") String phone);
    // 根据获取电话号码有效用户
    UserInfo getEffectiveUserInfoByPhone(@Param("phone") String phone,@Param("system") SystemEnum system);
    // 根据获取电话号码有效用户
    UserInfo getEffectiveUserInfoByPhone(@Param("phone") String phone, @Param("system") SystemEnum system);
    // 根据获WXUnionId有效用户
    UserInfo getEffectiveUserInfoByWXUnionId(@Param("unionId") String unionId,@Param("system") SystemEnum system);
    //根据微信openid查询
    UserInfo getEffectiveUserInfoByWXOpenId(@Param("wxOpenId") String wxOpenId,@Param("system") SystemEnum system);
    // 根据获WXUnionId有效用户
    UserInfo getEffectiveUserInfoByWXUnionId(@Param("unionId") String unionId, @Param("system") SystemEnum system);
    Long getMaxUid();
    List<UserInfoVO> queryInfo(@Param("start") long start, @Param("count") int count, @Param("userState") Integer userState,
            @Param("key") String key, @Param("keyType") Integer keyType, @Param("userRank") String userRank,
            @Param("days") Integer days, @Param("startTime") String startTime, @Param("endTime") String endTime,
            @Param("userType") Integer userType, @Param("level")String level, @Param("activeCode") Integer activeCode);
    //根据微信openid查询
    UserInfo getEffectiveUserInfoByWXOpenId(@Param("wxOpenId") String wxOpenId, @Param("system") SystemEnum system);
    long countInfo(@Param("userState") Integer userState, @Param("key") String key, @Param("keyType") Integer keyType,
            @Param("userRank") String userRank, @Param("days") Integer days, @Param("startTime") String startTime,
            @Param("endTime") String endTime,@Param("userType") Integer userType, @Param("level")String level,
            @Param("activeCode") Integer activeCode);
    Long getMaxUid();
    /**
     *
     * @param start
     * @param count
     * @param key
     *            查询条件
     * @param userType
     *            用户类型
     * @param days
     *            天数
     * @param startTime
     *            注册时间 -小
     * @param endTime
     *            注册时间 -大
     * @param orderMode
     *            排序方式
     * @return
     */
    List<UserInfoVO> query(@Param("start") long start, @Param("count") int count, @Param("userState") Integer userState,
            @Param("key") String key, @Param("keyType") Integer keyType, @Param("userRank") String userRank,
            @Param("days") Integer days, @Param("startTime") String startTime, @Param("endTime") String endTime,
            @Param("orderField") Integer orderField, @Param("orderMode") Integer orderMode,
            @Param("userType") Integer userType, @Param("level")String level, @Param("activeCode") Integer activeCode);
    List<UserInfoVO> queryInfo(@Param("start") long start, @Param("count") int count, @Param("userState") Integer userState,
                               @Param("key") String key, @Param("keyType") Integer keyType, @Param("userRank") String userRank,
                               @Param("days") Integer days, @Param("startTime") String startTime, @Param("endTime") String endTime,
                               @Param("userType") Integer userType, @Param("level") String level, @Param("activeCode") Integer activeCode, @Param("system") SystemEnum system);
    long queryCount(@Param("userState") Integer userState, @Param("key") String key, @Param("keyType") Integer keyType,
            @Param("userRank") String userRank, @Param("days") Integer days, @Param("startTime") String startTime,
            @Param("endTime") String endTime,@Param("userType") Integer userType, @Param("level")String level,
            @Param("activeCode") Integer activeCode);
    long countInfo(@Param("userState") Integer userState, @Param("key") String key, @Param("keyType") Integer keyType,
                   @Param("userRank") String userRank, @Param("days") Integer days, @Param("startTime") String startTime,
                   @Param("endTime") String endTime, @Param("userType") Integer userType, @Param("level") String level,
                   @Param("activeCode") Integer activeCode, @Param("system") SystemEnum system);
    /**
     * 统计当前查询结果总金额
     *
     * @param title
     * @param userType
     * @param days
     * @param startTime
     * @param endTime
     * @return
     */
    double querySumMoney(@Param("key") String key, @Param("userType") Integer userType, @Param("days") Integer days,
            @Param("startTime") String startTime, @Param("endTime") String endTime);
    /**
     * 统计用户数量
     *
     * @param isToday
     *            统计今日
     * @param isMonth
     *            统计当月 二则不可同时存在
     * @return
     */
    long countNewUser(@Param("isToday") Integer isToday, @Param("isMonth") Integer isMonth);
    /**
     * @param start
     * @param count
     * @param key       查询条件
     * @param userType  用户类型
     * @param days      天数
     * @param startTime 注册时间 -小
     * @param endTime   注册时间 -大
     * @param orderMode 排序方式
     * @return
     */
    List<UserInfoVO> query(@Param("start") long start, @Param("count") int count, @Param("userState") Integer userState,
                           @Param("key") String key, @Param("keyType") Integer keyType, @Param("userRank") String userRank,
                           @Param("days") Integer days, @Param("startTime") String startTime, @Param("endTime") String endTime,
                           @Param("orderField") Integer orderField, @Param("orderMode") Integer orderMode,
                           @Param("userType") Integer userType, @Param("level") String level, @Param("activeCode") Integer activeCode, @Param("system") SystemEnum system);
    /**
     * 根据等级统计用户数量
     *
     * @param rank
     * @return
     */
    long countRank(@Param("rank") Integer rank);
    long queryCount(@Param("userState") Integer userState, @Param("key") String key, @Param("keyType") Integer keyType,
                    @Param("userRank") String userRank, @Param("days") Integer days, @Param("startTime") String startTime,
                    @Param("endTime") String endTime, @Param("userType") Integer userType, @Param("level") String level,
                    @Param("activeCode") Integer activeCode, @Param("system") SystemEnum system);
    /**
     * 统计所有用户总金额 或 可提现金额
     *
     * @param minMoney
     * @return
     */
    BigDecimal countAllMoney(@Param("minMoney") Double minMoney);
    /**
     * 统计当前查询结果总金额
     *
     * @param title
     * @param userType
     * @param days
     * @param startTime
     * @param endTime
     * @return
     */
    double querySumMoney(@Param("key") String key, @Param("userType") Integer userType, @Param("days") Integer days,
                         @Param("startTime") String startTime, @Param("endTime") String endTime);
    /**
     * 超过 daysNum 天未登陆的用户
     *
     * @param minMoney
     * @return
     */
    List<Long> longTimeNoLogin(@Param("daysNum") int daysNum, @Param("list") List<Long> list);
    /**
     * 统计用户数量
     *
     * @param isToday 统计今日
     * @param isMonth 统计当月 二则不可同时存在
     * @return
     */
    long countNewUser(@Param("isToday") Integer isToday, @Param("isMonth") Integer isMonth);
    /**
     * 统计流失用户数量:( num 天未使用登录并且无任何资金流动的账号数量)
     *
     * @param num
     *            180
     * @return
     */
    long countLoseUser(@Param("num") int num);
    /**
     * 根据等级统计用户数量
     *
     * @param rank
     * @return
     */
    long countRank(@Param("rank") Integer rank);
    /**
     * 累计有购买用户数
     *
     * @return
     */
    long countHasOrderUser();
    /**
     * 统计所有用户总金额 或 可提现金额
     *
     * @param minMoney
     * @return
     */
    BigDecimal countAllMoney(@Param("minMoney") Double minMoney);
    /**
     * 统计新增用户
     *
     * @return
     */
    List<ChartTDO> countNewUserByDate(@Param("channel") String channel, @Param("type") Integer type,
            @Param("years") String years, @Param("startTime") String startTime, @Param("endTime") String endTime);
    /**
     * 超过 daysNum 天未登陆的用户
     *
     * @param minMoney
     * @return
     */
    List<Long> longTimeNoLogin(@Param("daysNum") int daysNum, @Param("list") List<Long> list);
    /**
     * 统计新增用户当日产生订单用户数量
     *
     * @return
     */
    List<ChartTDO> getTodayHasOrder(@Param("channel") String channel, @Param("type") Integer type,
            @Param("years") String years, @Param("startTime") String startTime, @Param("endTime") String endTime);
    /**
     * 统计流失用户数量:( num 天未使用登录并且无任何资金流动的账号数量)
     *
     * @param num 180
     * @return
     */
    long countLoseUser(@Param("num") int num);
    /**
     * 统计新增用户一周产生订单用户数量
     *
     * @return
     */
    ChartTDO getWeekHasOrder(@Param("channel") String channel, @Param("startTime") String startTime,
            @Param("endTime") String endTime, @Param("orderNum") Integer orderNum);
    /**
     * 累计有购买用户数
     *
     * @return
     */
    long countHasOrderUser();
    /**
     * 根据电话号码、邀请码获取邀请用户
     *
     * @param phone
     * @param inviteCode
     * @return
     */
    UserInfo getUserInfoByInviteCode(@Param("inviteCode") String inviteCode);
    /**
     * 统计新增用户
     *
     * @return
     */
    List<ChartTDO> countNewUserByDate(@Param("channel") String channel, @Param("type") Integer type,
                                      @Param("years") String years, @Param("startTime") String startTime, @Param("endTime") String endTime);
    // 根据AppId与电话号码获取用户
    List<UserInfo> listByClosed(@Param("appId") String appId, @Param("phone") String phone);
    /**
     * 统计新增用户当日产生订单用户数量
     *
     * @return
     */
    List<ChartTDO> getTodayHasOrder(@Param("channel") String channel, @Param("type") Integer type,
                                    @Param("years") String years, @Param("startTime") String startTime, @Param("endTime") String endTime);
    long countAvaiableUser();
    /**
     * 统计新增用户一周产生订单用户数量
     *
     * @return
     */
    ChartTDO getWeekHasOrder(@Param("channel") String channel, @Param("startTime") String startTime,
                             @Param("endTime") String endTime, @Param("orderNum") Integer orderNum);
    /**
     * 查询满足自动提现用户
     *
     * @param start
     * @param count
     * @return
     */
    /**
     * 根据电话号码、邀请码获取邀请用户
     *
     * @param phone
     * @param inviteCode
     * @return
     */
    UserInfo getUserInfoByInviteCode(@Param("inviteCode") String inviteCode);
    List<UserInfo> getAutoExtractUser(@Param("start") int start, @Param("count") int count,
            @Param("money") BigDecimal money, @Param("beganDate") String beganDate, @Param("endDate") String endDate);
    // 根据AppId与电话号码获取用户
    List<UserInfo> listByClosed(@Param("appId") String appId, @Param("phone") String phone);
    /**
     * 根据type检索
     * @param type
     * @param start
     * @param count
     * @return
     */
    List<UserInfo> listByType(@Param("type")int type,@Param("start") long start, @Param("count")int count);
    long countAvaiableUser();
    long countByType(int type);
    /**
     * 查询满足自动提现用户
     * @param start
     * @param count
     * @return
     */
    List<UserInfo> getAutoExtractUserTo1212(@Param("start") int start, @Param("count") int count);
    /**
     * 查询满足自动提现用户
     *
     * @param start
     * @param count
     * @return
     */
    List<UserInfo> getAutoExtractUser(@Param("start") int start, @Param("count") int count,
                                      @Param("money") BigDecimal money, @Param("beganDate") String beganDate, @Param("endDate") String endDate);
    /**
     * 根据type检索
     *
     * @param type
     * @param start
     * @param count
     * @return
     */
    List<UserInfo> listByType(@Param("type") int type, @Param("start") long start, @Param("count") int count);
    long countByType(int type);
    /**
     * 查询满足自动提现用户
     *
     * @param start
     * @param count
     * @return
     */
    List<UserInfo> getAutoExtractUserTo1212(@Param("start") int start, @Param("count") int count);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/brand/BrandClassShopMapper.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;
@@ -25,7 +26,7 @@
     * @param cid
     * @return
     */
    List<BrandClassShop> listEffective(@Param("cid") Long cid);
    List<BrandClassShop> listEffective(@Param("cid") Long cid,@Param("system") SystemEnum system);
    
    long countEffective(@Param("cid") Long cid);
    
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/brand/BrandInfoMapper.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;
@@ -9,13 +10,15 @@
import com.yeshi.fanli.vo.brand.BrandInfoVO;
public interface BrandInfoMapper extends BaseMapper<BrandInfo> {
    /**
     * 查询列表
     * @param start
     * @param count
     * @param key
     * @param keys
     * @param cid
     * @param state
     * @param showState
     * @return
     */
    List<BrandInfo> listQuery(@Param("start") long start, @Param("count") int count, @Param("keys") List<String> keys,
@@ -38,7 +41,7 @@
     * @param cid
     * @return
     */
    List<BrandInfoVO> listBrandInfoVO(@Param("start")long start, @Param("count")int count,@Param("cid") Long cid);
    List<BrandInfoVO> listBrandInfoVO(@Param("start")long start, @Param("count")int count,@Param("cid") Long cid,@Param("system") SystemEnum system);
    
    
    long countBrandInfo(@Param("cid") Long cid);
@@ -60,7 +63,7 @@
     * @param cid
     * @return
     */
    List<BrandInfo> listValidByCidToApp(@Param("cid") Long cid);
    List<BrandInfo> listValidByCidToApp(@Param("cid") Long cid,@Param("system") SystemEnum system);
    
    /**
     * 查询店铺cid
@@ -74,18 +77,16 @@
     * @param cid
     * @return
     */
    long countValidByCidToApp(@Param("cid") Long cid);
    long countValidByCidToApp(@Param("cid") Long cid,@Param("system") SystemEnum system);
    
    
    BrandInfo selectByUniqueName(@Param("name") String name, @Param("cid") Long cid, @Param("id") Long id);
    
    
    /**
     * 查询返回前端品牌
     * @param start
     * @param count
     * @param cid
     *  查询返回前端品牌
     * @param key
     * @return
     */
    List<BrandInfoVO> listByAlikeName(@Param("key") String key);
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java
@@ -5,6 +5,7 @@
import java.util.List;
import java.util.Map;
import com.yeshi.fanli.entity.SystemEnum;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
@@ -187,7 +188,7 @@
            @Param("type") Integer type, @Param("orderState") Integer orderState, @Param("startTime") String startTime,
            @Param("endTime") String endTime, @Param("source") Integer source,
            @Param("listShopId")List<Long> listShopId, @Param("listGoodsId")List<Long> listGoodsId,
            @Param("minTime")Date minTime, @Param("money")BigDecimal money, @Param("payment") BigDecimal payment);
            @Param("minTime")Date minTime, @Param("money")BigDecimal money, @Param("payment") BigDecimal payment, @Param("system")  SystemEnum system);
    /**
     * 订单列表查询(不包含子订单)
@@ -207,20 +208,20 @@
    List<CommonOrderVO> listQueryWithNoChild(@Param("start") long start, @Param("count") int count,
            @Param("keyType") Integer keyType, @Param("key") String key, @Param("state") Integer state,
            @Param("type") Integer type, @Param("orderState") Integer orderState, @Param("startTime") String startTime,
            @Param("endTime") String endTime, @Param("source") Integer source, @Param("payment") BigDecimal payment);
            @Param("endTime") String endTime, @Param("source") Integer source, @Param("payment") BigDecimal payment, @Param("system")  SystemEnum system);
    /**
     * 统计
     */
    long countQuery(@Param("keyType") Integer keyType, @Param("key") String key, @Param("state") Integer state,
            @Param("type") Integer type, @Param("orderState") Integer orderState, @Param("startTime") String startTime,
            @Param("endTime") String endTime, @Param("source") Integer source,
            @Param("listShopId")List<Long> listShopId, @Param("listGoodsId")List<Long> listGoodsId,
            @Param("minTime")Date minTime, @Param("money")BigDecimal money,@Param("payment") BigDecimal payment);
                    @Param("type") Integer type, @Param("orderState") Integer orderState, @Param("startTime") String startTime,
                    @Param("endTime") String endTime, @Param("source") Integer source,
                    @Param("listShopId")List<Long> listShopId, @Param("listGoodsId")List<Long> listGoodsId,
                    @Param("minTime")Date minTime, @Param("money")BigDecimal money, @Param("payment") BigDecimal payment, @Param("system")  SystemEnum system);
    long countQueryWithNoChild(@Param("keyType") Integer keyType, @Param("key") String key,
            @Param("state") Integer state, @Param("type") Integer type, @Param("orderState") Integer orderState,
            @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("source") Integer source, @Param("payment") BigDecimal payment);
            @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("source") Integer source, @Param("payment") BigDecimal payment, @Param("system")  SystemEnum system);
    /**
     * 根据来源类型与订单号查询列表
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/LostOrderMapper.java
@@ -4,6 +4,7 @@
import java.util.List;
import java.util.Map;
import com.yeshi.fanli.entity.SystemEnum;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
@@ -36,10 +37,10 @@
     * @return
     */
    List<LostOrder> listQuery(@Param("start") long start, @Param("count") int count, @Param("key") String key,
            @Param("state") Integer state, @Param("handleType") Integer handleType, @Param("type") Integer type);
            @Param("state") Integer state, @Param("handleType") Integer handleType, @Param("type") Integer type,@Param("system") SystemEnum system);
    long countQuery(@Param("key") String key, @Param("state") Integer state, @Param("handleType") Integer handleType,
            @Param("type") Integer type);
            @Param("type") Integer type, @Param("system") SystemEnum system);
    /**
     * 统计申诉订单数量
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserExtraTaoBaoInfoMapper.java
@@ -3,7 +3,9 @@
import java.util.List;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
import org.apache.ibatis.annotations.Param;
public interface UserExtraTaoBaoInfoMapper extends BaseMapper<UserExtraTaoBaoInfo> {
@@ -21,7 +23,7 @@
     * @param taoBaoUid
     * @return
     */
    UserExtraTaoBaoInfo selectByTaoBaoUid(String taoBaoUid);
    UserExtraTaoBaoInfo selectByTaoBaoUid(@Param("taoBaoUid") String taoBaoUid,@Param("system")  SystemEnum system);
    /**
     * 清除用户ID
@@ -37,7 +39,7 @@
     * @param relationId
     * @return
     */
    UserExtraTaoBaoInfo selectByRelationIdWithUidNotNull(String relationId);
    UserExtraTaoBaoInfo selectByRelationIdWithUidNotNull(@Param("relationId") String relationId,@Param("system")  SystemEnum system);
    /**
     * 通过会员运营ID查询
@@ -45,12 +47,12 @@
     * @param specialId
     * @return
     */
    UserExtraTaoBaoInfo selectBySpecialIdWithUidNotNull(String specialId);
    UserExtraTaoBaoInfo selectBySpecialIdWithUidNotNull(@Param("specialId") String specialId,@Param("system")  SystemEnum system);
    
    /**
     * 统计正在使用的该淘宝的用户
     */
    List<UserExtraTaoBaoInfo> listByTaoBaoUid(String taoBaoUid);
    List<UserExtraTaoBaoInfo> listByTaoBaoUid(@Param("taoBaoUid") String taoBaoUid,@Param("system")  SystemEnum system);
    
    
fanli/src/main/java/com/yeshi/fanli/entity/SystemEnum.java
@@ -1,27 +1,39 @@
package com.yeshi.fanli.entity;
import java.util.HashSet;
import java.util.Set;
/**
 * 系统枚举
 */
public enum SystemEnum {
    blks("com.yeshi.ec.rebate", "com.xyj.ec.fanli-ios", new String[]{}, 1, "板栗快省"),
    flq("com.yeshi.ec.flq", "com.xyj.ec.flq-ios", new String[]{}, 2, "返利券");
    blks("com.yeshi.ec.rebate", "com.xyj.ec.fanli-ios", new String[]{}, new SystemFunction[]{
            SystemFunction.bindPhone, SystemFunction.threeSale, SystemFunction.cloudOrder, SystemFunction.godenCorn, SystemFunction.redPack
    }, 1, "板栗快省"),
    flq("com.yeshi.ec.flq", "com.xyj.ec.flq-ios", new String[]{}, new SystemFunction[]{}, 2, "返利券");
    private String packageName;
    private String bundleId;
    private int systemId;
    private String name;
    private String[] wxxcxAppIds;
    private Set<SystemFunction> functionSet;
    private SystemEnum(String packageName, String bundleId, String[] wxxcxAppIds, int systemId, String name) {
    private SystemEnum(String packageName, String bundleId, String[] wxxcxAppIds, SystemFunction[] functions, int systemId, String name) {
        this.bundleId = bundleId;
        this.name = name;
        this.packageName = packageName;
        this.systemId = systemId;
        this.wxxcxAppIds=wxxcxAppIds;
        this.wxxcxAppIds = wxxcxAppIds;
        Set<SystemFunction> set = new HashSet<>();
        if (functions != null)
            for (SystemFunction f : functions)
                set.add(f);
        this.functionSet = set;
    }
    public Set<SystemFunction> getFunctionSet() {
        return functionSet;
    }
    public String getPackageName() {
        return packageName;
fanli/src/main/java/com/yeshi/fanli/entity/SystemFunction.java
New file
@@ -0,0 +1,18 @@
package com.yeshi.fanli.entity;
/**
 * 系统功能
 */
public enum SystemFunction {
    bindPhone("绑定电话号码"),
    threeSale("三级分销"),
    godenCorn("金币"),
    cloudOrder("云发单"),
    redPack("红包"),
    vip("超级会员");
    private SystemFunction(String desc) {
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/HongBaoManage.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.entity.bus.user;
import com.yeshi.fanli.entity.SystemEnum;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
@@ -19,7 +20,17 @@
    private String value;
    @Column(name="remark")
    private String remark;
    @Column(name="system")
    private SystemEnum system;
    public SystemEnum getSystem() {
        return system;
    }
    public void setSystem(SystemEnum system) {
        this.system = system;
    }
    public HongBaoManage() {
    }
    
fanli/src/main/java/com/yeshi/fanli/entity/system/BusinessSystem.java
@@ -13,145 +13,163 @@
import javax.persistence.Transient;
/**
 *    业务系统
 *
 * @author Administrator
 * 业务系统
 *
 * @author Administrator
 */
@Table(name = "yeshi_ec_system")
@org.yeshi.utils.mybatis.Table("yeshi_ec_system")
public class BusinessSystem implements Serializable{
    private static final long serialVersionUID = 2735576110255715412L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    @org.yeshi.utils.mybatis.Column(name="id")
    private Long id;
    @org.yeshi.utils.mybatis.Column(name="name")
    @Column(name = "`name`", length = 50)
    private String name;
    @org.yeshi.utils.mybatis.Column(name="platform")
    private Integer platform;// 1-Android 2-IOS 3-web
    @org.yeshi.utils.mybatis.Column(name="createtime")
    private Long createtime;
    @org.yeshi.utils.mybatis.Column(name="beizhu")
    @Column(name = "`beizhu`", length = 256)
    private String beizhu;
    @org.yeshi.utils.mybatis.Column(name="package_name")
    @Column(name = "`package_name`", length = 50)
    private String packageName;// Android包名或IOS bundleid
    @org.yeshi.utils.mybatis.Column(name="appid")
    private String appid;
public class BusinessSystem implements Serializable {
    private static final long serialVersionUID = 2735576110255715412L;
    @org.yeshi.utils.mybatis.Column(name="system")
    private SystemEnum system;//系统
    @Transient
    private int check;//判断是否选中: 1选中  0 未选中
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    @org.yeshi.utils.mybatis.Column(name = "id")
    private Long id;
    @org.yeshi.utils.mybatis.Column(name = "name")
    @Column(name = "`name`", length = 50)
    private String name;
    @org.yeshi.utils.mybatis.Column(name = "platform")
    private Integer platform;// 1-Android 2-IOS 3-web
    @org.yeshi.utils.mybatis.Column(name = "createtime")
    private Long createtime;
    @org.yeshi.utils.mybatis.Column(name = "beizhu")
    @Column(name = "`beizhu`", length = 256)
    private String beizhu;
    @org.yeshi.utils.mybatis.Column(name = "package_name")
    @Column(name = "`package_name`", length = 50)
    private String packageName;// Android包名或IOS bundleid
    @org.yeshi.utils.mybatis.Column(name = "appid")
    private String appid;
    @org.yeshi.utils.mybatis.Column(name = "system")
    private SystemEnum system;//系统
    @org.yeshi.utils.mybatis.Column(name = "wx_app_id")
    private String wxAppId;
    @org.yeshi.utils.mybatis.Column(name = "wx_app_secret")
    private String wxAppSecret;
    public String getWxAppId() {
        return wxAppId;
    }
    public void setWxAppId(String wxAppId) {
        this.wxAppId = wxAppId;
    }
    public String getWxAppSecret() {
        return wxAppSecret;
    }
    public void setWxAppSecret(String wxAppSecret) {
        this.wxAppSecret = wxAppSecret;
    }
    @Transient
    private int check;//判断是否选中: 1选中  0 未选中
    public BusinessSystem() {
    }
    public BusinessSystem() {
    }
    public BusinessSystem(Long id) {
        super();
        this.id = id;
    }
    public BusinessSystem(Long id) {
        super();
        this.id = id;
    }
    public SystemEnum getSystem() {
        return system;
    }
    public SystemEnum getSystem() {
        return system;
    }
    public void setSystem(SystemEnum system) {
        this.system = system;
    }
    public void setSystem(SystemEnum system) {
        this.system = system;
    }
    public BusinessSystem(String name, int platform, long createtime, String beizhu,
            String packageName) {
        super();
        this.name = name;
        this.platform = platform;
        this.createtime = createtime;
        this.beizhu = beizhu;
        this.packageName = packageName;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Integer getPlatform() {
        return platform;
    }
    public void setPlatform(Integer platform) {
        this.platform = platform;
    }
    public Long getCreatetime() {
        return createtime;
    }
    public void setCreatetime(Long createtime) {
        this.createtime = createtime;
    }
    public String getAppid() {
        return appid;
    }
    public void setAppid(String appid) {
        this.appid = appid;
    }
    public String getPackageName() {
        return packageName;
    }
    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }
    public BusinessSystem(String name, int platform, long createtime, String beizhu,
                          String packageName) {
        super();
        this.name = name;
        this.platform = platform;
        this.createtime = createtime;
        this.beizhu = beizhu;
        this.packageName = packageName;
    }
    public Long getId() {
        return id;
    }
    public String getName() {
        return name;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Integer getPlatform() {
        return platform;
    }
    public void setPlatform(Integer platform) {
        this.platform = platform;
    }
    public Long getCreatetime() {
        return createtime;
    }
    public void setCreatetime(Long createtime) {
        this.createtime = createtime;
    }
    public String getAppid() {
        return appid;
    }
    public void setAppid(String appid) {
        this.appid = appid;
    }
    public String getPackageName() {
        return packageName;
    }
    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }
    public String getBeizhu() {
        return beizhu;
    }
    public String getName() {
        return name;
    }
    public void setBeizhu(String beizhu) {
        this.beizhu = beizhu;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getCheck() {
        return check;
    }
    public void setCheck(int check) {
        this.check = check;
    }
    public String getBeizhu() {
        return beizhu;
    }
    public void setBeizhu(String beizhu) {
        this.beizhu = beizhu;
    }
    public int getCheck() {
        return check;
    }
    public void setCheck(int check) {
        this.check = check;
    }
}
fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java
@@ -328,13 +328,13 @@
            List<String> lastPicture = new ArrayList<>();
            for (JDGoods jdGoods : goodsList) {
                GoodsPicture picture = new GoodsPicture();
                BigDecimal money = JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getShareRate());
                BigDecimal money = JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getShareRate(SystemEnum.blks));
                totalMoney = totalMoney.add(money);
                picture.setGoodsVO(
                        GoodsDetailVOFactory.convertJDGoods(jdGoods,
                                new ConfigParamsDTO(hongBaoManageService.getFanLiRate(),
                                        hongBaoManageService.getShareRate(), null,
                                        hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
                                new ConfigParamsDTO(hongBaoManageService.getFanLiRate(SystemEnum.blks),
                                        hongBaoManageService.getShareRate(SystemEnum.blks), null,
                                        hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,SystemEnum.blks))));
                picture.setGoodState(0);
                picture.setJumpDetail(jumpDetailV2Service.getByTypeCache("goodsdetail"));
                picture.setParams(null);
fanli/src/main/java/com/yeshi/fanli/job/goods/FreeGoodsCouponJob.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;
@@ -44,354 +45,353 @@
@Component
public class FreeGoodsCouponJob {
    @Resource
    private FreeGoodsCouponService freeGoodsCouponService;
    @Resource
    private FreeGoodsCouponService freeGoodsCouponService;
    @Resource
    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
    @Resource
    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private JDGoodsCacheUtil jdGoodsCacheUtil;
    @Resource
    private JDGoodsCacheUtil jdGoodsCacheUtil;
    @Resource
    private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
    @Resource
    private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
    @XxlJob("freeGoodsCouponJob-addFreeGoods")
    public ReturnT<String> startPreOrderTeamIncome(String param) throws Exception {
        updateGoodsTB();
        updateGoodsPDD();
        return ReturnT.SUCCESS;
    }
    @XxlJob("freeGoodsCouponJob-addFreeGoods")
    public ReturnT<String> startPreOrderTeamIncome(String param) throws Exception {
        updateGoodsTB();
        updateGoodsPDD();
        return ReturnT.SUCCESS;
    }
    /**
     * 更新淘宝商品-免单
     */
    private void updateGoodsTB() {
        int maxNum = 5;
        BigDecimal limitPrice = new BigDecimal(2);
        List<FreeGoodsCoupon> listExist = freeGoodsCouponService.listByType(0, 100, Constant.SOURCE_TYPE_TAOBAO);
    /**
     * 更新淘宝商品-免单
     */
    private void updateGoodsTB() {
        int maxNum = 5;
        BigDecimal limitPrice = new BigDecimal(2);
        List<FreeGoodsCoupon> listExist = freeGoodsCouponService.listByType(0, 100, Constant.SOURCE_TYPE_TAOBAO);
        ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
        params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", SystemEnum.blks);
        params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(SystemEnum.blks));
        // 信息更新
        List<GoodsDetailVO> listNew = new ArrayList<GoodsDetailVO>();
        List<FreeGoodsCoupon> listdel = new ArrayList<FreeGoodsCoupon>();
        // 信息更新
        List<GoodsDetailVO> listNew = new ArrayList<GoodsDetailVO>();
        List<FreeGoodsCoupon> listdel = new ArrayList<FreeGoodsCoupon>();
        if (listExist != null && listExist.size() > 0) {
            for (FreeGoodsCoupon freeGood : listExist) {
                HDKGoodsDetail itemDetail = HaoDanKuApiUtil.getInstance().getItemDetail(freeGood.getGoodsId());
                if (itemDetail == null) {
                    listdel.add(freeGood);
                } else {
                    if (listNew.size() >= 5) {
                        listdel.add(freeGood);
                        continue;
                    }
        if (listExist != null && listExist.size() > 0) {
            for (FreeGoodsCoupon freeGood : listExist) {
                HDKGoodsDetail itemDetail = HaoDanKuApiUtil.getInstance().getItemDetail(freeGood.getGoodsId());
                if (itemDetail == null) {
                    listdel.add(freeGood);
                } else {
                    if (listNew.size() >= 5) {
                        listdel.add(freeGood);
                        continue;
                    }
                    // 比例限制: 金比高于60%
                    if (itemDetail.getTkrates() == null || itemDetail.getTkrates() < 60) {
                        listdel.add(freeGood);
                        continue;
                    }
                    // 比例限制: 金比高于60%
                    if (itemDetail.getTkrates() == null || itemDetail.getTkrates() < 60) {
                        listdel.add(freeGood);
                        continue;
                    }
                    TaoBaoGoodsBrief tbGoods = TaoBaoGoodsFactory.create(itemDetail);
                    GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(tbGoods, params);
                    if (detailVO.getCouponPrice() != null) {
                        if (detailVO.getCouponPrice().compareTo(limitPrice) > 0)
                            continue;
                    } else if (detailVO.getZkPrice().compareTo(limitPrice) > 0) {
                        continue;
                    }
                    TaoBaoGoodsBrief tbGoods = TaoBaoGoodsFactory.create(itemDetail);
                    GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(tbGoods, params);
                    if (detailVO.getCouponPrice() != null) {
                        if (detailVO.getCouponPrice().compareTo(limitPrice) > 0)
                            continue;
                    } else if (detailVO.getZkPrice().compareTo(limitPrice) > 0) {
                        continue;
                    }
                    boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
                    if (saveResult) {
                        listNew.add(detailVO);
                    }
                }
            }
        }
                    boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
                    if (saveResult) {
                        listNew.add(detailVO);
                    }
                }
            }
        }
        if (listNew.size() < 5) {
            Integer minId = 1;
            HDKSearchFilter filter = new HDKSearchFilter();
            filter.setBack(100);
            filter.setPriceMax(2);
            filter.setTkratesMin(60);
            while (minId != null) {
                filter.setMinId(minId);
                HDKGoodsListResultDTO dto = HaoDanKuApiUtil.getInstance().queryList(filter);
                if (dto == null) {
                    break;
                }
                minId = dto.getMinId();
                List<HDKGoodsDetail> goodsList = dto.getGoodsList();
                if (goodsList == null || goodsList.size() == 0) {
                    break;
                }
        if (listNew.size() < 5) {
            Integer minId = 1;
            HDKSearchFilter filter = new HDKSearchFilter();
            filter.setBack(100);
            filter.setPriceMax(2);
            filter.setTkratesMin(60);
            while (minId != null) {
                filter.setMinId(minId);
                HDKGoodsListResultDTO dto = HaoDanKuApiUtil.getInstance().queryList(filter);
                if (dto == null) {
                    break;
                }
                minId = dto.getMinId();
                List<HDKGoodsDetail> goodsList = dto.getGoodsList();
                if (goodsList == null || goodsList.size() == 0) {
                    break;
                }
                for (HDKGoodsDetail goods : goodsList) {
                    // 比例限制: 金比高于60%
                    if (goods.getTkrates() == null || goods.getTkrates() < 60)
                        continue;
                for (HDKGoodsDetail goods : goodsList) {
                    // 比例限制: 金比高于60%
                    if (goods.getTkrates() == null || goods.getTkrates() < 60)
                        continue;
                    boolean exist = false;
                    if (listNew.size() > 0) {
                        for (GoodsDetailVO goodsDetailVO : listNew) {
                            if (goodsDetailVO.getGoodsId().equalsIgnoreCase(goods.getItemid() + "")) {
                                exist = true;
                                break;
                            }
                        }
                    }
                    if (exist)
                        continue;
                    boolean exist = false;
                    if (listNew.size() > 0) {
                        for (GoodsDetailVO goodsDetailVO : listNew) {
                            if (goodsDetailVO.getGoodsId().equalsIgnoreCase(goods.getItemid() + "")) {
                                exist = true;
                                break;
                            }
                        }
                    }
                    if (exist)
                        continue;
                    TaoBaoGoodsBrief tbGoods = TaoBaoGoodsFactory.create(goods);
                    GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(tbGoods, params);
                    boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
                    if (saveResult) {
                        listNew.add(detailVO);
                    }
                    TaoBaoGoodsBrief tbGoods = TaoBaoGoodsFactory.create(goods);
                    GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(tbGoods, params);
                    boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
                    if (saveResult) {
                        listNew.add(detailVO);
                    }
                    if (listNew.size() >= maxNum)
                        break;
                }
                    if (listNew.size() >= maxNum)
                        break;
                }
                if (listNew.size() >= maxNum)
                    break;
            }
        }
                if (listNew.size() >= maxNum)
                    break;
            }
        }
        // 删除不满足条件
        if (listdel.size() > 0) {
            for (FreeGoodsCoupon freeGoods : listdel) {
                freeGoodsCouponService.delete(freeGoods.getGoodsId(), freeGoods.getGoodsType());
            }
        }
    }
        // 删除不满足条件
        if (listdel.size() > 0) {
            for (FreeGoodsCoupon freeGoods : listdel) {
                freeGoodsCouponService.delete(freeGoods.getGoodsId(), freeGoods.getGoodsType());
            }
        }
    }
    /**
     * 更新京东商品-免单
     */
    private void updateGoodsJD() {
        int maxNum = 5;
        BigDecimal limitPrice = new BigDecimal(2);
        List<FreeGoodsCoupon> listExist = freeGoodsCouponService.listByType(0, 100, Constant.SOURCE_TYPE_JD);
    /**
     * 更新京东商品-免单
     */
    private void updateGoodsJD() {
        int maxNum = 5;
        BigDecimal limitPrice = new BigDecimal(2);
        List<FreeGoodsCoupon> listExist = freeGoodsCouponService.listByType(0, 100, Constant.SOURCE_TYPE_JD);
        ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
        params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55",SystemEnum.blks);
        params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(SystemEnum.blks));
        // 信息更新
        List<GoodsDetailVO> listNew = new ArrayList<GoodsDetailVO>();
        List<FreeGoodsCoupon> listdel = new ArrayList<FreeGoodsCoupon>();
        if (listExist != null && listExist.size() > 0) {
            for (FreeGoodsCoupon freeGood : listExist) {
                JDGoods goodsInfo = jdGoodsCacheUtil.getGoodsInfo(Long.parseLong(freeGood.getGoodsId()));
                if (goodsInfo == null) {
                    listdel.add(freeGood);
                } else {
                    if (listNew.size() >= 5) {
                        listdel.add(freeGood);
                        continue;
                    }
        // 信息更新
        List<GoodsDetailVO> listNew = new ArrayList<GoodsDetailVO>();
        List<FreeGoodsCoupon> listdel = new ArrayList<FreeGoodsCoupon>();
        if (listExist != null && listExist.size() > 0) {
            for (FreeGoodsCoupon freeGood : listExist) {
                JDGoods goodsInfo = jdGoodsCacheUtil.getGoodsInfo(Long.parseLong(freeGood.getGoodsId()));
                if (goodsInfo == null) {
                    listdel.add(freeGood);
                } else {
                    if (listNew.size() >= 5) {
                        listdel.add(freeGood);
                        continue;
                    }
                    // 比例限制: 金比高于60%
                    JDCommissionInfo commissionInfo = goodsInfo.getCommissionInfo();
                    if (commissionInfo == null) {
                        continue;
                    }
                    if (commissionInfo.getCommissionShare().compareTo(BigDecimal.valueOf(60)) < 0) {
                        continue;
                    }
                    // 比例限制: 金比高于60%
                    JDCommissionInfo commissionInfo = goodsInfo.getCommissionInfo();
                    if (commissionInfo == null) {
                        continue;
                    }
                    if (commissionInfo.getCommissionShare().compareTo(BigDecimal.valueOf(60)) < 0) {
                        continue;
                    }
                    GoodsDetailVO detailVO = GoodsDetailVOFactory.convertJDGoods(goodsInfo, params);
                    GoodsDetailVO detailVO = GoodsDetailVOFactory.convertJDGoods(goodsInfo, params);
                    if (detailVO.getCouponPrice() != null) {
                        if (detailVO.getCouponPrice().compareTo(limitPrice) > 0)
                            continue;
                    } else if (detailVO.getZkPrice().compareTo(limitPrice) > 0) {
                        continue;
                    }
                    if (detailVO.getCouponPrice() != null) {
                        if (detailVO.getCouponPrice().compareTo(limitPrice) > 0)
                            continue;
                    } else if (detailVO.getZkPrice().compareTo(limitPrice) > 0) {
                        continue;
                    }
                    boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
                    if (saveResult) {
                        listNew.add(detailVO);
                    }
                }
            }
        }
        // 不足补齐
        if (listNew.size() < maxNum) {
            JDFilter filterAPI = new JDFilter();
            filterAPI.setPageSize(Constant.PAGE_SIZE);
            filterAPI.setPriceto(2.0);
            filterAPI.setCommissionShareStart(60);
            for (int page = 1; page < 1000; page++) {
                filterAPI.setPageIndex(page);
                JDSearchResult result = JDApiUtil.queryByKey(filterAPI);
                if (result == null) {
                    break;
                }
                    boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
                    if (saveResult) {
                        listNew.add(detailVO);
                    }
                }
            }
        }
        // 不足补齐
        if (listNew.size() < maxNum) {
            JDFilter filterAPI = new JDFilter();
            filterAPI.setPageSize(Constant.PAGE_SIZE);
            filterAPI.setPriceto(2.0);
            filterAPI.setCommissionShareStart(60);
            for (int page = 1; page < 1000; page++) {
                filterAPI.setPageIndex(page);
                JDSearchResult result = JDApiUtil.queryByKey(filterAPI);
                if (result == null) {
                    break;
                }
                List<JDGoods> goodsList = result.getGoodsList();
                if (goodsList == null || goodsList.size() == 0) {
                    break;
                }
                List<JDGoods> goodsList = result.getGoodsList();
                if (goodsList == null || goodsList.size() == 0) {
                    break;
                }
                for (JDGoods goods : goodsList) {
                    // 比例限制: 金比高于60%
                    JDCommissionInfo commissionInfo = goods.getCommissionInfo();
                    if (commissionInfo == null) {
                        continue;
                    }
                    if (commissionInfo.getCommissionShare().compareTo(BigDecimal.valueOf(60)) < 0) {
                        continue;
                    }
                for (JDGoods goods : goodsList) {
                    // 比例限制: 金比高于60%
                    JDCommissionInfo commissionInfo = goods.getCommissionInfo();
                    if (commissionInfo == null) {
                        continue;
                    }
                    if (commissionInfo.getCommissionShare().compareTo(BigDecimal.valueOf(60)) < 0) {
                        continue;
                    }
                    boolean exist = false;
                    if (listNew.size() > 0) {
                        for (GoodsDetailVO goodsDetailVO : listNew) {
                            if (goodsDetailVO.getGoodsId().equalsIgnoreCase(goods.getSkuId() + "")) {
                                exist = true;
                                break;
                            }
                        }
                    }
                    if (exist)
                        continue;
                    boolean exist = false;
                    if (listNew.size() > 0) {
                        for (GoodsDetailVO goodsDetailVO : listNew) {
                            if (goodsDetailVO.getGoodsId().equalsIgnoreCase(goods.getSkuId() + "")) {
                                exist = true;
                                break;
                            }
                        }
                    }
                    if (exist)
                        continue;
                    GoodsDetailVO detailVO = GoodsDetailVOFactory.convertJDGoods(goods, params);
                    boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
                    if (saveResult) {
                        listNew.add(detailVO);
                    }
                    GoodsDetailVO detailVO = GoodsDetailVOFactory.convertJDGoods(goods, params);
                    boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
                    if (saveResult) {
                        listNew.add(detailVO);
                    }
                    if (listNew.size() >= maxNum)
                        break;
                }
                    if (listNew.size() >= maxNum)
                        break;
                }
                if (listNew.size() >= maxNum)
                    break;
            }
        }
                if (listNew.size() >= maxNum)
                    break;
            }
        }
        // 删除不满足条件
        if (listdel.size() > 0) {
            for (FreeGoodsCoupon freeGoods : listdel) {
                freeGoodsCouponService.delete(freeGoods.getGoodsId(), freeGoods.getGoodsType());
            }
        }
    }
        // 删除不满足条件
        if (listdel.size() > 0) {
            for (FreeGoodsCoupon freeGoods : listdel) {
                freeGoodsCouponService.delete(freeGoods.getGoodsId(), freeGoods.getGoodsType());
            }
        }
    }
    /**
     * 更新京东商品-免单
     */
    private void updateGoodsPDD() {
        int maxNum = 5;
        BigDecimal limitPrice = new BigDecimal(2);
        List<FreeGoodsCoupon> listExist = freeGoodsCouponService.listByType(0, 100, Constant.SOURCE_TYPE_PDD);
    /**
     * 更新京东商品-免单
     */
    private void updateGoodsPDD() {
        int maxNum = 5;
        BigDecimal limitPrice = new BigDecimal(2);
        List<FreeGoodsCoupon> listExist = freeGoodsCouponService.listByType(0, 100, Constant.SOURCE_TYPE_PDD);
        ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
        params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55",SystemEnum.blks);
        params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(SystemEnum.blks));
        // 信息更新
        List<GoodsDetailVO> listNew = new ArrayList<GoodsDetailVO>();
        List<FreeGoodsCoupon> listdel = new ArrayList<FreeGoodsCoupon>();
        if (listExist != null && listExist.size() > 0) {
            for (FreeGoodsCoupon freeGood : listExist) {
                PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(freeGood.getGoodsId()));
                if (goodsInfo == null) {
                    listdel.add(freeGood);
                } else {
                    if (listNew.size() >= 5) {
                        listdel.add(freeGood);
                        continue;
                    }
        // 信息更新
        List<GoodsDetailVO> listNew = new ArrayList<GoodsDetailVO>();
        List<FreeGoodsCoupon> listdel = new ArrayList<FreeGoodsCoupon>();
        if (listExist != null && listExist.size() > 0) {
            for (FreeGoodsCoupon freeGood : listExist) {
                PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(freeGood.getGoodsId()));
                if (goodsInfo == null) {
                    listdel.add(freeGood);
                } else {
                    if (listNew.size() >= 5) {
                        listdel.add(freeGood);
                        continue;
                    }
                    // 比例限制: 金比高于60%
                    BigDecimal promotionRate = new BigDecimal(goodsInfo.getPromotionRate());
                    if (promotionRate.compareTo(BigDecimal.valueOf(600)) < 0)
                        continue;
                    // 比例限制: 金比高于60%
                    BigDecimal promotionRate = new BigDecimal(goodsInfo.getPromotionRate());
                    if (promotionRate.compareTo(BigDecimal.valueOf(600)) < 0)
                        continue;
                    GoodsDetailVO detailVO = GoodsDetailVOFactory.convertPDDGoods(goodsInfo, params);
                    if (detailVO.getCouponPrice() != null) {
                        if (detailVO.getCouponPrice().compareTo(limitPrice) > 0)
                            continue;
                    } else if (detailVO.getZkPrice().compareTo(limitPrice) > 0) {
                        continue;
                    }
                    GoodsDetailVO detailVO = GoodsDetailVOFactory.convertPDDGoods(goodsInfo, params);
                    if (detailVO.getCouponPrice() != null) {
                        if (detailVO.getCouponPrice().compareTo(limitPrice) > 0)
                            continue;
                    } else if (detailVO.getZkPrice().compareTo(limitPrice) > 0) {
                        continue;
                    }
                    boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
                    if (saveResult) {
                        listNew.add(detailVO);
                    }
                }
            }
        }
                    boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
                    if (saveResult) {
                        listNew.add(detailVO);
                    }
                }
            }
        }
        // 不足补齐
        if (listNew.size() < maxNum) {
            // 筛选范围列表
            List<PDDSearchRange> rangeList = new ArrayList<>();
            // 券后价小于2元
            rangeList.add(new PDDSearchRange(0L, 0, 200L));
            // 比例60%以上
            rangeList.add(new PDDSearchRange(600L, 2, 1000L));
        // 不足补齐
        if (listNew.size() < maxNum) {
            // 筛选范围列表
            List<PDDSearchRange> rangeList = new ArrayList<>();
            // 券后价小于2元
            rangeList.add(new PDDSearchRange(0L, 0, 200L));
            // 比例60%以上
            rangeList.add(new PDDSearchRange(600L, 2, 1000L));
            PDDSearchFilter pddfilter = new PDDSearchFilter();
            pddfilter.setRangeList(rangeList);
            for (int page = 1; page < 1000; page++) {
                pddfilter.setPage(page);
                PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
                if (result == null) {
                    break;
                }
            PDDSearchFilter pddfilter = new PDDSearchFilter();
            pddfilter.setRangeList(rangeList);
            for (int page = 1; page < 1000; page++) {
                pddfilter.setPage(page);
                PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
                if (result == null) {
                    break;
                }
                List<PDDGoodsDetail> goodsList = result.getGoodsList();
                if (goodsList == null || goodsList.size() == 0) {
                    break;
                }
                List<PDDGoodsDetail> goodsList = result.getGoodsList();
                if (goodsList == null || goodsList.size() == 0) {
                    break;
                }
                for (PDDGoodsDetail goods : goodsList) {
                    boolean exist = false;
                    if (listNew.size() > 0) {
                        for (GoodsDetailVO goodsDetailVO : listNew) {
                            if (goodsDetailVO.getGoodsId().equalsIgnoreCase(goods.getGoodsId() + "")) {
                                exist = true;
                                break;
                            }
                        }
                    }
                    if (exist)
                        continue;
                for (PDDGoodsDetail goods : goodsList) {
                    boolean exist = false;
                    if (listNew.size() > 0) {
                        for (GoodsDetailVO goodsDetailVO : listNew) {
                            if (goodsDetailVO.getGoodsId().equalsIgnoreCase(goods.getGoodsId() + "")) {
                                exist = true;
                                break;
                            }
                        }
                    }
                    if (exist)
                        continue;
                    GoodsDetailVO detailVO = GoodsDetailVOFactory.convertPDDGoods(goods, params);
                    boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
                    if (saveResult) {
                        listNew.add(detailVO);
                    }
                    GoodsDetailVO detailVO = GoodsDetailVOFactory.convertPDDGoods(goods, params);
                    boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
                    if (saveResult) {
                        listNew.add(detailVO);
                    }
                    if (listNew.size() >= maxNum)
                        break;
                }
                    if (listNew.size() >= maxNum)
                        break;
                }
                if (listNew.size() >= maxNum)
                    break;
            }
        }
                if (listNew.size() >= maxNum)
                    break;
            }
        }
        // 删除不满足条件
        if (listdel.size() > 0) {
            for (FreeGoodsCoupon freeGoods : listdel) {
                freeGoodsCouponService.delete(freeGoods.getGoodsId(), freeGoods.getGoodsType());
            }
        }
    }
        // 删除不满足条件
        if (listdel.size() > 0) {
            for (FreeGoodsCoupon freeGoods : listdel) {
                freeGoodsCouponService.delete(freeGoods.getGoodsId(), freeGoods.getGoodsType());
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/activity/ActivityServiceImpl.java
@@ -370,7 +370,7 @@
            goods.setRecommendActivity(activity);
            goods.setCouponAmount(tb.getCouponAmount());
            recommendActivityTaoBaoGoodsMapper.insertSelective(goods);
            BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb);
            BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb,SystemEnum.blks);
            taotaoMoney = taotaoMoney.add(money);
            // 转换简版商品信息
@@ -561,7 +561,7 @@
            goods.setTitle(tb.getTitle());
            goods.setCouponAmount(tb.getCouponAmount());
            recommendActivityTaoBaoGoodsMapper.insertSelective(goods);
            BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb);
            BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb,SystemEnum.blks);
            taotaoMoney = taotaoMoney.add(money);
            listgoods.add(goods);
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopServiceImpl.java
@@ -9,6 +9,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;
@@ -264,8 +265,8 @@
    }
    @Override
    @Cacheable(value = "brandCache", key = "'listEffectiveCache-'+#page+'-'+#cid")
    public JSONObject listEffectiveCache(int page, Long cid) {
    @Cacheable(value = "brandCache", key = "'listEffectiveCache-'+#page+'-'+#cid+'-'+#system")
    public JSONObject listEffectiveCache(int page, Long cid,SystemEnum system) {
        long countShop = 0;
        if (cid != null && cid <= 0) {
@@ -275,7 +276,7 @@
        List<TaoBaoShop> listShop = new ArrayList<TaoBaoShop>();
        // 第一页 查询全部分类下店铺
        if (page == 1 && cid != null) {
            List<BrandClassShop> list = brandClassShopMapper.listEffective(cid);
            List<BrandClassShop> list = brandClassShopMapper.listEffective(cid,system);
            if (list == null) {
                list = new ArrayList<BrandClassShop>();
            } else if (list.size() > 0) {
@@ -321,7 +322,7 @@
        // 淘宝商品信息过滤
        Map<Long, TaoBaoGoodsBrief> goodsMap = getFilterTaoBaoGoods(listInfo);
        BigDecimal proportion = hongBaoManageService.getFanLiRate();
        BigDecimal proportion = hongBaoManageService.getFanLiRate(system);
        for (TaoBaoShopVO taoBaoShopVO : listInfo) {
            String shopLink = taoBaoShopVO.getShopLink();
@@ -373,8 +374,8 @@
    }
    @Override
    @Cacheable(value = "brandCache", key = "'listEffectiveCacheV2-'+#page+'-'+#cid+'-'+#platform+'-'+#version")
    public JSONObject listEffectiveCacheV2(int page, Long cid,String platform,String version) {
    @Cacheable(value = "brandCache", key = "'listEffectiveCacheV2-'+#page+'-'+#cid+'-'+#platform+'-'+#version+'-'+#system")
    public JSONObject listEffectiveCacheV2(int page, Long cid,String platform,String version,SystemEnum system) {
        long countShop = 0;
        if (cid != null && cid <= 0) {
@@ -384,7 +385,7 @@
        List<TaoBaoShop> listShop = new ArrayList<TaoBaoShop>();
        // 第一页 查询全部分类下店铺
        if (page == 1 && cid != null) {
            List<BrandClassShop> list = brandClassShopMapper.listEffective(cid);
            List<BrandClassShop> list = brandClassShopMapper.listEffective(cid,system);
            if (list == null) {
                list = new ArrayList<BrandClassShop>();
            } else if (list.size() > 0) {
@@ -435,7 +436,7 @@
            count = taoBaoShopService.countBrandShopinfo(cid);
        }
        ConfigParamsDTO paramsDTO =     orderHongBaoMoneyComputeService.getShowComputeRate(platform, version);
        ConfigParamsDTO paramsDTO =     orderHongBaoMoneyComputeService.getShowComputeRate(platform, version,system);
        // 淘宝商品信息过滤
        Map<Long, TaoBaoGoodsBrief> goodsMap = getFilterTaoBaoGoods(listInfo);
@@ -530,7 +531,7 @@
    
    @Override
    public List<TaoBaoShopVO> listEffectiveShop(long start, int count, Long cid,String platform,String version) {
    public List<TaoBaoShopVO> listEffectiveShop(long start, int count, Long cid,String platform,String version,SystemEnum system) {
        if (cid != null && cid <= 0) {
            cid = null;
        }
@@ -541,7 +542,7 @@
        
        ConfigParamsDTO paramsDTO = 
                orderHongBaoMoneyComputeService.getShowComputeRate(platform, version);
                orderHongBaoMoneyComputeService.getShowComputeRate(platform, version,system);
        // 淘宝商品信息过滤
        Map<Long, TaoBaoGoodsBrief> goodsMap = getFilterTaoBaoGoods(listInfo);
@@ -582,11 +583,11 @@
    
    
    @Override
    public List<TaoBaoShop> listEffectiveClassShop(Long cid) {
    public List<TaoBaoShop> listEffectiveClassShop(Long cid, SystemEnum system) {
        if (cid == null)
            return null;
        
        List<BrandClassShop> list = brandClassShopMapper.listEffective(cid);
        List<BrandClassShop> list = brandClassShopMapper.listEffective(cid,system);
        if (list == null || list.size() == 0)
            return null;
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java
@@ -9,6 +9,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Service;
@@ -300,10 +301,10 @@
    @Override
    @Cacheable(value = "brandCache", key = "'listValidBrandInfoCache-'+#cid")
    public List<BrandInfo> listValidBrandInfoCache(Long cid) {
    public List<BrandInfo> listValidBrandInfoCache(Long cid,SystemEnum system) {
        List<BrandInfo> listInfo = new ArrayList<BrandInfo>();
        List<TaoBaoShop> listShop = brandClassShopService.listEffectiveClassShop(cid);
        List<TaoBaoShop> listShop = brandClassShopService.listEffectiveClassShop(cid,system);
        if (listShop == null || listShop.size() == 0)
            return listInfo;
        for (TaoBaoShop taoBaoShop : listShop) {
@@ -317,11 +318,11 @@
    }
    @Override
    @Cacheable(value = "brandCache", key = "'listBrandInfoCache-'+#start+'-'+#start +'-'+#cid+'-'+#platform+'-'+#version")
    public List<BrandInfoVO> listBrandInfoCache(long start, int count, Long cid, String platform, String version) {
    @Cacheable(value = "brandCache", key = "'listBrandInfoCache-'+#start+'-'+#start +'-'+#cid+'-'+#platform+'-'+#version+'-'+#system")
    public List<BrandInfoVO> listBrandInfoCache(long start, int count, Long cid, String platform, String version,SystemEnum system) {
        List<BrandInfoVO> listInfo = new ArrayList<BrandInfoVO>();
        List<TaoBaoShopVO> listShop = brandClassShopService.listEffectiveShop(start, count, cid, platform, version);
        List<TaoBaoShopVO> listShop = brandClassShopService.listEffectiveShop(start, count, cid, platform, version,system);
        if (listShop == null || listShop.size() == 0)
            return listInfo;
@@ -436,26 +437,26 @@
    }
    @Override
    public long countValidByCidToApp(Long cid) {
        return brandInfoMapper.countValidByCidToApp(cid);
    public long countValidByCidToApp(Long cid, SystemEnum system) {
        return brandInfoMapper.countValidByCidToApp(cid,system);
    }
    @Override
    @Cacheable(value = "brandCache", key = "'listValidByCidToApp-'+#cid")
    public List<BrandInfo> listValidByCidToApp(Long cid) {
    @Cacheable(value = "brandCache", key = "'listValidByCidToApp-'+#cid+'-'+#system")
    public List<BrandInfo> listValidByCidToApp(Long cid, SystemEnum system) {
        if (cid == null)
            return null;
        return brandInfoMapper.listValidByCidToApp(cid);
        return brandInfoMapper.listValidByCidToApp(cid,system);
    }
    @Cacheable(value = "brandCache", key = "'listValidToApp-'+#start+'-'+#cid")
    @Cacheable(value = "brandCache", key = "'listValidToApp-'+#start+'-'+#cid+'-'+#system")
    @Override
    public List<BrandInfoVO> listValidToApp(long start, int count, Long cid, String platform, String version) {
        List<BrandInfoVO> list = brandInfoMapper.listBrandInfoVO(start, count, cid);
    public List<BrandInfoVO> listValidToApp(long start, int count, Long cid, String platform, String version,SystemEnum system) {
        List<BrandInfoVO> list = brandInfoMapper.listBrandInfoVO(start, count, cid,system);
        if (list == null || list.size() == 0)
            return null;
        ConfigParamsDTO configParamsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version);
        ConfigParamsDTO configParamsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version,system);
        List<BrandInfoVO> listInfo = new ArrayList<BrandInfoVO>();
        for (int i = 0; i < list.size(); i++) {
@@ -497,8 +498,8 @@
    }
    @Override
    @Cacheable(value = "brandCache", key = "'listByAlikeName-'+#key+'-'+#platform+'-'+#version")
    public BrandInfoVO listByAlikeName(String key, String platform, String version) {
    @Cacheable(value = "brandCache", key = "'listByAlikeName-'+#key+'-'+#platform+'-'+#version+'-'+#system")
    public BrandInfoVO listByAlikeName(String key, String platform, String version,SystemEnum system) {
        if (StringUtil.isNullOrEmpty(key))
            return null;
@@ -506,7 +507,7 @@
        if (list == null || list.size() == 0)
            return null;
        ConfigParamsDTO configParamsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version);
        ConfigParamsDTO configParamsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version, system);
        BrandInfoVO brand = list.get(0);
        List<BrandGoodsCahe> listGoods = brandGoodsCaheService.getByBrandId(1, 3, brand.getId());
fanli/src/main/java/com/yeshi/fanli/service/impl/config/BusinessSystemServiceImpl.java
@@ -6,6 +6,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
@@ -34,24 +35,24 @@
    }
    @Override
    public BusinessSystem getBusinessSystem(String platform, String packages) {
    public BusinessSystem getBusinessSystem(String platform, String packages, SystemEnum system) {
        if (platform == null || packages == null) {
            return null;
        }
        platform = platform.toUpperCase();
        Integer platformInt = map.get(platform);
        List<BusinessSystem> list = businessSystemMapper.listByPlatformAndPackage(platformInt, packages);
        List<BusinessSystem> list = businessSystemMapper.listByPlatformAndPackage(platformInt, packages,system);
        if (list == null || list.size() == 0) {
            return null;
        }
        return list.get(0);
    }
    @Cacheable(value = "sysCache", key = "'getBusinessSystem-'+#platform+'-'+#packages")
    @Cacheable(value = "sysCache", key = "'getBusinessSystem-'+#platform+'-'+#packages+'-'+#system")
    @Override
    public BusinessSystem getBusinessSystemCache(String platform, String packages) {
        return getBusinessSystem(platform, packages);
    public BusinessSystem getBusinessSystemCache(String platform, String packages, SystemEnum system) {
        return getBusinessSystem(platform, packages,system);
    }
    @Override
fanli/src/main/java/com/yeshi/fanli/service/impl/count/CommonOrderCountServiceImpl.java
@@ -8,6 +8,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.stereotype.Service;
import org.yeshi.utils.DateUtil;
@@ -44,16 +45,10 @@
    @Resource
    private CommonOrderCountMapper commonOrderCountMapper;
    @Resource
    private CountOrderInfoDao countOrderInfoDao;
    @Resource
    private CountOrderTrackRateDao countOrderTrackRateDao;
    
    @Override
    public Long countByState(Integer state) {
        return commonOrderCountMapper.countByState(state);
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/DynamicInfoServiceImpl.java
@@ -13,6 +13,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.core.task.TaskExecutor;
@@ -106,9 +107,6 @@
    @Resource
    private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
    @Resource
    private GoodsEvaluateService goodsEvaluateService;
    @Override
    public void insert(DynamicInfo record) {
        dynamicInfoDao.insert(record);
@@ -306,7 +304,7 @@
        // 商品信息
        List<GoodsPicture> listPicture = new ArrayList<GoodsPicture>();
        for (TaoBaoGoodsBrief goodsBrief : listGoods) {
            BigDecimal proportion = hongBaoManageService.getFanLiRate();
            BigDecimal proportion = hongBaoManageService.getFanLiRate(SystemEnum.blks);
            TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief,
                    proportion.toString(), null);
            taoBaoGoodsBriefExtra.setCouponInfo(null);
@@ -362,7 +360,7 @@
            // 分享奖金
            BigDecimal shareMoney = new BigDecimal(0);
            BigDecimal proportion = hongBaoManageService.getFanLiRate();
            BigDecimal proportion = hongBaoManageService.getFanLiRate(SystemEnum.blks);
            for (DaTaoKeDetailV2 daTaoKe : listDaTaoKe) {
                if (daTaoKeDetail == null) {
                    daTaoKeDetail = daTaoKe;
@@ -377,7 +375,7 @@
                    taoBaoGoodsBriefExtra.setState(1);
                }
                BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(taoBaoGoodsBrief);
                BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(taoBaoGoodsBrief,SystemEnum.blks);
                shareMoney = MoneyBigDecimalUtil.add(shareMoney, money);
                // 商品图片
                taoBaoGoodsBriefExtra.setUpdatetime(new Date());
@@ -495,7 +493,7 @@
        }
        TaoBaoGoodsBrief taoBaoGoodsBrief = TaoBaoUtil.convert(daTaoKe);
        BigDecimal proportion = hongBaoManageService.getFanLiRate();
        BigDecimal proportion = hongBaoManageService.getFanLiRate(SystemEnum.blks);
        TaoBaoGoodsBriefExtra goodsExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(),
                null);
@@ -543,7 +541,7 @@
        goodsExtra.setImgList(imgList);
        // 分享奖金
        BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(taoBaoGoodsBrief);
        BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(taoBaoGoodsBrief,SystemEnum.blks);
        ClientTextStyleVO shareMoneyDesc = new ClientTextStyleVO();
        shareMoneyDesc.setColor("#FFFFFF");
        shareMoneyDesc.setBottomColor("#E8AE48");
@@ -813,7 +811,7 @@
            List<TaoBaoGoodsBrief> listGoods = new ArrayList<TaoBaoGoodsBrief>();
            // 商品列表
            List<GoodsPicture> listPicture = new ArrayList<GoodsPicture>();
            BigDecimal proportion = hongBaoManageService.getFanLiRate();
            BigDecimal proportion = hongBaoManageService.getFanLiRate(SystemEnum.blks);
            // 分享奖金
            BigDecimal shareMoney = new BigDecimal(0);
@@ -832,7 +830,7 @@
                            taoBaoGoodsBriefExtra.setState(1);
                        }
                        BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(taoBaoGoodsBrief);
                        BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(taoBaoGoodsBrief,SystemEnum.blks);
                        shareMoney = MoneyBigDecimalUtil.add(shareMoney, money);
                    } catch (TaobaoGoodsDownException e) {
                        taoBaoGoodsBrief = activityGoods.getTaoBaoGoodsBrief();
@@ -978,9 +976,9 @@
            // 提取商品
            Map<Long, TaoBaoGoodsBrief> goodsMap = getFilterGoodsMap(list);
            BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
            BigDecimal shareRate = hongBaoManageService.getShareRate();
            ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP));
            BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(SystemEnum.blks);
            BigDecimal shareRate = hongBaoManageService.getShareRate(SystemEnum.blks);
            ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,SystemEnum.blks));
            for (DynamicInfo dynamicInfo : list) {
                DynamicInfo dynamicNew = new DynamicInfo();
@@ -1083,7 +1081,7 @@
        }
        try {
            BigDecimal proportion = hongBaoManageService.getFanLiRate();
            BigDecimal proportion = hongBaoManageService.getFanLiRate(SystemEnum.blks);
            for (DynamicInfo dynamicInfo : list) {
                // 邀请数据不做更新
                long classId = dynamicInfo.getClassId();
@@ -1170,7 +1168,7 @@
                        // 更新热销单品的分享奖金
                        if (classId == 1) {
                            BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(goodsBrief);
                            BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(goodsBrief,SystemEnum.blks);
                            ClientTextStyleVO shareMoneyDesc = new ClientTextStyleVO();
                            shareMoneyDesc.setColor("#FFFFFF");
                            shareMoneyDesc.setBottomColor("#E8AE48");
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
@@ -427,8 +427,8 @@
        GoodsDetailVO goodsDetailVO = null;
        JDGoods jdGoods = null;
        PDDGoodsDetail pddGoods = null;
        ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
        params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
        params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
        if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
            try {
                TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(Long.parseLong(goodsId));
@@ -647,10 +647,10 @@
        return commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
    }
    public GoodsDetailVO getGoodsDetailVO(Long goodsId, Integer goodsType) throws GoodsEvaluateException {
    public GoodsDetailVO getGoodsDetailVO(Long goodsId, Integer goodsType, SystemEnum system) throws GoodsEvaluateException {
        GoodsDetailVO goodsDetail = null;
        ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
        params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
        params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
        if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
            try {
                TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(goodsId);
@@ -758,7 +758,7 @@
                for (int i = 0; i < goodsArray.length && i < 9; i++) {
                    String goodsids = goodsArray[i];
                    String[] g = goodsids.split("-");
                    GoodsDetailVO goodsDetailVO = getGoodsDetailVO(Long.parseLong(g[0]), Integer.parseInt(g[1]));
                    GoodsDetailVO goodsDetailVO = getGoodsDetailVO(Long.parseLong(g[0]), Integer.parseInt(g[1]), resultObj.getSystem());
                    if (goodsDetailVO == null) {
                        continue;
                    }
@@ -1821,9 +1821,10 @@
        try {
            Date now = new Date();
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
            params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
            for (GoodsEvaluate goodsEvaluate : list) {
                ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", goodsEvaluate.getSystem());
                params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(goodsEvaluate.getSystem()));
                // 是否2个小时之内已更新
                Date updateTime = goodsEvaluate.getUpdateTime();
                if (updateTime != null) {
@@ -1976,8 +1977,8 @@
        imgs.addAll(goodsBrief.getImgList());
        // 商品VO
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
        GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO);
        // 商品图片信息
@@ -2100,8 +2101,8 @@
        }
        // 商品VO
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
        GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO);
        // 商品图片信息
@@ -2286,8 +2287,8 @@
                return false;
            }
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
            GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO);
            ActivityUser user = null;
@@ -2515,8 +2516,8 @@
                if (queryExist == null || queryExist.size() == 0) {
                    continue;
                }
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
                paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
                paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
                GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO);
                updateGoods(queryExist, goodsNew);
            }
@@ -2537,8 +2538,8 @@
                continue;
            }
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
            GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
            updateGoods(queryExist, goodsNew);
@@ -2556,8 +2557,8 @@
                continue;
            }
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
            GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO);
            updateGoods(queryExist, goodsNew);
        }
@@ -2575,8 +2576,8 @@
                continue;
            }
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
            GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertVIPGoods(goods, paramsDTO);
            updateGoods(queryExist, goodsNew);
        }
@@ -2593,18 +2594,18 @@
            if (queryExist == null || queryExist.size() == 0) {
                continue;
            }
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
            GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertSuningGoods(goods, paramsDTO);
            updateGoods(queryExist, goodsNew);
        }
    }
    private void updateGoods(List<GoodsEvaluate> listExist, GoodsDetailVO goodsNew) {
        String goodsId = goodsNew.getGoodsId();
        int goodsType = goodsNew.getGoodsType();
        for (GoodsEvaluate goodsEvaluate : listExist) {
            String goodsId = goodsNew.getGoodsId();
            int goodsType = goodsNew.getGoodsType();
            GoodsDetailVO goodsDetailVO = goodsEvaluate.getGoods();
            if (goodsDetailVO != null && goodsDetailVO.getGoodsId() != null && goodsDetailVO.getGoodsId().equalsIgnoreCase(goodsId)
                    && goodsDetailVO.getGoodsType() == goodsType) {
@@ -2748,8 +2749,8 @@
    @Override
    public GoodsEvaluate queryExistSingle(String goodsId, int goodsType,SystemEnum system) {
        List<GoodsEvaluate> list = goodsEvaluateDao.queryExistSingle(goodsType, goodsId,system);
    public GoodsEvaluate queryExistSingle(String goodsId, int goodsType, SystemEnum system) {
        List<GoodsEvaluate> list = goodsEvaluateDao.queryExistSingle(goodsType, goodsId, system);
        if (list != null && list.size() > 0)
            return list.get(0);
        return null;
fanli/src/main/java/com/yeshi/fanli/service/impl/elme/ElmeOrderProcessServiceImpl.java
@@ -5,6 +5,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -31,122 +32,123 @@
@Service
public class ElmeOrderProcessServiceImpl implements ElmeOrderProcessService {
    @Resource
    private ElmeOrderService elmeOrderService;
    @Resource
    private ElmeOrderService elmeOrderService;
    @Resource
    private ElmeHongBaoOrderMapService elmeHongBaoOrderMapService;
    @Resource
    private ElmeHongBaoOrderMapService elmeHongBaoOrderMapService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private HongBaoV2Service hongBaoV2Service;
    @Resource
    private HongBaoV2Service hongBaoV2Service;
    @Resource
    private UserOrderMsgNotificationService userOrderMsgNotificationService;
    @Resource
    private UserOrderMsgNotificationService userOrderMsgNotificationService;
    @Resource
    private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
    @Resource
    private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void processOrder(ElmeOrder elmeOrder) throws ElmeOrderException {
        try {
            elmeOrderService.addOrder(elmeOrder);
        } catch (ElmeOrderException e) {
            return;
        }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void processOrder(ElmeOrder elmeOrder) throws ElmeOrderException {
        try {
            elmeOrderService.addOrder(elmeOrder);
        } catch (ElmeOrderException e) {
            return;
        }
        if (elmeOrder.getId() == null)
            return;
        // 查询订单是否存在
        ElmeHongBaoOrderMap map = elmeHongBaoOrderMapService.selectByOrderId(elmeOrder.getId());
        if (map == null)// 订单不存在
        {
            Long uid = null;
            if (StringUtil.isNullOrEmpty(elmeOrder.getChannelId())) {// 新版本
                UserExtraTaoBaoInfo extra = userExtraTaoBaoInfoService.getByRelationId(elmeOrder.getRid());
                if (extra != null)
                    uid = extra.getUser().getId();
            } else {// 老版本
                uid = Long.parseLong(elmeOrder.getRid());
            }
        if (elmeOrder.getId() == null)
            return;
        // 查询订单是否存在
        ElmeHongBaoOrderMap map = elmeHongBaoOrderMapService.selectByOrderId(elmeOrder.getId());
        if (map == null)// 订单不存在
        {
            Long uid = null;
            if (StringUtil.isNullOrEmpty(elmeOrder.getChannelId())) {// 新版本
                UserExtraTaoBaoInfo extra = userExtraTaoBaoInfoService.getByRelationId(elmeOrder.getRid(), null);
                if (extra != null)
                    uid = extra.getUser().getId();
            } else {// 老版本
                uid = Long.parseLong(elmeOrder.getRid());
            }
            if (uid == null)
                return;
            if (uid == null)
                return;
            // 查询映射用户
            UserInfo user = userInfoService.selectByPKey(uid);
            if (user == null)
                return;
            // 制造hongbao
            HongBaoV2 hongBao = createHongBao(elmeOrder, user);
            hongBao.setUpdateTime(new Date());
            hongBaoV2Service.insertSelective(hongBao);
            // 添加红包映射
            ElmeHongBaoOrderMap newMap = new ElmeHongBaoOrderMap();
            newMap.setCreateTime(new Date());
            newMap.setElmeOrder(elmeOrder);
            newMap.setHongBao(hongBao);
            try {
                elmeHongBaoOrderMapService.addHongBaoOrderMap(newMap);
            } catch (ElmeHongBaoOrderMapException e) {
                throw new ElmeOrderException(e.getCode(), e.getMsg());
            }
            // 查询映射用户
            UserInfo user = userInfoService.selectByPKey(uid);
            if (user == null)
                return;
            SystemEnum system = userInfoService.getUserSystem(uid);
            // 制造hongbao
            HongBaoV2 hongBao = createHongBao(elmeOrder, user, system);
            hongBao.setUpdateTime(new Date());
            hongBaoV2Service.insertSelective(hongBao);
            // 添加红包映射
            ElmeHongBaoOrderMap newMap = new ElmeHongBaoOrderMap();
            newMap.setCreateTime(new Date());
            newMap.setElmeOrder(elmeOrder);
            newMap.setHongBao(hongBao);
            try {
                elmeHongBaoOrderMapService.addHongBaoOrderMap(newMap);
            } catch (ElmeHongBaoOrderMapException e) {
                throw new ElmeOrderException(e.getCode(), e.getMsg());
            }
        } else {// 订单存在
            HongBaoV2 oldHongBao = hongBaoV2Service.selectByPrimaryKey(map.getHongBao().getId());
            if (oldHongBao == null)
                return;
            // 失效与到账状态的红包不需要修改
            if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
                return;
        } else {// 订单存在
            HongBaoV2 oldHongBao = hongBaoV2Service.selectByPrimaryKey(map.getHongBao().getId());
            if (oldHongBao == null)
                return;
            // 失效与到账状态的红包不需要修改
            if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
                return;
            SystemEnum system = userInfoService.getUserSystem(oldHongBao.getUserInfo().getId());
            HongBaoV2 hongBao = createHongBao(elmeOrder, null, system);
            if (hongBao.getState() != oldHongBao.getState()) {// 是否需要修改红包状态
                HongBaoV2 update = new HongBaoV2(oldHongBao.getId());
                update.setState(hongBao.getState());
                update.setPreGetTime(hongBao.getPreGetTime());
                update.setUpdateTime(new Date());
                hongBaoV2Service.updateByPrimaryKeySelective(update);
            HongBaoV2 hongBao = createHongBao(elmeOrder, null);
            if (hongBao.getState() != oldHongBao.getState()) {// 是否需要修改红包状态
                HongBaoV2 update = new HongBaoV2(oldHongBao.getId());
                update.setState(hongBao.getState());
                update.setPreGetTime(hongBao.getPreGetTime());
                update.setUpdateTime(new Date());
                hongBaoV2Service.updateByPrimaryKeySelective(update);
            }
        }
            }
        }
    }
    }
    private HongBaoV2 createHongBao(ElmeOrder elmeOrder, UserInfo userInfo, SystemEnum system) {
        BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
                elmeOrder.getOrderDate().getTime(), system);
        HongBaoV2 hongBao = new HongBaoV2();
        hongBao.setCreateTime(new Date());
        hongBao.setGetTime(null);
        hongBao.setMoney(MoneyBigDecimalUtil.div(
                MoneyBigDecimalUtil.mul(ElmeOrderUtil.getCommission(elmeOrder.getPayMoney()), fanliRate),
                new BigDecimal(100)));
        if (elmeOrder.getIsSettle() == true)
            hongBao.setPreGetTime(new Date(elmeOrder.getOrderDate().getTime() + 1000 * 60 * 60 * 24 * 15L));
        if (elmeOrder.getPayMoney().compareTo(new BigDecimal(0)) <= 0
                || (elmeOrder.getState() != null && elmeOrder.getState() == 0))
            hongBao.setState(HongBaoV2.STATE_SHIXIAO);
        else {
            if (elmeOrder.getIsSettle() == true) {
                hongBao.setState(HongBaoV2.STATE_KELINGQU);
            } else {
                hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
            }
        }
    private HongBaoV2 createHongBao(ElmeOrder elmeOrder, UserInfo userInfo) {
        BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
                elmeOrder.getOrderDate().getTime());
        HongBaoV2 hongBao = new HongBaoV2();
        hongBao.setCreateTime(new Date());
        hongBao.setGetTime(null);
        hongBao.setMoney(MoneyBigDecimalUtil.div(
                MoneyBigDecimalUtil.mul(ElmeOrderUtil.getCommission(elmeOrder.getPayMoney()), fanliRate),
                new BigDecimal(100)));
        if (elmeOrder.getIsSettle() == true)
            hongBao.setPreGetTime(new Date(elmeOrder.getOrderDate().getTime() + 1000 * 60 * 60 * 24 * 15L));
        if (elmeOrder.getPayMoney().compareTo(new BigDecimal(0)) <= 0
                || (elmeOrder.getState() != null && elmeOrder.getState() == 0))
            hongBao.setState(HongBaoV2.STATE_SHIXIAO);
        else {
            if (elmeOrder.getIsSettle() == true) {
                hongBao.setState(HongBaoV2.STATE_KELINGQU);
            } else {
                hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
            }
        }
        hongBao.setType(HongBaoV2.TYPE_ELME);
        if (userInfo != null)
            hongBao.setUrank(userInfo.getRank());
        hongBao.setUserInfo(userInfo);
        hongBao.setVersion(2);
        return hongBao;
    }
        hongBao.setType(HongBaoV2.TYPE_ELME);
        if (userInfo != null)
            hongBao.setUrank(userInfo.getRank());
        hongBao.setUserInfo(userInfo);
        hongBao.setVersion(2);
        return hongBao;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java
@@ -9,6 +9,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
@@ -142,9 +143,9 @@
        return navList;
    }
    @Cacheable(value = "commonContentCache", key = "#type+'-'+#cid+'-'+#page+'-'+#pageSize")
    @Cacheable(value = "commonContentCache", key = "#type+'-'+#cid+'-'+#page+'-'+#pageSize+'-'+#system")
    @Override
    public CommonContentResult getContentList(CommonContentTypeEnum type, String cid, int page, int pageSize) {
    public CommonContentResult getContentList(CommonContentTypeEnum type, String cid, int page, int pageSize, SystemEnum system) {
        CommonContentResult result = null;
        if (type == CommonContentTypeEnum._9k9) {
            result = get9K9Content(cid, page, pageSize);
@@ -171,7 +172,7 @@
        } else if (type == CommonContentTypeEnum.chaoPinReMai) {
            result = getChaoPinReMaiContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.chaoSheng) {
            result = getCaoShengContent(cid, page, pageSize);
            result = getCaoShengContent(cid, page, pageSize,system);
        } else if (type == CommonContentTypeEnum.haoQuan) {
            result = getHaoQuanContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.mianDan) {
@@ -254,7 +255,7 @@
     * @param pageSize
     * @return
     */
    private CommonContentResult getCaoShengContent(String cid, int page, int pageSize) {
    private CommonContentResult getCaoShengContent(String cid, int page, int pageSize, SystemEnum system) {
        pageSize = Constant.PAGE_SIZE;
        Integer startAmount = null;
        Integer endAmount = null;
@@ -278,7 +279,7 @@
        double tkRate = 20.00;
        BigDecimal proportion = hongBaoManageService.getFanLiRate();
        BigDecimal proportion = hongBaoManageService.getFanLiRate(system);
        List<QualityFactory> listQuery = qualityGoodsService.listQueryByRebateAmount((page - 1) * pageSize, pageSize,
                proportion.toString(), startAmount, endAmount, tkRate);
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java
@@ -73,455 +73,454 @@
@Service
public class ShareGoodsServiceImpl implements ShareGoodsService {
    @Resource
    private TBPidService tbPidService;
    @Resource
    private TBPidService tbPidService;
    @Resource
    private UserShareGoodsHistoryMapper userShareGoodsHistoryMapper;
    @Resource
    private UserShareGoodsHistoryMapper userShareGoodsHistoryMapper;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private RedisManager redisManager;
    @Resource
    private RedisManager redisManager;
    @Resource
    private ConfigService configService;
    @Resource
    private ConfigService configService;
    @Resource
    private TaoBaoUnionConfigService taoBaoUnionConfigService;
    @Resource
    private TaoBaoUnionConfigService taoBaoUnionConfigService;
    @Resource
    private UserAccountService userAccountService;
    @Resource
    private UserAccountService userAccountService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private UserTLJBuyHistoryService userTLJBuyHistoryService;
    @Resource
    private UserTLJBuyHistoryService userTLJBuyHistoryService;
    @Resource
    private TLJBuyGoodsService tljBuyGoodsService;
    @Resource
    private TLJBuyGoodsService tljBuyGoodsService;
    @Resource
    private BusinessEmergent110Service businessEmergent110Service;
    @Resource
    private BusinessEmergent110Service businessEmergent110Service;
    @Resource
    private UserTaoLiJinNewbiesService userTaoLiJinNewbiesService;
    @Resource
    private UserTaoLiJinNewbiesService userTaoLiJinNewbiesService;
    @Resource
    private ConvertLinkManager convertLinkManager;
    @Resource
    private ConvertLinkManager convertLinkManager;
    @Resource
    private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
    @Resource
    private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
    @Resource
    private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
    @Resource
    private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
    @Override
    public void addShareGoodsHistory(UserShareGoodsHistory history) {
        UserShareGoodsHistory userShareGoodsHistory = userShareGoodsHistoryMapper
                .selectByUidAndAuctionId(history.getUser().getId(), history.getGoodsId());
        if (userShareGoodsHistory != null && !StringUtil.isNullOrEmpty(history.getTkCode())) {
            UserShareGoodsHistory update = new UserShareGoodsHistory();
            update.setId(userShareGoodsHistory.getId());
            userShareGoodsHistory.setTkCode(history.getTkCode());
            userShareGoodsHistory.setCreateTime(new Date());
            userShareGoodsHistoryMapper.updateByPrimaryKeySelective(userShareGoodsHistory);
        } else
            userShareGoodsHistoryMapper.insertSelective(history);
    }
    @Override
    public void addShareGoodsHistory(UserShareGoodsHistory history) {
        UserShareGoodsHistory userShareGoodsHistory = userShareGoodsHistoryMapper
                .selectByUidAndAuctionId(history.getUser().getId(), history.getGoodsId());
        if (userShareGoodsHistory != null && !StringUtil.isNullOrEmpty(history.getTkCode())) {
            UserShareGoodsHistory update = new UserShareGoodsHistory();
            update.setId(userShareGoodsHistory.getId());
            userShareGoodsHistory.setTkCode(history.getTkCode());
            userShareGoodsHistory.setCreateTime(new Date());
            userShareGoodsHistoryMapper.updateByPrimaryKeySelective(userShareGoodsHistory);
        } else
            userShareGoodsHistoryMapper.insertSelective(history);
    }
    @Override
    public UserShareGoodsHistory addShareGoodsHistory(Long uid, Long auctionId) throws ShareGoodsException {
        TBPid tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_SHARE_GOODS);
        if (tbPid == null) {
            throw new ShareGoodsException(1, "获取PID失败");
        }
        String appId = tbPid.getPid().split("_")[2];
        String adzoneId = tbPid.getPid().split("_")[3];
        TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
    @Override
    public UserShareGoodsHistory addShareGoodsHistory(Long uid, Long auctionId) throws ShareGoodsException {
        TBPid tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_SHARE_GOODS);
        if (tbPid == null) {
            throw new ShareGoodsException(1, "获取PID失败");
        }
        String appId = tbPid.getPid().split("_")[2];
        String adzoneId = tbPid.getPid().split("_")[3];
        TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
        TaoKeAppInfo info = new TaoKeAppInfo();
        info.setAdzoneId(adzoneId);
        info.setAppKey(taoBaoUnionConfig.getAppKey());
        info.setAppSecret(taoBaoUnionConfig.getAppSecret());
        info.setPid(tbPid.getPid());
        TaoBaoGoodsBrief goods = null;
        long startTime = System.currentTimeMillis();
        try {
            goods = TaoKeApiUtil.searchGoodsDetail(auctionId, info);
        } catch (TaobaoGoodsDownException e) {
            throw new ShareGoodsException(3, "商品已下架");
        } finally {
            LogHelper.test(auctionId + "-获取商品详情耗时为:" + (System.currentTimeMillis() - startTime));
        }
        if (goods == null) {
            throw new ShareGoodsException(3, "商品已下架");
        }
        TaoKeAppInfo info = new TaoKeAppInfo();
        info.setAdzoneId(adzoneId);
        info.setAppKey(taoBaoUnionConfig.getAppKey());
        info.setAppSecret(taoBaoUnionConfig.getAppSecret());
        info.setPid(tbPid.getPid());
        TaoBaoGoodsBrief goods = null;
        long startTime = System.currentTimeMillis();
        try {
            goods = TaoKeApiUtil.searchGoodsDetail(auctionId, info);
        } catch (TaobaoGoodsDownException e) {
            throw new ShareGoodsException(3, "商品已下架");
        } finally {
            LogHelper.test(auctionId + "-获取商品详情耗时为:" + (System.currentTimeMillis() - startTime));
        }
        if (goods == null) {
            throw new ShareGoodsException(3, "商品已下架");
        }
        // 没有获取到转过链的商品详情
        if (StringUtil.isNullOrEmpty(goods.getCouponLink()) && !goods.getAuctionUrl().contains("s.click.taobao.com")) {
            TaoBaoGoodsBrief taoBaoLink = TaoKeApiUtil.specialConvertCoupon(auctionId, info); // TaoBaoUtil.getTbLinkForShare(auctionId,
                                                                                                // tbPid.getPid(),
                                                                                                // taoBaoUnionConfig);
            if (taoBaoLink == null) {
                throw new ShareGoodsException(201, "转链失败");
            }
            goods.setCouponLink(taoBaoLink.getCouponLink());
            goods.setAuctionUrl(taoBaoLink.getAuctionUrl());
        }
        return addShareGoodsHistory(uid, goods);
    }
        // 没有获取到转过链的商品详情
        if (StringUtil.isNullOrEmpty(goods.getCouponLink()) && !goods.getAuctionUrl().contains("s.click.taobao.com")) {
            TaoBaoGoodsBrief taoBaoLink = TaoKeApiUtil.specialConvertCoupon(auctionId, info); // TaoBaoUtil.getTbLinkForShare(auctionId,
            // tbPid.getPid(),
            // taoBaoUnionConfig);
            if (taoBaoLink == null) {
                throw new ShareGoodsException(201, "转链失败");
            }
            goods.setCouponLink(taoBaoLink.getCouponLink());
            goods.setAuctionUrl(taoBaoLink.getAuctionUrl());
        }
        return addShareGoodsHistory(uid, goods);
    }
    @Override
    public UserShareGoodsHistory addShareGoodsHistory(Long uid, TaoBaoGoodsBrief goods) throws ShareGoodsException {
        if (StringUtil.isNullOrEmpty(goods.getCouponLink()) && StringUtil.isNullOrEmpty(goods.getAuctionUrl())) {
            throw new ShareGoodsException(10, "转链失败");
        }
    @Override
    public UserShareGoodsHistory addShareGoodsHistory(Long uid, TaoBaoGoodsBrief goods) throws ShareGoodsException {
        if (StringUtil.isNullOrEmpty(goods.getCouponLink()) && StringUtil.isNullOrEmpty(goods.getAuctionUrl())) {
            throw new ShareGoodsException(10, "转链失败");
        }
        BigDecimal rate = hongBaoManageService.getShareRate();
        SystemEnum system = userInfoService.getUserSystem(uid);
        BigDecimal rate = hongBaoManageService.getShareRate(system);
        // 创建淘口令
        TaoBaoLink tbLink = new TaoBaoLink(); // TaoBaoUtil.getTbLinkForShare(goods.getAuctionId(),
                                                // tbPid.getPid(),
                                                // config.get(0));
        tbLink.setAuctionId(goods.getAuctionId());
        tbLink.setClickUrl(goods.getAuctionUrl());
        tbLink.setCouponLink(goods.getCouponLink());
        // 创建淘口令
        TaoBaoLink tbLink = new TaoBaoLink(); // TaoBaoUtil.getTbLinkForShare(goods.getAuctionId(),
        // tbPid.getPid(),
        // config.get(0));
        tbLink.setAuctionId(goods.getAuctionId());
        tbLink.setClickUrl(goods.getAuctionUrl());
        tbLink.setCouponLink(goods.getCouponLink());
        if (!StringUtil.isNullOrEmpty(tbLink.getCouponLink())) {// 通过立即推广方式获取淘口令成功
            String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), tbLink.getCouponLink());
            if (!StringUtil.isNullOrEmpty(quanToken)) {
                tbLink.setTaoToken(quanToken);
            }
        } else if (!StringUtil.isNullOrEmpty(tbLink.getClickUrl())) {
            String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), tbLink.getClickUrl());
            if (!StringUtil.isNullOrEmpty(quanToken)) {
                tbLink.setTaoToken(quanToken);
            }
        }
        if (!StringUtil.isNullOrEmpty(tbLink.getCouponLink())) {// 通过立即推广方式获取淘口令成功
            String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), tbLink.getCouponLink());
            if (!StringUtil.isNullOrEmpty(quanToken)) {
                tbLink.setTaoToken(quanToken);
            }
        } else if (!StringUtil.isNullOrEmpty(tbLink.getClickUrl())) {
            String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), tbLink.getClickUrl());
            if (!StringUtil.isNullOrEmpty(quanToken)) {
                tbLink.setTaoToken(quanToken);
            }
        }
        UserShareGoodsHistory history = new UserShareGoodsHistory();
        history.setTkCode(TaoBaoUtil.filterTaoToken(tbLink.getTaoToken()));
        history.setLink(tbLink.getClickUrl());
        history.setQuanLink(tbLink.getCouponLink());
        history.setTkCode(TaoBaoUtil.filterTaoToken(tbLink.getTaoToken()));
        UserShareGoodsHistory history = new UserShareGoodsHistory();
        history.setTkCode(TaoBaoUtil.filterTaoToken(tbLink.getTaoToken()));
        history.setLink(tbLink.getClickUrl());
        history.setQuanLink(tbLink.getCouponLink());
        history.setTkCode(TaoBaoUtil.filterTaoToken(tbLink.getTaoToken()));
        history.setCreateTime(new Date());
        history.setGoodsId(goods.getAuctionId());
        history.setGoodsType(UserShareGoodsHistory.TYPE_TAOBAO);
        history.setHongbao(TaoBaoUtil.getShareGoodsHongBaoInfo(goods, rate));
        List<String> imgList = goods.getImgList();
        if (imgList == null) {
            imgList = new ArrayList<>();
        }
        history.setPictures(JsonUtil.getGson().toJson(imgList));
        history.setUser(new UserInfo(uid));
        history.setPostPicture(goods.getPictUrl());
        // 生成二维码信息
        // 包含用户ID与商品ID
        // 新版商品分享
        history.setCreateTime(new Date());
        history.setGoodsId(goods.getAuctionId());
        history.setGoodsType(UserShareGoodsHistory.TYPE_TAOBAO);
        history.setHongbao(TaoBaoUtil.getShareGoodsHongBaoInfo(goods, rate));
        List<String> imgList = goods.getImgList();
        if (imgList == null) {
            imgList = new ArrayList<>();
        }
        history.setPictures(JsonUtil.getGson().toJson(imgList));
        history.setUser(new UserInfo(uid));
        history.setPostPicture(goods.getPictUrl());
        // 生成二维码信息
        // 包含用户ID与商品ID
        // 新版商品分享
        SystemEnum system= userInfoService.getUserSystem(uid);
        String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(system),
                Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
                goods.getAuctionId() + "");
        String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(system),
                Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
                goods.getAuctionId() + "");
        String shortLink = HttpUtil.getShortLink(url);
        if (!StringUtil.isNullOrEmpty(shortLink)) {
            url = shortLink;
        }
        String destPath = FileUtil.getCacheDir() + "/ercode_" + uid + "_" + goods.getAuctionId() + ".jpg";
        String shareImgPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + goods.getAuctionId() + ".png";
        InputStream erCodeInputStream = null;
        String shortLink = HttpUtil.getShortLink(url);
        if (!StringUtil.isNullOrEmpty(shortLink)) {
            url = shortLink;
        }
        String destPath = FileUtil.getCacheDir() + "/ercode_" + uid + "_" + goods.getAuctionId() + ".jpg";
        String shareImgPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + goods.getAuctionId() + ".png";
        InputStream erCodeInputStream = null;
        try {
            try {
                erCodeInputStream = QRCodeUtil.getInstance(500).encode(url);
            } catch (Exception e) {
                e.printStackTrace();
            }
        try {
            try {
                erCodeInputStream = QRCodeUtil.getInstance(500).encode(url);
            } catch (Exception e) {
                e.printStackTrace();
            }
            // if (!new File(destPath).exists()) {
            // throw new ShareGoodsException(4, "生成二维码失败");
            // }
            // 获取到用户的头像
            UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
            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 ShareGoodsException(11, "获取头像出错");
                    else {
                        // 再次获取头像
                        try {
                            portrait = HttpUtil.downLoadImg(portraitUrl);
                        } catch (HttpException e1) {
                            throw new ShareGoodsException(11, "获取头像出错");
                        }
                    }
                }
            }
            // if (!new File(destPath).exists()) {
            // throw new ShareGoodsException(4, "生成二维码失败");
            // }
            // 获取到用户的头像
            UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
            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 ShareGoodsException(11, "获取头像出错");
                    else {
                        // 再次获取头像
                        try {
                            portrait = HttpUtil.downLoadImg(portraitUrl);
                        } catch (HttpException e1) {
                            throw new ShareGoodsException(11, "获取头像出错");
                        }
                    }
                }
            }
            InputStream shareImgInputStream = null;
            InputStream shareImgInputStream = null;
            try {
                // 海草街的分享二维码不一样
                if (Constant.systemCommonConfig.getProjectChineseName().contains("海草街")) {
                    try {
                        shareImgInputStream = ImageUtil.drawGoodsShareImgHCJ(new FileInputStream(new File(destPath)),
                                portrait, goods);
                    } catch (Exception e) {
                        try {
                            LogHelper.errorDetailInfo(e);
                        } catch (Exception e1) {
                            e1.printStackTrace();
                        }
                        throw new ShareGoodsException(5, "分享图绘制失败");
                    }
                } else {
                    shareImgInputStream = ImageUtil.drawGoodsShareImg(erCodeInputStream, portrait, goods);
                }
            } catch (Exception e) {
                try {
                    LogHelper.errorDetailInfo(e, "", "分享图无法找到");
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
            try {
                // 海草街的分享二维码不一样
                if (Constant.systemCommonConfig.getProjectChineseName().contains("海草街")) {
                    try {
                        shareImgInputStream = ImageUtil.drawGoodsShareImgHCJ(new FileInputStream(new File(destPath)),
                                portrait, goods);
                    } catch (Exception e) {
                        try {
                            LogHelper.errorDetailInfo(e);
                        } catch (Exception e1) {
                            e1.printStackTrace();
                        }
                        throw new ShareGoodsException(5, "分享图绘制失败");
                    }
                } else {
                    shareImgInputStream = ImageUtil.drawGoodsShareImg(erCodeInputStream, portrait, goods);
                }
            } catch (Exception e) {
                try {
                    LogHelper.errorDetailInfo(e, "", "分享图无法找到");
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
            try {
                if (shareImgInputStream != null && shareImgInputStream.available() <= 0) {
                    throw new ShareGoodsException(5, "生成分享图失败");
                }
            } catch (IOException e) {
                throw new ShareGoodsException(5, "读取分享图失败");
            }
            try {
                if (shareImgInputStream != null && shareImgInputStream.available() <= 0) {
                    throw new ShareGoodsException(5, "生成分享图失败");
                }
            } catch (IOException e) {
                throw new ShareGoodsException(5, "读取分享图失败");
            }
            FileUploadResult shareImgResult = COSManager.getInstance().uploadInputStream(shareImgInputStream,
                    FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + goods.getAuctionId() + "_"
                            + System.currentTimeMillis() + ".png");
            FileUploadResult shareImgResult = COSManager.getInstance().uploadInputStream(shareImgInputStream,
                    FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + goods.getAuctionId() + "_"
                            + System.currentTimeMillis() + ".png");
            if (shareImgResult == null || StringUtil.isNullOrEmpty(shareImgResult.getUrl())) {
                throw new ShareGoodsException(6, "分享图片保存失败");
            }
            if (shareImgResult == null || StringUtil.isNullOrEmpty(shareImgResult.getUrl())) {
                throw new ShareGoodsException(6, "分享图片保存失败");
            }
            history.setShareImg(shareImgResult.getUrl());
            history.setShareImgMD5(shareImgResult.getMd5());
            history.setShareImg(shareImgResult.getUrl());
            history.setShareImgMD5(shareImgResult.getMd5());
            // 查询之前是否存在,存在就替换掉
            // 查询之前是否存在,存在就替换掉
            UserShareGoodsHistory old = userShareGoodsHistoryMapper.selectByUidAndAuctionId(uid, history.getGoodsId());
            if (old != null) {
                history.setId(old.getId());
                userShareGoodsHistoryMapper.updateByPrimaryKeySelective(history);
                // 删除原来的图片
                COSManager.getInstance().deleteFile(old.getShareImg());
            } else {
                userShareGoodsHistoryMapper.insertSelective(history);
            }
            history.setLink(url);
            return history;
        } finally {
            if (new File(destPath).exists()) {
                new File(destPath).delete();
            }
            if (new File(shareImgPath).exists()) {
                new File(shareImgPath).delete();
            }
        }
    }
            UserShareGoodsHistory old = userShareGoodsHistoryMapper.selectByUidAndAuctionId(uid, history.getGoodsId());
            if (old != null) {
                history.setId(old.getId());
                userShareGoodsHistoryMapper.updateByPrimaryKeySelective(history);
                // 删除原来的图片
                COSManager.getInstance().deleteFile(old.getShareImg());
            } else {
                userShareGoodsHistoryMapper.insertSelective(history);
            }
            history.setLink(url);
            return history;
        } finally {
            if (new File(destPath).exists()) {
                new File(destPath).delete();
            }
            if (new File(shareImgPath).exists()) {
                new File(shareImgPath).delete();
            }
        }
    }
    @Override
    public UserShareGoodsHistory getShareGoodsHistoryDetail(Long uid, Long auctionId) throws ShareGoodsException {
        UserShareGoodsHistory userShareGoodsHistory = userShareGoodsHistoryMapper.selectByUidAndAuctionId(uid,
                auctionId);
        if (userShareGoodsHistory == null)
            throw new ShareGoodsException(10, "分享不存在");
    @Override
    public UserShareGoodsHistory getShareGoodsHistoryDetail(Long uid, Long auctionId) throws ShareGoodsException {
        UserShareGoodsHistory userShareGoodsHistory = userShareGoodsHistoryMapper.selectByUidAndAuctionId(uid,
                auctionId);
        if (userShareGoodsHistory == null)
            throw new ShareGoodsException(10, "分享不存在");
        // 淘口令不存在
        if (StringUtil.isNullOrEmpty(userShareGoodsHistory.getTkCode())) {
            TBPid tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_SHARE_GOODS);
            if (tbPid == null)
                throw new ShareGoodsException(1, "获取PID失败");
        // 淘口令不存在
        if (StringUtil.isNullOrEmpty(userShareGoodsHistory.getTkCode())) {
            TBPid tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_SHARE_GOODS);
            if (tbPid == null)
                throw new ShareGoodsException(1, "获取PID失败");
            List<TaoBaoUnionConfig> config = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_SHARE_GOODS);
            // 创建淘口令
            TaoBaoLink tbLink = TaoBaoUtil.getTbLink(auctionId, tbPid.getPid(), config.get(0));
            if (tbLink == null) {
                TaoBaoGoodsBrief goods = null;
                try {
                    goods = TaoKeApiUtil.searchGoodsDetail(auctionId);
                } catch (TaobaoGoodsDownException e) {
                    throw new ShareGoodsException(4, "商品已下架");
                }
                tbLink = TaoBaoUtil.getTbLinkWithCoupon(goods.getPictUrl(), goods.getTitle(),
                        goods.getCouponActivityId(), auctionId, tbPid.getPid());
                if (tbLink == null || StringUtil.isNullOrEmpty(tbLink.getTaoToken()))
                    throw new ShareGoodsException(2, "获取淘口令失败,请稍后重试");
            }
            // 更新淘口令
            List<TaoBaoUnionConfig> config = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_SHARE_GOODS);
            // 创建淘口令
            TaoBaoLink tbLink = TaoBaoUtil.getTbLink(auctionId, tbPid.getPid(), config.get(0));
            if (tbLink == null) {
                TaoBaoGoodsBrief goods = null;
                try {
                    goods = TaoKeApiUtil.searchGoodsDetail(auctionId);
                } catch (TaobaoGoodsDownException e) {
                    throw new ShareGoodsException(4, "商品已下架");
                }
                tbLink = TaoBaoUtil.getTbLinkWithCoupon(goods.getPictUrl(), goods.getTitle(),
                        goods.getCouponActivityId(), auctionId, tbPid.getPid());
                if (tbLink == null || StringUtil.isNullOrEmpty(tbLink.getTaoToken()))
                    throw new ShareGoodsException(2, "获取淘口令失败,请稍后重试");
            }
            // 更新淘口令
            UserShareGoodsHistory history = new UserShareGoodsHistory();
            history.setId(userShareGoodsHistory.getId());
            history.setTkCode(TaoBaoUtil.filterTaoToken(tbLink.getTaoToken()));
            history.setLink(tbLink.getClickUrl());
            history.setQuanLink(tbLink.getCouponLink());
            history.setTkCode(TaoBaoUtil.filterTaoToken(tbLink.getTaoToken()));
            userShareGoodsHistoryMapper.updateByPrimaryKeySelective(history);
            UserShareGoodsHistory history = new UserShareGoodsHistory();
            history.setId(userShareGoodsHistory.getId());
            history.setTkCode(TaoBaoUtil.filterTaoToken(tbLink.getTaoToken()));
            history.setLink(tbLink.getClickUrl());
            history.setQuanLink(tbLink.getCouponLink());
            history.setTkCode(TaoBaoUtil.filterTaoToken(tbLink.getTaoToken()));
            userShareGoodsHistoryMapper.updateByPrimaryKeySelective(history);
            userShareGoodsHistory.setTkCode(TaoBaoUtil.filterTaoToken(tbLink.getTaoToken()));
            userShareGoodsHistory.setLink(tbLink.getClickUrl());
            userShareGoodsHistory.setQuanLink(tbLink.getCouponLink());
            userShareGoodsHistory.setTkCode(TaoBaoUtil.filterTaoToken(tbLink.getTaoToken()));
        }
            userShareGoodsHistory.setTkCode(TaoBaoUtil.filterTaoToken(tbLink.getTaoToken()));
            userShareGoodsHistory.setLink(tbLink.getClickUrl());
            userShareGoodsHistory.setQuanLink(tbLink.getCouponLink());
            userShareGoodsHistory.setTkCode(TaoBaoUtil.filterTaoToken(tbLink.getTaoToken()));
        }
        return userShareGoodsHistory;
    }
        return userShareGoodsHistory;
    }
    @Override
    public String createTaoBaoToken(Long uid, TaoBaoGoodsBrief goods) {
        String quanToken = "";
        if (!StringUtil.isNullOrEmpty(goods.getCouponLink())) {// 通过立即推广方式获取淘口令成功
            quanToken = convertLinkManager.createTaoBaoToken(uid, goods.getPictUrl(), goods.getTitle(),
                    goods.getCouponLink());
        } else if (!StringUtil.isNullOrEmpty(goods.getAuctionUrl())) {
            quanToken = convertLinkManager.createTaoBaoToken(uid, goods.getPictUrl(), goods.getTitle(),
                    goods.getAuctionUrl());
        }
        return quanToken;
    }
    @Override
    public String createTaoBaoToken(Long uid, TaoBaoGoodsBrief goods) {
        String quanToken = "";
        if (!StringUtil.isNullOrEmpty(goods.getCouponLink())) {// 通过立即推广方式获取淘口令成功
            quanToken = convertLinkManager.createTaoBaoToken(uid, goods.getPictUrl(), goods.getTitle(),
                    goods.getCouponLink());
        } else if (!StringUtil.isNullOrEmpty(goods.getAuctionUrl())) {
            quanToken = convertLinkManager.createTaoBaoToken(uid, goods.getPictUrl(), goods.getTitle(),
                    goods.getAuctionUrl());
        }
        return quanToken;
    }
    @Override
    public TaoBaoLink getTaoBaoLink(Long uid, Long auctionId, String pid) throws ShareGoodsException {
    @Override
    public TaoBaoLink getTaoBaoLink(Long uid, Long auctionId, String pid) throws ShareGoodsException {
        if (uid == null || uid <= 0) {
            throw new ShareGoodsException(1, "用户ID不能为空");
        }
        if (uid == null || uid <= 0) {
            throw new ShareGoodsException(1, "用户ID不能为空");
        }
        if (auctionId == null || auctionId <= 0) {
            throw new ShareGoodsException(2, "商品ID不能为空");
        }
        if (auctionId == null || auctionId <= 0) {
            throw new ShareGoodsException(2, "商品ID不能为空");
        }
        if (StringUtil.isNullOrEmpty(pid)) {
            throw new ShareGoodsException(3, "无推广位");
        }
        if (StringUtil.isNullOrEmpty(pid)) {
            throw new ShareGoodsException(3, "无推广位");
        }
        String appId = pid.split("_")[2];
        String adzoneId = pid.split("_")[3];
        TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
        String appId = pid.split("_")[2];
        String adzoneId = pid.split("_")[3];
        TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
        TaoKeAppInfo info = new TaoKeAppInfo();
        info.setAdzoneId(adzoneId);
        info.setAppKey(taoBaoUnionConfig.getAppKey());
        info.setAppSecret(taoBaoUnionConfig.getAppSecret());
        info.setPid(pid);
        TaoBaoGoodsBrief goods = null;
        try {
            goods = TaoKeApiUtil.searchGoodsDetailForConvert(auctionId, info);
        } catch (TaobaoGoodsDownException e) {
            throw new ShareGoodsException(4, "商品已下架");
        } finally {
        TaoKeAppInfo info = new TaoKeAppInfo();
        info.setAdzoneId(adzoneId);
        info.setAppKey(taoBaoUnionConfig.getAppKey());
        info.setAppSecret(taoBaoUnionConfig.getAppSecret());
        info.setPid(pid);
        TaoBaoGoodsBrief goods = null;
        try {
            goods = TaoKeApiUtil.searchGoodsDetailForConvert(auctionId, info);
        } catch (TaobaoGoodsDownException e) {
            throw new ShareGoodsException(4, "商品已下架");
        } finally {
        }
        if (goods == null) {
            throw new ShareGoodsException(5, "获取商品详情失败");
        }
        }
        if (goods == null) {
            throw new ShareGoodsException(5, "获取商品详情失败");
        }
        if (StringUtil.isNullOrEmpty(goods.getCouponLink()) && !goods.getAuctionUrl().contains("s.click.taobao.com")) {
            TaoBaoGoodsBrief taoBaoLink = TaoKeApiUtil.specialConvertCoupon(auctionId, info);
            if (taoBaoLink == null) {
                throw new ShareGoodsException(201, "商品转链失败");
            }
            goods.setCouponLink(taoBaoLink.getCouponLink());
            goods.setAuctionUrl(taoBaoLink.getAuctionUrl());
        }
        if (StringUtil.isNullOrEmpty(goods.getCouponLink()) && !goods.getAuctionUrl().contains("s.click.taobao.com")) {
            TaoBaoGoodsBrief taoBaoLink = TaoKeApiUtil.specialConvertCoupon(auctionId, info);
            if (taoBaoLink == null) {
                throw new ShareGoodsException(201, "商品转链失败");
            }
            goods.setCouponLink(taoBaoLink.getCouponLink());
            goods.setAuctionUrl(taoBaoLink.getAuctionUrl());
        }
        // 创建淘口令
        TaoBaoLink tbLink = new TaoBaoLink();
        tbLink.setAuctionId(goods.getAuctionId());
        tbLink.setClickUrl(goods.getAuctionUrl());
        tbLink.setCouponLink(goods.getCouponLink());
        return tbLink;
    }
        // 创建淘口令
        TaoBaoLink tbLink = new TaoBaoLink();
        tbLink.setAuctionId(goods.getAuctionId());
        tbLink.setClickUrl(goods.getAuctionUrl());
        tbLink.setCouponLink(goods.getCouponLink());
        return tbLink;
    }
    @Override
    public UserShareGoodsHistory getShareGoodsHistory(Long uid, Long auctionId) {
        return userShareGoodsHistoryMapper.selectByUidAndAuctionId(uid, auctionId);
    }
    @Override
    public UserShareGoodsHistory getShareGoodsHistory(Long uid, Long auctionId) {
        return userShareGoodsHistoryMapper.selectByUidAndAuctionId(uid, auctionId);
    }
    @Override
    public TaoBaoLink getTaoLiJinLinkForBuyWithOutFanLi(Long uid, Long auctionId, TaoKeAppInfo app)
            throws ShareGoodsException, TaoLiJinCreateException {
        if (uid == null || uid <= 0) {
            throw new ShareGoodsException(1, "用户ID不能为空");
        }
    @Override
    public TaoBaoLink getTaoLiJinLinkForBuyWithOutFanLi(Long uid, Long auctionId, TaoKeAppInfo app)
            throws ShareGoodsException, TaoLiJinCreateException {
        if (uid == null || uid <= 0) {
            throw new ShareGoodsException(1, "用户ID不能为空");
        }
        if (auctionId == null || auctionId <= 0) {
            throw new ShareGoodsException(2, "商品ID不能为空");
        }
        if (auctionId == null || auctionId <= 0) {
            throw new ShareGoodsException(2, "商品ID不能为空");
        }
        boolean canBuy = userTLJBuyHistoryService.canBuy(uid, auctionId);
        if (!canBuy) {
            throw new ShareGoodsException(3, "立减红包已抢光,请稍后再试");
        }
        boolean canBuy = userTLJBuyHistoryService.canBuy(uid, auctionId);
        if (!canBuy) {
            throw new ShareGoodsException(3, "立减红包已抢光,请稍后再试");
        }
        SystemEnum system = userInfoService.getUserSystem(uid);
        SystemEnum system= userInfoService.getUserSystem(uid);
        long currentTime = System.currentTimeMillis();
        Date sendEndTime = new Date(TimeUtil.convertToTimeTemp(
                TimeUtil.getGernalTime(currentTime + 1000 * 60 * 60 * 24L, "yyyy-MM-dd"), "yyyy-MM-dd"));
        TaoBaoGoodsBrief goods = null;
        try {
            goods = TaoKeApiUtil.searchGoodsDetail(auctionId);
        } catch (TaobaoGoodsDownException e) {
            throw new ShareGoodsException(4, "商品已下架");
        }
        long currentTime = System.currentTimeMillis();
        Date sendEndTime = new Date(TimeUtil.convertToTimeTemp(
                TimeUtil.getGernalTime(currentTime + 1000 * 60 * 60 * 24L, "yyyy-MM-dd"), "yyyy-MM-dd"));
        TaoBaoGoodsBrief goods = null;
        try {
            goods = TaoKeApiUtil.searchGoodsDetail(auctionId);
        } catch (TaobaoGoodsDownException e) {
            throw new ShareGoodsException(4, "商品已下架");
        }
        BigDecimal perface = TaoBaoUtil.getGoodsHongBaoMoney(goods, new BigDecimal(70), false);
        TaoLiJinDTO taoLiJinDTO = null;
        try {
            taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, "自购立减", perface, 1,
                    new Date(currentTime - 1000 * 60 * 10L), sendEndTime, new Date(currentTime - 1000 * 60 * 10L),
                    sendEndTime, app);
        } catch (TaoLiJinCreateException e1) {
            if (e1.getCode() == TaoLiJinCreateException.CODE_TLJ_NO_MONEY) {// 资金不足
                TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppKeyCache(app.getAppKey());
                businessEmergent110Service.tljNoMoney(config.getAccount(), system);
            } else if (e1.getCode() == TaoLiJinCreateException.CODE_TLJ_FORBIDDEN) {// 商品不允许创建淘礼金
                tljBuyGoodsService.removeGoods(auctionId);
            }
            LogHelper.errorDetailInfo(e1, e1.getMessage(), null);
        } catch (TaoKeApiException e) {
            LogHelper.errorDetailInfo(e, e.getMessage(), null);
            throw new ShareGoodsException(5, "生成推广链接失败");
        }
        BigDecimal perface = TaoBaoUtil.getGoodsHongBaoMoney(goods, new BigDecimal(70), false);
        TaoLiJinDTO taoLiJinDTO = null;
        try {
            taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, "自购立减", perface, 1,
                    new Date(currentTime - 1000 * 60 * 10L), sendEndTime, new Date(currentTime - 1000 * 60 * 10L),
                    sendEndTime, app);
        } catch (TaoLiJinCreateException e1) {
            if (e1.getCode() == TaoLiJinCreateException.CODE_TLJ_NO_MONEY) {// 资金不足
                TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppKeyCache(app.getAppKey());
                businessEmergent110Service.tljNoMoney(config.getAccount(),system);
            } else if (e1.getCode() == TaoLiJinCreateException.CODE_TLJ_FORBIDDEN) {// 商品不允许创建淘礼金
                tljBuyGoodsService.removeGoods(auctionId);
            }
            LogHelper.errorDetailInfo(e1, e1.getMessage(), null);
        } catch (TaoKeApiException e) {
            LogHelper.errorDetailInfo(e, e.getMessage(), null);
            throw new ShareGoodsException(5, "生成推广链接失败");
        }
        if (taoLiJinDTO == null)
            throw new ShareGoodsException(5, "生成推广链接失败");
        if (taoLiJinDTO == null)
            throw new ShareGoodsException(5, "生成推广链接失败");
        // 减去剩余个数(随机减去8到10个)
        tljBuyGoodsService.subHongBaoLeftCount(auctionId, TimeUtil.getGernalTime(currentTime, "yyyy-MM-dd"),
                8 + (int) (3 * Math.random()));
        // 减去剩余个数(随机减去8到10个)
        tljBuyGoodsService.subHongBaoLeftCount(auctionId, TimeUtil.getGernalTime(currentTime, "yyyy-MM-dd"),
                8 + (int) (3 * Math.random()));
        // 插入记录
        try {
            userTLJBuyHistoryService.addHistory(new UserTLJBuyHistory(null, uid, auctionId,
                    TimeUtil.getGernalTime(currentTime, "yyyy-MM-dd"), taoLiJinDTO.getRightsId(), new Date()));
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
        // 插入记录
        try {
            userTLJBuyHistoryService.addHistory(new UserTLJBuyHistory(null, uid, auctionId,
                    TimeUtil.getGernalTime(currentTime, "yyyy-MM-dd"), taoLiJinDTO.getRightsId(), new Date()));
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
        TaoBaoLink taoBaoLink = new TaoBaoLink();
        taoBaoLink.setAuctionId(auctionId);
        taoBaoLink.setClickUrl(goods.getAuctionUrl());
        taoBaoLink.setCouponLink(taoLiJinDTO.getSendUrl());
        taoBaoLink.setGoods(goods);
        return taoBaoLink;
    }
        TaoBaoLink taoBaoLink = new TaoBaoLink();
        taoBaoLink.setAuctionId(auctionId);
        taoBaoLink.setClickUrl(goods.getAuctionUrl());
        taoBaoLink.setCouponLink(taoLiJinDTO.getSendUrl());
        taoBaoLink.setGoods(goods);
        return taoBaoLink;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/SuperGoodsClassServiceImpl.java
@@ -48,7 +48,7 @@
    @Override
    public Integer deleteSuperGoodsClass(final long gcid, final String platform, final String packageName) {
        
        BusinessSystem system = businessSystemService.getBusinessSystem(platform, packageName);
        BusinessSystem system = businessSystemService.getBusinessSystem(platform, packageName,null);
        if (system == null) {
            return 0;
        }
@@ -58,7 +58,7 @@
    
    @Override
    public void addSuperGoodsClass(long gcid, String platform, String packageName) {
        BusinessSystem system = businessSystemService.getBusinessSystem(platform,packageName);
        BusinessSystem system = businessSystemService.getBusinessSystem(platform,packageName,null);
        
        GoodsClass goodsClass = new GoodsClass();
        goodsClass.setId(gcid);
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/TaoBaoGoodsBriefServiceImpl.java
@@ -8,6 +8,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoGoodsBriefMapper;
@@ -41,14 +42,14 @@
    private TaoBaoUnionConfigService taoBaoUnionConfigService;
    @Override
    public String getGoodsUserHongBao(TaoBaoGoodsBrief goods) {
        BigDecimal rate = hongBaoManageService.getFanLiRate();
    public String getGoodsUserHongBao(TaoBaoGoodsBrief goods, SystemEnum system) {
        BigDecimal rate = hongBaoManageService.getFanLiRate(system);
        return TaoBaoUtil.getGoodsHongBaoInfo(goods, rate,false);
    }
    @Override
    public BigDecimal getShareGoodsUserHongBao(TaoBaoGoodsBrief goods) {
        BigDecimal rate = hongBaoManageService.getShareRate();
    public BigDecimal getShareGoodsUserHongBao(TaoBaoGoodsBrief goods, SystemEnum system) {
        BigDecimal rate = hongBaoManageService.getShareRate(system);
        return TaoBaoUtil.getShareGoodsHongBaoInfo(goods, rate);
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/lable/QualityGoodsServiceImpl.java
@@ -6,6 +6,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.yeshi.utils.JsonUtil;
@@ -42,22 +43,10 @@
public class QualityGoodsServiceImpl implements QualityGoodsService {
    @Resource
    private RedisManager redisManager;
    @Resource
    private QualityFactoryMapper qualityFactoryMapper;
    @Resource
    private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
    @Resource
    private LabelGoodsMapper labelGoodsMapper;
    @Resource
    private LabelService labelService;
    @Resource
    private TaoBaoGoodsBriefMapper taoBaoGoodsBriefMapper;
    @Resource
    private TaoBaoUnionConfigService taoBaoUnionConfigService;
    @Resource
    private TaoBaoClassRelationMapper taoBaoClassRelationMapper;
    private LabelGoodsMapper labelGoodsMapper;
    @Resource
    private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
@@ -337,8 +326,8 @@
     * 首页最底部@商品信息流
     */
    @Override
    @Cacheable(value = "qualityCache", key = "'getRecommendToIndexV2-'+#start+'-'+#platform+'-'+#version")
    public JSONArray getRecommendToIndexV2(long start, int count, String platform, String version) {
    @Cacheable(value = "qualityCache", key = "'getRecommendToIndexV2-'+#start+'-'+#platform+'-'+#version+'-'+#system")
    public JSONArray getRecommendToIndexV2(long start, int count, String platform, String version, SystemEnum system) {
        // 返利金额2元以上;
        Integer commision = 2;
@@ -349,7 +338,7 @@
        // 优惠率高于10%以上(优惠率=优惠券面额/商品在售价*100%)
        Double couponRatio = 10.0;
        BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
        BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(system);
        Double pop = 50.0;
        if (fanLiRate != null) {
            pop = Double.parseDouble(fanLiRate.toString());
@@ -376,7 +365,7 @@
        } catch (Exception e) {
        }
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version);
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version,system);
        for (TaoBaoGoodsBrief taoBaoGoodsBrief : goodsList) {
            GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO);
fanli/src/main/java/com/yeshi/fanli/service/impl/lable/TaoKeGoodsServiceImpl.java
@@ -9,6 +9,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.yeshi.utils.JsonUtil;
@@ -68,7 +69,7 @@
    @Override
    @Cacheable(value = "taoKeMaterialCache", key = "'getBrandsGoods-'+#materialId +'-'+#pageIndex")
    public JSONObject getBrandsGoods(Integer materialId, int pageIndex, int pageSize) throws Exception {
    public JSONObject getBrandsGoods(Integer materialId, int pageIndex, int pageSize, SystemEnum system) throws Exception {
        TaoBaoSearchResult result = TaoKeApiUtil.getMaterialByMaterialId(materialId, pageIndex, pageSize);
@@ -85,7 +86,7 @@
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        BigDecimal proportion = hongBaoManageService.getFanLiRate();
        BigDecimal proportion = hongBaoManageService.getFanLiRate(system);
        listGoods.parallelStream().forEach(taoBaoGoodsBrief -> {
@@ -191,8 +192,8 @@
    }
    @Override
    @Cacheable(value = "searchWuLiaoCache", key = "'searchWuLiao-'+#sf")
    public JSONObject searchWuLiao(SearchFilter sf) {
    @Cacheable(value = "searchWuLiaoCache", key = "'searchWuLiao-'+#sf+'-'+system")
    public JSONObject searchWuLiao(SearchFilter sf,SystemEnum system) {
        // 淘宝物料接口查询
        TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(sf);
@@ -212,7 +213,7 @@
        int fh = sf.getHongbao();
        boolean ft = sf.isTmall();
        BigDecimal proportion = hongBaoManageService.getFanLiRate();
        BigDecimal proportion = hongBaoManageService.getFanLiRate(system);
        if (fq == 0 && fh == 0 && !ft) {
            if (result != null && result.getTaoBaoGoodsBriefs() != null)
@@ -279,8 +280,8 @@
    
    
    @Override
    @Cacheable(value = "searchWuLiaoCache", key = "'searchWuLiaoV2-'+#sf+'-'+#platform+'-'+#version")
    public JSONObject searchWuLiaoV2(SearchFilter sf,String platform,String version) {
    @Cacheable(value = "searchWuLiaoCache", key = "'searchWuLiaoV2-'+#sf+'-'+#platform+'-'+#version+'-'+#system")
    public JSONObject searchWuLiaoV2(SearchFilter sf,String platform,String version,SystemEnum system) {
        // 淘宝物料接口查询
        TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(sf);
@@ -300,7 +301,7 @@
        int fh = sf.getHongbao();
        boolean ft = sf.isTmall();
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version);
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version,system);
        if (fq == 0 && fh == 0 && !ft) {
            if (result != null && result.getTaoBaoGoodsBriefs() != null)
@@ -347,9 +348,8 @@
    
    @Override
    @Cacheable(value = "searchWuLiaoCache", key = "'searchWuLiaoList-'+#sf")
    public List<TaoBaoGoodsBrief> searchWuLiaoList(SearchFilter sf) {
    @Cacheable(value = "searchWuLiaoCache", key = "'searchWuLiaoList-'+#sf+'-'+system")
    public List<TaoBaoGoodsBrief> searchWuLiaoList(SearchFilter sf,SystemEnum system) {
        // 淘宝物料接口查询
        TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(sf);
        if (result == null)
@@ -360,7 +360,7 @@
    @Override
    public JSONObject listByWuLiao(int page, String key, String cateIds, String filterParams, String order,
            String startprice, String endprice, String searchParam) {
            String startprice, String endprice, String searchParam,SystemEnum system) {
        SearchFilter sf = new SearchFilter();
        sf.setKey(key);
@@ -488,7 +488,7 @@
        int fh = sf.getHongbao();
        boolean ft = sf.isTmall();
        BigDecimal proportion = hongBaoManageService.getFanLiRate();
        BigDecimal proportion = hongBaoManageService.getFanLiRate(system);
        if (fq == 0 && fh == 0 && !ft) {
            if (result != null && result.getTaoBaoGoodsBriefs() != null)
@@ -636,13 +636,13 @@
    @Override
    public JSONObject listQualityGoods(List<QualityFactory> listQuality, List<TaoBaoGoodsBrief> searchWuLiaoList,
            Map<String, String> map) {
            Map<String, String> map,SystemEnum system) {
        JSONArray array = new JSONArray();
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        BigDecimal proportion = hongBaoManageService.getFanLiRate();
        BigDecimal proportion = hongBaoManageService.getFanLiRate(system);
        /* 遍历列表数据 */
        for (QualityFactory selectionGoods : listQuality) {
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -10,6 +10,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -630,7 +631,6 @@
     * @param hasRewardCoupon
     * @param hongBaoState
     * @param list
     * @param signList
     */
    private void couponFactory(CommonOrderVO order, boolean hasRewardCoupon, Integer hongBaoState, Integer hongBaoType,
            List<UserSystemCouponRecord> list, Long uid, boolean vip, AcceptData acceptData, BigDecimal hongBao)
@@ -1292,7 +1292,6 @@
     * 
     * @param commonOrder
     */
    @Transactional(rollbackFor = Exception.class)
    private CommonOrderAddResultDTO addCommonOrder(CommonOrder commonOrder) throws CommonOrderException {
        // 判断商品是否存在
        if (commonOrder == null)
@@ -1468,16 +1467,16 @@
    @Override
    public List<CommonOrderVO> listQuery(long start, int count, Integer keyType, String key, Integer state,
            Integer type, Integer orderState, String startTime, String endTime, Integer source, List<Long> listShopId,
            List<Long> listGoodsId, Date minTime, BigDecimal money, BigDecimal payment) throws CommonOrderException {
            List<Long> listGoodsId, Date minTime, BigDecimal money, BigDecimal payment,SystemEnum system) throws CommonOrderException {
        List<CommonOrderVO> list = null;
        if (StringUtil.isNullOrEmpty(key) || keyType == 1) {// 搜索框无值或者按订单号搜索时都只搜索主订单
            list = commonOrderMapper.listQueryWithNoChild(start, count, keyType, key, state, type, orderState,
                    startTime, endTime, source, payment);
                    startTime, endTime, source, payment,system);
        } else {
            list = commonOrderMapper.listQuery(start, count, keyType, key, state, type, orderState, startTime, endTime,
                    source, listShopId, listGoodsId, minTime, money, payment);
                    source, listShopId, listGoodsId, minTime, money, payment,system);
        }
        if (list == null) {
@@ -1663,14 +1662,14 @@
    @Override
    public long countQuery(Integer keyType, String key, Integer state, Integer type, Integer orderState,
            String startTime, String endTime, Integer source, List<Long> listShopId, List<Long> listGoodsId,
            Date minTime, BigDecimal money, BigDecimal payment) throws CommonOrderException {
                           String startTime, String endTime, Integer source, List<Long> listShopId, List<Long> listGoodsId,
                           Date minTime, BigDecimal money, BigDecimal payment, SystemEnum system) throws CommonOrderException {
        if (StringUtil.isNullOrEmpty(key) || keyType == 1) {// 搜索框无值或者按订单号搜索时都只搜索主订单
            return commonOrderMapper.countQueryWithNoChild(keyType, key, state, type, orderState, startTime, endTime,
                    source, payment);
                    source, payment,system);
        } else {
            return commonOrderMapper.countQuery(keyType, key, state, type, orderState, startTime, endTime, source,
                    listShopId, listGoodsId, minTime, money, payment);
                    listShopId, listGoodsId, minTime, money, payment,system);
        }
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/order/HongBaoV2ServiceImpl.java
@@ -13,6 +13,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -64,1116 +65,1108 @@
@Service
public class HongBaoV2ServiceImpl implements HongBaoV2Service {
    @Resource
    private HongBaoV2Mapper hongBaoV2Mapper;
    @Resource
    private HongBaoV2Mapper hongBaoV2Mapper;
    @Resource
    private TaoBaoOrderMapper taoBaoOrderMapper;
    @Resource
    private TaoBaoOrderMapper taoBaoOrderMapper;
    @Resource
    private CommonOrderMapper commonOrderMapper;
    @Resource
    private CommonOrderGoodsMapper commonOrderGoodsMapper;
    @Resource
    private CommonOrderGoodsMapper commonOrderGoodsMapper;
    @Resource
    private HongBaoOrderMapper hongBaoOrderMapper;
    @Resource
    private HongBaoOrderMapper hongBaoOrderMapper;
    @Resource
    private CommonOrderService commonOrderService;
    @Resource
    private OrderMapper orderMapper;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private CommonOrderService commonOrderService;
    @Resource
    private UserShareGoodsGroupService userShareGoodsGroupService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private TaoBaoWeiQuanOrderMapper taoBaoWeiQuanOrderMapper;
    @Resource
    private ThreeSaleSerivce threeSaleSerivce;
    @Resource
    private UserShareGoodsGroupService userShareGoodsGroupService;
    @Resource
    private UserOrderMsgNotificationService userOrderMsgNotificationService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private ConfigService configService;
    @Resource
    private ThreeSaleSerivce threeSaleSerivce;
    @Resource
    private ShareGoodsActivityOrderService shareGoodsActivityOrderService;
    @Resource
    private UserOrderMsgNotificationService userOrderMsgNotificationService;
    @Resource
    private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
    @Resource
    private ConfigService configService;
    @Lazy
    @Resource
    private UserSystemCouponService userSystemCouponService;
    @Resource
    private ShareGoodsActivityOrderService shareGoodsActivityOrderService;
    @Resource
    private UserSystemCouponRecordService userSystemCouponRecordService;
    @Resource
    private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
    @Override
    public int insert(HongBaoV2 record) {
        return hongBaoV2Mapper.insert(record);
    }
    @Lazy
    @Resource
    private UserSystemCouponService userSystemCouponService;
    @Override
    public int insertSelective(HongBaoV2 record) {
        return hongBaoV2Mapper.insertSelective(record);
    }
    @Resource
    private UserSystemCouponRecordService userSystemCouponRecordService;
    @Override
    public int updateByPrimaryKeySelective(HongBaoV2 record) {
        return hongBaoV2Mapper.updateByPrimaryKeySelective(record);
    }
    @Override
    public int insert(HongBaoV2 record) {
        return hongBaoV2Mapper.insert(record);
    }
    @Override
    public int updateByPrimaryKey(HongBaoV2 record) {
        return hongBaoV2Mapper.updateByPrimaryKey(record);
    }
    @Override
    public int insertSelective(HongBaoV2 record) {
        return hongBaoV2Mapper.insertSelective(record);
    }
    @Override
    public int deleteByPrimaryKey(Long id) {
        return hongBaoV2Mapper.deleteByPrimaryKey(id);
    }
    @Override
    public int updateByPrimaryKeySelective(HongBaoV2 record) {
        return hongBaoV2Mapper.updateByPrimaryKeySelective(record);
    }
    @Override
    public HongBaoV2 selectByPrimaryKey(Long id) {
        return hongBaoV2Mapper.selectByPrimaryKey(id);
    }
    @Override
    public int updateByPrimaryKey(HongBaoV2 record) {
        return hongBaoV2Mapper.updateByPrimaryKey(record);
    }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public HongBaoAddResult addHongBao(List<CommonOrder> commonOrderList, int type)
            throws HongBaoException, UserAccountException {
        Set<Integer> stateSet = new HashSet<>();// 订单状态Set
        if (commonOrderList != null && commonOrderList.size() > 0) {
            int orderType = commonOrderList.get(0).getSourceType();
    @Override
    public int deleteByPrimaryKey(Long id) {
        return hongBaoV2Mapper.deleteByPrimaryKey(id);
    }
            boolean miandan = false;
            Map<Integer, HongBaoOrder> notificationMap = new HashMap<>();
            int goodsCount = 0;
            boolean hasAdd = false;
            boolean hasUpdate = false;
            for (CommonOrder commonOrder : commonOrderList) {
                stateSet.add(commonOrder.getState());
                goodsCount += commonOrder.getCount();
                if (commonOrder == null || commonOrder.getId() == null || commonOrder.getUserInfo() == null)
                    throw new HongBaoException(1, "订单信息不完整");
                HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
                if (hongBaoOrder == null) {
                    miandan = saveHongBao(commonOrder, type, notificationMap);
                    hasAdd = true;
                } else {
                    boolean update = updateHongBao(hongBaoOrder, commonOrder, type, notificationMap);
                    if (update)
                        hasUpdate = true;
                }
            }
    @Override
    public HongBaoV2 selectByPrimaryKey(Long id) {
        return hongBaoV2Mapper.selectByPrimaryKey(id);
    }
            /**
             * 通知用户的返利情况
             */
            int state = getOrderState(stateSet);
            if (hasAdd) {
                Iterator<Integer> its = notificationMap.keySet().iterator();
                while (its.hasNext()) {
                    Integer t = its.next();
                    HongBaoV2 notify = notificationMap.get(t).getHongBaoV2();
                    CommonOrder commonOrder = notificationMap.get(t).getCommonOrder();
                    String orderId = commonOrderList.get(0).getOrderNo();
                    Long uid = notify.getUserInfo().getId();
                    BigDecimal money = notify.getMoney();
                    switch (t) {
                        case HongBaoV2.TYPE_ZIGOU:
                            userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, orderType,
                                    commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
                                    commonOrder.getThirdCreateTime());
    @Transactional(rollbackFor = Exception.class)
    @Override
    public HongBaoAddResult addHongBao(List<CommonOrder> commonOrderList, int type)
            throws HongBaoException, UserAccountException {
        Set<Integer> stateSet = new HashSet<>();// 订单状态Set
        if (commonOrderList != null && commonOrderList.size() > 0) {
            int orderType = commonOrderList.get(0).getSourceType();
                            break;
                        case HongBaoV2.TYPE_SHARE_GOODS:
            boolean miandan = false;
            Map<Integer, HongBaoOrder> notificationMap = new HashMap<>();
            int goodsCount = 0;
            boolean hasAdd = false;
            boolean hasUpdate = false;
            for (CommonOrder commonOrder : commonOrderList) {
                stateSet.add(commonOrder.getState());
                goodsCount += commonOrder.getCount();
                if (commonOrder == null || commonOrder.getId() == null || commonOrder.getUserInfo() == null)
                    throw new HongBaoException(1, "订单信息不完整");
                HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
                if (hongBaoOrder == null) {
                    miandan = saveHongBao(commonOrder, type, notificationMap);
                    hasAdd = true;
                } else {
                    boolean update = updateHongBao(hongBaoOrder, commonOrder, type, notificationMap);
                    if (update)
                        hasUpdate = true;
                }
            }
                            userOrderMsgNotificationService.orderShareStatistic(uid, orderId, orderType,
                                    commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
                                    commonOrder.getThirdCreateTime());
            /**
             * 通知用户的返利情况
             */
            int state = getOrderState(stateSet);
            if (hasAdd) {
                Iterator<Integer> its = notificationMap.keySet().iterator();
                while (its.hasNext()) {
                    Integer t = its.next();
                    HongBaoV2 notify = notificationMap.get(t).getHongBaoV2();
                    CommonOrder commonOrder = notificationMap.get(t).getCommonOrder();
                    String orderId = commonOrderList.get(0).getOrderNo();
                    Long uid = notify.getUserInfo().getId();
                    BigDecimal money = notify.getMoney();
                    switch (t) {
                    case HongBaoV2.TYPE_ZIGOU:
                        userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, orderType,
                                commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
                                commonOrder.getThirdCreateTime());
                            break;
                        case HongBaoV2.TYPE_YIJI:
                            userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                    commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(),
                                    commonOrder.getThirdCreateTime());
                            break;
                        case HongBaoV2.TYPE_ERJI:
                            userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                    commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(),
                                    commonOrder.getThirdCreateTime());
                            break;
                        break;
                    case HongBaoV2.TYPE_SHARE_GOODS:
                        case HongBaoV2.TYPE_SHARE_YIJI:
                            userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                    commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(),
                                    commonOrder.getThirdCreateTime());
                        userOrderMsgNotificationService.orderShareStatistic(uid, orderId, orderType,
                                commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
                                commonOrder.getThirdCreateTime());
                        case HongBaoV2.TYPE_SHARE_ERJI:
                            userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                    commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(),
                                    commonOrder.getThirdCreateTime());
                            break;
                    }
                }
            }
                        break;
                    case HongBaoV2.TYPE_YIJI:
                        userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(),
                                commonOrder.getThirdCreateTime());
                        break;
                    case HongBaoV2.TYPE_ERJI:
                        userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(),
                                commonOrder.getThirdCreateTime());
                        break;
            int resultCode = 0;
            if (hasAdd && hasUpdate)
                return new HongBaoAddResult(HongBaoAddResult.CODE_ADD_AND_UPDATE, miandan);
            else if (hasAdd)
                return new HongBaoAddResult(HongBaoAddResult.CODE_ADD, miandan);
            else if (hasUpdate)
                return new HongBaoAddResult(HongBaoAddResult.CODE_UPDATE, miandan);
            return new HongBaoAddResult(resultCode, miandan);
        }
        return new HongBaoAddResult(0, false);
    }
                    case HongBaoV2.TYPE_SHARE_YIJI:
                        userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(),
                                commonOrder.getThirdCreateTime());
    private int getOrderState(Set<Integer> states) {
        if (states.size() == 1)
            return states.iterator().next();
        Iterator<Integer> its = states.iterator();
        while (its.hasNext()) {
            int tempState = its.next();
            if (tempState == CommonOrder.STATE_FK)
                return CommonOrder.STATE_FK;
            else if (tempState == CommonOrder.STATE_JS)
                return CommonOrder.STATE_JS;
        }
        return CommonOrder.STATE_SX;
    }
                    case HongBaoV2.TYPE_SHARE_ERJI:
                        userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
                                commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(),
                                commonOrder.getThirdCreateTime());
                        break;
                    }
                }
            }
    private boolean updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type,
                                  Map<Integer, HongBaoOrder> notificationMap) throws HongBaoException, UserAccountException {
        System.out.println(commonOrder.getOrderNo());
        // 锁行
        HongBaoV2 oldHongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBaoOrder.getHongBaoV2().getId());
        if (oldHongBao == null)
            throw new HongBaoException(10, "红包对象不存在");
        // 已经失效,已经领取,新老状态一致的红包不做处理
        if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
            return false;
            int resultCode = 0;
            if (hasAdd && hasUpdate)
                return new HongBaoAddResult(HongBaoAddResult.CODE_ADD_AND_UPDATE, miandan);
            else if (hasAdd)
                return new HongBaoAddResult(HongBaoAddResult.CODE_ADD, miandan);
            else if (hasUpdate)
                return new HongBaoAddResult(HongBaoAddResult.CODE_UPDATE, miandan);
            return new HongBaoAddResult(resultCode, miandan);
        }
        return new HongBaoAddResult(0, false);
    }
        SystemEnum system = userInfoService.getUserSystem(commonOrder.getUserInfo().getId());
    private int getOrderState(Set<Integer> states) {
        if (states.size() == 1)
            return states.iterator().next();
        Iterator<Integer> its = states.iterator();
        while (its.hasNext()) {
            int tempState = its.next();
            if (tempState == CommonOrder.STATE_FK)
                return CommonOrder.STATE_FK;
            else if (tempState == CommonOrder.STATE_JS)
                return CommonOrder.STATE_JS;
        }
        return CommonOrder.STATE_SX;
    }
        if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
            BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
                    commonOrder.getCreateTime().getTime(), system);
            // 免单处理
            boolean mianDan = false;
            List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO,
                    commonOrder.getOrderNo());
            if (orderList != null && orderList.size() == 1) {// 只有1个订单才参与免单
                BigDecimal payMent = commonOrder.getPayment();
                if (commonOrder.getState() == CommonOrder.STATE_JS)
                    payMent = commonOrder.getSettlement();
    @Transactional(rollbackFor = Exception.class)
    private boolean updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type,
            Map<Integer, HongBaoOrder> notificationMap) throws HongBaoException, UserAccountException {
        System.out.println(commonOrder.getOrderNo());
        // 锁行
        HongBaoV2 oldHongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBaoOrder.getHongBaoV2().getId());
        if (oldHongBao == null)
            throw new HongBaoException(10, "红包对象不存在");
        // 已经失效,已经领取,新老状态一致的红包不做处理
        if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
            return false;
                if (payMent.compareTo(new BigDecimal(10)) < 0) {
                    mianDan = userSystemCouponRecordService.isSuccessMianDan(commonOrder.getSourceType(),
                            commonOrder.getOrderNo());
                }
            }
        if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
            BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
                    commonOrder.getCreateTime().getTime());
            // 免单处理
            boolean mianDan = false;
            List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO,
                    commonOrder.getOrderNo());
            if (orderList != null && orderList.size() == 1) {// 只有1个订单才参与免单
                BigDecimal payMent = commonOrder.getPayment();
                if (commonOrder.getState() == CommonOrder.STATE_JS)
                    payMent = commonOrder.getSettlement();
            HongBaoV2 hongBao = new HongBaoV2(hongBaoOrder.getHongBaoV2().getId());
            hongBao.setUpdateTime(new Date());
            // 更改状态与资金
            if (commonOrder.getState() == CommonOrder.STATE_FK) {
                hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
                if (mianDan)
                    hongBao.setMoney(commonOrder.getPayment());
            } else if (commonOrder.getState() == CommonOrder.STATE_JS
                    || commonOrder.getState() == CommonOrder.STATE_WQ) {
                hongBao.setState(HongBaoV2.STATE_KELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
                if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_PDD)// 拼多多15天过1个小时到账
                    hongBao.setPreGetTime(new Date(
                            commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L + 1000 * 60 * 60 * 1L));
                else
                    hongBao.setPreGetTime(new Date(commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L));
                if (mianDan)
                    hongBao.setMoney(commonOrder.getSettlement().compareTo(commonOrder.getPayment()) <= 0
                            ? commonOrder.getSettlement() : commonOrder.getPayment());// 返利结算与付款较小的金额
            } else if (commonOrder.getState() == CommonOrder.STATE_SX) {
                hongBao.setState(HongBaoV2.STATE_SHIXIAO);
                hongBao.setMoney(new BigDecimal(0));
            }
                if (payMent.compareTo(new BigDecimal(10)) < 0) {
                    mianDan = userSystemCouponRecordService.isSuccessMianDan(commonOrder.getSourceType(),
                            commonOrder.getOrderNo());
                }
            }
            // 新老红包状态一致不处理
            if (oldHongBao.getState().intValue() == hongBao.getState())
                return false;
            HongBaoV2 hongBao = new HongBaoV2(hongBaoOrder.getHongBaoV2().getId());
            hongBao.setUpdateTime(new Date());
            // 更改状态与资金
            if (commonOrder.getState() == CommonOrder.STATE_FK) {
                hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
                if (mianDan)
                    hongBao.setMoney(commonOrder.getPayment());
            } else if (commonOrder.getState() == CommonOrder.STATE_JS
                    || commonOrder.getState() == CommonOrder.STATE_WQ) {
                hongBao.setState(HongBaoV2.STATE_KELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
                if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_PDD)// 拼多多15天过1个小时到账
                    hongBao.setPreGetTime(new Date(
                            commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L + 1000 * 60 * 60 * 1L));
                else
                    hongBao.setPreGetTime(new Date(commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L));
                if (mianDan)
                    hongBao.setMoney(commonOrder.getSettlement().compareTo(commonOrder.getPayment()) <= 0
                            ? commonOrder.getSettlement() : commonOrder.getPayment());// 返利结算与付款较小的金额
            } else if (commonOrder.getState() == CommonOrder.STATE_SX) {
                hongBao.setState(HongBaoV2.STATE_SHIXIAO);
                hongBao.setMoney(new BigDecimal(0));
            }
            if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO) {
                if (mianDan) {
                    try {
                        userSystemCouponService.updateStateByDrawback(commonOrder.getOrderNo(), commonOrder.getSourceType());
                    } catch (Exception e) {
                        e.printStackTrace();
                        throw new HongBaoException(12, "免单券退款出错");
                    }
                }
            }
            // 新老红包状态一致不处理
            if (oldHongBao.getState().intValue() == hongBao.getState())
                return false;
            hongBaoV2Mapper.updateByPrimaryKeySelective(hongBao);
            if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO) {
                if (mianDan) {
                    try {
                        userSystemCouponService.updateStateByDrawback(commonOrder.getOrderNo(),commonOrder.getSourceType());
                    } catch (Exception e) {
                        e.printStackTrace();
                        throw new HongBaoException(12, "免单券退款出错");
                    }
                }
            }
            // 加入通知
            if (notificationMap.get(type) == null) {
                HongBaoV2 tempHongBao = new HongBaoV2(oldHongBao.getId());
                tempHongBao.setUserInfo(oldHongBao.getUserInfo());
                tempHongBao.setMoney(hongBao.getMoney());
                CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                tempCommonOrder.setPayment(commonOrder.getPayment());
                notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
            } else {
                // 增加付款金额与资金
                HongBaoOrder tempHongBaoOrder = notificationMap.get(type);
                tempHongBaoOrder.getCommonOrder()
                        .setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                tempHongBaoOrder.getHongBaoV2()
                        .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(hongBao.getMoney()));
                notificationMap.put(type, tempHongBaoOrder);
            }
            hongBaoV2Mapper.updateByPrimaryKeySelective(hongBao);
            // 获取子红包
            List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
            if (children != null && children.size() > 0)
                for (HongBaoV2 child : children) {
                    if (child.getState() == HongBaoV2.STATE_YILINGQU)
                        continue;
            // 加入通知
            if (notificationMap.get(type) == null) {
                HongBaoV2 tempHongBao = new HongBaoV2(oldHongBao.getId());
                tempHongBao.setUserInfo(oldHongBao.getUserInfo());
                tempHongBao.setMoney(hongBao.getMoney());
                CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                tempCommonOrder.setPayment(commonOrder.getPayment());
                notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
            } else {
                // 增加付款金额与资金
                HongBaoOrder tempHongBaoOrder = notificationMap.get(type);
                tempHongBaoOrder.getCommonOrder()
                        .setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                tempHongBaoOrder.getHongBaoV2()
                        .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(hongBao.getMoney()));
                notificationMap.put(type, tempHongBaoOrder);
            }
                    HongBaoV2 childUpdate = new HongBaoV2(child.getId());
                    childUpdate.setState(hongBao.getState());
                    childUpdate.setUpdateTime(new Date());
                    BigDecimal rate = null;
                    if (child.getType() == HongBaoV2.TYPE_YIJI) {// 一级分享赚
                        rate = hongBaoManageService.getFirstInviteRate(child.getUrank(),
                                commonOrder.getCreateTime().getTime(), system);
                    } else if (child.getType() == HongBaoV2.TYPE_ERJI) {// 二级分享赚
                        rate = hongBaoManageService.getSecondInviteRate(child.getUrank(),
                                commonOrder.getCreateTime().getTime(), system);
                    }
            // 获取子红包
            List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
            if (children != null && children.size() > 0)
                for (HongBaoV2 child : children) {
                    if (child.getState() == HongBaoV2.STATE_YILINGQU)
                        continue;
                    // 以实际收入为准计算预估收益
                    if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
                        childUpdate.setMoney(
                                MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(commonOrder.getSettleTime());
                        calendar.add(Calendar.MONTH, 1);
                        childUpdate.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                                calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                                "yyyy-M-dd")));
                    } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
                        childUpdate.setMoney(
                                MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
                    }
                    hongBaoV2Mapper.updateByPrimaryKeySelective(childUpdate);
                    HongBaoV2 childUpdate = new HongBaoV2(child.getId());
                    childUpdate.setState(hongBao.getState());
                    childUpdate.setUpdateTime(new Date());
                    BigDecimal rate = null;
                    if (child.getType() == HongBaoV2.TYPE_YIJI) {// 一级分享赚
                        rate = hongBaoManageService.getFirstInviteRate(child.getUrank(),
                                commonOrder.getCreateTime().getTime());
                    } else if (child.getType() == HongBaoV2.TYPE_ERJI) {// 二级分享赚
                        rate = hongBaoManageService.getSecondInviteRate(child.getUrank(),
                                commonOrder.getCreateTime().getTime());
                    }
                    // 加入通知
                    if (notificationMap.get(child.getType()) == null) {
                        HongBaoV2 tempHongBao = new HongBaoV2(child.getId());
                        tempHongBao.setUserInfo(child.getUserInfo());
                        tempHongBao.setMoney(child.getMoney());
                        CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                        tempCommonOrder.setPayment(commonOrder.getPayment());
                        notificationMap.put(child.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao));
                    } else {
                        // 增加付款金额与资金
                        HongBaoOrder tempHongBaoOrder = notificationMap.get(child.getType());
                        tempHongBaoOrder.getCommonOrder().setPayment(
                                tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                        tempHongBaoOrder.getHongBaoV2()
                                .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(child.getMoney()));
                        notificationMap.put(child.getType(), tempHongBaoOrder);
                    }
                    // 以实际收入为准计算预估收益
                    if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
                        childUpdate.setMoney(
                                MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(commonOrder.getSettleTime());
                        calendar.add(Calendar.MONTH, 1);
                        childUpdate.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                                calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                                "yyyy-M-dd")));
                    } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
                        childUpdate.setMoney(
                                MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
                    }
                    hongBaoV2Mapper.updateByPrimaryKeySelective(childUpdate);
                }
            else {// 修复之前二级,三级订单未统计到的情况
                if (!mianDan) {
                    ThreeSale threeSale = threeSaleSerivce.selectByWorkerId(commonOrder.getUserInfo().getId());
                    if (threeSale != null && threeSale.getSucceedTime() != null
                            && threeSale.getSucceedTime() <= commonOrder.getThirdCreateTime().getTime()) {
                        UserInfo boss = threeSaleSerivce.getBoss(commonOrder.getUserInfo().getId());
                        // 插入一级子红包
                        BigDecimal firstRate = hongBaoManageService
                                .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank(), system);
                        if (firstRate.compareTo(new BigDecimal(0)) <= 0)
                            return true;
                        HongBaoV2 firstHongbao = new HongBaoV2();
                        firstHongbao.setUserInfo(boss);
                        firstHongbao.setUrank(boss.getRank());
                        firstHongbao.setParent(hongBao);
                        firstHongbao.setCreateTime(new Date());
                        firstHongbao.setType(HongBaoV2.TYPE_YIJI);
                        firstHongbao.setVersion(2);
                        firstHongbao.setState(hongBao.getState());
                        firstHongbao.setOrderType(commonOrder.getSourceType());
                    // 加入通知
                    if (notificationMap.get(child.getType()) == null) {
                        HongBaoV2 tempHongBao = new HongBaoV2(child.getId());
                        tempHongBao.setUserInfo(child.getUserInfo());
                        tempHongBao.setMoney(child.getMoney());
                        CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                        tempCommonOrder.setPayment(commonOrder.getPayment());
                        notificationMap.put(child.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao));
                    } else {
                        // 增加付款金额与资金
                        HongBaoOrder tempHongBaoOrder = notificationMap.get(child.getType());
                        tempHongBaoOrder.getCommonOrder().setPayment(
                                tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                        tempHongBaoOrder.getHongBaoV2()
                                .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(child.getMoney()));
                        notificationMap.put(child.getType(), tempHongBaoOrder);
                    }
                        if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
                            firstHongbao.setMoney(
                                    MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
                            Calendar calendar = Calendar.getInstance();
                            calendar.setTime(commonOrder.getSettleTime());
                            calendar.add(Calendar.MONTH, 1);
                            firstHongbao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                                    calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                                    "yyyy-M-dd")));
                        } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
                            firstHongbao.setMoney(
                                    MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
                        } else if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO) {
                            firstHongbao.setMoney(new BigDecimal(0));
                        }
                }
            else {// 修复之前二级,三级订单未统计到的情况
                if (!mianDan) {
                    ThreeSale threeSale = threeSaleSerivce.selectByWorkerId(commonOrder.getUserInfo().getId());
                    if (threeSale != null && threeSale.getSucceedTime() != null
                            && threeSale.getSucceedTime() <= commonOrder.getThirdCreateTime().getTime()) {
                        UserInfo boss = threeSaleSerivce.getBoss(commonOrder.getUserInfo().getId());
                        // 插入一级子红包
                        BigDecimal firstRate = hongBaoManageService
                                .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank());
                        if (firstRate.compareTo(new BigDecimal(0)) <= 0)
                            return true;
                        HongBaoV2 firstHongbao = new HongBaoV2();
                        firstHongbao.setUserInfo(boss);
                        firstHongbao.setUrank(boss.getRank());
                        firstHongbao.setParent(hongBao);
                        firstHongbao.setCreateTime(new Date());
                        firstHongbao.setType(HongBaoV2.TYPE_YIJI);
                        firstHongbao.setVersion(2);
                        firstHongbao.setState(hongBao.getState());
                        firstHongbao.setOrderType(commonOrder.getSourceType());
                        if (firstHongbao.getMoney() != null
                                && firstHongbao.getMoney().compareTo(new BigDecimal(0)) > 0) {
                            hongBaoV2Mapper.insertSelective(firstHongbao);
                            // 用户通知
                            if (notificationMap.get(HongBaoV2.TYPE_YIJI) == null) {
                                HongBaoV2 tempHongBao = new HongBaoV2(firstHongbao.getId());
                                tempHongBao.setUserInfo(firstHongbao.getUserInfo());
                                tempHongBao.setMoney(firstHongbao.getMoney());
                                CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                                tempCommonOrder.setPayment(commonOrder.getPayment());
                                notificationMap.put(HongBaoV2.TYPE_YIJI,
                                        new HongBaoOrder(tempCommonOrder, tempHongBao));
                            } else {
                                // 增加付款金额与资金
                                HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_YIJI);
                                tempHongBaoOrder.getCommonOrder().setPayment(
                                        tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                                tempHongBaoOrder.getHongBaoV2().setMoney(
                                        tempHongBaoOrder.getHongBaoV2().getMoney().add(firstHongbao.getMoney()));
                                notificationMap.put(HongBaoV2.TYPE_YIJI, tempHongBaoOrder);
                            }
                        }
                        if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
                            firstHongbao.setMoney(
                                    MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
                            Calendar calendar = Calendar.getInstance();
                            calendar.setTime(commonOrder.getSettleTime());
                            calendar.add(Calendar.MONTH, 1);
                            firstHongbao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                                    calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                                    "yyyy-M-dd")));
                        } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
                            firstHongbao.setMoney(
                                    MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
                        } else if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO) {
                            firstHongbao.setMoney(new BigDecimal(0));
                        }
                        // 插入二级子红包
                        boss = threeSaleSerivce.getBoss(boss.getId());
                        if (boss != null) {// 二级BOSS存在
                            BigDecimal secondRate = hongBaoManageService
                                    .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank(), system);
                            if (secondRate.compareTo(new BigDecimal(0)) <= 0)
                                return true;
                            HongBaoV2 secondHongbao = new HongBaoV2();
                            secondHongbao.setUserInfo(boss);
                            secondHongbao.setUrank(boss.getRank());
                            secondHongbao.setParent(hongBao);
                            secondHongbao.setCreateTime(new Date());
                            secondHongbao.setType(HongBaoV2.TYPE_ERJI);
                            secondHongbao.setVersion(2);
                            secondHongbao.setState(hongBao.getState());
                            secondHongbao.setOrderType(commonOrder.getSourceType());
                            if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
                                secondHongbao.setMoney(MoneyBigDecimalUtil.mul(hongBao.getMoney(),
                                        secondRate.divide(new BigDecimal(100))));
                                Calendar calendar = Calendar.getInstance();
                                calendar.setTime(commonOrder.getSettleTime());
                                calendar.add(Calendar.MONTH, 1);
                                secondHongbao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                                        calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                                        "yyyy-M-dd")));
                            } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
                                secondHongbao.setMoney(MoneyBigDecimalUtil.mul(hongBao.getMoney(),
                                        secondRate.divide(new BigDecimal(100))));
                            } else if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO)
                                secondHongbao.setMoney(new BigDecimal(0));
                            if (secondHongbao.getMoney() != null
                                    && secondHongbao.getMoney().compareTo(new BigDecimal(0)) > 0) {
                                hongBaoV2Mapper.insertSelective(secondHongbao);
                                // 用户通知
                                if (notificationMap.get(HongBaoV2.TYPE_ERJI) == null) {
                                    HongBaoV2 tempHongBao = new HongBaoV2(secondHongbao.getId());
                                    tempHongBao.setUserInfo(secondHongbao.getUserInfo());
                                    tempHongBao.setMoney(secondHongbao.getMoney());
                                    CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                                    tempCommonOrder.setPayment(commonOrder.getPayment());
                                    notificationMap.put(HongBaoV2.TYPE_ERJI,
                                            new HongBaoOrder(tempCommonOrder, tempHongBao));
                                } else {
                                    // 增加付款金额与资金
                                    HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_ERJI);
                                    tempHongBaoOrder.getCommonOrder().setPayment(tempHongBaoOrder.getCommonOrder()
                                            .getPayment().add(commonOrder.getPayment()));
                                    tempHongBaoOrder.getHongBaoV2().setMoney(
                                            tempHongBaoOrder.getHongBaoV2().getMoney().add(secondHongbao.getMoney()));
                                    notificationMap.put(HongBaoV2.TYPE_ERJI, tempHongBaoOrder);
                                }
                            }
                        }
                    }
                }
            }
        } else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
            BigDecimal fanliRate = null;
            if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_TAOBAO
                    && commonOrder.getSourcePosition().equalsIgnoreCase(TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT))
                fanliRate = hongBaoManageService.getTLJShareRate(commonOrder.getCreateTime().getTime(), system);
            else
                fanliRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
                        commonOrder.getCreateTime().getTime(), system);
                        if (firstHongbao.getMoney() != null
                                && firstHongbao.getMoney().compareTo(new BigDecimal(0)) > 0) {
                            hongBaoV2Mapper.insertSelective(firstHongbao);
                            // 用户通知
                            if (notificationMap.get(HongBaoV2.TYPE_YIJI) == null) {
                                HongBaoV2 tempHongBao = new HongBaoV2(firstHongbao.getId());
                                tempHongBao.setUserInfo(firstHongbao.getUserInfo());
                                tempHongBao.setMoney(firstHongbao.getMoney());
                                CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                                tempCommonOrder.setPayment(commonOrder.getPayment());
                                notificationMap.put(HongBaoV2.TYPE_YIJI,
                                        new HongBaoOrder(tempCommonOrder, tempHongBao));
                            } else {
                                // 增加付款金额与资金
                                HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_YIJI);
                                tempHongBaoOrder.getCommonOrder().setPayment(
                                        tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                                tempHongBaoOrder.getHongBaoV2().setMoney(
                                        tempHongBaoOrder.getHongBaoV2().getMoney().add(firstHongbao.getMoney()));
                                notificationMap.put(HongBaoV2.TYPE_YIJI, tempHongBaoOrder);
                            }
                        }
            List<ShareGoodsActivityOrder> list = shareGoodsActivityOrderService
                    .listByOrderIdAndUid(commonOrder.getUserInfo().getId(), commonOrder.getOrderNo());
            if (list != null && list.size() > 0) {
                fanliRate = list.get(0).getShareRate();
            }
                        // 插入二级子红包
                        boss = threeSaleSerivce.getBoss(boss.getId());
                        if (boss != null) {// 二级BOSS存在
                            BigDecimal secondRate = hongBaoManageService
                                    .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank());
                            if (secondRate.compareTo(new BigDecimal(0)) <= 0)
                                return true;
                            HongBaoV2 secondHongbao = new HongBaoV2();
                            secondHongbao.setUserInfo(boss);
                            secondHongbao.setUrank(boss.getRank());
                            secondHongbao.setParent(hongBao);
                            secondHongbao.setCreateTime(new Date());
                            secondHongbao.setType(HongBaoV2.TYPE_ERJI);
                            secondHongbao.setVersion(2);
                            secondHongbao.setState(hongBao.getState());
                            secondHongbao.setOrderType(commonOrder.getSourceType());
                            if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
                                secondHongbao.setMoney(MoneyBigDecimalUtil.mul(hongBao.getMoney(),
                                        secondRate.divide(new BigDecimal(100))));
                                Calendar calendar = Calendar.getInstance();
                                calendar.setTime(commonOrder.getSettleTime());
                                calendar.add(Calendar.MONTH, 1);
                                secondHongbao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                                        calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                                        "yyyy-M-dd")));
                            } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
                                secondHongbao.setMoney(MoneyBigDecimalUtil.mul(hongBao.getMoney(),
                                        secondRate.divide(new BigDecimal(100))));
                            } else if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO)
                                secondHongbao.setMoney(new BigDecimal(0));
                            if (secondHongbao.getMoney() != null
                                    && secondHongbao.getMoney().compareTo(new BigDecimal(0)) > 0) {
                                hongBaoV2Mapper.insertSelective(secondHongbao);
                                // 用户通知
                                if (notificationMap.get(HongBaoV2.TYPE_ERJI) == null) {
                                    HongBaoV2 tempHongBao = new HongBaoV2(secondHongbao.getId());
                                    tempHongBao.setUserInfo(secondHongbao.getUserInfo());
                                    tempHongBao.setMoney(secondHongbao.getMoney());
                                    CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                                    tempCommonOrder.setPayment(commonOrder.getPayment());
                                    notificationMap.put(HongBaoV2.TYPE_ERJI,
                                            new HongBaoOrder(tempCommonOrder, tempHongBao));
                                } else {
                                    // 增加付款金额与资金
                                    HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_ERJI);
                                    tempHongBaoOrder.getCommonOrder().setPayment(tempHongBaoOrder.getCommonOrder()
                                            .getPayment().add(commonOrder.getPayment()));
                                    tempHongBaoOrder.getHongBaoV2().setMoney(
                                            tempHongBaoOrder.getHongBaoV2().getMoney().add(secondHongbao.getMoney()));
                                    notificationMap.put(HongBaoV2.TYPE_ERJI, tempHongBaoOrder);
                                }
                            }
                        }
                    }
                }
            }
        } else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
            BigDecimal fanliRate = null;
            if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_TAOBAO
                    && commonOrder.getSourcePosition().equalsIgnoreCase(TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT))
                fanliRate = hongBaoManageService.getTLJShareRate(commonOrder.getCreateTime().getTime());
            else
                fanliRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
                        commonOrder.getCreateTime().getTime());
            HongBaoV2 hongBao = new HongBaoV2(hongBaoOrder.getHongBaoV2().getId());
            hongBao.setUpdateTime(new Date());
            // 更改状态与资金
            if (commonOrder.getState() == CommonOrder.STATE_FK) {
                hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
            } else if (commonOrder.getState() == CommonOrder.STATE_JS
                    || commonOrder.getState() == CommonOrder.STATE_WQ) {
                hongBao.setState(HongBaoV2.STATE_KELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(commonOrder.getSettleTime());
                calendar.add(Calendar.MONTH, 1);
                hongBao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                        calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd")));
            } else if (commonOrder.getState() == CommonOrder.STATE_SX) {
                hongBao.setState(HongBaoV2.STATE_SHIXIAO);
                hongBao.setMoney(new BigDecimal(0));
            }
            hongBaoV2Mapper.updateByPrimaryKeySelective(hongBao);
            // 通知
            if (notificationMap.get(type) == null) {
                HongBaoV2 tempHongBao = new HongBaoV2(hongBao.getId());
                tempHongBao.setUserInfo(hongBaoOrder.getHongBaoV2().getUserInfo());
                tempHongBao.setMoney(hongBao.getMoney());
                CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                tempCommonOrder.setPayment(commonOrder.getPayment());
                notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
            } else {
                // 增加付款金额与资金
                HongBaoOrder tempHongBaoOrder = notificationMap.get(type);
                tempHongBaoOrder.getCommonOrder()
                        .setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                tempHongBaoOrder.getHongBaoV2()
                        .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(hongBao.getMoney()));
                notificationMap.put(type, tempHongBaoOrder);
            }
            List<ShareGoodsActivityOrder> list = shareGoodsActivityOrderService
                    .listByOrderIdAndUid(commonOrder.getUserInfo().getId(), commonOrder.getOrderNo());
            if (list != null && list.size() > 0) {
                fanliRate = list.get(0).getShareRate();
            }
            // 获取子红包
            List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
            if (children != null)
                for (HongBaoV2 child : children) {
                    if (child.getState() == HongBaoV2.STATE_YILINGQU)
                        continue;
            HongBaoV2 hongBao = new HongBaoV2(hongBaoOrder.getHongBaoV2().getId());
            hongBao.setUpdateTime(new Date());
            // 更改状态与资金
            if (commonOrder.getState() == CommonOrder.STATE_FK) {
                hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
            } else if (commonOrder.getState() == CommonOrder.STATE_JS
                    || commonOrder.getState() == CommonOrder.STATE_WQ) {
                hongBao.setState(HongBaoV2.STATE_KELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(commonOrder.getSettleTime());
                calendar.add(Calendar.MONTH, 1);
                hongBao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                        calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd")));
            } else if (commonOrder.getState() == CommonOrder.STATE_SX) {
                hongBao.setState(HongBaoV2.STATE_SHIXIAO);
                hongBao.setMoney(new BigDecimal(0));
            }
            hongBaoV2Mapper.updateByPrimaryKeySelective(hongBao);
            // 通知
            if (notificationMap.get(type) == null) {
                HongBaoV2 tempHongBao = new HongBaoV2(hongBao.getId());
                tempHongBao.setUserInfo(hongBaoOrder.getHongBaoV2().getUserInfo());
                tempHongBao.setMoney(hongBao.getMoney());
                CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                tempCommonOrder.setPayment(commonOrder.getPayment());
                notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
            } else {
                // 增加付款金额与资金
                HongBaoOrder tempHongBaoOrder = notificationMap.get(type);
                tempHongBaoOrder.getCommonOrder()
                        .setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                tempHongBaoOrder.getHongBaoV2()
                        .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(hongBao.getMoney()));
                notificationMap.put(type, tempHongBaoOrder);
            }
                    HongBaoV2 childUpdate = new HongBaoV2(child.getId());
                    // 统一设置状态
                    childUpdate.setState(hongBao.getState());
                    childUpdate.setUpdateTime(new Date());
                    BigDecimal rate = null;
                    if (child.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 一级分享赚
                        rate = hongBaoManageService.getFirstShareRate(1, commonOrder.getCreateTime().getTime(), system);
                    } else if (child.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 二级分享赚
                        rate = hongBaoManageService.getSecondShareRate(1, commonOrder.getCreateTime().getTime(), system);
                    }
            // 获取子红包
            List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
            if (children != null)
                for (HongBaoV2 child : children) {
                    if (child.getState() == HongBaoV2.STATE_YILINGQU)
                        continue;
                    // 以实际收入为准计算预估收益
                    if (CommonOrder.STATE_JS == commonOrder.getState()
                            || CommonOrder.STATE_WQ == commonOrder.getState()) {
                        childUpdate.setMoney(
                                MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
                        if (commonOrder.getThirdCreateTime().getTime() > TimeUtil.convertToTimeTemp("2019-04-16",
                                "yyyy-MM-dd"))
                            childUpdate.setMoney(MoneyBigDecimalUtil.mul(commonOrder.geteIncome(),
                                    rate.divide(new BigDecimal(100))));
                    HongBaoV2 childUpdate = new HongBaoV2(child.getId());
                    // 统一设置状态
                    childUpdate.setState(hongBao.getState());
                    childUpdate.setUpdateTime(new Date());
                    BigDecimal rate = null;
                    if (child.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 一级分享赚
                        rate = hongBaoManageService.getFirstShareRate(1, commonOrder.getCreateTime().getTime());
                    } else if (child.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 二级分享赚
                        rate = hongBaoManageService.getSecondShareRate(1, commonOrder.getCreateTime().getTime());
                    }
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(commonOrder.getSettleTime());
                        calendar.add(Calendar.MONTH, 1);
                        childUpdate.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                                calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                                "yyyy-M-dd")));
                    } else if (CommonOrder.STATE_FK == commonOrder.getState()) {
                        if (commonOrder.getThirdCreateTime().getTime() > TimeUtil.convertToTimeTemp("2019-04-16",
                                "yyyy-MM-dd"))
                            childUpdate.setMoney(MoneyBigDecimalUtil.mul(commonOrder.getEstimate(),
                                    rate.divide(new BigDecimal(100))));
                        else
                            childUpdate.setMoney(
                                    MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
                    }
                    hongBaoV2Mapper.updateByPrimaryKeySelective(childUpdate);
                    // 添加通知
                    if (notificationMap.get(child.getType()) == null) {
                        HongBaoV2 tempHongBao = new HongBaoV2(child.getId());
                        tempHongBao.setUserInfo(child.getUserInfo());
                        tempHongBao
                                .setMoney(childUpdate.getMoney() == null ? new BigDecimal(0) : childUpdate.getMoney());
                        CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                        tempCommonOrder.setPayment(commonOrder.getPayment());
                        notificationMap.put(child.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao));
                    } else {
                        // 增加付款金额与资金
                        HongBaoOrder tempHongBaoOrder = notificationMap.get(child.getType());
                        if (commonOrder.getPayment() != null)
                            tempHongBaoOrder.getCommonOrder().setPayment(
                                    tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                        if (childUpdate.getMoney() != null)
                            tempHongBaoOrder.getHongBaoV2()
                                    .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(childUpdate.getMoney()));
                        notificationMap.put(child.getType(), tempHongBaoOrder);
                    }
                    // 以实际收入为准计算预估收益
                    if (CommonOrder.STATE_JS == commonOrder.getState()
                            || CommonOrder.STATE_WQ == commonOrder.getState()) {
                        childUpdate.setMoney(
                                MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
                        if (commonOrder.getThirdCreateTime().getTime() > TimeUtil.convertToTimeTemp("2019-04-16",
                                "yyyy-MM-dd"))
                            childUpdate.setMoney(MoneyBigDecimalUtil.mul(commonOrder.geteIncome(),
                                    rate.divide(new BigDecimal(100))));
                }
        } else
            throw new HongBaoException(2, "type错误");
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(commonOrder.getSettleTime());
                        calendar.add(Calendar.MONTH, 1);
                        childUpdate.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                                calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                                "yyyy-M-dd")));
                    } else if (CommonOrder.STATE_FK == commonOrder.getState()) {
                        if (commonOrder.getThirdCreateTime().getTime() > TimeUtil.convertToTimeTemp("2019-04-16",
                                "yyyy-MM-dd"))
                            childUpdate.setMoney(MoneyBigDecimalUtil.mul(commonOrder.getEstimate(),
                                    rate.divide(new BigDecimal(100))));
                        else
                            childUpdate.setMoney(
                                    MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
                    }
                    hongBaoV2Mapper.updateByPrimaryKeySelective(childUpdate);
                    // 添加通知
                    if (notificationMap.get(child.getType()) == null) {
                        HongBaoV2 tempHongBao = new HongBaoV2(child.getId());
                        tempHongBao.setUserInfo(child.getUserInfo());
                        tempHongBao
                                .setMoney(childUpdate.getMoney() == null ? new BigDecimal(0) : childUpdate.getMoney());
                        CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                        tempCommonOrder.setPayment(commonOrder.getPayment());
                        notificationMap.put(child.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao));
                    } else {
                        // 增加付款金额与资金
                        HongBaoOrder tempHongBaoOrder = notificationMap.get(child.getType());
                        if (commonOrder.getPayment() != null)
                            tempHongBaoOrder.getCommonOrder().setPayment(
                                    tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                        if (childUpdate.getMoney() != null)
                            tempHongBaoOrder.getHongBaoV2()
                                    .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(childUpdate.getMoney()));
                        notificationMap.put(child.getType(), tempHongBaoOrder);
                    }
                }
        } else
            throw new HongBaoException(2, "type错误");
        return true;
    }
        return true;
    }
    private boolean saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap)
            throws HongBaoException, UserAccountException {
        SystemEnum system = userInfoService.getUserSystem(commonOrder.getUserInfo().getId());
        if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
            BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
                    commonOrder.getCreateTime().getTime(), system);
            // 查询是否有免单计划
            BigDecimal mianDanMoney = null;
            if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK) {
                List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(commonOrder.getSourceType(),
                        commonOrder.getOrderNo());
                if (orderList != null && orderList.size() == 1) {// 只有1个订单才参与免单
                    BigDecimal payMent = commonOrder.getPayment();
                    if (commonOrder.getState() == CommonOrder.STATE_JS)
                        payMent = commonOrder.getSettlement();
    @Transactional(rollbackFor = Exception.class)
    private boolean saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap)
            throws HongBaoException, UserAccountException {
        if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
            BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
                    commonOrder.getCreateTime().getTime());
            // 查询是否有免单计划
            BigDecimal mianDanMoney = null;
            if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK) {
                List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(commonOrder.getSourceType(),
                        commonOrder.getOrderNo());
                if (orderList != null && orderList.size() == 1) {// 只有1个订单才参与免单
                    BigDecimal payMent = commonOrder.getPayment();
                    if (commonOrder.getState() == CommonOrder.STATE_JS)
                        payMent = commonOrder.getSettlement();
                    CommonOrderGoods goods = commonOrderGoodsMapper
                            .selectByPrimaryKey(commonOrder.getCommonOrderGoods().getId());
                    if (goods != null) {
                        try {
                            if (userSystemCouponService.updateCouponRecordUsed(commonOrder.getUserInfo().getId(),
                                    commonOrder.getOrderNo(), payMent, Long.parseLong(goods.getGoodsId()), commonOrder.getSourceType()))
                                mianDanMoney = payMent;
                        } catch (NumberFormatException e) {
                            throw new HongBaoException(10, "免单商品处理出错");
                        } catch (Exception e) {
                            e.printStackTrace();
                            throw new HongBaoException(11, "免单商品处理出错");
                        }
                    }
                }
            } else if (commonOrder.getState() == CommonOrder.STATE_SX) {// 设置免单券失效
                commonOrder.setPayment(new BigDecimal(0));// 订单失效后的付款金额设置为0
                try {
                    userSystemCouponService.updateStateByDrawback(commonOrder.getOrderNo(), commonOrder.getSourceType());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
                    CommonOrderGoods goods = commonOrderGoodsMapper
                            .selectByPrimaryKey(commonOrder.getCommonOrderGoods().getId());
                    if (goods != null) {
                        try {
                            if (userSystemCouponService.updateCouponRecordUsed(commonOrder.getUserInfo().getId(),
                                    commonOrder.getOrderNo(), payMent, Long.parseLong(goods.getGoodsId()),commonOrder.getSourceType()))
                                mianDanMoney = payMent;
                        } catch (NumberFormatException e) {
                            throw new HongBaoException(10, "免单商品处理出错");
                        } catch (Exception e) {
                            e.printStackTrace();
                            throw new HongBaoException(11, "免单商品处理出错");
                        }
                    }
                }
            } else if (commonOrder.getState() == CommonOrder.STATE_SX) {// 设置免单券失效
                commonOrder.setPayment(new BigDecimal(0));// 订单失效后的付款金额设置为0
                try {
                    userSystemCouponService.updateStateByDrawback(commonOrder.getOrderNo(),commonOrder.getSourceType());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            HongBaoV2 hongBao = new HongBaoV2();
            hongBao.setUserInfo(commonOrder.getUserInfo());
            hongBao.setCreateTime(new Date());
            hongBao.setType(HongBaoV2.TYPE_ZIGOU);
            hongBao.setVersion(2);
            if (commonOrder.getState() == CommonOrder.STATE_FK) {
                hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
            } else if (commonOrder.getState() == CommonOrder.STATE_JS
                    || CommonOrder.STATE_WQ == commonOrder.getState()) {
                hongBao.setState(HongBaoV2.STATE_KELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
                if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_PDD)// 拼多多15天半到账
                    hongBao.setPreGetTime(new Date(
                            commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L + 1000 * 60 * 60 * 12L));
                else
                    hongBao.setPreGetTime(new Date(commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L));
            } else if (commonOrder.getState() == CommonOrder.STATE_SX) {
                hongBao.setState(HongBaoV2.STATE_SHIXIAO);
                hongBao.setMoney(new BigDecimal(0));
            } else {
                throw new HongBaoException(3, "维权订单不能创建红包");
            }
            HongBaoV2 hongBao = new HongBaoV2();
            hongBao.setUserInfo(commonOrder.getUserInfo());
            hongBao.setCreateTime(new Date());
            hongBao.setType(HongBaoV2.TYPE_ZIGOU);
            hongBao.setVersion(2);
            if (commonOrder.getState() == CommonOrder.STATE_FK) {
                hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
            } else if (commonOrder.getState() == CommonOrder.STATE_JS
                    || CommonOrder.STATE_WQ == commonOrder.getState()) {
                hongBao.setState(HongBaoV2.STATE_KELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
                if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_PDD)// 拼多多15天半到账
                    hongBao.setPreGetTime(new Date(
                            commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L + 1000 * 60 * 60 * 12L));
                else
                    hongBao.setPreGetTime(new Date(commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L));
            } else if (commonOrder.getState() == CommonOrder.STATE_SX) {
                hongBao.setState(HongBaoV2.STATE_SHIXIAO);
                hongBao.setMoney(new BigDecimal(0));
            } else {
                throw new HongBaoException(3, "维权订单不能创建红包");
            }
            if (mianDanMoney != null)
                hongBao.setMoney(mianDanMoney);
            if (mianDanMoney != null)
                hongBao.setMoney(mianDanMoney);
            UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
            if (user == null)
                throw new UserAccountException(1001, "用户不存在/被封禁");
            hongBao.setUrank(user.getRank());
            hongBao.setOrderType(commonOrder.getSourceType());
            hongBaoV2Mapper.insertSelective(hongBao);
            // 添加红包与订单的映射
            HongBaoOrder hongBaoOrder = new HongBaoOrder();
            hongBaoOrder.setCommonOrder(commonOrder);
            hongBaoOrder.setCreateTime(new Date());
            hongBaoOrder.setHongBaoV2(hongBao);
            hongBaoOrderMapper.insertSelective(hongBaoOrder);
            // 加入通知
            if (notificationMap.get(type) == null) {
                HongBaoV2 tempHongBao = new HongBaoV2(hongBao.getId());
                tempHongBao.setUserInfo(hongBao.getUserInfo());
                tempHongBao.setMoney(hongBao.getMoney());
                CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                tempCommonOrder.setPayment(commonOrder.getPayment());
                notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
            } else {
                // 增加付款金额与资金
                HongBaoOrder tempHongBaoOrder = notificationMap.get(type);
                tempHongBaoOrder.getCommonOrder()
                        .setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                tempHongBaoOrder.getHongBaoV2()
                        .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(hongBao.getMoney()));
                notificationMap.put(type, tempHongBaoOrder);
            }
            UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
            if (user == null)
                throw new UserAccountException(1001, "用户不存在/被封禁");
            hongBao.setUrank(user.getRank());
            hongBao.setOrderType(commonOrder.getSourceType());
            hongBaoV2Mapper.insertSelective(hongBao);
            // 添加红包与订单的映射
            HongBaoOrder hongBaoOrder = new HongBaoOrder();
            hongBaoOrder.setCommonOrder(commonOrder);
            hongBaoOrder.setCreateTime(new Date());
            hongBaoOrder.setHongBaoV2(hongBao);
            hongBaoOrderMapper.insertSelective(hongBaoOrder);
            // 加入通知
            if (notificationMap.get(type) == null) {
                HongBaoV2 tempHongBao = new HongBaoV2(hongBao.getId());
                tempHongBao.setUserInfo(hongBao.getUserInfo());
                tempHongBao.setMoney(hongBao.getMoney());
                CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                tempCommonOrder.setPayment(commonOrder.getPayment());
                notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
            } else {
                // 增加付款金额与资金
                HongBaoOrder tempHongBaoOrder = notificationMap.get(type);
                tempHongBaoOrder.getCommonOrder()
                        .setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                tempHongBaoOrder.getHongBaoV2()
                        .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(hongBao.getMoney()));
                notificationMap.put(type, tempHongBaoOrder);
            }
            UserInfo boss = threeSaleSerivce.getBoss(user.getId());
            if (boss != null && hongBao.getState() != HongBaoV2.STATE_SHIXIAO && mianDanMoney == null) {// 1级BOSS存在且红包未失效,免单不支持多级分销
            UserInfo boss = threeSaleSerivce.getBoss(user.getId());
            if (boss != null && hongBao.getState() != HongBaoV2.STATE_SHIXIAO && mianDanMoney == null) {// 1级BOSS存在且红包未失效,免单不支持多级分销
                // 插入一级子红包
                BigDecimal firstRate = hongBaoManageService
                        .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank(),system);
                if (firstRate.compareTo(new BigDecimal(0)) <= 0)
                    return mianDanMoney != null;
                HongBaoV2 firstHongbao = new HongBaoV2();
                firstHongbao.setUserInfo(boss);
                firstHongbao.setUrank(boss.getRank());
                firstHongbao.setParent(hongBao);
                firstHongbao.setCreateTime(new Date());
                firstHongbao.setType(HongBaoV2.TYPE_YIJI);
                firstHongbao.setVersion(2);
                firstHongbao.setState(hongBao.getState());
                firstHongbao.setOrderType(commonOrder.getSourceType());
                // 插入一级子红包
                BigDecimal firstRate = hongBaoManageService
                        .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank());
                if (firstRate.compareTo(new BigDecimal(0)) <= 0)
                    return mianDanMoney != null;
                HongBaoV2 firstHongbao = new HongBaoV2();
                firstHongbao.setUserInfo(boss);
                firstHongbao.setUrank(boss.getRank());
                firstHongbao.setParent(hongBao);
                firstHongbao.setCreateTime(new Date());
                firstHongbao.setType(HongBaoV2.TYPE_YIJI);
                firstHongbao.setVersion(2);
                firstHongbao.setState(hongBao.getState());
                firstHongbao.setOrderType(commonOrder.getSourceType());
                if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
                    firstHongbao.setMoney(
                            MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(commonOrder.getSettleTime());
                    calendar.add(Calendar.MONTH, 1);
                    firstHongbao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                            calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                            "yyyy-M-dd")));
                } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
                    firstHongbao.setMoney(
                            MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
                }
                // 返利为0的不通知
                if (firstHongbao.getMoney() == null || firstHongbao.getMoney().compareTo(new BigDecimal(0)) <= 0)
                    return mianDanMoney != null;
                if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
                    firstHongbao.setMoney(
                            MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(commonOrder.getSettleTime());
                    calendar.add(Calendar.MONTH, 1);
                    firstHongbao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                            calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                            "yyyy-M-dd")));
                } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
                    firstHongbao.setMoney(
                            MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
                }
                // 返利为0的不通知
                if (firstHongbao.getMoney() == null || firstHongbao.getMoney().compareTo(new BigDecimal(0)) <= 0)
                    return mianDanMoney != null;
                hongBaoV2Mapper.insertSelective(firstHongbao);
                // 用户通知
                if (notificationMap.get(HongBaoV2.TYPE_YIJI) == null) {
                    HongBaoV2 tempHongBao = new HongBaoV2(firstHongbao.getId());
                    tempHongBao.setUserInfo(firstHongbao.getUserInfo());
                    tempHongBao.setMoney(firstHongbao.getMoney());
                    CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                    tempCommonOrder.setPayment(commonOrder.getPayment());
                    notificationMap.put(HongBaoV2.TYPE_YIJI, new HongBaoOrder(tempCommonOrder, tempHongBao));
                } else {
                    // 增加付款金额与资金
                    HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_YIJI);
                    tempHongBaoOrder.getCommonOrder()
                            .setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                    tempHongBaoOrder.getHongBaoV2()
                            .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(firstHongbao.getMoney()));
                    notificationMap.put(HongBaoV2.TYPE_YIJI, tempHongBaoOrder);
                }
                hongBaoV2Mapper.insertSelective(firstHongbao);
                // 用户通知
                if (notificationMap.get(HongBaoV2.TYPE_YIJI) == null) {
                    HongBaoV2 tempHongBao = new HongBaoV2(firstHongbao.getId());
                    tempHongBao.setUserInfo(firstHongbao.getUserInfo());
                    tempHongBao.setMoney(firstHongbao.getMoney());
                    CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                    tempCommonOrder.setPayment(commonOrder.getPayment());
                    notificationMap.put(HongBaoV2.TYPE_YIJI, new HongBaoOrder(tempCommonOrder, tempHongBao));
                } else {
                    // 增加付款金额与资金
                    HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_YIJI);
                    tempHongBaoOrder.getCommonOrder()
                            .setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                    tempHongBaoOrder.getHongBaoV2()
                            .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(firstHongbao.getMoney()));
                    notificationMap.put(HongBaoV2.TYPE_YIJI, tempHongBaoOrder);
                }
                // 插入二级子红包
                boss = threeSaleSerivce.getBoss(boss.getId());
                if (boss != null) {// 二级BOSS存在
                    BigDecimal secondRate = hongBaoManageService
                            .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank(),system);
                    if (secondRate.compareTo(new BigDecimal(0)) <= 0)
                        return mianDanMoney != null;
                    HongBaoV2 secondHongbao = new HongBaoV2();
                    secondHongbao.setUserInfo(boss);
                    secondHongbao.setUrank(boss.getRank());
                    secondHongbao.setParent(hongBao);
                    secondHongbao.setCreateTime(new Date());
                    secondHongbao.setType(HongBaoV2.TYPE_ERJI);
                    secondHongbao.setVersion(2);
                    secondHongbao.setState(hongBao.getState());
                    secondHongbao.setOrderType(commonOrder.getSourceType());
                    if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
                        secondHongbao.setMoney(
                                MoneyBigDecimalUtil.mul(hongBao.getMoney(), secondRate.divide(new BigDecimal(100))));
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(commonOrder.getSettleTime());
                        calendar.add(Calendar.MONTH, 1);
                        secondHongbao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                                calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                                "yyyy-M-dd")));
                    } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
                        secondHongbao.setMoney(
                                MoneyBigDecimalUtil.mul(hongBao.getMoney(), secondRate.divide(new BigDecimal(100))));
                    }
                // 插入二级子红包
                boss = threeSaleSerivce.getBoss(boss.getId());
                if (boss != null) {// 二级BOSS存在
                    BigDecimal secondRate = hongBaoManageService
                            .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank());
                    if (secondRate.compareTo(new BigDecimal(0)) <= 0)
                        return mianDanMoney != null;
                    HongBaoV2 secondHongbao = new HongBaoV2();
                    secondHongbao.setUserInfo(boss);
                    secondHongbao.setUrank(boss.getRank());
                    secondHongbao.setParent(hongBao);
                    secondHongbao.setCreateTime(new Date());
                    secondHongbao.setType(HongBaoV2.TYPE_ERJI);
                    secondHongbao.setVersion(2);
                    secondHongbao.setState(hongBao.getState());
                    secondHongbao.setOrderType(commonOrder.getSourceType());
                    if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
                        secondHongbao.setMoney(
                                MoneyBigDecimalUtil.mul(hongBao.getMoney(), secondRate.divide(new BigDecimal(100))));
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(commonOrder.getSettleTime());
                        calendar.add(Calendar.MONTH, 1);
                        secondHongbao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                                calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                                "yyyy-M-dd")));
                    } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
                        secondHongbao.setMoney(
                                MoneyBigDecimalUtil.mul(hongBao.getMoney(), secondRate.divide(new BigDecimal(100))));
                    }
                    // 返利为0的不统计
                    if (secondHongbao.getMoney() == null || secondHongbao.getMoney().compareTo(new BigDecimal(0)) <= 0)
                        return mianDanMoney != null;
                    // 返利为0的不统计
                    if (secondHongbao.getMoney() == null || secondHongbao.getMoney().compareTo(new BigDecimal(0)) <= 0)
                        return mianDanMoney != null;
                    hongBaoV2Mapper.insertSelective(secondHongbao);
                    hongBaoV2Mapper.insertSelective(secondHongbao);
                    // 用户通知
                    if (notificationMap.get(HongBaoV2.TYPE_ERJI) == null) {
                        HongBaoV2 tempHongBao = new HongBaoV2(secondHongbao.getId());
                        tempHongBao.setUserInfo(secondHongbao.getUserInfo());
                        tempHongBao.setMoney(secondHongbao.getMoney());
                        CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                        tempCommonOrder.setPayment(commonOrder.getPayment());
                        notificationMap.put(HongBaoV2.TYPE_ERJI, new HongBaoOrder(tempCommonOrder, tempHongBao));
                    } else {
                        // 增加付款金额与资金
                        HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_ERJI);
                        tempHongBaoOrder.getCommonOrder().setPayment(
                                tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                        tempHongBaoOrder.getHongBaoV2()
                                .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(secondHongbao.getMoney()));
                        notificationMap.put(HongBaoV2.TYPE_ERJI, tempHongBaoOrder);
                    }
                }
                    // 用户通知
                    if (notificationMap.get(HongBaoV2.TYPE_ERJI) == null) {
                        HongBaoV2 tempHongBao = new HongBaoV2(secondHongbao.getId());
                        tempHongBao.setUserInfo(secondHongbao.getUserInfo());
                        tempHongBao.setMoney(secondHongbao.getMoney());
                        CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                        tempCommonOrder.setPayment(commonOrder.getPayment());
                        notificationMap.put(HongBaoV2.TYPE_ERJI, new HongBaoOrder(tempCommonOrder, tempHongBao));
                    } else {
                        // 增加付款金额与资金
                        HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_ERJI);
                        tempHongBaoOrder.getCommonOrder().setPayment(
                                tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                        tempHongBaoOrder.getHongBaoV2()
                                .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(secondHongbao.getMoney()));
                        notificationMap.put(HongBaoV2.TYPE_ERJI, tempHongBaoOrder);
                    }
                }
            }
            return mianDanMoney != null;
        } else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
            // 分享赚不加入失效的订单
            if (commonOrder.getState() == CommonOrder.STATE_SX || commonOrder.getState() == CommonOrder.STATE_WQ)
                return false;
            // 分享赚
            BigDecimal shareRate = null;
            if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_TAOBAO
                    && commonOrder.getSourcePosition().equalsIgnoreCase(TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT))// 来自于淘礼金的分享
                shareRate = hongBaoManageService.getTLJShareRate(commonOrder.getCreateTime().getTime(),system);
            else
                shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
                        commonOrder.getCreateTime().getTime(),system);
            }
            return mianDanMoney != null;
        } else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
            // 分享赚不加入失效的订单
            if (commonOrder.getState() == CommonOrder.STATE_SX || commonOrder.getState() == CommonOrder.STATE_WQ)
                return false;
            // 分享赚
            BigDecimal shareRate = null;
            if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_TAOBAO
                    && commonOrder.getSourcePosition().equalsIgnoreCase(TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT))// 来自于淘礼金的分享
                shareRate = hongBaoManageService.getTLJShareRate(commonOrder.getCreateTime().getTime());
            else
                shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
                        commonOrder.getCreateTime().getTime());
            UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
            UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
            // 判断订单分享活动是否开启
            if ("1".equalsIgnoreCase(configService.getValue(ConfigKeyEnum.shareGoodsActivityOpen.getKey(), user.getSystem()))) {
                // 没有订单,并且是渠道ID来的,并且
                UserExtraTaoBaoInfo taoBaoExtraInfo = userExtraTaoBaoInfoService
                        .getByUid(commonOrder.getUserInfo().getId());
                if (taoBaoExtraInfo != null && ((!StringUtil.isNullOrEmpty(taoBaoExtraInfo.getTaoBaoOrderEnd6Num())
                        && !commonOrder.getOrderNo().endsWith(taoBaoExtraInfo.getTaoBaoOrderEnd6Num().trim()))
                        || StringUtil.isNullOrEmpty(taoBaoExtraInfo.getTaoBaoOrderEnd6Num()))) {
                    List<TaoBaoOrder> taoBaoOrderList = taoBaoOrderMapper
                            .selectTaoBaoOrderByOrderId(commonOrder.getOrderNo());
                    if (taoBaoOrderList != null && taoBaoOrderList.size() > 0
                            && !StringUtil.isNullOrEmpty(taoBaoOrderList.get(0).getRelationId())) {
                        if (shareGoodsActivityOrderService.listByUid(commonOrder.getUserInfo().getId()).size() < 1) {
                            shareRate = new BigDecimal(hongBaoManageService.get("share_activity_proportion",system));
                            try {
                                shareGoodsActivityOrderService.addShareGoodsActivityOrder(
                                        commonOrder.getUserInfo().getId(), shareRate, commonOrder.getOrderNo());
                            } catch (ShareGoodsActivityOrderException e) {
                                try {
                                    LogHelper.errorDetailInfo(e);
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            }
                        }
                    }
                }
            }
            // 判断订单分享活动是否开启
            if ("1".equalsIgnoreCase(configService.getValue(ConfigKeyEnum.shareGoodsActivityOpen.getKey(),user.getSystem()))) {
                // 没有订单,并且是渠道ID来的,并且
                UserExtraTaoBaoInfo taoBaoExtraInfo = userExtraTaoBaoInfoService
                        .getByUid(commonOrder.getUserInfo().getId());
                if (taoBaoExtraInfo != null && ((!StringUtil.isNullOrEmpty(taoBaoExtraInfo.getTaoBaoOrderEnd6Num())
                        && !commonOrder.getOrderNo().endsWith(taoBaoExtraInfo.getTaoBaoOrderEnd6Num().trim()))
                        || StringUtil.isNullOrEmpty(taoBaoExtraInfo.getTaoBaoOrderEnd6Num()))) {
                    List<TaoBaoOrder> taoBaoOrderList = taoBaoOrderMapper
                            .selectTaoBaoOrderByOrderId(commonOrder.getOrderNo());
                    if (taoBaoOrderList != null && taoBaoOrderList.size() > 0
                            && !StringUtil.isNullOrEmpty(taoBaoOrderList.get(0).getRelationId())) {
                        if (shareGoodsActivityOrderService.listByUid(commonOrder.getUserInfo().getId()).size() < 1) {
                            shareRate = new BigDecimal(hongBaoManageService.get("share_activity_proportion"));
                            try {
                                shareGoodsActivityOrderService.addShareGoodsActivityOrder(
                                        commonOrder.getUserInfo().getId(), shareRate, commonOrder.getOrderNo());
                            } catch (ShareGoodsActivityOrderException e) {
                                try {
                                    LogHelper.errorDetailInfo(e);
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            }
                        }
                    }
                }
            }
            HongBaoV2 hongBao = new HongBaoV2();
            hongBao.setCreateTime(new Date());
            hongBao.setType(HongBaoV2.TYPE_SHARE_GOODS);
            hongBao.setVersion(2);
            if (commonOrder.getState() == CommonOrder.STATE_FK) {
                hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), shareRate.divide(new BigDecimal(100))));
            } else if (commonOrder.getState() == CommonOrder.STATE_JS
                    || commonOrder.getState() == CommonOrder.STATE_WQ) {
                hongBao.setState(HongBaoV2.STATE_KELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), shareRate.divide(new BigDecimal(100))));
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(commonOrder.getSettleTime());
                calendar.add(Calendar.MONTH, 1);
                hongBao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                        calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd")));
            }
            HongBaoV2 hongBao = new HongBaoV2();
            hongBao.setCreateTime(new Date());
            hongBao.setType(HongBaoV2.TYPE_SHARE_GOODS);
            hongBao.setVersion(2);
            if (commonOrder.getState() == CommonOrder.STATE_FK) {
                hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), shareRate.divide(new BigDecimal(100))));
            } else if (commonOrder.getState() == CommonOrder.STATE_JS
                    || commonOrder.getState() == CommonOrder.STATE_WQ) {
                hongBao.setState(HongBaoV2.STATE_KELINGQU);
                hongBao.setMoney(
                        MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), shareRate.divide(new BigDecimal(100))));
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(commonOrder.getSettleTime());
                calendar.add(Calendar.MONTH, 1);
                hongBao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                        calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd")));
            }
            if (user == null)
                throw new UserAccountException(1001, "用户不存在/被封禁");
            hongBao.setUrank(user.getRank());
            hongBao.setUserInfo(user);
            hongBao.setOrderType(commonOrder.getSourceType());
            hongBaoV2Mapper.insertSelective(hongBao);
            // 插入红包与订单映射
            HongBaoOrder hongBaoOrder = new HongBaoOrder();
            hongBaoOrder.setCommonOrder(commonOrder);
            hongBaoOrder.setCreateTime(new Date());
            hongBaoOrder.setHongBaoV2(hongBao);
            hongBaoOrderMapper.insertSelective(hongBaoOrder);
            if (user == null)
                throw new UserAccountException(1001, "用户不存在/被封禁");
            hongBao.setUrank(user.getRank());
            hongBao.setUserInfo(user);
            hongBao.setOrderType(commonOrder.getSourceType());
            hongBaoV2Mapper.insertSelective(hongBao);
            // 插入红包与订单映射
            HongBaoOrder hongBaoOrder = new HongBaoOrder();
            hongBaoOrder.setCommonOrder(commonOrder);
            hongBaoOrder.setCreateTime(new Date());
            hongBaoOrder.setHongBaoV2(hongBao);
            hongBaoOrderMapper.insertSelective(hongBaoOrder);
            if (notificationMap.get(type) == null) {
                HongBaoV2 tempHongBao = new HongBaoV2(hongBao.getId());
                tempHongBao.setUserInfo(hongBao.getUserInfo());
                tempHongBao.setMoney(hongBao.getMoney());
                CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                tempCommonOrder.setPayment(commonOrder.getPayment());
                notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
            } else {
                // 增加付款金额与资金
                HongBaoOrder tempHongBaoOrder = notificationMap.get(type);
                tempHongBaoOrder.getCommonOrder()
                        .setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                tempHongBaoOrder.getHongBaoV2()
                        .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(hongBao.getMoney()));
                notificationMap.put(type, tempHongBaoOrder);
            }
            if (notificationMap.get(type) == null) {
                HongBaoV2 tempHongBao = new HongBaoV2(hongBao.getId());
                tempHongBao.setUserInfo(hongBao.getUserInfo());
                tempHongBao.setMoney(hongBao.getMoney());
                CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                tempCommonOrder.setPayment(commonOrder.getPayment());
                notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
            } else {
                // 增加付款金额与资金
                HongBaoOrder tempHongBaoOrder = notificationMap.get(type);
                tempHongBaoOrder.getCommonOrder()
                        .setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                tempHongBaoOrder.getHongBaoV2()
                        .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(hongBao.getMoney()));
                notificationMap.put(type, tempHongBaoOrder);
            }
            // 4月17日后才有一级分享赚
            if (commonOrder.getThirdCreateTime().getTime() > TimeUtil.convertToTimeTemp("2019-04-17", "yyyy-MM-dd")) {
                UserInfo boss = threeSaleSerivce.getBoss(hongBao.getUserInfo().getId());
                if (boss != null) {
                    BigDecimal firstLevelRate = hongBaoManageService.getFirstShareRate(1,
                            commonOrder.getThirdCreateTime().getTime(),system);
                    HongBaoV2 child = new HongBaoV2();
                    child.setParent(hongBao);
                    child.setType(HongBaoV2.TYPE_SHARE_YIJI);
                    if (commonOrder.getState() == CommonOrder.STATE_FK) {
                        child.setState(HongBaoV2.STATE_BUKELINGQU);
                        child.setMoney(MoneyBigDecimalUtil.mul(commonOrder.getEstimate(),
                                firstLevelRate.divide(new BigDecimal(100))));
                    } else if (commonOrder.getState() == CommonOrder.STATE_JS
                            || commonOrder.getState() == CommonOrder.STATE_WQ) {
                        child.setState(HongBaoV2.STATE_KELINGQU);
                        child.setMoney(MoneyBigDecimalUtil.mul(commonOrder.geteIncome(),
                                firstLevelRate.divide(new BigDecimal(100))));
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(commonOrder.getSettleTime());
                        calendar.add(Calendar.MONTH, 1);
                        child.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                                calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                                "yyyy-M-dd")));
                    }
                    child.setUserInfo(boss);
                    child.setUrank(boss.getRank());
                    child.setVersion(2);
                    child.setCreateTime(new Date());
                    child.setOrderType(commonOrder.getSourceType());
                    if (child.getMoney() != null && child.getMoney().compareTo(new BigDecimal(0)) > 0) {
                        hongBaoV2Mapper.insertSelective(child);
                        // 添加通知
                        if (notificationMap.get(HongBaoV2.TYPE_SHARE_YIJI) == null) {
                            HongBaoV2 tempHongBao = new HongBaoV2(child.getId());
                            tempHongBao.setUserInfo(child.getUserInfo());
                            tempHongBao.setMoney(child.getMoney());
                            tempHongBao.setBeizhu(hongBao.getUserInfo().getNickName());
                            CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                            tempCommonOrder.setPayment(commonOrder.getPayment());
                            notificationMap.put(HongBaoV2.TYPE_SHARE_YIJI,
                                    new HongBaoOrder(tempCommonOrder, tempHongBao));
                        } else {
                            // 增加付款金额与资金
                            HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_SHARE_YIJI);
                            tempHongBaoOrder.getCommonOrder().setPayment(
                                    tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                            tempHongBaoOrder.getHongBaoV2()
                                    .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(child.getMoney()));
                            notificationMap.put(HongBaoV2.TYPE_SHARE_YIJI, tempHongBaoOrder);
                        }
                    }
                }
            }
            // 4月17日后才有一级分享赚
            if (commonOrder.getThirdCreateTime().getTime() > TimeUtil.convertToTimeTemp("2019-04-17", "yyyy-MM-dd")) {
                UserInfo boss = threeSaleSerivce.getBoss(hongBao.getUserInfo().getId());
                if (boss != null) {
                    BigDecimal firstLevelRate = hongBaoManageService.getFirstShareRate(1,
                            commonOrder.getThirdCreateTime().getTime());
                    HongBaoV2 child = new HongBaoV2();
                    child.setParent(hongBao);
                    child.setType(HongBaoV2.TYPE_SHARE_YIJI);
                    if (commonOrder.getState() == CommonOrder.STATE_FK) {
                        child.setState(HongBaoV2.STATE_BUKELINGQU);
                        child.setMoney(MoneyBigDecimalUtil.mul(commonOrder.getEstimate(),
                                firstLevelRate.divide(new BigDecimal(100))));
                    } else if (commonOrder.getState() == CommonOrder.STATE_JS
                            || commonOrder.getState() == CommonOrder.STATE_WQ) {
                        child.setState(HongBaoV2.STATE_KELINGQU);
                        child.setMoney(MoneyBigDecimalUtil.mul(commonOrder.geteIncome(),
                                firstLevelRate.divide(new BigDecimal(100))));
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(commonOrder.getSettleTime());
                        calendar.add(Calendar.MONTH, 1);
                        child.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
                                calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
                                "yyyy-M-dd")));
                    }
                    child.setUserInfo(boss);
                    child.setUrank(boss.getRank());
                    child.setVersion(2);
                    child.setCreateTime(new Date());
                    child.setOrderType(commonOrder.getSourceType());
                    if (child.getMoney() != null && child.getMoney().compareTo(new BigDecimal(0)) > 0) {
                        hongBaoV2Mapper.insertSelective(child);
                        // 添加通知
                        if (notificationMap.get(HongBaoV2.TYPE_SHARE_YIJI) == null) {
                            HongBaoV2 tempHongBao = new HongBaoV2(child.getId());
                            tempHongBao.setUserInfo(child.getUserInfo());
                            tempHongBao.setMoney(child.getMoney());
                            tempHongBao.setBeizhu(hongBao.getUserInfo().getNickName());
                            CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                            tempCommonOrder.setPayment(commonOrder.getPayment());
                            notificationMap.put(HongBaoV2.TYPE_SHARE_YIJI,
                                    new HongBaoOrder(tempCommonOrder, tempHongBao));
                        } else {
                            // 增加付款金额与资金
                            HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_SHARE_YIJI);
                            tempHongBaoOrder.getCommonOrder().setPayment(
                                    tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                            tempHongBaoOrder.getHongBaoV2()
                                    .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(child.getMoney()));
                            notificationMap.put(HongBaoV2.TYPE_SHARE_YIJI, tempHongBaoOrder);
                        }
                    }
                }
            }
            // 修改统计数据
            Long goodsId = commonOrder.getCommonOrderGoods().getId();
            // 查询商品
            CommonOrderGoods goods = commonOrderGoodsMapper.selectByPrimaryKey(goodsId);
            // 修改统计数据
            Long goodsId = commonOrder.getCommonOrderGoods().getId();
            // 查询商品
            CommonOrderGoods goods = commonOrderGoodsMapper.selectByPrimaryKey(goodsId);
            HongBao hb = new HongBao();
            if (goods != null)
                hb.setAuctionId(Long.parseLong(goods.getGoodsId()));
            hb.setUserInfo(hongBao.getUserInfo());
            hb.setMoney(hongBao.getMoney());
            HongBao hb = new HongBao();
            if (goods != null)
                hb.setAuctionId(Long.parseLong(goods.getGoodsId()));
            hb.setUserInfo(hongBao.getUserInfo());
            hb.setMoney(hongBao.getMoney());
            try {
                userShareGoodsGroupService.updateOrderRecord(hb, commonOrder.getSourceType());
            } catch (UserShareGoodsRecordException e) {
                try {
                    LogHelper.errorDetailInfo(e);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        } else
            throw new HongBaoException(2, "type错误");
            try {
                userShareGoodsGroupService.updateOrderRecord(hb, commonOrder.getSourceType());
            } catch (UserShareGoodsRecordException e) {
                try {
                    LogHelper.errorDetailInfo(e);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        } else
            throw new HongBaoException(2, "type错误");
        return false;
    }
        return false;
    }
    @Override
    public List<HongBaoDTO> listJiangJinByUid(Long uid, int page, int pageSize) {
        return hongBaoV2Mapper.listJiangJinByUid(uid, (page - 1) * pageSize, pageSize);
    }
    @Override
    public List<HongBaoDTO> listJiangJinByUid(Long uid, int page, int pageSize) {
        return hongBaoV2Mapper.listJiangJinByUid(uid, (page - 1) * pageSize, pageSize);
    }
    @Override
    public long countJiangJinByUid(Long uid) {
        Long count = hongBaoV2Mapper.countJiangJinByUid(uid);
        return count == null ? 0 : count;
    }
    @Override
    public long countJiangJinByUid(Long uid) {
        Long count = hongBaoV2Mapper.countJiangJinByUid(uid);
        return count == null ? 0 : count;
    }
    @Override
    public BigDecimal getTotalTiChengMoney(Long uid) {
    @Override
    public BigDecimal getTotalTiChengMoney(Long uid) {
        return hongBaoV2Mapper.getTotalTiChengMoney(uid);
    }
        return hongBaoV2Mapper.getTotalTiChengMoney(uid);
    }
    @Override
    public int getTotalTiChengCount(Long uid) {
        return hongBaoV2Mapper.getTotalTiChengCount(uid);
    }
    @Override
    public int getTotalTiChengCount(Long uid) {
        return hongBaoV2Mapper.getTotalTiChengCount(uid);
    }
    @Override
    public BigDecimal getUnGetTiChengMoney(Long uid) {
        return hongBaoV2Mapper.getUnGetTiChengMoney(uid);
    }
    @Override
    public BigDecimal getUnGetTiChengMoney(Long uid) {
        return hongBaoV2Mapper.getUnGetTiChengMoney(uid);
    }
    @Override
    public BigDecimal getTotalFanLiMoney(Long uid) {
        BigDecimal money = hongBaoV2Mapper.getTotalFanLiMoney(uid);
        return money == null ? new BigDecimal(0) : money;
    }
    @Override
    public BigDecimal getTotalFanLiMoney(Long uid) {
        BigDecimal money = hongBaoV2Mapper.getTotalFanLiMoney(uid);
        return money == null ? new BigDecimal(0) : money;
    }
    @Override
    public BigDecimal getUnRecievedFanLiMoney(Long uid) {
        BigDecimal money = hongBaoV2Mapper.getUnRecievedFanLiMoney(uid);
        return money == null ? new BigDecimal(0) : money;
    }
    @Override
    public BigDecimal getUnRecievedFanLiMoney(Long uid) {
        BigDecimal money = hongBaoV2Mapper.getUnRecievedFanLiMoney(uid);
        return money == null ? new BigDecimal(0) : money;
    }
    @Override
    public BigDecimal getUnRecievedMoneyWithCreateTime(Long uid, Date minDate, Date maxDate) {
        BigDecimal money = hongBaoV2Mapper.getUnRecievedMoneyWithCreateTime(uid, minDate, maxDate);
        if (money == null)
            return new BigDecimal(0);
        else
            return money;
    }
    @Override
    public BigDecimal getUnRecievedMoneyWithCreateTime(Long uid, Date minDate, Date maxDate) {
        BigDecimal money = hongBaoV2Mapper.getUnRecievedMoneyWithCreateTime(uid, minDate, maxDate);
        if (money == null)
            return new BigDecimal(0);
        else
            return money;
    }
    @Override
    public BigDecimal getUnRecievedMoneyWithPreGetTime(Long uid, Date minDate, Date maxDate) {
        BigDecimal money = hongBaoV2Mapper.getUnRecievedMoneyWithPreGetTime(uid, minDate, maxDate);
        if (money == null)
            return new BigDecimal(0);
        else
            return money;
    }
    @Override
    public BigDecimal getUnRecievedMoneyWithPreGetTime(Long uid, Date minDate, Date maxDate) {
        BigDecimal money = hongBaoV2Mapper.getUnRecievedMoneyWithPreGetTime(uid, minDate, maxDate);
        if (money == null)
            return new BigDecimal(0);
        else
            return money;
    }
    @Override
    public BigDecimal computeMoneyByUidAndState(Long uid, int state) {
        List<Integer> stateList = new ArrayList<>();
        stateList.add(state);
        BigDecimal money = hongBaoV2Mapper.computeMoneyByUidAndState(uid, stateList);
        if (money == null)
            return new BigDecimal(0);
        else
            return money;
    }
    @Override
    public BigDecimal computeMoneyByUidAndState(Long uid, int state) {
        List<Integer> stateList = new ArrayList<>();
        stateList.add(state);
        BigDecimal money = hongBaoV2Mapper.computeMoneyByUidAndState(uid, stateList);
        if (money == null)
            return new BigDecimal(0);
        else
            return money;
    }
    @Override
    public List<HongBaoV2> listChildrenById(Long id) {
        return hongBaoV2Mapper.listChildrenById(id);
    }
    @Override
    public List<HongBaoV2> listChildrenById(Long id) {
        return hongBaoV2Mapper.listChildrenById(id);
    }
    @Override
    public List<HongBaoV2> listChildrenByIds(List<Long> idList) {
        if (idList == null || idList.size() == 0)
            return null;
        return hongBaoV2Mapper.listChildrenByIds(idList);
    }
    @Override
    public List<HongBaoV2> listChildrenByIds(List<Long> idList) {
        if (idList == null || idList.size() == 0)
            return null;
        return hongBaoV2Mapper.listChildrenByIds(idList);
    }
    @Override
    public List<Long> getUidByNear30DayShareSucceed() {
        return hongBaoV2Mapper.getUidByNear30DayShareSucceed();
    }
    @Override
    public List<Long> getUidByNear30DayShareSucceed() {
        return hongBaoV2Mapper.getUidByNear30DayShareSucceed();
    }
    @Override
    public void invalidInviteHongBaoByParentUid(Long parentUid, String beiZhu) {
        List<Integer> typeList = new ArrayList<>();
        typeList.add(HongBaoV2.TYPE_YIJI);
        typeList.add(HongBaoV2.TYPE_ERJI);
        typeList.add(HongBaoV2.TYPE_SHARE_YIJI);
        typeList.add(HongBaoV2.TYPE_SHARE_ERJI);
        List<Integer> stateList = new ArrayList<>();
        stateList.add(HongBaoV2.STATE_KELINGQU);
        stateList.add(HongBaoV2.STATE_BUKELINGQU);
        long count = hongBaoV2Mapper.countByParentUidAndTypeAndState(parentUid, typeList, stateList);
        int page = (int) (count % 100 == 0 ? count / 100 : count / 100 + 1);
        for (int i = 1; i <= page; i++) {
            List<HongBaoV2> list = hongBaoV2Mapper.listByParentUidAndTypeAndState(parentUid, typeList, stateList, 0,
                    100);
            if (list != null)
                for (HongBaoV2 v2 : list) {
                    HongBaoV2 update = new HongBaoV2(v2.getId());
                    update.setUpdateTime(new Date());
                    update.setState(HongBaoV2.STATE_SHIXIAO);
                    update.setBeizhu(beiZhu);
                    hongBaoV2Mapper.updateByPrimaryKeySelective(update);
                }
        }
    }
    @Override
    public void invalidInviteHongBaoByParentUid(Long parentUid, String beiZhu) {
        List<Integer> typeList = new ArrayList<>();
        typeList.add(HongBaoV2.TYPE_YIJI);
        typeList.add(HongBaoV2.TYPE_ERJI);
        typeList.add(HongBaoV2.TYPE_SHARE_YIJI);
        typeList.add(HongBaoV2.TYPE_SHARE_ERJI);
        List<Integer> stateList = new ArrayList<>();
        stateList.add(HongBaoV2.STATE_KELINGQU);
        stateList.add(HongBaoV2.STATE_BUKELINGQU);
        long count = hongBaoV2Mapper.countByParentUidAndTypeAndState(parentUid, typeList, stateList);
        int page = (int) (count % 100 == 0 ? count / 100 : count / 100 + 1);
        for (int i = 1; i <= page; i++) {
            List<HongBaoV2> list = hongBaoV2Mapper.listByParentUidAndTypeAndState(parentUid, typeList, stateList, 0,
                    100);
            if (list != null)
                for (HongBaoV2 v2 : list) {
                    HongBaoV2 update = new HongBaoV2(v2.getId());
                    update.setUpdateTime(new Date());
                    update.setState(HongBaoV2.STATE_SHIXIAO);
                    update.setBeizhu(beiZhu);
                    hongBaoV2Mapper.updateByPrimaryKeySelective(update);
                }
        }
    }
    @Override
    public List<HongBaoV2> listBySourceTypeAndTradeIdListAndUid(int sourceType, long uid, List<String> tradeIdList) {
        if (tradeIdList == null || tradeIdList.size() == 0)
            return null;
        return hongBaoV2Mapper.listBySourceTypeAndTradeIdListAndUid(sourceType, uid, tradeIdList);
    }
    @Override
    public List<HongBaoV2> listBySourceTypeAndTradeIdListAndUid(int sourceType, long uid, List<String> tradeIdList) {
        if (tradeIdList == null || tradeIdList.size() == 0)
            return null;
        return hongBaoV2Mapper.listBySourceTypeAndTradeIdListAndUid(sourceType, uid, tradeIdList);
    }
    @Override
    public HongBaoV2 getFirstValidHongBaoByTypeAndUid(List<Integer> typeList, Long uid) {
        List<Integer> stateList = new ArrayList<>();
        stateList.add(HongBaoV2.STATE_BUKELINGQU);
        stateList.add(HongBaoV2.STATE_KELINGQU);
        stateList.add(HongBaoV2.STATE_YILINGQU);
        List<HongBaoV2> hongBaoV2List = hongBaoV2Mapper.listByStateAndTypeAndUid(stateList, typeList, uid, 0, 1);
        if (hongBaoV2List != null && hongBaoV2List.size() > 0)
            return hongBaoV2List.get(0);
        return null;
    }
    @Override
    public HongBaoV2 getFirstValidHongBaoByTypeAndUid(List<Integer> typeList, Long uid) {
        List<Integer> stateList = new ArrayList<>();
        stateList.add(HongBaoV2.STATE_BUKELINGQU);
        stateList.add(HongBaoV2.STATE_KELINGQU);
        stateList.add(HongBaoV2.STATE_YILINGQU);
        List<HongBaoV2> hongBaoV2List = hongBaoV2Mapper.listByStateAndTypeAndUid(stateList, typeList, uid, 0, 1);
        if (hongBaoV2List != null && hongBaoV2List.size() > 0)
            return hongBaoV2List.get(0);
        return null;
    }
    @Override
    public List<HongBaoV2> listByIds(List<Long> idList) {
        return hongBaoV2Mapper.listByIds(idList);
    }
    @Override
    public List<HongBaoV2> listByIds(List<Long> idList) {
        return hongBaoV2Mapper.listByIds(idList);
    }
    @Override
    public List<HongBaoDTO> listByOrderTradeId(String tradeId) {
        return hongBaoV2Mapper.listByOrderTradeId(tradeId);
    }
    @Override
    public List<HongBaoDTO> listByOrderTradeId(String tradeId) {
        return hongBaoV2Mapper.listByOrderTradeId(tradeId);
    }
    @Override
    public Integer getDirectBossUrankByPid(Long pid) {
        return hongBaoV2Mapper.getDirectBossUrankByPid(pid);
    }
    @Override
    public Integer getDirectBossUrankByPid(Long pid) {
        return hongBaoV2Mapper.getDirectBossUrankByPid(pid);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/order/LostOrderServiceImpl.java
@@ -326,13 +326,13 @@
     */
    @Override
    public List<LostOrder> listQuery(long start, int count, String key, Integer state, Integer handleType,
                                     Integer type) {
        return lostOrderMapper.listQuery(start, count, key, state, handleType, type);
                                     Integer type, SystemEnum system) {
        return lostOrderMapper.listQuery(start, count, key, state, handleType, type,system);
    }
    @Override
    public long countQuery(String key, Integer state, Integer handleType, Integer type) {
        return lostOrderMapper.countQuery(key, state, handleType, type);
    public long countQuery(String key, Integer state, Integer handleType, Integer type, SystemEnum system) {
        return lostOrderMapper.countQuery(key, state, handleType, type,system);
    }
    @Override
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderHongBaoMoneyComputeServiceImpl.java
@@ -7,6 +7,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.ConfigParamsDTO;
@@ -25,383 +27,391 @@
@Service
public class OrderHongBaoMoneyComputeServiceImpl implements OrderHongBaoMoneyComputeService {
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Override
    public BigDecimal computeBaseFanliMoney(CommonOrder order) {
        return getBaseCommission(order);
    }
    @Resource
    private UserInfoService userInfoService;
    @Override
    public BigDecimal computeBaseShareMoney(CommonOrder order) {
        return getBaseCommission(order);
    }
    @Override
    public BigDecimal computeBaseFanliMoney(CommonOrder order) {
        SystemEnum system = userInfoService.getUserSystem(order.getUserInfo().getId());
        return getBaseCommission(order,system);
    }
    private UserLevelEnum getCommonUserLevel(Date time, UserLevelEnum userLevel) {
        if (userLevel == null)
            return UserLevelEnum.daRen;
        if (time.getTime() < Constant.NEW_ORDER_FANLI_RULE_TIME)
            return UserLevelUtil.getOldLevel(userLevel);
        else
            return userLevel;
    }
    @Override
    public BigDecimal computeBaseShareMoney(CommonOrder order) {
        SystemEnum system = userInfoService.getUserSystem(order.getUserInfo().getId());
        return getBaseCommission(order,system);
    }
    // 获取基础佣金
    private BigDecimal getBaseCommission(CommonOrder order) {
        BigDecimal rate = hongBaoManageService.getBaseFanliRate(order.getThirdCreateTime().getTime());
        if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
            return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
        else if (order.getEstimate() != null)
            return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
        else
            return null;
    }
    private UserLevelEnum getCommonUserLevel(Date time, UserLevelEnum userLevel) {
        if (userLevel == null)
            return UserLevelEnum.daRen;
        if (time.getTime() < Constant.NEW_ORDER_FANLI_RULE_TIME)
            return UserLevelUtil.getOldLevel(userLevel);
        else
            return userLevel;
    }
    @Override
    public BigDecimal computeFanliMoney(CommonOrder order, UserLevelEnum userLevel) {
    // 获取基础佣金
    private BigDecimal getBaseCommission(CommonOrder order, SystemEnum system) {
        BigDecimal rate = hongBaoManageService.getBaseFanliRate(order.getThirdCreateTime().getTime(), system);
        if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
            return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
        else if (order.getEstimate() != null)
            return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
        else
            return null;
    }
        BigDecimal rate = hongBaoManageService.getBaseFanliRate(order.getThirdCreateTime().getTime())
                .add(getOfficialSubsidyRate(order.getThirdCreateTime(),
                        getCommonUserLevel(order.getThirdCreateTime(), userLevel), false));
        if (userLevel == UserLevelEnum.normalVIP) {
            rate = new BigDecimal("61");
        }
    @Override
    public BigDecimal computeFanliMoney(CommonOrder order, UserLevelEnum userLevel) {
        SystemEnum system = userInfoService.getUserSystem(order.getUserInfo().getId());
        BigDecimal rate = hongBaoManageService.getBaseFanliRate(order.getThirdCreateTime().getTime(),system)
                .add(getOfficialSubsidyRate(order.getThirdCreateTime(),
                        getCommonUserLevel(order.getThirdCreateTime(), userLevel), false,system));
        if (userLevel == UserLevelEnum.normalVIP) {
            rate = new BigDecimal("61");
        }
        if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
            return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
        else if (order.getEstimate() != null)
            return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
        else
            return null;
    }
        if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
            return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
        else if (order.getEstimate() != null)
            return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
        else
            return null;
    }
    @Override
    public BigDecimal computeShareMoney(CommonOrder order, UserLevelEnum userLevel) {
        BigDecimal rate = hongBaoManageService.getBaseFanliRate(order.getThirdCreateTime().getTime())
                .add(getOfficialSubsidyRate(order.getThirdCreateTime(),
                        getCommonUserLevel(order.getThirdCreateTime(), userLevel), true));
    @Override
    public BigDecimal computeShareMoney(CommonOrder order, UserLevelEnum userLevel) {
        SystemEnum system = userInfoService.getUserSystem(order.getUserInfo().getId());
        BigDecimal rate = hongBaoManageService.getBaseFanliRate(order.getThirdCreateTime().getTime(),system)
                .add(getOfficialSubsidyRate(order.getThirdCreateTime(),
                        getCommonUserLevel(order.getThirdCreateTime(), userLevel), true,system));
        if (userLevel == UserLevelEnum.normalVIP) {
            rate = new BigDecimal("61");
        }
        if (userLevel == UserLevelEnum.normalVIP) {
            rate = new BigDecimal("61");
        }
        if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
            return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
        else if (order.getEstimate() != null)
            return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
        else
            return null;
    }
        if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
            return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
        else if (order.getEstimate() != null)
            return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
        else
            return null;
    }
    @Override
    public BigDecimal computeFirstInviteMoney(CommonOrder order, UserLevelEnum buyer,
            List<UserTeamLevel> bossLevelList) {
        BigDecimal rate = null;
        if (order.getThirdCreateTime().getTime() >= Constant.NEW_ORDER_FANLI_RULE_TIME) {
            rate = getTeamRewardRate(buyer, bossLevelList, order.getThirdCreateTime(), 1).getRate();
            if (rate == null)
                return null;
            if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
            else if (order.getEstimate() != null)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
        } else {// 老的返利比例
            rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_6", order.getThirdCreateTime().getTime());
            if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order)),
                        new BigDecimal(100));
            else if (order.getEstimate() != null)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order)),
                        new BigDecimal(100));
        }
    @Override
    public BigDecimal computeFirstInviteMoney(CommonOrder order, UserLevelEnum buyer,
                                              List<UserTeamLevel> bossLevelList) {
        SystemEnum system = userInfoService.getUserSystem(order.getUserInfo().getId());
        BigDecimal rate = null;
        if (order.getThirdCreateTime().getTime() >= Constant.NEW_ORDER_FANLI_RULE_TIME) {
            rate = getTeamRewardRate(buyer, bossLevelList, order.getThirdCreateTime(), 1,system).getRate();
            if (rate == null)
                return null;
            if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
            else if (order.getEstimate() != null)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
        } else {// 老的返利比例
            rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_6", order.getThirdCreateTime().getTime(),system);
            if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order,system)),
                        new BigDecimal(100));
            else if (order.getEstimate() != null)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order,system)),
                        new BigDecimal(100));
        }
        return null;
    }
        return null;
    }
    @Override
    public BigDecimal computeSecondInviteMoney(CommonOrder order, UserLevelEnum buyer,
            List<UserTeamLevel> bossLevelList) {
        BigDecimal rate = null;
        if (order.getThirdCreateTime().getTime() >= Constant.NEW_ORDER_FANLI_RULE_TIME) {
            rate = getTeamRewardRate(buyer, bossLevelList, order.getThirdCreateTime(), 2).getRate();
            if (rate == null)
                return null;
            if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
            else if (order.getEstimate() != null)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
        } else {// 老的返利比例
            rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_7", order.getThirdCreateTime().getTime());
            if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order)),
                        new BigDecimal(100));
            else if (order.getEstimate() != null)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order)),
                        new BigDecimal(100));
        }
    @Override
    public BigDecimal computeSecondInviteMoney(CommonOrder order, UserLevelEnum buyer,
                                               List<UserTeamLevel> bossLevelList) {
        SystemEnum system = userInfoService.getUserSystem(order.getUserInfo().getId());
        BigDecimal rate = null;
        if (order.getThirdCreateTime().getTime() >= Constant.NEW_ORDER_FANLI_RULE_TIME) {
            rate = getTeamRewardRate(buyer, bossLevelList, order.getThirdCreateTime(), 2,system).getRate();
            if (rate == null)
                return null;
            if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
            else if (order.getEstimate() != null)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
        } else {// 老的返利比例
            rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_7", order.getThirdCreateTime().getTime(),system);
            if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order,system)),
                        new BigDecimal(100));
            else if (order.getEstimate() != null)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order,system)),
                        new BigDecimal(100));
        }
        return null;
    }
        return null;
    }
    /**
     * 获取官方补贴比例
     * @Title: getOfficialSubsidyRate
     * @Description:
     * @param date
     * @param userLevel
     * @param share
     * @return
     * BigDecimal 返回类型
     * @throws
     */
    private BigDecimal getOfficialSubsidyRate(Date date, UserLevelEnum userLevel, boolean share) {
        String key = null;
        if (share)
            key = String.format("official_subsidy_share_%s", userLevel.getLevel());
        else
            key = String.format("official_subsidy_zigou_%s", userLevel.getLevel());
        BigDecimal rate = null;
        if (date != null)
            rate = hongBaoManageService.getByKeyAndMaxTimeCache(key, TimeUtil
                    .convertToTimeTemp(TimeUtil.getGernalTime(date.getTime(), "yyyy-MM-dd HH"), "yyyy-MM-dd HH"));
        else
            rate = new BigDecimal(hongBaoManageService.get(key));
        return rate;
    }
    /**
     * 获取官方补贴比例
     *
     * @param date
     * @param userLevel
     * @param share
     * @return BigDecimal 返回类型
     * @throws
     * @Title: getOfficialSubsidyRate
     * @Description:
     */
    private BigDecimal getOfficialSubsidyRate(Date date, UserLevelEnum userLevel, boolean share,SystemEnum system) {
        String key = null;
        if (share)
            key = String.format("official_subsidy_share_%s", userLevel.getLevel());
        else
            key = String.format("official_subsidy_zigou_%s", userLevel.getLevel());
        BigDecimal rate = null;
        if (date != null)
            rate = hongBaoManageService.getByKeyAndMaxTimeCache(key, TimeUtil
                    .convertToTimeTemp(TimeUtil.getGernalTime(date.getTime(), "yyyy-MM-dd HH"), "yyyy-MM-dd HH"),system);
        else
            rate = new BigDecimal(hongBaoManageService.get(key,system));
        return rate;
    }
    private BigDecimal getRateByLevel(UserLevelEnum level, Date date) {
        BigDecimal baseRate = hongBaoManageService.getBaseFanliRateCache(
                TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(date.getTime(), "yyyy-MM-dd HH"), "yyyy-MM-dd HH"));
    private BigDecimal getRateByLevel(UserLevelEnum level, Date date,SystemEnum system) {
        BigDecimal baseRate = hongBaoManageService.getBaseFanliRateCache(
                TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(date.getTime(), "yyyy-MM-dd HH"), "yyyy-MM-dd HH"),system);
        BigDecimal subsidyRate = getOfficialSubsidyRate(date, level, false);
        BigDecimal subsidyRate = getOfficialSubsidyRate(date, level, false,system);
        return baseRate.add(subsidyRate);
    }
        return baseRate.add(subsidyRate);
    }
    @Override
    public UserTeamRate getTeamRewardRate(UserLevelEnum buyerLevel, List<UserTeamLevel> bossLevelList, Date date,
            int deep) {
        if (deep == 1) {// 直接邀请人奖金
            UserTeamLevel boss = bossLevelList.get(0);
            BigDecimal rate = null;
            if (bossLevelList == null || bossLevelList.size() < 1)
                return null;
    @Override
    public UserTeamRate getTeamRewardRate(UserLevelEnum buyerLevel, List<UserTeamLevel> bossLevelList, Date date,
                                          int deep,SystemEnum system) {
        if (deep == 1) {// 直接邀请人奖金
            UserTeamLevel boss = bossLevelList.get(0);
            BigDecimal rate = null;
            if (bossLevelList == null || bossLevelList.size() < 1)
                return null;
            if (buyerLevel == UserLevelEnum.daRen && boss.getLevel() == UserLevelEnum.daRen) {
                rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_6", date.getTime());
            } else if (buyerLevel == UserLevelEnum.normalVIP && boss.getLevel() == UserLevelEnum.normalVIP) {
                rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_6", date.getTime());
            } else {
                BigDecimal bossRate = getRateByLevel(boss.getLevel(), date);
                BigDecimal buyerRate = getRateByLevel(buyerLevel, date);
                rate = bossRate.subtract(buyerRate);
                if (rate.compareTo(new BigDecimal(0)) < 0)
                    rate = new BigDecimal(0);
            }
            if (buyerLevel == UserLevelEnum.daRen && boss.getLevel() == UserLevelEnum.daRen) {
                rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_6", date.getTime(),system);
            } else if (buyerLevel == UserLevelEnum.normalVIP && boss.getLevel() == UserLevelEnum.normalVIP) {
                rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_6", date.getTime(),system);
            } else {
                BigDecimal bossRate = getRateByLevel(boss.getLevel(), date,system);
                BigDecimal buyerRate = getRateByLevel(buyerLevel, date,system);
                rate = bossRate.subtract(buyerRate);
                if (rate.compareTo(new BigDecimal(0)) < 0)
                    rate = new BigDecimal(0);
            }
            return new UserTeamRate(boss.getUid(), boss.getLevel(), rate);
            return new UserTeamRate(boss.getUid(), boss.getLevel(), rate);
        } else if (deep == 2) {// 间接邀请人奖金
            if (bossLevelList == null || bossLevelList.size() < 2)
                return null;
        } else if (deep == 2) {// 间接邀请人奖金
            if (bossLevelList == null || bossLevelList.size() < 2)
                return null;
            BigDecimal buyerRate = getRateByLevel(buyerLevel, date);
            BigDecimal firstRate = getTeamRewardRate(buyerLevel, bossLevelList, date, 1).getRate();
            BigDecimal buyerRate = getRateByLevel(buyerLevel, date,system);
            BigDecimal firstRate = getTeamRewardRate(buyerLevel, bossLevelList, date, 1,system).getRate();
            UserTeamLevel boss = bossLevelList.get(1);
            UserTeamLevel firstBoss = bossLevelList.get(0);
            BigDecimal rate = null;
            if (buyerLevel == UserLevelEnum.daRen && firstBoss.getLevel() == UserLevelEnum.daRen) {
                if (boss.getLevel() == UserLevelEnum.daRen)
                    rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_7", date.getTime());
                else {
                    rate = null;
                }
            } else if (buyerLevel == UserLevelEnum.normalVIP && firstBoss.getLevel() == UserLevelEnum.normalVIP) {
                if (boss.getLevel() == UserLevelEnum.normalVIP)
                    rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_7", date.getTime());
                else {
                    rate = null;
                }
            } else if (buyerLevel == UserLevelEnum.daRen && firstBoss.getLevel() == UserLevelEnum.normalVIP) {
                if (boss.getLevel() == UserLevelEnum.normalVIP)
                    rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_7", date.getTime());
                else {
                    rate = null;
                }
            }
            // 极差计算法
            if (rate == null) {
                rate = getRateByLevel(boss.getLevel(), date).subtract(buyerRate).subtract(firstRate);
                if (rate.compareTo(new BigDecimal(0)) < 0)
                    rate = new BigDecimal(0);
            }
            UserTeamLevel boss = bossLevelList.get(1);
            UserTeamLevel firstBoss = bossLevelList.get(0);
            BigDecimal rate = null;
            if (buyerLevel == UserLevelEnum.daRen && firstBoss.getLevel() == UserLevelEnum.daRen) {
                if (boss.getLevel() == UserLevelEnum.daRen)
                    rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_7", date.getTime(),system);
                else {
                    rate = null;
                }
            } else if (buyerLevel == UserLevelEnum.normalVIP && firstBoss.getLevel() == UserLevelEnum.normalVIP) {
                if (boss.getLevel() == UserLevelEnum.normalVIP)
                    rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_7", date.getTime(),system);
                else {
                    rate = null;
                }
            } else if (buyerLevel == UserLevelEnum.daRen && firstBoss.getLevel() == UserLevelEnum.normalVIP) {
                if (boss.getLevel() == UserLevelEnum.normalVIP)
                    rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_7", date.getTime(),system);
                else {
                    rate = null;
                }
            }
            // 极差计算法
            if (rate == null) {
                rate = getRateByLevel(boss.getLevel(), date,system).subtract(buyerRate).subtract(firstRate);
                if (rate.compareTo(new BigDecimal(0)) < 0)
                    rate = new BigDecimal(0);
            }
            return new UserTeamRate(boss.getUid(), boss.getLevel(), rate);
        } else
            return null;
    }
            return new UserTeamRate(boss.getUid(), boss.getLevel(), rate);
        } else
            return null;
    }
    @Override
    public List<UserTeamRate> getTeamRewardMoreThan2LevelRates(UserLevelEnum buyerLevel,
            List<UserTeamLevel> bossLevelList, Date date) {
        if (bossLevelList == null || bossLevelList.size() < 3)
            return null;
    @Override
    public List<UserTeamRate> getTeamRewardMoreThan2LevelRates(UserLevelEnum buyerLevel,
                                                               List<UserTeamLevel> bossLevelList, Date date,SystemEnum system) {
        if (bossLevelList == null || bossLevelList.size() < 3)
            return null;
        UserTeamRate firstBoss = getTeamRewardRate(buyerLevel, bossLevelList, date, 1);
        if (firstBoss == null)
            return null;
        UserTeamRate secondBoss = getTeamRewardRate(buyerLevel, bossLevelList, date, 2);
        if (secondBoss == null)
            return null;
        UserTeamRate firstBoss = getTeamRewardRate(buyerLevel, bossLevelList, date, 1,system);
        if (firstBoss == null)
            return null;
        UserTeamRate secondBoss = getTeamRewardRate(buyerLevel, bossLevelList, date, 2,system);
        if (secondBoss == null)
            return null;
        BigDecimal buyerRate = getRateByLevel(buyerLevel, date);
        BigDecimal buyerRate = getRateByLevel(buyerLevel, date,system);
        BigDecimal totalRate = firstBoss.getRate().add(secondBoss.getRate()).add(buyerRate);
        BigDecimal totalRate = firstBoss.getRate().add(secondBoss.getRate()).add(buyerRate);
        List<UserTeamRate> rateList = new ArrayList<>();
        List<UserTeamRate> rateList = new ArrayList<>();
        for (int i = 2; i < bossLevelList.size(); i++) {
            BigDecimal rate = getRateByLevel(bossLevelList.get(i).getLevel(), date);
            if (rate.compareTo(totalRate) > 0) {
                BigDecimal subRate = rate.subtract(totalRate);
                totalRate = subRate.add(totalRate);// 累计分成比例
                rateList.add(new UserTeamRate(bossLevelList.get(i).getUid(), bossLevelList.get(i).getLevel(), subRate));
            }
        }
        for (int i = 2; i < bossLevelList.size(); i++) {
            BigDecimal rate = getRateByLevel(bossLevelList.get(i).getLevel(), date,system);
            if (rate.compareTo(totalRate) > 0) {
                BigDecimal subRate = rate.subtract(totalRate);
                totalRate = subRate.add(totalRate);// 累计分成比例
                rateList.add(new UserTeamRate(bossLevelList.get(i).getUid(), bossLevelList.get(i).getLevel(), subRate));
            }
        }
        return rateList;
    }
        return rateList;
    }
    // 团队分红
    @Override
    public List<UserTeamRate> getTeamDividentsRates(UserLevelEnum buyerLevel, List<UserTeamLevel> bossLevelList,
            Date date) {
        List<UserTeamRate> rateList = new ArrayList<>();
    // 团队分红
    @Override
    public List<UserTeamRate> getTeamDividentsRates(UserLevelEnum buyerLevel, List<UserTeamLevel> bossLevelList,
                                                    Date date,SystemEnum system) {
        List<UserTeamRate> rateList = new ArrayList<>();
        List<UserTeamLevel> levelList = new ArrayList<>();
        levelList.add(new UserTeamLevel(null, buyerLevel));
        levelList.addAll(bossLevelList);
        UserLevelEnum maxLevel = buyerLevel;
        List<UserTeamLevel> levelList = new ArrayList<>();
        levelList.add(new UserTeamLevel(null, buyerLevel));
        levelList.addAll(bossLevelList);
        UserLevelEnum maxLevel = buyerLevel;
        List<UserTeamLevel> vipList = new ArrayList<>();
        List<UserTeamLevel> highList = new ArrayList<>();
        List<UserTeamLevel> vipList = new ArrayList<>();
        List<UserTeamLevel> highList = new ArrayList<>();
        for (int i = 1; i < levelList.size(); i++) {
            if (maxLevel.getLevel() <= levelList.get(i).getLevel().getLevel()) {
                maxLevel = levelList.get(i).getLevel();
                if (levelList.get(i).getLevel() == UserLevelEnum.highVIP)
                    highList.add(levelList.get(i));
                else if (levelList.get(i).getLevel() == UserLevelEnum.superVIP) {
                    vipList.add(levelList.get(i));
                }
            }
        }
        for (int i = 1; i < levelList.size(); i++) {
            if (maxLevel.getLevel() <= levelList.get(i).getLevel().getLevel()) {
                maxLevel = levelList.get(i).getLevel();
                if (levelList.get(i).getLevel() == UserLevelEnum.highVIP)
                    highList.add(levelList.get(i));
                else if (levelList.get(i).getLevel() == UserLevelEnum.superVIP) {
                    vipList.add(levelList.get(i));
                }
            }
        }
        if (vipList.size() >= 4) {// 最多分4级
            vipList = vipList.subList(0, 4);
        }
        if (vipList.size() >= 4) {// 最多分4级
            vipList = vipList.subList(0, 4);
        }
        if (highList.size() >= 4) {// 最多分4级
            highList = highList.subList(0, 4);
        }
        if (highList.size() >= 4) {// 最多分4级
            highList = highList.subList(0, 4);
        }
        BigDecimal highTotalRate = hongBaoManageService.getByKeyAndMaxTime("dividents_rate_same_level_high",
                date.getTime());
        BigDecimal vipTotalRate = hongBaoManageService.getByKeyAndMaxTime("dividents_rate_same_level_super",
                date.getTime());
        BigDecimal highTotalRate = hongBaoManageService.getByKeyAndMaxTime("dividents_rate_same_level_high",
                date.getTime(),system);
        BigDecimal vipTotalRate = hongBaoManageService.getByKeyAndMaxTime("dividents_rate_same_level_super",
                date.getTime(),system);
        if (vipList.size() > 0 && highList.size() > 0) {
        if (vipList.size() > 0 && highList.size() > 0) {
        } else if (vipList.size() == 0) {
            highTotalRate = highTotalRate.add(vipTotalRate);
        } else {
            vipTotalRate = highTotalRate.add(vipTotalRate);
        }
        } else if (vipList.size() == 0) {
            highTotalRate = highTotalRate.add(vipTotalRate);
        } else {
            vipTotalRate = highTotalRate.add(vipTotalRate);
        }
        // 高级会员分红
        if (highList.size() > 0) {
            int count = 0;
            for (int i = 0; i < highList.size(); i++) {
                count += (4 - i);
            }
        // 高级会员分红
        if (highList.size() > 0) {
            int count = 0;
            for (int i = 0; i < highList.size(); i++) {
                count += (4 - i);
            }
            BigDecimal per = MoneyBigDecimalUtil.div(highTotalRate, new BigDecimal(count), 4);
            for (int i = 0; i < highList.size(); i++) {
                BigDecimal rate = MoneyBigDecimalUtil.mul(per, new BigDecimal(4 - i), 4);
                rateList.add(new UserTeamRate(highList.get(i), rate));
            }
        }
            BigDecimal per = MoneyBigDecimalUtil.div(highTotalRate, new BigDecimal(count), 4);
            for (int i = 0; i < highList.size(); i++) {
                BigDecimal rate = MoneyBigDecimalUtil.mul(per, new BigDecimal(4 - i), 4);
                rateList.add(new UserTeamRate(highList.get(i), rate));
            }
        }
        // 超级会员分红
        if (vipList.size() > 0) {
            int count = 0;
            for (int i = 0; i < vipList.size(); i++) {
                count += (4 - i);
            }
        // 超级会员分红
        if (vipList.size() > 0) {
            int count = 0;
            for (int i = 0; i < vipList.size(); i++) {
                count += (4 - i);
            }
            BigDecimal per = MoneyBigDecimalUtil.div(vipTotalRate, new BigDecimal(count), 4);
            BigDecimal per = MoneyBigDecimalUtil.div(vipTotalRate, new BigDecimal(count), 4);
            for (int i = 0; i < vipList.size(); i++) {
                BigDecimal rate = MoneyBigDecimalUtil.mul(per, new BigDecimal(4 - i), 4);
                rateList.add(new UserTeamRate(vipList.get(i), rate));
            }
            for (int i = 0; i < vipList.size(); i++) {
                BigDecimal rate = MoneyBigDecimalUtil.mul(per, new BigDecimal(4 - i), 4);
                rateList.add(new UserTeamRate(vipList.get(i), rate));
            }
        }
        }
        // 导师分红
        for (UserTeamLevel level : bossLevelList) {
            if (level.getLevel() == UserLevelEnum.tearcher) {
                rateList.add(new UserTeamRate(level,
                        hongBaoManageService.getByKeyAndMaxTime("dividents_rate_tearcher", date.getTime())));
                break;
            }
        }
        // 导师分红
        for (UserTeamLevel level : bossLevelList) {
            if (level.getLevel() == UserLevelEnum.tearcher) {
                rateList.add(new UserTeamRate(level,
                        hongBaoManageService.getByKeyAndMaxTime("dividents_rate_tearcher", date.getTime(),system)));
                break;
            }
        }
        return rateList;
    }
        return rateList;
    }
    @Override
    public UserTeamRate getTearcherSubsidy(UserLevelEnum buyerLevel, BigDecimal money,
            List<UserTeamLevel> bossLevelList, Date date) {
        // TODO Auto-generated method stub
        return null;
    }
    @Override
    public UserTeamRate getTearcherSubsidy(UserLevelEnum buyerLevel, BigDecimal money,
                                           List<UserTeamLevel> bossLevelList, Date date,SystemEnum system) {
        // TODO Auto-generated method stub
        return null;
    }
    private BigDecimal getFanliRate(Date time, UserLevelEnum userLevel) {
        BigDecimal rate = hongBaoManageService
                .getBaseFanliRateCache(TimeUtil
                        .convertToTimeTemp(TimeUtil.getGernalTime(time.getTime(), "yyyy-MM-dd HH"), "yyyy-MM-dd HH"))
                .add(getOfficialSubsidyRate(time, getCommonUserLevel(time, userLevel), false));
    private BigDecimal getFanliRate(Date time, UserLevelEnum userLevel,SystemEnum system) {
        BigDecimal rate = hongBaoManageService
                .getBaseFanliRateCache(TimeUtil
                        .convertToTimeTemp(TimeUtil.getGernalTime(time.getTime(), "yyyy-MM-dd HH"), "yyyy-MM-dd HH"),system)
                .add(getOfficialSubsidyRate(time, getCommonUserLevel(time, userLevel), false,system));
        if (userLevel == UserLevelEnum.normalVIP)
            rate = new BigDecimal("61");
        return rate;
    }
        if (userLevel == UserLevelEnum.normalVIP)
            rate = new BigDecimal("61");
        return rate;
    }
    @Override
    public ConfigParamsDTO getShowComputeRate(String platform, String version, UserLevelEnum userLevel) {
        BigDecimal fanLiRate = getFanliRate(new Date(), userLevel);
        BigDecimal shareRate = fanLiRate;
        ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,
                getFanliRate(new Date(), UserLevelEnum.superVIP));
        if (VersionUtil.greaterThan_2_0_5(platform, version)) {
            paramsDTO.setMaxRewardRate(null);
        }
        return paramsDTO;
    }
    @Override
    public ConfigParamsDTO getShowComputeRate(String platform, String version, UserLevelEnum userLevel,SystemEnum system) {
        BigDecimal fanLiRate = getFanliRate(new Date(), userLevel,system);
        BigDecimal shareRate = fanLiRate;
        ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,
                getFanliRate(new Date(), UserLevelEnum.superVIP,system));
        if (VersionUtil.greaterThan_2_0_5(platform, version)) {
            paramsDTO.setMaxRewardRate(null);
        }
        return paramsDTO;
    }
    @Override
    public ConfigParamsDTO getShowComputeRate(String platform, String version) {
        return getShowComputeRate(platform, version, UserLevelEnum.daRen);
    }
    @Override
    public ConfigParamsDTO getShowComputeRate(String platform, String version,SystemEnum system) {
        return getShowComputeRate(platform, version, UserLevelEnum.daRen,system);
    }
    @Override
    public BigDecimal getFanliRate(UserLevelEnum userLevel, Date date) {
        BigDecimal rate = hongBaoManageService.getBaseFanliRate(date.getTime())
                .add(getOfficialSubsidyRate(date, getCommonUserLevel(date, userLevel), false));
        return rate;
    }
    @Override
    public BigDecimal getFanliRate(UserLevelEnum userLevel, Date date,SystemEnum system) {
        BigDecimal rate = hongBaoManageService.getBaseFanliRate(date.getTime(),system)
                .add(getOfficialSubsidyRate(date, getCommonUserLevel(date, userLevel), false,system));
        return rate;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
@@ -294,7 +294,7 @@
        elmeOrder.setTrackPid(
                String.format("mm_124933865_%s_%s", taoBaoOrder.getSourceMediaId(), taoBaoOrder.getAdPositionId()));
        if (!StringUtil.isNullOrEmpty(taoBaoOrder.getRelationId())) {
            UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByRelationId(taoBaoOrder.getRelationId());
            UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByRelationId(taoBaoOrder.getRelationId(),null);
            if (extraInfo != null)
                elmeOrder.setUid(extraInfo.getUser().getId());
        }
@@ -754,13 +754,13 @@
                        || pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_KOUBEI_PID))
                        && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {// 处理饿了么,口碑的订单
                    UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService
                            .getByRelationId(orderList.get(0).getRelationId());
                            .getByRelationId(orderList.get(0).getRelationId(),null);
                    if (extraInfo != null) {
                        targetUid = extraInfo.getUser().getId();
                    }
                } else if (!StringUtil.isNullOrEmpty(orderList.get(0).getSpecialId())) {
                    UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService
                            .getBySpecialId(orderList.get(0).getSpecialId());
                            .getBySpecialId(orderList.get(0).getSpecialId(),null);
                    if (info != null && info.getUser() != null)
                        targetUid = info.getUser().getId();
                }
@@ -846,7 +846,7 @@
        if (orderList != null && orderList.size() > 0) {
            // 原来不存在订单
            Long uid = null;
            UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByRelationId(orderList.get(0).getRelationId());
            UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByRelationId(orderList.get(0).getRelationId(),null);
            if (info != null && info.getUser() != null)
                uid = info.getUser().getId();
            // 尚未找到和PID对应的用户
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderRepairServiceImpl.java
@@ -13,6 +13,8 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.omg.CORBA.COMM_FAILURE;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
@@ -131,9 +133,6 @@
    private OrderRepairHistoryService orderRepairHistoryService;
    @Resource
    private DataSourceTransactionManager dataSourceTransactionManager;
    @Resource
    private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService;
    @Resource
@@ -191,7 +190,6 @@
    }
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    private void processLessFanOrder(String orderId) throws Exception {
        List<CommonOrder> commonOrderList = commonOrderMapper.listBySourceTypeAndOrderNo(Constant.SOURCE_TYPE_TAOBAO,
@@ -392,10 +390,12 @@
    }
    // 修改订单信息
    @Transactional(rollbackFor = Exception.class)
    private void updateOrderInfo(TaoBaoOrder taoBaoOrder, Long commonOrderId) throws Exception {
        HongBaoOrder hongBaoOrder = hongBaoOrderService.selectDetailByCommonOrderId(commonOrderId);
        CommonOrder newCommonOrder = CommonOrderFactory.create(taoBaoOrder);
        SystemEnum system=userInfoService.getUserSystem(newCommonOrder.getUserInfo().getId());
        List<CommonOrderGoods> commonGoodsList = commonOrderGoodsMapper
                .listByGoodsIdAndGoodsType(taoBaoOrder.getAuctionId() + "", newCommonOrder.getSourceType());
        CommonOrderGoods cog = null;
@@ -434,7 +434,7 @@
        if (hongBaoOrder.getHongBaoV2().getType() == HongBaoV2.TYPE_ZIGOU) {
            BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
                    commonOrder.getCreateTime().getTime());
                    commonOrder.getCreateTime().getTime(),system);
            // 免单处理
            boolean mianDan = false;
            List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO,
@@ -492,10 +492,10 @@
                    BigDecimal rate = null;
                    if (child.getType() == HongBaoV2.TYPE_YIJI) {// 一级分享赚
                        rate = hongBaoManageService.getFirstInviteRate(child.getUrank(),
                                commonOrder.getCreateTime().getTime());
                                commonOrder.getCreateTime().getTime(),system);
                    } else if (child.getType() == HongBaoV2.TYPE_ERJI) {// 二级分享赚
                        rate = hongBaoManageService.getSecondInviteRate(child.getUrank(),
                                commonOrder.getCreateTime().getTime());
                                commonOrder.getCreateTime().getTime(),system);
                    }
                    // 以实际收入为准计算预估收益
@@ -523,7 +523,7 @@
        } else if (hongBaoOrder.getHongBaoV2().getType() == HongBaoV2.TYPE_SHARE_GOODS) {
            BigDecimal fanliRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
                    commonOrder.getCreateTime().getTime());
                    commonOrder.getCreateTime().getTime(),system);
            List<ShareGoodsActivityOrder> list = shareGoodsActivityOrderService
                    .listByOrderIdAndUid(commonOrder.getUserInfo().getId(), commonOrder.getOrderNo());
            if (list != null && list.size() > 0) {
@@ -564,9 +564,9 @@
                    childUpdate.setUpdateTime(new Date());
                    BigDecimal rate = null;
                    if (child.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 一级分享赚
                        rate = hongBaoManageService.getFirstShareRate(1, commonOrder.getCreateTime().getTime());
                        rate = hongBaoManageService.getFirstShareRate(1, commonOrder.getCreateTime().getTime(),system);
                    } else if (child.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 二级分享赚
                        rate = hongBaoManageService.getSecondShareRate(1, commonOrder.getCreateTime().getTime());
                        rate = hongBaoManageService.getSecondShareRate(1, commonOrder.getCreateTime().getTime(),system);
                    }
                    // 以实际收入为准计算预估收益
@@ -624,6 +624,8 @@
            commonOrder.setCommonOrderGoods(goods);
        }
        SystemEnum system=userInfoService.getUserSystem(commonOrder.getUserInfo().getId());
        CommonOrder oldCommonOrder = commonOrderMapper.selectBySourceTypeAndTradeId(commonOrder.getSourceType(),
                commonOrder.getTradeId());
        if (oldCommonOrder == null)// 新增
@@ -642,7 +644,7 @@
        // 添加红包
        if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
            BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
                    commonOrder.getCreateTime().getTime());
                    commonOrder.getCreateTime().getTime(),system);
            // 查询是否有免单计划
            BigDecimal mianDanMoney = null;
            if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK) {
@@ -724,7 +726,7 @@
                // 插入一级子红包
                BigDecimal firstRate = hongBaoManageService
                        .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank());
                        .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank(),system);
                if (firstRate.compareTo(new BigDecimal(0)) <= 0)
                    return;
                HongBaoV2 firstHongbao = new HongBaoV2();
@@ -771,7 +773,7 @@
                if (boss != null) {// 二级BOSS存在
                    BigDecimal secondRate = hongBaoManageService
                            .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank());
                            .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank(),system);
                    if (secondRate.compareTo(new BigDecimal(0)) <= 0)
                        return;
                    HongBaoV2 secondHongbao = new HongBaoV2();
@@ -819,7 +821,7 @@
                return;
            // 分享赚
            BigDecimal shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
                    commonOrder.getCreateTime().getTime());
                    commonOrder.getCreateTime().getTime(),system);
            HongBaoV2 hongBao = new HongBaoV2();
            hongBao.setBeizhu("2019年7月批量修改");
@@ -862,7 +864,7 @@
                    boss = userInfoService.selectByPKey(firstUid);
                if (boss != null) {
                    BigDecimal firstLevelRate = hongBaoManageService.getFirstShareRate(1,
                            commonOrder.getThirdCreateTime().getTime());
                            commonOrder.getThirdCreateTime().getTime(),system);
                    HongBaoV2 child = new HongBaoV2();
                    child.setBeizhu("2019年7月批量修改");
                    child.setParent(hongBao);
@@ -903,7 +905,6 @@
    }
    @Transactional(propagation = Propagation.REQUIRED)
    private void deleteByCommonOrderId(Long commonOrderId) {
        commonOrderMapper.deleteByPrimaryKey(commonOrderId);
        HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrderId);
@@ -992,7 +993,10 @@
                    return;
            }
            for (CommonOrder commonOrder : list) {
                SystemEnum system=userInfoService.getUserSystem(commonOrder.getUserInfo().getId());
                HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
                if (hongBaoOrder == null)
                    continue;
@@ -1007,7 +1011,7 @@
                if (boss != null && hongBao.getState() != HongBaoV2.STATE_SHIXIAO) {// 1级BOSS存在且红包未失效,免单不支持多级分销
                    // 插入一级子红包
                    BigDecimal firstRate = hongBaoManageService
                            .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank());
                            .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank(),system);
                    if (firstRate.compareTo(new BigDecimal(0)) <= 0)
                        return;
                    HongBaoV2 firstHongbao = new HongBaoV2();
@@ -1052,7 +1056,7 @@
                    if (boss != null) {// 二级BOSS存在
                        BigDecimal secondRate = hongBaoManageService
                                .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank());
                                .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank(),system);
                        if (secondRate.compareTo(new BigDecimal(0)) <= 0)
                            return;
                        HongBaoV2 secondHongbao = new HongBaoV2();
@@ -1161,6 +1165,8 @@
                if (hongBaoOrder == null)
                    continue;
                SystemEnum system=userInfoService.getUserSystem(commonOrder.getUserInfo().getId());
                HongBaoV2 hongBao = hongBaoOrder.getHongBaoV2();
                // 4月17日后才有一级分享赚
                if (commonOrder.getThirdCreateTime().getTime() > TimeUtil.convertToTimeTemp("2019-04-17",
@@ -1170,7 +1176,7 @@
                        boss = userInfoService.selectByPKey(firstUid);
                    if (boss != null) {
                        BigDecimal firstLevelRate = hongBaoManageService.getFirstShareRate(1,
                                commonOrder.getThirdCreateTime().getTime());
                                commonOrder.getThirdCreateTime().getTime(),system);
                        HongBaoV2 child = new HongBaoV2();
                        child.setBeizhu("2019年7月批量修改");
                        child.setParent(hongBao);
fanli/src/main/java/com/yeshi/fanli/service/impl/order/config/HongBaoManageServiceImpl.java
@@ -7,6 +7,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;
@@ -23,264 +24,264 @@
@Service
public class HongBaoManageServiceImpl implements HongBaoManageService {
    @Resource
    private HongBaoManageMapper hongBaoManageMapper;
    @Resource
    private HongBaoManageMapper hongBaoManageMapper;
    @Transactional
    public void update(List<HongBaoManage> hongBaoManageList) {
        for (HongBaoManage hongBaoManage : hongBaoManageList) {
            hongBaoManageMapper.updateByPrimaryKeySelective(hongBaoManage);
        }
    }
    @Transactional
    public void update(List<HongBaoManage> hongBaoManageList) {
        for (HongBaoManage hongBaoManage : hongBaoManageList) {
            hongBaoManageMapper.updateByPrimaryKeySelective(hongBaoManage);
        }
    }
    @Cacheable(value = "homeBaoManage", key = "#p0")
    public String get(final String key) {
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return hongBaoManage.getValue();
        return null;
    }
    @Cacheable(value = "homeBaoManage", key = "'get-'+#key+'-'+#system")
    public String get(final String key, SystemEnum system) {
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKey(key, system);
        if (hongBaoManage != null)
            return hongBaoManage.getValue();
        return null;
    }
    /**
     * 根据键值与时间查询比例
     *
     * @param key
     * @param time
     * @return
     */
    public BigDecimal getByKeyAndMaxTime(String key, Long time) {
        if (time == null)
            time = System.currentTimeMillis();
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        return null;
    }
    /**
     * 根据键值与时间查询比例
     *
     * @param key
     * @param time
     * @return
     */
    public BigDecimal getByKeyAndMaxTime(String key, Long time, SystemEnum system) {
        if (time == null)
            time = System.currentTimeMillis();
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time, system);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key, system);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        return null;
    }
    @Cacheable(value = "homeBaoManage", key = "'getByKeyAndMaxTime-'+#key+'-'+#time")
    public BigDecimal getByKeyAndMaxTimeCache(String key, Long time) {
        return getByKeyAndMaxTime(key, time);
    }
    @Cacheable(value = "homeBaoManage", key = "'getByKeyAndMaxTime-'+#key+'-'+#time+'-'+#system")
    public BigDecimal getByKeyAndMaxTimeCache(String key, Long time, SystemEnum system) {
        return getByKeyAndMaxTime(key, time, system);
    }
    @Cacheable(value = "homeBaoManage", key = "'convertMap'")
    public Map<String, String> convertMap() {
        List<HongBaoManage> list = hongBaoManageMapper.listAll();
        Map<String, String> map = new HashMap<String, String>();
        for (HongBaoManage hongBaoManage : list) {
            map.put(hongBaoManage.getKey(), hongBaoManage.getValue());
        }
        return map;
    }
    @Cacheable(value = "homeBaoManage", key = "'convertMap-'+#system")
    public Map<String, String> convertMap(SystemEnum system) {
        List<HongBaoManage> list = hongBaoManageMapper.listAll(system);
        Map<String, String> map = new HashMap<String, String>();
        for (HongBaoManage hongBaoManage : list) {
            map.put(hongBaoManage.getKey(), hongBaoManage.getValue());
        }
        return map;
    }
    @Override
    public BigDecimal getFanLiRate(UserLevelEnum level, long time) {
    @Override
    public BigDecimal getFanLiRate(UserLevelEnum level, long time, SystemEnum system) {
        return getBaseFanliRate(time).add(new BigDecimal(get("official_subsidy_zigou_" + level.getLevel())));
    }
        return getBaseFanliRate(time,system).add(new BigDecimal(get("official_subsidy_zigou_" + level.getLevel(),system)));
    }
    @Override
    public BigDecimal getShareRate(UserLevelEnum level, long time) {
        return getBaseFanliRate(time).add(new BigDecimal(get("official_subsidy_share_" + level.getLevel())));
    }
    @Override
    public BigDecimal getShareRate(UserLevelEnum level, long time, SystemEnum system) {
        return getBaseFanliRate(time,system).add(new BigDecimal(get("official_subsidy_share_" + level.getLevel(),system)));
    }
    @Override
    public BigDecimal getFanLiRate(UserLevelEnum level) {
        return getFanLiRate(level, System.currentTimeMillis());
    }
    @Override
    public BigDecimal getFanLiRate(UserLevelEnum level, SystemEnum system) {
        return getFanLiRate(level, System.currentTimeMillis(),system);
    }
    @Override
    public BigDecimal getFanLiRate() {
        return getFanLiRate(UserLevelEnum.daRen);
    }
    @Override
    public BigDecimal getFanLiRate(SystemEnum system) {
        return getFanLiRate(UserLevelEnum.daRen,system);
    }
    @Override
    public BigDecimal getShareRate(UserLevelEnum level) {
        return getShareRate(level, System.currentTimeMillis());
    }
    @Override
    public BigDecimal getShareRate(UserLevelEnum level, SystemEnum system) {
        return getShareRate(level, System.currentTimeMillis(),system);
    }
    @Override
    public BigDecimal getShareRate() {
        return getShareRate(UserLevelEnum.daRen);
    }
    @Override
    public BigDecimal getShareRate( SystemEnum system) {
        return getShareRate(UserLevelEnum.daRen,system);
    }
    @Override
    public BigDecimal getFirstInviteRate(int urank) {
        return getFirstInviteRate(urank, System.currentTimeMillis());
    }
    @Override
    public BigDecimal getFirstInviteRate(int urank, SystemEnum system) {
        return getFirstInviteRate(urank, System.currentTimeMillis(),system);
    }
    @Override
    public BigDecimal getFirstInviteRate(int urank, long time) {
        String key = "sale_6_" + urank;
    @Override
    public BigDecimal getFirstInviteRate(int urank, long time, SystemEnum system) {
        String key = "sale_6_" + urank;
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        return new BigDecimal(0);
    }
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time,system);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key,system);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getSecondInviteRate(int urank) {
        return getSecondInviteRate(urank, System.currentTimeMillis());
    }
    @Override
    public BigDecimal getSecondInviteRate(int urank, SystemEnum system) {
        return getSecondInviteRate(urank, System.currentTimeMillis(),system);
    }
    @Override
    public BigDecimal getSecondInviteRate(int urank, long time) {
        String key = "sale_7_" + urank;
    @Override
    public BigDecimal getSecondInviteRate(int urank, long time, SystemEnum system) {
        String key = "sale_7_" + urank;
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取返利分成比例出错");
        return new BigDecimal(0);
    }
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time,system);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key,system);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取返利分成比例出错");
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getFirstShareRate(int urank) {
        String key = "share_21_" + urank;
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, System.currentTimeMillis());
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取返利分成比例出错");
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getFirstShareRate(int urank, SystemEnum system) {
        String key = "share_21_" + urank;
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, System.currentTimeMillis(),system);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key,system);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取返利分成比例出错");
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getFirstShareRate(int urank, long time) {
        String key = "share_21_" + urank;
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取返利分成比例出错");
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getFirstShareRate(int urank, long time, SystemEnum system) {
        String key = "share_21_" + urank;
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time,system);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key,system);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取返利分成比例出错");
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getSecondShareRate(int urank) {
        String key = "share_22_" + urank;
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, System.currentTimeMillis());
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取返利分成比例出错");
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getSecondShareRate(int urank, SystemEnum system) {
        String key = "share_22_" + urank;
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, System.currentTimeMillis(),system);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key,system);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取返利分成比例出错");
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getSecondShareRate(int urank, long time) {
        String key = "share_22_" + urank;
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取返利分成比例出错");
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getSecondShareRate(int urank, long time, SystemEnum system) {
        String key = "share_22_" + urank;
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time,system);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key,system);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取返利分成比例出错");
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getTLJFanLiRate() {
        String key = "tlj_fanli_proportion";
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, System.currentTimeMillis());
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取淘礼金返利分成比例出错");
        return null;
    }
    @Override
    public BigDecimal getTLJFanLiRate( SystemEnum system) {
        String key = "tlj_fanli_proportion";
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, System.currentTimeMillis(),system);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key,system);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取淘礼金返利分成比例出错");
        return null;
    }
    @Override
    public BigDecimal getTLJShareRate(long time) {
        String key = "tlj_share_proportion";
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取淘礼金分享赚分成比例出错");
        return null;
    }
    @Override
    public BigDecimal getTLJShareRate(long time, SystemEnum system) {
        String key = "tlj_share_proportion";
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time,system);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key,system);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取淘礼金分享赚分成比例出错");
        return null;
    }
    @Override
    public BigDecimal getInviteFirstLevelSubsidyRate(Long time) {
        String key = "invite_subsidy_6";
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getInviteFirstLevelSubsidyRate(Long time, SystemEnum system) {
        String key = "invite_subsidy_6";
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time,system);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key,system);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getInviteSecondLevelSubsidyRate(Long time) {
        String key = "invite_subsidy_7";
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        return new BigDecimal(0);
    }
    @Override
    public BigDecimal getInviteSecondLevelSubsidyRate(Long time, SystemEnum system) {
        String key = "invite_subsidy_7";
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time,system);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key,system);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        return new BigDecimal(0);
    }
    @Override
    public ConfigParamsDTO getShowComputeRate(String platform, String version, UserLevelEnum userLevel) {
    @Override
    public ConfigParamsDTO getShowComputeRate(String platform, String version, UserLevelEnum userLevel, SystemEnum system) {
        BigDecimal fanLiRate = getFanLiRate(userLevel);
        BigDecimal shareRate = getShareRate(userLevel);
        ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,
                getFanLiRate(UserLevelEnum.superVIP));
        if (VersionUtil.greaterThan_2_0_5(platform, version)) {
            paramsDTO.setMaxRewardRate(null);
        }
        return paramsDTO;
    }
        BigDecimal fanLiRate = getFanLiRate(userLevel,system);
        BigDecimal shareRate = getShareRate(userLevel,system);
        ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,
                getFanLiRate(UserLevelEnum.superVIP,system));
        if (VersionUtil.greaterThan_2_0_5(platform, version)) {
            paramsDTO.setMaxRewardRate(null);
        }
        return paramsDTO;
    }
    @Override
    public ConfigParamsDTO getShowComputeRate(String platform, String version) {
    @Override
    public ConfigParamsDTO getShowComputeRate(String platform, String version, SystemEnum system) {
        BigDecimal fanLiRate = getFanLiRate(UserLevelEnum.daRen);
        BigDecimal shareRate = getShareRate(UserLevelEnum.daRen);
        ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,
                getFanLiRate(UserLevelEnum.superVIP));
        if (VersionUtil.greaterThan_2_0_5(platform, version)) {
            paramsDTO.setMaxRewardRate(null);
        }
        return paramsDTO;
    }
        BigDecimal fanLiRate = getFanLiRate(UserLevelEnum.daRen,system);
        BigDecimal shareRate = getShareRate(UserLevelEnum.daRen,system);
        ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,
                getFanLiRate(UserLevelEnum.superVIP,system));
        if (VersionUtil.greaterThan_2_0_5(platform, version)) {
            paramsDTO.setMaxRewardRate(null);
        }
        return paramsDTO;
    }
    @Override
    public BigDecimal getBaseFanliRate(long time) {
        String key = "base_fanli_rate";
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取基础返利比例出错");
        return null;
    }
    @Override
    public BigDecimal getBaseFanliRate(long time, SystemEnum system) {
        String key = "base_fanli_rate";
        HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time,system);
        if (hongBaoManage == null)
            hongBaoManage = hongBaoManageMapper.selectByKey(key,system);
        if (hongBaoManage != null)
            return new BigDecimal(hongBaoManage.getValue());
        LogHelper.error("获取基础返利比例出错");
        return null;
    }
    @Override
    public BigDecimal getBaseFanliRate() {
        return getBaseFanliRate(System.currentTimeMillis());
    }
    @Cacheable(value = "homeBaoManage", key = "'getBaseFanliRate'+#time")
    @Override
    public BigDecimal getBaseFanliRateCache(long time) {
        return getBaseFanliRate(System.currentTimeMillis());
    }
    @Override
    public BigDecimal getBaseFanliRate(SystemEnum system) {
        return getBaseFanliRate(System.currentTimeMillis(),system);
    }
    @Cacheable(value = "homeBaoManage", key = "'getBaseFanliRate'+#time+'-'+#system")
    @Override
    public BigDecimal getBaseFanliRateCache(long time, SystemEnum system) {
        return getBaseFanliRate(System.currentTimeMillis(),system);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/order/tb/TaoBaoPunishOrderServiceImpl.java
@@ -133,14 +133,14 @@
        for (Iterator<String> its = relationIdSets.iterator(); its.hasNext();) {
            String relationId = its.next();
            UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByRelationId(relationId);
            UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByRelationId(relationId,null);
            if (info != null && info.getUser() != null)
                uidSets.add(info.getUser().getId());
        }
        for (Iterator<String> its = specialIdSets.iterator(); its.hasNext();) {
            String specialId = its.next();
            UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getBySpecialId(specialId);
            UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getBySpecialId(specialId,null);
            if (info != null && info.getUser() != null)
                uidSets.add(info.getUser().getId());
        }
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoShopServiceImpl.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.web.multipart.MultipartFile;
@@ -173,13 +174,13 @@
    @Override
    @Cacheable(value = "brandCache", key = "'getShopByKey-'+#key")
    public List<TaoBaoShopVO> getShopByKey(String key) {
    public List<TaoBaoShopVO> getShopByKey(String key, SystemEnum system) {
        List<TaoBaoShopVO> list = taoBaoShopMapper.getShopByKey(key);
        if (list == null || list.size() == 0) {
            return null;
        }
        BigDecimal proportion = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen);
        BigDecimal proportion = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,system);
        for (TaoBaoShopVO taoBaoShopVO : list) {
            String shopLink = taoBaoShopVO.getShopLink();
@@ -208,14 +209,14 @@
    }
    @Override
    @Cacheable(value = "brandCache", key = "'getShopByKeyV2-'+#key+'-'+#platform+'-'+#version")
    public List<TaoBaoShopVO> getShopByKeyV2(String key, String platform, String version) {
    @Cacheable(value = "brandCache", key = "'getShopByKeyV2-'+#key+'-'+#platform+'-'+#version+'-'+#system")
    public List<TaoBaoShopVO> getShopByKeyV2(String key, String platform, String version,SystemEnum system) {
        List<TaoBaoShopVO> list = taoBaoShopMapper.getShopByKey(key);
        if (list == null || list.size() == 0) {
            return null;
        }
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version,UserLevelEnum.daRen);
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version,UserLevelEnum.daRen,system);
        for (TaoBaoShopVO taoBaoShopVO : list) {
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java
@@ -474,12 +474,13 @@
            int winNum = userTaoLiJinRecordVO.getWinNum();
            int totalNum = userTaoLiJinRecordVO.getTotalNum();
            userTaoLiJinRecordVO.setSurplusNum(totalNum - winNum);
            SystemEnum system = userInfoService.getUserSystem(uid);
            // 计算分享奖金
            BigDecimal shareMoney = new BigDecimal(0);
            BigDecimal commission = userTaoLiJinRecordVO.getCommission();
            if (commission != null && commission.compareTo(shareMoney) > 0) {
                BigDecimal shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen);
                BigDecimal shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,system);
                shareMoney = MoneyBigDecimalUtil.mul(commission,
                        MoneyBigDecimalUtil.div(shareRate, new BigDecimal(100)));
                shareMoney = BigDecimalUtil.getWithNoZera(shareMoney);
@@ -576,7 +577,7 @@
        while (tips.contains("{APP名称}")) {
            tips = tips.replace("{APP名称}", projectChineseName);
        }
        tips = tips.replace("{口令}", token).replace("{下载链接}", configService.getValue(ConfigKeyEnum.appDownLink.getKey(),system)).replace("{面额}",
        tips = tips.replace("{口令}", token).replace("{下载链接}", configService.getValue(ConfigKeyEnum.appDownLink.getKey(), system)).replace("{面额}",
                amount.setScale(0).toString());
        executor.execute(new Runnable() {
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java
@@ -8,13 +8,13 @@
import javax.servlet.http.HttpSession;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.system.BusinessSystem;
import com.yeshi.fanli.util.*;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yeshi.utils.HttpUtil;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.SystemUtil;
import org.yeshi.utils.entity.FileUploadResult;
import org.yeshi.utils.entity.ProxyIP;
import org.yeshi.utils.tencentcloud.COSManager;
@@ -22,7 +22,6 @@
import com.google.gson.Gson;
import com.qcloud.cos.model.COSObjectSummary;
import com.qcloud.cos.model.ObjectListing;
import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
import com.yeshi.fanli.dto.wx.WXAccountInfoDTO;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.BindingAccount;
@@ -797,7 +796,7 @@
    @Transactional(rollbackFor = Exception.class)
    @Override
    public UserInfo loginPhone(ProxyIP ipInfo, AcceptData acceptData, int loginType, String vcode, String phone, String appId)
    public UserInfo loginPhone(ProxyIP ipInfo, int loginType, String vcode, String phone, BusinessSystem businessSystem)
            throws UserAccountException {
        // 空额清理
@@ -826,7 +825,7 @@
        }
        JSONObject logInfo = new JSONObject();
        logInfo.put("appId", appId);
        logInfo.put("appId", businessSystem.getAppid());
        logInfo.put("phone", phone);
        logInfo.put("loginType", loginType);
        LogHelper.lgoinInfo(logInfo.toString());
@@ -859,19 +858,18 @@
            } else {
                // 查询是否存在该电话历史用户
                UserInfo userInfo = userInfoService.getEffectiveUserInfoByPhone(phone, SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages()));
                UserInfo userInfo = userInfoService.getEffectiveUserInfoByPhone(phone, businessSystem.getSystem());
                if (userInfo != null) {
                    // 更新账户登录信息
                    updateLonginInfo(userInfo, loginType, ipInfo);
                } else {
                    userInfo = new UserInfo();
                    userInfo.setAppId(appId);
                    // userInfo.setNickName(Constant.systemCommonConfig.getDefaultNickName());
                    userInfo.setAppId(businessSystem.getAppid());
                    userInfo.setPortrait(Constant.systemCommonConfig.getDefaultPortrait());
                    userInfo.setPhone(phone);
                    userInfo.setLoginType(loginType);
                    userInfo.setState(UserInfo.STATE_NORMAL);
                    userInfo.setSystem(SystemInfoUtil.getSystem(acceptData));
                    userInfo.setSystem( businessSystem.getSystem());
                    // 创建用户
                    addUser(userInfo);
@@ -981,18 +979,17 @@
    @Transactional(rollbackFor = Exception.class)
    @Override
    public UserInfo loginWinXin(ProxyIP ipInfo, AcceptData acceptData, int loginType, String code,
                                String appId) throws UserAccountException {
    public UserInfo loginWeiXin(ProxyIP ipInfo, int loginType, String code,
                                BusinessSystem businessSystem) throws UserAccountException {
        // 日志信息
        JSONObject logInfo = new JSONObject();
        logInfo.put("appId", appId);
        logInfo.put("appId", businessSystem.getAppid());
        logInfo.put("code", code);
        logInfo.put("loginType", loginType);
        LogHelper.lgoinInfo(logInfo.toString());
        // 通过Code换取信息
        WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
        WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret());
        WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code,businessSystem.getWxAppId(), businessSystem.getWxAppSecret());
        if (weiXinUser == null) {
            throw new UserAccountException(1, "微信帐号授权失败");
        }
@@ -1018,7 +1015,7 @@
            if (exec == null || exec.size() == 0) {
                throw new UserAccountException(10, "请稍后再试");
            } else {
                UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(), SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages()));
                UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(),businessSystem.getSystem());
                // 直接用的微信登录
                if (userInfo != null) {
                    LogHelper.test("微信unionID存在:" + weiXinUser.getUnionid());
@@ -1049,7 +1046,7 @@
                    // 创建新账户
                    userInfo = new UserInfo();
                    userInfo.setPortrait(portrait);
                    userInfo.setAppId(appId);
                    userInfo.setAppId(businessSystem.getAppid());
                    userInfo.setNickName(weiXinUser.getNickname());
                    userInfo.setWxName(weiXinUser.getNickname());
                    userInfo.setWxOpenId(weiXinUser.getOpenid());
@@ -1059,7 +1056,7 @@
                    userInfo.setLoginType(loginType);
                    userInfo.setLastLoginIp(ipInfo.getIp());
                    userInfo.setState(UserInfo.STATE_NORMAL);
                    userInfo.setSystem(SystemInfoUtil.getSystem(acceptData));
                    userInfo.setSystem(businessSystem.getSystem());
                    addUser(userInfo);
                    try {
@@ -1086,18 +1083,17 @@
    @Transactional(rollbackFor = Exception.class)
    @Override
    public UserInfo loginWeiXinNew(ProxyIP ipInfo, AcceptData acceptData, int loginType, String wxCode,
                                   String appId) throws UserAccountException {
    public UserInfo loginWeiXinNew(ProxyIP ipInfo, int loginType, String wxCode,
                                  BusinessSystem businessSystem) throws UserAccountException {
        // 日志信息
        JSONObject logInfo = new JSONObject();
        logInfo.put("appId", appId);
        logInfo.put("appId", businessSystem.getAppid());
        logInfo.put("wxCode", wxCode);
        logInfo.put("loginType", loginType);
        LogHelper.lgoinInfo(logInfo.toString());
        // 通过Code换取信息
        WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
        WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(wxCode, wxAccount.getAppId(), wxAccount.getAppSecret());
        WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(wxCode, businessSystem.getWxAppId(),businessSystem.getWxAppSecret());
        if (weiXinUser == null) {
            throw new UserAccountException(1, "微信帐号授权失败");
        }
@@ -1110,7 +1106,7 @@
            throw new UserAccountException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
        }
        UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(), SystemInfoUtil.getSystem(acceptData));
        UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(), businessSystem.getSystem());
        if (userInfo == null) {
            String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey,
                    StringUtil.Md5("WXLogin:" + weiXinUser.getUnionid()));
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java
@@ -9,6 +9,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.util.*;
@@ -51,415 +52,419 @@
@Service
public class UserGoodsStorageServiceImpl implements UserGoodsStorageService {
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    @Resource
    private RedisManager redisManager;
    @Resource
    private RedisManager redisManager;
    @Resource
    private ConfigService configService;
    @Resource
    private ConfigService configService;
    @Resource
    private CommonGoodsService commonGoodsService;
    @Resource
    private CommonGoodsService commonGoodsService;
    @Resource
    private HongBaoManageService manageService;
    @Resource
    private HongBaoManageService manageService;
    @Resource
    private UserGoodsStorageMapper userGoodsStorageMapper;
    @Resource
    private UserGoodsStorageMapper userGoodsStorageMapper;
    @Resource
    private UserShareGoodsRecordService userShareGoodsRecordService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private UserShareGoodsRecordService userShareGoodsRecordService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserInfoService userInfoService;
    @Override
    public int deleteByPrimaryKey(Long id) {
        return userGoodsStorageMapper.deleteByPrimaryKey(id);
    }
    @Override
    public int deleteByPrimaryKey(Long id) {
        return userGoodsStorageMapper.deleteByPrimaryKey(id);
    }
    @Override
    public int insert(UserGoodsStorage record) {
        return userGoodsStorageMapper.insert(record);
    }
    @Override
    public int insert(UserGoodsStorage record) {
        return userGoodsStorageMapper.insert(record);
    }
    @Override
    public int insertSelective(UserGoodsStorage record) {
        return userGoodsStorageMapper.insertSelective(record);
    }
    @Override
    public int insertSelective(UserGoodsStorage record) {
        return userGoodsStorageMapper.insertSelective(record);
    }
    @Override
    public UserGoodsStorage selectByPrimaryKey(Long id) {
        return userGoodsStorageMapper.selectByPrimaryKey(id);
    }
    @Override
    public UserGoodsStorage selectByPrimaryKey(Long id) {
        return userGoodsStorageMapper.selectByPrimaryKey(id);
    }
    @Override
    public int updateByPrimaryKeySelective(UserGoodsStorage record) {
        return userGoodsStorageMapper.updateByPrimaryKeySelective(record);
    }
    @Override
    public int updateByPrimaryKeySelective(UserGoodsStorage record) {
        return userGoodsStorageMapper.updateByPrimaryKeySelective(record);
    }
    @Override
    public int updateByPrimaryKey(UserGoodsStorage record) {
        return userGoodsStorageMapper.updateByPrimaryKey(record);
    }
    @Override
    public int updateByPrimaryKey(UserGoodsStorage record) {
        return userGoodsStorageMapper.updateByPrimaryKey(record);
    }
    /**
     * 根据主键批量删除
     *
     * @param list
     * @return
     */
    @Override
    public int deleteBatchByPrimaryKey(List<Long> list) {
        return userGoodsStorageMapper.deleteBatchByPrimaryKey(list);
    }
    /**
     * 根据主键批量删除
     *
     * @param list
     * @return
     */
    @Override
    public int deleteBatchByPrimaryKey(List<Long> list) {
        return userGoodsStorageMapper.deleteBatchByPrimaryKey(list);
    }
    /**
     * 根据主键 、uid 批量删除
     *
     * @param list
     * @return
     */
    @Override
    public int deleteBatchByUidAndPrimaryKey(Long uid, List<Long> list) {
        return userGoodsStorageMapper.deleteBatchByUidAndPrimaryKey(uid, list);
    }
    /**
     * 根据主键 、uid 批量删除
     *
     * @param list
     * @return
     */
    @Override
    public int deleteBatchByUidAndPrimaryKey(Long uid, List<Long> list) {
        return userGoodsStorageMapper.deleteBatchByUidAndPrimaryKey(uid, list);
    }
    @Override
    public List<UserGoodsStorage> listQueryByUid(long start, int count, Long uid, Integer source) {
        return userGoodsStorageMapper.listQueryByUid(start, count, uid, source);
    }
    @Override
    public List<UserGoodsStorage> listQueryByUid(long start, int count, Long uid, Integer source) {
        return userGoodsStorageMapper.listQueryByUid(start, count, uid, source);
    }
    @Override
    public UserGoodsStorage getByUidAndAuctionId(Long uid, Long auctionId, Integer goodsType) {
        return userGoodsStorageMapper.getByUidAndAuctionId(uid, auctionId, goodsType);
    }
    @Override
    public UserGoodsStorage getByUidAndAuctionId(Long uid, Long auctionId, Integer goodsType) {
        return userGoodsStorageMapper.getByUidAndAuctionId(uid, auctionId, goodsType);
    }
    @Override
    public long countQueryByUid(Long uid, Integer source) {
        return userGoodsStorageMapper.countQueryByUid(uid, source);
    }
    @Override
    public long countQueryByUid(Long uid, Integer source) {
        return userGoodsStorageMapper.countQueryByUid(uid, source);
    }
    @Override
    public void save(Long uid, Set<Long> auctionIds, Integer goodsType) throws UserGoodsStorageException {
    @Override
    public void save(Long uid, Set<Long> auctionIds, Integer goodsType) throws UserGoodsStorageException {
        if (uid == null) {
            throw new UserGoodsStorageException(1, "用户尚未登录");
        }
        if (uid == null) {
            throw new UserGoodsStorageException(1, "用户尚未登录");
        }
        if (auctionIds == null || auctionIds.size() == 0) {
            throw new UserGoodsStorageException(1, "商品ID为空");
        }
        if (auctionIds == null || auctionIds.size() == 0) {
            throw new UserGoodsStorageException(1, "商品ID为空");
        }
        for (Long auctionId : auctionIds) {
            CommonGoods commonGoods = null;
            if (goodsType == null) {
                goodsType = Constant.SOURCE_TYPE_TAOBAO;
            }
        for (Long auctionId : auctionIds) {
            CommonGoods commonGoods = null;
            if (goodsType == null) {
                goodsType = Constant.SOURCE_TYPE_TAOBAO;
            }
            if (goodsType == Constant.SOURCE_TYPE_JD) {
                // 京东
                JDGoods jdGoods = JDApiUtil.queryGoodsDetail(auctionId);
                if (jdGoods == null) {
                    jdGoods = JDApiUtil.getGoodsDetail(auctionId);
                }
                if (jdGoods == null) {
                    throw new UserGoodsStorageException(1, auctionId + "商品已下架");
                }
                commonGoods = CommonGoodsFactory.create(jdGoods);
            if (goodsType == Constant.SOURCE_TYPE_JD) {
                // 京东
                JDGoods jdGoods = JDApiUtil.queryGoodsDetail(auctionId);
                if (jdGoods == null) {
                    jdGoods = JDApiUtil.getGoodsDetail(auctionId);
                }
                if (jdGoods == null) {
                    throw new UserGoodsStorageException(1, auctionId + "商品已下架");
                }
                commonGoods = CommonGoodsFactory.create(jdGoods);
            } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
                // 拼多多
                PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(auctionId);
                if (pddGoods == null) {
                    throw new UserGoodsStorageException(1, auctionId + "商品已下架");
                }
                commonGoods = CommonGoodsFactory.create(pddGoods);
            } else {
                // 淘宝
                try {
                    // 获取商品详情
                    TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(auctionId);
                    commonGoods = CommonGoodsFactory.create(goodsBrief);
                } catch (TaobaoGoodsDownException e) {
                    throw new UserGoodsStorageException(1, auctionId + "商品已下架");
                }
            }
            } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
                // 拼多多
                PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(auctionId);
                if (pddGoods == null) {
                    throw new UserGoodsStorageException(1, auctionId + "商品已下架");
                }
                commonGoods = CommonGoodsFactory.create(pddGoods);
            } else {
                // 淘宝
                try {
                    // 获取商品详情
                    TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(auctionId);
                    commonGoods = CommonGoodsFactory.create(goodsBrief);
                } catch (TaobaoGoodsDownException e) {
                    throw new UserGoodsStorageException(1, auctionId + "商品已下架");
                }
            }
            if (commonGoods != null) {
                try {
                    commonGoodsService.addOrUpdateCommonGoods(commonGoods);
                } catch (CommonGoodsException e) {
                    e.printStackTrace();
                    throw new UserGoodsStorageException(1, "商品信息更新失败");
                }
            if (commonGoods != null) {
                try {
                    commonGoodsService.addOrUpdateCommonGoods(commonGoods);
                } catch (CommonGoodsException e) {
                    e.printStackTrace();
                    throw new UserGoodsStorageException(1, "商品信息更新失败");
                }
                Long cid = commonGoods.getId();
                Long cid = commonGoods.getId();
                UserGoodsStorage goodsStorage = userGoodsStorageMapper.getByUidAndCid(uid, cid);
                UserGoodsStorage goodsStorage = userGoodsStorageMapper.getByUidAndCid(uid, cid);
                if (goodsStorage != null) {
                    // 初始话状态
                    goodsStorage.setState(UserGoodsStorage.STATE_NORMAL);
                    goodsStorage.setUpdateTime(new Date());
                    userGoodsStorageMapper.updateByPrimaryKeySelective(goodsStorage);
                } else {
                    goodsStorage = new UserGoodsStorage();
                    goodsStorage.setUid(uid);
                    ;
                    goodsStorage.setState(UserGoodsStorage.STATE_NORMAL);
                    goodsStorage.setCommonGoods(commonGoods);
                    goodsStorage.setCreateTime(new Date());
                    goodsStorage.setUpdateTime(new Date());
                    userGoodsStorageMapper.insertSelective(goodsStorage);
                }
            }
        }
    }
                if (goodsStorage != null) {
                    // 初始话状态
                    goodsStorage.setState(UserGoodsStorage.STATE_NORMAL);
                    goodsStorage.setUpdateTime(new Date());
                    userGoodsStorageMapper.updateByPrimaryKeySelective(goodsStorage);
                } else {
                    goodsStorage = new UserGoodsStorage();
                    goodsStorage.setUid(uid);
                    ;
                    goodsStorage.setState(UserGoodsStorage.STATE_NORMAL);
                    goodsStorage.setCommonGoods(commonGoods);
                    goodsStorage.setCreateTime(new Date());
                    goodsStorage.setUpdateTime(new Date());
                    userGoodsStorageMapper.insertSelective(goodsStorage);
                }
            }
        }
    }
    @Override
    @Transactional(rollbackFor=Exception.class)
    public void addCommonGoods(Long uid, Set<Long> ids) throws UserGoodsStorageException {
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addCommonGoods(Long uid, Set<Long> ids) throws UserGoodsStorageException {
        if (uid == null) {
            throw new UserGoodsStorageException(1, "用户尚未登录");
        }
        if (uid == null) {
            throw new UserGoodsStorageException(1, "用户尚未登录");
        }
        if (ids == null || ids.size() == 0) {
            throw new UserGoodsStorageException(1, "商品ID为空");
        }
        if (ids == null || ids.size() == 0) {
            throw new UserGoodsStorageException(1, "商品ID为空");
        }
        for (Long id : ids) {
            CommonGoods commonGoods = commonGoodsService.selectByPrimaryKey(id);
            if (commonGoods != null) {
                UserGoodsStorage goodsStorage = userGoodsStorageMapper.getByUidAndCid(uid, id);
        for (Long id : ids) {
            CommonGoods commonGoods = commonGoodsService.selectByPrimaryKey(id);
            if (commonGoods != null) {
                UserGoodsStorage goodsStorage = userGoodsStorageMapper.getByUidAndCid(uid, id);
                if (goodsStorage != null) {
                    // 初始话状态
                    goodsStorage.setState(UserGoodsStorage.STATE_NORMAL);
                    goodsStorage.setUpdateTime(new Date());
                    userGoodsStorageMapper.updateByPrimaryKeySelective(goodsStorage);
                } else {
                    goodsStorage = new UserGoodsStorage();
                    goodsStorage.setUid(uid);
                    ;
                    goodsStorage.setState(UserGoodsStorage.STATE_NORMAL);
                    goodsStorage.setCommonGoods(commonGoods);
                    goodsStorage.setCreateTime(new Date());
                    goodsStorage.setUpdateTime(new Date());
                    userGoodsStorageMapper.insertSelective(goodsStorage);
                }
            }
        }
    }
                if (goodsStorage != null) {
                    // 初始话状态
                    goodsStorage.setState(UserGoodsStorage.STATE_NORMAL);
                    goodsStorage.setUpdateTime(new Date());
                    userGoodsStorageMapper.updateByPrimaryKeySelective(goodsStorage);
                } else {
                    goodsStorage = new UserGoodsStorage();
                    goodsStorage.setUid(uid);
                    ;
                    goodsStorage.setState(UserGoodsStorage.STATE_NORMAL);
                    goodsStorage.setCommonGoods(commonGoods);
                    goodsStorage.setCreateTime(new Date());
                    goodsStorage.setUpdateTime(new Date());
                    userGoodsStorageMapper.insertSelective(goodsStorage);
                }
            }
        }
    }
    @Override
    public JSONArray getMyStorage(int page, int pageSize, Long uid, Integer source) throws UserGoodsStorageException {
    @Override
    public JSONArray getMyStorage(int page, int pageSize, Long uid, Integer source) throws UserGoodsStorageException {
        JSONArray array = new JSONArray();
        JSONArray array = new JSONArray();
        List<UserGoodsStorage> listStorage = listQueryByUid(page, pageSize, uid, source);
        if (listStorage == null || listStorage.size() == 0) {
            return array;
        }
        List<UserGoodsStorage> listStorage = listQueryByUid(page, pageSize, uid, source);
        if (listStorage == null || listStorage.size() == 0) {
            return array;
        }
        if (source == null) {
            source = Constant.SOURCE_TYPE_TAOBAO;
        }
        if (source == null) {
            source = Constant.SOURCE_TYPE_TAOBAO;
        }
        List<TaoBaoGoodsBrief> listTaoKeGoods = null;
        if (source == Constant.SOURCE_TYPE_TAOBAO) {
            List<Long> listGid = new ArrayList<Long>();
            for (UserGoodsStorage userGoodsStorage : listStorage) {
                CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
                if (commonGoods == null) {
                    continue;
                }
                listGid.add(commonGoods.getGoodsId());
            }
        List<TaoBaoGoodsBrief> listTaoKeGoods = null;
        if (source == Constant.SOURCE_TYPE_TAOBAO) {
            List<Long> listGid = new ArrayList<Long>();
            for (UserGoodsStorage userGoodsStorage : listStorage) {
                CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
                if (commonGoods == null) {
                    continue;
                }
                listGid.add(commonGoods.getGoodsId());
            }
            // API网络接口验证是否在售
            try {
                listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
            } catch (TaoKeApiException e) {
                e.printStackTrace();
            } catch (TaobaoGoodsDownException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
            // API网络接口验证是否在售
            try {
                listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
            } catch (TaoKeApiException e) {
                e.printStackTrace();
            } catch (TaobaoGoodsDownException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        SystemEnum system = userInfoService.getUserSystem(uid);
        BigDecimal rate = manageService.getFanLiRate(UserLevelEnum.daRen, system);
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        BigDecimal rate = manageService.getFanLiRate(UserLevelEnum.daRen);
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        for (UserGoodsStorage userGoodsStorage : listStorage) {
            CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
            if (commonGoods == null) {
                continue;
            }
        for (UserGoodsStorage userGoodsStorage : listStorage) {
            CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
            if (commonGoods == null) {
                continue;
            }
            int state = 0;
            Integer goodsType = commonGoods.getGoodsType();
            int state = 0;
            Integer goodsType = commonGoods.getGoodsType();
            if (listTaoKeGoods != null && listTaoKeGoods.size() > 0 && goodsType != null
                    && goodsType == Constant.SOURCE_TYPE_TAOBAO) {
                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);
            if (listTaoKeGoods != null && listTaoKeGoods.size() > 0 && goodsType != null
                    && goodsType == Constant.SOURCE_TYPE_TAOBAO) {
                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);
            // 判断是否已分享
            Integer storageState = userGoodsStorage.getState();
            if (storageState != null && storageState == UserGoodsStorage.STATE_SHARED) {
                Integer goodsState = goodsBrief.getState();
                if (goodsState != null && goodsState != 1) {
                    goodsBrief.setState(2); // 已分享状态 优先显示已下架
                }
            }
            // 判断是否已分享
            Integer storageState = userGoodsStorage.getState();
            if (storageState != null && storageState == UserGoodsStorage.STATE_SHARED) {
                Integer goodsState = goodsBrief.getState();
                if (goodsState != null && goodsState != 1) {
                    goodsBrief.setState(2); // 已分享状态 优先显示已下架
                }
            }
            String json = gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, rate.toString(), null));
            String json = gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, rate.toString(), null));
            JSONObject dataObject = new JSONObject();
            dataObject.put("storageId", userGoodsStorage.getId());
            dataObject.put("goods", json);
            array.add(dataObject);
        }
            JSONObject dataObject = new JSONObject();
            dataObject.put("storageId", userGoodsStorage.getId());
            dataObject.put("goods", json);
            array.add(dataObject);
        }
        return array;
    }
        return array;
    }
    @Override
    public boolean isExistStorage(Long uid, Long auctionId, Integer goodType) {
        boolean state = false;
        if (uid != null && auctionId != null) {
            UserGoodsStorage userGoodsStorage = userGoodsStorageMapper.getByUidAndAuctionId(uid, auctionId, goodType);
            if (userGoodsStorage != null) {
                state = true;
            }
        }
        return state;
    }
    @Override
    public boolean isExistStorage(Long uid, Long auctionId, Integer goodType) {
        boolean state = false;
        if (uid != null && auctionId != null) {
            UserGoodsStorage userGoodsStorage = userGoodsStorageMapper.getByUidAndAuctionId(uid, auctionId, goodType);
            if (userGoodsStorage != null) {
                state = true;
            }
        }
        return state;
    }
    @Override
    public JSONObject shareGoods(Long uid, List<Long> listStorageID)
            throws UserGoodsStorageException, UserShareGoodsRecordException {
        List<UserGoodsStorage> listStorage = userGoodsStorageMapper.listQueryByIds(listStorageID);
        if (listStorage == null || listStorage.size() == 0) {
            throw new UserGoodsStorageException(1, "选品库商品不存在");
        }
    @Override
    public JSONObject shareGoods(Long uid, List<Long> listStorageID)
            throws UserGoodsStorageException, UserShareGoodsRecordException {
        List<UserGoodsStorage> listStorage = userGoodsStorageMapper.listQueryByIds(listStorageID);
        if (listStorage == null || listStorage.size() == 0) {
            throw new UserGoodsStorageException(1, "选品库商品不存在");
        }
        List<UserGoodsStorage> listResult = new ArrayList<UserGoodsStorage>();
        // 还原顺序 用于制图
        for (Long sid : listStorageID) {
            for (UserGoodsStorage torage : listStorage) {
                Long id = torage.getId();
                if (sid == id || sid.equals(id)) {
                    listResult.add(torage);
                    break;
                }
            }
        }
        List<UserGoodsStorage> listResult = new ArrayList<UserGoodsStorage>();
        // 还原顺序 用于制图
        for (Long sid : listStorageID) {
            for (UserGoodsStorage torage : listStorage) {
                Long id = torage.getId();
                if (sid == id || sid.equals(id)) {
                    listResult.add(torage);
                    break;
                }
            }
        }
        BigDecimal totalMoney = new BigDecimal(0.00);
        List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
        BigDecimal totalMoney = new BigDecimal(0.00);
        List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
        SystemEnum system = userInfoService.getUserSystem(uid);
        BigDecimal rate = hongBaoManageService.getShareRate(UserLevelEnum.daRen);
        for (UserGoodsStorage userGoodsStorage : listResult) {
            CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
            TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
            listGoodsBrief.add(goodsBrief);
        BigDecimal rate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,system);
        for (UserGoodsStorage userGoodsStorage : listResult) {
            CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
            TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
            listGoodsBrief.add(goodsBrief);
            BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(goodsBrief, rate,true);
            totalMoney = MoneyBigDecimalUtil.add(totalMoney, money);
        }
            BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(goodsBrief, rate, true);
            totalMoney = MoneyBigDecimalUtil.add(totalMoney, money);
        }
        ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsStorage(uid, listGoodsBrief,
                listStorageID);
        FileUploadResult uploadResult = new FileUploadResult();
        uploadResult.setUrl(shareRecord.getSharePictureUrl());
        ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsStorage(uid, listGoodsBrief,
                listStorageID);
        FileUploadResult uploadResult = new FileUploadResult();
        uploadResult.setUrl(shareRecord.getSharePictureUrl());
        UserInfo user=userInfoService.selectByPKey(uid);
        UserInfo user = userInfoService.selectByPKey(uid);
        JSONObject data = new JSONObject();
        data.put("revenue", listGoodsBrief.size() + "个商品预估分享奖金:¥" + totalMoney);
        data.put("shareId", shareRecord.getRedisKey());
        data.put("shareImg", uploadResult);
        data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareMultipleNotify.getKey(), user.getSystem()));
        return data;
    }
        JSONObject data = new JSONObject();
        data.put("revenue", listGoodsBrief.size() + "个商品预估分享奖金:¥" + totalMoney);
        data.put("shareId", shareRecord.getRedisKey());
        data.put("shareImg", uploadResult);
        data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareMultipleNotify.getKey(), user.getSystem()));
        return data;
    }
    @Override
    public JSONObject createShareV2(Long uid, List<Long> listStorageID, boolean needDrawPicture)
            throws UserGoodsStorageException, UserShareGoodsRecordException {
        List<UserGoodsStorage> listStorage = userGoodsStorageMapper.listQueryByIds(listStorageID);
        if (listStorage == null || listStorage.size() == 0) {
            throw new UserGoodsStorageException(1, "选品库商品不存在");
        }
    @Override
    public JSONObject createShareV2(Long uid, List<Long> listStorageID, boolean needDrawPicture)
            throws UserGoodsStorageException, UserShareGoodsRecordException {
        List<UserGoodsStorage> listStorage = userGoodsStorageMapper.listQueryByIds(listStorageID);
        if (listStorage == null || listStorage.size() == 0) {
            throw new UserGoodsStorageException(1, "选品库商品不存在");
        }
        List<UserGoodsStorage> listResult = new ArrayList<UserGoodsStorage>();
        // 还原顺序 用于制图
        for (Long sid : listStorageID) {
            for (UserGoodsStorage torage : listStorage) {
                Long id = torage.getId();
                if (sid == id || sid.equals(id)) {
                    listResult.add(torage);
                    break;
                }
            }
        }
        List<UserGoodsStorage> listResult = new ArrayList<UserGoodsStorage>();
        // 还原顺序 用于制图
        for (Long sid : listStorageID) {
            for (UserGoodsStorage torage : listStorage) {
                Long id = torage.getId();
                if (sid == id || sid.equals(id)) {
                    listResult.add(torage);
                    break;
                }
            }
        }
        BigDecimal totalMoney = new BigDecimal(0.00);
        List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
        SystemEnum system = userInfoService.getUserSystem(uid);
        Integer goodsType = null;
        BigDecimal rate = hongBaoManageService.getShareRate(UserLevelEnum.daRen);
        for (UserGoodsStorage userGoodsStorage : listResult) {
            CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
            BigDecimal money = CommonGoodsUtil.getCommission(commonGoods, rate);
            totalMoney = MoneyBigDecimalUtil.add(totalMoney, money);
            listCommonGoods.add(commonGoods);
        BigDecimal totalMoney = new BigDecimal(0.00);
        List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
            if (goodsType == null) {
                goodsType = commonGoods.getGoodsType();
            }
        }
        Integer goodsType = null;
        BigDecimal rate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,system);
        for (UserGoodsStorage userGoodsStorage : listResult) {
            CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
            BigDecimal money = CommonGoodsUtil.getCommission(commonGoods, rate);
            totalMoney = MoneyBigDecimalUtil.add(totalMoney, money);
            listCommonGoods.add(commonGoods);
        ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsStorageV2(uid, listCommonGoods,
                listStorageID, needDrawPicture);
        FileUploadResult uploadResult = new FileUploadResult();
        uploadResult.setUrl(shareRecord.getSharePictureUrl());
            if (goodsType == null) {
                goodsType = commonGoods.getGoodsType();
            }
        }
        JSONObject data = new JSONObject();
        data.put("revenue", listCommonGoods.size() + "个商品预估分享奖金:¥" + totalMoney);
        data.put("shareId", shareRecord.getRedisKey());
        data.put("shareImg", uploadResult);
        ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsStorageV2(uid, listCommonGoods,
                listStorageID, needDrawPicture);
        FileUploadResult uploadResult = new FileUploadResult();
        uploadResult.setUrl(shareRecord.getSharePictureUrl());
        SystemEnum system=userInfoService.getUserSystem(uid);
        // 提示语不同
        if (goodsType == Constant.SOURCE_TYPE_JD) {
            // 京东
            data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotifyJD.getKey(),system));
        } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
            // 拼多多
            data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotifyPDD.getKey(),system));
        } else {
            data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareMultipleNotify.getKey(),system));
        }
        return data;
    }
        JSONObject data = new JSONObject();
        data.put("revenue", listCommonGoods.size() + "个商品预估分享奖金:¥" + totalMoney);
        data.put("shareId", shareRecord.getRedisKey());
        data.put("shareImg", uploadResult);
        // 提示语不同
        if (goodsType == Constant.SOURCE_TYPE_JD) {
            // 京东
            data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotifyJD.getKey(), system));
        } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
            // 拼多多
            data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotifyPDD.getKey(), system));
        } else {
            data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareMultipleNotify.getKey(), system));
        }
        return data;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java
@@ -265,16 +265,16 @@
    @Override
    public long countInfo(Integer userState, String key, Integer keyType, String userRank, Integer days,
                          String startTime, String endTime, Integer userType, String level, Integer activeCode) {
        return userInfoMapper.countInfo(userState, key, keyType, userRank, days, startTime, endTime, userType, level, activeCode);
                          String startTime, String endTime, Integer userType, String level, Integer activeCode,SystemEnum system) {
        return userInfoMapper.countInfo(userState, key, keyType, userRank, days, startTime, endTime, userType, level, activeCode,system);
    }
    @Override
    public List<UserInfoVO> queryInfo(long start, int count, Integer userState, String key, Integer keyType,
                                      String userRank, Integer days, String startTime, String endTime, Integer userType, String level, Integer activeCode) {
                                      String userRank, Integer days, String startTime, String endTime, Integer userType, String level, Integer activeCode,SystemEnum system) {
        List<UserInfoVO> userList = userInfoMapper.queryInfo(start, count, userState, key, keyType, userRank, days,
                startTime, endTime, userType, level, activeCode);
                startTime, endTime, userType, level, activeCode,system);
        if (userList == null || userList.size() == 0) {
            return null;
@@ -354,17 +354,17 @@
    @Override
    public long queryCount(Integer userState, String key, Integer keyType, String userRank, Integer days,
                           String startTime, String endTime, Integer userType, String level, Integer activeCode) {
        return userInfoMapper.queryCount(userState, key, keyType, userRank, days, startTime, endTime, userType, level, activeCode);
                           String startTime, String endTime, Integer userType, String level, Integer activeCode,SystemEnum system) {
        return userInfoMapper.queryCount(userState, key, keyType, userRank, days, startTime, endTime, userType, level, activeCode,system);
    }
    @Override
    public List<UserInfoVO> query(long start, int count, Integer userState, String key, Integer keyType,
                                  String userRank, Integer days, String startTime, String endTime, Integer orderField, Integer orderMode,
                                  Integer userType, String level, Integer activeCode) {
                                  Integer userType, String level, Integer activeCode,SystemEnum system) {
        List<UserInfoVO> userList = userInfoMapper.query(start, count, userState, key, keyType, userRank, days,
                startTime, endTime, orderField, orderMode, userType, level, activeCode);
                startTime, endTime, orderField, orderMode, userType, level, activeCode,system);
        if (userList == null || userList.size() == 0) {
            return null;
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java
@@ -489,7 +489,7 @@
    }
    @Override
    public JSONObject getGoodsGroup(Long recordId) throws UserShareGoodsRecordException {
    public JSONObject getGoodsGroup(Long recordId, SystemEnum system) throws UserShareGoodsRecordException {
        JSONArray array = new JSONArray();
@@ -520,7 +520,7 @@
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        BigDecimal shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
                java.lang.System.currentTimeMillis());
                java.lang.System.currentTimeMillis(),system);
        for (UserShareGoodsGroup goodsGroup : list) {
            CommonGoods commonGoods = goodsGroup.getCommonGoods();
@@ -573,7 +573,7 @@
    }
    @Override
    public JSONObject getGoodsGroupDetail(Long recordId) throws UserShareGoodsRecordException {
    public JSONObject getGoodsGroupDetail(Long recordId, SystemEnum system) throws UserShareGoodsRecordException {
        JSONArray array = new JSONArray();
@@ -606,7 +606,7 @@
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            BigDecimal shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
                    java.lang.System.currentTimeMillis());
                    java.lang.System.currentTimeMillis(),system);
            for (UserShareGoodsGroup goodsGroup : list) {
                CommonGoods commonGoods = goodsGroup.getCommonGoods();
fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/ThreeSaleSerivceImpl.java
@@ -8,6 +8,8 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.SystemFunction;
import com.yeshi.fanli.util.SystemInfoUtil;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.task.TaskExecutor;
@@ -47,583 +49,589 @@
@Service
public class ThreeSaleSerivceImpl implements ThreeSaleSerivce {
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private ThreeSaleMapper threeSaleMapper;
    @Resource
    private UserInfoMapper userInfoMapper;
    @Resource
    private UserInviteMsgNotificationService userInviteMsgNotificationService;
    @Resource
    private ThreeSaleMapper threeSaleMapper;
    @Lazy
    @Resource
    private IntegralGetService integralGetService;
    @Resource
    private UserInviteMsgNotificationService userInviteMsgNotificationService;
    @Lazy
    @Resource
    private TeamFansInfoService teamFansInfoService;
    @Resource
    private MsgInviteDetailService msgInviteDetailService;
    @Resource
    private UserActiveLogService userActiveLogService;
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @Resource
    private RocketMQManager rocketMQManager;
    @Resource
    private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce;
    @Lazy
    @Resource
    private IntegralGetService integralGetService;
    @Lazy
    @Resource
    private TeamFansInfoService teamFansInfoService;
    public UserInfo getBoss(final long uid) {
        return threeSaleMapper.selectBoss(uid);
    }
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    @Transactional(rollbackFor = Exception.class)
    public void bind(UserInfo worker, UserInfo inviter) throws ThreeSaleException {
        if (worker == null || inviter == null)
            throw new ThreeSaleException(1, "用户信息为空");
    @Resource
    private RocketMQManager rocketMQManager;
        //判断是否存在邀请权限
        SystemEnum system1 = userInfoService.getUserSystem(worker.getId());
        if (!SystemInfoUtil.hasFunctions(system1, SystemFunction.threeSale))
            throw new ThreeSaleException(2, "无法建立邀请关系");
    public UserInfo getBoss(final long uid) {
        return threeSaleMapper.selectBoss(uid);
    }
        SystemEnum system2 = userInfoService.getUserSystem(inviter.getId());
        if (!SystemInfoUtil.hasFunctions(system2, SystemFunction.threeSale))
            throw new ThreeSaleException(2, "无法建立邀请关系");
    @Transactional(rollbackFor = Exception.class)
    public void bind(UserInfo worker, UserInfo inviter) throws ThreeSaleException {
        if (worker == null || inviter == null)
            throw new ThreeSaleException(1, "用户信息为空");
        if (system1 != system2)
            throw new ThreeSaleException(2, "无法建立邀请关系");
        if (worker.getId() == null)// 该用户还不存在
        {
            // 保存用户
            UserInfo inviteeUser = userInfoService.addUser(worker,worker.getSystem());
            if (inviteeUser == null)
                throw new ThreeSaleException(2, "创建用户失败");
            // 保存关系
            ThreeSale threeSale = new ThreeSale();
            threeSale.setBoss(inviter);
            threeSale.setCreateTime(java.lang.System.currentTimeMillis());
            threeSale.setExpire(ThreeSale.EXPIRE_NORMAL);
            threeSale.setState(false);
            threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
            threeSale.setWorker(inviteeUser);
            threeSaleMapper.insertSelective(threeSale);
        if (worker.getId() == null)// 该用户还不存在
        {
            // 保存用户
            UserInfo inviteeUser = userInfoService.addUser(worker, worker.getSystem());
            if (inviteeUser == null)
                throw new ThreeSaleException(2, "创建用户失败");
            // 保存关系
            ThreeSale threeSale = new ThreeSale();
            threeSale.setBoss(inviter);
            threeSale.setCreateTime(java.lang.System.currentTimeMillis());
            threeSale.setExpire(ThreeSale.EXPIRE_NORMAL);
            threeSale.setState(false);
            threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
            threeSale.setWorker(inviteeUser);
            threeSaleMapper.insertSelective(threeSale);
        } else {// 是已经存在的用户
            if (worker.getId().longValue() == inviter.getId())
                throw new ThreeSaleException(4, "不能绑定自己");
        } else {// 是已经存在的用户
            if (worker.getId().longValue() == inviter.getId())
                throw new ThreeSaleException(4, "不能绑定自己");
            worker = userInfoService.selectByPKey(worker.getId());
            worker = userInfoService.selectByPKey(worker.getId());
            // 用户已经存在我们的用户库中
            if (worker.getLastLoginTime() == null || worker.getLastLoginTime() == 0L) {
                // 用户未登录
                int outOfDateCount = 0;// 过期数量
                // 查询邀请关系
                List<ThreeSale> list = listByWorkerId(worker.getId());
                if (list != null && list.size() > 0) {
                    for (ThreeSale ts : list) {
                        if (!ts.getState() && ts.getExpire() == ThreeSale.EXPIRE_BREAK) {
                            outOfDateCount++;
                        }
                    }
                    // 全部是失效状态
                    if (outOfDateCount == list.size()) {
                        // 可以确定关系
                        ThreeSale threeSale = new ThreeSale();
                        threeSale.setBoss(inviter);
                        threeSale.setCreateTime(java.lang.System.currentTimeMillis());
                        threeSale.setExpire(ThreeSale.EXPIRE_NORMAL);
                        threeSale.setState(false);
                        threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
                        threeSale.setWorker(worker);
                        threeSaleMapper.insertSelective(threeSale);
                    } else {
                        // 还存在有效的邀请,则不做处理
                    }
                } else {
                    // 用户未登录,又不存在邀请关系,不做处理
                }
            } else {
                // 已经登录,而且没有上下级关系或者上下级关系未生效,则绑定关系
                List<ThreeSale> list = threeSaleMapper.listByWorkerId(worker.getId());
                // 删除无效的
                if (list != null)
                    for (int i = 0; i < list.size(); i++) {
                        if (list.get(i).getState() != null && list.get(i).getState() == false
                                && list.get(i).getExpire() == ThreeSale.EXPIRE_BREAK) {// 过期的
                            list.remove(i);
                            i--;
                        }
                    }
                // 查询上级是否有和现在上级一样的
                if (list == null || list.size() == 0)// 尚未确立关系,建立关系
                {
                    ThreeSale ts = new ThreeSale();
                    ts.setBoss(inviter);
                    ts.setCreateTime(System.currentTimeMillis());
                    ts.setExpire(ThreeSale.EXPIRE_NORMAL);
                    ts.setState(true);
                    ts.setSucceedTime(System.currentTimeMillis());
                    ts.setWorker(worker);
                    threeSaleMapper.insertSelective(ts);
                } else {
                    if (!list.get(0).getState() && list.get(0).getExpire() == ThreeSale.EXPIRE_NORMAL
                            && list.get(0).getBoss().getId() == inviter.getId().longValue()) {// 未生效的上级和现在上级一样就生效
                        ThreeSale update = new ThreeSale(list.get(0).getId());
                        update.setState(true);
                        update.setSucceedTime(System.currentTimeMillis());
                        threeSaleMapper.updateByPrimaryKeySelective(update);
                    }
                }
            }
        }
    }
            // 用户已经存在我们的用户库中
            if (worker.getLastLoginTime() == null || worker.getLastLoginTime() == 0L) {
                // 用户未登录
                int outOfDateCount = 0;// 过期数量
                // 查询邀请关系
                List<ThreeSale> list = listByWorkerId(worker.getId());
                if (list != null && list.size() > 0) {
                    for (ThreeSale ts : list) {
                        if (!ts.getState() && ts.getExpire() == ThreeSale.EXPIRE_BREAK) {
                            outOfDateCount++;
                        }
                    }
                    // 全部是失效状态
                    if (outOfDateCount == list.size()) {
                        // 可以确定关系
                        ThreeSale threeSale = new ThreeSale();
                        threeSale.setBoss(inviter);
                        threeSale.setCreateTime(java.lang.System.currentTimeMillis());
                        threeSale.setExpire(ThreeSale.EXPIRE_NORMAL);
                        threeSale.setState(false);
                        threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
                        threeSale.setWorker(worker);
                        threeSaleMapper.insertSelective(threeSale);
                    } else {
                        // 还存在有效的邀请,则不做处理
                    }
                } else {
                    // 用户未登录,又不存在邀请关系,不做处理
                }
            } else {
                // 已经登录,而且没有上下级关系或者上下级关系未生效,则绑定关系
                List<ThreeSale> list = threeSaleMapper.listByWorkerId(worker.getId());
                // 删除无效的
                if (list != null)
                    for (int i = 0; i < list.size(); i++) {
                        if (list.get(i).getState() != null && list.get(i).getState() == false
                                && list.get(i).getExpire() == ThreeSale.EXPIRE_BREAK) {// 过期的
                            list.remove(i);
                            i--;
                        }
                    }
                // 查询上级是否有和现在上级一样的
                if (list == null || list.size() == 0)// 尚未确立关系,建立关系
                {
                    ThreeSale ts = new ThreeSale();
                    ts.setBoss(inviter);
                    ts.setCreateTime(System.currentTimeMillis());
                    ts.setExpire(ThreeSale.EXPIRE_NORMAL);
                    ts.setState(true);
                    ts.setSucceedTime(System.currentTimeMillis());
                    ts.setWorker(worker);
                    threeSaleMapper.insertSelective(ts);
                } else {
                    if (!list.get(0).getState() && list.get(0).getExpire() == ThreeSale.EXPIRE_NORMAL
                            && list.get(0).getBoss().getId() == inviter.getId().longValue()) {// 未生效的上级和现在上级一样就生效
                        ThreeSale update = new ThreeSale(list.get(0).getId());
                        update.setState(true);
                        update.setSucceedTime(System.currentTimeMillis());
                        threeSaleMapper.updateByPrimaryKeySelective(update);
                    }
                }
            }
        }
    }
    @Transactional
    public void effective(UserInfo worker) {
        List<ThreeSale> list = threeSaleMapper.listByWorkerId(worker.getId());
        if (list != null)
            for (int i = 0; i < list.size(); i++) {
                if (list.get(i).getState() != null && list.get(i).getState() == false
                        && list.get(i).getExpire() == ThreeSale.EXPIRE_NORMAL) {
                    ;
                } else {
                    list.remove(i);
                    i--;
                }
            }
        if (list.size() > 0) {
            ThreeSale oldSale = list.get(0);
    @Transactional
    public void effective(UserInfo worker) {
        List<ThreeSale> list = threeSaleMapper.listByWorkerId(worker.getId());
        if (list != null)
            for (int i = 0; i < list.size(); i++) {
                if (list.get(i).getState() != null && list.get(i).getState() == false
                        && list.get(i).getExpire() == ThreeSale.EXPIRE_NORMAL) {
                    ;
                } else {
                    list.remove(i);
                    i--;
                }
            }
        if (list.size() > 0) {
            ThreeSale oldSale = list.get(0);
            ThreeSale update = new ThreeSale(list.get(0).getId());
            update.setState(true);
            update.setSucceedTime(System.currentTimeMillis());
            threeSaleMapper.updateByPrimaryKeySelective(update);
            ThreeSale update = new ThreeSale(list.get(0).getId());
            update.setState(true);
            update.setSucceedTime(System.currentTimeMillis());
            threeSaleMapper.updateByPrimaryKeySelective(update);
            oldSale.setState(update.getState());
            oldSale.setSucceedTime(update.getSucceedTime());
            oldSale.setState(update.getState());
            oldSale.setSucceedTime(update.getSucceedTime());
            // 不以邀请人数计算等级
            // if (inviter != null)
            // reComputeUserRank(inviter.getId());
            // 添加到队列
            inviteSuccess(worker.getId(), oldSale.getBoss().getId());
        }
    }
            // 不以邀请人数计算等级
            // if (inviter != null)
            // reComputeUserRank(inviter.getId());
            // 添加到队列
            inviteSuccess(worker.getId(), oldSale.getBoss().getId());
        }
    }
    @Override
    public List<ThreeSale> listFirstTeamQuery(long start, int count, Long uid, Integer state, String startTime,
            String endTime, Integer validState) {
        return threeSaleMapper.listFirstTeamQuery(start, count, uid, state, startTime, endTime, validState);
    }
    @Override
    public List<ThreeSale> listFirstTeamQuery(long start, int count, Long uid, Integer state, String startTime,
                                              String endTime, Integer validState) {
        return threeSaleMapper.listFirstTeamQuery(start, count, uid, state, startTime, endTime, validState);
    }
    @Override
    public long countFirstTeamQuery(Long uid, Integer state, String startTime, String endTime, Integer validState) {
        return threeSaleMapper.countFirstTeamQuery(uid, state, startTime, endTime, validState);
    }
    @Override
    public long countFirstTeamQuery(Long uid, Integer state, String startTime, String endTime, Integer validState) {
        return threeSaleMapper.countFirstTeamQuery(uid, state, startTime, endTime, validState);
    }
    @Override
    public List<ThreeSale> listSecondTeamQuery(long start, int count, Long uid, Integer state, String startTime,
            String endTime, Integer validState) {
        return threeSaleMapper.listSecondTeamQuery(start, count, uid, state, startTime, endTime, validState);
    }
    @Override
    public List<ThreeSale> listSecondTeamQuery(long start, int count, Long uid, Integer state, String startTime,
                                               String endTime, Integer validState) {
        return threeSaleMapper.listSecondTeamQuery(start, count, uid, state, startTime, endTime, validState);
    }
    @Override
    public long countSecondTeamQuery(Long uid, Integer state, String startTime, String endTime, Integer validState) {
        return threeSaleMapper.countSecondTeamQuery(uid, state, startTime, endTime, validState);
    }
    @Override
    public long countSecondTeamQuery(Long uid, Integer state, String startTime, String endTime, Integer validState) {
        return threeSaleMapper.countSecondTeamQuery(uid, state, startTime, endTime, validState);
    }
    @Override
    public List<ThreeSale> listSuperiorQuery(long start, int count, Integer state, Long uid) {
        return threeSaleMapper.listSuperiorQuery(start, count, state, uid);
    }
    @Override
    public List<ThreeSale> listSuperiorQuery(long start, int count, Integer state, Long uid) {
        return threeSaleMapper.listSuperiorQuery(start, count, state, uid);
    }
    @Override
    public long countSuperiorQuery(Integer state, Long uid) {
        return threeSaleMapper.countSuperiorQuery(state, uid);
    }
    @Override
    public long countSuperiorQuery(Integer state, Long uid) {
        return threeSaleMapper.countSuperiorQuery(state, uid);
    }
    @Override
    public ThreeSale getMyBoss(Long uid) {
        return threeSaleMapper.getMyBoss(uid);
    }
    @Override
    public ThreeSale getMyBoss(Long uid) {
        return threeSaleMapper.getMyBoss(uid);
    }
    @Override
    public ThreeSale selectByPrimaryKey(Long id) {
        return threeSaleMapper.selectByPrimaryKey(id);
    }
    @Override
    public ThreeSale selectByPrimaryKey(Long id) {
        return threeSaleMapper.selectByPrimaryKey(id);
    }
    @Override
    public List<ThreeSale> listbyIdAndBossId(Long id, Long uid, Integer expire) {
        return threeSaleMapper.listbyIdAndBossId(id, uid, expire);
    }
    @Override
    public List<ThreeSale> listbyIdAndBossId(Long id, Long uid, Integer expire) {
        return threeSaleMapper.listbyIdAndBossId(id, uid, expire);
    }
    @Override
    public JSONObject getMyFirstTeam(long start, int count, Long uid) {
        List<ThreeSale> list = threeSaleMapper.listFirstTeam(start, count, uid, null);
        if (list == null) {
            list = new ArrayList<ThreeSale>();
        }
        long countTotal = threeSaleMapper.countFirstTeam(uid, null);
        return organizeTeam(countTotal, list);
    }
    @Override
    public JSONObject getMyFirstTeam(long start, int count, Long uid) {
        List<ThreeSale> list = threeSaleMapper.listFirstTeam(start, count, uid, null);
        if (list == null) {
            list = new ArrayList<ThreeSale>();
        }
        long countTotal = threeSaleMapper.countFirstTeam(uid, null);
        return organizeTeam(countTotal, list);
    }
    @Override
    public JSONObject getMySecondTeam(long start, int count, Long uid) {
        List<ThreeSale> list = threeSaleMapper.listSecondTeam(start, count, uid, null);
        if (list == null) {
            list = new ArrayList<ThreeSale>();
        }
        long countTotal = threeSaleMapper.countSecondTeam(uid, null);
        return organizeTeam(countTotal, list);
    }
    @Override
    public JSONObject getMySecondTeam(long start, int count, Long uid) {
        List<ThreeSale> list = threeSaleMapper.listSecondTeam(start, count, uid, null);
        if (list == null) {
            list = new ArrayList<ThreeSale>();
        }
        long countTotal = threeSaleMapper.countSecondTeam(uid, null);
        return organizeTeam(countTotal, list);
    }
    public JSONObject organizeTeam(long count, List<ThreeSale> list) {
    public JSONObject organizeTeam(long count, List<ThreeSale> list) {
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        JSONArray resultArray = new JSONArray();
        JSONArray resultArray = new JSONArray();
        for (ThreeSale threeSale : list) {
            JSONObject object = new JSONObject();
            SimpleDateFormat sdf = new SimpleDateFormat("MM.dd HH:mm");
            SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
            SimpleDateFormat formatYears = new SimpleDateFormat("yyyy");
        for (ThreeSale threeSale : list) {
            JSONObject object = new JSONObject();
            SimpleDateFormat sdf = new SimpleDateFormat("MM.dd HH:mm");
            SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
            SimpleDateFormat formatYears = new SimpleDateFormat("yyyy");
            Date todayTime = new Date();
            // 邀请id
            object.put("inviteId", threeSale.getId());
            Date todayTime = new Date();
            // 邀请id
            object.put("inviteId", threeSale.getId());
            // 加入队列时间
            Long createTime = threeSale.getCreateTime();
            Date inviteTime = new Date(createTime);
            object.put("inviteTime", format.format(inviteTime) + " 加入");
            // 加入队列时间
            Long createTime = threeSale.getCreateTime();
            Date inviteTime = new Date(createTime);
            object.put("inviteTime", format.format(inviteTime) + " 加入");
            String memoName = "";
            ThreeSaleExtraInfo threeSaleExtraInfo = threeSale.getThreeSaleExtraInfo();
            if (threeSaleExtraInfo != null) {
                if (!StringUtil.isNullOrEmpty(threeSaleExtraInfo.getNickname())) {
                    memoName = threeSaleExtraInfo.getNickname();
                }
            }
            object.put("memoName", memoName);
            String memoName = "";
            ThreeSaleExtraInfo threeSaleExtraInfo = threeSale.getThreeSaleExtraInfo();
            if (threeSaleExtraInfo != null) {
                if (!StringUtil.isNullOrEmpty(threeSaleExtraInfo.getNickname())) {
                    memoName = threeSaleExtraInfo.getNickname();
                }
            }
            object.put("memoName", memoName);
            String nickName = "";
            String portrait = "";
            Long lastLoginTime = null;
            String nickName = "";
            String portrait = "";
            Long lastLoginTime = null;
            UserInfo worker = threeSale.getWorker();
            if (worker != null) {
                portrait = worker.getPortrait();
                lastLoginTime = worker.getLastLoginTime();
                nickName = worker.getNickName();
            }
            object.put("nickName", nickName);
            object.put("portrait", portrait);
            UserInfo worker = threeSale.getWorker();
            if (worker != null) {
                portrait = worker.getPortrait();
                lastLoginTime = worker.getLastLoginTime();
                nickName = worker.getNickName();
            }
            object.put("nickName", nickName);
            object.put("portrait", portrait);
            int state = 0;
            String fontColor1 = "#888888";
            String fontColor2 = "#F14242";
            JSONArray array = new JSONArray();
            if (threeSale.getState()) {
                state = 1;
                if (lastLoginTime == null) {
                    lastLoginTime = threeSale.getCreateTime();
                }
                JSONObject contentJson = new JSONObject();
                contentJson.put("color", fontColor1);
                if (formatYears.format(todayTime).equals(formatYears.format(lastLoginTime))) {
                    // 本年
                    contentJson.put("content", "最近登录 " + sdf.format(lastLoginTime));
                } else {
                    // 往年
                    contentJson.put("content", "最近登录 " + format.format(lastLoginTime));
                }
                array.add(contentJson);
            int state = 0;
            String fontColor1 = "#888888";
            String fontColor2 = "#F14242";
            } else if (threeSale.getExpire() != null
                    && (threeSale.getExpire() == 1 || threeSale.getExpire().equals(1))) {
                state = 2;
                JSONObject contentJson = new JSONObject();
                contentJson.put("color", fontColor1);
                contentJson.put("content", "已经脱离邀请关系");
                array.add(contentJson);
            } else {
                state = 0;
            JSONArray array = new JSONArray();
            if (threeSale.getState()) {
                state = 1;
                if (lastLoginTime == null) {
                    lastLoginTime = threeSale.getCreateTime();
                }
                Calendar c = Calendar.getInstance();
                c.setTime(inviteTime);
                c.add(Calendar.DAY_OF_MONTH, 60);// 邀请不超过60天
                JSONObject contentJson = new JSONObject();
                contentJson.put("color", fontColor1);
                long days = (c.getTimeInMillis() - todayTime.getTime()) / (1000 * 3600 * 24);
                if (days < 0) {
                    days = 0;
                }
                if (formatYears.format(todayTime).equals(formatYears.format(lastLoginTime))) {
                    // 本年
                    contentJson.put("content", "最近登录 " + sdf.format(lastLoginTime));
                } else {
                    // 往年
                    contentJson.put("content", "最近登录 " + format.format(lastLoginTime));
                }
                JSONObject contentJson1 = new JSONObject();
                contentJson1.put("color", fontColor1);
                contentJson1.put("content", "将于");
                array.add(contentJson);
                JSONObject contentJson2 = new JSONObject();
                contentJson2.put("color", fontColor2);
                contentJson2.put("content", days + "天");
            } else if (threeSale.getExpire() != null
                    && (threeSale.getExpire() == 1 || threeSale.getExpire().equals(1))) {
                state = 2;
                JSONObject contentJson = new JSONObject();
                contentJson.put("color", fontColor1);
                contentJson.put("content", "已经脱离邀请关系");
                array.add(contentJson);
            } else {
                state = 0;
                JSONObject contentJson3 = new JSONObject();
                contentJson3.put("color", fontColor1);
                contentJson3.put("content", "后脱离邀请关系");
                Calendar c = Calendar.getInstance();
                c.setTime(inviteTime);
                c.add(Calendar.DAY_OF_MONTH, 60);// 邀请不超过60天
                array.add(contentJson1);
                array.add(contentJson2);
                array.add(contentJson3);
            }
                long days = (c.getTimeInMillis() - todayTime.getTime()) / (1000 * 3600 * 24);
                if (days < 0) {
                    days = 0;
                }
            object.put("state", state);
            object.put("recentMsg", array);
                JSONObject contentJson1 = new JSONObject();
                contentJson1.put("color", fontColor1);
                contentJson1.put("content", "将于");
            resultArray.add(object);
        }
                JSONObject contentJson2 = new JSONObject();
                contentJson2.put("color", fontColor2);
                contentJson2.put("content", days + "天");
        result.put("count", count);
        result.put("result_list", resultArray);
                JSONObject contentJson3 = new JSONObject();
                contentJson3.put("color", fontColor1);
                contentJson3.put("content", "后脱离邀请关系");
        return result;
    }
                array.add(contentJson1);
                array.add(contentJson2);
                array.add(contentJson3);
            }
    @Override
    public List<ThreeSale> listByWorkerId(Long workerId) {
        return threeSaleMapper.listByWorkerId(workerId);
    }
            object.put("state", state);
            object.put("recentMsg", array);
    @Override
    public int getSuccessRelationshipNum(Long uid) {
        return threeSaleMapper.getSuccessRelationshipNum(uid);
    }
            resultArray.add(object);
        }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void bindInviteRelationship(Long workerId, Long bossId) throws ThreeSaleException {
        if (workerId == null || bossId == null)
            throw new ThreeSaleException(1, "用户信息为空");
        //判断是否存在邀请权限
        SystemEnum system1 = userInfoService.getUserSystem(workerId);
        if (!SystemInfoUtil.hasFunctions(system1, SystemFunction.threeSale))
            throw new ThreeSaleException(2, "无法建立邀请关系");
        result.put("count", count);
        result.put("result_list", resultArray);
        SystemEnum system2 = userInfoService.getUserSystem(bossId);
        if (!SystemInfoUtil.hasFunctions(system2, SystemFunction.threeSale))
            throw new ThreeSaleException(2, "无法建立邀请关系");
        return result;
    }
        if (system1 != system2)
            throw new ThreeSaleException(2, "无法建立邀请关系");
    @Override
    public List<ThreeSale> listByWorkerId(Long workerId) {
        return threeSaleMapper.listByWorkerId(workerId);
    }
        // 新建立确定关系
        ThreeSale threeSale = new ThreeSale();
        threeSale.setBoss(new UserInfo(bossId));
        threeSale.setWorker(new UserInfo(workerId));
        threeSale.setState(true);
        threeSale.setExpire(ThreeSale.EXPIRE_NORMAL);
        threeSale.setSucceedTime(java.lang.System.currentTimeMillis());
        threeSale.setCreateTime(java.lang.System.currentTimeMillis());
        threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
        threeSaleMapper.insertSelective(threeSale);
    @Override
    public int getSuccessRelationshipNum(Long uid) {
        return threeSaleMapper.getSuccessRelationshipNum(uid);
    }
        // 邀请成功:消息、相关处理
        inviteSuccess(workerId, bossId);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void bindInviteRelationship(Long workerId, Long bossId) throws ThreeSaleException {
        if (workerId == null || bossId == null)
            throw new ThreeSaleException(1, "用户信息为空");
    /**
     * 邀请成功
     */
    @Transactional
    private void inviteSuccess(Long workerId, Long bossId) {
        // 同步粉丝消息
        teamFansInfoService.addFansInfo(workerId, bossId, new Date());
        // 新建立确定关系
        ThreeSale threeSale = new ThreeSale();
        threeSale.setBoss(new UserInfo(bossId));
        threeSale.setWorker(new UserInfo(workerId));
        threeSale.setState(true);
        threeSale.setExpire(ThreeSale.EXPIRE_NORMAL);
        threeSale.setSucceedTime(java.lang.System.currentTimeMillis());
        threeSale.setCreateTime(java.lang.System.currentTimeMillis());
        threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
        threeSaleMapper.insertSelective(threeSale);
        if (!Constant.IS_TEST) {
            UserInviteMQMsg msg = new UserInviteMQMsg(bossId, workerId, null, new Date(),
                    UserInviteMQMsg.STATE_SUCCESS);
            Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteSuccess, msg);
            message.setStartDeliverTime(java.lang.System.currentTimeMillis() + 5000);
            rocketMQManager.sendNormalMsg(message, 5000L, null);
        }
        // 邀请成功:消息、相关处理
        inviteSuccess(workerId, bossId);
    }
        executor.execute(new Runnable() {
            @Override
            public void run() {
                try { // 邀请金币
                    integralGetService.addInviteLevelOne(bossId, workerId);
                } catch (Exception e) {
                    LogHelper.error(e);
                }
    /**
     * 邀请成功
     */
    @Transactional
    private void inviteSuccess(Long workerId, Long bossId) {
        // 同步粉丝消息
        teamFansInfoService.addFansInfo(workerId, bossId, new Date());
        if (!Constant.IS_TEST) {
            UserInviteMQMsg msg = new UserInviteMQMsg(bossId, workerId, null, new Date(),
                    UserInviteMQMsg.STATE_SUCCESS);
            Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteSuccess, msg);
            message.setStartDeliverTime(java.lang.System.currentTimeMillis() + 5000);
            rocketMQManager.sendNormalMsg(message,5000L, null);
        }
                // 邀请成功消息
                try {
                    // 直接粉丝邀请成功
                    UserInfo invitee = userInfoService.selectByPKey(workerId);
                    userInviteMsgNotificationService.directInviteSuccess(bossId, invitee.getNickName(),
                            invitee.getPortrait(), new Date());
        executor.execute(new Runnable() {
            @Override
            public void run() {
                try { // 邀请金币
                    integralGetService.addInviteLevelOne(bossId, workerId);
                } catch (Exception e) {
                    LogHelper.error(e);
                }
                // 邀请成功消息
                try {
                    // 直接粉丝邀请成功
                    UserInfo invitee = userInfoService.selectByPKey(workerId);
                    userInviteMsgNotificationService.directInviteSuccess(bossId, invitee.getNickName(),
                            invitee.getPortrait(), new Date());
                    // 间接粉丝邀请成功
                    ThreeSale myBoss = threeSaleMapper.getMyBoss(bossId);
                    if (myBoss != null) {
                        UserInfo boss = userInfoService.selectByPKey(bossId);
                        userInviteMsgNotificationService.indirectInviteSuccess(myBoss.getBoss().getId(),
                                boss.getNickName(), invitee.getNickName(), invitee.getPortrait(), new Date());
                    }
                } catch (Exception e) {
                    LogHelper.error(e);
                }
            }
        });
    }
                    // 间接粉丝邀请成功
                    ThreeSale myBoss = threeSaleMapper.getMyBoss(bossId);
                    if (myBoss != null) {
                        UserInfo boss = userInfoService.selectByPKey(bossId);
                        userInviteMsgNotificationService.indirectInviteSuccess(myBoss.getBoss().getId(),
                                boss.getNickName(), invitee.getNickName(), invitee.getPortrait(), new Date());
                    }
                } catch (Exception e) {
                    LogHelper.error(e);
                }
            }
        });
    }
    /**
     * 根据邀请者查询关系
     *
     * @param workerId
     * @return
     */
    @Override
    public ThreeSale getByWorkerId(Long workerId) {
        return threeSaleMapper.getByWorkerId(workerId);
    }
    /**
     * 根据邀请者查询关系
     *
     * @param workerId
     * @return
     */
    @Override
    public ThreeSale getByWorkerId(Long workerId) {
        return threeSaleMapper.getByWorkerId(workerId);
    }
    @Override
    public ThreeSale selectByWorkerId(Long workerId) {
        return threeSaleMapper.selectSuccessByWorkerId(workerId);
    }
    @Override
    public ThreeSale selectByWorkerId(Long workerId) {
        return threeSaleMapper.selectSuccessByWorkerId(workerId);
    }
    @Override
    public ThreeSale getNearRelationByBossIdAndWorkerId(Long bossId, Long workerId) {
        return threeSaleMapper.getNearRelationByBossIdAndWorkerId(bossId, workerId);
    }
    @Override
    public ThreeSale getNearRelationByBossIdAndWorkerId(Long bossId, Long workerId) {
        return threeSaleMapper.getNearRelationByBossIdAndWorkerId(bossId, workerId);
    }
    @Override
    public List<ThreeSale> getSuccessByDate(Long bossId, Long minTime, Long maxTime) {
        return threeSaleMapper.getSuccessByDate(bossId, minTime, maxTime);
    }
    @Override
    public List<ThreeSale> getSuccessByDate(Long bossId, Long minTime, Long maxTime) {
        return threeSaleMapper.getSuccessByDate(bossId, minTime, maxTime);
    }
    @Override
    public List<ThreeSale> listFirstTeam(long start, int count, Long uid) {
        return threeSaleMapper.listFirstTeam(start, count, uid, null);
    }
    @Override
    public List<ThreeSale> listFirstTeam(long start, int count, Long uid) {
        return threeSaleMapper.listFirstTeam(start, count, uid, null);
    }
    @Override
    public List<ThreeSale> listSecondTeam(long start, int count, Long uid) {
        return threeSaleMapper.listSecondTeam(start, count, uid, null);
    }
    @Override
    public List<ThreeSale> listSecondTeam(long start, int count, Long uid) {
        return threeSaleMapper.listSecondTeam(start, count, uid, null);
    }
    @Override
    public List<ThreeSale> listFirstTeam(long start, int count, Long uid, List<Long> listId) {
        return threeSaleMapper.listFirstTeam(start, count, uid, listId);
    }
    @Override
    public List<ThreeSale> listFirstTeam(long start, int count, Long uid, List<Long> listId) {
        return threeSaleMapper.listFirstTeam(start, count, uid, listId);
    }
    @Override
    public List<ThreeSale> listSecondTeam(long start, int count, Long uid, List<Long> listId) {
        return threeSaleMapper.listSecondTeam(start, count, uid, listId);
    }
    @Override
    public List<ThreeSale> listSecondTeam(long start, int count, Long uid, List<Long> listId) {
        return threeSaleMapper.listSecondTeam(start, count, uid, listId);
    }
    @Override
    public long countFirstTeam(Long uid) {
        return threeSaleMapper.countFirstTeam(uid, null);
    }
    @Override
    public long countFirstTeam(Long uid) {
        return threeSaleMapper.countFirstTeam(uid, null);
    }
    @Override
    public long countSecondTeam(Long uid) {
        return threeSaleMapper.countSecondTeam(uid, null);
    }
    @Override
    public long countSecondTeam(Long uid) {
        return threeSaleMapper.countSecondTeam(uid, null);
    }
    @Override
    public long countFirstTeam(Long uid, List<Long> listId) {
        return threeSaleMapper.countFirstTeam(uid, listId);
    }
    @Override
    public long countFirstTeam(Long uid, List<Long> listId) {
        return threeSaleMapper.countFirstTeam(uid, listId);
    }
    @Override
    public long countSecondTeam(Long uid, List<Long> listId) {
        return threeSaleMapper.countSecondTeam(uid, listId);
    }
    @Override
    public long countSecondTeam(Long uid, List<Long> listId) {
        return threeSaleMapper.countSecondTeam(uid, listId);
    }
    @Override
    public long countFirstTeamByDate(Long uid, int dayType) {
        return threeSaleMapper.countFirstTeamByDate(uid, dayType);
    }
    @Override
    public long countFirstTeamByDate(Long uid, int dayType) {
        return threeSaleMapper.countFirstTeamByDate(uid, dayType);
    }
    @Override
    public long countSecondTeamByDate(Long uid, int dayType) {
        return threeSaleMapper.countSecondTeamByDate(uid, dayType);
    }
    @Override
    public long countSecondTeamByDate(Long uid, int dayType) {
        return threeSaleMapper.countSecondTeamByDate(uid, dayType);
    }
    @Override
    public ThreeSale selectLatestByWorkerIdAndState(Long workerId, int state) {
        return threeSaleMapper.selectLatestByWorkerIdAndState(workerId, state);
    }
    @Override
    public ThreeSale selectLatestByWorkerIdAndState(Long workerId, int state) {
        return threeSaleMapper.selectLatestByWorkerIdAndState(workerId, state);
    }
    @Override
    public ThreeSale getByWorkerIdAndTime(Long workerId, long time) {
        return threeSaleMapper.getByWorkerIdAndTime(workerId, time);
    }
    @Override
    public ThreeSale getByWorkerIdAndTime(Long workerId, long time) {
        return threeSaleMapper.getByWorkerIdAndTime(workerId, time);
    }
    @Override
    public void inviteSeparate(Long workerId, Long bossId) {
        threeSaleMapper.inviteSeparate(workerId, bossId);
    }
    @Override
    public void inviteSeparate(Long workerId, Long bossId) {
        threeSaleMapper.inviteSeparate(workerId, bossId);
    }
    @Override
    public long getTeamOrderNumByWorkerId(Long workerId) {
        return threeSaleMapper.getTeamOrderNumByWorkerId(workerId);
    }
    @Override
    public long getTeamOrderNumByWorkerId(Long workerId) {
        return threeSaleMapper.getTeamOrderNumByWorkerId(workerId);
    }
    @Override
    public List<ThreeSale> getValidWorkerIdsByTime(Long bossId, long limitTime) {
        return threeSaleMapper.getValidWorkerIdsByTime(bossId, limitTime);
    }
    @Override
    public List<ThreeSale> getValidWorkerIdsByTime(Long bossId, long limitTime) {
        return threeSaleMapper.getValidWorkerIdsByTime(bossId, limitTime);
    }
    @Override
    public List<ThreeSale> getMyBossDeepList(Long uid, int deep) {
    @Override
    public List<ThreeSale> getMyBossDeepList(Long uid, int deep) {
        List<ThreeSale> deepList = new ArrayList<>();
        ThreeSale boss = getMyBoss(uid);
        while (deep > 0 && boss != null) {
            deep--;
            deepList.add(boss);
            boss = getMyBoss(boss.getBoss().getId());
        }
        List<ThreeSale> deepList = new ArrayList<>();
        ThreeSale boss = getMyBoss(uid);
        while (deep > 0 && boss != null) {
            deep--;
            deepList.add(boss);
            boss = getMyBoss(boss.getBoss().getId());
        }
        return deepList;
    }
        return deepList;
    }
    @Override
    public List<ThreeSale> getMyBossDeepList(Long uid) {
        // TODO 需要更加简便的方式处理
        return getMyBossDeepList(uid, 100);
    }
    @Override
    public List<ThreeSale> getMyBossDeepList(Long uid) {
        // TODO 需要更加简便的方式处理
        return getMyBossDeepList(uid, 100);
    }
    @Override
    public Long getTopBoss(Long uid) {
        Long bossUid = null;
        UserInfo boss = getBoss(uid);
        while (boss != null) {
            bossUid = boss.getId();
            boss = getBoss(boss.getId());
        }
        return bossUid;
    }
    @Override
    public Long getTopBoss(Long uid) {
        Long bossUid = null;
        UserInfo boss = getBoss(uid);
        while (boss != null) {
            bossUid = boss.getId();
            boss = getBoss(boss.getId());
        }
        return bossUid;
    }
    @Override
    public List<ThreeSale> listAll(Date minTime, Date maxTime, int page, int pageSize) {
        return threeSaleMapper.listAll(minTime == null ? null : minTime.getTime(),
                maxTime == null ? null : maxTime.getTime(), (page - 1) * pageSize, pageSize);
    }
    @Override
    public List<ThreeSale> listAll(Date minTime, Date maxTime, int page, int pageSize) {
        return threeSaleMapper.listAll(minTime == null ? null : minTime.getTime(),
                maxTime == null ? null : maxTime.getTime(), (page - 1) * pageSize, pageSize);
    }
    @Override
    public long countAll(Date minTime, Date maxTime) {
        return threeSaleMapper.countAll(minTime == null ? null : minTime.getTime(),
                maxTime == null ? null : maxTime.getTime());
    }
    @Override
    public long countAll(Date minTime, Date maxTime) {
        return threeSaleMapper.countAll(minTime == null ? null : minTime.getTime(),
                maxTime == null ? null : maxTime.getTime());
    }
    @Override
    public List<Long> getAllBossId(){
        return threeSaleMapper.getAllBossId();
    }
    @Override
    public List<Long> getAllBossId() {
        return threeSaleMapper.getAllBossId();
    }
}
Diff truncated after the above file
fanli/src/main/java/com/yeshi/fanli/service/impl/user/tb/UserExtraTaoBaoInfoServiceImpl.java fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandClassShopService.java fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandInfoService.java fanli/src/main/java/com/yeshi/fanli/service/inter/config/BusinessSystemService.java fanli/src/main/java/com/yeshi/fanli/service/inter/goods/CommonTemplateContentService.java fanli/src/main/java/com/yeshi/fanli/service/inter/goods/TaoBaoGoodsBriefService.java fanli/src/main/java/com/yeshi/fanli/service/inter/lable/QualityGoodsService.java fanli/src/main/java/com/yeshi/fanli/service/inter/lable/TaoKeGoodsService.java fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java fanli/src/main/java/com/yeshi/fanli/service/inter/order/LostOrderService.java fanli/src/main/java/com/yeshi/fanli/service/inter/order/OrderHongBaoMoneyComputeService.java fanli/src/main/java/com/yeshi/fanli/service/inter/order/config/HongBaoManageService.java fanli/src/main/java/com/yeshi/fanli/service/inter/taobao/TaoBaoShopService.java fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserAccountService.java fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserGoodsStorageService.java fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserInfoService.java fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserShareGoodsRecordService.java fanli/src/main/java/com/yeshi/fanli/service/inter/user/tb/UserExtraTaoBaoInfoService.java fanli/src/main/java/com/yeshi/fanli/service/manger/order/HongBaoV2AddManager.java fanli/src/main/java/com/yeshi/fanli/service/manger/order/TeamDividentsSourceManager.java fanli/src/main/java/com/yeshi/fanli/util/SystemInfoUtil.java fanli/src/main/java/com/yeshi/fanli/util/aitaoker/AitaokerApiUtil.java fanli/src/main/java/com/yeshi/fanli/util/cache/HttpGoodsCacheManager.java fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/order/OrderDividentsMessageListener.java fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/InvitePictureChangeMessageListener.java fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/UserVIPMessageListener.java fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java fanli/src/main/resource/env-dev/mongo.properties fanli/src/main/resource/mapping/BusinessSystemMapper.xml fanli/src/main/resource/mapping/HongBaoManageMapper.xml fanli/src/main/resource/mapping/UserInfoMapper.xml fanli/src/main/resource/mapping/brand/BrandClassShopMapper.xml fanli/src/main/resource/mapping/brand/BrandInfoMapper.xml fanli/src/main/resource/mapping/order/CommonOrderMapper.xml fanli/src/main/resource/mapping/order/LostOrderMapper.xml fanli/src/main/resource/mapping/user/UserExtraTaoBaoInfoMapper.xml fanli/src/test/java/org/fanli/MyBatisProduce.java