From d341cabc39c63ba77c20a43d0074c633746ccb81 Mon Sep 17 00:00:00 2001 From: yangjun <1173114630@qq.com> Date: Wed, 5 Jun 2024 19:12:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 41 + README.md | 71 + build.bat | 3 + db/anmo.sql | 2977 +++++++++++++++++ db/sql脚本 | 25 + db/三期/artificer_partitioning_details.sql | 55 + gxdm.bat | 6 + hs_err_pid36964.log | 245 ++ pom.xml | 533 +++ run.bat | 5 + script/fb.bat | 19 + script/findps.sh | 1 + script/killJar.sh | 2 + script/run.sh | 6 + src/main/java/com/sqx/SqxApplication.java | 32 + .../com/sqx/common/annotation/SysLog.java | 19 + .../com/sqx/common/aspect/RedisAspect.java | 37 + .../com/sqx/common/aspect/SysLogAspect.java | 92 + .../sqx/common/exception/SqxException.java | 52 + .../common/exception/SqxExceptionHandler.java | 55 + .../com/sqx/common/utils/ConfigConstant.java | 12 + .../java/com/sqx/common/utils/Constant.java | 110 + .../java/com/sqx/common/utils/DateUtils.java | 157 + .../sqx/common/utils/HttpContextUtils.java | 24 + .../java/com/sqx/common/utils/IPUtils.java | 49 + .../java/com/sqx/common/utils/ListUtils.java | 54 + .../java/com/sqx/common/utils/MapUtils.java | 17 + .../java/com/sqx/common/utils/PageUtils.java | 101 + .../java/com/sqx/common/utils/QRCodeUtil.java | 175 + src/main/java/com/sqx/common/utils/Query.java | 68 + .../java/com/sqx/common/utils/RedisKeys.java | 12 + .../java/com/sqx/common/utils/RedisUtils.java | 95 + .../java/com/sqx/common/utils/Result.java | 56 + .../java/com/sqx/common/utils/ShiroUtils.java | 52 + .../sqx/common/utils/SpringContextUtils.java | 46 + .../java/com/sqx/common/validator/Assert.java | 23 + .../sqx/common/validator/ValidatorUtils.java | 14 + .../sqx/common/validator/group/AddGroup.java | 8 + .../common/validator/group/AliyunGroup.java | 8 + .../common/validator/group/QcloudGroup.java | 8 + .../common/validator/group/QiniuGroup.java | 8 + .../common/validator/group/UpdateGroup.java | 10 + .../common/websocket/WebSocketMessage.java | 39 + .../sqx/common/websocket/WebSocketServer.java | 140 + .../java/com/sqx/common/xss/HTMLFilter.java | 526 +++ .../java/com/sqx/common/xss/SQLFilter.java | 41 + .../java/com/sqx/common/xss/XssFilter.java | 46 + .../xss/XssHttpServletRequestWrapper.java | 138 + src/main/java/com/sqx/config/CorsConfig.java | 47 + .../java/com/sqx/config/FilterConfig.java | 40 + .../java/com/sqx/config/KaptchaConfig.java | 30 + .../com/sqx/config/MybatisPlusConfig.java | 22 + src/main/java/com/sqx/config/RedisConfig.java | 54 + src/main/java/com/sqx/config/ShiroConfig.java | 106 + .../java/com/sqx/config/SwaggerConfig.java | 55 + .../sqx/datasource/annotation/DataSource.java | 14 + .../datasource/aspect/DataSourceAspect.java | 61 + .../config/DynamicContextHolder.java | 47 + .../datasource/config/DynamicDataSource.java | 15 + .../config/DynamicDataSourceConfig.java | 53 + .../config/DynamicDataSourceFactory.java | 44 + .../properties/DataSourceProperties.java | 192 ++ .../DynamicDataSourceProperties.java | 22 + src/main/java/com/sqx/ffmpeg/FFmpeg.java | 388 +++ src/main/java/com/sqx/map/CommonMapUtils.java | 352 ++ .../com/sqx/modules/app/annotation/Login.java | 12 + .../sqx/modules/app/annotation/LoginUser.java | 16 + .../sqx/modules/app/config/WebMvcConfig.java | 38 + .../app/controller/AddressController.java | 43 + .../app/controller/AppUpgradeController.java | 70 + .../app/controller/UserBrowseController.java | 45 + .../UserCertificationController.java | 58 + .../app/controller/UserController.java | 632 ++++ .../app/controller/UserFollowController.java | 47 + .../UserMoneyDetailsController.java | 101 + .../app/controller/VipDetailsController.java | 48 + .../controller/app/AppAddressController.java | 105 + .../app/controller/app/AppController.java | 256 ++ .../controller/app/AppLoginController.java | 211 ++ .../app/AppUserBrowseController.java | 55 + .../app/AppUserCertificationController.java | 67 + .../app/AppUserFollowController.java | 56 + .../app/AppUserMoneyController.java | 158 + .../controller/app/AppUserVipController.java | 37 + .../app/AppVipDetailsController.java | 46 + .../com/sqx/modules/app/dao/AddressDao.java | 20 + .../java/com/sqx/modules/app/dao/AppDao.java | 20 + .../java/com/sqx/modules/app/dao/MsgDao.java | 20 + .../sqx/modules/app/dao/UserBrowseDao.java | 21 + .../modules/app/dao/UserCertificationDao.java | 20 + .../java/com/sqx/modules/app/dao/UserDao.java | 55 + .../sqx/modules/app/dao/UserFollowDao.java | 26 + .../app/dao/UserMoneyArtificerDao.java | 14 + .../com/sqx/modules/app/dao/UserMoneyDao.java | 17 + .../modules/app/dao/UserMoneyDetailsDao.java | 16 + .../com/sqx/modules/app/dao/UserVipDao.java | 9 + .../sqx/modules/app/dao/UserVisitorDao.java | 17 + .../sqx/modules/app/dao/VipDetailsDao.java | 9 + .../sqx/modules/app/dao/VipDiscountDao.java | 11 + .../com/sqx/modules/app/entity/Address.java | 74 + .../java/com/sqx/modules/app/entity/App.java | 37 + .../sqx/modules/app/entity/AppUserInfo.java | 23 + .../java/com/sqx/modules/app/entity/Msg.java | 27 + .../sqx/modules/app/entity/UserBrowse.java | 54 + .../modules/app/entity/UserCertification.java | 105 + .../sqx/modules/app/entity/UserDetails.java | 27 + .../sqx/modules/app/entity/UserEntity.java | 243 ++ .../sqx/modules/app/entity/UserFollow.java | 48 + .../com/sqx/modules/app/entity/UserMoney.java | 48 + .../app/entity/UserMoneyArtificer.java | 60 + .../modules/app/entity/UserMoneyDetails.java | 89 + .../modules/app/entity/UserMoneyResult.java | 52 + .../com/sqx/modules/app/entity/UserVip.java | 42 + .../sqx/modules/app/entity/UserVisitor.java | 41 + .../sqx/modules/app/entity/VipDetails.java | 38 + .../sqx/modules/app/entity/VipDiscount.java | 32 + .../com/sqx/modules/app/form/LoginForm.java | 20 + .../sqx/modules/app/form/RegisterForm.java | 20 + .../interceptor/AuthorizationInterceptor.java | 63 + ...oginUserHandlerMethodArgumentResolver.java | 44 + .../app/response/CourseOrderResponse.java | 25 + .../app/response/HomeMessageResponse.java | 52 + .../app/response/TakingOrderResponse.java | 20 + .../app/response/UserFollowResponse.java | 58 + .../app/response/UserMessageResponse.java | 25 + .../modules/app/service/AddressService.java | 19 + .../sqx/modules/app/service/AppService.java | 25 + .../modules/app/service/IAppleService.java | 10 + .../sqx/modules/app/service/MsgService.java | 17 + .../app/service/UserBrowseService.java | 32 + .../app/service/UserCertificationService.java | 25 + .../app/service/UserFollowService.java | 32 + .../service/UserMoneyArtificerService.java | 17 + .../app/service/UserMoneyDetailsService.java | 26 + .../modules/app/service/UserMoneyService.java | 28 + .../sqx/modules/app/service/UserService.java | 222 ++ .../modules/app/service/UserVipService.java | 12 + .../app/service/VipDetailsService.java | 23 + .../app/service/impl/AddressServiceImpl.java | 27 + .../app/service/impl/AppServiceImpl.java | 45 + .../app/service/impl/AppleServiceImpl.java | 156 + .../app/service/impl/MsgServiceImpl.java | 30 + .../service/impl/UserBrowseServiceImpl.java | 135 + .../service/impl/UserCertificationImpl.java | 267 ++ .../service/impl/UserFollowServiceImpl.java | 139 + .../impl/UserMoneyArtificerServiceImpl.java | 32 + .../impl/UserMoneyDetailsServiceImpl.java | 355 ++ .../service/impl/UserMoneyServiceImpl.java | 139 + .../app/service/impl/UserServiceImpl.java | 1275 +++++++ .../app/service/impl/UserVipServiceImpl.java | 65 + .../service/impl/VipDetailsServiceImpl.java | 27 + .../com/sqx/modules/app/utils/JwtUtils.java | 86 + .../app/utils/UserConstantInterface.java | 53 + .../com/sqx/modules/app/utils/WxPhone.java | 14 + .../apply/controller/ApplyController.java | 64 + .../controller/app/AppApplyController.java | 58 + .../com/sqx/modules/apply/dao/ApplyDao.java | 16 + .../com/sqx/modules/apply/entity/Apply.java | 77 + .../modules/apply/service/ApplyService.java | 23 + .../apply/service/impl/ApplyServiceImpl.java | 101 + .../controller/ArtificerController.java | 501 +++ .../controller/ArtificerTimeController.java | 47 + .../controller/RealNameController.java | 89 + .../app/AppArtificerController.java | 497 +++ .../app/AppArtificerIntegralController.java | 114 + .../app/AppArtificerTimeController.java | 43 + .../controller/app/AppRealNameController.java | 55 + .../app/DividedIntoDetailsController.java | 43 + .../controller/app/FundDetailsController.java | 31 + .../sqx/modules/artificer/dao/AgencyDao.java | 17 + .../modules/artificer/dao/ArtificerDao.java | 35 + .../artificer/dao/ArtificerMassageDao.java | 20 + .../artificer/dao/ArtificerTimeDao.java | 17 + .../artificer/dao/CollectArtificerDao.java | 21 + .../modules/artificer/dao/MassageTypeDao.java | 25 + .../sqx/modules/artificer/dao/OrdersDao.java | 109 + .../artificer/dao/OrdersMassageDao.java | 15 + .../modules/artificer/dao/RealNameDao.java | 16 + .../artificer/dao/UserRechargeDao.java | 37 + .../sqx/modules/artificer/entity/Agency.java | 66 + .../modules/artificer/entity/Artificer.java | 179 + .../artificer/entity/ArtificerMassage.java | 136 + .../artificer/entity/ArtificerTime.java | 59 + .../artificer/entity/Certification.java | 98 + .../artificer/entity/CollectArtificer.java | 51 + .../artificer/entity/FundDetailsResult.java | 44 + .../modules/artificer/entity/MassageType.java | 137 + .../sqx/modules/artificer/entity/Orders.java | 363 ++ .../artificer/entity/OrdersMassage.java | 45 + .../sqx/modules/artificer/entity/Period.java | 59 + .../entity/UserMoneyArtificerDetails.java | 49 + .../artificer/entity/UserRecharge.java | 54 + .../artificer/service/AgencyService.java | 15 + .../service/AppArtificerIntegralService.java | 19 + .../service/ArtificerMassageService.java | 23 + .../artificer/service/ArtificerService.java | 40 + .../service/ArtificerTimeService.java | 17 + .../service/CollectArtificerService.java | 19 + .../artificer/service/MassageTypeService.java | 19 + .../service/OrdersMassageService.java | 11 + .../artificer/service/OrdersService.java | 100 + .../artificer/service/RealNameService.java | 25 + .../service/impl/AgencyServiceImpl.java | 64 + .../impl/AppArtificerIntegralServiceImpl.java | 536 +++ .../impl/ArtificerMassageServiceImpl.java | 100 + .../service/impl/ArtificerServiceImpl.java | 425 +++ .../impl/ArtificerTimeServiceImpl.java | 102 + .../impl/CollectArtificerServiceImpl.java | 254 ++ .../service/impl/MassageTypeServiceImpl.java | 58 + .../impl/OrdersMassageServiceImpl.java | 18 + .../service/impl/OrdersServiceImpl.java | 2646 +++++++++++++++ .../service/impl/RealNameServiceImpl.java | 259 ++ .../com/sqx/modules/artificer/vo/HomeVO.java | 82 + .../modules/artificer/vo/UserArtificerVO.java | 27 + .../banner/controller/ActivityController.java | 97 + .../banner/controller/BannerController.java | 86 + .../controller/app/AppBannerController.java | 38 + .../sqx/modules/banner/dao/ActivityDao.java | 19 + .../com/sqx/modules/banner/dao/BannerDao.java | 27 + .../sqx/modules/banner/entity/Activity.java | 29 + .../com/sqx/modules/banner/entity/Banner.java | 67 + .../banner/service/ActivityService.java | 27 + .../modules/banner/service/BannerService.java | 30 + .../service/impl/ActivityServiceImpl.java | 65 + .../service/impl/BannerServiceImpl.java | 95 + .../chat/controller/ChatController.java | 50 + .../controller/app/AppChatController.java | 65 + .../chat/controller/app/AppChatSocket.java | 181 + .../sqx/modules/chat/dao/ChatContentDao.java | 25 + .../modules/chat/dao/ChatConversationDao.java | 22 + .../sqx/modules/chat/entity/ChatContent.java | 52 + .../modules/chat/entity/ChatConversation.java | 47 + .../chat/service/ChatContentService.java | 17 + .../chat/service/ChatConversationService.java | 20 + .../service/impl/ChatContentServiceImpl.java | 39 + .../impl/ChatConversationServiceImpl.java | 75 + .../controller/ChatsContentController.java | 55 + .../chats/controller/ChatsController.java | 69 + .../modules/chats/controller/WebSocket.java | 164 + .../controller/app/AppChatsController.java | 35 + .../com/sqx/modules/chats/entity/Chats.java | 44 + .../modules/chats/entity/ChatsContent.java | 39 + .../respository/ChatContentRepository.java | 42 + .../chats/respository/ChatRepository.java | 77 + .../chats/service/ChatsContentService.java | 39 + .../service/ChatsContentServiceImpl.java | 140 + .../modules/chats/service/ChatsService.java | 43 + .../chats/service/ChatsServiceImpl.java | 134 + .../com/sqx/modules/chats/utils/DateUtil.java | 547 +++ .../chats/utils/DescribeException.java | 34 + .../modules/chats/utils/ExceptionEnum.java | 49 + .../com/sqx/modules/chats/utils/Result.java | 51 + .../sqx/modules/chats/utils/ResultUtil.java | 56 + .../common/controller/CommonController.java | 90 + .../controller/app/AppCommonController.java | 64 + .../ArtificerPartitioningDetailsMapper.java | 23 + .../sqx/modules/common/dao/CommonInfoDao.java | 24 + .../entity/ArtificerPartitioningDetails.java | 52 + .../sqx/modules/common/entity/CommonInfo.java | 33 + .../common/service/CommonInfoService.java | 50 + .../service/impl/CommonInfoServiceImpl.java | 87 + .../controller/ConsortiaController.java | 87 + .../app/AppConsortiaController.java | 42 + .../modules/consortia/dao/ConsortiaDao.java | 19 + .../modules/consortia/entity/Consortia.java | 94 + .../consortia/service/ConsortiaService.java | 29 + .../service/impl/ConsortiaServiceImpl.java | 133 + .../controller/CouponCardController.java | 96 + .../coupon/controller/CouponController.java | 56 + .../controller/CouponIssueController.java | 58 + .../controller/CouponUserController.java | 46 + .../app/AppCouponCardController.java | 39 + .../app/AppCouponIssueController.java | 39 + .../app/AppCouponUserController.java | 59 + .../sqx/modules/coupon/dao/CouponCardDao.java | 11 + .../modules/coupon/dao/CouponCardTypeDao.java | 11 + .../com/sqx/modules/coupon/dao/CouponDao.java | 18 + .../modules/coupon/dao/CouponIssueDao.java | 14 + .../sqx/modules/coupon/dao/CouponUserDao.java | 32 + .../com/sqx/modules/coupon/entity/Coupon.java | 45 + .../sqx/modules/coupon/entity/CouponCard.java | 57 + .../modules/coupon/entity/CouponCardType.java | 60 + .../modules/coupon/entity/CouponIssue.java | 93 + .../sqx/modules/coupon/entity/CouponUser.java | 77 + .../coupon/service/CouponCardService.java | 20 + .../coupon/service/CouponCardTypeService.java | 11 + .../coupon/service/CouponIssueService.java | 15 + .../modules/coupon/service/CouponService.java | 23 + .../coupon/service/CouponUserService.java | 25 + .../service/impl/CouponCardServiceImpl.java | 192 ++ .../impl/CouponCardTypeServiceImpl.java | 50 + .../service/impl/CouponIssueServiceImpl.java | 132 + .../service/impl/CouponServiceImpl.java | 85 + .../service/impl/CouponUserServiceImpl.java | 135 + .../modules/file/AliFileUploadController.java | 300 ++ .../modules/file/utils/DescribeException.java | 34 + .../sqx/modules/file/utils/ExceptionEnum.java | 49 + .../modules/file/utils/FileUploadUtils.java | 238 ++ .../com/sqx/modules/file/utils/FileUtils.java | 137 + .../com/sqx/modules/file/utils/ImageUtil.java | 251 ++ .../com/sqx/modules/file/utils/Md5Utils.java | 140 + .../sqx/modules/file/utils/MimeTypeUtils.java | 59 + .../controller/HelpWordController.java | 112 + .../controller/app/AppHelpWordController.java | 48 + .../helpCenter/dao/HelpClassifyDao.java | 12 + .../modules/helpCenter/dao/HelpWordDao.java | 12 + .../helpCenter/entity/HelpClassify.java | 60 + .../modules/helpCenter/entity/HelpWord.java | 51 + .../service/HelpClassifyService.java | 10 + .../helpCenter/service/HelpWordService.java | 11 + .../service/impl/HelpClassifyServiceImpl.java | 23 + .../service/impl/HelpWordServiceImpl.java | 23 + .../invite/controller/InviteController.java | 143 + .../controller/app/AppInviteController.java | 98 + .../com/sqx/modules/invite/dao/InviteDao.java | 41 + .../modules/invite/dao/InviteMoneyDao.java | 23 + .../com/sqx/modules/invite/entity/Invite.java | 50 + .../modules/invite/entity/InviteMoney.java | 44 + .../invite/service/InviteMoneyService.java | 20 + .../modules/invite/service/InviteService.java | 33 + .../service/impl/InviteMoneyServiceImpl.java | 42 + .../service/impl/InviteServiceImpl.java | 196 ++ .../com/sqx/modules/map/MapWebSocket.java | 203 ++ .../controller/MaterialController.java | 138 + .../controller/MaterialRecordController.java | 44 + .../controller/app/AppMaterialController.java | 30 + .../material/dao/MaterialArtificerMapper.java | 20 + .../modules/material/dao/MaterialMapper.java | 77 + .../material/dao/MaterialMassageMapper.java | 20 + .../material/dao/MaterialRecordMapper.java | 25 + .../sqx/modules/material/entity/Material.java | 74 + .../material/entity/MaterialArtificer.java | 82 + .../entity/MaterialArtificerResult.java | 42 + .../material/entity/MaterialMassage.java | 77 + .../entity/MaterialMassageResult.java | 46 + .../material/entity/MaterialRecord.java | 58 + .../service/MaterialArtificerService.java | 23 + .../service/MaterialMassageService.java | 19 + .../service/MaterialRecordService.java | 18 + .../material/service/MaterialService.java | 78 + .../impl/MaterialArtificerServiceImpl.java | 171 + .../impl/MaterialMassageServiceImpl.java | 53 + .../impl/MaterialRecordServiceImpl.java | 44 + .../service/impl/MaterialServiceImpl.java | 201 ++ .../member/controller/MemberController.java | 56 + .../controller/app/AppMemberController.java | 27 + .../com/sqx/modules/member/dao/MemberDao.java | 12 + .../com/sqx/modules/member/entity/Member.java | 42 + .../modules/member/service/MemberService.java | 19 + .../service/impl/MemberServiceImpl.java | 56 + .../controller/ActivityMessageController.java | 84 + .../controller/MessageAudioController.java | 67 + .../message/controller/MessageController.java | 193 ++ .../controller/app/AppMessageController.java | 111 + .../message/dao/ActivityMessageInfoDao.java | 28 + .../message/dao/MessageInfoAudioDao.java | 28 + .../modules/message/dao/MessageInfoDao.java | 31 + .../message/entity/ActivityMessageInfo.java | 49 + .../modules/message/entity/MessageInfo.java | 91 + .../message/entity/MessageInfoAudio.java | 43 + .../service/ActivityMessageService.java | 34 + .../message/service/MessageAudioService.java | 41 + .../message/service/MessageService.java | 44 + .../impl/ActivityMessageServiceImpl.java | 94 + .../service/impl/MessageAudioServiceImpl.java | 175 + .../service/impl/MessageServiceImpl.java | 239 ++ .../sqx/modules/monitor/MonitorWebSocket.java | 402 +++ .../modules/pay/config/AliPayConstants.java | 44 + .../com/sqx/modules/pay/config/WXConfig.java | 89 + .../pay/controller/CashController.java | 520 +++ .../pay/controller/PayClassifyController.java | 80 + .../pay/controller/app/AliPayController.java | 994 ++++++ .../app/ApiWeiXinPayController.java | 307 ++ .../pay/controller/app/AppCashController.java | 71 + .../app/AppPayClassifyController.java | 49 + .../com/sqx/modules/pay/dao/CashOutDao.java | 52 + .../sqx/modules/pay/dao/PayClassifyDao.java | 16 + .../sqx/modules/pay/dao/PayDetailsDao.java | 48 + .../modules/pay/entity/AliPayParamModel.java | 33 + .../pay/entity/AliPayWithdrawModel.java | 51 + .../com/sqx/modules/pay/entity/CashOut.java | 127 + .../sqx/modules/pay/entity/PayClassify.java | 56 + .../sqx/modules/pay/entity/PayDetails.java | 80 + .../modules/pay/service/CashOutService.java | 52 + .../pay/service/PayClassifyService.java | 11 + .../pay/service/PayDetailsService.java | 27 + .../sqx/modules/pay/service/WxService.java | 35 + .../pay/service/impl/CashOutServiceImpl.java | 393 +++ .../service/impl/PayClassifyServiceImpl.java | 23 + .../service/impl/PayDetailsServiceImpl.java | 82 + .../pay/service/impl/WxServiceImpl.java | 1197 +++++++ .../risk/controller/RiskController.java | 54 + .../controller/app/AppRiskController.java | 56 + .../com/sqx/modules/risk/dao/RiskDao.java | 19 + .../com/sqx/modules/risk/entity/Risk.java | 56 + .../sqx/modules/risk/service/RiskService.java | 15 + .../risk/service/impl/RiskServiceImpl.java | 52 + .../search/Response/SearchResponse.java | 22 + .../search/controller/SearchController.java | 46 + .../controller/app/AppSearchController.java | 46 + .../sqx/modules/search/dao/AppSearchDao.java | 26 + .../com/sqx/modules/search/dao/SearchDao.java | 9 + .../com/sqx/modules/search/entity/Search.java | 35 + .../search/service/AppSearchService.java | 17 + .../modules/search/service/SearchService.java | 11 + .../service/impl/AppSearchServiceImpl.java | 106 + .../service/impl/SearchServiceImpl.java | 31 + .../shopping/controller/AdvertController.java | 52 + .../controller/CouponsController.java | 64 + .../shopping/controller/GoodsController.java | 205 ++ .../controller/GoodsTypeController.java | 67 + .../shopping/controller/OrdersController.java | 195 ++ .../controller/OrdersRelationController.java | 60 + .../shopping/controller/OrdersTask.java | 57 + .../controller/SelfActivityController.java | 78 + .../controller/SelfBannerController.java | 52 + .../controller/SelfGoodsBrandController.java | 56 + .../SelfGoodsCommentController.java | 76 + .../controller/SelfGoodsRuleController.java | 49 + .../SelfGoodsVirtualController.java | 57 + .../SelfMerchantApplyController.java | 71 + .../controller/SelfUserCollectController.java | 54 + .../modules/shopping/controller/SkuUtil.java | 48 + .../controller/app/AppAdvertController.java | 34 + .../controller/app/AppCouponsController.java | 47 + .../controller/app/AppGoodsController.java | 148 + .../app/AppGoodsTypeController.java | 49 + .../controller/app/AppOrdersController.java | 130 + .../app/AppOrdersRelationController.java | 61 + .../app/AppSelfActivityController.java | 49 + .../app/AppSelfAliPayController.java | 378 +++ .../app/AppSelfBannerController.java | 33 + .../app/AppSelfGoodsBrandController.java | 37 + .../app/AppSelfGoodsCommentController.java | 62 + .../app/AppSelfGoodsRuleController.java | 49 + .../app/AppSelfGoodsVirtualController.java | 57 + .../app/AppSelfMerchantApplyController.java | 71 + .../app/AppSelfUserCollectController.java | 54 + .../app/AppSelfWXPayController.java | 115 + .../shopping/dao/AdvertJpaRepository.java | 11 + .../shopping/dao/AdvertRepository.java | 9 + .../shopping/dao/CouponsJpaRepository.java | 20 + .../shopping/dao/CouponsRepository.java | 9 + .../dao/CouponsUserJpaRepository.java | 20 + .../shopping/dao/CouponsUserRepository.java | 9 + .../shopping/dao/GoodsJpaRepository.java | 21 + .../modules/shopping/dao/GoodsRepository.java | 9 + .../shopping/dao/GoodsTypeJpaRepository.java | 15 + .../shopping/dao/GoodsTypeRepository.java | 24 + .../shopping/dao/OrdersJpaRepository.java | 31 + .../dao/OrdersRelationJpaRepository.java | 22 + .../dao/OrdersRelationRepository.java | 46 + .../shopping/dao/OrdersRepository.java | 29 + .../dao/SelfActivityJpaRepository.java | 13 + .../shopping/dao/SelfActivityRepository.java | 14 + .../shopping/dao/SelfBannerJpaRepository.java | 11 + .../shopping/dao/SelfBannerRepository.java | 9 + .../dao/SelfGoodsAttrJpaRepository.java | 24 + .../shopping/dao/SelfGoodsAttrRepository.java | 18 + .../dao/SelfGoodsAttrValueJpaRepository.java | 28 + .../dao/SelfGoodsAttrValueRepository.java | 18 + .../dao/SelfGoodsBrandJpaRepository.java | 22 + .../dao/SelfGoodsBrandRepository.java | 9 + .../dao/SelfGoodsCommentJpaRepository.java | 28 + .../dao/SelfGoodsCommentRepository.java | 9 + .../dao/SelfGoodsRuleJpaRepository.java | 16 + .../shopping/dao/SelfGoodsRuleRepository.java | 9 + .../dao/SelfGoodsRuleValueJpaRepository.java | 20 + .../dao/SelfGoodsRuleValueRepository.java | 9 + .../dao/SelfGoodsSkuJpaRepository.java | 45 + .../shopping/dao/SelfGoodsSkuRepository.java | 9 + .../dao/SelfGoodsVirtualJpaRepository.java | 55 + .../dao/SelfGoodsVirtualRepository.java | 9 + .../dao/SelfMerchantApplyJpaRepository.java | 22 + .../dao/SelfMerchantApplyRepository.java | 8 + .../dao/SelfOrdersRemindJpaRepository.java | 25 + .../dao/SelfOrdersRemindRepository.java | 11 + .../dao/SelfUserCollectJpaRepository.java | 26 + .../dao/SelfUserCollectRepository.java | 9 + .../sqx/modules/shopping/entity/Adverti.java | 51 + .../sqx/modules/shopping/entity/Coupons.java | 112 + .../modules/shopping/entity/CouponsUser.java | 91 + .../modules/shopping/entity/GoodsType.java | 29 + .../shopping/entity/GoodsTypeResult.java | 16 + .../modules/shopping/entity/SelfActivity.java | 73 + .../modules/shopping/entity/SelfBanner.java | 61 + .../modules/shopping/entity/SelfGoods.java | 77 + .../shopping/entity/SelfGoodsAttr.java | 25 + .../shopping/entity/SelfGoodsAttrValue.java | 25 + .../shopping/entity/SelfGoodsBrand.java | 22 + .../shopping/entity/SelfGoodsComment.java | 47 + .../shopping/entity/SelfGoodsRule.java | 23 + .../shopping/entity/SelfGoodsRuleValue.java | 22 + .../modules/shopping/entity/SelfGoodsSku.java | 32 + .../shopping/entity/SelfGoodsVirtual.java | 52 + .../shopping/entity/SelfMerchantApply.java | 77 + .../shopping/entity/SelfOrderRelation.java | 51 + .../shopping/entity/SelfOrderRemind.java | 23 + .../modules/shopping/entity/SelfOrders.java | 118 + .../shopping/entity/SelfUserCollect.java | 32 + .../shopping/service/AdvertService.java | 22 + .../shopping/service/CouponsService.java | 36 + .../shopping/service/CouponsUserService.java | 22 + .../shopping/service/GoodsService.java | 80 + .../shopping/service/GoodsTypeService.java | 28 + .../service/OrdersRelationService.java | 43 + .../shopping/service/OrdersService.java | 88 + .../shopping/service/SelfAliPayService.java | 7 + .../service/SelfGoodsAttrService.java | 21 + .../service/SelfGoodsBrandService.java | 26 + .../service/SelfGoodsCommentService.java | 35 + .../service/SelfGoodsRuleService.java | 25 + .../shopping/service/SelfGoodsSkuService.java | 17 + .../service/SelfGoodsVirtualService.java | 29 + .../service/SelfMerchantApplyService.java | 45 + .../service/SelfUserCollectService.java | 26 + .../shopping/service/SelfWXService.java | 27 + .../shopping/service/SlefBannerService.java | 22 + .../service/impl/AdvertServiceImpl.java | 48 + .../service/impl/CouponsServiceImpl.java | 158 + .../service/impl/CouponsUserServiceImpl.java | 52 + .../service/impl/GoodsTypeServiceImpl.java | 117 + .../impl/OrdersRelationServiceImpl.java | 208 ++ .../impl/SelUserCollectServiceImpl.java | 93 + .../service/impl/SelfAliPayServiceImpl.java | 45 + .../service/impl/SelfBannerServiceImpl.java | 48 + .../impl/SelfGoodsAttrServiceImpl.java | 69 + .../impl/SelfGoodsBrandServiceImpl.java | 67 + .../impl/SelfGoodsCommentServiceImpl.java | 144 + .../impl/SelfGoodsRuleServiceImpl.java | 85 + .../service/impl/SelfGoodsServiceImpl.java | 705 ++++ .../service/impl/SelfGoodsSkuServiceImpl.java | 39 + .../impl/SelfGoodsVirtualServiceImpl.java | 106 + .../impl/SelfMerchantApplyServiceImpl.java | 131 + .../service/impl/SelfOrdersServiceImpl.java | 968 ++++++ .../service/impl/SelfWXServiceImpl.java | 341 ++ .../modules/shopping/utils/AmountCalUtil.java | 62 + .../sqx/modules/shopping/utils/DateUtil.java | 439 +++ .../modules/shopping/utils/ExceptionEnum.java | 49 + .../sqx/modules/shopping/utils/Result.java | 51 + .../modules/shopping/utils/ResultUtil.java | 64 + .../modules/shopping/utils/WXConfigUtil.java | 78 + .../shopping/utils/excel/ExcelData.java | 34 + .../shopping/utils/excel/ExcelUtils.java | 171 + .../utils/excel/ExportExcelUtils.java | 209 ++ .../sys/controller/AbstractController.java | 22 + .../sys/controller/SysConfigController.java | 89 + .../sys/controller/SysDictController.java | 90 + .../sys/controller/SysLogController.java | 39 + .../sys/controller/SysLoginController.java | 91 + .../sys/controller/SysMenuController.java | 183 + .../sys/controller/SysRoleController.java | 117 + .../sys/controller/SysUserController.java | 145 + .../sys/controller/app/AppDictController.java | 35 + .../sqx/modules/sys/dao/SysCaptchaDao.java | 14 + .../com/sqx/modules/sys/dao/SysConfigDao.java | 26 + .../com/sqx/modules/sys/dao/SysDictDao.java | 14 + .../com/sqx/modules/sys/dao/SysLogDao.java | 15 + .../com/sqx/modules/sys/dao/SysMenuDao.java | 27 + .../com/sqx/modules/sys/dao/SysRoleDao.java | 20 + .../sqx/modules/sys/dao/SysRoleMenuDao.java | 25 + .../com/sqx/modules/sys/dao/SysUserDao.java | 32 + .../sqx/modules/sys/dao/SysUserRoleDao.java | 26 + .../sqx/modules/sys/dao/SysUserTokenDao.java | 16 + .../modules/sys/entity/SysCaptchaEntity.java | 28 + .../modules/sys/entity/SysConfigEntity.java | 21 + .../sqx/modules/sys/entity/SysDictEntity.java | 58 + .../sqx/modules/sys/entity/SysLogEntity.java | 36 + .../sqx/modules/sys/entity/SysMenuEntity.java | 76 + .../sqx/modules/sys/entity/SysRoleEntity.java | 51 + .../modules/sys/entity/SysRoleMenuEntity.java | 31 + .../sqx/modules/sys/entity/SysUserEntity.java | 75 + .../modules/sys/entity/SysUserRoleEntity.java | 31 + .../sys/entity/SysUserTokenEntity.java | 31 + .../sqx/modules/sys/form/PasswordForm.java | 20 + .../sqx/modules/sys/form/SysLoginForm.java | 17 + .../sqx/modules/sys/oauth2/OAuth2Filter.java | 101 + .../sqx/modules/sys/oauth2/OAuth2Realm.java | 70 + .../sqx/modules/sys/oauth2/OAuth2Token.java | 26 + .../modules/sys/oauth2/TokenGenerator.java | 43 + .../sqx/modules/sys/redis/SysConfigRedis.java | 36 + .../sqx/modules/sys/service/ShiroService.java | 25 + .../sys/service/SysCaptchaService.java | 26 + .../modules/sys/service/SysConfigService.java | 51 + .../modules/sys/service/SysDictService.java | 15 + .../modules/sys/service/SysLogService.java | 19 + .../modules/sys/service/SysMenuService.java | 43 + .../sys/service/SysRoleMenuService.java | 28 + .../modules/sys/service/SysRoleService.java | 30 + .../sys/service/SysUserRoleService.java | 27 + .../modules/sys/service/SysUserService.java | 57 + .../sys/service/SysUserTokenService.java | 25 + .../sys/service/impl/ShiroServiceImpl.java | 60 + .../service/impl/SysCaptchaServiceImpl.java | 62 + .../service/impl/SysConfigServiceImpl.java | 96 + .../sys/service/impl/SysDictServiceImpl.java | 30 + .../sys/service/impl/SysLogServiceImpl.java | 31 + .../sys/service/impl/SysMenuServiceImpl.java | 99 + .../service/impl/SysRoleMenuServiceImpl.java | 51 + .../sys/service/impl/SysRoleServiceImpl.java | 113 + .../service/impl/SysUserRoleServiceImpl.java | 49 + .../sys/service/impl/SysUserServiceImpl.java | 136 + .../service/impl/SysUserTokenServiceImpl.java | 66 + .../taking/controller/GameController.java | 77 + .../OrderTakingCommentController.java | 50 + .../controller/app/AppGameController.java | 25 + .../app/AppOrderTakingCommentController.java | 87 + .../com/sqx/modules/taking/dao/GameDao.java | 9 + .../taking/dao/OrderTakingCommentDao.java | 34 + .../taking/entity/CommentFabulous.java | 41 + .../com/sqx/modules/taking/entity/Game.java | 41 + .../modules/taking/entity/TakingCommnt.java | 68 + .../taking/response/MyReleaseResponse.java | 57 + .../taking/response/OrderTakingResponse.java | 79 + .../response/TakingCommentResponse.java | 59 + .../response/TakingDetailsResponse.java | 99 + .../taking/response/TakingResponse.java | 96 + .../modules/taking/service/GameService.java | 55 + .../service/OrderTakingCommentService.java | 39 + .../taking/service/impl/GameServiceImpl.java | 112 + .../impl/OrderTakingCommentServiceImpl.java | 163 + .../trip/controller/TripController.java | 72 + .../controller/app/AppTripController.java | 35 + .../com/sqx/modules/trip/dao/TripDao.java | 14 + .../com/sqx/modules/trip/entity/Trip.java | 66 + .../sqx/modules/trip/service/TripService.java | 12 + .../trip/service/impl/TripServiceImpl.java | 27 + .../sqx/modules/utils/AliPayOrderUtil.java | 133 + .../com/sqx/modules/utils/AmountCalUtils.java | 76 + .../com/sqx/modules/utils/AppNotifyUtil.java | 34 + .../com/sqx/modules/utils/Base64Utils.java | 313 ++ .../sqx/modules/utils/CertificateUtils.java | 892 +++++ .../modules/utils/CusAccessObjectUtil.java | 88 + .../java/com/sqx/modules/utils/FileUtils.java | 63 + .../com/sqx/modules/utils/HttpClientUtil.java | 266 ++ .../java/com/sqx/modules/utils/HttpUtil.java | 223 ++ .../sqx/modules/utils/InvitationCodeUtil.java | 55 + .../com/sqx/modules/utils/LonLatUtil.java | 25 + .../java/com/sqx/modules/utils/MD5Util.java | 162 + .../com/sqx/modules/utils/PeriodUtil.java | 127 + .../sqx/modules/utils/SenInfoCheckUtil.java | 392 +++ .../java/com/sqx/modules/utils/Template.java | 20 + .../com/sqx/modules/utils/TemplateParam.java | 21 + .../java/com/sqx/modules/utils/TreeUtils.java | 76 + .../sqx/modules/utils/VerifyIdCardUtils.java | 180 + .../com/sqx/modules/utils/WXConfigUtil.java | 78 + .../java/com/sqx/modules/utils/WxMssVo.java | 42 + .../modules/utils/address/AddressUtil.java | 57 + .../modules/utils/address/WSSsdrAddress.java | 34 + .../sqx/modules/utils/excel/ExcelData.java | 34 + .../sqx/modules/utils/excel/ExcelUtils.java | 171 + .../modules/utils/excel/ExportExcelUtils.java | 209 ++ src/main/java/com/sqx/ws/BaseInfoModel.java | 30 + .../java/com/sqx/ws/BaseModelEncoder.java | 41 + .../java/com/sqx/ws/BaseResponseMessage.java | 13 + src/main/java/com/sqx/ws/HashMapEncoder.java | 51 + src/main/resources/application-prod.yml | 55 + src/main/resources/application-test.yml | 55 + src/main/resources/application.yml | 73 + src/main/resources/banner/banner.jpg | Bin 0 -> 35981 bytes src/main/resources/mapper/app/AddressDao.xml | 12 + src/main/resources/mapper/app/AppDao.xml | 12 + src/main/resources/mapper/app/MsgDao.xml | 15 + .../resources/mapper/app/UserBrowseDao.xml | 47 + .../mapper/app/UserCertificationDao.xml | 35 + src/main/resources/mapper/app/UserDao.xml | 403 +++ .../resources/mapper/app/UserFollowDao.xml | 54 + .../mapper/app/UserMoneyArtificerDao.xml | 19 + .../resources/mapper/app/UserMoneyDao.xml | 30 + .../mapper/app/UserMoneyDetailsDao.xml | 22 + .../resources/mapper/app/UserVisitorDao.xml | 32 + .../mapper/artificer/ArtificerDao.xml | 179 + .../artificer/ArtificerMassageMapper.xml | 35 + .../mapper/artificer/CollectArtificerDao.xml | 30 + .../mapper/artificer/MassageTypeDao.xml | 147 + .../resources/mapper/artificer/OrdersDao.xml | 986 ++++++ .../mapper/artificer/RealNameMapper.xml | 22 + .../mapper/artificer/UserRechargeDao.xml | 43 + .../resources/mapper/banner/ActivityDao.xml | 14 + .../resources/mapper/banner/BannerDao.xml | 26 + .../resources/mapper/chat/ChatContentDao.xml | 29 + .../mapper/chat/ChatConversationDao.xml | 73 + .../resources/mapper/common/CommonInfoDao.xml | 17 + .../mapper/consortia/ConsortiaMapper.xml | 40 + .../mapper/coupon/CouponIssueMapper.xml | 14 + .../mapper/coupon/TbCouponMapper.xml | 19 + .../mapper/coupon/TbCouponUserMapper.xml | 64 + .../resources/mapper/invite/InviteDao.xml | 98 + .../mapper/invite/InviteMoneyDao.xml | 26 + .../resources/mapper/job/ScheduleJobDao.xml | 14 + .../mapper/job/ScheduleJobLogDao.xml | 6 + .../material/MaterialArtificerMapper.xml | 23 + .../mapper/material/MaterialMapper.xml | 164 + .../mapper/material/MaterialMassageMapper.xml | 23 + .../mapper/material/MaterialRecordMapper.xml | 38 + .../mapper/message/ActivityMessageInfoDao.xml | 29 + .../mapper/message/MessageInfoAudioDao.xml | 6 + .../mapper/message/MessageInfoDao.xml | 79 + src/main/resources/mapper/oss/SysOssDao.xml | 7 + src/main/resources/mapper/pay/CashDao.xml | 212 ++ .../resources/mapper/pay/PayClassifyDao.xml | 11 + .../resources/mapper/pay/PayDetailsDao.xml | 179 + src/main/resources/mapper/risk/RiskDao.xml | 67 + .../resources/mapper/search/AppSearchDao.xml | 14 + .../resources/mapper/sys/SysConfigDao.xml | 15 + src/main/resources/mapper/sys/SysDictDao.xml | 7 + src/main/resources/mapper/sys/SysLogDao.xml | 6 + src/main/resources/mapper/sys/SysMenuDao.xml | 14 + src/main/resources/mapper/sys/SysRoleDao.xml | 10 + .../resources/mapper/sys/SysRoleMenuDao.xml | 17 + src/main/resources/mapper/sys/SysUserDao.xml | 24 + .../resources/mapper/sys/SysUserRoleDao.xml | 16 + .../resources/mapper/sys/SysUserTokenDao.xml | 9 + .../mapper/taking/OrderTakingCommentDao.xml | 129 + .../mapper/taking/OrderTakingDao.xml | 338 ++ src/main/resources/weixin/apiclient_cert.p12 | Bin 0 -> 4918 bytes tbdm.bat | 3 + 717 files changed, 61155 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 build.bat create mode 100644 db/anmo.sql create mode 100644 db/sql脚本 create mode 100644 db/三期/artificer_partitioning_details.sql create mode 100644 gxdm.bat create mode 100644 hs_err_pid36964.log create mode 100644 pom.xml create mode 100644 run.bat create mode 100644 script/fb.bat create mode 100644 script/findps.sh create mode 100644 script/killJar.sh create mode 100644 script/run.sh create mode 100644 src/main/java/com/sqx/SqxApplication.java create mode 100644 src/main/java/com/sqx/common/annotation/SysLog.java create mode 100644 src/main/java/com/sqx/common/aspect/RedisAspect.java create mode 100644 src/main/java/com/sqx/common/aspect/SysLogAspect.java create mode 100644 src/main/java/com/sqx/common/exception/SqxException.java create mode 100644 src/main/java/com/sqx/common/exception/SqxExceptionHandler.java create mode 100644 src/main/java/com/sqx/common/utils/ConfigConstant.java create mode 100644 src/main/java/com/sqx/common/utils/Constant.java create mode 100644 src/main/java/com/sqx/common/utils/DateUtils.java create mode 100644 src/main/java/com/sqx/common/utils/HttpContextUtils.java create mode 100644 src/main/java/com/sqx/common/utils/IPUtils.java create mode 100644 src/main/java/com/sqx/common/utils/ListUtils.java create mode 100644 src/main/java/com/sqx/common/utils/MapUtils.java create mode 100644 src/main/java/com/sqx/common/utils/PageUtils.java create mode 100644 src/main/java/com/sqx/common/utils/QRCodeUtil.java create mode 100644 src/main/java/com/sqx/common/utils/Query.java create mode 100644 src/main/java/com/sqx/common/utils/RedisKeys.java create mode 100644 src/main/java/com/sqx/common/utils/RedisUtils.java create mode 100644 src/main/java/com/sqx/common/utils/Result.java create mode 100644 src/main/java/com/sqx/common/utils/ShiroUtils.java create mode 100644 src/main/java/com/sqx/common/utils/SpringContextUtils.java create mode 100644 src/main/java/com/sqx/common/validator/Assert.java create mode 100644 src/main/java/com/sqx/common/validator/ValidatorUtils.java create mode 100644 src/main/java/com/sqx/common/validator/group/AddGroup.java create mode 100644 src/main/java/com/sqx/common/validator/group/AliyunGroup.java create mode 100644 src/main/java/com/sqx/common/validator/group/QcloudGroup.java create mode 100644 src/main/java/com/sqx/common/validator/group/QiniuGroup.java create mode 100644 src/main/java/com/sqx/common/validator/group/UpdateGroup.java create mode 100644 src/main/java/com/sqx/common/websocket/WebSocketMessage.java create mode 100644 src/main/java/com/sqx/common/websocket/WebSocketServer.java create mode 100644 src/main/java/com/sqx/common/xss/HTMLFilter.java create mode 100644 src/main/java/com/sqx/common/xss/SQLFilter.java create mode 100644 src/main/java/com/sqx/common/xss/XssFilter.java create mode 100644 src/main/java/com/sqx/common/xss/XssHttpServletRequestWrapper.java create mode 100644 src/main/java/com/sqx/config/CorsConfig.java create mode 100644 src/main/java/com/sqx/config/FilterConfig.java create mode 100644 src/main/java/com/sqx/config/KaptchaConfig.java create mode 100644 src/main/java/com/sqx/config/MybatisPlusConfig.java create mode 100644 src/main/java/com/sqx/config/RedisConfig.java create mode 100644 src/main/java/com/sqx/config/ShiroConfig.java create mode 100644 src/main/java/com/sqx/config/SwaggerConfig.java create mode 100644 src/main/java/com/sqx/datasource/annotation/DataSource.java create mode 100644 src/main/java/com/sqx/datasource/aspect/DataSourceAspect.java create mode 100644 src/main/java/com/sqx/datasource/config/DynamicContextHolder.java create mode 100644 src/main/java/com/sqx/datasource/config/DynamicDataSource.java create mode 100644 src/main/java/com/sqx/datasource/config/DynamicDataSourceConfig.java create mode 100644 src/main/java/com/sqx/datasource/config/DynamicDataSourceFactory.java create mode 100644 src/main/java/com/sqx/datasource/properties/DataSourceProperties.java create mode 100644 src/main/java/com/sqx/datasource/properties/DynamicDataSourceProperties.java create mode 100644 src/main/java/com/sqx/ffmpeg/FFmpeg.java create mode 100644 src/main/java/com/sqx/map/CommonMapUtils.java create mode 100644 src/main/java/com/sqx/modules/app/annotation/Login.java create mode 100644 src/main/java/com/sqx/modules/app/annotation/LoginUser.java create mode 100644 src/main/java/com/sqx/modules/app/config/WebMvcConfig.java create mode 100644 src/main/java/com/sqx/modules/app/controller/AddressController.java create mode 100644 src/main/java/com/sqx/modules/app/controller/AppUpgradeController.java create mode 100644 src/main/java/com/sqx/modules/app/controller/UserBrowseController.java create mode 100644 src/main/java/com/sqx/modules/app/controller/UserCertificationController.java create mode 100644 src/main/java/com/sqx/modules/app/controller/UserController.java create mode 100644 src/main/java/com/sqx/modules/app/controller/UserFollowController.java create mode 100644 src/main/java/com/sqx/modules/app/controller/UserMoneyDetailsController.java create mode 100644 src/main/java/com/sqx/modules/app/controller/VipDetailsController.java create mode 100644 src/main/java/com/sqx/modules/app/controller/app/AppAddressController.java create mode 100644 src/main/java/com/sqx/modules/app/controller/app/AppController.java create mode 100644 src/main/java/com/sqx/modules/app/controller/app/AppLoginController.java create mode 100644 src/main/java/com/sqx/modules/app/controller/app/AppUserBrowseController.java create mode 100644 src/main/java/com/sqx/modules/app/controller/app/AppUserCertificationController.java create mode 100644 src/main/java/com/sqx/modules/app/controller/app/AppUserFollowController.java create mode 100644 src/main/java/com/sqx/modules/app/controller/app/AppUserMoneyController.java create mode 100644 src/main/java/com/sqx/modules/app/controller/app/AppUserVipController.java create mode 100644 src/main/java/com/sqx/modules/app/controller/app/AppVipDetailsController.java create mode 100644 src/main/java/com/sqx/modules/app/dao/AddressDao.java create mode 100644 src/main/java/com/sqx/modules/app/dao/AppDao.java create mode 100644 src/main/java/com/sqx/modules/app/dao/MsgDao.java create mode 100644 src/main/java/com/sqx/modules/app/dao/UserBrowseDao.java create mode 100644 src/main/java/com/sqx/modules/app/dao/UserCertificationDao.java create mode 100644 src/main/java/com/sqx/modules/app/dao/UserDao.java create mode 100644 src/main/java/com/sqx/modules/app/dao/UserFollowDao.java create mode 100644 src/main/java/com/sqx/modules/app/dao/UserMoneyArtificerDao.java create mode 100644 src/main/java/com/sqx/modules/app/dao/UserMoneyDao.java create mode 100644 src/main/java/com/sqx/modules/app/dao/UserMoneyDetailsDao.java create mode 100644 src/main/java/com/sqx/modules/app/dao/UserVipDao.java create mode 100644 src/main/java/com/sqx/modules/app/dao/UserVisitorDao.java create mode 100644 src/main/java/com/sqx/modules/app/dao/VipDetailsDao.java create mode 100644 src/main/java/com/sqx/modules/app/dao/VipDiscountDao.java create mode 100644 src/main/java/com/sqx/modules/app/entity/Address.java create mode 100644 src/main/java/com/sqx/modules/app/entity/App.java create mode 100644 src/main/java/com/sqx/modules/app/entity/AppUserInfo.java create mode 100644 src/main/java/com/sqx/modules/app/entity/Msg.java create mode 100644 src/main/java/com/sqx/modules/app/entity/UserBrowse.java create mode 100644 src/main/java/com/sqx/modules/app/entity/UserCertification.java create mode 100644 src/main/java/com/sqx/modules/app/entity/UserDetails.java create mode 100644 src/main/java/com/sqx/modules/app/entity/UserEntity.java create mode 100644 src/main/java/com/sqx/modules/app/entity/UserFollow.java create mode 100644 src/main/java/com/sqx/modules/app/entity/UserMoney.java create mode 100644 src/main/java/com/sqx/modules/app/entity/UserMoneyArtificer.java create mode 100644 src/main/java/com/sqx/modules/app/entity/UserMoneyDetails.java create mode 100644 src/main/java/com/sqx/modules/app/entity/UserMoneyResult.java create mode 100644 src/main/java/com/sqx/modules/app/entity/UserVip.java create mode 100644 src/main/java/com/sqx/modules/app/entity/UserVisitor.java create mode 100644 src/main/java/com/sqx/modules/app/entity/VipDetails.java create mode 100644 src/main/java/com/sqx/modules/app/entity/VipDiscount.java create mode 100644 src/main/java/com/sqx/modules/app/form/LoginForm.java create mode 100644 src/main/java/com/sqx/modules/app/form/RegisterForm.java create mode 100644 src/main/java/com/sqx/modules/app/interceptor/AuthorizationInterceptor.java create mode 100644 src/main/java/com/sqx/modules/app/resolver/LoginUserHandlerMethodArgumentResolver.java create mode 100644 src/main/java/com/sqx/modules/app/response/CourseOrderResponse.java create mode 100644 src/main/java/com/sqx/modules/app/response/HomeMessageResponse.java create mode 100644 src/main/java/com/sqx/modules/app/response/TakingOrderResponse.java create mode 100644 src/main/java/com/sqx/modules/app/response/UserFollowResponse.java create mode 100644 src/main/java/com/sqx/modules/app/response/UserMessageResponse.java create mode 100644 src/main/java/com/sqx/modules/app/service/AddressService.java create mode 100644 src/main/java/com/sqx/modules/app/service/AppService.java create mode 100644 src/main/java/com/sqx/modules/app/service/IAppleService.java create mode 100644 src/main/java/com/sqx/modules/app/service/MsgService.java create mode 100644 src/main/java/com/sqx/modules/app/service/UserBrowseService.java create mode 100644 src/main/java/com/sqx/modules/app/service/UserCertificationService.java create mode 100644 src/main/java/com/sqx/modules/app/service/UserFollowService.java create mode 100644 src/main/java/com/sqx/modules/app/service/UserMoneyArtificerService.java create mode 100644 src/main/java/com/sqx/modules/app/service/UserMoneyDetailsService.java create mode 100644 src/main/java/com/sqx/modules/app/service/UserMoneyService.java create mode 100644 src/main/java/com/sqx/modules/app/service/UserService.java create mode 100644 src/main/java/com/sqx/modules/app/service/UserVipService.java create mode 100644 src/main/java/com/sqx/modules/app/service/VipDetailsService.java create mode 100644 src/main/java/com/sqx/modules/app/service/impl/AddressServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/app/service/impl/AppServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/app/service/impl/AppleServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/app/service/impl/MsgServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/app/service/impl/UserBrowseServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/app/service/impl/UserCertificationImpl.java create mode 100644 src/main/java/com/sqx/modules/app/service/impl/UserFollowServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/app/service/impl/UserMoneyArtificerServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/app/service/impl/UserMoneyDetailsServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/app/service/impl/UserMoneyServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/app/service/impl/UserVipServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/app/service/impl/VipDetailsServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/app/utils/JwtUtils.java create mode 100644 src/main/java/com/sqx/modules/app/utils/UserConstantInterface.java create mode 100644 src/main/java/com/sqx/modules/app/utils/WxPhone.java create mode 100644 src/main/java/com/sqx/modules/apply/controller/ApplyController.java create mode 100644 src/main/java/com/sqx/modules/apply/controller/app/AppApplyController.java create mode 100644 src/main/java/com/sqx/modules/apply/dao/ApplyDao.java create mode 100644 src/main/java/com/sqx/modules/apply/entity/Apply.java create mode 100644 src/main/java/com/sqx/modules/apply/service/ApplyService.java create mode 100644 src/main/java/com/sqx/modules/apply/service/impl/ApplyServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/artificer/controller/ArtificerController.java create mode 100644 src/main/java/com/sqx/modules/artificer/controller/ArtificerTimeController.java create mode 100644 src/main/java/com/sqx/modules/artificer/controller/RealNameController.java create mode 100644 src/main/java/com/sqx/modules/artificer/controller/app/AppArtificerController.java create mode 100644 src/main/java/com/sqx/modules/artificer/controller/app/AppArtificerIntegralController.java create mode 100644 src/main/java/com/sqx/modules/artificer/controller/app/AppArtificerTimeController.java create mode 100644 src/main/java/com/sqx/modules/artificer/controller/app/AppRealNameController.java create mode 100644 src/main/java/com/sqx/modules/artificer/controller/app/DividedIntoDetailsController.java create mode 100644 src/main/java/com/sqx/modules/artificer/controller/app/FundDetailsController.java create mode 100644 src/main/java/com/sqx/modules/artificer/dao/AgencyDao.java create mode 100644 src/main/java/com/sqx/modules/artificer/dao/ArtificerDao.java create mode 100644 src/main/java/com/sqx/modules/artificer/dao/ArtificerMassageDao.java create mode 100644 src/main/java/com/sqx/modules/artificer/dao/ArtificerTimeDao.java create mode 100644 src/main/java/com/sqx/modules/artificer/dao/CollectArtificerDao.java create mode 100644 src/main/java/com/sqx/modules/artificer/dao/MassageTypeDao.java create mode 100644 src/main/java/com/sqx/modules/artificer/dao/OrdersDao.java create mode 100644 src/main/java/com/sqx/modules/artificer/dao/OrdersMassageDao.java create mode 100644 src/main/java/com/sqx/modules/artificer/dao/RealNameDao.java create mode 100644 src/main/java/com/sqx/modules/artificer/dao/UserRechargeDao.java create mode 100644 src/main/java/com/sqx/modules/artificer/entity/Agency.java create mode 100644 src/main/java/com/sqx/modules/artificer/entity/Artificer.java create mode 100644 src/main/java/com/sqx/modules/artificer/entity/ArtificerMassage.java create mode 100644 src/main/java/com/sqx/modules/artificer/entity/ArtificerTime.java create mode 100644 src/main/java/com/sqx/modules/artificer/entity/Certification.java create mode 100644 src/main/java/com/sqx/modules/artificer/entity/CollectArtificer.java create mode 100644 src/main/java/com/sqx/modules/artificer/entity/FundDetailsResult.java create mode 100644 src/main/java/com/sqx/modules/artificer/entity/MassageType.java create mode 100644 src/main/java/com/sqx/modules/artificer/entity/Orders.java create mode 100644 src/main/java/com/sqx/modules/artificer/entity/OrdersMassage.java create mode 100644 src/main/java/com/sqx/modules/artificer/entity/Period.java create mode 100644 src/main/java/com/sqx/modules/artificer/entity/UserMoneyArtificerDetails.java create mode 100644 src/main/java/com/sqx/modules/artificer/entity/UserRecharge.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/AgencyService.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/AppArtificerIntegralService.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/ArtificerMassageService.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/ArtificerService.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/ArtificerTimeService.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/CollectArtificerService.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/MassageTypeService.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/OrdersMassageService.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/OrdersService.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/RealNameService.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/impl/AgencyServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/impl/AppArtificerIntegralServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/impl/ArtificerMassageServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/impl/ArtificerServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/impl/ArtificerTimeServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/impl/CollectArtificerServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/impl/MassageTypeServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/impl/OrdersMassageServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/impl/OrdersServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/artificer/service/impl/RealNameServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/artificer/vo/HomeVO.java create mode 100644 src/main/java/com/sqx/modules/artificer/vo/UserArtificerVO.java create mode 100644 src/main/java/com/sqx/modules/banner/controller/ActivityController.java create mode 100644 src/main/java/com/sqx/modules/banner/controller/BannerController.java create mode 100644 src/main/java/com/sqx/modules/banner/controller/app/AppBannerController.java create mode 100644 src/main/java/com/sqx/modules/banner/dao/ActivityDao.java create mode 100644 src/main/java/com/sqx/modules/banner/dao/BannerDao.java create mode 100644 src/main/java/com/sqx/modules/banner/entity/Activity.java create mode 100644 src/main/java/com/sqx/modules/banner/entity/Banner.java create mode 100644 src/main/java/com/sqx/modules/banner/service/ActivityService.java create mode 100644 src/main/java/com/sqx/modules/banner/service/BannerService.java create mode 100644 src/main/java/com/sqx/modules/banner/service/impl/ActivityServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/banner/service/impl/BannerServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/chat/controller/ChatController.java create mode 100644 src/main/java/com/sqx/modules/chat/controller/app/AppChatController.java create mode 100644 src/main/java/com/sqx/modules/chat/controller/app/AppChatSocket.java create mode 100644 src/main/java/com/sqx/modules/chat/dao/ChatContentDao.java create mode 100644 src/main/java/com/sqx/modules/chat/dao/ChatConversationDao.java create mode 100644 src/main/java/com/sqx/modules/chat/entity/ChatContent.java create mode 100644 src/main/java/com/sqx/modules/chat/entity/ChatConversation.java create mode 100644 src/main/java/com/sqx/modules/chat/service/ChatContentService.java create mode 100644 src/main/java/com/sqx/modules/chat/service/ChatConversationService.java create mode 100644 src/main/java/com/sqx/modules/chat/service/impl/ChatContentServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/chat/service/impl/ChatConversationServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/chats/controller/ChatsContentController.java create mode 100644 src/main/java/com/sqx/modules/chats/controller/ChatsController.java create mode 100644 src/main/java/com/sqx/modules/chats/controller/WebSocket.java create mode 100644 src/main/java/com/sqx/modules/chats/controller/app/AppChatsController.java create mode 100644 src/main/java/com/sqx/modules/chats/entity/Chats.java create mode 100644 src/main/java/com/sqx/modules/chats/entity/ChatsContent.java create mode 100644 src/main/java/com/sqx/modules/chats/respository/ChatContentRepository.java create mode 100644 src/main/java/com/sqx/modules/chats/respository/ChatRepository.java create mode 100644 src/main/java/com/sqx/modules/chats/service/ChatsContentService.java create mode 100644 src/main/java/com/sqx/modules/chats/service/ChatsContentServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/chats/service/ChatsService.java create mode 100644 src/main/java/com/sqx/modules/chats/service/ChatsServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/chats/utils/DateUtil.java create mode 100644 src/main/java/com/sqx/modules/chats/utils/DescribeException.java create mode 100644 src/main/java/com/sqx/modules/chats/utils/ExceptionEnum.java create mode 100644 src/main/java/com/sqx/modules/chats/utils/Result.java create mode 100644 src/main/java/com/sqx/modules/chats/utils/ResultUtil.java create mode 100644 src/main/java/com/sqx/modules/common/controller/CommonController.java create mode 100644 src/main/java/com/sqx/modules/common/controller/app/AppCommonController.java create mode 100644 src/main/java/com/sqx/modules/common/dao/ArtificerPartitioningDetailsMapper.java create mode 100644 src/main/java/com/sqx/modules/common/dao/CommonInfoDao.java create mode 100644 src/main/java/com/sqx/modules/common/entity/ArtificerPartitioningDetails.java create mode 100644 src/main/java/com/sqx/modules/common/entity/CommonInfo.java create mode 100644 src/main/java/com/sqx/modules/common/service/CommonInfoService.java create mode 100644 src/main/java/com/sqx/modules/common/service/impl/CommonInfoServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/consortia/controller/ConsortiaController.java create mode 100644 src/main/java/com/sqx/modules/consortia/controller/app/AppConsortiaController.java create mode 100644 src/main/java/com/sqx/modules/consortia/dao/ConsortiaDao.java create mode 100644 src/main/java/com/sqx/modules/consortia/entity/Consortia.java create mode 100644 src/main/java/com/sqx/modules/consortia/service/ConsortiaService.java create mode 100644 src/main/java/com/sqx/modules/consortia/service/impl/ConsortiaServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/coupon/controller/CouponCardController.java create mode 100644 src/main/java/com/sqx/modules/coupon/controller/CouponController.java create mode 100644 src/main/java/com/sqx/modules/coupon/controller/CouponIssueController.java create mode 100644 src/main/java/com/sqx/modules/coupon/controller/CouponUserController.java create mode 100644 src/main/java/com/sqx/modules/coupon/controller/app/AppCouponCardController.java create mode 100644 src/main/java/com/sqx/modules/coupon/controller/app/AppCouponIssueController.java create mode 100644 src/main/java/com/sqx/modules/coupon/controller/app/AppCouponUserController.java create mode 100644 src/main/java/com/sqx/modules/coupon/dao/CouponCardDao.java create mode 100644 src/main/java/com/sqx/modules/coupon/dao/CouponCardTypeDao.java create mode 100644 src/main/java/com/sqx/modules/coupon/dao/CouponDao.java create mode 100644 src/main/java/com/sqx/modules/coupon/dao/CouponIssueDao.java create mode 100644 src/main/java/com/sqx/modules/coupon/dao/CouponUserDao.java create mode 100644 src/main/java/com/sqx/modules/coupon/entity/Coupon.java create mode 100644 src/main/java/com/sqx/modules/coupon/entity/CouponCard.java create mode 100644 src/main/java/com/sqx/modules/coupon/entity/CouponCardType.java create mode 100644 src/main/java/com/sqx/modules/coupon/entity/CouponIssue.java create mode 100644 src/main/java/com/sqx/modules/coupon/entity/CouponUser.java create mode 100644 src/main/java/com/sqx/modules/coupon/service/CouponCardService.java create mode 100644 src/main/java/com/sqx/modules/coupon/service/CouponCardTypeService.java create mode 100644 src/main/java/com/sqx/modules/coupon/service/CouponIssueService.java create mode 100644 src/main/java/com/sqx/modules/coupon/service/CouponService.java create mode 100644 src/main/java/com/sqx/modules/coupon/service/CouponUserService.java create mode 100644 src/main/java/com/sqx/modules/coupon/service/impl/CouponCardServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/coupon/service/impl/CouponCardTypeServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/coupon/service/impl/CouponIssueServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/coupon/service/impl/CouponServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/coupon/service/impl/CouponUserServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/file/AliFileUploadController.java create mode 100644 src/main/java/com/sqx/modules/file/utils/DescribeException.java create mode 100644 src/main/java/com/sqx/modules/file/utils/ExceptionEnum.java create mode 100644 src/main/java/com/sqx/modules/file/utils/FileUploadUtils.java create mode 100644 src/main/java/com/sqx/modules/file/utils/FileUtils.java create mode 100644 src/main/java/com/sqx/modules/file/utils/ImageUtil.java create mode 100644 src/main/java/com/sqx/modules/file/utils/Md5Utils.java create mode 100644 src/main/java/com/sqx/modules/file/utils/MimeTypeUtils.java create mode 100644 src/main/java/com/sqx/modules/helpCenter/controller/HelpWordController.java create mode 100644 src/main/java/com/sqx/modules/helpCenter/controller/app/AppHelpWordController.java create mode 100644 src/main/java/com/sqx/modules/helpCenter/dao/HelpClassifyDao.java create mode 100644 src/main/java/com/sqx/modules/helpCenter/dao/HelpWordDao.java create mode 100644 src/main/java/com/sqx/modules/helpCenter/entity/HelpClassify.java create mode 100644 src/main/java/com/sqx/modules/helpCenter/entity/HelpWord.java create mode 100644 src/main/java/com/sqx/modules/helpCenter/service/HelpClassifyService.java create mode 100644 src/main/java/com/sqx/modules/helpCenter/service/HelpWordService.java create mode 100644 src/main/java/com/sqx/modules/helpCenter/service/impl/HelpClassifyServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/helpCenter/service/impl/HelpWordServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/invite/controller/InviteController.java create mode 100644 src/main/java/com/sqx/modules/invite/controller/app/AppInviteController.java create mode 100644 src/main/java/com/sqx/modules/invite/dao/InviteDao.java create mode 100644 src/main/java/com/sqx/modules/invite/dao/InviteMoneyDao.java create mode 100644 src/main/java/com/sqx/modules/invite/entity/Invite.java create mode 100644 src/main/java/com/sqx/modules/invite/entity/InviteMoney.java create mode 100644 src/main/java/com/sqx/modules/invite/service/InviteMoneyService.java create mode 100644 src/main/java/com/sqx/modules/invite/service/InviteService.java create mode 100644 src/main/java/com/sqx/modules/invite/service/impl/InviteMoneyServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/invite/service/impl/InviteServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/map/MapWebSocket.java create mode 100644 src/main/java/com/sqx/modules/material/controller/MaterialController.java create mode 100644 src/main/java/com/sqx/modules/material/controller/MaterialRecordController.java create mode 100644 src/main/java/com/sqx/modules/material/controller/app/AppMaterialController.java create mode 100644 src/main/java/com/sqx/modules/material/dao/MaterialArtificerMapper.java create mode 100644 src/main/java/com/sqx/modules/material/dao/MaterialMapper.java create mode 100644 src/main/java/com/sqx/modules/material/dao/MaterialMassageMapper.java create mode 100644 src/main/java/com/sqx/modules/material/dao/MaterialRecordMapper.java create mode 100644 src/main/java/com/sqx/modules/material/entity/Material.java create mode 100644 src/main/java/com/sqx/modules/material/entity/MaterialArtificer.java create mode 100644 src/main/java/com/sqx/modules/material/entity/MaterialArtificerResult.java create mode 100644 src/main/java/com/sqx/modules/material/entity/MaterialMassage.java create mode 100644 src/main/java/com/sqx/modules/material/entity/MaterialMassageResult.java create mode 100644 src/main/java/com/sqx/modules/material/entity/MaterialRecord.java create mode 100644 src/main/java/com/sqx/modules/material/service/MaterialArtificerService.java create mode 100644 src/main/java/com/sqx/modules/material/service/MaterialMassageService.java create mode 100644 src/main/java/com/sqx/modules/material/service/MaterialRecordService.java create mode 100644 src/main/java/com/sqx/modules/material/service/MaterialService.java create mode 100644 src/main/java/com/sqx/modules/material/service/impl/MaterialArtificerServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/material/service/impl/MaterialMassageServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/material/service/impl/MaterialRecordServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/material/service/impl/MaterialServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/member/controller/MemberController.java create mode 100644 src/main/java/com/sqx/modules/member/controller/app/AppMemberController.java create mode 100644 src/main/java/com/sqx/modules/member/dao/MemberDao.java create mode 100644 src/main/java/com/sqx/modules/member/entity/Member.java create mode 100644 src/main/java/com/sqx/modules/member/service/MemberService.java create mode 100644 src/main/java/com/sqx/modules/member/service/impl/MemberServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/message/controller/ActivityMessageController.java create mode 100644 src/main/java/com/sqx/modules/message/controller/MessageAudioController.java create mode 100644 src/main/java/com/sqx/modules/message/controller/MessageController.java create mode 100644 src/main/java/com/sqx/modules/message/controller/app/AppMessageController.java create mode 100644 src/main/java/com/sqx/modules/message/dao/ActivityMessageInfoDao.java create mode 100644 src/main/java/com/sqx/modules/message/dao/MessageInfoAudioDao.java create mode 100644 src/main/java/com/sqx/modules/message/dao/MessageInfoDao.java create mode 100644 src/main/java/com/sqx/modules/message/entity/ActivityMessageInfo.java create mode 100644 src/main/java/com/sqx/modules/message/entity/MessageInfo.java create mode 100644 src/main/java/com/sqx/modules/message/entity/MessageInfoAudio.java create mode 100644 src/main/java/com/sqx/modules/message/service/ActivityMessageService.java create mode 100644 src/main/java/com/sqx/modules/message/service/MessageAudioService.java create mode 100644 src/main/java/com/sqx/modules/message/service/MessageService.java create mode 100644 src/main/java/com/sqx/modules/message/service/impl/ActivityMessageServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/message/service/impl/MessageAudioServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/message/service/impl/MessageServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/monitor/MonitorWebSocket.java create mode 100644 src/main/java/com/sqx/modules/pay/config/AliPayConstants.java create mode 100644 src/main/java/com/sqx/modules/pay/config/WXConfig.java create mode 100644 src/main/java/com/sqx/modules/pay/controller/CashController.java create mode 100644 src/main/java/com/sqx/modules/pay/controller/PayClassifyController.java create mode 100644 src/main/java/com/sqx/modules/pay/controller/app/AliPayController.java create mode 100644 src/main/java/com/sqx/modules/pay/controller/app/ApiWeiXinPayController.java create mode 100644 src/main/java/com/sqx/modules/pay/controller/app/AppCashController.java create mode 100644 src/main/java/com/sqx/modules/pay/controller/app/AppPayClassifyController.java create mode 100644 src/main/java/com/sqx/modules/pay/dao/CashOutDao.java create mode 100644 src/main/java/com/sqx/modules/pay/dao/PayClassifyDao.java create mode 100644 src/main/java/com/sqx/modules/pay/dao/PayDetailsDao.java create mode 100644 src/main/java/com/sqx/modules/pay/entity/AliPayParamModel.java create mode 100644 src/main/java/com/sqx/modules/pay/entity/AliPayWithdrawModel.java create mode 100644 src/main/java/com/sqx/modules/pay/entity/CashOut.java create mode 100644 src/main/java/com/sqx/modules/pay/entity/PayClassify.java create mode 100644 src/main/java/com/sqx/modules/pay/entity/PayDetails.java create mode 100644 src/main/java/com/sqx/modules/pay/service/CashOutService.java create mode 100644 src/main/java/com/sqx/modules/pay/service/PayClassifyService.java create mode 100644 src/main/java/com/sqx/modules/pay/service/PayDetailsService.java create mode 100644 src/main/java/com/sqx/modules/pay/service/WxService.java create mode 100644 src/main/java/com/sqx/modules/pay/service/impl/CashOutServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/pay/service/impl/PayClassifyServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/pay/service/impl/PayDetailsServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/pay/service/impl/WxServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/risk/controller/RiskController.java create mode 100644 src/main/java/com/sqx/modules/risk/controller/app/AppRiskController.java create mode 100644 src/main/java/com/sqx/modules/risk/dao/RiskDao.java create mode 100644 src/main/java/com/sqx/modules/risk/entity/Risk.java create mode 100644 src/main/java/com/sqx/modules/risk/service/RiskService.java create mode 100644 src/main/java/com/sqx/modules/risk/service/impl/RiskServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/search/Response/SearchResponse.java create mode 100644 src/main/java/com/sqx/modules/search/controller/SearchController.java create mode 100644 src/main/java/com/sqx/modules/search/controller/app/AppSearchController.java create mode 100644 src/main/java/com/sqx/modules/search/dao/AppSearchDao.java create mode 100644 src/main/java/com/sqx/modules/search/dao/SearchDao.java create mode 100644 src/main/java/com/sqx/modules/search/entity/Search.java create mode 100644 src/main/java/com/sqx/modules/search/service/AppSearchService.java create mode 100644 src/main/java/com/sqx/modules/search/service/SearchService.java create mode 100644 src/main/java/com/sqx/modules/search/service/impl/AppSearchServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/search/service/impl/SearchServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/AdvertController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/CouponsController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/GoodsController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/GoodsTypeController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/OrdersController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/OrdersRelationController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/OrdersTask.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/SelfActivityController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/SelfBannerController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/SelfGoodsBrandController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/SelfGoodsCommentController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/SelfGoodsRuleController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/SelfGoodsVirtualController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/SelfMerchantApplyController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/SelfUserCollectController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/SkuUtil.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/app/AppAdvertController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/app/AppCouponsController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/app/AppGoodsController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/app/AppGoodsTypeController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/app/AppOrdersController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/app/AppOrdersRelationController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/app/AppSelfActivityController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/app/AppSelfAliPayController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/app/AppSelfBannerController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/app/AppSelfGoodsBrandController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/app/AppSelfGoodsCommentController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/app/AppSelfGoodsRuleController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/app/AppSelfGoodsVirtualController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/app/AppSelfMerchantApplyController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/app/AppSelfUserCollectController.java create mode 100644 src/main/java/com/sqx/modules/shopping/controller/app/AppSelfWXPayController.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/AdvertJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/AdvertRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/CouponsJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/CouponsRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/CouponsUserJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/CouponsUserRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/GoodsJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/GoodsRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/GoodsTypeJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/GoodsTypeRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/OrdersJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/OrdersRelationJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/OrdersRelationRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/OrdersRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfActivityJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfActivityRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfBannerJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfBannerRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfGoodsAttrJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfGoodsAttrRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfGoodsAttrValueJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfGoodsAttrValueRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfGoodsBrandJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfGoodsBrandRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfGoodsCommentJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfGoodsCommentRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfGoodsRuleJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfGoodsRuleRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfGoodsRuleValueJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfGoodsRuleValueRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfGoodsSkuJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfGoodsSkuRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfGoodsVirtualJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfGoodsVirtualRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfMerchantApplyJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfMerchantApplyRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfOrdersRemindJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfOrdersRemindRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfUserCollectJpaRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/dao/SelfUserCollectRepository.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/Adverti.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/Coupons.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/CouponsUser.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/GoodsType.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/GoodsTypeResult.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/SelfActivity.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/SelfBanner.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/SelfGoods.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/SelfGoodsAttr.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/SelfGoodsAttrValue.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/SelfGoodsBrand.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/SelfGoodsComment.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/SelfGoodsRule.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/SelfGoodsRuleValue.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/SelfGoodsSku.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/SelfGoodsVirtual.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/SelfMerchantApply.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/SelfOrderRelation.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/SelfOrderRemind.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/SelfOrders.java create mode 100644 src/main/java/com/sqx/modules/shopping/entity/SelfUserCollect.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/AdvertService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/CouponsService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/CouponsUserService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/GoodsService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/GoodsTypeService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/OrdersRelationService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/OrdersService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/SelfAliPayService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/SelfGoodsAttrService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/SelfGoodsBrandService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/SelfGoodsCommentService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/SelfGoodsRuleService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/SelfGoodsSkuService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/SelfGoodsVirtualService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/SelfMerchantApplyService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/SelfUserCollectService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/SelfWXService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/SlefBannerService.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/AdvertServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/CouponsServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/CouponsUserServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/GoodsTypeServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/OrdersRelationServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/SelUserCollectServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/SelfAliPayServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/SelfBannerServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsAttrServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsBrandServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsCommentServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsRuleServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsSkuServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsVirtualServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/SelfMerchantApplyServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/SelfOrdersServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/service/impl/SelfWXServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/shopping/utils/AmountCalUtil.java create mode 100644 src/main/java/com/sqx/modules/shopping/utils/DateUtil.java create mode 100644 src/main/java/com/sqx/modules/shopping/utils/ExceptionEnum.java create mode 100644 src/main/java/com/sqx/modules/shopping/utils/Result.java create mode 100644 src/main/java/com/sqx/modules/shopping/utils/ResultUtil.java create mode 100644 src/main/java/com/sqx/modules/shopping/utils/WXConfigUtil.java create mode 100644 src/main/java/com/sqx/modules/shopping/utils/excel/ExcelData.java create mode 100644 src/main/java/com/sqx/modules/shopping/utils/excel/ExcelUtils.java create mode 100644 src/main/java/com/sqx/modules/shopping/utils/excel/ExportExcelUtils.java create mode 100644 src/main/java/com/sqx/modules/sys/controller/AbstractController.java create mode 100644 src/main/java/com/sqx/modules/sys/controller/SysConfigController.java create mode 100644 src/main/java/com/sqx/modules/sys/controller/SysDictController.java create mode 100644 src/main/java/com/sqx/modules/sys/controller/SysLogController.java create mode 100644 src/main/java/com/sqx/modules/sys/controller/SysLoginController.java create mode 100644 src/main/java/com/sqx/modules/sys/controller/SysMenuController.java create mode 100644 src/main/java/com/sqx/modules/sys/controller/SysRoleController.java create mode 100644 src/main/java/com/sqx/modules/sys/controller/SysUserController.java create mode 100644 src/main/java/com/sqx/modules/sys/controller/app/AppDictController.java create mode 100644 src/main/java/com/sqx/modules/sys/dao/SysCaptchaDao.java create mode 100644 src/main/java/com/sqx/modules/sys/dao/SysConfigDao.java create mode 100644 src/main/java/com/sqx/modules/sys/dao/SysDictDao.java create mode 100644 src/main/java/com/sqx/modules/sys/dao/SysLogDao.java create mode 100644 src/main/java/com/sqx/modules/sys/dao/SysMenuDao.java create mode 100644 src/main/java/com/sqx/modules/sys/dao/SysRoleDao.java create mode 100644 src/main/java/com/sqx/modules/sys/dao/SysRoleMenuDao.java create mode 100644 src/main/java/com/sqx/modules/sys/dao/SysUserDao.java create mode 100644 src/main/java/com/sqx/modules/sys/dao/SysUserRoleDao.java create mode 100644 src/main/java/com/sqx/modules/sys/dao/SysUserTokenDao.java create mode 100644 src/main/java/com/sqx/modules/sys/entity/SysCaptchaEntity.java create mode 100644 src/main/java/com/sqx/modules/sys/entity/SysConfigEntity.java create mode 100644 src/main/java/com/sqx/modules/sys/entity/SysDictEntity.java create mode 100644 src/main/java/com/sqx/modules/sys/entity/SysLogEntity.java create mode 100644 src/main/java/com/sqx/modules/sys/entity/SysMenuEntity.java create mode 100644 src/main/java/com/sqx/modules/sys/entity/SysRoleEntity.java create mode 100644 src/main/java/com/sqx/modules/sys/entity/SysRoleMenuEntity.java create mode 100644 src/main/java/com/sqx/modules/sys/entity/SysUserEntity.java create mode 100644 src/main/java/com/sqx/modules/sys/entity/SysUserRoleEntity.java create mode 100644 src/main/java/com/sqx/modules/sys/entity/SysUserTokenEntity.java create mode 100644 src/main/java/com/sqx/modules/sys/form/PasswordForm.java create mode 100644 src/main/java/com/sqx/modules/sys/form/SysLoginForm.java create mode 100644 src/main/java/com/sqx/modules/sys/oauth2/OAuth2Filter.java create mode 100644 src/main/java/com/sqx/modules/sys/oauth2/OAuth2Realm.java create mode 100644 src/main/java/com/sqx/modules/sys/oauth2/OAuth2Token.java create mode 100644 src/main/java/com/sqx/modules/sys/oauth2/TokenGenerator.java create mode 100644 src/main/java/com/sqx/modules/sys/redis/SysConfigRedis.java create mode 100644 src/main/java/com/sqx/modules/sys/service/ShiroService.java create mode 100644 src/main/java/com/sqx/modules/sys/service/SysCaptchaService.java create mode 100644 src/main/java/com/sqx/modules/sys/service/SysConfigService.java create mode 100644 src/main/java/com/sqx/modules/sys/service/SysDictService.java create mode 100644 src/main/java/com/sqx/modules/sys/service/SysLogService.java create mode 100644 src/main/java/com/sqx/modules/sys/service/SysMenuService.java create mode 100644 src/main/java/com/sqx/modules/sys/service/SysRoleMenuService.java create mode 100644 src/main/java/com/sqx/modules/sys/service/SysRoleService.java create mode 100644 src/main/java/com/sqx/modules/sys/service/SysUserRoleService.java create mode 100644 src/main/java/com/sqx/modules/sys/service/SysUserService.java create mode 100644 src/main/java/com/sqx/modules/sys/service/SysUserTokenService.java create mode 100644 src/main/java/com/sqx/modules/sys/service/impl/ShiroServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/sys/service/impl/SysCaptchaServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/sys/service/impl/SysConfigServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/sys/service/impl/SysDictServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/sys/service/impl/SysLogServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/sys/service/impl/SysMenuServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/sys/service/impl/SysRoleMenuServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/sys/service/impl/SysRoleServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/sys/service/impl/SysUserRoleServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/sys/service/impl/SysUserServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/sys/service/impl/SysUserTokenServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/taking/controller/GameController.java create mode 100644 src/main/java/com/sqx/modules/taking/controller/OrderTakingCommentController.java create mode 100644 src/main/java/com/sqx/modules/taking/controller/app/AppGameController.java create mode 100644 src/main/java/com/sqx/modules/taking/controller/app/AppOrderTakingCommentController.java create mode 100644 src/main/java/com/sqx/modules/taking/dao/GameDao.java create mode 100644 src/main/java/com/sqx/modules/taking/dao/OrderTakingCommentDao.java create mode 100644 src/main/java/com/sqx/modules/taking/entity/CommentFabulous.java create mode 100644 src/main/java/com/sqx/modules/taking/entity/Game.java create mode 100644 src/main/java/com/sqx/modules/taking/entity/TakingCommnt.java create mode 100644 src/main/java/com/sqx/modules/taking/response/MyReleaseResponse.java create mode 100644 src/main/java/com/sqx/modules/taking/response/OrderTakingResponse.java create mode 100644 src/main/java/com/sqx/modules/taking/response/TakingCommentResponse.java create mode 100644 src/main/java/com/sqx/modules/taking/response/TakingDetailsResponse.java create mode 100644 src/main/java/com/sqx/modules/taking/response/TakingResponse.java create mode 100644 src/main/java/com/sqx/modules/taking/service/GameService.java create mode 100644 src/main/java/com/sqx/modules/taking/service/OrderTakingCommentService.java create mode 100644 src/main/java/com/sqx/modules/taking/service/impl/GameServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/taking/service/impl/OrderTakingCommentServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/trip/controller/TripController.java create mode 100644 src/main/java/com/sqx/modules/trip/controller/app/AppTripController.java create mode 100644 src/main/java/com/sqx/modules/trip/dao/TripDao.java create mode 100644 src/main/java/com/sqx/modules/trip/entity/Trip.java create mode 100644 src/main/java/com/sqx/modules/trip/service/TripService.java create mode 100644 src/main/java/com/sqx/modules/trip/service/impl/TripServiceImpl.java create mode 100644 src/main/java/com/sqx/modules/utils/AliPayOrderUtil.java create mode 100644 src/main/java/com/sqx/modules/utils/AmountCalUtils.java create mode 100644 src/main/java/com/sqx/modules/utils/AppNotifyUtil.java create mode 100644 src/main/java/com/sqx/modules/utils/Base64Utils.java create mode 100644 src/main/java/com/sqx/modules/utils/CertificateUtils.java create mode 100644 src/main/java/com/sqx/modules/utils/CusAccessObjectUtil.java create mode 100644 src/main/java/com/sqx/modules/utils/FileUtils.java create mode 100644 src/main/java/com/sqx/modules/utils/HttpClientUtil.java create mode 100644 src/main/java/com/sqx/modules/utils/HttpUtil.java create mode 100644 src/main/java/com/sqx/modules/utils/InvitationCodeUtil.java create mode 100644 src/main/java/com/sqx/modules/utils/LonLatUtil.java create mode 100644 src/main/java/com/sqx/modules/utils/MD5Util.java create mode 100644 src/main/java/com/sqx/modules/utils/PeriodUtil.java create mode 100644 src/main/java/com/sqx/modules/utils/SenInfoCheckUtil.java create mode 100644 src/main/java/com/sqx/modules/utils/Template.java create mode 100644 src/main/java/com/sqx/modules/utils/TemplateParam.java create mode 100644 src/main/java/com/sqx/modules/utils/TreeUtils.java create mode 100644 src/main/java/com/sqx/modules/utils/VerifyIdCardUtils.java create mode 100644 src/main/java/com/sqx/modules/utils/WXConfigUtil.java create mode 100644 src/main/java/com/sqx/modules/utils/WxMssVo.java create mode 100644 src/main/java/com/sqx/modules/utils/address/AddressUtil.java create mode 100644 src/main/java/com/sqx/modules/utils/address/WSSsdrAddress.java create mode 100644 src/main/java/com/sqx/modules/utils/excel/ExcelData.java create mode 100644 src/main/java/com/sqx/modules/utils/excel/ExcelUtils.java create mode 100644 src/main/java/com/sqx/modules/utils/excel/ExportExcelUtils.java create mode 100644 src/main/java/com/sqx/ws/BaseInfoModel.java create mode 100644 src/main/java/com/sqx/ws/BaseModelEncoder.java create mode 100644 src/main/java/com/sqx/ws/BaseResponseMessage.java create mode 100644 src/main/java/com/sqx/ws/HashMapEncoder.java create mode 100644 src/main/resources/application-prod.yml create mode 100644 src/main/resources/application-test.yml create mode 100644 src/main/resources/application.yml create mode 100644 src/main/resources/banner/banner.jpg create mode 100644 src/main/resources/mapper/app/AddressDao.xml create mode 100644 src/main/resources/mapper/app/AppDao.xml create mode 100644 src/main/resources/mapper/app/MsgDao.xml create mode 100644 src/main/resources/mapper/app/UserBrowseDao.xml create mode 100644 src/main/resources/mapper/app/UserCertificationDao.xml create mode 100644 src/main/resources/mapper/app/UserDao.xml create mode 100644 src/main/resources/mapper/app/UserFollowDao.xml create mode 100644 src/main/resources/mapper/app/UserMoneyArtificerDao.xml create mode 100644 src/main/resources/mapper/app/UserMoneyDao.xml create mode 100644 src/main/resources/mapper/app/UserMoneyDetailsDao.xml create mode 100644 src/main/resources/mapper/app/UserVisitorDao.xml create mode 100644 src/main/resources/mapper/artificer/ArtificerDao.xml create mode 100644 src/main/resources/mapper/artificer/ArtificerMassageMapper.xml create mode 100644 src/main/resources/mapper/artificer/CollectArtificerDao.xml create mode 100644 src/main/resources/mapper/artificer/MassageTypeDao.xml create mode 100644 src/main/resources/mapper/artificer/OrdersDao.xml create mode 100644 src/main/resources/mapper/artificer/RealNameMapper.xml create mode 100644 src/main/resources/mapper/artificer/UserRechargeDao.xml create mode 100644 src/main/resources/mapper/banner/ActivityDao.xml create mode 100644 src/main/resources/mapper/banner/BannerDao.xml create mode 100644 src/main/resources/mapper/chat/ChatContentDao.xml create mode 100644 src/main/resources/mapper/chat/ChatConversationDao.xml create mode 100644 src/main/resources/mapper/common/CommonInfoDao.xml create mode 100644 src/main/resources/mapper/consortia/ConsortiaMapper.xml create mode 100644 src/main/resources/mapper/coupon/CouponIssueMapper.xml create mode 100644 src/main/resources/mapper/coupon/TbCouponMapper.xml create mode 100644 src/main/resources/mapper/coupon/TbCouponUserMapper.xml create mode 100644 src/main/resources/mapper/invite/InviteDao.xml create mode 100644 src/main/resources/mapper/invite/InviteMoneyDao.xml create mode 100644 src/main/resources/mapper/job/ScheduleJobDao.xml create mode 100644 src/main/resources/mapper/job/ScheduleJobLogDao.xml create mode 100644 src/main/resources/mapper/material/MaterialArtificerMapper.xml create mode 100644 src/main/resources/mapper/material/MaterialMapper.xml create mode 100644 src/main/resources/mapper/material/MaterialMassageMapper.xml create mode 100644 src/main/resources/mapper/material/MaterialRecordMapper.xml create mode 100644 src/main/resources/mapper/message/ActivityMessageInfoDao.xml create mode 100644 src/main/resources/mapper/message/MessageInfoAudioDao.xml create mode 100644 src/main/resources/mapper/message/MessageInfoDao.xml create mode 100644 src/main/resources/mapper/oss/SysOssDao.xml create mode 100644 src/main/resources/mapper/pay/CashDao.xml create mode 100644 src/main/resources/mapper/pay/PayClassifyDao.xml create mode 100644 src/main/resources/mapper/pay/PayDetailsDao.xml create mode 100644 src/main/resources/mapper/risk/RiskDao.xml create mode 100644 src/main/resources/mapper/search/AppSearchDao.xml create mode 100644 src/main/resources/mapper/sys/SysConfigDao.xml create mode 100644 src/main/resources/mapper/sys/SysDictDao.xml create mode 100644 src/main/resources/mapper/sys/SysLogDao.xml create mode 100644 src/main/resources/mapper/sys/SysMenuDao.xml create mode 100644 src/main/resources/mapper/sys/SysRoleDao.xml create mode 100644 src/main/resources/mapper/sys/SysRoleMenuDao.xml create mode 100644 src/main/resources/mapper/sys/SysUserDao.xml create mode 100644 src/main/resources/mapper/sys/SysUserRoleDao.xml create mode 100644 src/main/resources/mapper/sys/SysUserTokenDao.xml create mode 100644 src/main/resources/mapper/taking/OrderTakingCommentDao.xml create mode 100644 src/main/resources/mapper/taking/OrderTakingDao.xml create mode 100644 src/main/resources/weixin/apiclient_cert.p12 create mode 100644 tbdm.bat diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d0ad017 --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +**/static/** +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +WebMvcConfiguration.java +WebSocketConfig.java +application-dev.yml +application-local.yml +/logs/anmo.log +/logs diff --git a/README.md b/README.md new file mode 100644 index 0000000..11e0288 --- /dev/null +++ b/README.md @@ -0,0 +1,71 @@ +**项目说明** +- sqx-fast是一个轻量级的,前后端分离的Java快速开发平台,能快速开发项目并交付 +- 支持MySQL、PostgreSQL等主流数据库 +
+ + +**具有如下特点** +- 友好的代码结构及注释,便于阅读及二次开发 +- 实现前后端分离,通过token进行数据交互,前端再也不用关注后端技术 +- 灵活的权限控制,可控制到页面或按钮,满足绝大部分的权限需求 +- 页面交互使用Vue2.x,极大的提高了开发效率 +- 完善的代码生成机制,可在线生成entity、xml、dao、service、vue、sql代码,减少70%以上的开发任务 +- 引入quartz定时任务,可动态完成任务的添加、修改、删除、暂停、恢复及日志查看等功能 +- 引入API模板,根据token作为登录令牌,极大的方便了APP接口开发 +- 引入Hibernate Validator校验框架,轻松实现后端校验 +- 引入云存储服务,已支持:七牛云、阿里云、腾讯云等 +- 引入swagger文档支持,方便编写API接口文档 +
+ +**项目结构** +``` +sqx_fast +├─db 项目SQL语句 +│ +├─common 公共模块 +│ ├─aspect 系统日志 +│ ├─exception 异常处理 +│ ├─validator 后台校验 +│ └─xss XSS过滤 +│ +├─config 配置信息 +│ +├─modules 功能模块 +│ ├─app API接口模块(APP调用) +│ ├─job 定时任务模块 +│ ├─oss 文件服务模块 +│ └─sys 权限模块 +│ +├─sqxApplication 项目启动类 +│ +├──resources +│ ├─mapper SQL对应的XML文件 +│ └─static 静态资源 + +``` +
+ +**技术选型:** +- 核心框架:Spring Boot 2.1 +- 安全框架:Apache Shiro 1.4 +- 视图框架:Spring MVC 5.0 +- 持久层框架:MyBatis 3.3 +- 定时器:Quartz 2.3 +- 数据库连接池:Druid 1.0 +- 日志管理:SLF4J 1.7、Log4j +- 页面交互:Vue2.x +
+ + + **后端部署** +- 通过git下载源码 +- idea、eclipse需安装lombok插件,不然会提示找不到entity的get set方法 +- 创建数据库sqx_fast,数据库编码为UTF-8 +- 执行db/mysql.sql文件,初始化数据 +- 修改application-dev.yml,更新MySQL账号和密码 +- Eclipse、IDEA运行sqxApplication.java,则可启动项目 +- Swagger文档路径:http://localhost:8080/sqx_fast/swagger/index.html +- Swagger注解路径:http://localhost:8080/sqx_fast/swagger-ui.html + + +
diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..8465a1c --- /dev/null +++ b/build.bat @@ -0,0 +1,3 @@ +@echo off +call mvn clean package +pause \ No newline at end of file diff --git a/db/anmo.sql b/db/anmo.sql new file mode 100644 index 0000000..8131039 --- /dev/null +++ b/db/anmo.sql @@ -0,0 +1,2977 @@ +/* + Navicat Premium Data Transfer + + Source Server : 服务器数据库 + Source Server Type : MySQL + Source Server Version : 50734 + Source Host : 42.193.11.150:3306 + Source Schema : z2 + + Target Server Type : MySQL + Target Server Version : 50734 + File Encoding : 65001 + + Date: 08/03/2023 13:28:35 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for address +-- ---------------------------- +DROP TABLE IF EXISTS `address`; +CREATE TABLE `address` ( + `address_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '地址id', + `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '姓名', + `phone` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '电话', + `province` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '省', + `city` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '市', + `district` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '区', + `details_address` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '详细地址', + `is_default` int(11) NULL DEFAULT NULL COMMENT '是否是默认地址 0 否 1是', + `create_time` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '时间', + `user_id` int(11) NULL DEFAULT NULL, + `longitude` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `latitude` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`address_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 73 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of address +-- ---------------------------- + +-- ---------------------------- +-- Table structure for adverti +-- ---------------------------- +DROP TABLE IF EXISTS `adverti`; +CREATE TABLE `adverti` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '广告id', + `create_at` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建时间', + `img_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '图片路径', + `link_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '页面路由', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of adverti +-- ---------------------------- +INSERT INTO `adverti` VALUES (1, '2021-08-14 17:46:02', 'https://sac.xianmxkj.com/img/20210814/15c7f30c6fb040c4a2832abf2decf045.png', '/pages/index/mian'); + +-- ---------------------------- +-- Table structure for agency +-- ---------------------------- +DROP TABLE IF EXISTS `agency`; +CREATE TABLE `agency` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '申请id', + `city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '城市', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '姓名', + `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '电话', + `age` int(11) NULL DEFAULT NULL COMMENT '年龄', + `img` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '头像', + `user_id` int(11) NULL DEFAULT NULL COMMENT '用户id', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '时间', + `status` int(11) NULL DEFAULT NULL COMMENT '状态0待审核 1同意 2拒绝', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 24 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of agency +-- ---------------------------- + +-- ---------------------------- +-- Table structure for app +-- ---------------------------- +DROP TABLE IF EXISTS `app`; +CREATE TABLE `app` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `android_wgt_url` varchar(600) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, + `create_at` varchar(600) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL, + `des` varchar(600) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, + `ios_version` varchar(255) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL, + `ios_wgt_url` varchar(600) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, + `method` varchar(600) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL, + `version` varchar(600) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL, + `wgt_url` varchar(600) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, + `classify` int(11) NULL DEFAULT NULL COMMENT '1 用户端 2技师端', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = big5 COLLATE = big5_chinese_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of app +-- ---------------------------- +INSERT INTO `app` VALUES (5, 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-e456bae7-a062-42af-9507-4ec00ceb0b59/6dfe11de-fe9c-477d-9a81-e3ec04ca1160.apk', '2020-07-20 18:35:00', '升级', NULL, '', 'false', '1.0.0', 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-e456bae7-a062-42af-9507-4ec00ceb0b59/6dfe11de-fe9c-477d-9a81-e3ec04ca1160.apk', 1); +INSERT INTO `app` VALUES (7, '333333', '2022-02-11 15:03:59', 'sdfasdf', 'werqwerwqr', 'wqerwqer', 'false', 'ewrqwwqe', '1123123', 2); + +-- ---------------------------- +-- Table structure for apply +-- ---------------------------- +DROP TABLE IF EXISTS `apply`; +CREATE TABLE `apply` ( + `apply_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '申请id', + `apply_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '姓名', + `apply_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '电话', + `apply_age` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '年龄', + `apply_content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '内容', + `classify` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '分类 1推广员 2代理商', + `user_id` int(11) NULL DEFAULT NULL COMMENT '用户id', + `status` int(11) NULL DEFAULT NULL COMMENT '状态 1待审核 2通过 3拒绝', + `audit_content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '审核内容', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`apply_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 29 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of apply +-- ---------------------------- + +-- ---------------------------- +-- Table structure for artificer +-- ---------------------------- +DROP TABLE IF EXISTS `artificer`; +CREATE TABLE `artificer` ( + `artificer_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '技师id', + `user_id` int(11) NULL DEFAULT NULL COMMENT '用户id', + `artificer_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '技师名称', + `artificer_img` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '技师图片', + `longitude` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '经度', + `latitude` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '纬度', + `life_photo` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '技师生活照', + `certificate` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '证书', + `content` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '描述', + `working_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '从业时长', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + `artificer_sales` int(11) NULL DEFAULT NULL COMMENT '技师销量', + `begin_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '接单起始时间', + `finish_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '结束时间', + `status` int(11) NULL DEFAULT NULL COMMENT '上下线', + `city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '城市', + `classify_id` int(11) NULL DEFAULT NULL COMMENT '认证类型id', + `trip_way` int(11) NULL DEFAULT NULL COMMENT '出行方式', + `credit_score` decimal(10, 2) NULL DEFAULT NULL COMMENT '信誉分', + `add_artificer_money` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `is_goods` int(11) NULL DEFAULT NULL, + `is_hot` int(11) NULL DEFAULT NULL, + `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `rate` decimal(10,2) DEFAULT NULL, + PRIMARY KEY (`artificer_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 84 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of artificer +-- ---------------------------- + +-- ---------------------------- +-- Table structure for artificer_massage +-- ---------------------------- +DROP TABLE IF EXISTS `artificer_massage`; +CREATE TABLE `artificer_massage` ( + `artificer_massage_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '技术服务id', + `artificer_id` int(11) NULL DEFAULT NULL COMMENT '技师id', + `massage_type_id` int(11) NULL DEFAULT NULL COMMENT '服务id', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + `status` int(11) NULL DEFAULT NULL COMMENT '服务是否上架 0上架 1下架', + PRIMARY KEY (`artificer_massage_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 188 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of artificer_massage +-- ---------------------------- + +-- ---------------------------- +-- Table structure for artificer_time +-- ---------------------------- +DROP TABLE IF EXISTS `artificer_time`; +CREATE TABLE `artificer_time` ( + `artificer_time_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '师傅时间配置id', + `artificer_id` int(11) NULL DEFAULT NULL COMMENT '技师id', + `artificer_date` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '日期', + `artificer_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '时分秒', + `classify` int(11) NULL DEFAULT NULL COMMENT '1订单占用 2技师设置', + `orders_id` int(11) NULL DEFAULT NULL COMMENT '订单id', + `create_time` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`artificer_time_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 194 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of artificer_time +-- ---------------------------- + +-- ---------------------------- +-- Table structure for banner +-- ---------------------------- +DROP TABLE IF EXISTS `banner`; +CREATE TABLE `banner` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'bannerid', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '名称', + `image_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '图片地址', + `state` int(2) NULL DEFAULT NULL COMMENT '状态1正常2隐藏', + `classify` int(2) NULL DEFAULT NULL COMMENT '分类1banner图2金刚区分类', + `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '跳转地址 ', + `sort` int(4) NULL DEFAULT NULL COMMENT '顺序', + `describes` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '描述', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 32 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of banner +-- ---------------------------- +INSERT INTO `banner` VALUES (1, '2023-01-06 14:07:10', '轮播', 'https://yuesao.xianmxkj.com/file/uploadPath/2023/01/06/df5cdf396838ac2fc6cfc34ed5d31c94.png', 1, 1, 'https://shegnqx.oss-cn-beijing.aliyuncs.com/20200804/2b33cfd09af84c3ca4aedbde6af7d469.png', 1, '轮播'); +INSERT INTO `banner` VALUES (10, '2022-02-23 09:15:11', '按摩理疗', 'https://jiazheng.xianmxkj.com/file/uploadPath/2021/11/30/a4be84c4d972a618b52b81fcd4ea42df.png', 1, 2, '/pages/index/game/order?massageTypeId=17&name=全身SPA', NULL, '按摩理疗'); +INSERT INTO `banner` VALUES (11, '2022-02-23 09:15:11', '全身SPA', 'https://jiazheng.xianmxkj.com/file/uploadPath/2021/11/30/63ef000d158217f135cf419b973e7b1f.png', 1, 2, '/pages/index/game/order?massageTypeId=17&name=全身SPA', NULL, '全身SPA'); +INSERT INTO `banner` VALUES (12, '2022-02-23 09:15:11', '足疗按摩', 'https://jiazheng.xianmxkj.com/file/uploadPath/2021/11/30/609492e0f1bae110d1486bf7845eb02d.png', 1, 2, '/pages/index/game/order?massageTypeId=17&name=全身SPA', NULL, '足疗按摩'); +INSERT INTO `banner` VALUES (13, '2022-02-23 09:15:11', '中医推拿', 'https://jiazheng.xianmxkj.com/file/uploadPath/2021/11/30/379d195183e34cd849e83e3cbc708cd5.png', 1, 2, '/pages/index/game/order?massageTypeId=17&name=全身SPA', NULL, '中医推拿'); +INSERT INTO `banner` VALUES (15, '2022-02-23 09:15:11', '艾灸刮痧', 'https://jiazheng.xianmxkj.com/file/uploadPath/2021/11/30/eb2669c23120d10fda6b7b9da1b06ccb.png', 1, 2, '/pages/index/game/order?massageTypeId=17&name=全身SPA', NULL, '艾灸刮痧'); +INSERT INTO `banner` VALUES (19, '2023-02-15 14:14:52', '邀请背景图', 'https://anmo.xianmxkj.com/file/uploadPath/2023/02/15/0c36331e0e6cf9126c3971739c2b7db3.png', 1, 5, 'https://yuesao.xianmxkj.com', NULL, '邀请背景图'); +INSERT INTO `banner` VALUES (28, '2022-01-07 13:29:05', '测试分类', 'https://yuesao.xianmxkj.com/file/uploadPath/2022/01/07/3e96d729b23b8e75e9d8161274532f27.png', 2, 2, '111111', NULL, '测试'); +INSERT INTO `banner` VALUES (29, '2023-01-06 14:07:10', '1', 'https://yuesao.xianmxkj.com/file/uploadPath/2023/01/06/62eff023f89bb581800e67693f351a25.png', 1, 1, '1', NULL, '1'); +INSERT INTO `banner` VALUES (30, '2023-01-06 14:07:43', '1', 'https://yuesao.xianmxkj.com/file/uploadPath/2023/01/06/0065c5ab33a3b7370d3cc70227c99adf.png', 1, 1, '1', NULL, '1'); +INSERT INTO `banner` VALUES (31, '2023-01-06 14:07:49', '1', 'https://yuesao.xianmxkj.com/file/uploadPath/2023/01/06/db0a230dac02786b058018b62efcf168.png', 1, 1, '1', NULL, '1'); +INSERT INTO `banner` VALUES (32, '2023-08-24 16:11:13', '技师邀请图', 'https://anmo5.0.xianmaxiong.com/file/uploadPath/2023/08/24/4fd10ebbedec3160c5c373c74111160f.png', 1, 6, '1', NULL, '1'); + + +-- ---------------------------- +-- Table structure for cash_out +-- ---------------------------- +DROP TABLE IF EXISTS `cash_out`; +CREATE TABLE `cash_out` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '申请提现id', + `create_at` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '申请时间', + `is_out` int(2) NULL DEFAULT NULL COMMENT '是否转账', + `money` decimal(10, 2) NULL DEFAULT NULL COMMENT '提现金额', + `out_at` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '转账时间', + `relation_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '会员编号', + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id', + `zhifubao` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付宝账号', + `zhifubao_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付宝姓名', + `order_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '订单编号', + `state` int(11) NULL DEFAULT NULL COMMENT '状态 0待转账 1成功 -1退款', + `refund` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `classify` int(11) NULL DEFAULT NULL, + `rate` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '利息', + `user_type` int(11) NULL DEFAULT NULL, + `bank_card` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '银行卡号', + `bank_card_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '银行名称', + `bank_card_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '银行卡用户姓名', + `bank_card_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '银行开户行地址', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 129 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cash_out +-- ---------------------------- + +-- ---------------------------- +-- Table structure for certification +-- ---------------------------- +DROP TABLE IF EXISTS `certification`; +CREATE TABLE `certification` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '用户实名认证id', + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id', + `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '真实姓名', + `id_number` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '身份证号码', + `birthdate` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '出生年月日', + `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '地址', + `sex` int(11) NULL DEFAULT NULL COMMENT '性别 1男 2女', + `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '电话', + `individual_resume` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '个人简介', + `front` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '正面照', + `back` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '反面照', + `certification` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '资格证书', + `avatar` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '头像', + `image_photo` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '形象照', + `create_time` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + `status` int(255) NULL DEFAULT NULL COMMENT '0审核中1审核成功2拒绝3申请退还保证金', + `remek` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '说明', + `update_time` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '修改时间', + `classify_id` int(11) NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 144 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of certification +-- ---------------------------- + +-- ---------------------------- +-- Table structure for chat_content +-- ---------------------------- +DROP TABLE IF EXISTS `chat_content`; +CREATE TABLE `chat_content` ( + `chat_content_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '聊天内容id', + `chat_conversation_id` int(11) NULL DEFAULT NULL COMMENT '聊天会话id', + `content` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '内容', + `message_type` int(11) NULL DEFAULT NULL COMMENT '类型 1文字 2图片 3语音', + `width` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '图片宽度', + `height` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '图片高度', + `user_id` int(11) NULL DEFAULT NULL COMMENT '发送用户id', + `status` int(11) NULL DEFAULT NULL COMMENT '0未读 1已读', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '发送时间', + PRIMARY KEY (`chat_content_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 506 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of chat_content +-- ---------------------------- + +-- ---------------------------- +-- Table structure for chat_conversation +-- ---------------------------- +DROP TABLE IF EXISTS `chat_conversation`; +CREATE TABLE `chat_conversation` ( + `chat_conversation_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '聊天会话id', + `user_id` int(11) NULL DEFAULT NULL COMMENT '发送用户id', + `focused_user_id` int(11) NULL DEFAULT NULL COMMENT '接受用户id', + `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '状态', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + `update_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新时间', + `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`chat_conversation_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 88 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of chat_conversation +-- ---------------------------- + +-- ---------------------------- +-- Table structure for chats +-- ---------------------------- +DROP TABLE IF EXISTS `chats`; +CREATE TABLE `chats` ( + `chat_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '会话id', + `create_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + `user_count` int(20) NULL DEFAULT 0 COMMENT '用户未读条数', + `user_count2` int(20) NULL DEFAULT 0 COMMENT '好友未读条数', + `user_head` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户头像', + `user_head2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '好友头像', + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id', + `user_id2` bigint(20) NULL DEFAULT NULL COMMENT '好友id', + `user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户昵称', + `user_name2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '好友昵称', + `store_count` int(11) NULL DEFAULT 0 COMMENT '后台未读条数', + `store_head` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '后台头像', + `store_id` bigint(20) NULL DEFAULT NULL COMMENT '总后台id(总后台传0', + `store_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户昵称', + PRIMARY KEY (`chat_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 113 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '聊天会话' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of chats +-- ---------------------------- + +-- ---------------------------- +-- Table structure for chats_content +-- ---------------------------- +DROP TABLE IF EXISTS `chats_content`; +CREATE TABLE `chats_content` ( + `chat_content_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '会话内容id', + `chat_id` bigint(20) NULL DEFAULT NULL COMMENT '会话Id', + `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '聊天内容', + `create_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + `send_type` bigint(20) NULL DEFAULT NULL COMMENT '消息来源(1用户消息 2好友消息)', + `status` int(11) NULL DEFAULT 1 COMMENT '是否已读(1未读 2已读)', + `type` int(1) NULL DEFAULT NULL COMMENT '类型(1文字 2图片 3链接)', + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id', + `user_id2` bigint(20) NULL DEFAULT NULL COMMENT '好友id', + `store_id` bigint(20) NULL DEFAULT NULL COMMENT '后台id(总后台传0)', + PRIMARY KEY (`chat_content_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1143 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '聊天会话内容' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of chats_content +-- ---------------------------- + +-- ---------------------------- +-- Table structure for collect_artificer +-- ---------------------------- +DROP TABLE IF EXISTS `collect_artificer`; +CREATE TABLE `collect_artificer` ( + `collect_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '收藏', + `artificer_id` int(11) NULL DEFAULT NULL COMMENT '订单id', + `user_id` int(11) NULL DEFAULT NULL COMMENT '用户id', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建时间', + `classify` int(11) NULL DEFAULT NULL COMMENT '1收藏 2浏览记录', + PRIMARY KEY (`collect_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1812 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '收藏' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of collect_artificer +-- ---------------------------- + +-- ---------------------------- +-- Table structure for comment_fabulous +-- ---------------------------- +DROP TABLE IF EXISTS `comment_fabulous`; +CREATE TABLE `comment_fabulous` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '点赞id', + `taking_comment_id` bigint(20) NULL DEFAULT NULL COMMENT '接单评论id', + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of comment_fabulous +-- ---------------------------- + +-- ---------------------------- +-- Table structure for common_info +-- ---------------------------- +DROP TABLE IF EXISTS `common_info`; +CREATE TABLE `common_info` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '配置文件id', + `create_at` varchar(255) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL COMMENT '创建时间', + `max` varchar(255) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL, + `min` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '配置文件名称', + `type` int(11) NULL DEFAULT NULL COMMENT '类型', + `value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL COMMENT '值', + `condition_from` varchar(255) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL COMMENT '分类', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 378 CHARACTER SET = big5 COLLATE = big5_chinese_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of common_info +-- ---------------------------- +INSERT INTO `common_info` VALUES (1, '2021-09-02 15:46:41', NULL, '客服二维码', 1, 'https://www.gomyorder.cn/custom.jpg', 'image'); +INSERT INTO `common_info` VALUES (2, '2023-02-03 20:59:15', NULL, '公众号二维码', 2, 'https://taobao.xianmxkj.com/erweima.jpg', 'image'); +INSERT INTO `common_info` VALUES (3, '2023-01-28 18:49:11', NULL, '微信公众号标题', 3, '公众号', 'weixin'); +INSERT INTO `common_info` VALUES (4, '2023-01-28 18:49:11', NULL, '微信公众号内容', 4, '公众号内容', 'weixin'); +INSERT INTO `common_info` VALUES (6, '2023-02-15 14:24:40', NULL, '微信公众号APPID ', 5, '', 'weixin'); +INSERT INTO `common_info` VALUES (7, '2023-02-08 22:01:46', NULL, '短信签名', 6, '省钱兄', 'duanxin'); +INSERT INTO `common_info` VALUES (16, '2023-02-15 14:24:44', NULL, '微信公众号秘钥 ', 21, '', 'weixin'); +INSERT INTO `common_info` VALUES (17, '2023-01-28 18:49:43', NULL, '公众号Token', 16, 'mxkj', 'weixin'); +INSERT INTO `common_info` VALUES (18, '2023-01-28 18:49:58', NULL, '公众号EncodingAESKey ', 17, 'qD42ixTtLwDEvex9yg17YHHWkqGMxvQh8P3lRrBZ6Aq', 'weixin'); +INSERT INTO `common_info` VALUES (20, '2023-02-03 20:54:30', NULL, '后台管理平台域名配置 ', 20, 'https://anmoadmin.xianmxkj.com', 'xitong'); +INSERT INTO `common_info` VALUES (21, '2023-02-03 20:54:37', NULL, 'h5服务域名配置 ', 19, 'https://anmo.xianmxkj.com', 'xitong'); +INSERT INTO `common_info` VALUES (22, '2020-07-27 15:17', NULL, '短信服务商(1 开启腾讯云 2 开启阿里云 3短信宝)', 79, '3', 'duanxin'); +INSERT INTO `common_info` VALUES (23, '2023-02-08 22:01:26', NULL, '后台服务名称 ', 12, '省钱兄', 'xitong'); +INSERT INTO `common_info` VALUES (27, '2023-02-03 20:55:03', NULL, '通用APP下载地址 ', 25, '11', 'xitong'); +INSERT INTO `common_info` VALUES (33, '2021-03-15 21:19:27', NULL, '腾讯云短信clientId ', 31, '', 'duanxin'); +INSERT INTO `common_info` VALUES (34, '2020-03-28 00:47', NULL, '腾讯云短信clientSecret ', 32, '', 'duanxin'); +INSERT INTO `common_info` VALUES (47, '2020-03-29 00:21', NULL, '微信小程序APPID', 45, '', 'weixin'); +INSERT INTO `common_info` VALUES (48, '2020-03-29 00:21', NULL, '微信小程序秘钥', 46, '', 'weixin'); +INSERT INTO `common_info` VALUES (51, '2023-02-03 20:55:08', NULL, '分享安卓下载地址', 49, '11', 'xitong'); +INSERT INTO `common_info` VALUES (52, '2023-02-03 20:55:16', NULL, '分享苹果下载地址', 50, '11', 'xitong'); +INSERT INTO `common_info` VALUES (58, '2020-03-29 00:21', NULL, '开启微信登录', 53, '是', 'xitongs'); +INSERT INTO `common_info` VALUES (69, '2023-01-30 18:22:19', NULL, 'APP消息推送PushAppKey', 60, 'j0qnxK8CHq5IPSAojkfNC4', 'push'); +INSERT INTO `common_info` VALUES (70, '2023-01-30 18:22:14', NULL, 'APP消息推送PushAppId', 61, 'UNrMQr363kAeUwiO2HJa28', 'push'); +INSERT INTO `common_info` VALUES (71, '2023-01-30 18:22:27', NULL, 'APP消息推送PushMasterSecret', 62, '8AlquOxOZx92p1iZ9nUV43', 'push'); +INSERT INTO `common_info` VALUES (72, '2020-06-04 16:34', NULL, '企业支付宝APPID', 63, '', 'zhifubao'); +INSERT INTO `common_info` VALUES (73, '2020-06-04 16:34', NULL, '企业支付宝公钥', 64, '', 'zhifubao'); +INSERT INTO `common_info` VALUES (74, '2020-06-04 16:34', NULL, '企业支付宝商户秘钥', 65, '', 'zhifubao'); +INSERT INTO `common_info` VALUES (77, '2021-03-15 21:22:30', NULL, '文件上传阿里云Endpoint', 68, 'https://oss-cn-beijing.aliyuncs.com', 'oss'); +INSERT INTO `common_info` VALUES (78, '2021-03-15 21:22:38', NULL, '文件上传阿里云账号accessKeyId', 69, '', 'oss'); +INSERT INTO `common_info` VALUES (79, '2021-03-15 21:22:46', NULL, '文件上传阿里云账号accessKeySecret', 70, '', 'oss'); +INSERT INTO `common_info` VALUES (80, '2021-03-15 21:22:53', NULL, '文件上传阿里云Bucket名称', 71, 'shegnqx', 'oss'); +INSERT INTO `common_info` VALUES (81, '2021-03-15 21:23:00', NULL, '文件上传阿里云Bucket域名', 72, 'https://shegnqx.oss-cn-beijing.aliyuncs.com', 'oss'); +INSERT INTO `common_info` VALUES (83, '2020-07-27 15:17', NULL, '微信APPappId', 74, '', 'weixin'); +INSERT INTO `common_info` VALUES (84, '2020-07-27 15:17', NULL, '微信商户key', 75, '', 'weixin'); +INSERT INTO `common_info` VALUES (85, '2020-07-27 15:17', NULL, '微信商户号mchId', 76, '', 'weixin'); +INSERT INTO `common_info` VALUES (96, '2020-07-27 15:17', NULL, '阿里云登陆或注册模板code(开启阿里云短信必须配置)', 80, 'SMS_200190994', 'duanxin'); +INSERT INTO `common_info` VALUES (97, '2020-07-27 15:17', NULL, '阿里云找回密码模板code(开启阿里云短信必须配置)', 81, 'SMS_200176048', 'duanxin'); +INSERT INTO `common_info` VALUES (98, '2020-07-27 15:17', NULL, '阿里云绑定手机号模板code(开启阿里云短信必须配置)', 82, 'SMS_200186024', 'duanxin'); +INSERT INTO `common_info` VALUES (99, '2020-07-27 15:17', NULL, '阿里云短信accessKeyId', 83, '', 'duanxin'); +INSERT INTO `common_info` VALUES (100, '2020-07-27 15:17', NULL, '阿里云短信accessSecret', 84, '', 'duanxin'); +INSERT INTO `common_info` VALUES (101, '2021-02-24 18:46:57', NULL, '官方邀请码', 88, '666666', 'xitong'); +INSERT INTO `common_info` VALUES (102, '2022-02-08 17:45:36', NULL, '支付宝转账方式 1支付宝证书 2支付宝秘钥 3手动', 98, '3', 'zhifubao'); +INSERT INTO `common_info` VALUES (103, '2020-07-27 15:17', NULL, '阿里云快递查询AppCode', 103, '', 'xitong'); +INSERT INTO `common_info` VALUES (130, '2021-12-03 16:21:05', NULL, '提现最低额度', 112, '10', 'fuwufei'); +INSERT INTO `common_info` VALUES (134, '2023-02-14 19:55:58', NULL, '海报邀请语', 116, '一键下单 上门服务', 'xitong'); +INSERT INTO `common_info` VALUES (154, '2020-11-04 10:31:40', NULL, '是否开启APP微信分享', 136, '否', 'weixins'); +INSERT INTO `common_info` VALUES (159, '2021-11-02 14:53:27', NULL, 'H5推广是否分享APP下载页面', 141, '否', 'xitongs'); +INSERT INTO `common_info` VALUES (170, '2021-12-03 16:51:14', NULL, '提现手续费', 152, '0.05', 'fuwufei'); +INSERT INTO `common_info` VALUES (171, '2021-09-06 16:19:51', NULL, '最高提现金额', 153, '1000', 'fuwufei'); +INSERT INTO `common_info` VALUES (182, '2020-07-27 15:17', NULL, '短信宝用户名', 164, '', 'duanxin'); +INSERT INTO `common_info` VALUES (183, '2020-07-27 15:17', NULL, '短信宝密码', 165, '', 'duanxin'); +INSERT INTO `common_info` VALUES (184, '2020-11-04 10:31:40', NULL, '支付宝证书路径', 200, 'E:\\gongzuo\\waimai-renwu\\src\\main\\resources\\zhifubao', 'zhifubao'); +INSERT INTO `common_info` VALUES (185, '2020-11-04 10:31:40', NULL, '支付宝支付方式 1证书 2秘钥', 201, '2', 'zhifubao'); +INSERT INTO `common_info` VALUES (201, '2021-08-14 19:10:04', NULL, '隐私政策', 176, '

本应用尊重并保护所有使用服务用户的个人隐私权。为了给您提供更准确、更有个性化的服务,本应用会按照本隐私权政策的规定使用和披露您的个人信息。但本应用将以高度的勤勉、审慎义务对待这些信息。除本隐私权政策另有规定外,在未征得您事先许可的情况下,本应用不会将这些信息对外披露或向第三方提供。本应用会不时更新本隐私权政策。 您在同意本应用服务使用协议之时,即视为您已经同意本隐私权政策全部内容。本隐私权政策属于本应用服务使用协议不可分割的一部分。

1. 适用范围

(a) 在您注册本应用帐号时,您根据本应用要求提供的个人注册信息;

(b) 在您使用本应用网络服务,或访问本应用平台网页时,本应用自动接收并记录的您的浏览器和计算机上的信息,包括但不限于您的IP地址、浏览器的类型、使用的语言、访问日期和时间、软硬件特征信息及您需求的网页记录等数据;

(c) 本应用通过合法途径从商业伙伴处取得的用户个人数据。

您了解并同意,以下信息不适用本隐私权政策:

(a) 您在使用本应用平台提供的搜索服务时输入的关键字信息;

(b) 本应用收集到的您在本应用发布的有关信息数据,包括但不限于参与活动、成交信息及评价详情;

(c) 违反法律规定或违反本应用规则行为及本应用已对您采取的措施。

2. 信息使用

(a)本应用不会向任何无关第三方提供、出售、出租、分享或交易您的个人信息,除非事先得到您的许可,或该第三方和本应用(含本应用关联公司)单独或共同为您提供服务,且在该服务结束后,其将被禁止访问包括其以前能够访问的所有这些资料。

(b) 本应用亦不允许任何第三方以任何手段收集、编辑、出售或者无偿传播您的个人信息。任何本应用平台用户如从事上述活动,一经发现,本应用有权立即终止与该用户的服务协议。

(c) 为服务用户的目的,本应用可能通过使用您的个人信息,向您提供您感兴趣的信息,包括但不限于向您发出产品和服务信息,或者与本应用合作伙伴共享信息以便他们向您发送有关其产品和服务的信息(后者需要您的事先同意)。

3. 信息披露

在如下情况下,本应用将依据您的个人意愿或法律的规定全部或部分的披露您的个人信息:

(a) 经您事先同意,向第三方披露;

(b)为提供您所要求的产品和服务,而必须和第三方分享您的个人信息;

(c) 根据法律的有关规定,或者行政或司法机构的要求,向第三方或者行政、司法机构披露;

(d) 如您出现违反中国有关法律、法规或者本应用服务协议或相关规则的情况,需要向第三方披露;

(e) 如您是适格的知识产权投诉人并已提起投诉,应被投诉人要求,向被投诉人披露,以便双方处理可能的权利纠纷;

(f) 在本应用平台上创建的某一交易中,如交易任何一方履行或部分履行了交易义务并提出信息披露请求的,本应用有权决定向该用户提供其交易对方的联络方式等必要信息,以促成交易的完成或纠纷的解决。

(g) 其它本应用根据法律、法规或者网站政策认为合适的披露。

4. 信息存储和交换

本应用收集的有关您的信息和资料将保存在本应用及(或)其关联公司的服务器上,这些信息和资料可能传送至您所在国家、地区或本应用收集信息和资料所在地的境外并在境外被访问、存储和展示。

5. Cookie的使用

(a) 在您未拒绝接受cookies的情况下,本应用会在您的计算机上设定或取用cookies ,以便您能登录或使用依赖于cookies的本应用平台服务或功能。本应用使用cookies可为您提供更加周到的个性化服务,包括推广服务。

(b) 您有权选择接受或拒绝接受cookies。您可以通过修改浏览器设置的方式拒绝接受cookies。但如果您选择拒绝接受cookies,则您可能无法登录或使用依赖于cookies的本应用网络服务或功能。

(c) 通过本应用所设cookies所取得的有关信息,将适用本政策。

6. 信息安全

(a) 本应用帐号均有安全保护功能,请妥善保管您的用户名及密码信息。本应用将通过对用户密码进行加密等安全措施确保您的信息不丢失,不被滥用和变造。尽管有前述安全措施,但同时也请您注意在信息网络上不存在“完善的安全措施”。

(b) 在使用本应用网络服务进行网上交易时,您不可避免的要向交易对方或潜在的交易对方披露自己的个人信息,如联络方式或者邮政地址。请您妥善保护自己的个人信息,仅在必要的情形下向他人提供。如您发现自己的个人信息泄密,尤其是本应用用户名及密码发生泄露,请您立即联络本应用客服,以便本应用采取相应措施。

7.本隐私政策的更改

(a)如果决定更改隐私政策,我们会在本政策中、本公司网站中以及我们认为适当的位置发布这些更改,以便您了解我们如何收集、使用您的个人信息,哪些人可以访问这些信息,以及在什么情况下我们会透露这些信息。

(b)本公司保留随时修改本政策的权利,因此请经常查看。如对本政策作出重大更改,本公司会通过网站通知的形式告知。

', 'xieyi'); +INSERT INTO `common_info` VALUES (202, '2021-08-14 19:09:54', NULL, '注册协议', 177, '

尊敬的用户您好:在您使用本服务之前,请您认真阅读本用户协议,更好的了解我们所提供的服务以及您享有的权利义务。您开始使用时,即表示您已经了解并确认接受了本文件中的全部条款,包括我们对本服务条款随时做的任何修改。

一、协议的效力

本协议内容包括协议正文及所有已经发布或将来可能发布的各类规则。所有规则为本协议不可分割的组成部分,与协议正文具有同等法律效力。您承诺接受并遵守本协议的约定。如果您不同意本协议的约定,您应立即停止使用本平台服务。

二、用户行为规范

用户同意将不会利用本服务进行任何违法或不正当的活动,包括但不限于下列行为∶

发布或以其它方式传送含有下列内容之一的信息:

反对宪法所确定的基本原则的;

危害国家安全,泄露国家秘密,颠覆国家政权,破坏国家统一的;

损害国家荣誉和利益的;

煽动民族仇恨、民族歧视、破坏民族团结的;

破坏国家宗教政策,宣扬邪教和封建迷信的;

散布谣言,扰乱社会秩序,破坏社会稳定的;

散布淫秽、色情、赌博、暴力、凶杀、恐怖或者教唆犯罪的;

侮辱或者诽谤他人,侵害他人合法权利的;

含有虚假、诈骗、有害、胁迫、侵害他人隐私、骚扰、侵害、中伤、粗俗、猥亵、或其它道德上令人反感的内容;

含有当地法律、法规、规章、条例以及任何具有法律效力之规范所限制或禁止的其它内容的;

含有不适合在本平台展示的内容;

以任何方式危害他人的合法权益;

冒充其他任何人或机构,或以虚伪不实的方式陈述或谎称与任何人或机构有关;

将依据任何法律或合约或法定关系(例如由于雇佣关系和依据保密合约所得知或揭露之内部资料、专属及机密资料)知悉但无权传送之任何内容加以发布、发送电子邮件或以其它方式传送;

将侵害他人著作权、专利权、商标权、商业秘密、或其它专属权利(以下简称“专属权利”)之内容加以发布或以其它方式传送;

将任何广告信函、促销资料、“垃圾邮件”、““滥发信件”、“连锁信件”、“直销”或其它任何形式的劝诱资料加以发布、发送或以其它方式传送;

将设计目的在于干扰、破坏或限制任何计算机软件、硬件或通讯设备功能之计算机病毒(包括但不限于木马程序(trojan horses)、蠕虫(worms)、定时炸弹、删除蝇(cancelbots)(以下简称“病毒”)或其它计算机代码、档案和程序之任何资料,加以发布、发送或以其它方式传送;

干扰或破坏本服务或与本服务相连线之服务器和网络,或违反任何关于本服务连线网络之规定、程序、政策或规范;

跟踪、人肉搜索或以其它方式骚扰他人;

故意或非故意地违反任何适用的当地、国家法律,以及任何具有法律效力的规则;

未经合法授权而截获、篡改、收集、储存或删除他人个人信息、站内邮件或其它数据资料,或将获知的此类资料用于任何非法或不正当目的。

三、知识产权

本平台所有设计图样以及其他图样、产品及服务名称。任何人不得使用、复制或用作其他用途。未经我们许可,任何单位和个人不得私自复制、传播、展示、镜像、上载、下载、使用,或者从事任何其他侵犯我们知识产权的行为。否则,我们将追究相关法律责任。

我们鼓励用户充分利用平台自由地张贴和共享自己的信息,但这些内容必须位于公共领域内,或者用户拥有这些内容的使用权。同时,用户对于其创作并在本平台上发布的合法内容依法享有著作权及其相关权利。

四、免责声明

互联网是一个开放平台,用户将照片等个人资料上传到互联网上,有可能会被其他组织或个人复制、转载、擅改或做其它非法用途,用户必须充分意识此类风险的存在。用户明确同意其使用本服务所存在的风险将完全由其自己承担;因其使用本服务而产生的一切后果也由其自己承担,我们对用户不承担任何责任。

对于用户上传的照片、资料、证件等,已采用相关措施并已尽合理努力进行审核,但不保证其内容的正确性、合法性或可靠性,相关责任由上传上述内容的会员负责。

尽管已采取相应的技术保障措施 ,但用户仍有可能收到各类的广告信或其他不以招聘/应聘为目的邮件或其它方式传送的任何内容,本平台不承担责任。

对于各种广告信息、链接、资讯等,不保证其内容的正确性、合法性或可靠性,相关责任由广告商承担;用户通过本服务与广告商进行任何形式的通讯或商业往来,或参与促销活动,包含相关商品或服务之付款及交付,以及达成的其它任何相关条款、条件、保证或声明,完全为用户与广告商之间之行为,与本平台无关。用户因前述任何交易或前述广告商而遭受的任何性质的损失或损害,本平台不承担任何责任。

本平台不保证其提供的服务一定能满足用户的要求和期望,也不保证服务不会中断,对服务的及时性、安全性、准确性也都不作保证。对于因不可抗力或无法控制的原因造成的网络服务中断或其他缺陷,不承担任何责任。我们不对用户所发布信息的删除或储存失败承担责任。我们有权判断用户的行为是否符合本网站使用协议条款之规定,如果我们认为用户违背了协议条款的规定,我们有终止向其提供服务的权利。

本平台保留变更、中断或终止部分网络服务的权利。保留根据实际情况随时调整平台提供的服务种类、形式的权利。本平台不承担因业务调整给用户造成的损失。本平台仅提供相关服务,除此之外与本服务有关的设备(如电脑、调制解调器及其他与接入互联网有关的装置)及所需的费用(如为接入互联网而支付的电话费及上网费)均应由用户自行负担。

', 'xieyi'); +INSERT INTO `common_info` VALUES (203, '2021-08-14 19:09:54', NULL, '关于我们', 187, '关于我们,有问题可以在线联系客服哦。', 'xieyi'); +INSERT INTO `common_info` VALUES (204, '2023-02-14 18:46:11', NULL, '登录是否获取手机号', 188, '否', 'kaiguan'); +INSERT INTO `common_info` VALUES (217, '2020-07-27 15:17', NULL, '腾讯地图key', 217, 'WI7BZ-YZCKF-U3BJQ-JUMBB-XUQ3E-UXFYU', 'xitong'); +INSERT INTO `common_info` VALUES (234, '2020-11-04 10:31:40', NULL, '上传方式 1阿里云oss 2本地', 234, '2', 'oss'); +INSERT INTO `common_info` VALUES (237, '2023-02-10 14:04:25', NULL, '是否开启公众号', 237, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (238, '2023-01-18 22:51:14', NULL, '小程序上架是否显示', 238, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (240, '2020-11-04 10:31:40', NULL, '是否开启腾讯云实名认证', 240, '否', 'kaiguan'); +INSERT INTO `common_info` VALUES (241, '2022-02-12 10:52:01', NULL, '师傅实名认证保证金', 241, '0.01', 'fuwufei'); +INSERT INTO `common_info` VALUES (243, '2023-01-16 16:32:08', NULL, '师傅端微信小程序APPID', 243, '', 'weixin'); +INSERT INTO `common_info` VALUES (244, '2023-01-16 16:32:46', NULL, '师傅端微信小程序秘钥', 244, '', 'weixin'); +INSERT INTO `common_info` VALUES (245, '2020-07-27 15:1', NULL, '师傅端微信商户key', 245, '', 'weixin'); +INSERT INTO `common_info` VALUES (246, '2020-07-27 15:1', NULL, '师傅端微信商户号mchId', 246, '', 'weixin'); +INSERT INTO `common_info` VALUES (247, '2020-07-27 15:1', NULL, '小程序师傅端下单成功通知', 247, 'wAOXHhPoQ-isu3K1yVZ4Tq5r-yYLnATaE7gJrn-_kJ8', 'weixin'); +INSERT INTO `common_info` VALUES (248, '2020-07-27 15:1', NULL, '小程序用户端订单取消通知', 248, 'WCglVnYANPEXpKbdCZco7fi3y2pkhdsDMPQJhisycI4', 'weixin'); +INSERT INTO `common_info` VALUES (249, '2020-07-27 15:1', NULL, '小程序师傅端完成订单通知', 249, 'D0J4daOvbKozN4EASyAUqNlM4euGlmGmHizx_nZeXnk', 'weixin'); +INSERT INTO `common_info` VALUES (250, '2020-07-27 15:1', NULL, '小程序用户端完成订单通知', 250, 'tNylkp6qdVRHs8h0xmBKk_LbUrwTpZtBQGaXlfxMsik', 'weixin'); +INSERT INTO `common_info` VALUES (251, '2020-07-27 15:1', NULL, '是否开启用户下单短信通知', 251, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (252, '2023-02-01 11:58:25', NULL, '用户端是否上线', 252, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (253, '2020-07-27 15:1', NULL, '商户端是否上线', 253, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (257, '2020-11-04 10:31:40', NULL, '身份验证SecretID', 257, 'AKIDcs5hbyp6hjweb38a443LDjz41d1dYdhhzw0', 'xitong'); +INSERT INTO `common_info` VALUES (258, '2020-11-04 10:31:40', NULL, '身份验证SecretKey', 258, '7Q2WtQSSvr1PFhUMDEZ6C155mM61kP1ZCVt9ll78', 'xitongs'); +INSERT INTO `common_info` VALUES (259, '2020-11-04 10:31:40', NULL, '身份验证实例ID', 259, 'market', 'xitong'); +INSERT INTO `common_info` VALUES (260, '2020-07-27 15:17', NULL, '商户端微信APPappId', 260, '', 'weixin'); +INSERT INTO `common_info` VALUES (261, '2021-12-02 18:32:06', NULL, '技师端域名', 261, 'https://anmoshop.xianmxkj.com', 'xitong'); +INSERT INTO `common_info` VALUES (281, '2022-11-22 14:05:09', NULL, '新人优惠券', 281, '30', 'xitong'); +INSERT INTO `common_info` VALUES (288, '2023-01-29 15:05:32', NULL, '阿里云语音通知accessKeyId', 288, '', 'duanxin'); +INSERT INTO `common_info` VALUES (289, '2023-01-29 15:05:50', NULL, '阿里云语音通知accessKeySecret', 289, '', 'duanxin'); +INSERT INTO `common_info` VALUES (290, '2023-01-29 15:02:36', NULL, '阿里云语音通知 1公共模式 2专属号码', 290, '1', 'duanxin'); +INSERT INTO `common_info` VALUES (291, '2022-11-22 14:05:09', NULL, '阿里云语音通知专属号码(开启专属号码时填写)', 291, '', 'duanxin'); +INSERT INTO `common_info` VALUES (292, '2023-01-29 15:02:31', NULL, '阿里云语音结束通知语音id', 292, 'TTS_268765011', 'duanxin'); +INSERT INTO `common_info` VALUES (295, '2022-11-22 14:05:09', NULL, '邀请用户平台收益返利比例', 295, '0.1', 'fuwufei'); +INSERT INTO `common_info` VALUES (296, '2023-01-14 16:49:21', NULL, '邀请师傅平台收益返利比例', 296, '0.2', 'fuwufei'); +INSERT INTO `common_info` VALUES (297, '2023-02-14 18:38:30', NULL, '用户端是否上线2', 297, '否', 'kaiguan'); +INSERT INTO `common_info` VALUES (298, '2023-02-15 09:20:41', NULL, '师傅端是否上线2', 298, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (299, '2023-01-18 16:17:29', NULL, '分享文案', 299, '快来下单吧,这里的技师很专业', 'xitong'); +INSERT INTO `common_info` VALUES (300, '2023-01-17 18:05:41', NULL, '分享图片', 300, 'https://www.gomyorder.cn/custom.jpg', 'image'); +INSERT INTO `common_info` VALUES (301, '2023-01-18 17:15:06', NULL, '用户端联系方式 1 手机号 2企业微信', 301, '1', 'kefu'); +INSERT INTO `common_info` VALUES (302, '2023-01-18 18:01:46', NULL, '用户端客服手机号', 302, '0298949111', 'kefu'); +INSERT INTO `common_info` VALUES (303, '2023-01-17 18:05:41', NULL, '用户端企业微信AppId', 303, 'https://www.gomyorder.cn/custom.jpg', 'kefu'); +INSERT INTO `common_info` VALUES (304, '2023-01-17 18:05:41', NULL, '用户端企业微信链接', 304, 'https://www.gomyorder.cn/custom.jpg', 'kefu'); +INSERT INTO `common_info` VALUES (305, '2023-01-18 17:15:16', NULL, '师傅端联系方式 1 手机号 2企业微信', 305, '1', 'kefu'); +INSERT INTO `common_info` VALUES (306, '2023-01-19 09:26:45', NULL, '师傅端客服手机号', 306, '18329688001', 'kefu'); +INSERT INTO `common_info` VALUES (307, '2023-01-17 18:05:41', NULL, '师傅端企业微信AppId', 307, 'https://www.gomyorder.cn/custom.jpg', 'kefu'); +INSERT INTO `common_info` VALUES (308, '2023-01-17 18:05:41', NULL, '师傅端企业微信链接', 308, 'https://www.gomyorder.cn/custom.jpg', 'kefu'); +INSERT INTO `common_info` VALUES (309, '2023-01-17 18:05:41', NULL, '小程序师傅端订单变更通知', 309, 'PwAgkSg5yXTlgihXVxX3mUHqn1nlwuFNaj_AhvoeRFo', 'weixin'); +INSERT INTO `common_info` VALUES (310, '2023-01-29 15:02:25', NULL, '阿里云语音下单通知语音id', 310, 'TTS_268745013', 'duanxin'); +INSERT INTO `common_info` VALUES (311, '2023-01-29 17:04:04', NULL, '是否开启阿里云语音通知', 311, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (312, '2022-11-22 14:05:09', NULL, '公众号客户下单通知', 312, 'v8UhV3ubj51dqr2ViRUkT-N6Noewa9_VQ86aGwg8ahk', 'weixin'); +INSERT INTO `common_info` VALUES (313, '2022-11-22 14:05:09', NULL, '公众号取消订单提醒', 313, 'LZsF483Og56UtUyru-8hTKI3huNC7ZD2_WGmWCOef0c', 'weixin'); +INSERT INTO `common_info` VALUES (314, '2022-11-22 14:05:09', NULL, '公众号订单完成通知', 314, '7MWmJM6y0EJIpQtAkkyMwL57z6i-Kak4Dep1ryKPK1Y', 'weixin'); +INSERT INTO `common_info` VALUES (315, '2022-11-22 14:05:09', NULL, '公众号订单结束提醒', 315, ' TF2QDebLKsa2sOf6ErM72B5mOwOgMnJITrIfaXRTKOk', 'weixin'); +INSERT INTO `common_info` VALUES (316, '2022-11-22 14:05:09', NULL, '订单结束通知提前分钟', 316, '5', 'xitong'); +INSERT INTO `common_info` VALUES (317, '2022-11-22 14:05:09', NULL, '语音提醒方式 1文本转语音 2语音文件', 317, '1', 'duanxin'); +INSERT INTO `common_info` VALUES (318, '2023-02-14 19:56:16', NULL, '是否支持外部浏览器', 318, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (319, '2022-11-22 14:05:09', NULL, '师傅是否可以可以自己修改服务', 319, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (320, '2022-11-22 14:05:09', NULL, '是否开启保证金', 320, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (321, '2023-02-14 19:38:03', NULL, '是否开启会员', 321, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (322, '2023-02-14 19:22:10', NULL, '是否开启推广', 322, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (323, '2020-06-04 16:34', NULL, '评论关键字过滤', 323, '年卡会员VIP同程vipVipVIPVIpvIPviPViP套套,情趣用品,避孕,男用,女用,成人用品,保健品,冈本杜蕾斯杰士邦第六感倍力乐诺丝多乐士斯香妮双一雨蝶玛尼仕,充气娃娃,娃娃充气阴蒂刺激超薄螺纹震动润滑女液体延时,月卡,季卡,年卡,会员卡,超级会员卡,会员,vipVipVIPVIpvIPviPViP套套,情趣用品,避孕,男用,女用,成人用品,保健品,冈本杜蕾斯杰士邦第六感倍力乐诺丝多乐士斯香妮双一雨蝶玛尼仕,充气娃娃,娃娃充气阴蒂刺激超薄螺纹震动润滑女液体延时,月卡,季卡,年卡,会员卡,超级会员卡,会员爱奇艺优酷QQqq百度网盘迅雷腾讯视频携程黑卡去哪儿饿了么美团tvTV芒果会员VIPVIP会员腾讯VIP,优酷VIP,同程VIP,爱奇艺VIP,芒果TV,腾讯TV,爱奇艺TV,优酷TV,TV成人情趣、计生、性保健品', 'xitong'); +INSERT INTO `common_info` VALUES (324, '2023-02-17 20:43:44', NULL, '服务下单最远公里数', 324, '3000', 'fuwufei'); +INSERT INTO `common_info` VALUES (325, '2020-06-04 16:34', NULL, '超时订单超出分钟', 325, '30', 'fuwufei'); +INSERT INTO `common_info` VALUES (326, '2023-03-02 15:10:31', NULL, '提现底部提示', 326, '每月14和28号可提现,节假日顺延,其他时间无法提现', 'fuwufei'); +INSERT INTO `common_info` VALUES (327, '2020-06-04 16:34', NULL, '水印文字', 327, '省钱兄', 'xitong'); +INSERT INTO `common_info` VALUES (328, '2020-06-04 16:34', NULL, '商城配送方式', 328, '快递,自取,同城自取', 'xitong'); +INSERT INTO `common_info` VALUES (329, '2020-06-04 16:34', NULL, '是否开启师傅端商城', 329, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (330, '2023-02-22 15:55:32', NULL, '商家地址', 330, '陕西省西安市雁塔区高新三路(雁塔区高新九号广场(高新三路西))', 'shop'); +INSERT INTO `common_info` VALUES (331, '2020-06-04 16:34', NULL, '商家联系方式', 331, '13000000000', 'shop'); +INSERT INTO `common_info` VALUES (332, '2020-06-04 16:34', NULL, '商家名称', 332, '我是商家', 'shop'); +INSERT INTO `common_info` VALUES (333, '2023-02-22 15:55:34', 'null', '商家经纬度', 333, '34.23884745240398,108.89914512634277', 'shop'); +INSERT INTO `common_info` VALUES (334, '2023-03-02 15:09:17', NULL, '提现日期(逗号间隔)', 334, '14,28', 'fuwufei'); +INSERT INTO `common_info` VALUES (373, '2020-06-04 16:34', NULL, '完成订单需离开当前位置(m)', 373, '500', 'fuwufei'); +INSERT INTO `common_info` VALUES (374, '2021-08-14 19:09:54', NULL, '师傅入驻协议', 374, '

尊敬的用户您好:在您使用本服务之前,请您认真阅读本用户协议,更好的了解我们所提供的服务以及您享有的权利义务。您开始使用时,即表示您已经了解并确认接受了本文件中的全部条款,包括我们对本服务条款随时做的任何修改。

一、协议的效力

本协议内容包括协议正文及所有已经发布或将来可能发布的各类规则。所有规则为本协议不可分割的组成部分,与协议正文具有同等法律效力。您承诺接受并遵守本协议的约定。如果您不同意本协议的约定,您应立即停止使用本平台服务。

二、用户行为规范

用户同意将不会利用本服务进行任何违法或不正当的活动,包括但不限于下列行为∶

发布或以其它方式传送含有下列内容之一的信息:

反对宪法所确定的基本原则的;

危害国家安全,泄露国家秘密,颠覆国家政权,破坏国家统一的;

损害国家荣誉和利益的;

煽动民族仇恨、民族歧视、破坏民族团结的;

破坏国家宗教政策,宣扬邪教和封建迷信的;

散布谣言,扰乱社会秩序,破坏社会稳定的;

散布淫秽、色情、赌博、暴力、凶杀、恐怖或者教唆犯罪的;

侮辱或者诽谤他人,侵害他人合法权利的;

含有虚假、诈骗、有害、胁迫、侵害他人隐私、骚扰、侵害、中伤、粗俗、猥亵、或其它道德上令人反感的内容;

含有当地法律、法规、规章、条例以及任何具有法律效力之规范所限制或禁止的其它内容的;

含有不适合在本平台展示的内容;

以任何方式危害他人的合法权益;

冒充其他任何人或机构,或以虚伪不实的方式陈述或谎称与任何人或机构有关;

将依据任何法律或合约或法定关系(例如由于雇佣关系和依据保密合约所得知或揭露之内部资料、专属及机密资料)知悉但无权传送之任何内容加以发布、发送电子邮件或以其它方式传送;

将侵害他人著作权、专利权、商标权、商业秘密、或其它专属权利(以下简称“专属权利”)之内容加以发布或以其它方式传送;

将任何广告信函、促销资料、“垃圾邮件”、““滥发信件”、“连锁信件”、“直销”或其它任何形式的劝诱资料加以发布、发送或以其它方式传送;

将设计目的在于干扰、破坏或限制任何计算机软件、硬件或通讯设备功能之计算机病毒(包括但不限于木马程序(trojan horses)、蠕虫(worms)、定时炸弹、删除蝇(cancelbots)(以下简称“病毒”)或其它计算机代码、档案和程序之任何资料,加以发布、发送或以其它方式传送;

干扰或破坏本服务或与本服务相连线之服务器和网络,或违反任何关于本服务连线网络之规定、程序、政策或规范;

跟踪、人肉搜索或以其它方式骚扰他人;

故意或非故意地违反任何适用的当地、国家法律,以及任何具有法律效力的规则;

未经合法授权而截获、篡改、收集、储存或删除他人个人信息、站内邮件或其它数据资料,或将获知的此类资料用于任何非法或不正当目的。

三、知识产权

本平台所有设计图样以及其他图样、产品及服务名称。任何人不得使用、复制或用作其他用途。未经我们许可,任何单位和个人不得私自复制、传播、展示、镜像、上载、下载、使用,或者从事任何其他侵犯我们知识产权的行为。否则,我们将追究相关法律责任。

我们鼓励用户充分利用平台自由地张贴和共享自己的信息,但这些内容必须位于公共领域内,或者用户拥有这些内容的使用权。同时,用户对于其创作并在本平台上发布的合法内容依法享有著作权及其相关权利。

四、免责声明

互联网是一个开放平台,用户将照片等个人资料上传到互联网上,有可能会被其他组织或个人复制、转载、擅改或做其它非法用途,用户必须充分意识此类风险的存在。用户明确同意其使用本服务所存在的风险将完全由其自己承担;因其使用本服务而产生的一切后果也由其自己承担,我们对用户不承担任何责任。

对于用户上传的照片、资料、证件等,已采用相关措施并已尽合理努力进行审核,但不保证其内容的正确性、合法性或可靠性,相关责任由上传上述内容的会员负责。

尽管已采取相应的技术保障措施 ,但用户仍有可能收到各类的广告信或其他不以招聘/应聘为目的邮件或其它方式传送的任何内容,本平台不承担责任。

对于各种广告信息、链接、资讯等,不保证其内容的正确性、合法性或可靠性,相关责任由广告商承担;用户通过本服务与广告商进行任何形式的通讯或商业往来,或参与促销活动,包含相关商品或服务之付款及交付,以及达成的其它任何相关条款、条件、保证或声明,完全为用户与广告商之间之行为,与本平台无关。用户因前述任何交易或前述广告商而遭受的任何性质的损失或损害,本平台不承担任何责任。

本平台不保证其提供的服务一定能满足用户的要求和期望,也不保证服务不会中断,对服务的及时性、安全性、准确性也都不作保证。对于因不可抗力或无法控制的原因造成的网络服务中断或其他缺陷,不承担任何责任。我们不对用户所发布信息的删除或储存失败承担责任。我们有权判断用户的行为是否符合本网站使用协议条款之规定,如果我们认为用户违背了协议条款的规定,我们有终止向其提供服务的权利。

本平台保留变更、中断或终止部分网络服务的权利。保留根据实际情况随时调整平台提供的服务种类、形式的权利。本平台不承担因业务调整给用户造成的损失。本平台仅提供相关服务,除此之外与本服务有关的设备(如电脑、调制解调器及其他与接入互联网有关的装置)及所需的费用(如为接入互联网而支付的电话费及上网费)均应由用户自行负担。

', 'xieyi'); +INSERT INTO `common_info` VALUES (375, '2021-08-14 19:09:54', NULL, '是否开启师傅端实时定位', 375, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (376, '2021-08-14 19:09:54', NULL, '警告订单超出分钟', 376, '15', 'fuwufei'); +INSERT INTO `common_info` VALUES (377, '2021-08-14 19:09:54', NULL, '用户是否可以取消订单', 377, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (378, '2023-01-29 15:05:50', NULL, '是否开启银联提现', 378, '否', 'kaiguan'); +INSERT INTO `common_info` VALUES (379, '2023-01-29 15:05:50', NULL, '技师端首页是否弹框', 379, 'https://wap.quanmindaojia.com/file/uploadPath/2023/03/08/7e16e95fc5f3c0e95aff875fdb98c4f2.png', 'image'); +INSERT INTO `common_info` VALUES (380, '2023-03-15 20:48:27', NULL, '技师端首页是否弹框', 380, '否', 'kaiguan'); +INSERT INTO `common_info` VALUES (381, '2021-08-14 19:09:54', NULL, '技师初始化提成', 381, '0.7', 'fuwufei'); +INSERT INTO `common_info` VALUES (382, '2021-08-14 19:09:54', NULL, '阿里云隐私号码池key', 382, '', 'duanxin'); +INSERT INTO `common_info` VALUES (383, '2021-08-14 19:09:54', NULL, '是否开启阿里云隐私电话', 383, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (384, '2021-08-14 19:09:54', NULL, '技师取消订单信誉分单次扣除', 384, '2', 'fuwufei'); +INSERT INTO `common_info` VALUES (385, '2021-08-14 19:09:54', NULL, '取消技师资格信誉分底线', 385, '60', 'fuwufei'); +INSERT INTO `common_info` VALUES (386, '2023-01-29 15:05:32', NULL, '阿里云隐私号码池accessKeyId', 386, '', 'duanxin'); +INSERT INTO `common_info` VALUES (387, '2023-01-29 15:05:50', NULL, '阿里云隐私号码池accessKeySecret', 387, '', 'duanxin'); +INSERT INTO `common_info` VALUES (388, '2023-01-29 15:05:50', NULL, '自动取消时间', 388, '15', 'fuwufei'); +INSERT INTO `common_info` VALUES (389, '2023-03-17 18:36:19', NULL, '是否开启微信提现', 389, '否', 'kaiguan'); +INSERT INTO `common_info` VALUES (390, '2023-03-17 18:51:03', NULL, '是否开启为技师充值', 390, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (391, '2023-03-17 18:51:03', NULL, '下单协议', 391, '

尊敬的用户您好:在您使用本服务之前,请您认真阅读本用户协议,更好的了解我们所提供的服务以及您享有的权利义务。您开始使用时,即表示您已经了解并确认接受了本文件中的全部条款,包括我们对本服务条款随时做的任何修改。

一、协议的效力

本协议内容包括协议正文及所有已经发布或将来可能发布的各类规则。所有规则为本协议不可分割的组成部分,与协议正文具有同等法律效力。您承诺接受并遵守本协议的约定。如果您不同意本协议的约定,您应立即停止使用本平台服务。

二、用户行为规范

用户同意将不会利用本服务进行任何违法或不正当的活动,包括但不限于下列行为∶

发布或以其它方式传送含有下列内容之一的信息:

反对宪法所确定的基本原则的;

危害国家安全,泄露国家秘密,颠覆国家政权,破坏国家统一的;

损害国家荣誉和利益的;

煽动民族仇恨、民族歧视、破坏民族团结的;

破坏国家宗教政策,宣扬邪教和封建迷信的;

散布谣言,扰乱社会秩序,破坏社会稳定的;

散布淫秽、色情、赌博、暴力、凶杀、恐怖或者教唆犯罪的;

侮辱或者诽谤他人,侵害他人合法权利的;

含有虚假、诈骗、有害、胁迫、侵害他人隐私、骚扰、侵害、中伤、粗俗、猥亵、或其它道德上令人反感的内容;

含有当地法律、法规、规章、条例以及任何具有法律效力之规范所限制或禁止的其它内容的;

含有不适合在本平台展示的内容;

以任何方式危害他人的合法权益;

冒充其他任何人或机构,或以虚伪不实的方式陈述或谎称与任何人或机构有关;

将依据任何法律或合约或法定关系(例如由于雇佣关系和依据保密合约所得知或揭露之内部资料、专属及机密资料)知悉但无权传送之任何内容加以发布、发送电子邮件或以其它方式传送;

将侵害他人著作权、专利权、商标权、商业秘密、或其它专属权利(以下简称“专属权利”)之内容加以发布或以其它方式传送;

将任何广告信函、促销资料、“垃圾邮件”、““滥发信件”、“连锁信件”、“直销”或其它任何形式的劝诱资料加以发布、发送或以其它方式传送;

将设计目的在于干扰、破坏或限制任何计算机软件、硬件或通讯设备功能之计算机病毒(包括但不限于木马程序(trojan horses)、蠕虫(worms)、定时炸弹、删除蝇(cancelbots)(以下简称“病毒”)或其它计算机代码、档案和程序之任何资料,加以发布、发送或以其它方式传送;

干扰或破坏本服务或与本服务相连线之服务器和网络,或违反任何关于本服务连线网络之规定、程序、政策或规范;

跟踪、人肉搜索或以其它方式骚扰他人;

故意或非故意地违反任何适用的当地、国家法律,以及任何具有法律效力的规则;

未经合法授权而截获、篡改、收集、储存或删除他人个人信息、站内邮件或其它数据资料,或将获知的此类资料用于任何非法或不正当目的。

三、知识产权

本平台所有设计图样以及其他图样、产品及服务名称。任何人不得使用、复制或用作其他用途。未经我们许可,任何单位和个人不得私自复制、传播、展示、镜像、上载、下载、使用,或者从事任何其他侵犯我们知识产权的行为。否则,我们将追究相关法律责任。

我们鼓励用户充分利用平台自由地张贴和共享自己的信息,但这些内容必须位于公共领域内,或者用户拥有这些内容的使用权。同时,用户对于其创作并在本平台上发布的合法内容依法享有著作权及其相关权利。

四、免责声明

互联网是一个开放平台,用户将照片等个人资料上传到互联网上,有可能会被其他组织或个人复制、转载、擅改或做其它非法用途,用户必须充分意识此类风险的存在。用户明确同意其使用本服务所存在的风险将完全由其自己承担;因其使用本服务而产生的一切后果也由其自己承担,我们对用户不承担任何责任。

对于用户上传的照片、资料、证件等,已采用相关措施并已尽合理努力进行审核,但不保证其内容的正确性、合法性或可靠性,相关责任由上传上述内容的会员负责。

尽管已采取相应的技术保障措施 ,但用户仍有可能收到各类的广告信或其他不以招聘/应聘为目的邮件或其它方式传送的任何内容,本平台不承担责任。

对于各种广告信息、链接、资讯等,不保证其内容的正确性、合法性或可靠性,相关责任由广告商承担;用户通过本服务与广告商进行任何形式的通讯或商业往来,或参与促销活动,包含相关商品或服务之付款及交付,以及达成的其它任何相关条款、条件、保证或声明,完全为用户与广告商之间之行为,与本平台无关。用户因前述任何交易或前述广告商而遭受的任何性质的损失或损害,本平台不承担任何责任。

本平台不保证其提供的服务一定能满足用户的要求和期望,也不保证服务不会中断,对服务的及时性、安全性、准确性也都不作保证。对于因不可抗力或无法控制的原因造成的网络服务中断或其他缺陷,不承担任何责任。我们不对用户所发布信息的删除或储存失败承担责任。我们有权判断用户的行为是否符合本网站使用协议条款之规定,如果我们认为用户违背了协议条款的规定,我们有终止向其提供服务的权利。

本平台保留变更、中断或终止部分网络服务的权利。保留根据实际情况随时调整平台提供的服务种类、形式的权利。本平台不承担因业务调整给用户造成的损失。本平台仅提供相关服务,除此之外与本服务有关的设备(如电脑、调制解调器及其他与接入互联网有关的装置)及所需的费用(如为接入互联网而支付的电话费及上网费)均应由用户自行负担。

', 'xieyi'); +INSERT INTO `common_info` VALUES (392, '2023-03-21 14:00:23', NULL, '忙时时间切换(只限输入 30半个小时 60一个小时)', 392, '30', 'fuwufei'); +INSERT INTO `common_info` VALUES (393, '2023-03-21 14:00:23', NULL, '管理员手机号', 393, '', 'xitong'); +INSERT INTO `common_info` VALUES (394, '2023-03-21 14:00:23', NULL, '是否开启打车费扣提成', 394, '否', 'kaiguan'); +INSERT INTO `common_info` VALUES (395, '2023-03-21 14:00:23', NULL, '是否开启忙时按照项目时间计算', 395, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (396, '2023-03-21 14:00:23', NULL, '是否开启到钟短信提醒', 396, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (397, '2020-11-04 10:31:40', NULL, '腾讯云短信SecretId', 397, '', 'duanxin'); +INSERT INTO `common_info` VALUES (398, '2020-11-04 10:31:40', NULL, '腾讯云短信SecretKey', 398, '', 'duanxin'); +INSERT INTO `common_info` VALUES (399, '2020-11-04 10:31:40', NULL, '腾讯云短信登录或注册模板id', 399, '', 'duanxin'); +INSERT INTO `common_info` VALUES (400, '2020-11-04 10:31:40', NULL, '腾讯云短信找回密码模板id', 400, '', 'duanxin'); +INSERT INTO `common_info` VALUES (401, '2020-11-04 10:31:40', NULL, '腾讯云短信绑定手机号模板id', 401, '', 'duanxin'); +INSERT INTO `common_info` VALUES (402, '2020-11-04 10:31:40', NULL, '腾讯云短信下单通知id', 402, '', 'duanxin'); +INSERT INTO `common_info` VALUES (403, '2020-11-04 10:31:40', NULL, '腾讯云短信订单结束通知id', 403, '', 'duanxin'); +INSERT INTO `common_info` VALUES (404, '2020-11-04 10:31:40', NULL, '腾讯云短信违规通知id', 404, '', 'duanxin'); +INSERT INTO `common_info` VALUES (405, '2020-11-04 10:31:40', NULL, '腾讯云短信商家投诉扣除信誉分通知id', 405, '', 'duanxin'); +INSERT INTO `common_info` VALUES (414, '2023-07-26 16:27:15', NULL, '地图方式 1腾讯 2天地图', 414, '1', 'xitong'); +INSERT INTO `common_info` VALUES (415, '2023-07-26 16:27:15', NULL, '天地图key', 415, '', 'xitong'); +INSERT INTO `common_info` VALUES (418, '2023-07-26 16:27:15', NULL, '阿里云隐私号码通话录音是否开启', 418, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (419, '2023-08-24 15:07:48', NULL, '取消订单扣除百分比', 419, '0', 'fuwufei'); +INSERT INTO `common_info` VALUES (420, '2023-08-25 17:17:10', NULL, '开始服务是否需要上传照片', 420, '是', 'kaiguan'); +INSERT INTO `common_info` VALUES (421, '2023-08-25 10:59:14', NULL, '技师详情顶部图高度', 421, '358', 'xitong'); +INSERT INTO `common_info` VALUES (426, '2023-09-06 14:54:16', NULL, '是否开启来回车费', 426, '是', 'kaiguan'); + + +-- ---------------------------- +-- Table structure for consortia +-- ---------------------------- +DROP TABLE IF EXISTS `consortia`; +CREATE TABLE `consortia` ( + `consortia_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '商家id', + `consortia_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商家名称', + `consortia_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '商家公告', + `logo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '头像 ', + `identity_card` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '身份证号码', + `identity_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '姓名', + `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '电话', + `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '详细地址', + `business_license` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '营业执照', + `qualification_certificate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '资质证书', + `rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '佣金', + `user_id` int(11) NULL DEFAULT NULL COMMENT '商家id', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`consortia_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 27 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of consortia +-- ---------------------------- + +-- ---------------------------- +-- Table structure for coupon +-- ---------------------------- +DROP TABLE IF EXISTS `coupon`; +CREATE TABLE `coupon` ( + `coupon_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '优惠券id', + `coupon_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '优惠券名称', + `coupon_picture` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '优惠券图片', + `end_date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '有效期天数', + `min_money` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '优惠券可使用订单最低金额', + `money` decimal(10, 2) NULL DEFAULT NULL COMMENT '优惠券金额', + PRIMARY KEY (`coupon_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 31 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of coupon +-- ---------------------------- +INSERT INTO `coupon` VALUES (25, '优惠券3', 'https://tcwm.xianmaxiong.com/file/uploadPath/2022/11/09/8bba4cef29578ebf87ad3c5842b25b10.jpeg', '3', '10', 6.00); +INSERT INTO `coupon` VALUES (26, '优惠券2', 'https://tcwm.xianmaxiong.com/file/uploadPath/2022/11/10/6a2ce793ba5d0c3de9e320ade9d89732.jpeg', '5', '8', 5.00); +INSERT INTO `coupon` VALUES (30, '优惠券1', 'https://xiyi.xianmxkj.com/file/uploadPath/2022/11/16/7019ded3ea9fdd8b5408a5f76736889a.png', '2', '2.01', 2.00); + +-- ---------------------------- +-- Table structure for coupon_card +-- ---------------------------- +DROP TABLE IF EXISTS `coupon_card`; +CREATE TABLE `coupon_card` ( + `coupon_card_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '卡密优惠券', + `coupon_card_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '卡密', + `coupon_card_type_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '卡密类型id', + `status` int(11) NULL DEFAULT NULL COMMENT '状态 1待使用 2已领取', + `user_id` int(11) NULL DEFAULT NULL COMMENT '领取用户id', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`coupon_card_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 21 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of coupon_card +-- ---------------------------- +INSERT INTO `coupon_card` VALUES (1, '123456', '1', 2, 69, '2020-12-12 12:12:12'); +INSERT INTO `coupon_card` VALUES (2, '12345678', '1', 2, 154, '2020-12-12 12:12:12'); +INSERT INTO `coupon_card` VALUES (3, '22345678', '1', 1, NULL, '2020-12-12 12:12:12'); +INSERT INTO `coupon_card` VALUES (4, '32345678', '1', 1, NULL, '2020-12-12 12:12:12'); +INSERT INTO `coupon_card` VALUES (12, '56922371', '4', 1, NULL, '2022-11-21 17:49:05'); +INSERT INTO `coupon_card` VALUES (13, '68856586', '3', 2, 466, '2022-11-21 17:50:57'); +INSERT INTO `coupon_card` VALUES (15, '57344411', '6', 2, 466, '2022-11-21 18:24:56'); +INSERT INTO `coupon_card` VALUES (16, '80294664', '6', 1, NULL, '2022-11-21 18:24:56'); +INSERT INTO `coupon_card` VALUES (17, '71057388', '7', 1, NULL, '2022-11-22 16:14:39'); +INSERT INTO `coupon_card` VALUES (18, '16902027', '5', 2, 477, '2022-12-02 16:47:33'); +INSERT INTO `coupon_card` VALUES (20, '87243665', '5', 2, 477, '2022-12-05 14:14:45'); + +-- ---------------------------- +-- Table structure for coupon_card_type +-- ---------------------------- +DROP TABLE IF EXISTS `coupon_card_type`; +CREATE TABLE `coupon_card_type` ( + `coupon_card_type_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '卡密类型id', + `coupon_card_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '卡密类型名称', + `coupon_ids` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '包含优惠券', + `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '状态 1开启 2关闭', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`coupon_card_type_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of coupon_card_type +-- ---------------------------- +INSERT INTO `coupon_card_type` VALUES (5, '专属卡密优惠券包', '30,26', '1', '2022-11-21 18:22:16'); +INSERT INTO `coupon_card_type` VALUES (6, '单张优惠券', '25', '1', '2022-11-21 18:24:44'); +INSERT INTO `coupon_card_type` VALUES (7, '11', '30', '2', '2022-11-22 16:14:32'); + +-- ---------------------------- +-- Table structure for coupon_issue +-- ---------------------------- +DROP TABLE IF EXISTS `coupon_issue`; +CREATE TABLE `coupon_issue` ( + `coupon_issue_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '发布优惠券', + `coupon_ids` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '优惠券ids', + `coupon_issue_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '发布优惠券名称', + `coupon_issue_image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '发布优惠券图片', + `coupon_content_image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '优惠券主页图', + `classify` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '分类 1活动优惠券 2售卖优惠券', + `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '价格', + `original_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '原价', + `pay_notice` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '购买须知', + `is_limit` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否限购', + `coupon_num` int(11) NULL DEFAULT NULL COMMENT '发放数量', + `status` int(11) NULL DEFAULT NULL COMMENT '状态 1开启 2关闭', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`coupon_issue_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of coupon_issue +-- ---------------------------- + +-- ---------------------------- +-- Table structure for coupon_user +-- ---------------------------- +DROP TABLE IF EXISTS `coupon_user`; +CREATE TABLE `coupon_user` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NULL DEFAULT NULL COMMENT '用户id', + `coupon_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '优惠券名称', + `coupon_picture` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '优惠券图片', + `create_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '优惠券领取时间', + `employ_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '优惠券使用时间', + `expiration_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '优惠券过期时间', + `min_money` decimal(10, 2) NULL DEFAULT NULL COMMENT '优惠券可使用订单最低金额', + `money` decimal(10, 2) NULL DEFAULT NULL COMMENT '优惠券金额', + `status` int(11) NULL DEFAULT NULL COMMENT '优惠券状态 0正常 1已使用 2已失效', + `end_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '有效天数', + `coupon_issue_id` int(11) NULL DEFAULT NULL COMMENT '领取优惠券的活动id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 2383 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of coupon_user +-- ---------------------------- + +-- ---------------------------- +-- Table structure for game +-- ---------------------------- +DROP TABLE IF EXISTS `game`; +CREATE TABLE `game` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '游戏id', + `game_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '游戏名称', + `status` int(2) NULL DEFAULT NULL COMMENT '0启用1删除\r\n', + `game_img` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '游戏图分类图片', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + `update_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '修改时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of game +-- ---------------------------- +INSERT INTO `game` VALUES (1, '金牌月嫂', 0, 'https://xxpw.xianmxkj.com/file/uploadPath/2021/11/11/049f584624cd7bcca4de6cec506da1fe.png', '2021-08-10 09:46:12', '2021-11-30 10:10:36'); +INSERT INTO `game` VALUES (2, '做饭保姆', 0, 'https://xxpw.xianmxkj.com/file/uploadPath/2021/11/11/ce697f385af35bd4ac9ecd254801b815.png', '2021-08-10 09:46:12', '2021-11-11 17:51:43'); +INSERT INTO `game` VALUES (3, '育婴儿师', 0, 'https://xxpw.xianmxkj.com/file/uploadPath/2021/11/11/3537f952650ad425ba974a1ec4a8bdbc.png', '2021-08-10 09:46:12', '2021-11-30 10:11:16'); +INSERT INTO `game` VALUES (4, '钟点工', 0, 'https://xxpw.xianmxkj.com/file/uploadPath/2021/11/11/fbb61891331030a9f9bf61aa4041c7c6.png', '2021-08-10 09:46:12', '2021-11-30 10:11:33'); +INSERT INTO `game` VALUES (5, '护工护理', 0, 'https://xxpw.xianmxkj.com/file/uploadPath/2021/11/05/91fe0a53bce1db7b00cf14590796a16c.png', '2021-08-10 09:46:12', '2021-11-30 10:11:46'); + +-- ---------------------------- +-- Table structure for goods +-- ---------------------------- +DROP TABLE IF EXISTS `goods`; +CREATE TABLE `goods` ( + `goods_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '商品id', + `goods_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商品标题', + `longitude` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '经度', + `latitude` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '纬度', + `address` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '地址', + `title_img` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '封面图', + `img` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '详情图', + `sum_num` int(11) NULL DEFAULT NULL COMMENT '总数量', + `end_num` int(11) NULL DEFAULT NULL COMMENT '剩余数量', + `goods_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '商品价格', + `member_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '会员满', + `member_money` decimal(10, 2) NULL DEFAULT NULL COMMENT '会员返', + `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '普通用户满', + `money` decimal(10, 2) NULL DEFAULT NULL COMMENT '普通用户返', + `start_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '开始时间', + `end_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '结束时间', + `classify` int(11) NULL DEFAULT NULL COMMENT '分类 1 饿了么 2美团', + `type_id` int(11) NULL DEFAULT NULL COMMENT '类型', + `num_star` int(11) NULL DEFAULT NULL COMMENT '几颗星', + `num_img` int(11) NULL DEFAULT NULL COMMENT '几张图', + `num_word` int(11) NULL DEFAULT NULL COMMENT '多少字', + `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注 富文本', + `url` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '小程序跳转参数', + `status` int(11) NULL DEFAULT NULL COMMENT '1 上架 2下架', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + `province` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '省', + `city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '市', + `district` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '区', + `activity_ids` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '金刚区分类', + `is_goods` int(11) NULL DEFAULT NULL COMMENT '是否是精选商品 0否 1是', + `scope` int(11) NULL DEFAULT NULL COMMENT '范围', + `member_privilege` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '会员权益', + `privilege` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '普通用户权益', + `describes` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '门店介绍', + `shop_describe` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商家介绍', + `phone` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '电话', + PRIMARY KEY (`goods_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 180 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of goods +-- ---------------------------- +INSERT INTO `goods` VALUES (167, '德尚铭车北郊店', '108.9389', '34.35836', '凤城十 二路与文景路 十字西北角', 'https://audi.xianmxkj.com/img/20210625/678e2042e0024788949631e1c201fdcf.png', 'https://audi.xianmxkj.com/img/20210629/72c18fde7ee443fab23e1ea46791f9e3.png', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '08:30:00', '23:40:00', NULL, 23, NULL, NULL, NULL, NULL, NULL, 1, '2021-06-25 10:42:07', '陕西省', '西安市', '未央区', '21', 1, NULL, '会标成员西安市内救援:免费,会标成员刷新隐藏功能:免费,会标成员享受水蜡洗车:每月免费洗车一次,会标成员享受补胎项目:免费,会标成员车辆水蜡洗车:30元/次,会标成员享受添加玻璃水:全年免费', '非车标成员车辆水蜡洗车:60元/次', '

首次进店的会标成员免费洗车

', '

1.会员享受西安市内免费救援.免费刷新隐藏功能.享受每月免费一次水蜡洗车

2.享受全年免费添加玻璃水.享受每年两次免费钻石打蜡.每年免费补胎项目

3.贴标车辆水蜡洗车30元

', '13227737503'); +INSERT INTO `goods` VALUES (168, '新旅程汽车服务连锁(长安区)', '108.937935', '34.158966', '长兴北路乔家 村西门对面', 'https://audi.xianmxkj.com/img/20210625/de5fddb4e1a443bb84b3d5911f477767.png', 'https://audi.xianmxkj.com/img/20210629/72c18fde7ee443fab23e1ea46791f9e3.png', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '08:52:46', '23:52:46', NULL, 25, NULL, NULL, NULL, NULL, NULL, 1, '2021-06-25 13:53:37', '陕西省', '西安市', '长安区', '34', 1, NULL, '1.会标成员西安市内救援:免费,2.会标成员全年补胎:免费,3.会标成员四轮换位一次:免费,4.会标成员全年加玻璃水:免费,5.会标成员全年加防冻液,刹车油:免费,会标成员全年检测 :免费', '', '

每月可免费享 受一次德式三 星洗车(其他时 间洗车可享受 店内会员价)

', '

1.会员每月免费享受一次德式三星洗车

2.西安市内免费救援.全年免费补胎

3.免费四轮换位一次.全年免费加玻璃水

4.全年免费加防冻液刹车油.全年免费检测

', '18392119256'); +INSERT INTO `goods` VALUES (169, '美德豪华汽服(大雁塔)', '108.948051', '34.225315', '雁南一路与慈恩西路东北角海港城9街负一层', 'https://audi.xianmxkj.com/img/20210628/6b6744ade4f44840b941c92a04bc7413.png', 'https://audi.xianmxkj.com/img/20210629/72c18fde7ee443fab23e1ea46791f9e3.png', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '09:16:53', '23:16:53', NULL, 24, NULL, NULL, NULL, NULL, NULL, 1, '2021-06-28 14:26:29', '陕西省', '西安市', '雁塔区', '33', 1, NULL, '1.会标成员常规保养4缸:350 元,2.会标成员常规保养6缸:500 元,3.会标成员四轮定位:每年一次,4.会标成员补胎:全年不限次,5.会标成员加玻璃水:不限次数,6.会标成员全车油液(机油、刹车油、防冻液):免费添加,7.会标成员西安市内救援:免费,8.会标成员全车检查:不限次数,9.会标成员电脑诊断 :不限次数,10.会标成员天窗轨道清洁润滑:免费,11.会标成员洗车:38 元/次', '店面洗车价:98 元/次', '

首次进店的会标成员免费洗车

', '

1. 常规保养4缸350常规保养6缸500元

2.每年一次四轮定位.全年不限次数补胎

3.不限次数加玻璃水.免费添加全车油液

4.西安市内免费救援

5.不限次数全车检查.不限次数电脑诊断

6.天窗轨道清洁润滑

7.贴标洗车38元/次 首次进店的会标成员免费洗车

', '15686085315'); +INSERT INTO `goods` VALUES (170, 'HG 省代.奥嘉 车改俱乐部', '108.830551', '34.274097', '水厂东路 65 号奥嘉车改', 'https://audi.xianmxkj.com/img/20210628/5351885f8535480a9b38480ee1a1125c.png', 'https://audi.xianmxkj.com/img/20210629/72c18fde7ee443fab23e1ea46791f9e3.png', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '17:35:15', '18:35:15', NULL, 24, NULL, NULL, NULL, NULL, NULL, 1, '2021-06-28 17:35:19', '陕西省', '西安市', '未央区', '33', 1, NULL, '会标成员洗车:全年免费,会标成员发放熏黑尾灯膜一套 (价值 128):免费', '', '

每个月初会群里举行抽奖活动,中网、碳纤维材质配件、免费保养等,价值 1000 到 3000+不等

仅限会标车主参与!

', '

1.终生免费洗车,每位会标成员发放熏黑尾灯膜一套! 价值128!

2.每个月月初会在线上举行抽奖活动,中网 碳纤维材质配件 免费保养等,仅限会标群发起抽奖!

', '18066607700'); +INSERT INTO `goods` VALUES (171, '途虎养车', '108.936653', '34.306728', '文 景路 89 号唐安 酒店院内。(延 长石油小区对 面)', 'https://audi.xianmxkj.com/img/20210629/c76ebed28d2447f4b99443e29dc23e95.png', 'https://audi.xianmxkj.com/img/20210629/72c18fde7ee443fab23e1ea46791f9e3.png', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '08:34:29', '23:34:29', NULL, 24, NULL, NULL, NULL, NULL, NULL, 1, '2021-06-29 17:36:06', '陕西省', '西安市', '未央区', '33', 1, NULL, '会标成员添加玻璃水:终身免费,会标成员加充氮气:免费,会标成员臭氧消毒杀菌:免费,会标成员全车电脑检测:会标成员全车电脑检测,会标成员进店赠品牌机滤一个:仅限首次,只 可店内使用,会标成员小保养:终身免工时,会标成员维修工时:5 折,会标成员享受全年洗车机清洗:免费,会标成员享受全车内外清洁:19.9 元,会标成员享受美容项目:全部 5 折优惠,会标成员享受提供西安市救援:免费,会标成员轮胎换位:免费', '', '

会标成员享受全年洗车机清洗 免费 

', '

1.会标车主玻璃水终身免费加,

免费臭氧消毒杀菌 免费加充氮气 免费全车电脑检测终身小保养免工时

2.会标车主享受全年洗车机免费清洗,美容项目全部5折优惠。提供免费救援.提供免费轮胎换位

', '13669251588'); +INSERT INTO `goods` VALUES (172, '圣佳膜咖直营店.3M直营店', '108.896896', '34.269058', '大庆路', 'https://audi.xianmxkj.com/img/20210629/68d95be6f7fe47e79430a84400239728.png', 'https://audi.xianmxkj.com/img/20210629/72c18fde7ee443fab23e1ea46791f9e3.png', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '08:44:04', '21:44:04', NULL, 25, NULL, NULL, NULL, NULL, NULL, 1, '2021-06-29 17:44:56', '陕西省', '西安市', '莲湖区', '34', 1, NULL, '会标成员首月三次车辆精洗:免费', '', '

设置有陕西奥迪俱乐部专属休息室

', '

 首月免费三次车辆精洗 提供免费饮料零食 ,设置有陕西奥迪俱乐部专属休息室

', '13227737503'); +INSERT INTO `goods` VALUES (173, '海底捞', '108.94878', '34.22259', '雁塔区', 'https://audi.xianmxkj.com/img/20210629/57a9f9a2285a491bbf8d13c029346ebd.png', 'https://audi.xianmxkj.com/img/20210629/72c18fde7ee443fab23e1ea46791f9e3.png', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '10:46:54', '18:46:54', NULL, 29, NULL, NULL, NULL, NULL, NULL, 1, '2021-06-29 17:47:58', '陕西省', '西安市', '雁塔区', '45', 1, NULL, '', '', '

登陆俱乐部会员,优先用餐,8折优惠!(只可在西安地区登陆)

', '

登陆俱乐部会员,无需 排队,全国范围内 8.8 折,西安 8 折! 

', '18511013000'); +INSERT INTO `goods` VALUES (174, '蓬盛实弹射击俱乐部', '108.93425', '34.23053', '碑林区', 'https://audi.xianmxkj.com/img/20210629/aea36c11ad644d45955237fd25b94633.png', 'https://audi.xianmxkj.com/img/20210629/72c18fde7ee443fab23e1ea46791f9e3.png', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '11:49:07', '18:49:07', NULL, 27, NULL, NULL, NULL, NULL, NULL, 1, '2021-06-29 17:50:27', '陕西省', '西安市', '碑林区', '45', 1, NULL, '', '', '

提前联系翟经理,提供 姓名,电话,开卡,免 枪支使用费,卡里内赠 10 发小口径。 

来玩的时候携带身份证原件, 酒后不可体验。享受 VIP 待 遇,专人服务!

', '

 凭标无枪械使用费 进店赠送十发小口经子弹!享受VIP待遇,专人服务!户外打猎体验优先待遇!

', '15102910683'); +INSERT INTO `goods` VALUES (175, '西安骏茂超跑豪车俱乐部 ', '108.89075', '34.22847', '科技一路 58 号', 'https://audi.xianmxkj.com/img/20210629/d8f4668a8b8745989f120b375095f921.png', 'https://audi.xianmxkj.com/img/20210629/72c18fde7ee443fab23e1ea46791f9e3.png', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '08:54:55', '18:54:55', NULL, 27, NULL, NULL, NULL, NULL, NULL, 1, '2021-06-29 17:55:08', '陕西省', '西安市', '雁塔区', '45', 1, NULL, '', '', '

所有俱乐部会标成员租车免押金,享受免费送取车服务,所有车型9折优惠!

', '

(价格很透明)针对俱乐 部成员所有车型 8.8 折 优惠,包月低至 7.6 折,跑车、轿车、越野 车、商务车皆可安排。

', '13468666789'); +INSERT INTO `goods` VALUES (176, 'K歌.Club (南郊延平门地铁口)', '108.891121', '34.237465', '南郊延平门 地铁口', 'https://audi.xianmxkj.com/img/20210629/2889dc38a5ee436a81b368d82f1d20db.png', 'https://audi.xianmxkj.com/img/20210629/72c18fde7ee443fab23e1ea46791f9e3.png', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '08:56:21', '18:56:21', NULL, 27, NULL, NULL, NULL, NULL, NULL, 1, '2021-06-29 17:57:55', '陕西省', '西安市', '雁塔区', '45', 1, NULL, '', '', '

入店即送酒水一打,赠送三份小吃,果盘无限续! 注:无最低消费。

', '

入店即送酒水一打,赠送三份小吃,果盘无限续! 注:无最低消费。

', '15596750333'); +INSERT INTO `goods` VALUES (177, '星绽放KTV (南郊群贤路群贤广场4F)', '108.894867', '34.245296', '南郊群贤路 群贤广场 4F', 'https://audi.xianmxkj.com/img/20210629/e79e85895ca14500afe8386704694f81.png', 'https://audi.xianmxkj.com/img/20210629/72c18fde7ee443fab23e1ea46791f9e3.png', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '08:58:33', '18:58:33', NULL, 27, NULL, NULL, NULL, NULL, NULL, 1, '2021-06-29 17:59:22', '陕西省', '西安市', '雁塔区', '45', 1, NULL, '', '', '

会标成员入店即送酒水一打,绿茶一壶 果盘无限续! 小吃无限续!酒水买二送一 注:无最低消费!

', '

会标成员入店即送酒水一打,绿茶一壶 果盘无限续! 小吃无限续!酒水买二送一 注:无最低消费!

', '15809189795'); +INSERT INTO `goods` VALUES (178, '希瑞格酒店', '108.93895', '34.218658', '朱雀大街南 段城市立方 G1 号楼', 'https://audi.xianmxkj.com/img/20210629/b63ad4c81d094dd3bea6ededf230da39.png', 'https://audi.xianmxkj.com/img/20210629/72c18fde7ee443fab23e1ea46791f9e3.png', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '06:00:15', '19:00:15', NULL, 30, NULL, NULL, NULL, NULL, NULL, 1, '2021-06-29 18:02:34', '陕西省', '西安市', '碑林区', '45', 1, NULL, '', '', '

会标成员下午茶用餐等八折,住店赠送早餐俩份,入住所有房型八折优惠,退房延迟至16:00 入住高级房型免费升级豪华房型

', '

会标成员下午茶用餐等八折,住店赠送早餐俩份,入住所有房型八折优惠,退房延迟至16:00 入住高级房型免费升级豪华房型

', '15280212995'); +INSERT INTO `goods` VALUES (179, 'STEK漆面膜陕西总代理(美德)', '108.93425', '34.23053', '碑林区', 'https://audi.xianmxkj.com/img/20210629/d8cd3bb1f78d4a97a1767b776299d873.png', 'https://audi.xianmxkj.com/img/20210629/72c18fde7ee443fab23e1ea46791f9e3.png', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '07:09:32', '19:09:32', NULL, 27, NULL, NULL, NULL, NULL, NULL, 1, '2021-06-29 18:10:36', '陕西省', '西安市', '碑林区', '45', 1, NULL, '加玻璃水:全年免费,西安市救援:终身免费,补胎:终身免费,四轮动平衡:终身免费,享受会员价:28元/次,价值1280元4个B柱车衣保护膜:免费赠送,价值880元前大灯透明保护膜一对:免费赠送,贴车衣膜面养护:终身免费,贴车衣,局部小刮擦修补:终身免费,基础保养会员价4杠:350元/次', '', '

全年免费加玻璃水

', '

全年免费加玻璃水

', '15280212995'); + +-- ---------------------------- +-- Table structure for goods_type +-- ---------------------------- +DROP TABLE IF EXISTS `goods_type`; +CREATE TABLE `goods_type` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '商品类型id', + `create_at` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建时间', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '类型名称', + `img` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '图片', + `parent_id` bigint(20) NULL DEFAULT NULL COMMENT '上级类型id', + `sort` int(11) NULL DEFAULT NULL COMMENT '排序', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 56 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of goods_type +-- ---------------------------- +INSERT INTO `goods_type` VALUES (10, '2021-06-25 10:21:46', '男装', 'https://www.gomyorder.cn/img/20200910/a04b841a1e474c16b589b8e2d3b7843e.png', 0, 1); +INSERT INTO `goods_type` VALUES (12, '2020-09-14 10:51:10', '女装', 'https://www.gomyorder.cn/img/20200910/5a75277d953b4da7a0f89939cc111e64.jpg', 0, 2); +INSERT INTO `goods_type` VALUES (13, '2020-09-14 10:50:59', '衬衫', 'https://www.gomyorder.cn/img/20200910/996b1adeac924abc99404a01e45cb091.jpg', 10, 1); +INSERT INTO `goods_type` VALUES (14, '2020-09-10 14:44:00', '袜子', 'https://www.gomyorder.cn/img/20200910/4c8d907c6d6946c38efbfe786e29ef06.png', 10, 2); +INSERT INTO `goods_type` VALUES (20, '2020-09-14 10:51:17', '童装', 'https://www.gomyorder.cn/img/20200910/135b92402aaa45de882fcb24ccf6aade.png', 0, 3); +INSERT INTO `goods_type` VALUES (21, '2020-09-10 14:45:24', '鞋子', 'https://www.gomyorder.cn/img/20200910/dc1fd03916e743f0a3adce976df05fd2.png', 20, 1); +INSERT INTO `goods_type` VALUES (23, '2020-09-14 10:51:24', '大家电', 'https://www.gomyorder.cn/img/20200910/ff31a115b22f4101a43fee026ce3335e.png', 0, 4); +INSERT INTO `goods_type` VALUES (29, '2020-09-14 14:12:29', '裤子', 'https://www.gomyorder.cn/img/20200914/b4b2551e0dc044be8d4ec5b0141eade7.png', 12, 1); +INSERT INTO `goods_type` VALUES (30, '2020-09-14 14:13:31', '上衣', 'https://www.gomyorder.cn/img/20200914/e14f254f3d04429995744407c03c4d2e.png', 12, 2); +INSERT INTO `goods_type` VALUES (31, '2020-11-30 11:05:10', '瓜果蔬菜', 'https://www.gomyorder.cn/img/20201130/2204b0202e1d4cde8dfdb1839a98c7de.png', 0, 5); +INSERT INTO `goods_type` VALUES (32, '2020-11-30 11:07:05', '苹果', 'https://www.gomyorder.cn/img/20201130/e1286331a4164c8ab7407e60b4fb5f43.png', 31, 5); +INSERT INTO `goods_type` VALUES (33, '2020-11-30 11:08:25', '电视', 'https://www.gomyorder.cn/img/20201130/5a0ff54a5b5745a3b31b1a22f53cc965.png', 23, 5); +INSERT INTO `goods_type` VALUES (34, '2020-11-30 11:10:45', '电子产品', 'https://www.gomyorder.cn/img/20201130/5db7ed61748d4383ae38b7469fce01ac.png', 23, 5); +INSERT INTO `goods_type` VALUES (42, '2021-04-07 14:11:55', '坚果', 'https://tk.gomyorder.cn/img/20210407/d418f717a76b4683bd911583bdab89f8.jpg', 0, 6); +INSERT INTO `goods_type` VALUES (43, '2021-04-07 14:12:51', '麻花', 'https://tk.gomyorder.cn/img/20210407/056a1d7ba629457d88a875788ad008de.jpg', 42, 12); +INSERT INTO `goods_type` VALUES (44, '2021-04-19 21:21:19', '测试', '', 23, 1); +INSERT INTO `goods_type` VALUES (46, '2021-08-10 18:01:59', '衣服', 'https://tk.gomyorder.cn/img/20210628/9697c4f2ba3d4a878c16cfbdf664e470.png', 0, 0); +INSERT INTO `goods_type` VALUES (48, '2021-06-28 15:27:42', '衬衫', 'https://tk.gomyorder.cn/img/20210628/3149b3330050452caa2259b8aa98e434.png', 46, 1); +INSERT INTO `goods_type` VALUES (51, '2021-08-10 17:53:28', '书籍类', 'https://audi.xianmxkj.com/img/20210810/b7e259e4fa7d4fd793f34526a58f02a7.jpg', 0, 1); +INSERT INTO `goods_type` VALUES (52, '2021-08-10 17:53:11', '小孩书籍', 'https://sac.xianmxkj.com/img/20210810/e4ce41a616da4f1daca94fdbed6f42ad.jpg', 51, 1); +INSERT INTO `goods_type` VALUES (53, '2021-08-10 18:03:54', '大孩子书籍', 'https://sac.xianmxkj.com/img/20210810/b7f9db9314d44a07a5cdb37ac7533876.jpg', 51, 1); +INSERT INTO `goods_type` VALUES (54, '2022-05-19 10:13:09', '日用品', 'https://rwshop.xianmxkj.com/file/uploadPath/2022/05/19/9d8f26344499e8f68a4ca33b44db4708.png', 0, 1); +INSERT INTO `goods_type` VALUES (55, '2022-05-19 10:13:31', '垃圾桶', 'https://rwshop.xianmxkj.com/file/uploadPath/2022/05/19/d00844556000c25ad51e26ff1e00c4cf.png', 54, 1); + +-- ---------------------------- +-- Table structure for help_classify +-- ---------------------------- +DROP TABLE IF EXISTS `help_classify`; +CREATE TABLE `help_classify` ( + `help_classify_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '帮助中心分类', + `help_classify_name` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '分类名称', + `sort` int(11) NULL DEFAULT NULL COMMENT '排序', + `parent_id` int(11) NULL DEFAULT NULL COMMENT '上级id', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + `types` int(11) NULL DEFAULT NULL, + PRIMARY KEY (`help_classify_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of help_classify +-- ---------------------------- +INSERT INTO `help_classify` VALUES (7, '登录问题', 0, NULL, '2022-07-06', 1); +INSERT INTO `help_classify` VALUES (8, '商家端入驻申请流程', 0, NULL, '2022-07-06', 2); +INSERT INTO `help_classify` VALUES (9, '商家端怎么发起服务?', 0, NULL, '2022-07-06', 2); +INSERT INTO `help_classify` VALUES (10, '充值问题', 1, NULL, '2023-01-18 17:24:09', 1); + +-- ---------------------------- +-- Table structure for help_word +-- ---------------------------- +DROP TABLE IF EXISTS `help_word`; +CREATE TABLE `help_word` ( + `help_word_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '帮助文档id', + `help_word_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '帮助标题', + `help_word_content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '帮助文档内容', + `help_classify_id` int(11) NULL DEFAULT NULL COMMENT '帮助分类id', + `sort` int(11) NULL DEFAULT NULL COMMENT '排序', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`help_word_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 15 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of help_word +-- ---------------------------- +INSERT INTO `help_word` VALUES (1, '为什么提示不支持打开非业务域名', '因为所以科学道理', 2, 1, '2020-12-12 12:12:12'); +INSERT INTO `help_word` VALUES (2, '文件类课间如何保存', '不知道', 2, 2, '2020-12-12 12:12:12'); +INSERT INTO `help_word` VALUES (3, '已报名的活动可以取消吗', '可以,需要扣除百分之20', 3, 1, '2020-12-12 12:12:12'); +INSERT INTO `help_word` VALUES (7, '报名活动呀呀呀呀', '

报名活动呀呀呀呀报名活动呀呀呀呀报名活动呀呀呀呀报名活动呀呀呀呀报名活动呀呀呀呀报名活动呀呀呀呀报名活动呀呀呀呀报名活动呀呀呀呀报名活动呀呀呀呀

', 6, 0, '2022-07-05'); +INSERT INTO `help_word` VALUES (8, '怎么登录呢?', '

微信授权即可登录

', 7, 0, '2023-01-18 17:17:48'); +INSERT INTO `help_word` VALUES (9, '商户怎么入驻呢?', '

登录首页 点击:我要入驻

', 8, 1, '2022-10-31 14:46:27'); +INSERT INTO `help_word` VALUES (10, '额鹅鹅鹅', '

额鹅鹅鹅

', 8, 0, '2022-10-31 14:49:57'); +INSERT INTO `help_word` VALUES (11, '如何充值提现呢?', '

如何充值提现呢?充值充值

', 10, 0, '2023-01-18 17:25:03'); + +-- ---------------------------- +-- Table structure for invite +-- ---------------------------- +DROP TABLE IF EXISTS `invite`; +CREATE TABLE `invite` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id', + `user_id` int(11) NULL DEFAULT NULL COMMENT '邀请者id', + `invitee_user_id` int(11) NULL DEFAULT NULL COMMENT '被邀请者id', + `money` decimal(10, 2) NULL DEFAULT NULL COMMENT '收益', + `create_time` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建时间', + `money_type` int(1) NULL DEFAULT NULL COMMENT '1会员2陪玩', + `state` int(11) NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 803 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '邀请信息' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of invite +-- ---------------------------- + +-- ---------------------------- +-- Table structure for invite_money +-- ---------------------------- +DROP TABLE IF EXISTS `invite_money`; +CREATE TABLE `invite_money` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '收益钱包id', + `user_id` int(11) NULL DEFAULT NULL COMMENT '用户id', + `money_sum` decimal(10, 2) NULL DEFAULT NULL COMMENT '总获取收益', + `money` decimal(10, 2) NULL DEFAULT NULL COMMENT '当前金额', + `cash_out` decimal(10, 2) NULL DEFAULT NULL COMMENT '累计提现', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 135 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of invite_money +-- ---------------------------- + +-- ---------------------------- +-- Table structure for massage_type +-- ---------------------------- +DROP TABLE IF EXISTS `massage_type`; +CREATE TABLE `massage_type` ( + `massage_type_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '按摩类型id', + `massage_img` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '图片', + `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '标题', + `content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '内容', + `old_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '原价', + `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '现价', + `member_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '会员价', + `artificer_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '技师价', + `duration` int(11) NULL DEFAULT NULL COMMENT '时长', + `sales` int(11) NULL DEFAULT NULL COMMENT '销量', + `is_sex` int(11) NULL DEFAULT NULL COMMENT '是否限制性别 0不限制 1男 2女', + `status` int(11) NULL DEFAULT NULL COMMENT '状态 1上 2下', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + `city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '城市', + `content_img` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '详情图', + `labels` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '标签逗号隔开', + `parent_id` int(11) NULL DEFAULT NULL COMMENT '下级id 加钟项目', + `classify_id` int(11) NULL DEFAULT NULL COMMENT '分类id', + `add_num` int(11) NULL DEFAULT NULL COMMENT '加钟次数', + `apply_people` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '适用人群', + `score` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`massage_type_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 34 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of massage_type +-- ---------------------------- +INSERT INTO `massage_type` VALUES (17, 'https://anmo.xianmxkj.com/file/uploadPath/2023/01/18/aef64cb891c5ada332a9cdcc1e160713.png', '泰式按摩', '1、颈椎按摩', 300.00, 280.00, 250.00, 200.00, 10, 6, 2, 1, '2022-02-12 15:15:29', '石家庄市', 'https://anmo.xianmxkj.com/file/uploadPath/2023/01/18/d891ae8f9a793fa5e66b1e06e03a863a.png', '专业', NULL, 91, 3, '不限', NULL); +INSERT INTO `massage_type` VALUES (21, 'https://anmo.xianmxkj.com/file/uploadPath/2023/01/18/628ce3d31b8c22b3eba579fd0e031472.png', '盲人按摩', '盲人按摩盲人按摩盲人按摩盲人按摩', 100.00, 90.00, 88.00, 70.00, 50, 7, 1, 1, '2023-01-05 16:59:14', '西安市', 'https://anmo.xianmxkj.com/file/uploadPath/2023/01/18/315a8a0cff77e9a689a4e9baa9e0c380.png', '', NULL, 91, 2, '健康人群即可', '10'); +INSERT INTO `massage_type` VALUES (22, '', '按摩脚丫子', '', NULL, 60.00, 50.00, 40.00, 30, 0, NULL, 1, '2023-01-05 17:14:40', '', '', '', 21, NULL, NULL, NULL, NULL); +INSERT INTO `massage_type` VALUES (23, '', '开背', '', NULL, 50.00, 40.00, 35.00, 20, 0, NULL, 1, '2023-01-05 17:18:21', '', '', '', 21, NULL, NULL, NULL, NULL); +INSERT INTO `massage_type` VALUES (24, 'https://anmo.xianmxkj.com/file/uploadPath/2023/01/18/00e541ad22606ae82452a8b2b4e56150.png', '本土泰式按摩精品服务', '服务内容服务内容服务内容服务内容服务内容服务内容服务内容服务内容服务内容服务内容服务内容服务内容', 120.00, 100.00, 90.00, 80.00, 60, 16, 0, 1, '2023-01-12 13:46:35', '西安市', 'https://anmo.xianmxkj.com/file/uploadPath/2023/01/18/649ec8298bfa5f285ada03304f272d3f.png', '养生,专业', NULL, 91, 2, '孕妇及老年人外,其他人群均适用', NULL); +INSERT INTO `massage_type` VALUES (25, '', '加钟一小时', '', NULL, 100.00, 90.00, 80.00, 15, 0, NULL, 1, '2023-01-12 13:47:52', '', '', '', 24, 91, NULL, NULL, NULL); +INSERT INTO `massage_type` VALUES (26, '', '加钟两小时', '', NULL, 200.00, 180.00, 160.00, 30, 0, NULL, 1, '2023-01-12 13:48:26', '', '', '', 24, 91, NULL, NULL, NULL); +INSERT INTO `massage_type` VALUES (27, 'https://anmo.xianmxkj.com/file/uploadPath/2023/01/18/4f4a6b555dd674cdbb3b13d05947e3c6.png', '产后修复妈咪宝贝瑜伽助产孕期瑜伽', '竹韵瑜伽产后期妈咪宝贝;\n60分钟瑜伽;\n产后修复.', 110.00, 100.00, 90.00, 80.00, 60, 7, 0, 2, '2023-01-17 11:30:50', '西安市', 'https://anmo.xianmxkj.com/file/uploadPath/2023/01/18/de42cb31120782f845acd811f9cea3d8.png', '孕妇,瑜伽', NULL, 92, 1, '预产期等其他健康人士', NULL); +INSERT INTO `massage_type` VALUES (28, '', '减脂(有氧运动)', '', NULL, 388.00, 358.00, 280.00, 120, 0, NULL, 1, '2023-01-17 14:19:08', '', '', '', 27, 92, NULL, NULL, NULL); +INSERT INTO `massage_type` VALUES (29, '', '增肌训练(无氧运动)', '', NULL, 400.00, 350.00, 300.00, 150, 0, NULL, 1, '2023-01-17 14:19:30', '', '', '', 27, 92, NULL, NULL, NULL); +INSERT INTO `massage_type` VALUES (30, 'https://anmo.xianmxkj.com/file/uploadPath/2023/01/19/022ba672d55b7b39f0fcabae1d254780.png', '花花', '', 1.00, 1.00, 1.00, 1.00, 1, 0, 0, 1, '2023-01-19 10:47:48', '西安市', 'https://anmo.xianmxkj.com/file/uploadPath/2023/01/19/e501660223b2c2303b7600623b58a0f2.png', '', NULL, 91, 1, '人民', NULL); +INSERT INTO `massage_type` VALUES (31, 'https://anmo.xianmxkj.com/file/uploadPath/2023/01/28/998732cf56770e958710c0c5a0491b4a.png', '精品按摩', '', 10.00, 0.10, 0.09, 0.08, 60, 1, 0, 1, '2023-01-28 20:10:36', '郑州市', 'https://anmo.xianmxkj.com/file/uploadPath/2023/01/28/a0c62804124a46d648283639f0b6d7a7.png', '', NULL, 91, 3, '孕妇及老年人外,其他人群均适用', NULL); +INSERT INTO `massage_type` VALUES (32, 'https://anmo.xianmxkj.com/file/uploadPath/2023/01/28/1afaca9c9af9ea8a57c50d15b1cc9db9.png', '1111', '', 100.00, 90.00, 80.00, 70.00, 60, 0, 0, 2, '2023-01-28 20:11:31', '郑州市', 'https://anmo.xianmxkj.com/file/uploadPath/2023/01/28/d25a888ff600d9188c3af3b373f35c17.png', '', NULL, 92, 3, '孕妇及老年人外,其他人群均适用', NULL); +INSERT INTO `massage_type` VALUES (33, '', '泰式按摩', '', NULL, 3000.00, 280.00, 280.00, 10, 0, NULL, 1, '2023-02-09 13:36:20', '', '', '', 17, NULL, NULL, NULL, NULL); + +-- ---------------------------- +-- Table structure for member +-- ---------------------------- +DROP TABLE IF EXISTS `member`; +CREATE TABLE `member` ( + `member_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '会员特权id', + `member_img` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '特权图标', + `member_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '特权名称', + `sort` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '排序', + PRIMARY KEY (`member_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of member +-- ---------------------------- +INSERT INTO `member` VALUES (4, 'https://sac.xianmxkj.com/file/uploadPath/2022/02/16/74ed314cec7ae738cba7efed90d2c656.png', '享会员价', '1'); +INSERT INTO `member` VALUES (6, 'https://sac.xianmxkj.com/file/uploadPath/2022/02/16/88d495a21a15a651748d3d1b2f5c7613.png', '身份标识', '2'); + +-- ---------------------------- +-- Table structure for message_info +-- ---------------------------- +DROP TABLE IF EXISTS `message_info`; +CREATE TABLE `message_info` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '消息id', + `content` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '内容', + `create_at` varchar(600) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL COMMENT '创建时间', + `image` varchar(600) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL COMMENT '图片', + `is_see` varchar(600) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL, + `type_id` varchar(600) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL, + `type_name` varchar(600) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `state` varchar(600) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL COMMENT '分类', + `title` varchar(600) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '标题', + `by_user_id` varchar(600) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL COMMENT '地址', + `type` varchar(600) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL, + `by_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `user_id` varchar(255) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL COMMENT '用户id', + `user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户名', + `audit_content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 9361 CHARACTER SET = big5 COLLATE = big5_chinese_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of message_info +-- ---------------------------- + +-- ---------------------------- +-- Table structure for msg +-- ---------------------------- +DROP TABLE IF EXISTS `msg`; +CREATE TABLE `msg` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `code` varchar(255) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL COMMENT '短信验证码', + `phone` varchar(255) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL COMMENT '电话', + PRIMARY KEY (`id`) USING BTREE, + INDEX `index_name`(`code`, `phone`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 3315 CHARACTER SET = big5 COLLATE = big5_chinese_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of msg +-- ---------------------------- + +-- ---------------------------- +-- Table structure for orders +-- ---------------------------- +DROP TABLE IF EXISTS `orders`; +CREATE TABLE `orders` ( + `orders_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '订单id', + `artificer_id` int(11) DEFAULT NULL COMMENT '技师id', + `user_id` int(11) DEFAULT NULL COMMENT '用户id', + `serve_time` varchar(64) DEFAULT NULL COMMENT '服务时间', + `phone` varchar(255) DEFAULT NULL COMMENT '联系电话', + `address` varchar(500) DEFAULT NULL COMMENT '地址', + `remark` varchar(1000) DEFAULT NULL COMMENT '备注', + `pay_money` decimal(10,2) DEFAULT NULL COMMENT '项目单价', + `orders_no` varchar(64) DEFAULT NULL COMMENT '订单号', + `pay_time` varchar(64) DEFAULT NULL COMMENT '支付时间', + `pay_way` int(11) DEFAULT NULL COMMENT '支付方式', + `status` int(11) DEFAULT NULL COMMENT '状态 1待支付 2待服务 3待评论 4已取消 5已完成 6进行中 7技师出发 8技师到达', + `artificer_start_time` varchar(64) DEFAULT NULL COMMENT '技师出发时间', + `artificer_end_time` varchar(64) DEFAULT NULL COMMENT '技师到达时间', + `create_time` varchar(64) DEFAULT NULL COMMENT '创建时间', + `artificer_money` decimal(10,2) DEFAULT NULL COMMENT '技师收益', + `longitude` varchar(255) DEFAULT NULL COMMENT '经度', + `latitude` varchar(255) DEFAULT NULL COMMENT '纬度', + `start_longitude` varchar(255) DEFAULT NULL COMMENT '技师出发经度', + `start_latitude` varchar(255) DEFAULT NULL COMMENT '技师出发纬度', + `sum_money` varchar(255) DEFAULT NULL COMMENT '总金额', + `add_num` int(11) DEFAULT NULL COMMENT '加钟次数', + `add_time` varchar(60) DEFAULT NULL COMMENT '加钟时长', + `taxi_money` decimal(10,2) DEFAULT NULL COMMENT '出行服务费', + `trip_way` int(11) DEFAULT NULL COMMENT '出行方式 1公交 2出租 3免费', + `km` varchar(255) DEFAULT NULL COMMENT '全程公里', + `parent_id` int(11) DEFAULT NULL COMMENT '下级id 加钟订单id', + `start_time` datetime DEFAULT NULL COMMENT '开始服务时间', + `coupon_id` int(11) DEFAULT NULL COMMENT '优惠券id', + `coupon_name` varchar(255) DEFAULT NULL COMMENT '优惠券名称', + `coupon_money` decimal(10,2) DEFAULT NULL COMMENT '优惠券金额', + `add_artificer_money` decimal(10,2) DEFAULT NULL COMMENT '技师加钟金额', + `add_money` decimal(10,2) DEFAULT NULL COMMENT '加钟金额', + `price` decimal(10,2) DEFAULT NULL COMMENT '服务费用', + `sum_artificer_money` decimal(10,2) DEFAULT NULL COMMENT '技师总收益', + `is_send` int(11) DEFAULT NULL COMMENT '是否通知技师结束1是', + `end_time` varchar(64) DEFAULT NULL COMMENT '预估结束时间', + `user_name` varchar(255) DEFAULT NULL COMMENT '下单用户名称', + `one_user_money` decimal(10,2) DEFAULT NULL COMMENT '推广用户收益', + `one_user_id` int(11) DEFAULT NULL COMMENT '推广用户id', + `one_user_name` varchar(255) DEFAULT NULL COMMENT '推广用户名称', + `one_artificer_money` decimal(10,2) DEFAULT NULL COMMENT '推广技师收益', + `one_artificer_user_id` int(11) DEFAULT NULL COMMENT '推广技师用户id', + `one_artificer_user_name` varchar(255) DEFAULT NULL COMMENT '推广技师用户名称', + `ping_money` decimal(10,2) DEFAULT NULL COMMENT '平台收益', + `massage_type_id` int(11) DEFAULT NULL COMMENT '服务id', + `shop_money` decimal(10,2) DEFAULT NULL COMMENT '商家收益', + `shop_user_id` int(11) DEFAULT NULL COMMENT '商家用户id', + `shop_user_name` varchar(255) DEFAULT NULL COMMENT '商家用户名称', + `over_time_orders` int(11) DEFAULT NULL COMMENT '是否超时 1是 2否', + `end_times` varchar(64) DEFAULT NULL COMMENT '服务结束时间', + `consortia_id` int(11) DEFAULT NULL COMMENT '商家id', + `accomplish_longitude` varchar(255) DEFAULT NULL COMMENT '师傅完成经度', + `accomplish_latitude` varchar(255) DEFAULT NULL COMMENT '师傅完成纬度', + `warning` int(11) DEFAULT NULL COMMENT '是否是警告订单 1是', + `user_artificer_money` int(255) DEFAULT NULL, + `ping_taxi_money` decimal(10,2) DEFAULT NULL, + `artificer_taxi_money` decimal(10,2) DEFAULT NULL, + `start_address` varchar(500) DEFAULT NULL COMMENT '开始服务地点', + `accomplish_address` varchar(500) DEFAULT NULL COMMENT '完成服务地点', + `start_img` varchar(2000) DEFAULT NULL, + PRIMARY KEY (`orders_id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=318 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; + +-- ---------------------------- +-- Records of orders +-- ---------------------------- + +-- ---------------------------- +-- Table structure for orders_massage +-- ---------------------------- +DROP TABLE IF EXISTS `orders_massage`; +CREATE TABLE `orders_massage` ( + `orders_massage_id` int(255) NOT NULL AUTO_INCREMENT COMMENT '订单服务id', + `orders_id` int(11) NULL DEFAULT NULL COMMENT '订单id', + `massage_id` int(11) NULL DEFAULT NULL COMMENT '服务id', + `num` int(11) NULL DEFAULT NULL COMMENT '数量', + PRIMARY KEY (`orders_massage_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 201 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of orders_massage +-- ---------------------------- + +-- ---------------------------- +-- Table structure for pay_classify +-- ---------------------------- +DROP TABLE IF EXISTS `pay_classify`; +CREATE TABLE `pay_classify` ( + `pay_classify_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '充值分类id', + `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '售价', + `coupon_id` bigint(10) NULL DEFAULT NULL COMMENT '优惠券id', + `give_num` bigint(10) NULL DEFAULT NULL COMMENT '数量', + `sort` int(11) NULL DEFAULT NULL COMMENT '排序', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '时间', + `money` decimal(10, 2) NULL DEFAULT NULL COMMENT '到账金额', + PRIMARY KEY (`pay_classify_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 21 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of pay_classify +-- ---------------------------- +INSERT INTO `pay_classify` VALUES (2, 0.01, 30, 1, 2, NULL, NULL); +INSERT INTO `pay_classify` VALUES (3, 0.02, 26, 2, 3, NULL, NULL); +INSERT INTO `pay_classify` VALUES (4, 1000.00, 25, 4, 4, NULL, NULL); +INSERT INTO `pay_classify` VALUES (5, 3000.00, 26, 5, 5, NULL, NULL); +INSERT INTO `pay_classify` VALUES (17, 0.03, NULL, NULL, NULL, '2022-11-25 18:54:10', NULL); +INSERT INTO `pay_classify` VALUES (18, 100.00, 30, 1, NULL, '2022-11-25 18:55:00', NULL); + +-- ---------------------------- +-- Table structure for pay_details +-- ---------------------------- +DROP TABLE IF EXISTS `pay_details`; +CREATE TABLE `pay_details` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '充值id', + `classify` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '分类( 1app微信 2微信公众号 3微信小程序 4支付宝)', + `order_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '订单编号', + `trade_no` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付宝支付单号', + `money` decimal(10, 2) NULL DEFAULT NULL COMMENT '充值金额', + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id', + `state` int(4) NULL DEFAULT NULL COMMENT '0待支付 1支付成功 2失败', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + `pay_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付时间', + `type` int(4) NULL DEFAULT NULL COMMENT '支付类型 1 用户 2会员', + `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 840 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of pay_details +-- ---------------------------- + +-- ---------------------------- +-- Table structure for risk +-- ---------------------------- +DROP TABLE IF EXISTS `risk`; +CREATE TABLE `risk` ( + `risk_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '风险记录', + `risk_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '风险类型(1ip属地风险 2动态评价风险 3聊天风险)', + `user_id` int(11) NULL DEFAULT NULL COMMENT '用户id', + `content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '触犯原因', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '时间', + PRIMARY KEY (`risk_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 93 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of risk +-- ---------------------------- + +-- ---------------------------- +-- Table structure for search +-- ---------------------------- +DROP TABLE IF EXISTS `search`; +CREATE TABLE `search` ( + `search_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '搜索id', + `search_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '搜索名称', + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id', + `update_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`search_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 121 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of search +-- ---------------------------- + +-- ---------------------------- +-- Table structure for self_activity +-- ---------------------------- +DROP TABLE IF EXISTS `self_activity`; +CREATE TABLE `self_activity` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `create_at` varchar(255) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL COMMENT '创建时间', + `image_url` varchar(255) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL COMMENT '图片地址', + `state` varchar(255) CHARACTER SET big5 COLLATE big5_chinese_ci NULL DEFAULT NULL COMMENT '状态', + `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '链接', + `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '标题', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 40 CHARACTER SET = big5 COLLATE = big5_chinese_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_activity +-- ---------------------------- +INSERT INTO `self_activity` VALUES (9, '2021-08-24 18:23:56', 'https://taskshop.xianmxkj.com/img/20210824/7f9c10c8434748c19b8aaaaef462f516.png', '1', '/package/pages/zysc/my/myList', '我的订单'); +INSERT INTO `self_activity` VALUES (10, '2021-08-24 18:24:19', 'https://taskshop.xianmxkj.com/img/20210824/de708a8d95504c94bac0e0ef8fea0c45.png', '1', '/package/pages/zysc/my/rebateorder', '我的返利'); +INSERT INTO `self_activity` VALUES (11, '2021-08-24 18:24:23', 'https://taskshop.xianmxkj.com/img/20210824/af5a96620ff54553a2958de23af1f1e7.png', '1', '/package/pages/zysc/my/teamorder', '团队返利'); +INSERT INTO `self_activity` VALUES (12, '2021-08-24 18:24:27', 'https://taskshop.xianmxkj.com/img/20210824/aafe0eb7a4ce4dbf838ec4706c847642.png', '1', '/package/pages/zysc/categray/category', '商品分类'); +INSERT INTO `self_activity` VALUES (13, '2021-08-24 18:24:32', 'https://taskshop.xianmxkj.com/img/20210824/c5199711f8484d84932f000475012cb9.png', '1', '/pages/invitation/invitationUser', '邀请好友'); +INSERT INTO `self_activity` VALUES (20, '2021-08-24 18:25:37', 'https://taskshop.xianmxkj.com/img/20210824/0d9a3211fc8f420ab3620adc1076a28e.png', '3', '/pages/index/tuiguang?cid=1', '精选好物'); +INSERT INTO `self_activity` VALUES (21, '2021-08-24 18:25:48', 'https://taskshop.xianmxkj.com/img/20210824/e234249b69e2464691b14c0a97200e75.png', '3', '/pages/index/tuiguang?cid=10', '精选好物'); +INSERT INTO `self_activity` VALUES (22, '2021-08-24 18:25:53', 'https://taskshop.xianmxkj.com/img/20210824/6c130f7cecc34100aefd396d2f3ba734.png', '4', '/pages/miandan/miandan', '热卖榜单'); +INSERT INTO `self_activity` VALUES (23, '2021-08-24 18:26:00', 'https://taskshop.xianmxkj.com/img/20210824/bff1b15798cc4b26bfb63eede94ea7a4.png', '4', '/pages/index/tuiguang?cid=4', '热卖榜单'); +INSERT INTO `self_activity` VALUES (24, '2021-08-24 18:26:07', 'https://taskshop.xianmxkj.com/img/20210824/9514cce44dc54eeeaaa2e15a64a1e73f.png', '5', '/pages/index/list?title=每日上新&type=1', '每日上新'); +INSERT INTO `self_activity` VALUES (25, '2021-08-24 18:26:11', 'https://taskshop.xianmxkj.com/img/20210824/d89261b278ec483aa5d30993b469eace.png', '5', '/pages/index/food?title=爆款美食&type=9', '爆款美食'); +INSERT INTO `self_activity` VALUES (35, '2021-08-24 18:24:45', 'https://taskshop.xianmxkj.com/img/20210824/d6de78ba664e424f852f3d05104717a0.png', '1', '/package/pages/zysc/categray/search?cid=48&name=衬衫', '女装'); +INSERT INTO `self_activity` VALUES (36, '2021-08-24 18:24:50', 'https://taskshop.xianmxkj.com/img/20210824/0e0791133e024a40a54f146f1dd6bb2a.png', '1', '/package/pages/zysc/my/like', '我的收藏'); +INSERT INTO `self_activity` VALUES (37, '2021-08-24 18:24:57', 'https://taskshop.xianmxkj.com/img/20210824/4e42272c61ca4f49aa88ecad7d953275.png', '1', '/package/pages/zysc/categray/search?cid=48&name=苹果', '新鲜瓜果'); +INSERT INTO `self_activity` VALUES (38, '2021-08-24 18:25:02', 'https://taskshop.xianmxkj.com/img/20210824/d757d4507d324b9f9d03fa4d81af94e2.png', '1', '/package/pages/zysc/categray/search?cid=48&name=电视', '电视'); +INSERT INTO `self_activity` VALUES (39, '2021-08-24 18:25:06', 'https://taskshop.xianmxkj.com/img/20210824/ac36e2e5121f4ad88e3deaca73224b7b.png', '1', '/package/pages/zysc/categray/search?cid=34&name=电子产品', '电子产品'); + +-- ---------------------------- +-- Table structure for self_banner +-- ---------------------------- +DROP TABLE IF EXISTS `self_banner`; +CREATE TABLE `self_banner` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `create_at` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建时间', + `img_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '图片地址', + `link_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '跳转链接', + `sort` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '排序', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_banner +-- ---------------------------- +INSERT INTO `self_banner` VALUES (1, '2020-08-15 10:58:44', 'https://pic3.zhimg.com/ac2929dd435e78ae8efe25252008dcdd_xs.jpg?source=1940ef5c', 'www.jd.com', '1'); +INSERT INTO `self_banner` VALUES (4, '2020-08-15 11:00:26', 'https://pic4.zhimg.com/v2-095892c2f4425ff90f53b946b577847b_540x450.jpeg', 'www.taobao.com', '2'); + +-- ---------------------------- +-- Table structure for self_goods +-- ---------------------------- +DROP TABLE IF EXISTS `self_goods`; +CREATE TABLE `self_goods` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '商品id', + `create_at` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建时间', + `descrition` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL COMMENT '商品描述', + `img` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL COMMENT '商品图片', + `merchants` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '商户号', + `price` double NULL DEFAULT NULL COMMENT '价格', + `sales` int(11) NULL DEFAULT NULL COMMENT '商品销量', + `status` int(11) NULL DEFAULT 0 COMMENT '商品状态(默认1正常 2下架)', + `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '标题', + `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '商品类型id', + `member_price` double NULL DEFAULT NULL COMMENT '会员价格', + `original_price` double NULL DEFAULT NULL COMMENT '商品原价', + `commission_price` double NULL DEFAULT NULL COMMENT '商品佣金', + `home_goods` int(11) NULL DEFAULT NULL COMMENT '首页商品(0默认 1是首页商品)', + `is_select` int(11) NULL DEFAULT NULL COMMENT '精选好物(0默认 1精选好物)', + `buy_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '必买理由', + `cover_img` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '商品封面图片', + `is_express` int(11) NULL DEFAULT NULL COMMENT '是否需要发货(1普通商品需要发货 2虚拟商品无需发货)', + `is_recommend` int(11) NULL DEFAULT NULL COMMENT '每日推荐(0默认 1推荐商品)', + `postage_price` double NULL DEFAULT NULL COMMENT '邮费', + `type_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '商品类型id', + `is_postage` int(11) NULL DEFAULT NULL, + `is_ji_fen_goods` int(11) NULL DEFAULT NULL, + `brand_id` int(11) NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 105 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_goods +-- ---------------------------- +INSERT INTO `self_goods` VALUES (60, '2020-09-16 13:44:30', '

\"\"

', 'https://tk.gomyorder.cn/img/20200916/318adb4736a84a70aa02e311c3fcf325.jpg,https://tk.gomyorder.cn/img/20200916/5075c958e04644bd983850e9a8f2e81e.jpg,https://tk.gomyorder.cn/img/20200916/06f285fd5d8748bf9baede8d38b5543a.jpg', '', 2, 21124, 1, '晾衣架子小孩子晒挂衣服婴儿童凉的家用袜子多夹子新生功能可折叠', NULL, 2, 3, 0.01, 1, 1, '好物', 'https://tk.gomyorder.cn/img/20200916/99e1d541b5c245e2addb9d5c4cdfddd1.jpg', 1, 0, NULL, '13', NULL, NULL, NULL); +INSERT INTO `self_goods` VALUES (63, '2020-09-24 14:45:50', '

\"\"

\n

\"\"

\n

\"\"

', 'https://tk.gomyorder.cn/img/20200924/7bae1c7b42d04943adb64b901cdca345.jpg,https://tk.gomyorder.cn/img/20200924/a401af5d892c4226bc5fdb31946bccb3.jpg,https://tk.gomyorder.cn/img/20200924/2c081e77d2c047d2b383de763b2a736b.jpg,https://tk.gomyorder.cn/img/20200924/7d729c59272e46d9bac220f19f94b4f0.jpg', '', 1, 1578, 1, '乔丹女运动鞋2020秋季网面跑步鞋气垫缓震增高旅游鞋黑粉色波鞋子', NULL, 1, 5, 0.01, 1, 1, '有种脾气叫,不放弃。', 'https://tk.gomyorder.cn/img/20200924/8bc17c26f578441981efb5c0d55a761f.jpg', 1, 1, 0, '13', NULL, NULL, NULL); +INSERT INTO `self_goods` VALUES (65, '2020-09-24 14:49:11', '

\"\"

\n

\"\"

\n

\"\"

\n

\"\"

', 'https://tk.gomyorder.cn/img/20200924/1dfcd54fcc0a49a9bef6d6c93e354464.jpg,https://tk.gomyorder.cn/img/20200924/1523374d86b34c25a9af121c3238adee.jpg,https://tk.gomyorder.cn/img/20200924/13e991739f384fc3bbff71b65cab2b3b.jpg', '', 1, 2112, 1, '百草味-零食大礼包网红爆款休闲充饥夜宵小吃饼干组合一整箱送礼', NULL, 1, 2, 0.01, 1, 1, '600款零食 一站购 1元起开抢', 'https://tk.gomyorder.cn/img/20200924/6896a2717e3c419094f62a3c107455e6.jpg', 1, 1, 0, '21', NULL, NULL, NULL); +INSERT INTO `self_goods` VALUES (66, '2020-09-24 14:52:21', '

\"\"

\n

\"\"

', 'https://api.shengqianxiong.com.cn/img/20210820/a59e127b5f1d435bb813543293609640.png', '', 1, 54219, 1, '维达手帕纸超韧4层8张18包卫生纸巾 自然无香面巾纸 新旧交替发货', NULL, 1, 5, 0.1, 1, 1, '出门必备易携带,超韧细密湿水不易破', 'https://api.shengqianxiong.com.cn/img/20210820/a61d772ddf6e4eaaae843993c91170d7.png', 1, 1, 0, '30', NULL, NULL, 1); +INSERT INTO `self_goods` VALUES (97, '2021-08-10 16:12:36', '

好好学习,天天向上。

', 'https://api.shengqianxiong.com.cn/img/20210810/d08193121f8549199294a3a0f53a9f22.jpg,https://api.shengqianxiong.com.cn/img/20210810/21001828cf2c465896995c6360f486e7.jpg,https://api.shengqianxiong.com.cn/img/20210810/852c4e1c2ef84f5087a58503bf32cdb8.jpg', '', 55, 12, 1, '计算机与科学书籍·', NULL, 55, 36, 0.2, 1, 1, '有用的东西不需要理由', 'https://api.shengqianxiong.com.cn/img/20210810/a47def2d5bfe4c07b8d6dfba2ff7fd8a.jpg', 1, 1, 0, '51', NULL, NULL, NULL); +INSERT INTO `self_goods` VALUES (98, '2021-08-11 18:09:32', '

\"fsdf\"

', 'https://api.shengqianxiong.com.cn/img/20210811/7d923d42836a4d82af306ec7163dbff6.jpg,https://api.shengqianxiong.com.cn/img/20210811/1339d822bf9042b99d85971752d4055d.jpg', '', 85, 10000, 1, '哲学', NULL, 85, 95, 0.1, 1, 1, '对你们有用哦', 'https://api.shengqianxiong.com.cn/img/20210811/7e2a40c37b1745539da07793e1c1c7dc.jpg', 3, 1, 10, '53', NULL, NULL, NULL); +INSERT INTO `self_goods` VALUES (100, '2021-08-14 10:11:28', '

今天 你吃了吗

', 'https://api.shengqianxiong.com.cn/img/20210814/19222cef43a845209f081ab6a38c4e2f.jpg,https://api.shengqianxiong.com.cn/img/20210814/48949a3bbb53412391ea33290e626f32.jpg', '', 50, 101, 1, '测试商品', NULL, 50, 100, 10, 1, 1, '迎娶白富美 走上人生巅峰', 'https://api.shengqianxiong.com.cn/img/20210814/7bb076847871417d9d153c1b126f99f2.jpg', 2, 1, 0, '48', NULL, NULL, 1); +INSERT INTO `self_goods` VALUES (101, '2022-04-25 11:21:41', '

asdas

', 'https://api.shengqianxiong.com.cn/file/uploadPath/2022/04/25/a9e8f15bdc0839a183fcfe208ddfe95f.jpg', '', 20, 20, 1, 'ceshi', NULL, NULL, NULL, NULL, NULL, NULL, '223232', 'https://api.shengqianxiong.com.cn/file/uploadPath/2022/04/25/ae6370334a486d637f73de07c32afd6f.jpg', 1, NULL, 0, NULL, NULL, 1, NULL); +INSERT INTO `self_goods` VALUES (102, '2022-04-30 01:54:19', '

好喝不上头

', 'https://api.shengqianxiong.com.cn/file/uploadPath/2022/04/30/f71215b08370ee99d3008430ce7740fb.png', '', 100, 100, 1, '神酒', NULL, 100, 100, 100, 1, 1, '好喝不上头', 'https://api.shengqianxiong.com.cn/file/uploadPath/2022/04/30/7981dc0ed9a4792ddf3d14243e9473f2.png', 1, 1, 0, '44', NULL, NULL, NULL); +INSERT INTO `self_goods` VALUES (103, '2022-05-19 10:22:59', '

dfdsfsf

', 'https://rwshop.xianmxkj.com/file/uploadPath/2022/05/19/83d2e2b580440e41eef40eb4f2539058.jpg,https://rwshop.xianmxkj.com/file/uploadPath/2022/05/19/e04c924326249cef6ffb6af9ee90a2be.jpg', '', 1.01, 0, 1, '自营商品0519', NULL, 1.01, 10, 0.5, 1, 1, 'mmm', 'https://rwshop.xianmxkj.com/file/uploadPath/2022/05/19/176e12eee3b6f6b9b61e6dc047a6870c.jpg', 1, 1, 0, '55', NULL, NULL, NULL); +INSERT INTO `self_goods` VALUES (104, '2022-06-24 17:12:07', '

', 'https://rwshop.xianmxkj.com/file/uploadPath/2022/06/24/516bdde7ccaada5913f6002fda859160.jpg,https://rwshop.xianmxkj.com/file/uploadPath/2022/06/24/5b7b056cd7ca3197fe44282eb668fce0.jpg', '', 90, 25, 1, '千禾酱油味极鲜1L特级生抽', NULL, 90, 100, 5, 1, 1, '千禾酱油味极鲜值得信赖', 'https://rwshop.xianmxkj.com/file/uploadPath/2022/06/24/94681944d192677aa426b95837c1abec.jpg', 1, 1, 5, '55', NULL, NULL, NULL); + +-- ---------------------------- +-- Table structure for self_goods_attr +-- ---------------------------- +DROP TABLE IF EXISTS `self_goods_attr`; +CREATE TABLE `self_goods_attr` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `attr_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '属性名称', + `goods_id` bigint(20) NULL DEFAULT NULL COMMENT '商品id', + `rule_id` bigint(20) NULL DEFAULT NULL COMMENT '规格模板id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 128 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_goods_attr +-- ---------------------------- +INSERT INTO `self_goods_attr` VALUES (1, '帽子', 52, NULL); +INSERT INTO `self_goods_attr` VALUES (2, '衣服', 53, NULL); +INSERT INTO `self_goods_attr` VALUES (3, '衣服', 54, NULL); +INSERT INTO `self_goods_attr` VALUES (4, '衣服', 55, NULL); +INSERT INTO `self_goods_attr` VALUES (5, '衣服', 56, NULL); +INSERT INTO `self_goods_attr` VALUES (6, '衣服', 57, NULL); +INSERT INTO `self_goods_attr` VALUES (7, '衣服', 58, NULL); +INSERT INTO `self_goods_attr` VALUES (8, '衣服', 59, NULL); +INSERT INTO `self_goods_attr` VALUES (13, '衣服', 76, 8); +INSERT INTO `self_goods_attr` VALUES (15, '帽子', 77, 9); +INSERT INTO `self_goods_attr` VALUES (20, '衣服', 78, 8); +INSERT INTO `self_goods_attr` VALUES (25, '衣服', 79, 8); +INSERT INTO `self_goods_attr` VALUES (45, '衣服', 83, 8); +INSERT INTO `self_goods_attr` VALUES (91, '衣服', 94, 8); +INSERT INTO `self_goods_attr` VALUES (117, '衣服', 99, 8); +INSERT INTO `self_goods_attr` VALUES (121, '衣服', 97, 8); +INSERT INTO `self_goods_attr` VALUES (122, '衣服1423', 96, 8); +INSERT INTO `self_goods_attr` VALUES (123, '帽子', 95, 9); +INSERT INTO `self_goods_attr` VALUES (126, '衣服', 100, 8); +INSERT INTO `self_goods_attr` VALUES (127, '帽子', 104, 9); + +-- ---------------------------- +-- Table structure for self_goods_attr_value +-- ---------------------------- +DROP TABLE IF EXISTS `self_goods_attr_value`; +CREATE TABLE `self_goods_attr_value` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `detail` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '属性值组合:{尺寸: \"7寸\", 颜色: \"红底\"}', + `goods_id` bigint(20) NULL DEFAULT NULL COMMENT '商品id', + `img` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '图片', + `member_price` double NULL DEFAULT NULL COMMENT '会员价格', + `original_price` double NULL DEFAULT NULL COMMENT '原价', + `price` double NULL DEFAULT NULL COMMENT '价格', + `sales` int(11) NULL DEFAULT NULL, + `stock` int(11) NULL DEFAULT NULL, + `attr_id` bigint(20) NULL DEFAULT NULL, + `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 293 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_goods_attr_value +-- ---------------------------- +INSERT INTO `self_goods_attr_value` VALUES (1, '大', 52, NULL, NULL, NULL, NULL, NULL, NULL, 1, '尺码'); +INSERT INTO `self_goods_attr_value` VALUES (2, '红色', 52, NULL, NULL, NULL, NULL, NULL, NULL, 1, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (3, '紫色,红色', 53, NULL, NULL, NULL, NULL, NULL, NULL, 2, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (4, 'm', 53, NULL, NULL, NULL, NULL, NULL, NULL, 2, '尺码'); +INSERT INTO `self_goods_attr_value` VALUES (5, '紫色,红色', 54, NULL, NULL, NULL, NULL, NULL, NULL, 3, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (6, 'm', 54, NULL, NULL, NULL, NULL, NULL, NULL, 3, '尺码'); +INSERT INTO `self_goods_attr_value` VALUES (7, '紫色,红色', 55, NULL, NULL, NULL, NULL, NULL, NULL, 4, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (8, 'm', 55, NULL, NULL, NULL, NULL, NULL, NULL, 4, '尺码'); +INSERT INTO `self_goods_attr_value` VALUES (11, '紫色,红色', 57, NULL, NULL, NULL, NULL, NULL, NULL, 6, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (12, 'm', 57, NULL, NULL, NULL, NULL, NULL, NULL, 6, '尺码'); +INSERT INTO `self_goods_attr_value` VALUES (13, '紫色,红色', 58, NULL, NULL, NULL, NULL, NULL, NULL, 7, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (14, 'm', 58, NULL, NULL, NULL, NULL, NULL, NULL, 7, '尺码'); +INSERT INTO `self_goods_attr_value` VALUES (15, '紫色,红色', 59, NULL, NULL, NULL, NULL, NULL, NULL, 8, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (16, 'm', 59, NULL, NULL, NULL, NULL, NULL, NULL, 8, '尺码'); +INSERT INTO `self_goods_attr_value` VALUES (33, '紫色,红色', 78, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (34, 'm', 78, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '尺码'); +INSERT INTO `self_goods_attr_value` VALUES (43, '紫色,红色', 79, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (44, 'm', 79, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '尺码'); +INSERT INTO `self_goods_attr_value` VALUES (83, '紫色,红色', 83, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (84, 'm', 83, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '尺码'); +INSERT INTO `self_goods_attr_value` VALUES (175, '紫色,红色', 94, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (176, 'm', 94, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '尺码'); +INSERT INTO `self_goods_attr_value` VALUES (237, '红,黄,蓝', 97, NULL, NULL, NULL, NULL, NULL, NULL, 121, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (238, 'x,l', 97, NULL, NULL, NULL, NULL, NULL, NULL, 121, '大小'); +INSERT INTO `self_goods_attr_value` VALUES (239, '紫色,红色', 96, NULL, NULL, NULL, NULL, NULL, NULL, 122, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (240, 'm', 96, NULL, NULL, NULL, NULL, NULL, NULL, 122, '尺码'); +INSERT INTO `self_goods_attr_value` VALUES (241, '大', 95, NULL, NULL, NULL, NULL, NULL, NULL, 123, '尺码'); +INSERT INTO `self_goods_attr_value` VALUES (242, '红色', 95, NULL, NULL, NULL, NULL, NULL, NULL, 123, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (261, '红色', 99, NULL, NULL, NULL, NULL, NULL, NULL, 117, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (262, 'm', 99, NULL, NULL, NULL, NULL, NULL, NULL, 117, '大小'); +INSERT INTO `self_goods_attr_value` VALUES (263, '工装', 99, NULL, NULL, NULL, NULL, NULL, NULL, 117, '风格'); +INSERT INTO `self_goods_attr_value` VALUES (264, '粉色,五颜六色', 99, NULL, NULL, NULL, NULL, NULL, NULL, 117, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (285, '红色', 100, NULL, NULL, NULL, NULL, NULL, NULL, 126, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (286, 'm', 100, NULL, NULL, NULL, NULL, NULL, NULL, 126, '大小'); +INSERT INTO `self_goods_attr_value` VALUES (287, '工装', 100, NULL, NULL, NULL, NULL, NULL, NULL, 126, '风格'); +INSERT INTO `self_goods_attr_value` VALUES (288, '粉色,黑色,红色', 100, NULL, NULL, NULL, NULL, NULL, NULL, 126, '颜色'); +INSERT INTO `self_goods_attr_value` VALUES (291, '大,小', 104, NULL, NULL, NULL, NULL, NULL, NULL, 127, '尺码'); +INSERT INTO `self_goods_attr_value` VALUES (292, '红色,黑色', 104, NULL, NULL, NULL, NULL, NULL, NULL, 127, '颜色'); + +-- ---------------------------- +-- Table structure for self_goods_brand +-- ---------------------------- +DROP TABLE IF EXISTS `self_goods_brand`; +CREATE TABLE `self_goods_brand` ( + `brand_id` bigint(20) NOT NULL AUTO_INCREMENT, + `brand_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `create_time` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `names` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`brand_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_goods_brand +-- ---------------------------- +INSERT INTO `self_goods_brand` VALUES (1, '马来西亚', '2020-10-28 10:05:10', 'INTI'); +INSERT INTO `self_goods_brand` VALUES (2, '泰国', '2020-10-28 10:18:25', '西那瓦'); +INSERT INTO `self_goods_brand` VALUES (3, '英国', '2020-10-28 10:19:21', '伯明翰'); +INSERT INTO `self_goods_brand` VALUES (5, '腾讯', '2020-11-10 16:07:18', '腾讯视频'); + +-- ---------------------------- +-- Table structure for self_goods_comment +-- ---------------------------- +DROP TABLE IF EXISTS `self_goods_comment`; +CREATE TABLE `self_goods_comment` ( + `comment_id` bigint(20) NOT NULL AUTO_INCREMENT, + `content` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `create_time` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `goods_id` bigint(20) NULL DEFAULT NULL, + `img` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `sku` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `user_header` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `user_id` bigint(20) NULL DEFAULT NULL, + `user_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `order_id` bigint(20) NULL DEFAULT NULL, + `sku_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `reply` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `score` int(11) NULL DEFAULT NULL, + `score_type` int(11) NULL DEFAULT NULL, + PRIMARY KEY (`comment_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 40 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_goods_comment +-- ---------------------------- + +-- ---------------------------- +-- Table structure for self_goods_rule +-- ---------------------------- +DROP TABLE IF EXISTS `self_goods_rule`; +CREATE TABLE `self_goods_rule` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `create_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建时间', + `rule_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '规格名称', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 29 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_goods_rule +-- ---------------------------- +INSERT INTO `self_goods_rule` VALUES (8, '2020-09-11 15:21:01', '衣服'); +INSERT INTO `self_goods_rule` VALUES (9, '2020-09-11 15:27:02', '帽子'); +INSERT INTO `self_goods_rule` VALUES (10, '2020-09-11 15:44:37', '鞋子'); +INSERT INTO `self_goods_rule` VALUES (14, '2020-09-11 17:27:49', '裤子'); +INSERT INTO `self_goods_rule` VALUES (15, '2020-09-11 17:38:59', '袜子'); +INSERT INTO `self_goods_rule` VALUES (27, '2021-08-10 17:58:41', '首饰'); +INSERT INTO `self_goods_rule` VALUES (28, '2021-08-11 17:45:25', '项链'); + +-- ---------------------------- +-- Table structure for self_goods_rule_value +-- ---------------------------- +DROP TABLE IF EXISTS `self_goods_rule_value`; +CREATE TABLE `self_goods_rule_value` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `detail` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '规格属性值', + `rule_id` bigint(20) NULL DEFAULT NULL COMMENT '规格id', + `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '规格属性名称', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 103 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_goods_rule_value +-- ---------------------------- +INSERT INTO `self_goods_rule_value` VALUES (1, '紫色', 3, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (2, '紫色', 4, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (3, 'm', 5, '尺码'); +INSERT INTO `self_goods_rule_value` VALUES (4, 'm,l', 5, NULL); +INSERT INTO `self_goods_rule_value` VALUES (5, '紫色,红色', 6, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (6, '紫色,红色,蓝色', 7, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (9, '大', 9, '尺码'); +INSERT INTO `self_goods_rule_value` VALUES (10, '红色', 9, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (14, 'm', 11, '大小'); +INSERT INTO `self_goods_rule_value` VALUES (15, '紫色', 12, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (16, '红色,紫色', 13, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (20, '红色', 16, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (22, '红色,白色', 17, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (23, '红色', 18, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (24, 'm', 18, '尺码'); +INSERT INTO `self_goods_rule_value` VALUES (25, '红色,黑色,白色', 19, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (26, 'm,l,s', 19, '尺码'); +INSERT INTO `self_goods_rule_value` VALUES (27, 'm,l', 20, '大小'); +INSERT INTO `self_goods_rule_value` VALUES (28, '红色,紫色', 20, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (29, 'm,l', 21, '大小'); +INSERT INTO `self_goods_rule_value` VALUES (30, '红色,紫色', 21, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (47, '黑色,白色,黑色', 22, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (52, '紫色', 10, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (53, 'm', 10, '尺码'); +INSERT INTO `self_goods_rule_value` VALUES (54, '红色,紫色', 14, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (55, 'm', 14, '大小'); +INSERT INTO `self_goods_rule_value` VALUES (56, '黑色,白色,紫色', 15, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (59, '黑色', 23, 'X'); +INSERT INTO `self_goods_rule_value` VALUES (60, '156', 24, '大小·'); +INSERT INTO `self_goods_rule_value` VALUES (61, '222', 25, '大小'); +INSERT INTO `self_goods_rule_value` VALUES (68, '253', 26, '大小'); +INSERT INTO `self_goods_rule_value` VALUES (78, '带钻', 27, '有无钻'); +INSERT INTO `self_goods_rule_value` VALUES (79, '2-2000000', 27, '价位'); +INSERT INTO `self_goods_rule_value` VALUES (93, '布灵布灵', 28, '风格'); +INSERT INTO `self_goods_rule_value` VALUES (94, 'l', 28, '大小'); +INSERT INTO `self_goods_rule_value` VALUES (99, '红色', 8, '颜色'); +INSERT INTO `self_goods_rule_value` VALUES (100, 'm', 8, '大小'); +INSERT INTO `self_goods_rule_value` VALUES (101, '工装', 8, '风格'); +INSERT INTO `self_goods_rule_value` VALUES (102, '粉色,五颜六色', 8, '颜色'); + +-- ---------------------------- +-- Table structure for self_goods_sku +-- ---------------------------- +DROP TABLE IF EXISTS `self_goods_sku`; +CREATE TABLE `self_goods_sku` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `goods_id` bigint(20) NULL DEFAULT NULL COMMENT '商品id', + `sku_img` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT 'sku图片', + `sku_original_price` double NULL DEFAULT NULL COMMENT 'sku原价', + `sku_price` double NULL DEFAULT NULL COMMENT 'sku商品售价', + `member_price` double NULL DEFAULT NULL COMMENT '会员价格', + `detail_json` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT 'sku信息,json封装', + `sales` int(11) NULL DEFAULT NULL COMMENT '销量', + `stock` int(11) NULL DEFAULT NULL COMMENT '库存', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 160 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_goods_sku +-- ---------------------------- +INSERT INTO `self_goods_sku` VALUES (1, 52, NULL, 0, 0, 0, '大,红色', 0, 0); +INSERT INTO `self_goods_sku` VALUES (2, 53, NULL, 0, 0, 0, '紫色,m', 0, 0); +INSERT INTO `self_goods_sku` VALUES (3, 53, NULL, 0, 0, 0, '红色,m', 0, 0); +INSERT INTO `self_goods_sku` VALUES (4, 54, NULL, 0, 0, 0, '紫色,m', 0, 0); +INSERT INTO `self_goods_sku` VALUES (5, 54, NULL, 0, 0, 0, '红色,m', 0, 0); +INSERT INTO `self_goods_sku` VALUES (6, 55, NULL, 0, 0, 0, '紫色,m', 0, 0); +INSERT INTO `self_goods_sku` VALUES (7, 55, NULL, 0, 0, 0, '红色,m', 0, 0); +INSERT INTO `self_goods_sku` VALUES (8, 57, NULL, 0, 0, 0, '紫色,m', 0, 0); +INSERT INTO `self_goods_sku` VALUES (9, 57, NULL, 0, 0, 0, '红色,m', 0, 0); +INSERT INTO `self_goods_sku` VALUES (10, 58, NULL, 0, 0, 0, '紫色,m', 0, 0); +INSERT INTO `self_goods_sku` VALUES (11, 58, NULL, 0, 0, 0, '红色,m', 0, 0); +INSERT INTO `self_goods_sku` VALUES (12, 59, NULL, 0, 0, 0, '紫色,m', 0, 0); +INSERT INTO `self_goods_sku` VALUES (13, 59, NULL, 0, 0, 0, '红色,m', 0, 0); +INSERT INTO `self_goods_sku` VALUES (16, 76, NULL, 0, 0, 0, '紫色,m', 0, 0); +INSERT INTO `self_goods_sku` VALUES (17, 76, NULL, 0, 0, 0, '红色,m', 0, 0); +INSERT INTO `self_goods_sku` VALUES (34, 91, 'https://tk.gomyorder.cn/img/20210512/66e26326a0a14e3abea2090bebd588f3.jfif', 100, 50, NULL, NULL, 0, 999); +INSERT INTO `self_goods_sku` VALUES (84, 97, 'https://api.shengqianxiong.com.cn/img/20210810/a47def2d5bfe4c07b8d6dfba2ff7fd8a.jpg', 36, 55, NULL, '红,x', 0, 995); +INSERT INTO `self_goods_sku` VALUES (85, 97, 'https://api.shengqianxiong.com.cn/img/20210810/a47def2d5bfe4c07b8d6dfba2ff7fd8a.jpg', 36, 55, NULL, '红,l', 0, 999); +INSERT INTO `self_goods_sku` VALUES (86, 97, 'https://api.shengqianxiong.com.cn/img/20210810/a47def2d5bfe4c07b8d6dfba2ff7fd8a.jpg', 36, 55, NULL, '黄,x', 0, 999); +INSERT INTO `self_goods_sku` VALUES (87, 97, 'https://api.shengqianxiong.com.cn/img/20210810/a47def2d5bfe4c07b8d6dfba2ff7fd8a.jpg', 36, 55, NULL, '黄,l', 0, 999); +INSERT INTO `self_goods_sku` VALUES (88, 97, 'https://api.shengqianxiong.com.cn/img/20210810/a47def2d5bfe4c07b8d6dfba2ff7fd8a.jpg', 36, 55, NULL, '蓝,x', 0, 999); +INSERT INTO `self_goods_sku` VALUES (89, 97, 'https://api.shengqianxiong.com.cn/img/20210810/a47def2d5bfe4c07b8d6dfba2ff7fd8a.jpg', 36, 55, NULL, '蓝,l', 0, 999); +INSERT INTO `self_goods_sku` VALUES (90, 96, 'https://api.shengqianxiong.com.cn/img/20210810/99866e2ada0e4d9c8d55a56527f77deb.jpg', 50, 40, NULL, '紫色,m', 0, 999); +INSERT INTO `self_goods_sku` VALUES (91, 96, 'https://api.shengqianxiong.com.cn/img/20210810/99866e2ada0e4d9c8d55a56527f77deb.jpg', 50, 40, NULL, '红色,m', 0, 999); +INSERT INTO `self_goods_sku` VALUES (92, 95, 'https://api.shengqianxiong.com.cn/img/20210810/0f972f2dc9fe46a08dfebf508364be80.jpg', 100, 90, NULL, '大,红色', 0, 999); +INSERT INTO `self_goods_sku` VALUES (107, 99, 'https://api.shengqianxiong.com.cn/img/20210814/bcd8ed002d9446d1b2e26d12a35283f9.jpeg', 10, 0.01, NULL, '红色,m,工装,粉色', 0, 96); +INSERT INTO `self_goods_sku` VALUES (108, 99, 'https://api.shengqianxiong.com.cn/img/20210814/8c038f45f5864a6e9bbaab133ee52bea.jpg', 10, 0.01, NULL, '红色,m,工装,五颜六色', 0, 88); +INSERT INTO `self_goods_sku` VALUES (111, 65, 'https://tk.gomyorder.cn/img/20200924/6896a2717e3c419094f62a3c107455e6.jpg', 2, 1, NULL, NULL, 0, 5); +INSERT INTO `self_goods_sku` VALUES (112, 63, 'https://tk.gomyorder.cn/img/20200924/8bc17c26f578441981efb5c0d55a761f.jpg', 5, 1, NULL, NULL, 0, 997); +INSERT INTO `self_goods_sku` VALUES (133, 66, 'https://tk.gomyorder.cn/img/20201107/e2c3514bc9824acd97841a23bc5f9998.png', 5, 1, NULL, NULL, 0, 5); +INSERT INTO `self_goods_sku` VALUES (135, 100, 'https://api.shengqianxiong.com.cn/img/20210814/7bb076847871417d9d153c1b126f99f2.jpg', 100, 50, NULL, '红色,m,工装,粉色', 0, 0); +INSERT INTO `self_goods_sku` VALUES (136, 100, 'https://api.shengqianxiong.com.cn/img/20210814/7bb076847871417d9d153c1b126f99f2.jpg', 100, 50, NULL, '红色,m,工装,黑色', 0, 0); +INSERT INTO `self_goods_sku` VALUES (137, 100, 'https://api.shengqianxiong.com.cn/img/20210814/7bb076847871417d9d153c1b126f99f2.jpg', 100, 50, NULL, '红色,m,工装,红色', 0, 0); +INSERT INTO `self_goods_sku` VALUES (138, 101, 'https://api.shengqianxiong.com.cn/file/uploadPath/2022/04/25/ae6370334a486d637f73de07c32afd6f.jpg', NULL, 20, NULL, NULL, 0, 999); +INSERT INTO `self_goods_sku` VALUES (140, 102, 'https://api.shengqianxiong.com.cn/file/uploadPath/2022/04/30/7981dc0ed9a4792ddf3d14243e9473f2.png', 100, 100, NULL, NULL, 0, 999); +INSERT INTO `self_goods_sku` VALUES (148, 98, 'https://api.shengqianxiong.com.cn/img/20210811/7e2a40c37b1745539da07793e1c1c7dc.jpg', 95, 85, NULL, NULL, 0, 998); +INSERT INTO `self_goods_sku` VALUES (155, 104, 'https://rwshop.xianmxkj.com/file/uploadPath/2022/06/24/94681944d192677aa426b95837c1abec.jpg', 100, 90, NULL, '大,红色', 0, 996); +INSERT INTO `self_goods_sku` VALUES (156, 104, 'https://rwshop.xianmxkj.com/file/uploadPath/2022/06/24/94681944d192677aa426b95837c1abec.jpg', 100, 90, NULL, '大,黑色', 0, 999); +INSERT INTO `self_goods_sku` VALUES (157, 104, 'https://rwshop.xianmxkj.com/file/uploadPath/2022/06/24/94681944d192677aa426b95837c1abec.jpg', 100, 90, NULL, '小,红色', 0, 999); +INSERT INTO `self_goods_sku` VALUES (158, 104, 'https://rwshop.xianmxkj.com/file/uploadPath/2022/06/24/94681944d192677aa426b95837c1abec.jpg', 100, 90, NULL, '小,黑色', 0, 998); +INSERT INTO `self_goods_sku` VALUES (159, 103, 'https://rwshop.xianmxkj.com/file/uploadPath/2022/05/19/176e12eee3b6f6b9b61e6dc047a6870c.jpg', 10, 1.01, NULL, NULL, 0, 999); + +-- ---------------------------- +-- Table structure for self_goods_virtual +-- ---------------------------- +DROP TABLE IF EXISTS `self_goods_virtual`; +CREATE TABLE `self_goods_virtual` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '卡密内容', + `cover_img` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '商品封面图片', + `create_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建时间', + `goods_id` bigint(20) NULL DEFAULT NULL COMMENT '商品id', + `link_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '链接', + `status` int(11) NULL DEFAULT NULL COMMENT '状态(1正常 2关闭 3已使用)', + `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '标题', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 57 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_goods_virtual +-- ---------------------------- +INSERT INTO `self_goods_virtual` VALUES (6, 'sadasd45455', 'https://www.gomyorder.cn/img/20201028/800543bfd20e4d4b818e8797146a655b.png', '2020-11-12 15:06:06', 80, 'http://www.baidu.com', 3, '省钱兄淘宝客系统'); +INSERT INTO `self_goods_virtual` VALUES (7, '12211212s1d', 'https://www.gomyorder.cn/img/20201028/800543bfd20e4d4b818e8797146a655b.png', '2020-11-12 15:06:06', 80, 'http://www.baidu.com', 3, '省钱兄淘宝客系统'); +INSERT INTO `self_goods_virtual` VALUES (8, 'sfdssd65656', 'https://www.gomyorder.cn/img/20201028/800543bfd20e4d4b818e8797146a655b.png', '2020-11-12 15:31:22', 80, 'http://www.baidu.com', 3, '省钱兄淘宝客系统'); +INSERT INTO `self_goods_virtual` VALUES (9, 'sdfsdfsd54587', 'https://www.gomyorder.cn/img/20201028/800543bfd20e4d4b818e8797146a655b.png', '2020-11-12 15:31:22', 80, 'http://www.baidu.com', 3, '省钱兄淘宝客系统'); +INSERT INTO `self_goods_virtual` VALUES (10, 'sdfdsf5655', 'https://www.gomyorder.cn/img/20201028/800543bfd20e4d4b818e8797146a655b.png', '2020-11-12 15:31:22', 80, 'http://www.baidu.com', 3, '省钱兄淘宝客系统'); +INSERT INTO `self_goods_virtual` VALUES (11, 'sfdssd65656', 'https://www.gomyorder.cn/img/20201028/800543bfd20e4d4b818e8797146a655b.png', '2020-11-12 19:45:25', 80, 'http://www.baidu.com', 3, '省钱兄淘宝客系统'); +INSERT INTO `self_goods_virtual` VALUES (15, 'sfdssd656586', 'https://www.gomyorder.cn/img/20201028/800543bfd20e4d4b818e8797146a655b.png', '2020-11-12 19:48:41', 80, 'https://www.xiansqx.com', 3, '省钱兄淘宝客系统'); +INSERT INTO `self_goods_virtual` VALUES (16, 'sfdssd659656', 'https://www.gomyorder.cn/img/20201028/800543bfd20e4d4b818e8797146a655b.png', '2020-11-12 19:48:41', 80, 'https://www.xiansqx.com', 3, '省钱兄淘宝客系统'); +INSERT INTO `self_goods_virtual` VALUES (17, 'sfdssd651656', 'https://www.gomyorder.cn/img/20201028/800543bfd20e4d4b818e8797146a655b.png', '2020-11-12 19:48:41', 80, 'https://www.xiansqx.com', 3, '省钱兄淘宝客系统'); +INSERT INTO `self_goods_virtual` VALUES (20, 'sfdssd65656', 'https://www.gomyorder.cn/img/20201107/10febbaeed25419f82a8d2cf7782f792.png', '2020-11-12 19:53:00', 82, 'https://www.xiansqx.com', 1, '诗凡黎衬衫女2020年新款秋装设计感小众天丝女装上衣长袖黄色衬衣'); +INSERT INTO `self_goods_virtual` VALUES (22, 'dfjkhf', 'https://www.gomyorder.cn/img/20201028/800543bfd20e4d4b818e8797146a655b.png', '2020-11-17 13:31:06', 80, 'https://www.xiansqx.com', 3, '省钱兄淘宝客系统'); +INSERT INTO `self_goods_virtual` VALUES (23, 'dfjkhdgf', 'https://www.gomyorder.cn/img/20201028/800543bfd20e4d4b818e8797146a655b.png', '2020-11-17 13:31:06', 80, 'https://www.xiansqx.com', 3, '省钱兄淘宝客系统'); +INSERT INTO `self_goods_virtual` VALUES (24, 'dsadkskldsalfDSF', 'https://www.gomyorder.cn/img/20201107/10febbaeed25419f82a8d2cf7782f792.png', '2020-11-17 14:58:54', 82, 'https://www.xiansqx.com', 1, '诗凡黎衬衫女2020年新款秋装设计感小众天丝女装上衣长袖黄色衬衣'); +INSERT INTO `self_goods_virtual` VALUES (25, '5546565656', 'https://www.gomyorder.cn/img/20201107/10febbaeed25419f82a8d2cf7782f792.png', '2020-11-17 14:58:54', 82, 'https://www.xiansqx.com', 1, '诗凡黎衬衫女2020年新款秋装设计感小众天丝女装上衣长袖黄色衬衣'); +INSERT INTO `self_goods_virtual` VALUES (30, '5454578855', 'https://www.gomyorder.cn/img/20201107/10febbaeed25419f82a8d2cf7782f792.png', '2020-11-17 15:14:49', 82, 'https://sqx.gomyorder.cn', 1, '诗凡黎衬衫女2020年新款秋装设计感小众天丝女装上衣长袖黄色衬衣'); +INSERT INTO `self_goods_virtual` VALUES (31, 'aaa', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2020-11-24 15:08:22', 83, 'http://tengxun.com', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (32, 'bbb', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2020-11-24 15:08:22', 83, 'http://tengxun.com', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (33, 'ccc', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2020-11-24 15:08:22', 83, 'https://m.nn.com/mcenterList.html?region_code=1&language=zh_CN&platform=2', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (34, 'dskjjfhkfh', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2020-12-04 13:10:27', 83, 'http://www/cj', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (35, 'sfjsf', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2020-12-04 13:10:27', 83, 'http://www/cj', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (36, 'sfkj', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2020-12-04 13:10:27', 83, 'http://www/cj', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (37, 'aa', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2020-12-08 10:57:49', 83, 'ss', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (38, 'wwqq', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2020-12-08 10:57:57', 83, 'ww', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (39, 'sbfsb', 'https://www.gomyorder.cn/img/20210322/77756115a5e046ee9b0463d53fb5ecfe.jpg', '2021-03-22 14:59:53', 89, 'sdvsf', 3, 'dbfg'); +INSERT INTO `self_goods_virtual` VALUES (40, 'grgde', 'https://www.gomyorder.cn/img/20210322/77756115a5e046ee9b0463d53fb5ecfe.jpg', '2021-03-22 15:00:17', 89, 'dgfr', 3, 'dbfg'); +INSERT INTO `self_goods_virtual` VALUES (41, 'fdhgf', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2021-03-24 11:04:22', 83, 'gdf', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (42, 'fdgdf', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2021-03-24 11:05:48', 83, 'http://www.baidu.com', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (43, 'dsgds', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2021-03-24 11:12:36', 83, 'https://www.baidu.com/', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (44, 'dvd', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2021-03-24 11:13:27', 83, 'https://sqx.gomyorder.cn', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (45, 'gregee', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2021-03-24 13:39:16', 83, 'reter', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (46, 'gtrg', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2021-03-24 14:05:15', 83, 'trg', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (47, 'fdbf', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2021-03-24 14:05:32', 83, 'dhb', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (48, 'bgf', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2021-03-24 14:05:45', 83, 'bfg', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (49, 'vd', 'https://www.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2021-03-24 14:06:39', 83, 'dv', 2, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (50, '111111111111111', 'https://tk.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2021-04-12 13:25:49', 83, '1111111', 3, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (51, '654654', 'https://tk.gomyorder.cn/img/20201118/3c8f31bfe8604dc199e52c59a15dae18.png', '2021-06-28 15:38:30', 83, '4645', 1, '腾讯视频'); +INSERT INTO `self_goods_virtual` VALUES (52, '64564', 'https://tk.gomyorder.cn/img/20210628/185be6791d9d4dc99d6b90602201f2cf.png', '2021-06-29 11:28:23', 92, '436456', 1, '衬衫'); +INSERT INTO `self_goods_virtual` VALUES (53, '67575', 'https://tk.gomyorder.cn/img/20201028/800543bfd20e4d4b818e8797146a655b.png', '2021-06-29 16:33:42', 80, '75675', 3, '省钱兄淘宝客系统'); +INSERT INTO `self_goods_virtual` VALUES (54, '儿童', 'https://tk.gomyorder.cn/img/20201107/10febbaeed25419f82a8d2cf7782f792.png', '2021-08-03 09:45:08', 82, '儿童椅44444', 1, '诗凡黎衬衫女2020年新款秋装设计感小众天丝女装上衣长袖黄色衬衣'); +INSERT INTO `self_goods_virtual` VALUES (55, '没有', 'https://tk.gomyorder.cn/img/20201028/800543bfd20e4d4b818e8797146a655b.png', '2021-08-10 15:32:09', 80, 'VC', 1, '省钱兄淘宝客系统'); +INSERT INTO `self_goods_virtual` VALUES (56, '兜兜风', 'https://api.shengqianxiong.com.cn/img/20210814/7bb076847871417d9d153c1b126f99f2.jpg', '2022-04-15 10:43:36', 100, '嗯嗯', 3, '测试商品'); + +-- ---------------------------- +-- Table structure for self_merchant_apply +-- ---------------------------- +DROP TABLE IF EXISTS `self_merchant_apply`; +CREATE TABLE `self_merchant_apply` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `audit_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '生效日期', + `audit_years` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '生效年限', + `company_address_city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '公司注册地址市', + `company_address_detail` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '公司注册详细地址', + `company_address_district` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '公司注册地址区', + `company_address_province` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '公司注册地址省', + `company_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '营业执照编号', + `company_license_img` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '营业执照照片', + `company_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '商户名称', + `company_term` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '营业期限', + `create_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建时间', + `id_card_img1` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '证件照片正面', + `id_card_img2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '证件照片国徽面', + `id_card_img3` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '手持证件照片', + `id_card_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '身份证号码', + `id_card_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '证件类型(1中国大陆居民身份证 2中国香港居民来往内地通行证 3中国澳门居民来往内地通行证 4中国台湾居民来往内地通行证 5其他国家或地区居民护照)', + `id_card_valid_time_end` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '身份证有效期起始时间', + `id_card_valid_time_start` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '身份证有效期截止时间', + `legal` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '店铺负责人', + `legal_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '负责人电话', + `server_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '客服电话', + `status` int(11) NULL DEFAULT NULL COMMENT '审核状态(1待处理 2通过 3拒绝)', + `store_address_detail` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '店铺地址详细', + `store_address_province` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '店铺地址省市', + `store_head` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '负责人姓名', + `store_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '店铺名称', + `store_type` int(11) NULL DEFAULT NULL COMMENT '店铺类型(1个人 2个体工商户 3企业 4其他组织)', + `refund_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '拒绝原因', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_merchant_apply +-- ---------------------------- + +-- ---------------------------- +-- Table structure for self_order_relation +-- ---------------------------- +DROP TABLE IF EXISTS `self_order_relation`; +CREATE TABLE `self_order_relation` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `commission_price` double NULL DEFAULT NULL COMMENT '订单佣金', + `create_at` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建时间', + `order_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '订单id', + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id', + `detail` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '分销明细', + `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '电话', + `status` int(11) NULL DEFAULT NULL COMMENT '状态 1未到账 2已到账', + `finish_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '收货时间', + `goods_id` bigint(20) NULL DEFAULT NULL COMMENT '商品id', + `goods_img` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '商品图片', + `goods_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '商品标题', + `lower_user_id` bigint(20) NULL DEFAULT NULL COMMENT '下级用户id', + `lower_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '下级用户名称', + `money_from` int(11) NULL DEFAULT NULL COMMENT '佣金来源(1直属 2自己 3非直属)', + `pay_money` double NULL DEFAULT NULL COMMENT '支付金额', + `commission_money` double NULL DEFAULT NULL COMMENT '订单佣金', + `user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '用户姓名', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 473 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_order_relation +-- ---------------------------- + +-- ---------------------------- +-- Table structure for self_order_remind +-- ---------------------------- +DROP TABLE IF EXISTS `self_order_remind`; +CREATE TABLE `self_order_remind` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `create_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建时间', + `orders_id` bigint(20) NULL DEFAULT NULL COMMENT '订单id', + `status` int(11) NULL DEFAULT NULL COMMENT '状态1提醒 2收到', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 50 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_order_remind +-- ---------------------------- + +-- ---------------------------- +-- Table structure for self_order_sale +-- ---------------------------- +DROP TABLE IF EXISTS `self_order_sale`; +CREATE TABLE `self_order_sale` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '未使用', + `refused` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `apply` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `create_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `orders_id` bigint(20) NULL DEFAULT NULL, + `status` int(11) NULL DEFAULT NULL, + `user_id` bigint(20) NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_order_sale +-- ---------------------------- + +-- ---------------------------- +-- Table structure for self_orders +-- ---------------------------- +DROP TABLE IF EXISTS `self_orders`; +CREATE TABLE `self_orders` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `consignee` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '收货人', + `create_at` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建时间', + `descrition` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '订单备注', + `detail` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '详细地址', + `img` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '商品图片', + `mobile` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '电话', + `number` int(11) NULL DEFAULT NULL COMMENT '商品个数', + `order_num` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '订单号', + `pay_money` double NULL DEFAULT NULL COMMENT '支付金额', + `price` double NULL DEFAULT NULL COMMENT '价格', + `status` int(11) NULL DEFAULT NULL COMMENT '订单状态(1待付款 2已付款 3已发货 4已收货 5已取消 6退款中 7已退款 8拒绝退款 9拼团中 10已评价)', + `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '标题', + `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '类型', + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id', + `finish_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '完成时间', + `pay_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '支付时间', + `pay_way` int(11) NULL DEFAULT NULL COMMENT '支付方式(1app微信 2微信公众号 3微信小程序 4app支付宝 5H5支付宝 6零钱)', + `user_coupons_id` bigint(20) NULL DEFAULT NULL COMMENT '用户优惠券id', + `commission_price` double NULL DEFAULT NULL COMMENT '订单佣金', + `relation_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '会员邀请码id', + `provinces` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '省市区', + `express_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '快递名称', + `express_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '快递单号', + `refund` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '退款理由', + `goods_id` bigint(20) NULL DEFAULT NULL COMMENT '商品id', + `is_express` int(11) NULL DEFAULT NULL COMMENT '是否需要发货(1需要发货 2无需发货)', + `is_refund` int(11) NULL DEFAULT NULL COMMENT '是否可以退款(2不可退款)', + `refused_refund` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '拒绝退款理由', + `coupon_money` double NULL DEFAULT NULL COMMENT '优惠券金额', + `detail_json` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '商品sku信息', + `express_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '发货时间', + `group_id` bigint(20) NULL DEFAULT NULL COMMENT '拼团商品Id', + `group_pink_id` bigint(20) NULL DEFAULT NULL COMMENT '加入拼团团体id', + `merchant_id` bigint(20) NULL DEFAULT NULL COMMENT '商户id', + `order_type` int(11) NULL DEFAULT NULL COMMENT '订单类型(1普通订单 2拼团 3秒杀)', + `pay_num` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '支付单号', + `postage_price` double NULL DEFAULT NULL COMMENT '邮费', + `sec_kill_id` bigint(20) NULL DEFAULT NULL COMMENT '秒杀商品id', + `sku_id` bigint(20) NULL DEFAULT NULL COMMENT '商品skuId', + `virtual_id` bigint(20) NULL DEFAULT NULL COMMENT '虚拟商品id', + `member_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '会员价格', + `send_way` int(11) NULL DEFAULT NULL COMMENT '配送方式 1快递 2自取', + `old_status` int(11) NULL DEFAULT NULL COMMENT '退款前状态', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 618 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_orders +-- ---------------------------- + +-- ---------------------------- +-- Table structure for self_prize +-- ---------------------------- +DROP TABLE IF EXISTS `self_prize`; +CREATE TABLE `self_prize` ( + `prize_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '奖品id', + `add_ji_fen` int(11) NULL DEFAULT NULL COMMENT '中奖积分', + `create_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建时间', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '奖品展示名称', + `prize_image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '奖品图片', + `prize_rule_id` bigint(20) NULL DEFAULT NULL, + `type` int(11) NULL DEFAULT NULL COMMENT '类型', + `weight` int(11) NULL DEFAULT NULL, + PRIMARY KEY (`prize_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_prize +-- ---------------------------- +INSERT INTO `self_prize` VALUES (1, 0, '2020-11-25 16:59:43', '谢谢惠顾', 'https://api.shengqianxiong.com.cn/img/20201125/83eca1a126ab43ddb98d50317ba98550.png', 1, 1, 100); +INSERT INTO `self_prize` VALUES (2, 10, '2020-11-25 16:59:54', '10积分', 'https://api.shengqianxiong.com.cn/img/20201125/90f5eb02d4af4083a80e8dae51bdfd78.png', 1, 1, 30); +INSERT INTO `self_prize` VALUES (3, 50, '2020-11-25 17:00:04', '50积分', 'https://api.shengqianxiong.com.cn/img/20201125/b7c494a13a06457192a2b63f9e7bcb3f.png', 1, 1, 50); +INSERT INTO `self_prize` VALUES (4, 5, '2021-03-22 14:27:33', 'tyrt', '', 5, 1, 1); +INSERT INTO `self_prize` VALUES (6, 1, '2021-06-25 16:51:49', 'tytr', 'https://h5.xuexiaedu.com/img/20210625/5ed65002c33f417eb7bfa5876723dd48.png', 7, 1, 5); + +-- ---------------------------- +-- Table structure for self_prize_rule +-- ---------------------------- +DROP TABLE IF EXISTS `self_prize_rule`; +CREATE TABLE `self_prize_rule` ( + `prize_rule_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '奖池id', + `create_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建时间', + `detail` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '活动规则', + `ji_fen` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '消耗积分', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '抽奖名称', + `number` int(11) NULL DEFAULT NULL COMMENT '每日抽取次数', + `status` int(11) NULL DEFAULT NULL COMMENT '状态(1开启 2关闭)', + PRIMARY KEY (`prize_rule_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_prize_rule +-- ---------------------------- +INSERT INTO `self_prize_rule` VALUES (1, '2020-11-23 13:55:18', '每人每天限制抽取3次', '10', '积分抽奖', 3, 1); + +-- ---------------------------- +-- Table structure for self_prize_user +-- ---------------------------- +DROP TABLE IF EXISTS `self_prize_user`; +CREATE TABLE `self_prize_user` ( + `prize_user_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '抽奖记录id', + `add_ji_fen` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '增加的积分', + `create_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建时间', + `less_ji_fen` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '减少的积分', + `nick_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '昵称', + `prize_id` bigint(20) NULL DEFAULT NULL COMMENT '奖品id', + `prize_rule_id` bigint(20) NULL DEFAULT NULL COMMENT '奖池id', + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id', + PRIMARY KEY (`prize_user_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 189 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_prize_user +-- ---------------------------- + +-- ---------------------------- +-- Table structure for self_tenant_apply +-- ---------------------------- +DROP TABLE IF EXISTS `self_tenant_apply`; +CREATE TABLE `self_tenant_apply` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '未使用', + `company_address_city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `company_address_detail` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `company_address_district` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `company_address_province` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `company_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `company_license_img` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `company_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `company_term` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `legal` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `legal_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `server_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `store_address_detail` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `store_address_province` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `store_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL, + `store_type` int(11) NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_tenant_apply +-- ---------------------------- + +-- ---------------------------- +-- Table structure for self_user_collect +-- ---------------------------- +DROP TABLE IF EXISTS `self_user_collect`; +CREATE TABLE `self_user_collect` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `cover_img` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `create_time` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `goods_id` bigint(20) NULL DEFAULT NULL, + `price` double NULL DEFAULT NULL, + `title` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `user_id` bigint(20) NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 104 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of self_user_collect +-- ---------------------------- + +-- ---------------------------- +-- Table structure for sys_captcha +-- ---------------------------- +DROP TABLE IF EXISTS `sys_captcha`; +CREATE TABLE `sys_captcha` ( + `uuid` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'uuid', + `code` varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '验证码', + `expire_time` datetime(0) NULL DEFAULT NULL COMMENT '过期时间', + PRIMARY KEY (`uuid`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统验证码' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_captcha +-- ---------------------------- + +-- ---------------------------- +-- Table structure for sys_config +-- ---------------------------- +DROP TABLE IF EXISTS `sys_config`; +CREATE TABLE `sys_config` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `param_key` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'key', + `param_value` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'value', + `status` tinyint(4) NULL DEFAULT 1 COMMENT '状态 0:隐藏 1:显示', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `param_key`(`param_key`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统配置信息表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_config +-- ---------------------------- + +-- ---------------------------- +-- Table structure for sys_dict +-- ---------------------------- +DROP TABLE IF EXISTS `sys_dict`; +CREATE TABLE `sys_dict` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '字典名称', + `type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '字典类型', + `code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '字典码', + `value` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '字典值', + `order_num` int(11) NULL DEFAULT 0 COMMENT '排序', + `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + `parent_id` int(11) NULL DEFAULT NULL, + `status` int(11) NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 96 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '数据字典表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_dict +-- ---------------------------- +INSERT INTO `sys_dict` VALUES (22, '服务类型', '服务类型', '', '', 5, '11', 0, NULL); +INSERT INTO `sys_dict` VALUES (91, '', '', '足浴按摩', '足浴按摩', 2, '足浴按摩', 22, 1); +INSERT INTO `sys_dict` VALUES (95, '', '', '健身私教', '健身私教', 1, '健身私教', 22, 1); + +-- ---------------------------- +-- Table structure for sys_log +-- ---------------------------- +DROP TABLE IF EXISTS `sys_log`; +CREATE TABLE `sys_log` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户名', + `operation` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户操作', + `method` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '请求方法', + `params` varchar(5000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '请求参数', + `time` bigint(20) NOT NULL COMMENT '执行时长(毫秒)', + `ip` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'IP地址', + `create_date` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 473 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统日志' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_log +-- ---------------------------- + +-- ---------------------------- +-- Table structure for sys_menu +-- ---------------------------- +DROP TABLE IF EXISTS `sys_menu`; +CREATE TABLE `sys_menu` ( + `menu_id` bigint(20) NOT NULL AUTO_INCREMENT, + `parent_id` bigint(20) NULL DEFAULT NULL COMMENT '父菜单ID,一级菜单为0', + `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单名称', + `url` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单URL', + `perms` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '授权(多个用逗号分隔,如:user:list,user:create)', + `type` int(11) NULL DEFAULT NULL COMMENT '类型 0:目录 1:菜单 2:按钮', + `icon` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单图标', + `order_num` int(11) NULL DEFAULT NULL COMMENT '排序', + PRIMARY KEY (`menu_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 264 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '菜单管理' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_menu +-- ---------------------------- +INSERT INTO `sys_menu` VALUES (2, 128, '管理员列表', 'sys/user', NULL, 1, 'admin', 1); +INSERT INTO `sys_menu` VALUES (3, 128, '角色管理', 'sys/role', NULL, 1, 'role', 1); +INSERT INTO `sys_menu` VALUES (4, 128, '菜单管理', 'sys/menu', NULL, 1, 'menu', 2); +INSERT INTO `sys_menu` VALUES (15, 2, '查看', NULL, 'sys:user:list,sys:user:info', 2, NULL, 0); +INSERT INTO `sys_menu` VALUES (16, 2, '新增', NULL, 'sys:user:save,sys:role:select', 2, NULL, 0); +INSERT INTO `sys_menu` VALUES (17, 2, '修改', NULL, 'sys:user:update,sys:role:select', 2, NULL, 0); +INSERT INTO `sys_menu` VALUES (18, 2, '删除', NULL, 'sys:user:delete', 2, NULL, 0); +INSERT INTO `sys_menu` VALUES (19, 3, '查看', NULL, 'sys:role:list,sys:role:info', 2, NULL, 0); +INSERT INTO `sys_menu` VALUES (20, 3, '新增', NULL, 'sys:role:save,sys:menu:list', 2, NULL, 0); +INSERT INTO `sys_menu` VALUES (21, 3, '修改', NULL, 'sys:role:update,sys:menu:list', 2, NULL, 0); +INSERT INTO `sys_menu` VALUES (22, 3, '删除', NULL, 'sys:role:delete', 2, NULL, 0); +INSERT INTO `sys_menu` VALUES (23, 4, '查看', NULL, 'sys:menu:list,sys:menu:info', 2, NULL, 0); +INSERT INTO `sys_menu` VALUES (24, 4, '新增', NULL, 'sys:menu:save,sys:menu:select', 2, NULL, 0); +INSERT INTO `sys_menu` VALUES (25, 4, '修改', NULL, 'sys:menu:update,sys:menu:select', 2, NULL, 0); +INSERT INTO `sys_menu` VALUES (26, 4, '删除', NULL, 'sys:menu:delete', 2, NULL, 0); +INSERT INTO `sys_menu` VALUES (32, 0, '用户中心', 'userList', '', 1, 'yonghul', 1); +INSERT INTO `sys_menu` VALUES (33, 0, '数据中心', 'home', '', 1, 'shuju', 0); +INSERT INTO `sys_menu` VALUES (34, 0, '财务中心', 'financeList', '', 1, 'caiwu', 1); +INSERT INTO `sys_menu` VALUES (35, 34, '查看', '', 'financeList:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (36, 34, '转账', '', 'financeList:transfer', 2, '', 0); +INSERT INTO `sys_menu` VALUES (37, 34, '退款', '', 'financeList:refund', 2, '', 0); +INSERT INTO `sys_menu` VALUES (39, 34, '修改', '', 'financeList:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (40, 34, '删除', '', 'financeList:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (41, 0, '消息中心', 'message', '', 1, 'xiaoxi', 1); +INSERT INTO `sys_menu` VALUES (42, 41, '查看', '', 'message:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (43, 41, '消息推送', '', 'message:push', 2, '', 0); +INSERT INTO `sys_menu` VALUES (50, 0, '首页装修', 'bannerList', '', 1, 'shangpin', 2); +INSERT INTO `sys_menu` VALUES (51, 50, '查看', '', 'bannerList:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (52, 50, '添加', '', 'bannerList:add', 2, '', 0); +INSERT INTO `sys_menu` VALUES (53, 50, '修改', '', 'bannerList:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (54, 50, '删除', '', 'bannerList:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (57, 0, '系统配置', 'allocationList', '', 1, 'menu', 19); +INSERT INTO `sys_menu` VALUES (58, 57, '查看', '', 'allocationList:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (59, 57, '修改', '', 'allocationList:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (60, 32, '查看', '', 'userList:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (61, 32, '删除', '', 'userList:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (62, 0, '订单中心', 'orderCenter', '', 1, 'log', 4); +INSERT INTO `sys_menu` VALUES (63, 62, '查看', '', '', 2, '', 0); +INSERT INTO `sys_menu` VALUES (64, 62, '删除', '', 'orderCenter:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (69, 41, '添加', '', 'message:add', 2, '', 0); +INSERT INTO `sys_menu` VALUES (70, 41, '修改', '', 'message:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (71, 41, '删除', '', 'message:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (72, 0, '服务中心', 'locality', '', 1, 'order', 6); +INSERT INTO `sys_menu` VALUES (73, 72, '添加', '', 'locality:add', 2, '', 0); +INSERT INTO `sys_menu` VALUES (74, 72, '查看', '', 'locality:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (75, 72, '修改', '', 'locality:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (76, 72, '删除', '', 'locality:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (77, 159, '实名认证', 'autonym', '', 1, 'shangpin', 6); +INSERT INTO `sys_menu` VALUES (78, 77, '列表', '', 'autonym:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (79, 129, '聊天室', 'vueMchat', '', 1, 'xiaoxi', 0); +INSERT INTO `sys_menu` VALUES (90, 32, '修改积分', '', 'userList:updatejf', 2, '', 0); +INSERT INTO `sys_menu` VALUES (91, 32, '修改用户状态', '', 'userList:updateStatus', 2, '', 0); +INSERT INTO `sys_menu` VALUES (92, 77, '通过', '', 'autonym:tongguo', 2, '', 0); +INSERT INTO `sys_menu` VALUES (93, 77, '拒绝', '', 'autonym:jujue', 2, '', 0); +INSERT INTO `sys_menu` VALUES (94, 128, '升级配置', 'app', '', 1, 'sql', 9); +INSERT INTO `sys_menu` VALUES (95, 94, '查看', '', 'app:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (96, 94, '添加', '', 'app:add', 2, '', 0); +INSERT INTO `sys_menu` VALUES (97, 94, '修改', '', 'app:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (98, 94, '删除', '', 'app:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (99, 129, '聊天记录', 'chatRecord', '', 1, 'renwu', 0); +INSERT INTO `sys_menu` VALUES (100, 99, '查看', '', 'chatRecord:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (101, 99, '删除', '', 'chatRecord:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (107, 159, '技师申请', 'applyList', '', 1, 'fenleilist', 0); +INSERT INTO `sys_menu` VALUES (108, 107, '查看', '', 'applyList:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (109, 107, '通过', '', 'applyList:tongguo', 2, '', 0); +INSERT INTO `sys_menu` VALUES (110, 107, '拒绝', '', 'applyList:jujue', 2, '', 0); +INSERT INTO `sys_menu` VALUES (118, 130, '会员配置', 'memberDetails', '', 1, 'renwu', 0); +INSERT INTO `sys_menu` VALUES (119, 130, '会员特权', 'vipPrivilege', '', 1, 'renwu', 0); +INSERT INTO `sys_menu` VALUES (120, 118, '修改', '', 'memberDetails:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (121, 118, '删除', '', 'memberDetails:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (122, 118, '添加', '', 'memberDetails:add', 2, '', 0); +INSERT INTO `sys_menu` VALUES (123, 118, '列表', '', 'memberDetails:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (124, 119, '列表', '', 'vipPrivilege:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (125, 119, '添加', '', 'vipPrivilege:add', 2, '', 0); +INSERT INTO `sys_menu` VALUES (126, 119, '修改', '', 'vipPrivilege:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (127, 119, '删除', '', 'vipPrivilege:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (128, 0, '系统管理', '', '', 0, 'shezhi', 20); +INSERT INTO `sys_menu` VALUES (129, 0, '聊天管理', '', '', 0, 'renwu1', 9); +INSERT INTO `sys_menu` VALUES (130, 0, '会员管理', '', '', 0, 'leibie', 7); +INSERT INTO `sys_menu` VALUES (131, 128, '字典', 'sys/dict', '', 1, 'fenleilist', 0); +INSERT INTO `sys_menu` VALUES (132, 131, '查看', '', 'sys:dict:list,sys:dict:info', 2, '', 0); +INSERT INTO `sys_menu` VALUES (133, 131, '新增', '', 'sys:dict:save', 2, '', 0); +INSERT INTO `sys_menu` VALUES (134, 131, '修改', '', 'sys:dict:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (135, 131, '删除', '', 'sys:dict:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (136, 0, '师傅地图', 'shifuScheduling', '', 1, 'dangdifill', 10); +INSERT INTO `sys_menu` VALUES (137, 136, '查看', '', 'shifuScheduling:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (138, 195, '天网中心', 'skynetCenter', '', 1, 'xinxi', 0); +INSERT INTO `sys_menu` VALUES (139, 138, '查看', '', 'skynetCenter:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (140, 0, '优惠券管理', '', '', 0, 'editor', 7); +INSERT INTO `sys_menu` VALUES (141, 140, '优惠券', 'couponYhq', '', 1, 'tianjia', 0); +INSERT INTO `sys_menu` VALUES (142, 141, '查看', '', 'couponYhq:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (143, 141, '添加', '', 'couponYhq:add', 2, '', 0); +INSERT INTO `sys_menu` VALUES (144, 141, '修改', '', 'couponYhq:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (145, 141, '删除', '', 'couponYhq:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (146, 141, '赠送', '', 'couponYhq:zengsong', 2, '', 0); +INSERT INTO `sys_menu` VALUES (152, 140, '优惠券领取记录', 'couponuser', '', 1, 'order', 0); +INSERT INTO `sys_menu` VALUES (153, 152, '查看', '', 'couponuser:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (154, 140, '充值配置', 'IntegralGoods', '', 1, 'log', 0); +INSERT INTO `sys_menu` VALUES (155, 154, '查看', '', 'IntegralGoods:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (156, 154, '添加', '', 'IntegralGoods:add', 2, '', 0); +INSERT INTO `sys_menu` VALUES (157, 154, '修改', '', 'IntegralGoods:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (158, 154, '删除', '', 'IntegralGoods:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (159, 0, '技师管理', '', '', 0, 'role', 8); +INSERT INTO `sys_menu` VALUES (160, 159, '技师列表', 'technician', '', 1, 'renwu', 0); +INSERT INTO `sys_menu` VALUES (161, 160, '查看', '', 'technician:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (162, 160, '修改', '', 'technician:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (163, 160, '删除', '', 'technician:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (164, 0, '评价中心', 'comment', '', 1, 'pinglun', 9); +INSERT INTO `sys_menu` VALUES (165, 164, '查看', '', 'comment:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (166, 164, '删除', '', 'comment:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (167, 0, '投诉中心', 'business', '', 1, 'renwu1', 9); +INSERT INTO `sys_menu` VALUES (168, 167, '查看', '', 'business:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (169, 167, '通过', '', 'business:tongguo', 2, '', 0); +INSERT INTO `sys_menu` VALUES (170, 167, '拒绝', '', 'business:jujue', 2, '', 0); +INSERT INTO `sys_menu` VALUES (171, 167, '添加', '', 'business:add', 2, '', 0); +INSERT INTO `sys_menu` VALUES (172, 167, '修改', '', 'business:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (173, 167, '删除', '', 'business:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (174, 195, '紧急求助', 'emergencyHelp', '', 1, 'tianjia', 0); +INSERT INTO `sys_menu` VALUES (175, 174, '查看', '', 'emergencyHelp:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (176, 32, '修改信用分', '', 'userList:updateXyf', 2, '', 0); +INSERT INTO `sys_menu` VALUES (177, 0, '出行配置', 'travel', '', 1, 'pingtai', 12); +INSERT INTO `sys_menu` VALUES (178, 177, '查看', '', 'travel:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (179, 177, '添加', '', 'travel:add', 2, '', 0); +INSERT INTO `sys_menu` VALUES (180, 177, '修改', '', 'travel:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (181, 177, '删除', '', 'travel:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (182, 0, '推广代理', 'agent', '', 1, 'shangpin', 10); +INSERT INTO `sys_menu` VALUES (183, 182, '查看', '', 'agent:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (184, 0, '帮助中心', 'materialsList', '', 1, 'leibie', 10); +INSERT INTO `sys_menu` VALUES (185, 184, '查看', '', 'materialsList:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (186, 184, '添加', '', 'materialsList:add', 2, '', 0); +INSERT INTO `sys_menu` VALUES (188, 184, '修改', '', 'materialsList:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (189, 184, '删除', '', 'materialsList:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (195, 0, '安全中心', '', '', 0, 'tianjia', 11); +INSERT INTO `sys_menu` VALUES (196, 32, '修改佣金比例', '', 'userList:updatebl', 2, '', 0); +INSERT INTO `sys_menu` VALUES (197, 32, '设置会员', '', 'userList:updateVip', 2, '', 0); +INSERT INTO `sys_menu` VALUES (198, 32, '设置技师', '', 'userList:updateJs', 2, '', 0); +INSERT INTO `sys_menu` VALUES (199, 32, '设置推广员', '', 'userList:updateTgy', 2, '', 0); +INSERT INTO `sys_menu` VALUES (200, 32, '修改信息', '', 'userList:updateXx', 2, '', 0); +INSERT INTO `sys_menu` VALUES (201, 34, '导出', '', 'financeList:daochu', 2, '', 0); +INSERT INTO `sys_menu` VALUES (202, 62, '导出', '', 'orderCenter:daochu', 2, '', 0); +INSERT INTO `sys_menu` VALUES (203, 62, '退款', '', 'orderCenter:tuikuan', 2, '', 0); +INSERT INTO `sys_menu` VALUES (204, 182, '通过', '', 'agent:tongguo', 2, '', 0); +INSERT INTO `sys_menu` VALUES (205, 182, '拒绝', '', 'agent:jujue', 2, '', 0); +INSERT INTO `sys_menu` VALUES (206, 138, '修改用户状态', '', 'skynetCenter:fxyh', 2, '', 0); +INSERT INTO `sys_menu` VALUES (207, 174, '处理', '', 'emergencyHelp:chuli', 2, '', 0); +INSERT INTO `sys_menu` VALUES (208, 0, '自营商城', '', '', 0, 'shouye', 6); +INSERT INTO `sys_menu` VALUES (209, 208, '商品管理', 'shopAdmin', '', 1, 'peizhilb', 0); +INSERT INTO `sys_menu` VALUES (210, 209, '查看', '', 'shopAdmin:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (211, 209, '添加', '', 'shopAdmin:add', 2, '', 0); +INSERT INTO `sys_menu` VALUES (213, 209, '修改', '', 'shopAdmin:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (214, 209, '删除', '', 'shopAdmin:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (215, 208, '商品分类', 'classifyAdmin', '', 1, 'leibie', 0); +INSERT INTO `sys_menu` VALUES (216, 215, '查看', '', 'classifyAdmin:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (217, 215, '添加', '', 'classifyAdmin:add', 2, '', 0); +INSERT INTO `sys_menu` VALUES (218, 215, '修改', '', 'classifyAdmin:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (219, 215, '删除', '', 'classifyAdmin:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (220, 208, '商品规格', 'specification', '', 1, 'fenleilist', 0); +INSERT INTO `sys_menu` VALUES (221, 220, '查看', '', 'specification:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (222, 220, '添加', '', 'specification:add', 2, '', 0); +INSERT INTO `sys_menu` VALUES (223, 220, '修改', '', 'specification:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (224, 220, '删除', '', 'specification:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (225, 208, '订单管理', 'orderAdmin', '', 1, 'order', 0); +INSERT INTO `sys_menu` VALUES (226, 225, '查看', '', 'orderAdmin:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (227, 208, '商城配置', 'shopConfig', '', 1, 'config', 0); +INSERT INTO `sys_menu` VALUES (228, 227, '查看', '', 'shopConfig:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (229, 227, '添加', '', 'shopConfig:add', 2, '', 0); +INSERT INTO `sys_menu` VALUES (230, 227, '修改', '', 'shopConfig:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (231, 227, '删除', '', 'shopConfig:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (232, 0, '商家管理', 'merchantList', '', 1, 'yonghul', 6); +INSERT INTO `sys_menu` VALUES (233, 232, '查看', '', 'merchantList:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (234, 232, '添加', '', 'merchantList:add', 2, '', 0); +INSERT INTO `sys_menu` VALUES (235, 232, '修改', '', 'merchantList:update', 2, '', 0); +INSERT INTO `sys_menu` VALUES (236, 232, '删除', '', 'merchantList:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (237, 208, '待处理订单', 'disposeOrder', '', 1, 'config', 0); +INSERT INTO `sys_menu` VALUES (238, 237, '查看', '', 'disposeOrder:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (239, 237, '确认退款', '', 'disposeOrder:refund', 2, '', 0); +INSERT INTO `sys_menu` VALUES (240, 237, '拒绝退款', '', 'disposeOrder:jujue', 2, '', 0); +INSERT INTO `sys_menu` VALUES (241, 237, '发货', '', 'disposeOrder:deliver', 2, '', 0); +INSERT INTO `sys_menu` VALUES (242, 32, '解绑商家', '', 'userList:updatejb', 2, '', 0); +INSERT INTO `sys_menu` VALUES (243, 32, '添加充值技师金额', '', 'userList:addcz', 2, '', 0); +INSERT INTO `sys_menu` VALUES (244, 32, '修改充值技师金额', '', 'userList:updatecz', 2, '', 0); +INSERT INTO `sys_menu` VALUES (245, 208, '商品评价', 'discuss', '', 1, 'xiaoxi', 0); +INSERT INTO `sys_menu` VALUES (246, 245, '查看', '', 'discuss:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (247, 245, '回复', '', 'brandShop:huifu', 2, '', 0); +INSERT INTO `sys_menu` VALUES (248, 245, '删除', '', 'brandShop:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (249, 237, '确认收货', '', 'disposeOrder:shouhuo', 2, '', 0); +INSERT INTO `sys_menu` VALUES (250, 225, '确认收货', '', 'disposeOrder:shouhuo', 2, '', 0); +INSERT INTO `sys_menu` VALUES (251, 159, '签到记录', 'signIn', '', 1, 'renwu', 0); +INSERT INTO `sys_menu` VALUES (252, 251, '查看', '', 'signIn:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (253, 159, '收益排行榜', 'riderTop', '', 1, 'tubiao', 0); +INSERT INTO `sys_menu` VALUES (254, 253, '查看', '', 'riderTop:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (257, 0, '城市投票', 'cityVoting', '', 1, 'mudedi', 8); +INSERT INTO `sys_menu` VALUES (258, 257, '查看', '', 'cityVoting:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (259, 195, '师傅位置记录', 'masterPosition', '', 1, 'dangdifill', 0); +INSERT INTO `sys_menu` VALUES (260, 259, '查看', '', 'masterPosition:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (261, 195, '服务中订单', 'orderInService', '', 1, 'renwu', 0); +INSERT INTO `sys_menu` VALUES (262, 261, '查看', '', 'orderInService:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (263, 62, '完成订单', '', 'orderCenter:wancheng', 2, '', 0); +INSERT INTO `sys_menu` VALUES (264, 159, '信用分排行榜', 'top', '', 1, 'tubiao', 1); +INSERT INTO `sys_menu` VALUES (265, 264, '查看', '', 'top:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (266, 159, '信用分明细', 'creditScore', '', 1, 'renwu', 2); +INSERT INTO `sys_menu` VALUES (267, 266, '查看', '', 'creditScore:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (268, 251, '删除', '', 'signIn:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (269, 0, '转化率列表', 'conversionRate', ' ', 1, 'leibie', 9); +INSERT INTO `sys_menu` VALUES (270, 269, '查看', '', 'conversionRate:list', 2, '', 0); +INSERT INTO `sys_menu` VALUES (271, 152, '失效', '', 'couponuser:shixiao', 2, '', 0); +INSERT INTO `sys_menu` VALUES (272, 152, '删除', '', 'couponuser:delete', 2, '', 0); +INSERT INTO `sys_menu` VALUES (273, 62, '取消订单', '', 'orderCenter:quxiao', 2, '', 0); + +-- ---------------------------- +-- Table structure for sys_oss +-- ---------------------------- +DROP TABLE IF EXISTS `sys_oss`; +CREATE TABLE `sys_oss` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `url` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'URL地址', + `create_date` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '文件上传' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_oss +-- ---------------------------- + +-- ---------------------------- +-- Table structure for sys_role +-- ---------------------------- +DROP TABLE IF EXISTS `sys_role`; +CREATE TABLE `sys_role` ( + `role_id` bigint(20) NOT NULL AUTO_INCREMENT, + `role_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '角色名称', + `remark` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + `create_user_id` bigint(20) NULL DEFAULT NULL COMMENT '创建者ID', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`role_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_role +-- ---------------------------- +INSERT INTO `sys_role` VALUES (1, '超级管理员', 'super', 2, '2021-06-04 17:38:28'); +INSERT INTO `sys_role` VALUES (4, '普通用户', '普通用户', 2, '2021-09-10 15:33:47'); + +-- ---------------------------- +-- Table structure for sys_role_menu +-- ---------------------------- +DROP TABLE IF EXISTS `sys_role_menu`; +CREATE TABLE `sys_role_menu` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `role_id` bigint(20) NULL DEFAULT NULL COMMENT '角色ID', + `menu_id` bigint(20) NULL DEFAULT NULL COMMENT '菜单ID', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 6313 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色与菜单对应关系' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_role_menu +-- ---------------------------- +INSERT INTO `sys_role_menu` VALUES (7087, 4, 33); +INSERT INTO `sys_role_menu` VALUES (7088, 4, 60); +INSERT INTO `sys_role_menu` VALUES (7089, 4, 90); +INSERT INTO `sys_role_menu` VALUES (7090, 4, 91); +INSERT INTO `sys_role_menu` VALUES (7091, 4, 176); +INSERT INTO `sys_role_menu` VALUES (7092, 4, 196); +INSERT INTO `sys_role_menu` VALUES (7093, 4, 197); +INSERT INTO `sys_role_menu` VALUES (7094, 4, 198); +INSERT INTO `sys_role_menu` VALUES (7095, 4, 199); +INSERT INTO `sys_role_menu` VALUES (7096, 4, 200); +INSERT INTO `sys_role_menu` VALUES (7097, 4, 242); +INSERT INTO `sys_role_menu` VALUES (7098, 4, 243); +INSERT INTO `sys_role_menu` VALUES (7099, 4, 244); +INSERT INTO `sys_role_menu` VALUES (7100, 4, 34); +INSERT INTO `sys_role_menu` VALUES (7101, 4, 35); +INSERT INTO `sys_role_menu` VALUES (7102, 4, 36); +INSERT INTO `sys_role_menu` VALUES (7103, 4, 37); +INSERT INTO `sys_role_menu` VALUES (7104, 4, 39); +INSERT INTO `sys_role_menu` VALUES (7105, 4, 40); +INSERT INTO `sys_role_menu` VALUES (7106, 4, 201); +INSERT INTO `sys_role_menu` VALUES (7107, 4, 41); +INSERT INTO `sys_role_menu` VALUES (7108, 4, 42); +INSERT INTO `sys_role_menu` VALUES (7109, 4, 43); +INSERT INTO `sys_role_menu` VALUES (7110, 4, 69); +INSERT INTO `sys_role_menu` VALUES (7111, 4, 70); +INSERT INTO `sys_role_menu` VALUES (7112, 4, 71); +INSERT INTO `sys_role_menu` VALUES (7113, 4, 51); +INSERT INTO `sys_role_menu` VALUES (7114, 4, 62); +INSERT INTO `sys_role_menu` VALUES (7115, 4, 263); +INSERT INTO `sys_role_menu` VALUES (7116, 4, 63); +INSERT INTO `sys_role_menu` VALUES (7117, 4, 64); +INSERT INTO `sys_role_menu` VALUES (7118, 4, 202); +INSERT INTO `sys_role_menu` VALUES (7119, 4, 203); +INSERT INTO `sys_role_menu` VALUES (7120, 4, 73); +INSERT INTO `sys_role_menu` VALUES (7121, 4, 74); +INSERT INTO `sys_role_menu` VALUES (7122, 4, 75); +INSERT INTO `sys_role_menu` VALUES (7123, 4, 208); +INSERT INTO `sys_role_menu` VALUES (7124, 4, 209); +INSERT INTO `sys_role_menu` VALUES (7125, 4, 210); +INSERT INTO `sys_role_menu` VALUES (7126, 4, 211); +INSERT INTO `sys_role_menu` VALUES (7127, 4, 213); +INSERT INTO `sys_role_menu` VALUES (7128, 4, 214); +INSERT INTO `sys_role_menu` VALUES (7129, 4, 215); +INSERT INTO `sys_role_menu` VALUES (7130, 4, 216); +INSERT INTO `sys_role_menu` VALUES (7131, 4, 217); +INSERT INTO `sys_role_menu` VALUES (7132, 4, 218); +INSERT INTO `sys_role_menu` VALUES (7133, 4, 219); +INSERT INTO `sys_role_menu` VALUES (7134, 4, 220); +INSERT INTO `sys_role_menu` VALUES (7135, 4, 221); +INSERT INTO `sys_role_menu` VALUES (7136, 4, 222); +INSERT INTO `sys_role_menu` VALUES (7137, 4, 223); +INSERT INTO `sys_role_menu` VALUES (7138, 4, 224); +INSERT INTO `sys_role_menu` VALUES (7139, 4, 225); +INSERT INTO `sys_role_menu` VALUES (7140, 4, 226); +INSERT INTO `sys_role_menu` VALUES (7141, 4, 250); +INSERT INTO `sys_role_menu` VALUES (7142, 4, 227); +INSERT INTO `sys_role_menu` VALUES (7143, 4, 228); +INSERT INTO `sys_role_menu` VALUES (7144, 4, 229); +INSERT INTO `sys_role_menu` VALUES (7145, 4, 230); +INSERT INTO `sys_role_menu` VALUES (7146, 4, 231); +INSERT INTO `sys_role_menu` VALUES (7147, 4, 237); +INSERT INTO `sys_role_menu` VALUES (7148, 4, 238); +INSERT INTO `sys_role_menu` VALUES (7149, 4, 239); +INSERT INTO `sys_role_menu` VALUES (7150, 4, 240); +INSERT INTO `sys_role_menu` VALUES (7151, 4, 241); +INSERT INTO `sys_role_menu` VALUES (7152, 4, 249); +INSERT INTO `sys_role_menu` VALUES (7153, 4, 245); +INSERT INTO `sys_role_menu` VALUES (7154, 4, 246); +INSERT INTO `sys_role_menu` VALUES (7155, 4, 247); +INSERT INTO `sys_role_menu` VALUES (7156, 4, 248); +INSERT INTO `sys_role_menu` VALUES (7157, 4, 233); +INSERT INTO `sys_role_menu` VALUES (7158, 4, 234); +INSERT INTO `sys_role_menu` VALUES (7159, 4, 235); +INSERT INTO `sys_role_menu` VALUES (7160, 4, 120); +INSERT INTO `sys_role_menu` VALUES (7161, 4, 122); +INSERT INTO `sys_role_menu` VALUES (7162, 4, 123); +INSERT INTO `sys_role_menu` VALUES (7163, 4, 124); +INSERT INTO `sys_role_menu` VALUES (7164, 4, 125); +INSERT INTO `sys_role_menu` VALUES (7165, 4, 126); +INSERT INTO `sys_role_menu` VALUES (7166, 4, 140); +INSERT INTO `sys_role_menu` VALUES (7167, 4, 141); +INSERT INTO `sys_role_menu` VALUES (7168, 4, 142); +INSERT INTO `sys_role_menu` VALUES (7169, 4, 143); +INSERT INTO `sys_role_menu` VALUES (7170, 4, 144); +INSERT INTO `sys_role_menu` VALUES (7171, 4, 145); +INSERT INTO `sys_role_menu` VALUES (7172, 4, 146); +INSERT INTO `sys_role_menu` VALUES (7178, 4, 152); +INSERT INTO `sys_role_menu` VALUES (7179, 4, 153); +INSERT INTO `sys_role_menu` VALUES (7180, 4, 154); +INSERT INTO `sys_role_menu` VALUES (7181, 4, 155); +INSERT INTO `sys_role_menu` VALUES (7182, 4, 156); +INSERT INTO `sys_role_menu` VALUES (7183, 4, 157); +INSERT INTO `sys_role_menu` VALUES (7184, 4, 158); +INSERT INTO `sys_role_menu` VALUES (7185, 4, 257); +INSERT INTO `sys_role_menu` VALUES (7186, 4, 258); +INSERT INTO `sys_role_menu` VALUES (7187, 4, 159); +INSERT INTO `sys_role_menu` VALUES (7188, 4, 107); +INSERT INTO `sys_role_menu` VALUES (7189, 4, 108); +INSERT INTO `sys_role_menu` VALUES (7190, 4, 109); +INSERT INTO `sys_role_menu` VALUES (7191, 4, 110); +INSERT INTO `sys_role_menu` VALUES (7192, 4, 160); +INSERT INTO `sys_role_menu` VALUES (7193, 4, 161); +INSERT INTO `sys_role_menu` VALUES (7194, 4, 162); +INSERT INTO `sys_role_menu` VALUES (7195, 4, 163); +INSERT INTO `sys_role_menu` VALUES (7196, 4, 251); +INSERT INTO `sys_role_menu` VALUES (7197, 4, 268); +INSERT INTO `sys_role_menu` VALUES (7198, 4, 252); +INSERT INTO `sys_role_menu` VALUES (7199, 4, 253); +INSERT INTO `sys_role_menu` VALUES (7200, 4, 254); +INSERT INTO `sys_role_menu` VALUES (7201, 4, 264); +INSERT INTO `sys_role_menu` VALUES (7202, 4, 265); +INSERT INTO `sys_role_menu` VALUES (7203, 4, 266); +INSERT INTO `sys_role_menu` VALUES (7204, 4, 267); +INSERT INTO `sys_role_menu` VALUES (7205, 4, 77); +INSERT INTO `sys_role_menu` VALUES (7206, 4, 78); +INSERT INTO `sys_role_menu` VALUES (7207, 4, 92); +INSERT INTO `sys_role_menu` VALUES (7208, 4, 93); +INSERT INTO `sys_role_menu` VALUES (7209, 4, 269); +INSERT INTO `sys_role_menu` VALUES (7210, 4, 270); +INSERT INTO `sys_role_menu` VALUES (7211, 4, 164); +INSERT INTO `sys_role_menu` VALUES (7212, 4, 165); +INSERT INTO `sys_role_menu` VALUES (7213, 4, 166); +INSERT INTO `sys_role_menu` VALUES (7214, 4, 167); +INSERT INTO `sys_role_menu` VALUES (7215, 4, 168); +INSERT INTO `sys_role_menu` VALUES (7216, 4, 169); +INSERT INTO `sys_role_menu` VALUES (7217, 4, 170); +INSERT INTO `sys_role_menu` VALUES (7218, 4, 171); +INSERT INTO `sys_role_menu` VALUES (7219, 4, 172); +INSERT INTO `sys_role_menu` VALUES (7220, 4, 173); +INSERT INTO `sys_role_menu` VALUES (7221, 4, 136); +INSERT INTO `sys_role_menu` VALUES (7222, 4, 137); +INSERT INTO `sys_role_menu` VALUES (7223, 4, 182); +INSERT INTO `sys_role_menu` VALUES (7224, 4, 183); +INSERT INTO `sys_role_menu` VALUES (7225, 4, 204); +INSERT INTO `sys_role_menu` VALUES (7226, 4, 205); +INSERT INTO `sys_role_menu` VALUES (7227, 4, 184); +INSERT INTO `sys_role_menu` VALUES (7228, 4, 185); +INSERT INTO `sys_role_menu` VALUES (7229, 4, 186); +INSERT INTO `sys_role_menu` VALUES (7230, 4, 188); +INSERT INTO `sys_role_menu` VALUES (7231, 4, 189); +INSERT INTO `sys_role_menu` VALUES (7232, 4, 195); +INSERT INTO `sys_role_menu` VALUES (7233, 4, 259); +INSERT INTO `sys_role_menu` VALUES (7234, 4, 260); +INSERT INTO `sys_role_menu` VALUES (7235, 4, 261); +INSERT INTO `sys_role_menu` VALUES (7236, 4, 262); +INSERT INTO `sys_role_menu` VALUES (7237, 4, 138); +INSERT INTO `sys_role_menu` VALUES (7238, 4, 139); +INSERT INTO `sys_role_menu` VALUES (7239, 4, 206); +INSERT INTO `sys_role_menu` VALUES (7240, 4, 174); +INSERT INTO `sys_role_menu` VALUES (7241, 4, 175); +INSERT INTO `sys_role_menu` VALUES (7242, 4, 207); +INSERT INTO `sys_role_menu` VALUES (7243, 4, 178); +INSERT INTO `sys_role_menu` VALUES (7244, 4, 179); +INSERT INTO `sys_role_menu` VALUES (7245, 4, 180); +INSERT INTO `sys_role_menu` VALUES (7246, 4, 58); +INSERT INTO `sys_role_menu` VALUES (7247, 4, 132); +INSERT INTO `sys_role_menu` VALUES (7248, 4, 15); +INSERT INTO `sys_role_menu` VALUES (7249, 4, 19); +INSERT INTO `sys_role_menu` VALUES (7250, 4, 23); +INSERT INTO `sys_role_menu` VALUES (7251, 4, 95); +INSERT INTO `sys_role_menu` VALUES (7252, 4, -666666); +INSERT INTO `sys_role_menu` VALUES (7253, 4, 32); +INSERT INTO `sys_role_menu` VALUES (7254, 4, 50); +INSERT INTO `sys_role_menu` VALUES (7255, 4, 72); +INSERT INTO `sys_role_menu` VALUES (7256, 4, 232); +INSERT INTO `sys_role_menu` VALUES (7257, 4, 130); +INSERT INTO `sys_role_menu` VALUES (7258, 4, 118); +INSERT INTO `sys_role_menu` VALUES (7259, 4, 119); +INSERT INTO `sys_role_menu` VALUES (7260, 4, 177); +INSERT INTO `sys_role_menu` VALUES (7261, 4, 57); +INSERT INTO `sys_role_menu` VALUES (7262, 4, 128); +INSERT INTO `sys_role_menu` VALUES (7263, 4, 131); +INSERT INTO `sys_role_menu` VALUES (7264, 4, 2); +INSERT INTO `sys_role_menu` VALUES (7265, 4, 3); +INSERT INTO `sys_role_menu` VALUES (7266, 4, 4); +INSERT INTO `sys_role_menu` VALUES (7267, 4, 94); +INSERT INTO `sys_role_menu` VALUES (7471, 1, 33); +INSERT INTO `sys_role_menu` VALUES (7472, 1, 32); +INSERT INTO `sys_role_menu` VALUES (7473, 1, 60); +INSERT INTO `sys_role_menu` VALUES (7474, 1, 61); +INSERT INTO `sys_role_menu` VALUES (7475, 1, 90); +INSERT INTO `sys_role_menu` VALUES (7476, 1, 91); +INSERT INTO `sys_role_menu` VALUES (7477, 1, 176); +INSERT INTO `sys_role_menu` VALUES (7478, 1, 196); +INSERT INTO `sys_role_menu` VALUES (7479, 1, 197); +INSERT INTO `sys_role_menu` VALUES (7480, 1, 198); +INSERT INTO `sys_role_menu` VALUES (7481, 1, 199); +INSERT INTO `sys_role_menu` VALUES (7482, 1, 200); +INSERT INTO `sys_role_menu` VALUES (7483, 1, 242); +INSERT INTO `sys_role_menu` VALUES (7484, 1, 243); +INSERT INTO `sys_role_menu` VALUES (7485, 1, 244); +INSERT INTO `sys_role_menu` VALUES (7486, 1, 34); +INSERT INTO `sys_role_menu` VALUES (7487, 1, 35); +INSERT INTO `sys_role_menu` VALUES (7488, 1, 36); +INSERT INTO `sys_role_menu` VALUES (7489, 1, 37); +INSERT INTO `sys_role_menu` VALUES (7490, 1, 39); +INSERT INTO `sys_role_menu` VALUES (7491, 1, 40); +INSERT INTO `sys_role_menu` VALUES (7492, 1, 201); +INSERT INTO `sys_role_menu` VALUES (7493, 1, 41); +INSERT INTO `sys_role_menu` VALUES (7494, 1, 42); +INSERT INTO `sys_role_menu` VALUES (7495, 1, 43); +INSERT INTO `sys_role_menu` VALUES (7496, 1, 69); +INSERT INTO `sys_role_menu` VALUES (7497, 1, 70); +INSERT INTO `sys_role_menu` VALUES (7498, 1, 71); +INSERT INTO `sys_role_menu` VALUES (7499, 1, 50); +INSERT INTO `sys_role_menu` VALUES (7500, 1, 51); +INSERT INTO `sys_role_menu` VALUES (7501, 1, 52); +INSERT INTO `sys_role_menu` VALUES (7502, 1, 53); +INSERT INTO `sys_role_menu` VALUES (7503, 1, 54); +INSERT INTO `sys_role_menu` VALUES (7504, 1, 62); +INSERT INTO `sys_role_menu` VALUES (7505, 1, 263); +INSERT INTO `sys_role_menu` VALUES (7506, 1, 273); +INSERT INTO `sys_role_menu` VALUES (7507, 1, 63); +INSERT INTO `sys_role_menu` VALUES (7508, 1, 64); +INSERT INTO `sys_role_menu` VALUES (7509, 1, 202); +INSERT INTO `sys_role_menu` VALUES (7510, 1, 203); +INSERT INTO `sys_role_menu` VALUES (7511, 1, 72); +INSERT INTO `sys_role_menu` VALUES (7512, 1, 73); +INSERT INTO `sys_role_menu` VALUES (7513, 1, 74); +INSERT INTO `sys_role_menu` VALUES (7514, 1, 75); +INSERT INTO `sys_role_menu` VALUES (7515, 1, 76); +INSERT INTO `sys_role_menu` VALUES (7516, 1, 208); +INSERT INTO `sys_role_menu` VALUES (7517, 1, 209); +INSERT INTO `sys_role_menu` VALUES (7518, 1, 210); +INSERT INTO `sys_role_menu` VALUES (7519, 1, 211); +INSERT INTO `sys_role_menu` VALUES (7520, 1, 213); +INSERT INTO `sys_role_menu` VALUES (7521, 1, 214); +INSERT INTO `sys_role_menu` VALUES (7522, 1, 215); +INSERT INTO `sys_role_menu` VALUES (7523, 1, 216); +INSERT INTO `sys_role_menu` VALUES (7524, 1, 217); +INSERT INTO `sys_role_menu` VALUES (7525, 1, 218); +INSERT INTO `sys_role_menu` VALUES (7526, 1, 219); +INSERT INTO `sys_role_menu` VALUES (7527, 1, 220); +INSERT INTO `sys_role_menu` VALUES (7528, 1, 221); +INSERT INTO `sys_role_menu` VALUES (7529, 1, 222); +INSERT INTO `sys_role_menu` VALUES (7530, 1, 223); +INSERT INTO `sys_role_menu` VALUES (7531, 1, 224); +INSERT INTO `sys_role_menu` VALUES (7532, 1, 225); +INSERT INTO `sys_role_menu` VALUES (7533, 1, 226); +INSERT INTO `sys_role_menu` VALUES (7534, 1, 250); +INSERT INTO `sys_role_menu` VALUES (7535, 1, 227); +INSERT INTO `sys_role_menu` VALUES (7536, 1, 228); +INSERT INTO `sys_role_menu` VALUES (7537, 1, 229); +INSERT INTO `sys_role_menu` VALUES (7538, 1, 230); +INSERT INTO `sys_role_menu` VALUES (7539, 1, 231); +INSERT INTO `sys_role_menu` VALUES (7540, 1, 237); +INSERT INTO `sys_role_menu` VALUES (7541, 1, 238); +INSERT INTO `sys_role_menu` VALUES (7542, 1, 239); +INSERT INTO `sys_role_menu` VALUES (7543, 1, 240); +INSERT INTO `sys_role_menu` VALUES (7544, 1, 241); +INSERT INTO `sys_role_menu` VALUES (7545, 1, 249); +INSERT INTO `sys_role_menu` VALUES (7546, 1, 245); +INSERT INTO `sys_role_menu` VALUES (7547, 1, 246); +INSERT INTO `sys_role_menu` VALUES (7548, 1, 247); +INSERT INTO `sys_role_menu` VALUES (7549, 1, 248); +INSERT INTO `sys_role_menu` VALUES (7550, 1, 232); +INSERT INTO `sys_role_menu` VALUES (7551, 1, 233); +INSERT INTO `sys_role_menu` VALUES (7552, 1, 234); +INSERT INTO `sys_role_menu` VALUES (7553, 1, 235); +INSERT INTO `sys_role_menu` VALUES (7554, 1, 236); +INSERT INTO `sys_role_menu` VALUES (7555, 1, 130); +INSERT INTO `sys_role_menu` VALUES (7556, 1, 118); +INSERT INTO `sys_role_menu` VALUES (7557, 1, 120); +INSERT INTO `sys_role_menu` VALUES (7558, 1, 121); +INSERT INTO `sys_role_menu` VALUES (7559, 1, 122); +INSERT INTO `sys_role_menu` VALUES (7560, 1, 123); +INSERT INTO `sys_role_menu` VALUES (7561, 1, 119); +INSERT INTO `sys_role_menu` VALUES (7562, 1, 124); +INSERT INTO `sys_role_menu` VALUES (7563, 1, 125); +INSERT INTO `sys_role_menu` VALUES (7564, 1, 126); +INSERT INTO `sys_role_menu` VALUES (7565, 1, 127); +INSERT INTO `sys_role_menu` VALUES (7566, 1, 140); +INSERT INTO `sys_role_menu` VALUES (7567, 1, 141); +INSERT INTO `sys_role_menu` VALUES (7568, 1, 142); +INSERT INTO `sys_role_menu` VALUES (7569, 1, 143); +INSERT INTO `sys_role_menu` VALUES (7570, 1, 144); +INSERT INTO `sys_role_menu` VALUES (7571, 1, 145); +INSERT INTO `sys_role_menu` VALUES (7572, 1, 146); +INSERT INTO `sys_role_menu` VALUES (7573, 1, 152); +INSERT INTO `sys_role_menu` VALUES (7574, 1, 271); +INSERT INTO `sys_role_menu` VALUES (7575, 1, 272); +INSERT INTO `sys_role_menu` VALUES (7576, 1, 153); +INSERT INTO `sys_role_menu` VALUES (7577, 1, 154); +INSERT INTO `sys_role_menu` VALUES (7578, 1, 155); +INSERT INTO `sys_role_menu` VALUES (7579, 1, 156); +INSERT INTO `sys_role_menu` VALUES (7580, 1, 157); +INSERT INTO `sys_role_menu` VALUES (7581, 1, 158); +INSERT INTO `sys_role_menu` VALUES (7582, 1, 257); +INSERT INTO `sys_role_menu` VALUES (7583, 1, 258); +INSERT INTO `sys_role_menu` VALUES (7584, 1, 159); +INSERT INTO `sys_role_menu` VALUES (7585, 1, 107); +INSERT INTO `sys_role_menu` VALUES (7586, 1, 108); +INSERT INTO `sys_role_menu` VALUES (7587, 1, 109); +INSERT INTO `sys_role_menu` VALUES (7588, 1, 110); +INSERT INTO `sys_role_menu` VALUES (7589, 1, 160); +INSERT INTO `sys_role_menu` VALUES (7590, 1, 161); +INSERT INTO `sys_role_menu` VALUES (7591, 1, 162); +INSERT INTO `sys_role_menu` VALUES (7592, 1, 163); +INSERT INTO `sys_role_menu` VALUES (7593, 1, 251); +INSERT INTO `sys_role_menu` VALUES (7594, 1, 268); +INSERT INTO `sys_role_menu` VALUES (7595, 1, 252); +INSERT INTO `sys_role_menu` VALUES (7596, 1, 253); +INSERT INTO `sys_role_menu` VALUES (7597, 1, 254); +INSERT INTO `sys_role_menu` VALUES (7598, 1, 264); +INSERT INTO `sys_role_menu` VALUES (7599, 1, 265); +INSERT INTO `sys_role_menu` VALUES (7600, 1, 266); +INSERT INTO `sys_role_menu` VALUES (7601, 1, 267); +INSERT INTO `sys_role_menu` VALUES (7602, 1, 77); +INSERT INTO `sys_role_menu` VALUES (7603, 1, 78); +INSERT INTO `sys_role_menu` VALUES (7604, 1, 92); +INSERT INTO `sys_role_menu` VALUES (7605, 1, 93); +INSERT INTO `sys_role_menu` VALUES (7606, 1, 269); +INSERT INTO `sys_role_menu` VALUES (7607, 1, 270); +INSERT INTO `sys_role_menu` VALUES (7608, 1, 164); +INSERT INTO `sys_role_menu` VALUES (7609, 1, 165); +INSERT INTO `sys_role_menu` VALUES (7610, 1, 166); +INSERT INTO `sys_role_menu` VALUES (7611, 1, 167); +INSERT INTO `sys_role_menu` VALUES (7612, 1, 168); +INSERT INTO `sys_role_menu` VALUES (7613, 1, 169); +INSERT INTO `sys_role_menu` VALUES (7614, 1, 170); +INSERT INTO `sys_role_menu` VALUES (7615, 1, 171); +INSERT INTO `sys_role_menu` VALUES (7616, 1, 172); +INSERT INTO `sys_role_menu` VALUES (7617, 1, 173); +INSERT INTO `sys_role_menu` VALUES (7618, 1, 136); +INSERT INTO `sys_role_menu` VALUES (7619, 1, 137); +INSERT INTO `sys_role_menu` VALUES (7620, 1, 182); +INSERT INTO `sys_role_menu` VALUES (7621, 1, 183); +INSERT INTO `sys_role_menu` VALUES (7622, 1, 204); +INSERT INTO `sys_role_menu` VALUES (7623, 1, 205); +INSERT INTO `sys_role_menu` VALUES (7624, 1, 184); +INSERT INTO `sys_role_menu` VALUES (7625, 1, 185); +INSERT INTO `sys_role_menu` VALUES (7626, 1, 186); +INSERT INTO `sys_role_menu` VALUES (7627, 1, 188); +INSERT INTO `sys_role_menu` VALUES (7628, 1, 189); +INSERT INTO `sys_role_menu` VALUES (7629, 1, 195); +INSERT INTO `sys_role_menu` VALUES (7630, 1, 259); +INSERT INTO `sys_role_menu` VALUES (7631, 1, 260); +INSERT INTO `sys_role_menu` VALUES (7632, 1, 261); +INSERT INTO `sys_role_menu` VALUES (7633, 1, 262); +INSERT INTO `sys_role_menu` VALUES (7634, 1, 138); +INSERT INTO `sys_role_menu` VALUES (7635, 1, 139); +INSERT INTO `sys_role_menu` VALUES (7636, 1, 206); +INSERT INTO `sys_role_menu` VALUES (7637, 1, 174); +INSERT INTO `sys_role_menu` VALUES (7638, 1, 175); +INSERT INTO `sys_role_menu` VALUES (7639, 1, 207); +INSERT INTO `sys_role_menu` VALUES (7640, 1, 177); +INSERT INTO `sys_role_menu` VALUES (7641, 1, 178); +INSERT INTO `sys_role_menu` VALUES (7642, 1, 179); +INSERT INTO `sys_role_menu` VALUES (7643, 1, 180); +INSERT INTO `sys_role_menu` VALUES (7644, 1, 181); +INSERT INTO `sys_role_menu` VALUES (7645, 1, 57); +INSERT INTO `sys_role_menu` VALUES (7646, 1, 58); +INSERT INTO `sys_role_menu` VALUES (7647, 1, 59); +INSERT INTO `sys_role_menu` VALUES (7648, 1, 128); +INSERT INTO `sys_role_menu` VALUES (7649, 1, 131); +INSERT INTO `sys_role_menu` VALUES (7650, 1, 132); +INSERT INTO `sys_role_menu` VALUES (7651, 1, 133); +INSERT INTO `sys_role_menu` VALUES (7652, 1, 134); +INSERT INTO `sys_role_menu` VALUES (7653, 1, 135); +INSERT INTO `sys_role_menu` VALUES (7654, 1, 2); +INSERT INTO `sys_role_menu` VALUES (7655, 1, 15); +INSERT INTO `sys_role_menu` VALUES (7656, 1, 16); +INSERT INTO `sys_role_menu` VALUES (7657, 1, 17); +INSERT INTO `sys_role_menu` VALUES (7658, 1, 18); +INSERT INTO `sys_role_menu` VALUES (7659, 1, 3); +INSERT INTO `sys_role_menu` VALUES (7660, 1, 19); +INSERT INTO `sys_role_menu` VALUES (7661, 1, 20); +INSERT INTO `sys_role_menu` VALUES (7662, 1, 21); +INSERT INTO `sys_role_menu` VALUES (7663, 1, 22); +INSERT INTO `sys_role_menu` VALUES (7664, 1, 4); +INSERT INTO `sys_role_menu` VALUES (7665, 1, 23); +INSERT INTO `sys_role_menu` VALUES (7666, 1, 24); +INSERT INTO `sys_role_menu` VALUES (7667, 1, 25); +INSERT INTO `sys_role_menu` VALUES (7668, 1, 26); +INSERT INTO `sys_role_menu` VALUES (7669, 1, 94); +INSERT INTO `sys_role_menu` VALUES (7670, 1, 95); +INSERT INTO `sys_role_menu` VALUES (7671, 1, 96); +INSERT INTO `sys_role_menu` VALUES (7672, 1, 97); +INSERT INTO `sys_role_menu` VALUES (7673, 1, 98); +INSERT INTO `sys_role_menu` VALUES (7674, 1, -666666); + +-- ---------------------------- +-- Table structure for sys_user +-- ---------------------------- +DROP TABLE IF EXISTS `sys_user`; +CREATE TABLE `sys_user` ( + `user_id` bigint(20) NOT NULL AUTO_INCREMENT, + `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户名', + `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '密码', + `salt` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '盐', + `email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邮箱', + `mobile` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手机号', + `status` tinyint(4) NULL DEFAULT NULL COMMENT '状态 0:禁用 1:正常', + `create_user_id` bigint(20) NULL DEFAULT NULL COMMENT '创建者ID', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`user_id`) USING BTREE, + UNIQUE INDEX `username`(`username`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 17 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统用户' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_user +-- ---------------------------- +INSERT INTO `sys_user` VALUES (1, 'admin', '1cc7f0f4e29524bfbfb2a299dde135e6ebad047b2c0ef70eceb7fbc198293927', 'YKJpTRPDurwTYVsIhd0P', '24564651@qq.com', '13612345678', 1, 1, '2016-11-11 11:11:11'); + +-- ---------------------------- +-- Table structure for sys_user_role +-- ---------------------------- +DROP TABLE IF EXISTS `sys_user_role`; +CREATE TABLE `sys_user_role` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户ID', + `role_id` bigint(20) NULL DEFAULT NULL COMMENT '角色ID', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 38 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户与角色对应关系' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_user_role +-- ---------------------------- +INSERT INTO `sys_user_role` VALUES (30, 1, 1); + +-- ---------------------------- +-- Table structure for sys_user_token +-- ---------------------------- +DROP TABLE IF EXISTS `sys_user_token`; +CREATE TABLE `sys_user_token` ( + `user_id` bigint(20) NOT NULL, + `token` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'token', + `expire_time` datetime(0) NULL DEFAULT NULL COMMENT '过期时间', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`user_id`) USING BTREE, + UNIQUE INDEX `token`(`token`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统用户Token' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_user_token +-- ---------------------------- + +-- ---------------------------- +-- Table structure for taking_commnt +-- ---------------------------- +DROP TABLE IF EXISTS `taking_commnt`; +CREATE TABLE `taking_commnt` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '接单评论id', + `order_id` bigint(20) NULL DEFAULT NULL COMMENT '接单id', + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id', + `content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '评论内容', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + `mail` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系方式', + `score` int(11) NULL DEFAULT NULL COMMENT '评分', + `artificer_id` int(11) NULL DEFAULT NULL COMMENT '评论id', + `massage_type_id` int(11) NULL DEFAULT NULL COMMENT '项目id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 109 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of taking_commnt +-- ---------------------------- + +-- ---------------------------- +-- Table structure for tb_user +-- ---------------------------- +DROP TABLE IF EXISTS `tb_user`; +CREATE TABLE `tb_user` ( + `user_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '用户id', + `type` int(11) NULL DEFAULT NULL COMMENT '用户类型 1普通用户 2技师', + `user_name` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户名', + `phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手机号', + `avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '头像', + `sex` int(11) NULL DEFAULT NULL COMMENT '性别 1男 2女', + `age` int(4) NULL DEFAULT NULL COMMENT '年龄', + `open_id` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '微信小程序openId', + `wx_open_id` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '微信App openId', + `password` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '密码', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + `update_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新时间', + `apple_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '苹果id', + `sys_phone` int(11) NULL DEFAULT NULL COMMENT '手机类型 1安卓 2ios', + `status` int(11) NULL DEFAULT NULL COMMENT '状态 1正常 2禁用', + `platform` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '来源 APP 小程序 公众号', + `jifen` int(11) NULL DEFAULT NULL COMMENT '积分', + `invitation_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邀请码', + `inviter_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邀请人邀请码', + `clientid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'app消息推送', + `zhi_fu_bao_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付宝名称', + `zhi_fu_bao` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付宝账号', + `is_authentication` int(11) NULL DEFAULT NULL COMMENT '实名认证0未认证 1个人认证审核中 2个人认证成功 3个人认证失败', + `is_cash_deposit` int(11) NULL DEFAULT NULL COMMENT '保证金状态 1待缴纳 2已缴纳 3申请退款中', + `cash_deposit_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '申请时间', + `artificer_open_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '技师小程序openId', + `is_coupon` int(11) NULL DEFAULT NULL COMMENT '是否领取新人优惠券', + `risk` int(11) NULL DEFAULT NULL COMMENT '是否是风险用户 1是 2不是', + `is_agency` int(11) NULL DEFAULT NULL COMMENT '是否是代理1是', + `user_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '代理用户分佣比例', + `shop_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '代理技师分佣比例', + `consortia_id` int(11) NULL DEFAULT NULL COMMENT '商家id', + `is_shop` int(11) NULL DEFAULT NULL COMMENT '是否是商家 1是', + `bank_card` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '银行卡号', + `bank_card_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '银行名称', + `bank_card_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '银行卡用户姓名', + `bank_card_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '银行开户行地址', + PRIMARY KEY (`user_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 313 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of tb_user +-- ---------------------------- +INSERT INTO `tb_user` VALUES (1, NULL, '官方', '13000000000', 'https://jiaoyu.xianmxkj.com/file/uploadPath/2021/08/30/18d20e9a11701fbe6dbb31454ec37eb8.jpg', 0, NULL, NULL, NULL, '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92', '2021-08-24 10:14:40', '2023-01-10 17:38:52', NULL, NULL, 2, 'H5', NULL, '666666', '666666', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 2, 0.10, 0.20, NULL, NULL, NULL, NULL, NULL, NULL); + +-- ---------------------------- +-- Table structure for trip +-- ---------------------------- +DROP TABLE IF EXISTS `trip`; +CREATE TABLE `trip` ( + `trip_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '出行方式', + `taxi_starting_fare` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '出租起步价', + `taxi_starting_km` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '出租起步公里', + `taxi_km_money` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '出租每公里价格', + `bus_starting_fare` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '公交起步价', + `bus_starting_km` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '公交起步公里', + `bus_km_money` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '公交每公里价格', + `city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '城市', + `create_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`trip_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of trip +-- ---------------------------- +INSERT INTO `trip` VALUES (1, '8.5', '3', '1.5', '2', '3', '0.5', '西安市', '2020-12-12 12:12:12'); +INSERT INTO `trip` VALUES (3, '10', '5', '3', '2', '6', '0.5', '北京', '2023-01-14 15:00:17'); + +-- ---------------------------- +-- Table structure for user_browse +-- ---------------------------- +DROP TABLE IF EXISTS `user_browse`; +CREATE TABLE `user_browse` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id', + `by_browse_id` bigint(20) NULL DEFAULT NULL COMMENT '浏览用户id', + `update_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新时间', + `taking_id` bigint(20) NULL DEFAULT NULL COMMENT '接单id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 838 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user_browse +-- ---------------------------- + +-- ---------------------------- +-- Table structure for user_follow +-- ---------------------------- +DROP TABLE IF EXISTS `user_follow`; +CREATE TABLE `user_follow` ( + `follow_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id', + `follow_user_id` bigint(20) NULL DEFAULT NULL COMMENT '关注用户id', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`follow_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 167 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user_follow +-- ---------------------------- + +-- ---------------------------- +-- Table structure for user_money +-- ---------------------------- +DROP TABLE IF EXISTS `user_money`; +CREATE TABLE `user_money` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '钱包id', + `money` decimal(10, 2) NULL DEFAULT NULL COMMENT '钱包金额', + `user_id` bigint(11) NULL DEFAULT NULL COMMENT '用户id', + `cash_deposit` decimal(10, 2) NULL DEFAULT NULL COMMENT '技师保证金', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 336 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user_money +-- ---------------------------- + +-- ---------------------------- +-- Table structure for user_money_artificer +-- ---------------------------- +DROP TABLE IF EXISTS `user_money_artificer`; +CREATE TABLE `user_money_artificer` ( + `user_money_artificer_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户充值师傅钱包', + `user_id` int(11) NULL DEFAULT NULL COMMENT '用户id', + `artificer_id` int(11) NULL DEFAULT NULL COMMENT '师傅id', + `money` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '金额', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '时间', + PRIMARY KEY (`user_money_artificer_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 17 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user_money_artificer +-- ---------------------------- + +-- ---------------------------- +-- Table structure for user_money_details +-- ---------------------------- +DROP TABLE IF EXISTS `user_money_details`; +CREATE TABLE `user_money_details` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '钱包详情id', + `user_id` int(11) NULL DEFAULT NULL COMMENT '用户id', + `by_user_id` int(11) NULL DEFAULT NULL COMMENT '邀请用户id', + `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '标题', + `classify` int(11) NULL DEFAULT NULL COMMENT '1注册 2购买 3提现', + `type` int(11) NULL DEFAULT NULL COMMENT '类型(1充值 2.提现)', + `state` int(11) NULL DEFAULT 1 COMMENT '状态 1待支付 2已到账 3取消', + `money` decimal(10, 2) NULL DEFAULT NULL COMMENT '金额', + `content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '内容', + `create_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建时间', + `artificer_id` int(11) NULL DEFAULT NULL COMMENT '技师id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1595 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user_money_details +-- ---------------------------- + +-- ---------------------------- +-- Table structure for user_vip +-- ---------------------------- +DROP TABLE IF EXISTS `user_vip`; +CREATE TABLE `user_vip` ( + `vip_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '会员id', + `vip_name_type` int(2) NULL DEFAULT NULL COMMENT '会员类型0月1季2年', + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id', + `create_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '购买时间', + `end_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '到期时间', + `is_vip` int(255) NULL DEFAULT NULL COMMENT '1是会员2不是', + PRIMARY KEY (`vip_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 45 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user_vip +-- ---------------------------- + +-- ---------------------------- +-- Table structure for user_visitor +-- ---------------------------- +DROP TABLE IF EXISTS `user_visitor`; +CREATE TABLE `user_visitor` ( + `id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT '访客id', + `user_id` bigint(32) NULL DEFAULT NULL COMMENT '用户id', + `by_user_id` bigint(32) NULL DEFAULT NULL COMMENT '访问用户id', + `update_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 310 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user_visitor +-- ---------------------------- + +-- ---------------------------- +-- Table structure for vip_details +-- ---------------------------- +DROP TABLE IF EXISTS `vip_details`; +CREATE TABLE `vip_details` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `vip_name_type` int(2) NULL DEFAULT NULL COMMENT '会员类型0月1季2年', + `money` decimal(10, 0) NULL DEFAULT NULL COMMENT '会员价格', + `vip_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '会员名称', + `rate` decimal(10, 2) NULL DEFAULT NULL, + `award` decimal(10, 2) NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of vip_details +-- ---------------------------- +INSERT INTO `vip_details` VALUES (2, 1, 2, '季会员', NULL, 20.00); +INSERT INTO `vip_details` VALUES (3, 2, 3, '年会员', NULL, 50.00); +INSERT INTO `vip_details` VALUES (8, 0, 1, '月会员', NULL, 10.00); + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/db/sql脚本 b/db/sql脚本 new file mode 100644 index 0000000..658cd37 --- /dev/null +++ b/db/sql脚本 @@ -0,0 +1,25 @@ +--common_info表增加多少分钟等1积分 数据(type=100000) +INSERT INTO `anmo`.`common_info` (`id`, `create_at`, `max`, `min`, `type`, `value`, `condition_from`) VALUES (430, '2024-02-01 11:19:11', NULL, '多少分钟等1积分', 100000, '10', 'xitong'); + + +--新增 积分等级字典表 artificer_partitioning_details.sql sql脚本在db文件夹下 + +--新增 积分储值表 +CREATE TABLE `anmo`.`user_recharge` ( + `id` bigint(11) NOT NULL AUTO_INCREMENT, + `user_recharge` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '用户充值积分', + `orders_id` int(11) NULL DEFAULT NULL COMMENT '订单id', + `user_id` int(11) NULL DEFAULT NULL COMMENT '用户id', + `type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '积分类型(1在线积分2储值积分)', + `artificer_id` int(11) NULL DEFAULT NULL COMMENT '技师id', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`id`) +); +--artificer 技师表增加grade +ALTER TABLE `anmo`.`artificer` +ADD COLUMN `grade` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '当前等级' AFTER `up_time`; +--artificer 技师表增加up_time +ALTER TABLE `anmo`.`artificer` +ADD COLUMN `up_time` datetime(0) NULL DEFAULT NULL COMMENT '上线时间' AFTER `grade`; + +INSERT INTO `anmo`.`common_info` (`id`, `create_at`, `max`, `min`, `type`, `value`, `condition_from`) VALUES (436, '2024-02-18 15:52:12', NULL, '中医忙时时间切换(只限输入 30半个小时 60一个小时)', 436, '60', 'fuwufei'); diff --git a/db/三期/artificer_partitioning_details.sql b/db/三期/artificer_partitioning_details.sql new file mode 100644 index 0000000..88382cc --- /dev/null +++ b/db/三期/artificer_partitioning_details.sql @@ -0,0 +1,55 @@ +/* + Navicat Premium Data Transfer + + Source Server : 192.168.1.102 + Source Server Type : MySQL + Source Server Version : 50722 (5.7.22-log) + Source Host : 192.168.1.102:3306 + Source Schema : anmoceshi + + Target Server Type : MySQL + Target Server Version : 50722 (5.7.22-log) + File Encoding : 65001 + + Date: 21/03/2024 15:08:11 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for artificer_partitioning_details +-- ---------------------------- +DROP TABLE IF EXISTS `artificer_partitioning_details`; +CREATE TABLE `artificer_partitioning_details` ( + `id` bigint(20) NOT NULL, + `grade` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '等级', + `outstanding_achievement` decimal(20, 2) NULL DEFAULT NULL COMMENT '最低业绩', + `clock_rate` decimal(20, 2) NULL DEFAULT NULL COMMENT '加钟率', + `deposit_rate` decimal(20, 2) NULL DEFAULT NULL COMMENT '充值率', + `duration_online` int(11) NULL DEFAULT NULL COMMENT '在线时长', + `integral` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '积分', + `proportional_sharing` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '分成比例', + `classify_id` int(11) NULL DEFAULT NULL COMMENT '项目类型id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '技师等级表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of artificer_partitioning_details +-- ---------------------------- +INSERT INTO `artificer_partitioning_details` VALUES (1, '新', 0.00, 0.00, 0.00, 0, '0', '0.65', 91); +INSERT INTO `artificer_partitioning_details` VALUES (3, 'A0', 0.00, 0.00, 0.00, 50, '0', '0.6', 91); +INSERT INTO `artificer_partitioning_details` VALUES (5, 'A1', 4000.00, 0.06, 0.10, 80, '0', '0.7', 91); +INSERT INTO `artificer_partitioning_details` VALUES (7, 'A2', 6000.00, 0.15, 0.15, 0, '1000', '0.75', 91); +INSERT INTO `artificer_partitioning_details` VALUES (9, 'A3', 8000.00, 0.20, 0.20, 0, '1200', '0.8', 91); +INSERT INTO `artificer_partitioning_details` VALUES (11, 'A4', 10000.00, 0.30, 0.30, 0, '2500', '0.9', 91); +INSERT INTO `artificer_partitioning_details` VALUES (13, 'A5', 12000.00, 0.35, 0.35, 0, '6000', '0.95', 91); +INSERT INTO `artificer_partitioning_details` VALUES (27, '新', 0.00, 0.00, 0.00, 0, '0', '0.65', 95); +INSERT INTO `artificer_partitioning_details` VALUES (29, 'A0', 0.00, 0.00, 0.00, 50, '0', '0.6', 95); +INSERT INTO `artificer_partitioning_details` VALUES (31, 'A1', 4000.00, 0.10, 0.20, 80, '0', '0.7', 95); +INSERT INTO `artificer_partitioning_details` VALUES (33, 'A2', 6000.00, 0.15, 0.15, 0, '1000', '0.75', 95); +INSERT INTO `artificer_partitioning_details` VALUES (35, 'A3', 8000.00, 0.20, 0.20, 0, '1200', '0.8', 95); +INSERT INTO `artificer_partitioning_details` VALUES (37, 'A4', 10000.00, 0.30, 0.30, 0, '2500', '0.9', 95); +INSERT INTO `artificer_partitioning_details` VALUES (39, 'A5', 12000.00, 0.35, 0.35, 0, '6000', '0.95', 95); + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/gxdm.bat b/gxdm.bat new file mode 100644 index 0000000..f8b23a9 --- /dev/null +++ b/gxdm.bat @@ -0,0 +1,6 @@ +@echo off +echo º̨... +git.exe pull -v --progress "origin" +echo ³ɹ +PAUSE +exit \ No newline at end of file diff --git a/hs_err_pid36964.log b/hs_err_pid36964.log new file mode 100644 index 0000000..7066a41 --- /dev/null +++ b/hs_err_pid36964.log @@ -0,0 +1,245 @@ +# +# There is insufficient memory for the Java Runtime Environment to continue. +# Native memory allocation (mmap) failed to map 268435456 bytes for G1 virtual space +# Possible reasons: +# The system is out of physical RAM or swap space +# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap +# Possible solutions: +# Reduce memory load on the system +# Increase physical memory or swap space +# Check if swap backing store is full +# Decrease Java heap size (-Xmx/-Xms) +# Decrease number of Java threads +# Decrease Java thread stack sizes (-Xss) +# Set larger code cache with -XX:ReservedCodeCacheSize= +# JVM is running with Zero Based Compressed Oops mode in which the Java heap is +# placed in the first 32GB address space. The Java Heap base address is the +# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress +# to set the Java Heap base and to place the Java Heap above 32GB virtual address. +# This output file may be truncated or incomplete. +# +# Out of Memory Error (os_windows.cpp:3825), pid=36964, tid=32736 +# +# JRE version: (17.0.9+7) (build ) +# Java VM: OpenJDK 64-Bit Server VM (17.0.9+7-b1087.9, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64) +# No core dump will be written. Minidumps are not enabled by default on client versions of Windows +# + +--------------- S U M M A R Y ------------ + +Command Line: git4idea.http.GitAskPassApp Username for 'https://gitee.com': + +Host: Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz, 6 cores, 15G, Windows 10 , 64 bit Build 19041 (10.0.19041.3636) +Time: Tue Apr 2 13:41:41 2024 Windows 10 , 64 bit Build 19041 (10.0.19041.3636) elapsed time: 0.039108 seconds (0d 0h 0m 0s) + +--------------- T H R E A D --------------- + +Current thread (0x000002889d97c530): JavaThread "Unknown thread" [_thread_in_vm, id=32736, stack(0x0000009f06a00000,0x0000009f06b00000)] + +Stack: [0x0000009f06a00000,0x0000009f06b00000] +Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) +V [jvm.dll+0x688349] +V [jvm.dll+0x841bfa] +V [jvm.dll+0x84383e] +V [jvm.dll+0x843ea3] +V [jvm.dll+0x24bdef] +V [jvm.dll+0x6850f9] +V [jvm.dll+0x67988a] +V [jvm.dll+0x30cbfb] +V [jvm.dll+0x3140a6] +V [jvm.dll+0x363ede] +V [jvm.dll+0x36410f] +V [jvm.dll+0x2e29c8] +V [jvm.dll+0x2e3934] +V [jvm.dll+0x812771] +V [jvm.dll+0x371d41] +V [jvm.dll+0x7f12bc] +V [jvm.dll+0x3f59cf] +V [jvm.dll+0x3f7601] +C [jli.dll+0x528f] +C [ucrtbase.dll+0x21bb2] +C [KERNEL32.DLL+0x17344] +C [ntdll.dll+0x526b1] + + +--------------- P R O C E S S --------------- + +Threads class SMR info: +_java_thread_list=0x00007ffc3951df18, length=0, elements={ +} + +Java Threads: ( => current thread ) + +Other Threads: + 0x000002889d9e76f0 GCTaskThread "GC Thread#0" [stack: 0x0000009f06b00000,0x0000009f06c00000] [id=36344] + 0x000002889d9f85c0 ConcurrentGCThread "G1 Main Marker" [stack: 0x0000009f06c00000,0x0000009f06d00000] [id=24640] + 0x000002889d9f8fe0 ConcurrentGCThread "G1 Conc#0" [stack: 0x0000009f06d00000,0x0000009f06e00000] [id=23712] + +[error occurred during error reporting (printing all threads), id 0xc0000005, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffc38cd3597] + +VM state: not at safepoint (not fully initialized) + +VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event]) +[0x000002889d9789f0] Heap_lock - owner thread: 0x000002889d97c530 + +Heap address: 0x0000000700800000, size: 4088 MB, Compressed Oops mode: Zero based, Oop shift amount: 3 + +CDS archive(s) mapped at: [0x0000000000000000-0x0000000000000000-0x0000000000000000), size 0, SharedBaseAddress: 0x0000000800000000, ArchiveRelocationMode: 1. +Narrow klass base: 0x0000000000000000, Narrow klass shift: 0, Narrow klass range: 0x0 + +GC Precious Log: + + +Heap: + garbage-first heap total 0K, used 0K [0x0000000700800000, 0x0000000800000000) + region size 2048K, 0 young (0K), 0 survivors (0K) + Metaspace used 0K, committed 0K, reserved 0K + class space used 0K, committed 0K, reserved 0K + +Heap Regions: E=young(eden), S=young(survivor), O=old, HS=humongous(starts), HC=humongous(continues), CS=collection set, F=free, OA=open archive, CA=closed archive, TAMS=top-at-mark-start (previous, next) + +Card table byte_map: [0x00000288b0a10000,0x00000288b1210000] _byte_map_base: 0x00000288ad20c000 + +Marking Bits (Prev, Next): (CMBitMap*) 0x000002889d9e7d10, (CMBitMap*) 0x000002889d9e7d50 + Prev Bits: [0x00000288b1a10000, 0x00000288b59f0000) + Next Bits: [0x00000288b59f0000, 0x00000288b99d0000) + +GC Heap History (0 events): +No events + +Dll operation events (1 events): +Event: 0.024 Loaded shared library C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\java.dll + +Deoptimization events (0 events): +No events + +Classes unloaded (0 events): +No events + +Classes redefined (0 events): +No events + +Internal exceptions (0 events): +No events + +VM Operations (0 events): +No events + +Events (0 events): +No events + + +Dynamic libraries: +0x00007ff726640000 - 0x00007ff72664a000 C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\java.exe +0x00007ffc72ff0000 - 0x00007ffc731e8000 C:\Windows\SYSTEM32\ntdll.dll +0x00007ffc71250000 - 0x00007ffc7130d000 C:\Windows\System32\KERNEL32.DLL +0x00007ffc70800000 - 0x00007ffc70af6000 C:\Windows\System32\KERNELBASE.dll +0x00007ffc706a0000 - 0x00007ffc707a0000 C:\Windows\System32\ucrtbase.dll +0x00007ffc636a0000 - 0x00007ffc636b7000 C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\jli.dll +0x00007ffc655f0000 - 0x00007ffc6560b000 C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\VCRUNTIME140.dll +0x00007ffc71be0000 - 0x00007ffc71d7e000 C:\Windows\System32\USER32.dll +0x00007ffc707a0000 - 0x00007ffc707c2000 C:\Windows\System32\win32u.dll +0x00007ffc72d00000 - 0x00007ffc72d2b000 C:\Windows\System32\GDI32.dll +0x00007ffc70b00000 - 0x00007ffc70c17000 C:\Windows\System32\gdi32full.dll +0x00007ffc70f80000 - 0x00007ffc7101d000 C:\Windows\System32\msvcp_win.dll +0x00007ffc62590000 - 0x00007ffc6282a000 C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.3636_none_60b6a03d71f818d5\COMCTL32.dll +0x00007ffc71ac0000 - 0x00007ffc71b5e000 C:\Windows\System32\msvcrt.dll +0x00007ffc72e10000 - 0x00007ffc72e42000 C:\Windows\System32\IMM32.DLL +0x00007ffc6a360000 - 0x00007ffc6a36c000 C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\vcruntime140_1.dll +0x00007ffc592d0000 - 0x00007ffc5935d000 C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\msvcp140.dll +0x00007ffc389e0000 - 0x00007ffc39662000 C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\server\jvm.dll +0x00007ffc72e60000 - 0x00007ffc72f10000 C:\Windows\System32\ADVAPI32.dll +0x00007ffc72f10000 - 0x00007ffc72fb0000 C:\Windows\System32\sechost.dll +0x00007ffc71d80000 - 0x00007ffc71ea5000 C:\Windows\System32\RPCRT4.dll +0x00007ffc707d0000 - 0x00007ffc707f7000 C:\Windows\System32\bcrypt.dll +0x00007ffc6fc40000 - 0x00007ffc6fc8b000 C:\Windows\SYSTEM32\POWRPROF.dll +0x00007ffc67ca0000 - 0x00007ffc67cc7000 C:\Windows\SYSTEM32\WINMM.dll +0x00007ffc6a350000 - 0x00007ffc6a35a000 C:\Windows\SYSTEM32\VERSION.dll +0x00007ffc6be30000 - 0x00007ffc6be39000 C:\Windows\SYSTEM32\WSOCK32.dll +0x00007ffc71b70000 - 0x00007ffc71bdb000 C:\Windows\System32\ws2_32.DLL +0x00007ffc6fab0000 - 0x00007ffc6fac2000 C:\Windows\SYSTEM32\UMPDC.dll +0x00007ffc6ef30000 - 0x00007ffc6ef42000 C:\Windows\SYSTEM32\kernel.appcore.dll +0x00007ffc6bf00000 - 0x00007ffc6bf0a000 C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\jimage.dll +0x00007ffc6e160000 - 0x00007ffc6e344000 C:\Windows\SYSTEM32\DBGHELP.DLL +0x00007ffc57240000 - 0x00007ffc57274000 C:\Windows\SYSTEM32\dbgcore.DLL +0x00007ffc70cd0000 - 0x00007ffc70d52000 C:\Windows\System32\bcryptPrimitives.dll +0x00007ffc63f20000 - 0x00007ffc63f45000 C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\java.dll + +dbghelp: loaded successfully - version: 4.0.5 - missing functions: none +symbol engine: initialized successfully - sym options: 0x614 - pdb path: .;C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin;C:\Windows\SYSTEM32;C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.3636_none_60b6a03d71f818d5;C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\server + +VM Arguments: +java_command: git4idea.http.GitAskPassApp Username for 'https://gitee.com': +java_class_path (initial): C:/Program Files/JetBrains/IntelliJ IDEA 2023.3.2/plugins/vcs-git/lib/git4idea-rt.jar;C:/Program Files/JetBrains/IntelliJ IDEA 2023.3.2/lib/externalProcess-rt.jar +Launcher Type: SUN_STANDARD + +[Global flags] + intx CICompilerCount = 3 {product} {ergonomic} + uint ConcGCThreads = 2 {product} {ergonomic} + uint G1ConcRefinementThreads = 6 {product} {ergonomic} + size_t G1HeapRegionSize = 2097152 {product} {ergonomic} + uintx GCDrainStackTargetSize = 64 {product} {ergonomic} + size_t InitialHeapSize = 268435456 {product} {ergonomic} + size_t MarkStackSize = 4194304 {product} {ergonomic} + size_t MaxHeapSize = 4286578688 {product} {ergonomic} + size_t MinHeapDeltaBytes = 2097152 {product} {ergonomic} + size_t MinHeapSize = 8388608 {product} {ergonomic} + uintx NonNMethodCodeHeapSize = 5832780 {pd product} {ergonomic} + uintx NonProfiledCodeHeapSize = 122912730 {pd product} {ergonomic} + uintx ProfiledCodeHeapSize = 122912730 {pd product} {ergonomic} + uintx ReservedCodeCacheSize = 251658240 {pd product} {ergonomic} + bool SegmentedCodeCache = true {product} {ergonomic} + size_t SoftMaxHeapSize = 4286578688 {manageable} {ergonomic} + bool UseCompressedClassPointers = true {product lp64_product} {ergonomic} + bool UseCompressedOops = true {product lp64_product} {ergonomic} + bool UseG1GC = true {product} {ergonomic} + bool UseLargePagesIndividualAllocation = false {pd product} {ergonomic} + +Logging: +Log output configuration: + #0: stdout all=warning uptime,level,tags + #1: stderr all=off uptime,level,tags + +Environment Variables: +PATH=C:/Program Files/Git/mingw64/libexec/git-core;C:/Program Files/Git/mingw64/libexec/git-core;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Administrator\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\TortoiseGit\bin;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\AppData\Roaming\npm +USERNAME=Administrator +DISPLAY=:0.0 +LC_ALL=en_US.UTF-8 +TERM=xterm-256color +TMPDIR=C:\Users\Administrator\AppData\Local\Temp +OS=Windows_NT +PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 158 Stepping 10, GenuineIntel +TMP=C:\Users\Administrator\AppData\Local\Temp +TEMP=C:\Users\Administrator\AppData\Local\Temp + + + +Periodic native trim disabled + +JNI global refs: +JNI global refs: 0, weak refs: 0 + +JNI global refs memory usage: 0, weak refs: 0 + +OOME stack traces (most recent first): +Classloader memory used: + + +--------------- S Y S T E M --------------- + +OS: + Windows 10 , 64 bit Build 19041 (10.0.19041.3636) +OS uptime: 19 days 19:43 hours + +CPU: total 6 (initial active 6) (6 cores per cpu, 1 threads per core) family 6 model 158 stepping 10 microcode 0xb4, cx8, cmov, fxsr, mmx, 3dnowpref, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, lzcnt, tsc, tscinvbit, avx, avx2, aes, erms, clmul, bmi1, bmi2, adx, fma, vzeroupper, clflush, clflushopt +Processor Information for all 6 processors : + Max Mhz: 2904, Current Mhz: 2904, Mhz Limit: 2904 + +Memory: 4k page, system-wide physical 16349M (1308M free) +TotalPageFile size 35549M (AvailPageFile size 98M) +current process WorkingSet (physical memory assigned to process): 10M, peak: 10M +current process commit charge ("private bytes"): 56M, peak: 312M + +vm_info: OpenJDK 64-Bit Server VM (17.0.9+7-b1087.9) for windows-amd64 JRE (17.0.9+7-b1087.9), built on 2023-12-05 by "builduser" with MS VC++ 16.10 / 16.11 (VS2019) + +END. diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..c943b68 --- /dev/null +++ b/pom.xml @@ -0,0 +1,533 @@ + + + 4.0.0 + com.sqx + anmo + 3.0.0 + jar + anmo + + + org.springframework.boot + spring-boot-starter-parent + 2.6.11 + + + + UTF-8 + UTF-8 + 1.8 + 3.2.0 + 8.0.17 + 4.0 + 11.2.0.3 + 1.1.13 + 2.3.0 + 2.6 + 1.2.2 + 2.5 + 1.10 + 1.10 + 1.10.1 + 0.7.0 + 0.0.9 + 7.2.23 + 3.4.0 + 4.4 + 2.7.0 + 2.9.9 + 2.8.5 + 1.2.83 + 5.8.16 + 1.18.22 + + + + + + + + + com.winnerlook + voice-sdk + 1.1.6 + + + + com.github.xiaoymin + knife4j-spring-boot-starter + 2.0.2 + + + + + org.springframework.boot + spring-boot-starter-websocket + + + + com.tencentcloudapi + tencentcloud-sdk-java + + + 3.1.792 + + + + com.aliyun + dyplsapi20170525 + 2.0.3 + + + + com.aliyun + dyvmsapi20170525 + 2.1.4 + + + + org.gavaghan + geodesy + 1.1.3 + + + + org + jaudiotagger + 2.0.3 + + + + + org.springframework + spring-websocket + 5.1.2.RELEASE + + + + net.java.dev.jna + jna + 5.5.0 + + + net.java.dev.jna + jna-platform + 5.5.0 + + + + com.alibaba + druid + 1.1.10 + + + + com.auth0 + java-jwt + 3.8.3 + + + com.auth0 + jwks-rsa + 0.12.0 + + + io.jsonwebtoken + jjwt + 0.9.0 + + + net.sf.json-lib + json-lib + 2.4 + jdk15 + + + + org.apache.poi + poi + 4.0.1 + + + + org.apache.poi + poi-ooxml + 4.0.1 + + + com.github.qcloudsms + qcloudsms + 1.0.6 + + + + com.aliyun + aliyun-java-sdk-core + 4.5.3 + + + com.aliyun.oss + aliyun-sdk-oss + 3.4.0 + + + + com.alipay.sdk + alipay-sdk-java + 4.10.29.ALL + + + com.github.wxpay + wxpay-sdk + 0.0.3 + + + com.github.liyiorg + weixin-popular + 2.8.25 + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-aop + + + org.springframework + spring-context-support + + + org.springframework.boot + spring-boot-starter-data-redis + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + + + + + com.baomidou + mybatis-plus-boot-starter + ${mybatisplus.version} + + + com.baomidou + mybatis-plus-generator + + + + + mysql + mysql-connector-java + ${mysql.version} + + + + com.oracle + ojdbc6 + ${oracle.version} + + + + com.microsoft.sqlserver + sqljdbc4 + ${mssql.version} + + + + org.postgresql + postgresql + + + com.alibaba + druid-spring-boot-starter + ${druid.version} + + + org.quartz-scheduler + quartz + ${quartz.version} + + + com.mchange + c3p0 + + + + + commons-lang + commons-lang + ${commons.lang.version} + + + commons-fileupload + commons-fileupload + ${commons.fileupload.version} + + + commons-io + commons-io + ${commons.io.version} + + + commons-codec + commons-codec + ${commons.codec.version} + + + commons-configuration + commons-configuration + ${commons.configuration.version} + + + org.apache.shiro + shiro-core + ${shiro.version} + + + org.apache.shiro + shiro-spring + ${shiro.version} + + + com.github.axet + kaptcha + ${kaptcha.version} + + + com.qiniu + qiniu-java-sdk + ${qiniu.version} + + + com.qcloud + cos_api + ${qcloud.cos.version} + + + org.slf4j + slf4j-log4j12 + + + + + joda-time + joda-time + ${joda.time.version} + + + com.google.code.gson + gson + ${gson.version} + + + com.alibaba + fastjson + ${fastjson.version} + + + cn.hutool + hutool-all + ${hutool.version} + + + org.projectlombok + lombok + ${lombok.version} + + + + + + com.google.zxing + core + 3.3.3 + + + + com.google.zxing + javase + 3.3.3 + + + com.github.binarywang + weixin-java-mp + 3.6.0 + + + com.github.binarywang + weixin-java-pay + 3.6.0 + + + com.github.pagehelper + pagehelper-spring-boot-starter + 1.2.5 + + + mybatis-spring + org.mybatis + + + mybatis + org.mybatis + + + + + com.github.dozermapper + dozer-core + 6.4.1 + + + com.getui.push + restful-sdk + 1.0.0.1 + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework + spring-test + + + + + com.googlecode.soundlibs + jlayer + 1.0.1.4 + + + com.googlecode.soundlibs + mp3spi + 1.9.5.4 + + + com.googlecode.soundlibs + tritonus-all + 0.3.7.2 + + + + + + + + + + + ${project.artifactId} + + + org.apache.maven.wagon + wagon-ssh + 2.8 + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + org.codehaus.mojo + wagon-maven-plugin + 1.0 + + + + + com.spotify + docker-maven-plugin + 0.4.14 + + + + + + + + + + sqx/fast + ${project.basedir} + + + / + ${project.build.directory} + ${project.build.finalName}.jar + + + + + + + + + + + public + aliyun nexus + http://maven.aliyun.com/nexus/content/groups/public/ + + true + + + + + + public + aliyun nexus + http://maven.aliyun.com/nexus/content/groups/public/ + + true + + + false + + + + + diff --git a/run.bat b/run.bat new file mode 100644 index 0000000..a5e770f --- /dev/null +++ b/run.bat @@ -0,0 +1,5 @@ +@echo off && chcp 65001 +#call mvn clean package +for /f "delims=" %%i in ('dir target\*.jar /b ') do @set jarPath=%%i +call java -jar -Dfile.encoding=utf-8 -Dspring.profiles.active=dev -Xms1024m -Xmx1536m -XX:PermSize=128M -XX:MaxPermSize=256M target\%jarPath% +pause \ No newline at end of file diff --git a/script/fb.bat b/script/fb.bat new file mode 100644 index 0000000..036716a --- /dev/null +++ b/script/fb.bat @@ -0,0 +1,19 @@ +@echo off && title 벢 +echo лļ +ren .\src\main\resources\application.yml application.yml.dev +ren .\src\main\resources\application.yml.prod application.yml +echo лϣִд +call mvn clean package +echo ԭļ +ren .\src\main\resources\application.yml application.yml.prod +ren .\src\main\resources\application.yml.dev application.yml +echo ԭϣ +echo Xrtx*2022 +echo ʼ +pause +::ɱ +ssh root@49.232.154.11 "cd /home/springboot/jdbiJava/ && sh killJar.sh" +scp ./target/jdyybi-0.0.1.jar root@49.232.154.11:/home/springboot/jdbiJava +ssh root@49.232.154.11 "cd /home/springboot/jdbiJava/ && sh run.sh" +pause + diff --git a/script/findps.sh b/script/findps.sh new file mode 100644 index 0000000..def9ac6 --- /dev/null +++ b/script/findps.sh @@ -0,0 +1 @@ +ps -ef | grep anmo.jar | grep -v grep \ No newline at end of file diff --git a/script/killJar.sh b/script/killJar.sh new file mode 100644 index 0000000..c52d6ee --- /dev/null +++ b/script/killJar.sh @@ -0,0 +1,2 @@ +#!/bin/sh +ps -ef | grep anmo.jar | grep -v grep | awk '{print $2}' | xargs kill -9 \ No newline at end of file diff --git a/script/run.sh b/script/run.sh new file mode 100644 index 0000000..279785c --- /dev/null +++ b/script/run.sh @@ -0,0 +1,6 @@ +#!/bin/sh +#nohup +JAVA_OPTS="-server -Xms400m -Xmx400m -Xmn30m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xverify:none -XX:+DisableExplicitGC -Djava.awt.headless=true" +#java $JAVA_OPTS -jar ./jdyybi-0.0.1.jar 1>/dev/null 2>./out.log & +nohup java $JAVA_OPTS -jar ./anmo.jar >nohup.log 2>&1 & +exit 0 \ No newline at end of file diff --git a/src/main/java/com/sqx/SqxApplication.java b/src/main/java/com/sqx/SqxApplication.java new file mode 100644 index 0000000..71c2984 --- /dev/null +++ b/src/main/java/com/sqx/SqxApplication.java @@ -0,0 +1,32 @@ +package com.sqx; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableScheduling; + +@Slf4j +@SpringBootApplication +@EnableScheduling +public class SqxApplication { + + public static void main(String[] args) { + SpringApplication.run(SqxApplication.class, args); + log.info("(♥◠‿◠)ノ゙ 按摩项目启动成功 ლ(´ڡ`ლ)゙ \n"+ + " _ \n" + + " | | \n" + + " ___ | | __\n" + + " / _ \\| |/ /\n" + + "| (_) | < \n" + + " \\___/|_|\\_\\"); + System.out.println("swagger访问地址:http://localhost:8187/sqx_fast/doc.html"); + System.out.println("-------------======= 华丽的分割线 =========----------"); + //返回Java虚拟机中的堆内存总量 + long xmsMemory = Runtime.getRuntime().totalMemory() / 1024 / 1024; + //返回Java虚拟机中使用的最大堆内存 + long xmxMemory = Runtime.getRuntime().maxMemory() / 1024 / 1024; + System.out.println("-Xms:" + xmsMemory + "M"); + System.out.println("-Xmx:" + xmxMemory + "M"); + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/common/annotation/SysLog.java b/src/main/java/com/sqx/common/annotation/SysLog.java new file mode 100644 index 0000000..70cec15 --- /dev/null +++ b/src/main/java/com/sqx/common/annotation/SysLog.java @@ -0,0 +1,19 @@ +package com.sqx.common.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 系统日志注解 + * + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface SysLog { + + String value() default ""; +} diff --git a/src/main/java/com/sqx/common/aspect/RedisAspect.java b/src/main/java/com/sqx/common/aspect/RedisAspect.java new file mode 100644 index 0000000..896c0f7 --- /dev/null +++ b/src/main/java/com/sqx/common/aspect/RedisAspect.java @@ -0,0 +1,37 @@ +package com.sqx.common.aspect; + +import com.sqx.common.exception.SqxException; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +/** + * Redis切面处理类 + * + */ +@Aspect +@Configuration +public class RedisAspect { + private Logger logger = LoggerFactory.getLogger(getClass()); + //是否开启redis缓存 true开启 false关闭 + @Value("${spring.redis.open: false}") + private boolean open; + + @Around("execution(* com.sqx.common.utils.RedisUtils.*(..))") + public Object around(ProceedingJoinPoint point) throws Throwable { + Object result = null; + if(open){ + try{ + result = point.proceed(); + }catch (Exception e){ + logger.error("redis error", e); + throw new SqxException("Redis服务异常"); + } + } + return result; + } +} diff --git a/src/main/java/com/sqx/common/aspect/SysLogAspect.java b/src/main/java/com/sqx/common/aspect/SysLogAspect.java new file mode 100644 index 0000000..b0f5ac8 --- /dev/null +++ b/src/main/java/com/sqx/common/aspect/SysLogAspect.java @@ -0,0 +1,92 @@ +package com.sqx.common.aspect; + +import com.google.gson.Gson; +import com.sqx.common.utils.HttpContextUtils; +import com.sqx.common.utils.IPUtils; +import com.sqx.common.annotation.SysLog; +import com.sqx.modules.sys.entity.SysLogEntity; +import com.sqx.modules.sys.entity.SysUserEntity; +import com.sqx.modules.sys.service.SysLogService; +import org.apache.shiro.SecurityUtils; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import java.lang.reflect.Method; +import java.util.Date; + + +/** + * 系统日志,切面处理类 + * + */ +@Aspect +@Component +public class SysLogAspect { + @Autowired + private SysLogService sysLogService; + + @Pointcut("@annotation(com.sqx.common.annotation.SysLog)") + public void logPointCut() { + + } + + @Around("logPointCut()") + public Object around(ProceedingJoinPoint point) throws Throwable { + long beginTime = System.currentTimeMillis(); + //执行方法 + Object result = point.proceed(); + //执行时长(毫秒) + long time = System.currentTimeMillis() - beginTime; + + //保存日志 + saveSysLog(point, time); + + return result; + } + + private void saveSysLog(ProceedingJoinPoint joinPoint, long time) { + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); + + SysLogEntity sysLog = new SysLogEntity(); + SysLog syslog = method.getAnnotation(SysLog.class); + if(syslog != null){ + //注解上的描述 + sysLog.setOperation(syslog.value()); + } + + //请求的方法名 + String className = joinPoint.getTarget().getClass().getName(); + String methodName = signature.getName(); + sysLog.setMethod(className + "." + methodName + "()"); + + //请求的参数 + Object[] args = joinPoint.getArgs(); + try{ + String params = new Gson().toJson(args); + sysLog.setParams(params); + }catch (Exception e){ + + } + + //获取request + HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); + //设置IP地址 + sysLog.setIp(IPUtils.getIpAddr(request)); + + //用户名 + String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); + sysLog.setUsername(username); + + sysLog.setTime(time); + sysLog.setCreateDate(new Date()); + //保存系统日志 + sysLogService.save(sysLog); + } +} diff --git a/src/main/java/com/sqx/common/exception/SqxException.java b/src/main/java/com/sqx/common/exception/SqxException.java new file mode 100644 index 0000000..f343af5 --- /dev/null +++ b/src/main/java/com/sqx/common/exception/SqxException.java @@ -0,0 +1,52 @@ +package com.sqx.common.exception; + +/** + * 自定义异常 + * + */ +public class SqxException extends RuntimeException { + private static final long serialVersionUID = 1L; + + private String msg; + private int code = 500; + + public SqxException(String msg) { + super(msg); + this.msg = msg; + } + + public SqxException(String msg, Throwable e) { + super(msg, e); + this.msg = msg; + } + + public SqxException(String msg, int code) { + super(msg); + this.msg = msg; + this.code = code; + } + + public SqxException(String msg, int code, Throwable e) { + super(msg, e); + this.msg = msg; + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + +} diff --git a/src/main/java/com/sqx/common/exception/SqxExceptionHandler.java b/src/main/java/com/sqx/common/exception/SqxExceptionHandler.java new file mode 100644 index 0000000..a171e7d --- /dev/null +++ b/src/main/java/com/sqx/common/exception/SqxExceptionHandler.java @@ -0,0 +1,55 @@ +package com.sqx.common.exception; + +import com.sqx.common.utils.Result; +import org.apache.shiro.authz.AuthorizationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.dao.DuplicateKeyException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.servlet.NoHandlerFoundException; + +/** + * 异常处理器 + * + */ +@RestControllerAdvice +public class SqxExceptionHandler { + private Logger logger = LoggerFactory.getLogger(getClass()); + + /** + * 处理自定义异常 + */ + @ExceptionHandler(SqxException.class) + public Result handleException(SqxException e){ + Result r = new Result(); + r.put("code", e.getCode()); + r.put("msg", e.getMessage()); + + return r; + } + + @ExceptionHandler(NoHandlerFoundException.class) + public Result handlerNoFoundException(Exception e) { + logger.error(e.getMessage(), e); + return Result.error(404, "路径不存在,请检查路径是否正确"); + } + + @ExceptionHandler(DuplicateKeyException.class) + public Result handleDuplicateKeyException(DuplicateKeyException e){ + logger.error(e.getMessage(), e); + return Result.error("数据库中已存在该记录"); + } + + @ExceptionHandler(AuthorizationException.class) + public Result handleAuthorizationException(AuthorizationException e){ + logger.error(e.getMessage(), e); + return Result.error("没有权限,请联系管理员授权"); + } + + @ExceptionHandler(Exception.class) + public Result handleException(Exception e){ + logger.error(e.getMessage(), e); + return Result.error(); + } +} diff --git a/src/main/java/com/sqx/common/utils/ConfigConstant.java b/src/main/java/com/sqx/common/utils/ConfigConstant.java new file mode 100644 index 0000000..6e18daf --- /dev/null +++ b/src/main/java/com/sqx/common/utils/ConfigConstant.java @@ -0,0 +1,12 @@ +package com.sqx.common.utils; + +/** + * 系统参数相关Key + * + */ +public class ConfigConstant { + /** + * 云存储配置KEY + */ + public final static String CLOUD_STORAGE_CONFIG_KEY = "CLOUD_STORAGE_CONFIG_KEY"; +} diff --git a/src/main/java/com/sqx/common/utils/Constant.java b/src/main/java/com/sqx/common/utils/Constant.java new file mode 100644 index 0000000..436bcb1 --- /dev/null +++ b/src/main/java/com/sqx/common/utils/Constant.java @@ -0,0 +1,110 @@ +package com.sqx.common.utils; + +/** + * 常量 + * + */ +public class Constant { + /** 超级管理员ID */ + public static final int SUPER_ADMIN = 1; + /** + * 当前页码 + */ + public static final String PAGE = "page"; + /** + * 每页显示记录数 + */ + public static final String LIMIT = "limit"; + /** + * 排序字段 + */ + public static final String ORDER_FIELD = "sidx"; + /** + * 排序方式 + */ + public static final String ORDER = "order"; + /** + * 升序 + */ + public static final String ASC = "asc"; + /** + * 菜单类型 + */ + public enum MenuType { + /** + * 目录 + */ + CATALOG(0), + /** + * 菜单 + */ + MENU(1), + /** + * 按钮 + */ + BUTTON(2); + + private int value; + + MenuType(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + + /** + * 定时任务状态 + */ + public enum ScheduleStatus { + /** + * 正常 + */ + NORMAL(0), + /** + * 暂停 + */ + PAUSE(1); + + private int value; + + ScheduleStatus(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + + /** + * 云服务商 + */ + public enum CloudService { + /** + * 七牛云 + */ + QINIU(1), + /** + * 阿里云 + */ + ALIYUN(2), + /** + * 腾讯云 + */ + QCLOUD(3); + + private int value; + + CloudService(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + +} diff --git a/src/main/java/com/sqx/common/utils/DateUtils.java b/src/main/java/com/sqx/common/utils/DateUtils.java new file mode 100644 index 0000000..9d51649 --- /dev/null +++ b/src/main/java/com/sqx/common/utils/DateUtils.java @@ -0,0 +1,157 @@ +package com.sqx.common.utils; + +import org.apache.commons.lang.StringUtils; +import org.joda.time.DateTime; +import org.joda.time.LocalDate; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 日期处理 + * + */ +public class DateUtils { + /** 时间格式(yyyy-MM-dd) */ + public final static String DATE_PATTERN = "yyyy-MM-dd"; + /** 时间格式(yyyy-MM-dd HH:mm:ss) */ + public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; + + /** + * 日期格式化 日期格式为:yyyy-MM-dd + * @param date 日期 + * @return 返回yyyy-MM-dd格式日期 + */ + public static String format(Date date) { + return format(date, DATE_TIME_PATTERN); + } + + /** + * 日期格式化 日期格式为:yyyy-MM-dd + * @param date 日期 + * @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN + * @return 返回yyyy-MM-dd格式日期 + */ + public static String format(Date date, String pattern) { + if(date != null){ + SimpleDateFormat df = new SimpleDateFormat(pattern); + return df.format(date); + } + return null; + } + + /** + * 字符串转换成日期 + * @param strDate 日期字符串 + * @param pattern 日期的格式,如:DateUtils.DATE_TIME_PATTERN + */ + public static Date stringToDate(String strDate, String pattern) { + if (StringUtils.isBlank(strDate)){ + return null; + } + + DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); + return fmt.parseLocalDateTime(strDate).toDate(); + } + + /** + * 根据周数,获取开始日期、结束日期 + * @param week 周期 0本周,-1上周,-2上上周,1下周,2下下周 + * @return 返回date[0]开始日期、date[1]结束日期 + */ + public static Date[] getWeekStartAndEnd(int week) { + DateTime dateTime = new DateTime(); + LocalDate date = new LocalDate(dateTime.plusWeeks(week)); + + date = date.dayOfWeek().withMinimumValue(); + Date beginDate = date.toDate(); + Date endDate = date.plusDays(6).toDate(); + return new Date[]{beginDate, endDate}; + } + + /** + * 对日期的【秒】进行加/减 + * + * @param date 日期 + * @param seconds 秒数,负数为减 + * @return 加/减几秒后的日期 + */ + public static Date addDateSeconds(Date date, int seconds) { + DateTime dateTime = new DateTime(date); + return dateTime.plusSeconds(seconds).toDate(); + } + + /** + * 对日期的【分钟】进行加/减 + * + * @param date 日期 + * @param minutes 分钟数,负数为减 + * @return 加/减几分钟后的日期 + */ + public static Date addDateMinutes(Date date, int minutes) { + DateTime dateTime = new DateTime(date); + return dateTime.plusMinutes(minutes).toDate(); + } + + /** + * 对日期的【小时】进行加/减 + * + * @param date 日期 + * @param hours 小时数,负数为减 + * @return 加/减几小时后的日期 + */ + public static Date addDateHours(Date date, int hours) { + DateTime dateTime = new DateTime(date); + return dateTime.plusHours(hours).toDate(); + } + + /** + * 对日期的【天】进行加/减 + * + * @param date 日期 + * @param days 天数,负数为减 + * @return 加/减几天后的日期 + */ + public static Date addDateDays(Date date, int days) { + DateTime dateTime = new DateTime(date); + return dateTime.plusDays(days).toDate(); + } + + /** + * 对日期的【周】进行加/减 + * + * @param date 日期 + * @param weeks 周数,负数为减 + * @return 加/减几周后的日期 + */ + public static Date addDateWeeks(Date date, int weeks) { + DateTime dateTime = new DateTime(date); + return dateTime.plusWeeks(weeks).toDate(); + } + + /** + * 对日期的【月】进行加/减 + * + * @param date 日期 + * @param months 月数,负数为减 + * @return 加/减几月后的日期 + */ + public static Date addDateMonths(Date date, int months) { + DateTime dateTime = new DateTime(date); + return dateTime.plusMonths(months).toDate(); + } + + /** + * 对日期的【年】进行加/减 + * + * @param date 日期 + * @param years 年数,负数为减 + * @return 加/减几年后的日期 + */ + public static Date addDateYears(Date date, int years) { + DateTime dateTime = new DateTime(date); + return dateTime.plusYears(years).toDate(); + } +} diff --git a/src/main/java/com/sqx/common/utils/HttpContextUtils.java b/src/main/java/com/sqx/common/utils/HttpContextUtils.java new file mode 100644 index 0000000..82c860e --- /dev/null +++ b/src/main/java/com/sqx/common/utils/HttpContextUtils.java @@ -0,0 +1,24 @@ +package com.sqx.common.utils; + +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + +public class HttpContextUtils { + + public static HttpServletRequest getHttpServletRequest() { + return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + } + + public static String getDomain(){ + HttpServletRequest request = getHttpServletRequest(); + StringBuffer url = request.getRequestURL(); + return url.delete(url.length() - request.getRequestURI().length(), url.length()).toString(); + } + + public static String getOrigin(){ + HttpServletRequest request = getHttpServletRequest(); + return request.getHeader("Origin"); + } +} diff --git a/src/main/java/com/sqx/common/utils/IPUtils.java b/src/main/java/com/sqx/common/utils/IPUtils.java new file mode 100644 index 0000000..0fbd6c9 --- /dev/null +++ b/src/main/java/com/sqx/common/utils/IPUtils.java @@ -0,0 +1,49 @@ +package com.sqx.common.utils; + +import com.alibaba.druid.util.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.http.HttpServletRequest; + +/** + * IP地址 + * + */ +public class IPUtils { + private static Logger logger = LoggerFactory.getLogger(IPUtils.class); + + /** + * 获取IP地址 + * + * 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址 + * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址 + */ + public static String getIpAddr(HttpServletRequest request) { + String ip = null; + try { + ip = request.getHeader("x-forwarded-for"); + if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (StringUtils.isEmpty(ip) || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + } + if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + } catch (Exception e) { + logger.error("IPUtils ERROR ", e); + } + + + return ip; + } + +} diff --git a/src/main/java/com/sqx/common/utils/ListUtils.java b/src/main/java/com/sqx/common/utils/ListUtils.java new file mode 100644 index 0000000..ad4ecdd --- /dev/null +++ b/src/main/java/com/sqx/common/utils/ListUtils.java @@ -0,0 +1,54 @@ +package com.sqx.common.utils; + +import java.util.*; + +public class ListUtils { + /** + * list 集合分组 + * + * @param list 待分组集合 + * @param groupBy 分组Key算法 + * @param 分组Key类型 + * @param 行数据类型 + * @return 分组后的Map集合 + */ + public static Map> groupBy(List list, GroupBy groupBy) { + return groupBy((Collection) list, groupBy); + } + + /** + * list 集合分组 + * + * @param list 待分组集合 + * @param groupBy 分组Key算法 + * @param 分组Key类型 + * @param 行数据类型 + * @return 分组后的Map集合 + */ + public static Map> groupBy(Collection list, GroupBy groupBy) { + Map> resultMap = new LinkedHashMap>(); + + for (V e : list) { + + K k = groupBy.groupBy(e); + if (resultMap.containsKey(k)) { + resultMap.get(k).add(e); + } else { + List tmp = new LinkedList(); + tmp.add(e); + resultMap.put(k, tmp); + } + } + return resultMap; + } + + /** + * List分组 + * + * @param 返回分组Key + * @param 分组行 + */ + public interface GroupBy { + K groupBy(V row); + } +} diff --git a/src/main/java/com/sqx/common/utils/MapUtils.java b/src/main/java/com/sqx/common/utils/MapUtils.java new file mode 100644 index 0000000..14a1558 --- /dev/null +++ b/src/main/java/com/sqx/common/utils/MapUtils.java @@ -0,0 +1,17 @@ +package com.sqx.common.utils; + +import java.util.HashMap; + + +/** + * Map工具类 + * + */ +public class MapUtils extends HashMap { + + @Override + public MapUtils put(String key, Object value) { + super.put(key, value); + return this; + } +} diff --git a/src/main/java/com/sqx/common/utils/PageUtils.java b/src/main/java/com/sqx/common/utils/PageUtils.java new file mode 100644 index 0000000..6e522c0 --- /dev/null +++ b/src/main/java/com/sqx/common/utils/PageUtils.java @@ -0,0 +1,101 @@ +package com.sqx.common.utils; + +import com.baomidou.mybatisplus.core.metadata.IPage; + +import java.io.Serializable; +import java.util.List; + +/** + * 分页工具类 + * + */ +public class PageUtils implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 总记录数 + */ + private int totalCount; + /** + * 每页记录数 + */ + private int pageSize; + /** + * 总页数 + */ + private int totalPage; + /** + * 当前页数 + */ + private int currPage; + /** + * 列表数据 + */ + private List list; + + /** + * 分页 + * @param list 列表数据 + * @param totalCount 总记录数 + * @param pageSize 每页记录数 + * @param currPage 当前页数 + */ + public PageUtils(List list, int totalCount, int pageSize, int currPage) { + this.list = list; + this.totalCount = totalCount; + this.pageSize = pageSize; + this.currPage = currPage; + this.totalPage = (int)Math.ceil((double)totalCount/pageSize); + } + + /** + * 分页 + */ + public PageUtils(IPage page) { + this.list = page.getRecords(); + this.totalCount = (int)page.getTotal(); + this.pageSize = (int)page.getSize(); + this.currPage = (int)page.getCurrent(); + this.totalPage = (int)page.getPages(); + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getTotalPage() { + return totalPage; + } + + public void setTotalPage(int totalPage) { + this.totalPage = totalPage; + } + + public int getCurrPage() { + return currPage; + } + + public void setCurrPage(int currPage) { + this.currPage = currPage; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + +} diff --git a/src/main/java/com/sqx/common/utils/QRCodeUtil.java b/src/main/java/com/sqx/common/utils/QRCodeUtil.java new file mode 100644 index 0000000..e4d06fa --- /dev/null +++ b/src/main/java/com/sqx/common/utils/QRCodeUtil.java @@ -0,0 +1,175 @@ +package com.sqx.common.utils; + +import cn.hutool.extra.qrcode.BufferedImageLuminanceSource; +import com.google.zxing.*; +import com.google.zxing.Result; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.common.HybridBinarizer; +import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.geom.RoundRectangle2D; +import java.awt.image.BufferedImage; +import java.io.File; +import java.util.Hashtable; + +/** + * 二维码生成解析工具类 + + * @date 2020/02/12 09:37 + */ +public class QRCodeUtil { + + //编码格式,采用utf-8 + private static final String UNICODE = "utf-8"; + //图片格式 + private static final String FORMAT = "JPG"; + //二维码宽度,单位:像素pixels + private static final int QRCODE_WIDTH = 300; + //二维码高度,单位:像素pixels + private static final int QRCODE_HEIGHT = 300; + //LOGO宽度,单位:像素pixels + private static final int LOGO_WIDTH = 100; + //LOGO高度,单位:像素pixels + private static final int LOGO_HEIGHT = 100; + + /** + * 生成二维码图片 + * @param content 二维码内容 + * @param logoPath 图片地址 + * @param needCompress 是否压缩 + * @return + * @throws Exception + */ + private static BufferedImage createImage(String content, String logoPath, boolean needCompress) throws Exception { + Hashtable hints = new Hashtable(); + hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); + hints.put(EncodeHintType.CHARACTER_SET, UNICODE); + hints.put(EncodeHintType.MARGIN, 1); + BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, QRCODE_WIDTH, QRCODE_HEIGHT, + hints); + int width = bitMatrix.getWidth(); + int height = bitMatrix.getHeight(); + BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + image.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF); + } + } + if (logoPath == null || "".equals(logoPath)) { + return image; + } + // 插入图片 + QRCodeUtil.insertImage(image, logoPath, needCompress); + return image; + } + + /** + * 插入LOGO + * @param source 二维码图片 + * @param logoPath LOGO图片地址 + * @param needCompress 是否压缩 + * @throws Exception + */ + private static void insertImage(BufferedImage source, String logoPath, boolean needCompress) throws Exception { + File file = new File(logoPath); + if (!file.exists()) { + throw new Exception("logo file not found."); + } + Image src = ImageIO.read(new File(logoPath)); + int width = src.getWidth(null); + int height = src.getHeight(null); + if (needCompress) { // 压缩LOGO + if (width > LOGO_WIDTH) { + width = LOGO_WIDTH; + } + if (height > LOGO_HEIGHT) { + height = LOGO_HEIGHT; + } + Image image = src.getScaledInstance(width, height, Image.SCALE_SMOOTH); + BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + Graphics g = tag.getGraphics(); + g.drawImage(image, 0, 0, null); // 绘制缩小后的图 + g.dispose(); + src = image; + } + // 插入LOGO + Graphics2D graph = source.createGraphics(); + int x = (QRCODE_WIDTH - width) / 2; + int y = (QRCODE_HEIGHT - height) / 2; + graph.drawImage(src, x, y, width, height, null); + Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6); + graph.setStroke(new BasicStroke(3f)); + graph.draw(shape); + graph.dispose(); + } + + /** + * 生成二维码(内嵌LOGO) + * 调用者指定二维码文件名 + * @param content 二维码的内容 + * @param logoPath 中间图片地址 + * @param destPath 存储路径 + * @param fileName 文件名称 + * @param needCompress 是否压缩 + * @return + * @throws Exception + */ + public static String encode(String content, String logoPath, String destPath, String fileName, boolean needCompress) throws Exception { + BufferedImage image = QRCodeUtil.createImage(content, logoPath, needCompress); + mkdirs(destPath); + //文件名称通过传递 + fileName = fileName.substring(0, fileName.indexOf(".")>0?fileName.indexOf("."):fileName.length()) + + "." + FORMAT.toLowerCase(); + ImageIO.write(image, FORMAT, new File(destPath + "/" + fileName)); + return fileName; + } + + /** + * 创建文件夹, mkdirs会自动创建多层目录,区别于mkdir.(mkdir如果父目录不存在则会抛出异常) + * @param destPath + */ + public static void mkdirs(String destPath) { + File file = new File(destPath); + if (!file.exists() && !file.isDirectory()) { + file.mkdirs(); + } + } + + /** + * 解析二维码 + * @param path 二维码图片路径 + * @return String 二维码内容 + * @throws Exception + */ + public static String decode(String path) throws Exception { + File file = new File(path); + BufferedImage image = ImageIO.read(file); + if (image == null) { + return null; + } + BufferedImageLuminanceSource source = new BufferedImageLuminanceSource(image); + BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); + Result result; + Hashtable hints = new Hashtable(); + hints.put(DecodeHintType.CHARACTER_SET, UNICODE); + result = new MultiFormatReader().decode(bitmap, hints); + return result.getText(); + } + + /** + * 测试 + * @param args + * @throws Exception + */ + public static void main(String[] args) throws Exception { + String text = "http://47.105.101.72:8088"; + //不含Logo +// QRCodeUtil.encode(text, null, "/Users/kyson/Downloads", "qrcode", true); + //含Logo,指定二维码图片名 + QRCodeUtil.encode(text, "/Users/kyson/Downloads/宋康.jpg", "/Users/kyson/Downloads", "qrcode1", true); +// System.out.println(QRCodeUtil.decode("d:\\cc\\qrcode1.jpg")); +// System.out.println(QRCodeUtil.encode(text, null, "/Users/kyson/Downloads", "qrcode", true)); + } +} diff --git a/src/main/java/com/sqx/common/utils/Query.java b/src/main/java/com/sqx/common/utils/Query.java new file mode 100644 index 0000000..bbddb66 --- /dev/null +++ b/src/main/java/com/sqx/common/utils/Query.java @@ -0,0 +1,68 @@ +package com.sqx.common.utils; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.xss.SQLFilter; +import org.apache.commons.lang.StringUtils; + +import java.util.Map; + +/** + * 查询参数 + * + */ +public class Query { + + public IPage getPage(Map params) { + return this.getPage(params, null, false); + } + + public IPage getPage(Map params, String defaultOrderField, boolean isAsc) { + //分页参数 + long curPage = 1; + long limit = 10; + + if(params.get(Constant.PAGE) != null){ + curPage = Long.parseLong(String.valueOf(params.get(Constant.PAGE))); + } + if(params.get(Constant.LIMIT) != null){ + limit = Long.parseLong(String.valueOf(params.get(Constant.LIMIT))); + } + + //分页对象 + Page page = new Page<>(curPage, limit); + + //分页参数 + params.put(Constant.PAGE, page); + + //排序字段 + //防止SQL注入(因为sidx、order是通过拼接SQL实现排序的,会有SQL注入风险) + String orderField = SQLFilter.sqlInject((String)params.get(Constant.ORDER_FIELD)); + String order = (String)params.get(Constant.ORDER); + + + //前端字段排序 + if(StringUtils.isNotEmpty(orderField) && StringUtils.isNotEmpty(order)){ + if(Constant.ASC.equalsIgnoreCase(order)) { + return page.addOrder(OrderItem.asc(orderField)); + }else { + return page.addOrder(OrderItem.desc(orderField)); + } + } + + //没有排序字段,则不排序 + if(StringUtils.isBlank(defaultOrderField)){ + return page; + } + + //默认排序 + if(isAsc) { + page.addOrder(OrderItem.asc(defaultOrderField)); + }else { + page.addOrder(OrderItem.desc(defaultOrderField)); + } + + return page; + } +} diff --git a/src/main/java/com/sqx/common/utils/RedisKeys.java b/src/main/java/com/sqx/common/utils/RedisKeys.java new file mode 100644 index 0000000..f195413 --- /dev/null +++ b/src/main/java/com/sqx/common/utils/RedisKeys.java @@ -0,0 +1,12 @@ +package com.sqx.common.utils; + +/** + * Redis所有Keys + * + */ +public class RedisKeys { + + public static String getSysConfigKey(String key){ + return "sys:config:" + key; + } +} diff --git a/src/main/java/com/sqx/common/utils/RedisUtils.java b/src/main/java/com/sqx/common/utils/RedisUtils.java new file mode 100644 index 0000000..0e8ae54 --- /dev/null +++ b/src/main/java/com/sqx/common/utils/RedisUtils.java @@ -0,0 +1,95 @@ +package com.sqx.common.utils; + +import com.google.gson.Gson; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.*; +import org.springframework.stereotype.Component; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +/** + * Redis工具类 + * + */ +@Component +public class RedisUtils { + @Autowired + private RedisTemplate redisTemplate; + @Autowired + private ValueOperations valueOperations; + @Autowired + private HashOperations hashOperations; + @Autowired + private ListOperations listOperations; + @Autowired + private SetOperations setOperations; + @Autowired + private ZSetOperations zSetOperations; + /** 默认过期时长,单位:秒 */ + public final static long DEFAULT_EXPIRE = 60 * 60 * 24; + /** 不设置过期时长 */ + public final static long NOT_EXPIRE = -1; + private final static Gson Gson = new Gson(); + + public void set(String key, Object value, long expire){ + valueOperations.set(key, toJson(value)); + if(expire != NOT_EXPIRE){ + redisTemplate.expire(key, expire, TimeUnit.SECONDS); + } + } + + public void set(String key, Object value){ + set(key, value, DEFAULT_EXPIRE); + } + + public T get(String key, Class clazz, long expire) { + String value = valueOperations.get(key); + if(expire != NOT_EXPIRE){ + redisTemplate.expire(key, expire, TimeUnit.SECONDS); + } + return value == null ? null : fromJson(value, clazz); + } + + public T get(String key, Class clazz) { + return get(key, clazz, NOT_EXPIRE); + } + + public String get(String key, long expire) { + String value = valueOperations.get(key); + if(expire != NOT_EXPIRE){ + redisTemplate.expire(key, expire, TimeUnit.SECONDS); + } + return value; + } + + public String get(String key) { + return get(key, NOT_EXPIRE); + } + + public Set keys(String key){ + return redisTemplate.keys(key); + } + + public void delete(String key) { + redisTemplate.delete(key); + } + + /** + * Object转成JSON数据 + */ + private String toJson(Object object){ + if(object instanceof Integer || object instanceof Long || object instanceof Float || + object instanceof Double || object instanceof Boolean || object instanceof String){ + return String.valueOf(object); + } + return Gson.toJson(object); + } + + /** + * JSON数据,转成Object + */ + private T fromJson(String json, Class clazz){ + return Gson.fromJson(json, clazz); + } +} diff --git a/src/main/java/com/sqx/common/utils/Result.java b/src/main/java/com/sqx/common/utils/Result.java new file mode 100644 index 0000000..6ceb162 --- /dev/null +++ b/src/main/java/com/sqx/common/utils/Result.java @@ -0,0 +1,56 @@ +package com.sqx.common.utils; + +import org.apache.http.HttpStatus; + +import java.util.HashMap; +import java.util.Map; + +/** + * 返回数据 + * + */ +public class Result extends HashMap { + private static final long serialVersionUID = 1L; + + public Result () { + put("code", 0); + put("msg", "success"); + } + + public static Result error() { + return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员"); + } + + public static Result error(String msg) { + return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg); + } + + public static Result error(int code, String msg) { + Result r = new Result(); + r.put("code", code); + r.put("msg", msg); + return r; + } + + public static Result success(String msg) { + Result r = new Result(); + r.put("msg", msg); + return r; + } + + public static Result success(Map map) { + Result r = new Result(); + r.putAll(map); + return r; + } + + public static Result success() { + return new Result(); + } + + @Override + public Result put(String key, Object value) { + super.put(key, value); + return this; + } +} diff --git a/src/main/java/com/sqx/common/utils/ShiroUtils.java b/src/main/java/com/sqx/common/utils/ShiroUtils.java new file mode 100644 index 0000000..291a032 --- /dev/null +++ b/src/main/java/com/sqx/common/utils/ShiroUtils.java @@ -0,0 +1,52 @@ +package com.sqx.common.utils; + +import com.sqx.common.exception.SqxException; +import com.sqx.modules.sys.entity.SysUserEntity; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.session.Session; +import org.apache.shiro.subject.Subject; + +/** + * Shiro工具类 + * + */ +public class ShiroUtils { + + public static Session getSession() { + return SecurityUtils.getSubject().getSession(); + } + + public static Subject getSubject() { + return SecurityUtils.getSubject(); + } + + public static SysUserEntity getUserEntity() { + return (SysUserEntity)SecurityUtils.getSubject().getPrincipal(); + } + + public static Long getUserId() { + return getUserEntity().getUserId(); + } + + public static void setSessionAttribute(Object key, Object value) { + getSession().setAttribute(key, value); + } + + public static Object getSessionAttribute(Object key) { + return getSession().getAttribute(key); + } + + public static boolean isLogin() { + return SecurityUtils.getSubject().getPrincipal() != null; + } + + public static String getKaptcha(String key) { + Object kaptcha = getSessionAttribute(key); + if(kaptcha == null){ + throw new SqxException("验证码已失效"); + } + getSession().removeAttribute(key); + return kaptcha.toString(); + } + +} diff --git a/src/main/java/com/sqx/common/utils/SpringContextUtils.java b/src/main/java/com/sqx/common/utils/SpringContextUtils.java new file mode 100644 index 0000000..2061193 --- /dev/null +++ b/src/main/java/com/sqx/common/utils/SpringContextUtils.java @@ -0,0 +1,46 @@ +package com.sqx.common.utils; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +/** + * Spring Context 工具类 + * + */ +@Component +public class SpringContextUtils implements ApplicationContextAware { + public static ApplicationContext applicationContext; + + @Override + public void setApplicationContext(ApplicationContext applicationContext) + throws BeansException { + SpringContextUtils.applicationContext = applicationContext; + } + + public static Object getBean(String name) { + return applicationContext.getBean(name); + } + + public static T getBean(String name, Class requiredType) { + return applicationContext.getBean(name, requiredType); + } + + public static T getBean(Class clazz) { + return applicationContext.getBean(clazz); + } + + public static boolean containsBean(String name) { + return applicationContext.containsBean(name); + } + + public static boolean isSingleton(String name) { + return applicationContext.isSingleton(name); + } + + public static Class getType(String name) { + return applicationContext.getType(name); + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/common/validator/Assert.java b/src/main/java/com/sqx/common/validator/Assert.java new file mode 100644 index 0000000..3152500 --- /dev/null +++ b/src/main/java/com/sqx/common/validator/Assert.java @@ -0,0 +1,23 @@ +package com.sqx.common.validator; + +import com.sqx.common.exception.SqxException; +import org.apache.commons.lang.StringUtils; + +/** + * 数据校验 + * + */ + public class Assert { + + public static void isBlank(String str, String message) { + if (StringUtils.isBlank(str)) { + throw new SqxException(message); + } + } + + public static void isNull(Object object, String message) { + if (object == null) { + throw new SqxException(message); + } + } +} diff --git a/src/main/java/com/sqx/common/validator/ValidatorUtils.java b/src/main/java/com/sqx/common/validator/ValidatorUtils.java new file mode 100644 index 0000000..f771453 --- /dev/null +++ b/src/main/java/com/sqx/common/validator/ValidatorUtils.java @@ -0,0 +1,14 @@ +package com.sqx.common.validator; + +import com.sqx.common.exception.SqxException; + + + +public class ValidatorUtils { + + + public static void validateEntity(Object object, Class... groups) + throws SqxException { + + } +} diff --git a/src/main/java/com/sqx/common/validator/group/AddGroup.java b/src/main/java/com/sqx/common/validator/group/AddGroup.java new file mode 100644 index 0000000..b7021b2 --- /dev/null +++ b/src/main/java/com/sqx/common/validator/group/AddGroup.java @@ -0,0 +1,8 @@ +package com.sqx.common.validator.group; + +/** + * 新增数据 Group + * + */ +public interface AddGroup { +} diff --git a/src/main/java/com/sqx/common/validator/group/AliyunGroup.java b/src/main/java/com/sqx/common/validator/group/AliyunGroup.java new file mode 100644 index 0000000..d130a82 --- /dev/null +++ b/src/main/java/com/sqx/common/validator/group/AliyunGroup.java @@ -0,0 +1,8 @@ +package com.sqx.common.validator.group; + +/** + * 阿里云 + * + */ +public interface AliyunGroup { +} diff --git a/src/main/java/com/sqx/common/validator/group/QcloudGroup.java b/src/main/java/com/sqx/common/validator/group/QcloudGroup.java new file mode 100644 index 0000000..323a9ce --- /dev/null +++ b/src/main/java/com/sqx/common/validator/group/QcloudGroup.java @@ -0,0 +1,8 @@ +package com.sqx.common.validator.group; + +/** + * 腾讯云 + * + */ +public interface QcloudGroup { +} diff --git a/src/main/java/com/sqx/common/validator/group/QiniuGroup.java b/src/main/java/com/sqx/common/validator/group/QiniuGroup.java new file mode 100644 index 0000000..17ab553 --- /dev/null +++ b/src/main/java/com/sqx/common/validator/group/QiniuGroup.java @@ -0,0 +1,8 @@ +package com.sqx.common.validator.group; + +/** + * 七牛 + * + */ +public interface QiniuGroup { +} diff --git a/src/main/java/com/sqx/common/validator/group/UpdateGroup.java b/src/main/java/com/sqx/common/validator/group/UpdateGroup.java new file mode 100644 index 0000000..fa0a242 --- /dev/null +++ b/src/main/java/com/sqx/common/validator/group/UpdateGroup.java @@ -0,0 +1,10 @@ +package com.sqx.common.validator.group; + +/** + * 更新数据 Group + * + */ + +public interface UpdateGroup { + +} diff --git a/src/main/java/com/sqx/common/websocket/WebSocketMessage.java b/src/main/java/com/sqx/common/websocket/WebSocketMessage.java new file mode 100644 index 0000000..6dd687a --- /dev/null +++ b/src/main/java/com/sqx/common/websocket/WebSocketMessage.java @@ -0,0 +1,39 @@ +package com.sqx.common.websocket; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.util.Date; + +/** + * @description:WebSocketMessage + * @author:zc. + * @createData:2024-1-10 下午 4:21 + * @projectName:anmo + * @className:WebSocketMessage + * @packageName:com.sqx.websocket + */ +@Data +public class WebSocketMessage { + + /** + * 用户ID + */ + private String fromId; + + /** + * 对方ID + */ + private String toOtherId; + /** + * 消息内容 + */ + private String message; + + /** + * 发送时间 + */ + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + public Date date; + +} diff --git a/src/main/java/com/sqx/common/websocket/WebSocketServer.java b/src/main/java/com/sqx/common/websocket/WebSocketServer.java new file mode 100644 index 0000000..e60ca14 --- /dev/null +++ b/src/main/java/com/sqx/common/websocket/WebSocketServer.java @@ -0,0 +1,140 @@ +package com.sqx.common.websocket; + + +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.sqx.modules.artificer.dao.ArtificerDao; +import com.sqx.modules.artificer.dao.UserRechargeDao; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.UserRecharge; +import com.sqx.modules.common.dao.CommonInfoDao; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import javax.websocket.*; +import javax.websocket.server.PathParam; +import javax.websocket.server.ServerEndpoint; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Date; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArraySet; + +/** + * @description:WebSocketServer 操作类 + * @author:zc. + * @createData:2024-1-10 下午 4:21 + * @projectName:anmo + * @className:WebSocketServer + * @packageName:com.sqx.websocket + */ +@ServerEndpoint("/ws/{userId}") +@Component +@Slf4j +public class WebSocketServer { + + @Autowired + private ArtificerDao artificerDao; + @Autowired + private UserRechargeDao userRechargeDao; + @Autowired + private CommonInfoDao commonInfoDao; + //静态初始化 + public static WebSocketServer webSocketServer; + + //保证Bean初始化前已经装配了属性 + @PostConstruct + public void init() { + webSocketServer = this; + } + + // 与某个客户端的连接会话,需要通过它来给客户端发送数据 + private String userId; + + + // session集合,存放对应的session + private static ConcurrentHashMap sessionPool = new ConcurrentHashMap<>(); + + // concurrent包的线程安全Set,用来存放每个客户端对应的WebSocket对象。 + private static CopyOnWriteArraySet webSocketSet = new CopyOnWriteArraySet<>(); + + /** + * 建立WebSocket连接 + * + * @param session + * @param userId 用户ID + */ + @OnOpen + public void onOpen(Session session, @PathParam(value = "userId") String userId) { + log.info("WebSocket建立连接中,连接用户ID:{}", userId); + try { + Session historySession = sessionPool.get(userId); + // historySession不为空,说明已经有人登陆账号,应该删除登陆的WebSocket对象 + if (historySession != null) { + webSocketSet.remove(historySession); + historySession.close(); + } + } catch (IOException e) { + log.error("重复登录异常,错误信息:" + e.getMessage(), e); + } + // 建立连接 + this.userId = userId; + webSocketSet.add(this); + sessionPool.put(userId, session); + log.info("建立连接完成,当前在线人数为:{}", webSocketSet.size()); + } + + /** + * 发生错误 + * + * @param throwable e + */ + @OnError + public void onError(Throwable throwable) { + throwable.printStackTrace(); + } + + /** + * 连接关闭 + */ + @OnClose + public void onClose() { + turnOffTheGoLive(this.userId); + webSocketSet.remove(this); + sessionPool.remove(this.userId); + log.info("连接断开,当前在线人数为:{}", webSocketSet.size()); + } + + + /** + * 技师在线强制退出应用,改为离线状态 + * + * @param userId 技师id + */ + public void turnOffTheGoLive(String userId) { + Artificer artificer = webSocketServer.artificerDao.selectOne(Wrappers.lambdaUpdate().eq(Artificer::getUserId, userId)); + Artificer artificerUpd = new Artificer(); + artificerUpd.setStatus(2); + artificerUpd.setArtificerId(artificer.getArtificerId()); + webSocketServer.artificerDao.updateById(artificerUpd); + + Integer i = Integer.valueOf(webSocketServer.commonInfoDao.findOne(100000).getValue()); + Date upTime = artificer.getUpTime(); + long betweenDay = DateUtil.between(upTime, new Date(), DateUnit.MINUTE); + int i1 = new Long(betweenDay).intValue(); + int count = i1 / i; + for (int i2 = 0; i2 < count; i2++) { + UserRecharge userRecharge = new UserRecharge(); + userRecharge.setArtificerId(artificer.getArtificerId().intValue()); + userRecharge.setUserRecharge(new BigDecimal("1")); + userRecharge.setType("1"); + upTime = DateUtil.offsetMinute(upTime, i); + userRecharge.setCreateTime(upTime.toString()); + webSocketServer.userRechargeDao.insert(userRecharge); + } + + } +} \ No newline at end of file diff --git a/src/main/java/com/sqx/common/xss/HTMLFilter.java b/src/main/java/com/sqx/common/xss/HTMLFilter.java new file mode 100644 index 0000000..1cc0e4f --- /dev/null +++ b/src/main/java/com/sqx/common/xss/HTMLFilter.java @@ -0,0 +1,526 @@ +package com.sqx.common.xss; + +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * HTML filtering utility for protecting against XSS (Cross Site Scripting). + * + * This code is licensed LGPLv3 + * + * This code is a Java port of the original work in PHP by Cal Hendersen. + * http://code.iamcal.com/php/lib_filter/ + * + * The trickiest part of the translation was handling the differences in regex handling + * between PHP and Java. These resources were helpful in the process: + * + * http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html + * http://us2.php.net/manual/en/reference.pcre.pattern.modifiers.php + * http://www.regular-expressions.info/modifiers.html + * + * A note on naming conventions: instance variables are prefixed with a "v"; global + * constants are in all caps. + * + * Sample use: + * String input = ... + * String clean = new HTMLFilter().filter( input ); + * + * The class is not thread safe. Create a new instance if in doubt. + * + * If you find bugs or have suggestions on improvement (especially regarding + * performance), please contact us. The latest version of this + * source, and our contact details, can be found at http://xss-html-filter.sf.net + * + * @author Joseph O'Connell + * @author Cal Hendersen + * @author Michael Semb Wever + */ +public final class HTMLFilter { + + /** regex flag union representing /si modifiers in php **/ + private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL; + private static final Pattern P_COMMENTS = Pattern.compile("", Pattern.DOTALL); + private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI); + private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL); + private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI); + private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI); + private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI); + private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI); + private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI); + private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?"); + private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?"); + private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?"); + private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))"); + private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL); + private static final Pattern P_END_ARROW = Pattern.compile("^>"); + private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_AMP = Pattern.compile("&"); + private static final Pattern P_QUOTE = Pattern.compile("<"); + private static final Pattern P_LEFT_ARROW = Pattern.compile("<"); + private static final Pattern P_RIGHT_ARROW = Pattern.compile(">"); + private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>"); + + // @xxx could grow large... maybe use sesat's ReferenceMap + private static final ConcurrentMap P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap(); + private static final ConcurrentMap P_REMOVE_SELF_BLANKS = new ConcurrentHashMap(); + + /** set of allowed html elements, along with allowed attributes for each element **/ + private final Map> vAllowed; + /** counts of open tags for each (allowable) html element **/ + private final Map vTagCounts = new HashMap(); + + /** html elements which must always be self-closing (e.g. "") **/ + private final String[] vSelfClosingTags; + /** html elements which must always have separate opening and closing tags (e.g. "") **/ + private final String[] vNeedClosingTags; + /** set of disallowed html elements **/ + private final String[] vDisallowed; + /** attributes which should be checked for valid protocols **/ + private final String[] vProtocolAtts; + /** allowed protocols **/ + private final String[] vAllowedProtocols; + /** tags which should be removed if they contain no content (e.g. "" or "") **/ + private final String[] vRemoveBlanks; + /** entities allowed within html markup **/ + private final String[] vAllowedEntities; + /** flag determining whether comments are allowed in input String. */ + private final boolean stripComment; + private final boolean encodeQuotes; + private boolean vDebug = false; + /** + * flag determining whether to try to make tags when presented with "unbalanced" + * angle brackets (e.g. "" becomes " text "). If set to false, + * unbalanced angle brackets will be html escaped. + */ + private final boolean alwaysMakeTags; + + /** Default constructor. + * + */ + public HTMLFilter() { + vAllowed = new HashMap<>(); + + final ArrayList a_atts = new ArrayList(); + a_atts.add("href"); + a_atts.add("target"); + vAllowed.put("a", a_atts); + + final ArrayList img_atts = new ArrayList(); + img_atts.add("src"); + img_atts.add("width"); + img_atts.add("height"); + img_atts.add("alt"); + vAllowed.put("img", img_atts); + + final ArrayList no_atts = new ArrayList(); + vAllowed.put("b", no_atts); + vAllowed.put("strong", no_atts); + vAllowed.put("i", no_atts); + vAllowed.put("em", no_atts); + + vSelfClosingTags = new String[]{"img"}; + vNeedClosingTags = new String[]{"a", "b", "strong", "i", "em"}; + vDisallowed = new String[]{}; + vAllowedProtocols = new String[]{"http", "mailto", "https"}; // no ftp. + vProtocolAtts = new String[]{"src", "href"}; + vRemoveBlanks = new String[]{"a", "b", "strong", "i", "em"}; + vAllowedEntities = new String[]{"amp", "gt", "lt", "quot"}; + stripComment = true; + encodeQuotes = true; + alwaysMakeTags = true; + } + + /** Set debug flag to true. Otherwise use default settings. See the default constructor. + * + * @param debug turn debug on with a true argument + */ + public HTMLFilter(final boolean debug) { + this(); + vDebug = debug; + + } + + /** Map-parameter configurable constructor. + * + * @param conf map containing configuration. keys match field names. + */ + public HTMLFilter(final Map conf) { + + assert conf.containsKey("vAllowed") : "configuration requires vAllowed"; + assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags"; + assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags"; + assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed"; + assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols"; + assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts"; + assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks"; + assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities"; + + vAllowed = Collections.unmodifiableMap((HashMap>) conf.get("vAllowed")); + vSelfClosingTags = (String[]) conf.get("vSelfClosingTags"); + vNeedClosingTags = (String[]) conf.get("vNeedClosingTags"); + vDisallowed = (String[]) conf.get("vDisallowed"); + vAllowedProtocols = (String[]) conf.get("vAllowedProtocols"); + vProtocolAtts = (String[]) conf.get("vProtocolAtts"); + vRemoveBlanks = (String[]) conf.get("vRemoveBlanks"); + vAllowedEntities = (String[]) conf.get("vAllowedEntities"); + stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true; + encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true; + alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true; + } + + private void reset() { + vTagCounts.clear(); + } + + private void debug(final String msg) { + if (vDebug) { + Logger.getAnonymousLogger().info(msg); + } + } + + //--------------------------------------------------------------- + // my versions of some PHP library functions + public static String chr(final int decimal) { + return String.valueOf((char) decimal); + } + + public static String htmlSpecialChars(final String s) { + String result = s; + result = regexReplace(P_AMP, "&", result); + result = regexReplace(P_QUOTE, """, result); + result = regexReplace(P_LEFT_ARROW, "<", result); + result = regexReplace(P_RIGHT_ARROW, ">", result); + return result; + } + + //--------------------------------------------------------------- + /** + * given a user submitted input String, filter out any invalid or restricted + * html. + * + * @param input text (i.e. submitted by a user) than may contain html + * @return "clean" version of input, with only valid, whitelisted html elements allowed + */ + public String filter(final String input) { + reset(); + String s = input; + + debug("************************************************"); + debug(" INPUT: " + input); + + s = escapeComments(s); + debug(" escapeComments: " + s); + + s = balanceHTML(s); + debug(" balanceHTML: " + s); + + s = checkTags(s); + debug(" checkTags: " + s); + + s = processRemoveBlanks(s); + debug("processRemoveBlanks: " + s); + + s = validateEntities(s); + debug(" validateEntites: " + s); + + debug("************************************************\n\n"); + return s; + } + + public boolean isAlwaysMakeTags(){ + return alwaysMakeTags; + } + + public boolean isStripComments(){ + return stripComment; + } + + private String escapeComments(final String s) { + final Matcher m = P_COMMENTS.matcher(s); + final StringBuffer buf = new StringBuffer(); + if (m.find()) { + final String match = m.group(1); //(.*?) + m.appendReplacement(buf, Matcher.quoteReplacement("")); + } + m.appendTail(buf); + + return buf.toString(); + } + + private String balanceHTML(String s) { + if (alwaysMakeTags) { + // + // try and form html + // + s = regexReplace(P_END_ARROW, "", s); + s = regexReplace(P_BODY_TO_END, "<$1>", s); + s = regexReplace(P_XML_CONTENT, "$1<$2", s); + + } else { + // + // escape stray brackets + // + s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s); + s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s); + + // + // the last regexp causes '<>' entities to appear + // (we need to do a lookahead assertion so that the last bracket can + // be used in the next pass of the regexp) + // + s = regexReplace(P_BOTH_ARROWS, "", s); + } + + return s; + } + + private String checkTags(String s) { + Matcher m = P_TAGS.matcher(s); + + final StringBuffer buf = new StringBuffer(); + while (m.find()) { + String replaceStr = m.group(1); + replaceStr = processTag(replaceStr); + m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr)); + } + m.appendTail(buf); + + s = buf.toString(); + + // these get tallied in processTag + // (remember to reset before subsequent calls to filter method) + for (String key : vTagCounts.keySet()) { + for (int ii = 0; ii < vTagCounts.get(key); ii++) { + s += ""; + } + } + + return s; + } + + private String processRemoveBlanks(final String s) { + String result = s; + for (String tag : vRemoveBlanks) { + if(!P_REMOVE_PAIR_BLANKS.containsKey(tag)){ + P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?>")); + } + result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result); + if(!P_REMOVE_SELF_BLANKS.containsKey(tag)){ + P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>")); + } + result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result); + } + + return result; + } + + private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) { + Matcher m = regex_pattern.matcher(s); + return m.replaceAll(replacement); + } + + private String processTag(final String s) { + // ending tags + Matcher m = P_END_TAG.matcher(s); + if (m.find()) { + final String name = m.group(1).toLowerCase(); + if (allowed(name)) { + if (!inArray(name, vSelfClosingTags)) { + if (vTagCounts.containsKey(name)) { + vTagCounts.put(name, vTagCounts.get(name) - 1); + return ""; + } + } + } + } + + // starting tags + m = P_START_TAG.matcher(s); + if (m.find()) { + final String name = m.group(1).toLowerCase(); + final String body = m.group(2); + String ending = m.group(3); + + //debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" ); + if (allowed(name)) { + String params = ""; + + final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body); + final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body); + final List paramNames = new ArrayList(); + final List paramValues = new ArrayList(); + while (m2.find()) { + paramNames.add(m2.group(1)); //([a-z0-9]+) + paramValues.add(m2.group(3)); //(.*?) + } + while (m3.find()) { + paramNames.add(m3.group(1)); //([a-z0-9]+) + paramValues.add(m3.group(3)); //([^\"\\s']+) + } + + String paramName, paramValue; + for (int ii = 0; ii < paramNames.size(); ii++) { + paramName = paramNames.get(ii).toLowerCase(); + paramValue = paramValues.get(ii); + + if (allowedAttribute(name, paramName)) { + if (inArray(paramName, vProtocolAtts)) { + paramValue = processParamProtocol(paramValue); + } + params += " " + paramName + "=\"" + paramValue + "\""; + } + } + + if (inArray(name, vSelfClosingTags)) { + ending = " /"; + } + + if (inArray(name, vNeedClosingTags)) { + ending = ""; + } + + if (ending == null || ending.length() < 1) { + if (vTagCounts.containsKey(name)) { + vTagCounts.put(name, vTagCounts.get(name) + 1); + } else { + vTagCounts.put(name, 1); + } + } else { + ending = " /"; + } + return "<" + name + params + ending + ">"; + } else { + return ""; + } + } + + // comments + m = P_COMMENT.matcher(s); + if (!stripComment && m.find()) { + return "<" + m.group() + ">"; + } + + return ""; + } + + private String processParamProtocol(String s) { + s = decodeEntities(s); + final Matcher m = P_PROTOCOL.matcher(s); + if (m.find()) { + final String protocol = m.group(1); + if (!inArray(protocol, vAllowedProtocols)) { + // bad protocol, turn into local anchor link instead + s = "#" + s.substring(protocol.length() + 1, s.length()); + if (s.startsWith("#//")) { + s = "#" + s.substring(3, s.length()); + } + } + } + + return s; + } + + private String decodeEntities(String s) { + StringBuffer buf = new StringBuffer(); + + Matcher m = P_ENTITY.matcher(s); + while (m.find()) { + final String match = m.group(1); + final int decimal = Integer.decode(match).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENTITY_UNICODE.matcher(s); + while (m.find()) { + final String match = m.group(1); + final int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENCODE.matcher(s); + while (m.find()) { + final String match = m.group(1); + final int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + s = validateEntities(s); + return s; + } + + private String validateEntities(final String s) { + StringBuffer buf = new StringBuffer(); + + // validate entities throughout the string + Matcher m = P_VALID_ENTITIES.matcher(s); + while (m.find()) { + final String one = m.group(1); //([^&;]*) + final String two = m.group(2); //(?=(;|&|$)) + m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two))); + } + m.appendTail(buf); + + return encodeQuotes(buf.toString()); + } + + private String encodeQuotes(final String s){ + if(encodeQuotes){ + StringBuffer buf = new StringBuffer(); + Matcher m = P_VALID_QUOTES.matcher(s); + while (m.find()) { + final String one = m.group(1); //(>|^) + final String two = m.group(2); //([^<]+?) + final String three = m.group(3); //(<|$) + m.appendReplacement(buf, Matcher.quoteReplacement(one + regexReplace(P_QUOTE, """, two) + three)); + } + m.appendTail(buf); + return buf.toString(); + }else{ + return s; + } + } + + private String checkEntity(final String preamble, final String term) { + + return ";".equals(term) && isValidEntity(preamble) + ? '&' + preamble + : "&" + preamble; + } + + private boolean isValidEntity(final String entity) { + return inArray(entity, vAllowedEntities); + } + + private static boolean inArray(final String s, final String[] array) { + for (String item : array) { + if (item != null && item.equals(s)) { + return true; + } + } + return false; + } + + private boolean allowed(final String name) { + return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed); + } + + private boolean allowedAttribute(final String name, final String paramName) { + return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName)); + } +} \ No newline at end of file diff --git a/src/main/java/com/sqx/common/xss/SQLFilter.java b/src/main/java/com/sqx/common/xss/SQLFilter.java new file mode 100644 index 0000000..b16ad39 --- /dev/null +++ b/src/main/java/com/sqx/common/xss/SQLFilter.java @@ -0,0 +1,41 @@ +package com.sqx.common.xss; + +import com.sqx.common.exception.SqxException; +import org.apache.commons.lang.StringUtils; + +/** + * SQL过滤 + * + */ +public class SQLFilter { + + /** + * SQL注入过滤 + * @param str 待验证的字符串 + */ + public static String sqlInject(String str){ + if(StringUtils.isBlank(str)){ + return null; + } + //去掉'|"|;|\字符 + str = StringUtils.replace(str, "'", ""); + str = StringUtils.replace(str, "\"", ""); + str = StringUtils.replace(str, ";", ""); + str = StringUtils.replace(str, "\\", ""); + + //转换成小写 + str = str.toLowerCase(); + + //非法字符 + String[] keywords = {"master", "truncate", "insert", "select", "delete", "update", "declare", "alter", "drop"}; + + //判断是否包含非法字符 + for(String keyword : keywords){ + if(str.indexOf(keyword) != -1){ + throw new SqxException("包含非法字符"); + } + } + + return str; + } +} diff --git a/src/main/java/com/sqx/common/xss/XssFilter.java b/src/main/java/com/sqx/common/xss/XssFilter.java new file mode 100644 index 0000000..2ece381 --- /dev/null +++ b/src/main/java/com/sqx/common/xss/XssFilter.java @@ -0,0 +1,46 @@ +package com.sqx.common.xss; + +import javax.servlet.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * XSS过滤 + * + */ +public class XssFilter implements Filter { + + @Override + public void init(FilterConfig config) throws ServletException { + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + HttpServletRequest hreq = (HttpServletRequest) request; + HttpServletResponse hresp = (HttpServletResponse) response; + + //跨域 + hresp.setHeader("Access-Control-Allow-Origin", "*"); + + + //跨域 Header + + hresp.setHeader("Access-Control-Allow-Methods", "*"); + + hresp.setHeader("Access-Control-Allow-Headers", "*"); + + // Filter 只是链式处理,请求依然转发到目的地址。 + + chain.doFilter(request, response); + /*XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper( + (HttpServletRequest) request); + chain.doFilter(xssRequest, response);*/ + } + + @Override + public void destroy() { + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/common/xss/XssHttpServletRequestWrapper.java b/src/main/java/com/sqx/common/xss/XssHttpServletRequestWrapper.java new file mode 100644 index 0000000..d9700e9 --- /dev/null +++ b/src/main/java/com/sqx/common/xss/XssHttpServletRequestWrapper.java @@ -0,0 +1,138 @@ +package com.sqx.common.xss; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; + +import javax.servlet.ReadListener; +import javax.servlet.ServletInputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * XSS过滤处理 + * + */ +public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { + //没被包装过的HttpServletRequest(特殊场景,需要自己过滤) + HttpServletRequest orgRequest; + //html过滤 + private final static HTMLFilter HtmlFilter = new HTMLFilter(); + + public XssHttpServletRequestWrapper(HttpServletRequest request) { + super(request); + orgRequest = request; + } + + @Override + public ServletInputStream getInputStream() throws IOException { + //非json类型,直接返回 + if(!MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(super.getHeader(HttpHeaders.CONTENT_TYPE))){ + return super.getInputStream(); + } + + //为空,直接返回 + String json = IOUtils.toString(super.getInputStream(), "utf-8"); + if (StringUtils.isBlank(json)) { + return super.getInputStream(); + } + + //xss过滤 + json = xssEncode(json); + final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf-8")); + return new ServletInputStream() { + @Override + public boolean isFinished() { + return true; + } + + @Override + public boolean isReady() { + return true; + } + + @Override + public void setReadListener(ReadListener readListener) { + + } + + @Override + public int read() throws IOException { + return bis.read(); + } + }; + } + + @Override + public String getParameter(String name) { + String value = super.getParameter(xssEncode(name)); + if (StringUtils.isNotBlank(value)) { + value = xssEncode(value); + } + return value; + } + + @Override + public String[] getParameterValues(String name) { + String[] parameters = super.getParameterValues(name); + if (parameters == null || parameters.length == 0) { + return null; + } + + for (int i = 0; i < parameters.length; i++) { + parameters[i] = xssEncode(parameters[i]); + } + return parameters; + } + + @Override + public Map getParameterMap() { + Map map = new LinkedHashMap<>(); + Map parameters = super.getParameterMap(); + for (String key : parameters.keySet()) { + String[] values = parameters.get(key); + for (int i = 0; i < values.length; i++) { + values[i] = xssEncode(values[i]); + } + map.put(key, values); + } + return map; + } + + @Override + public String getHeader(String name) { + String value = super.getHeader(xssEncode(name)); + if (StringUtils.isNotBlank(value)) { + value = xssEncode(value); + } + return value; + } + + private String xssEncode(String input) { + return HtmlFilter.filter(input); + } + + /** + * 获取最原始的request + */ + public HttpServletRequest getOrgRequest() { + return orgRequest; + } + + /** + * 获取最原始的request + */ + public static HttpServletRequest getOrgRequest(HttpServletRequest request) { + if (request instanceof XssHttpServletRequestWrapper) { + return ((XssHttpServletRequestWrapper) request).getOrgRequest(); + } + + return request; + } + +} diff --git a/src/main/java/com/sqx/config/CorsConfig.java b/src/main/java/com/sqx/config/CorsConfig.java new file mode 100644 index 0000000..781ce11 --- /dev/null +++ b/src/main/java/com/sqx/config/CorsConfig.java @@ -0,0 +1,47 @@ +package com.sqx.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + + +/** + * 跨域设置 + */ +@Configuration +public class CorsConfig implements WebMvcConfigurer { + + /*private CorsConfiguration buildConfig() { + CorsConfiguration corsConfiguration = new CorsConfiguration(); + // 1允许任何域名使用 + corsConfiguration.addAllowedOrigin("*"); + // 2允许任何头 + corsConfiguration.addAllowedHeader("*"); + // 3允许任何方法(post、get等) + corsConfiguration.addAllowedMethod("*"); + return corsConfiguration; + } + + @Bean + public CorsFilter corsFilter() { + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + source.registerCorsConfiguration("/**", buildConfig()); + return new CorsFilter(source); + }*/ + + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOriginPatterns("*") + .allowCredentials(true) + .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") + .maxAge(3600); + } + + +} diff --git a/src/main/java/com/sqx/config/FilterConfig.java b/src/main/java/com/sqx/config/FilterConfig.java new file mode 100644 index 0000000..778e0b2 --- /dev/null +++ b/src/main/java/com/sqx/config/FilterConfig.java @@ -0,0 +1,40 @@ +package com.sqx.config; + +import com.sqx.common.xss.XssFilter; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.filter.DelegatingFilterProxy; + +import javax.servlet.DispatcherType; + +/** + * Filter配置 + * + */ +@Configuration +public class FilterConfig { + + @Bean + public FilterRegistrationBean shiroFilterRegistration() { + FilterRegistrationBean registration = new FilterRegistrationBean(); + registration.setFilter(new DelegatingFilterProxy("shiroFilter")); + //该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理 + registration.addInitParameter("targetFilterLifecycle", "true"); + registration.setEnabled(true); + registration.setOrder(Integer.MAX_VALUE - 1); + registration.addUrlPatterns("/*"); + return registration; + } + + @Bean + public FilterRegistrationBean xssFilterRegistration() { + FilterRegistrationBean registration = new FilterRegistrationBean(); + registration.setDispatcherTypes(DispatcherType.REQUEST); + registration.setFilter(new XssFilter()); + registration.addUrlPatterns("/*"); + registration.setName("xssFilter"); + registration.setOrder(Integer.MAX_VALUE); + return registration; + } +} diff --git a/src/main/java/com/sqx/config/KaptchaConfig.java b/src/main/java/com/sqx/config/KaptchaConfig.java new file mode 100644 index 0000000..ea8c936 --- /dev/null +++ b/src/main/java/com/sqx/config/KaptchaConfig.java @@ -0,0 +1,30 @@ +package com.sqx.config; + +import com.google.code.kaptcha.impl.DefaultKaptcha; +import com.google.code.kaptcha.util.Config; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Properties; + + +/** + * 生成验证码配置 + * + */ +@Configuration +public class KaptchaConfig { + + @Bean + public DefaultKaptcha producer() { + Properties properties = new Properties(); + properties.put("kaptcha.border", "no"); + properties.put("kaptcha.textproducer.font.color", "black"); + properties.put("kaptcha.textproducer.char.space", "5"); + properties.put("kaptcha.textproducer.font.names", "Arial,Courier,cmr10,宋体,楷体,微软雅黑"); + Config config = new Config(properties); + DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); + defaultKaptcha.setConfig(config); + return defaultKaptcha; + } +} diff --git a/src/main/java/com/sqx/config/MybatisPlusConfig.java b/src/main/java/com/sqx/config/MybatisPlusConfig.java new file mode 100644 index 0000000..97edf00 --- /dev/null +++ b/src/main/java/com/sqx/config/MybatisPlusConfig.java @@ -0,0 +1,22 @@ +package com.sqx.config; + +import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * mybatis-plus配置 + * + */ +@Configuration +public class MybatisPlusConfig { + + /** + * 分页插件 + */ + @Bean + public PaginationInterceptor paginationInterceptor() { + return new PaginationInterceptor(); + } + +} diff --git a/src/main/java/com/sqx/config/RedisConfig.java b/src/main/java/com/sqx/config/RedisConfig.java new file mode 100644 index 0000000..deb93e2 --- /dev/null +++ b/src/main/java/com/sqx/config/RedisConfig.java @@ -0,0 +1,54 @@ +package com.sqx.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.*; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +/** + * Redis配置 + * + */ +@Configuration +public class RedisConfig { + @Autowired + private RedisConnectionFactory factory; + + @Bean + public RedisTemplate redisTemplate() { + RedisTemplate redisTemplate = new RedisTemplate<>(); + redisTemplate.setKeySerializer(new StringRedisSerializer()); + redisTemplate.setHashKeySerializer(new StringRedisSerializer()); + redisTemplate.setHashValueSerializer(new StringRedisSerializer()); + redisTemplate.setValueSerializer(new StringRedisSerializer()); + redisTemplate.setConnectionFactory(factory); + return redisTemplate; + } + + @Bean + public HashOperations hashOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForHash(); + } + + @Bean + public ValueOperations valueOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForValue(); + } + + @Bean + public ListOperations listOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForList(); + } + + @Bean + public SetOperations setOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForSet(); + } + + @Bean + public ZSetOperations zSetOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForZSet(); + } +} diff --git a/src/main/java/com/sqx/config/ShiroConfig.java b/src/main/java/com/sqx/config/ShiroConfig.java new file mode 100644 index 0000000..bb181fe --- /dev/null +++ b/src/main/java/com/sqx/config/ShiroConfig.java @@ -0,0 +1,106 @@ +package com.sqx.config; + +import com.sqx.modules.sys.oauth2.OAuth2Filter; +import com.sqx.modules.sys.oauth2.OAuth2Realm; +import org.apache.shiro.mgt.SecurityManager; +import org.apache.shiro.spring.LifecycleBeanPostProcessor; +import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor; +import org.apache.shiro.spring.web.ShiroFilterFactoryBean; +import org.apache.shiro.web.mgt.DefaultWebSecurityManager; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.servlet.Filter; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * Shiro配置 + * + */ +@Configuration +public class ShiroConfig { + + @Bean("securityManager") + public SecurityManager securityManager(OAuth2Realm oAuth2Realm) { + DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); + securityManager.setRealm(oAuth2Realm); + securityManager.setRememberMeManager(null); + return securityManager; + } + + @Bean("shiroFilter") + public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager) { + ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean(); + shiroFilter.setSecurityManager(securityManager); + + //oauth过滤 + Map filters = new HashMap<>(); + filters.put("oauth2", new OAuth2Filter()); + shiroFilter.setFilters(filters); + + Map filterMap = new LinkedHashMap<>(); + filterMap.put("/webjars/**", "anon"); + filterMap.put("/druid/**", "anon"); + + filterMap.put("/advert/list", "anon"); + filterMap.put("/goods/recommend", "anon"); + filterMap.put("/selfActivity/state", "anon"); + filterMap.put("/goods/homeGoods", "anon"); + filterMap.put("/goods/find", "anon"); + filterMap.put("/goods/selectGoods", "anon"); + filterMap.put("/selfActivity/list", "anon"); + filterMap.put("/pay/**", "anon"); + filterMap.put("/aliPay/**", "anon"); + filterMap.put("/order/**", "anon"); + filterMap.put("/pays/notifyPay", "anon"); + filterMap.put("/selfGoodsBrand/find", "anon"); + filterMap.put("/selfGoodsComment/list", "anon"); + filterMap.put("/selfGoodsComment/count", "anon"); + filterMap.put("/selfGoodsComment/findByOrderId", "anon"); + filterMap.put("/selfGoodsComment/find", "anon"); + filterMap.put("/goods/brandList", "anon"); + + + filterMap.put("/app/wxPay/notifyJsApi", "anon"); + filterMap.put("/app/wxPay/notifyMp", "anon"); + filterMap.put("/app/wxPay/notify", "anon"); + filterMap.put("/app/aliPay/notifyApp", "anon"); + filterMap.put("/app/**", "anon"); + filterMap.put("/activity/**", "anon"); + filterMap.put("/banner/**", "anon"); + filterMap.put("/courseClassification/selectCourseClassification", "anon"); + filterMap.put("/sys/login", "anon"); + filterMap.put("/swagger/**", "anon"); + filterMap.put("/v2/api-docs", "anon"); + filterMap.put("/swagger-ui.html", "anon"); + filterMap.put("/swagger-resources/**", "anon"); + filterMap.put("/captcha.jpg", "anon"); + filterMap.put("/chatSocket/**", "anon"); + filterMap.put("/websocket/**", "anon"); + filterMap.put("/mapWebsocket/**", "anon"); + filterMap.put("/monitorWebSocket/**", "anon"); + filterMap.put("/search/**", "anon"); + filterMap.put("/alioss/**","anon"); + filterMap.put("/ws/**","anon"); + filterMap.put("/doc.html/**","anon"); + filterMap.put("/**", "oauth2"); + shiroFilter.setFilterChainDefinitionMap(filterMap); + + return shiroFilter; + } + + @Bean("lifecycleBeanPostProcessor") + public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() { + return new LifecycleBeanPostProcessor(); + } + + @Bean + public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) { + AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor(); + advisor.setSecurityManager(securityManager); + return advisor; + } + +} diff --git a/src/main/java/com/sqx/config/SwaggerConfig.java b/src/main/java/com/sqx/config/SwaggerConfig.java new file mode 100644 index 0000000..f573a38 --- /dev/null +++ b/src/main/java/com/sqx/config/SwaggerConfig.java @@ -0,0 +1,55 @@ +package com.sqx.config; + +import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; +import io.swagger.annotations.ApiOperation; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.ApiKey; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import java.util.List; + +import static com.google.common.collect.Lists.newArrayList; + +@Configuration +@EnableSwagger2 +@EnableKnife4j +public class SwaggerConfig implements WebMvcConfigurer { + + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select() + //加了ApiOperation注解的类,才生成接口文档 + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + //包下的类,才生成接口文档 + //.apis(RequestHandlerSelectors.basePackage("com.sqx.controller")) + .paths(PathSelectors.any()) + .build() + .securitySchemes(security()); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("") + .description("sqx-fast文档") + .termsOfServiceUrl("") + .version("3.0.0") + .build(); + } + + private List security() { + return newArrayList( + new ApiKey("token", "token", "header") + ); + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/datasource/annotation/DataSource.java b/src/main/java/com/sqx/datasource/annotation/DataSource.java new file mode 100644 index 0000000..082da71 --- /dev/null +++ b/src/main/java/com/sqx/datasource/annotation/DataSource.java @@ -0,0 +1,14 @@ +package com.sqx.datasource.annotation; + +import java.lang.annotation.*; + +/** + * 多数据源注解 + */ +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface DataSource { + String value() default ""; +} diff --git a/src/main/java/com/sqx/datasource/aspect/DataSourceAspect.java b/src/main/java/com/sqx/datasource/aspect/DataSourceAspect.java new file mode 100644 index 0000000..b3c5d0a --- /dev/null +++ b/src/main/java/com/sqx/datasource/aspect/DataSourceAspect.java @@ -0,0 +1,61 @@ +package com.sqx.datasource.aspect; + + +import com.sqx.datasource.annotation.DataSource; +import com.sqx.datasource.config.DynamicContextHolder; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.Ordered; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +import java.lang.reflect.Method; + +/** + * 多数据源,切面处理类 + */ +@Aspect +@Component +@Order(Ordered.HIGHEST_PRECEDENCE) +public class DataSourceAspect { + protected Logger logger = LoggerFactory.getLogger(getClass()); + + @Pointcut("@annotation(com.sqx.datasource.annotation.DataSource) " + + "|| @within(com.sqx.datasource.annotation.DataSource)") + public void dataSourcePointCut() { + + } + + @Around("dataSourcePointCut()") + public Object around(ProceedingJoinPoint point) throws Throwable { + MethodSignature signature = (MethodSignature) point.getSignature(); + Class targetClass = point.getTarget().getClass(); + Method method = signature.getMethod(); + + DataSource targetDataSource = (DataSource)targetClass.getAnnotation(DataSource.class); + DataSource methodDataSource = method.getAnnotation(DataSource.class); + if(targetDataSource != null || methodDataSource != null){ + String value; + if(methodDataSource != null){ + value = methodDataSource.value(); + }else { + value = targetDataSource.value(); + } + + DynamicContextHolder.push(value); + logger.debug("set datasource is {}", value); + } + + try { + return point.proceed(); + } finally { + DynamicContextHolder.poll(); + logger.debug("clean datasource"); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/sqx/datasource/config/DynamicContextHolder.java b/src/main/java/com/sqx/datasource/config/DynamicContextHolder.java new file mode 100644 index 0000000..f059bf7 --- /dev/null +++ b/src/main/java/com/sqx/datasource/config/DynamicContextHolder.java @@ -0,0 +1,47 @@ +package com.sqx.datasource.config; + +import java.util.ArrayDeque; +import java.util.Deque; + +/** + * 多数据源上下文 + */ +public class DynamicContextHolder { + @SuppressWarnings("unchecked") + private static final ThreadLocal> CONTEXT_HOLDER = new ThreadLocal() { + @Override + protected Object initialValue() { + return new ArrayDeque(); + } + }; + + /** + * 获得当前线程数据源 + * + * @return 数据源名称 + */ + public static String peek() { + return CONTEXT_HOLDER.get().peek(); + } + + /** + * 设置当前线程数据源 + * + * @param dataSource 数据源名称 + */ + public static void push(String dataSource) { + CONTEXT_HOLDER.get().push(dataSource); + } + + /** + * 清空当前线程数据源 + */ + public static void poll() { + Deque deque = CONTEXT_HOLDER.get(); + deque.poll(); + if (deque.isEmpty()) { + CONTEXT_HOLDER.remove(); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/datasource/config/DynamicDataSource.java b/src/main/java/com/sqx/datasource/config/DynamicDataSource.java new file mode 100644 index 0000000..4374032 --- /dev/null +++ b/src/main/java/com/sqx/datasource/config/DynamicDataSource.java @@ -0,0 +1,15 @@ +package com.sqx.datasource.config; + +import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; + +/** + * 多数据源 + */ +public class DynamicDataSource extends AbstractRoutingDataSource { + + @Override + protected Object determineCurrentLookupKey() { + return DynamicContextHolder.peek(); + } + +} diff --git a/src/main/java/com/sqx/datasource/config/DynamicDataSourceConfig.java b/src/main/java/com/sqx/datasource/config/DynamicDataSourceConfig.java new file mode 100644 index 0000000..9c1033f --- /dev/null +++ b/src/main/java/com/sqx/datasource/config/DynamicDataSourceConfig.java @@ -0,0 +1,53 @@ +package com.sqx.datasource.config; + +import com.alibaba.druid.pool.DruidDataSource; +import com.sqx.datasource.properties.DataSourceProperties; +import com.sqx.datasource.properties.DynamicDataSourceProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.HashMap; +import java.util.Map; + +/** + * 配置多数据源 + */ +@Configuration +@EnableConfigurationProperties(DynamicDataSourceProperties.class) +public class DynamicDataSourceConfig { + @Autowired + private DynamicDataSourceProperties properties; + + @Bean + @ConfigurationProperties(prefix = "spring.datasource.druid") + public DataSourceProperties dataSourceProperties() { + return new DataSourceProperties(); + } + + @Bean + public DynamicDataSource dynamicDataSource(DataSourceProperties dataSourceProperties) { + DynamicDataSource dynamicDataSource = new DynamicDataSource(); + dynamicDataSource.setTargetDataSources(getDynamicDataSource()); + + //默认数据源 + DruidDataSource defaultDataSource = DynamicDataSourceFactory.buildDruidDataSource(dataSourceProperties); + dynamicDataSource.setDefaultTargetDataSource(defaultDataSource); + + return dynamicDataSource; + } + + private Map getDynamicDataSource(){ + Map dataSourcePropertiesMap = properties.getDatasource(); + Map targetDataSources = new HashMap<>(dataSourcePropertiesMap.size()); + dataSourcePropertiesMap.forEach((k, v) -> { + DruidDataSource druidDataSource = DynamicDataSourceFactory.buildDruidDataSource(v); + targetDataSources.put(k, druidDataSource); + }); + + return targetDataSources; + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/datasource/config/DynamicDataSourceFactory.java b/src/main/java/com/sqx/datasource/config/DynamicDataSourceFactory.java new file mode 100644 index 0000000..b506b40 --- /dev/null +++ b/src/main/java/com/sqx/datasource/config/DynamicDataSourceFactory.java @@ -0,0 +1,44 @@ +package com.sqx.datasource.config; + +import com.alibaba.druid.pool.DruidDataSource; +import com.sqx.datasource.properties.DataSourceProperties; + +import java.sql.SQLException; + +/** + * DruidDataSource + * + */ +public class DynamicDataSourceFactory { + + public static DruidDataSource buildDruidDataSource(DataSourceProperties properties) { + DruidDataSource druidDataSource = new DruidDataSource(); + druidDataSource.setDriverClassName(properties.getDriverClassName()); + druidDataSource.setUrl(properties.getUrl()); + druidDataSource.setUsername(properties.getUsername()); + druidDataSource.setPassword(properties.getPassword()); + + druidDataSource.setInitialSize(properties.getInitialSize()); + druidDataSource.setMaxActive(properties.getMaxActive()); + druidDataSource.setMinIdle(properties.getMinIdle()); + druidDataSource.setMaxWait(properties.getMaxWait()); + druidDataSource.setTimeBetweenEvictionRunsMillis(properties.getTimeBetweenEvictionRunsMillis()); + druidDataSource.setMinEvictableIdleTimeMillis(properties.getMinEvictableIdleTimeMillis()); + druidDataSource.setMaxEvictableIdleTimeMillis(properties.getMaxEvictableIdleTimeMillis()); + druidDataSource.setValidationQuery(properties.getValidationQuery()); + druidDataSource.setValidationQueryTimeout(properties.getValidationQueryTimeout()); + druidDataSource.setTestOnBorrow(properties.isTestOnBorrow()); + druidDataSource.setTestOnReturn(properties.isTestOnReturn()); + druidDataSource.setPoolPreparedStatements(properties.isPoolPreparedStatements()); + druidDataSource.setMaxOpenPreparedStatements(properties.getMaxOpenPreparedStatements()); + druidDataSource.setSharePreparedStatements(properties.isSharePreparedStatements()); + + try { + druidDataSource.setFilters(properties.getFilters()); + druidDataSource.init(); + } catch (SQLException e) { + e.printStackTrace(); + } + return druidDataSource; + } +} \ No newline at end of file diff --git a/src/main/java/com/sqx/datasource/properties/DataSourceProperties.java b/src/main/java/com/sqx/datasource/properties/DataSourceProperties.java new file mode 100644 index 0000000..0cc4fc4 --- /dev/null +++ b/src/main/java/com/sqx/datasource/properties/DataSourceProperties.java @@ -0,0 +1,192 @@ +package com.sqx.datasource.properties; + +/** + * 多数据源属性 + * + */ +public class DataSourceProperties { + private String driverClassName; + private String url; + private String username; + private String password; + + /** + * Druid默认参数 + */ + private int initialSize = 2; + private int maxActive = 10; + private int minIdle = -1; + private long maxWait = 60 * 1000L; + private long timeBetweenEvictionRunsMillis = 60 * 1000L; + private long minEvictableIdleTimeMillis = 1000L * 60L * 30L; + private long maxEvictableIdleTimeMillis = 1000L * 60L * 60L * 7; + private String validationQuery = "select 1"; + private int validationQueryTimeout = -1; + private boolean testOnBorrow = false; + private boolean testOnReturn = false; + private boolean testWhileIdle = true; + private boolean poolPreparedStatements = false; + private int maxOpenPreparedStatements = -1; + private boolean sharePreparedStatements = false; + private String filters = "stat,wall"; + + public String getDriverClassName() { + return driverClassName; + } + + public void setDriverClassName(String driverClassName) { + this.driverClassName = driverClassName; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public int getInitialSize() { + return initialSize; + } + + public void setInitialSize(int initialSize) { + this.initialSize = initialSize; + } + + public int getMaxActive() { + return maxActive; + } + + public void setMaxActive(int maxActive) { + this.maxActive = maxActive; + } + + public int getMinIdle() { + return minIdle; + } + + public void setMinIdle(int minIdle) { + this.minIdle = minIdle; + } + + public long getMaxWait() { + return maxWait; + } + + public void setMaxWait(long maxWait) { + this.maxWait = maxWait; + } + + public long getTimeBetweenEvictionRunsMillis() { + return timeBetweenEvictionRunsMillis; + } + + public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) { + this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis; + } + + public long getMinEvictableIdleTimeMillis() { + return minEvictableIdleTimeMillis; + } + + public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) { + this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis; + } + + public long getMaxEvictableIdleTimeMillis() { + return maxEvictableIdleTimeMillis; + } + + public void setMaxEvictableIdleTimeMillis(long maxEvictableIdleTimeMillis) { + this.maxEvictableIdleTimeMillis = maxEvictableIdleTimeMillis; + } + + public String getValidationQuery() { + return validationQuery; + } + + public void setValidationQuery(String validationQuery) { + this.validationQuery = validationQuery; + } + + public int getValidationQueryTimeout() { + return validationQueryTimeout; + } + + public void setValidationQueryTimeout(int validationQueryTimeout) { + this.validationQueryTimeout = validationQueryTimeout; + } + + public boolean isTestOnBorrow() { + return testOnBorrow; + } + + public void setTestOnBorrow(boolean testOnBorrow) { + this.testOnBorrow = testOnBorrow; + } + + public boolean isTestOnReturn() { + return testOnReturn; + } + + public void setTestOnReturn(boolean testOnReturn) { + this.testOnReturn = testOnReturn; + } + + public boolean isTestWhileIdle() { + return testWhileIdle; + } + + public void setTestWhileIdle(boolean testWhileIdle) { + this.testWhileIdle = testWhileIdle; + } + + public boolean isPoolPreparedStatements() { + return poolPreparedStatements; + } + + public void setPoolPreparedStatements(boolean poolPreparedStatements) { + this.poolPreparedStatements = poolPreparedStatements; + } + + public int getMaxOpenPreparedStatements() { + return maxOpenPreparedStatements; + } + + public void setMaxOpenPreparedStatements(int maxOpenPreparedStatements) { + this.maxOpenPreparedStatements = maxOpenPreparedStatements; + } + + public boolean isSharePreparedStatements() { + return sharePreparedStatements; + } + + public void setSharePreparedStatements(boolean sharePreparedStatements) { + this.sharePreparedStatements = sharePreparedStatements; + } + + public String getFilters() { + return filters; + } + + public void setFilters(String filters) { + this.filters = filters; + } +} \ No newline at end of file diff --git a/src/main/java/com/sqx/datasource/properties/DynamicDataSourceProperties.java b/src/main/java/com/sqx/datasource/properties/DynamicDataSourceProperties.java new file mode 100644 index 0000000..ebd2a26 --- /dev/null +++ b/src/main/java/com/sqx/datasource/properties/DynamicDataSourceProperties.java @@ -0,0 +1,22 @@ +package com.sqx.datasource.properties; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * 多数据源属性 + */ +@ConfigurationProperties(prefix = "dynamic") +public class DynamicDataSourceProperties { + private Map datasource = new LinkedHashMap<>(); + + public Map getDatasource() { + return datasource; + } + + public void setDatasource(Map datasource) { + this.datasource = datasource; + } +} diff --git a/src/main/java/com/sqx/ffmpeg/FFmpeg.java b/src/main/java/com/sqx/ffmpeg/FFmpeg.java new file mode 100644 index 0000000..29a563f --- /dev/null +++ b/src/main/java/com/sqx/ffmpeg/FFmpeg.java @@ -0,0 +1,388 @@ +package com.sqx.ffmpeg; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.RuntimeUtil; +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.sound.sampled.*; +import java.io.*; +import java.util.Collections; +import java.util.List; + +@Component +@Slf4j +public class FFmpeg { + + @Value("${ffmpeg.core.executableFile}") + public String ffmpegPath; + + @Value("${business.audio.uploadPath}") + public String baseAudioUploadPath; + + + public void montageAudio(String inFilePath, String inFilePath2,String outPath){ + //montageAudioByJavaIo(inFilePath, inFilePath2, outPath); + montageAudioByFFmpeg(inFilePath, inFilePath2, outPath); + } + public void montageAudioByJavaIo(String inFilePath, String inFilePath2,String outPath){ + List audioFiles = Lists.newArrayList(); + audioFiles.add(new File(inFilePath)); + audioFiles.add(new File(inFilePath2)); + mergeAudioFiles(audioFiles, new File(outPath)); + } + + public void mergeAudioFiles(List audioFiles, File outputFile){ + if(audioFiles == null || audioFiles.isEmpty()){ + log.warn("待合并列表为空,不执行合并"); + return; + } + try { + List audioInputStreamList = Lists.newArrayList(); + AudioFormat audioFormat = null; + AudioInputStream audioInputStream = null; + + //读取音频文件,读取格式和流 + for (File audioFile : audioFiles) { + audioInputStream = AudioSystem.getAudioInputStream(audioFile); + audioFormat = audioInputStream.getFormat(); + if (audioFormat.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) { + audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, + audioFormat.getSampleRate(), + 16, + audioFormat.getChannels(), + audioFormat.getChannels() * 2, + audioFormat.getSampleRate(), + false); + audioInputStream = AudioSystem.getAudioInputStream(audioFormat, audioInputStream); + } + audioInputStreamList.add(audioInputStream); + } + AudioFormat newAudioFormat = new AudioFormat( + audioFormat.getEncoding(), + audioFormat.getSampleRate(), + audioFormat.getSampleSizeInBits(), + audioFormat.getChannels(), + audioFormat.getFrameSize(), + audioFormat.getFrameRate(), + audioFormat.isBigEndian() + ); +// AudioInputStream mergedAudioStream = new AudioInputStream( +// new SequenceInputStream(Collections.enumeration(audioInputStreamList)), +// newAudioFormat, +// audioInputStream.getFrameLength() +// ); + + AudioInputStream mergedAudioStream = new AudioInputStream( + new SequenceInputStream(Collections.enumeration(audioInputStreamList)), + newAudioFormat, + audioInputStream.getFrameLength() + + ); + + //合并后扔到输出文件里 + AudioSystem.write(mergedAudioStream, AudioFileFormat.Type.WAVE, outputFile); + //AudioSystem.write(mergedAudioStream, new AudioFileFormat.Type("MP3", "mp3"), outputFile); + + //Conv c = new Converter(); + //AudioFileWriter writer = (AudioFileWriter) + + //THeaderlessAudioFileWriter x = new THeaderlessAudioFileWriter(); + //MpegAudioFileWriter mpegAudioFileWriter = new MpegAudioFileWriter(); + //mpegAudioFileWriter.write(mergedAudioStream, MpegFileFormatType.MP3, outputFile); + + //new THeaderlessAudioFileWriter(null,null,null).write(null,null,null,null); + + //AudioSystem.write() + + + //AudioSystem.write(mergedAudioStream, MpegFileFormatType.MP3, outputFile); + //MpegFormatConversionProvider mpegFormatConversionProvider = new MpegFormatConversionProvider(); + //mpegFormatConversionProvider. + for (AudioInputStream ais: audioInputStreamList){ + ais.close(); + } + mergedAudioStream.close(); + } catch (IOException | UnsupportedAudioFileException e) { + log.error(e.getMessage(),e); + } + } + + + + //合并音频 + public void montageAudioByFFmpeg(String inFilePath, String inFilePath2,String outPath){ +// //ffmpeg -i 1.mp3 -i 2.mp3 -filter_complex "[0:a][1:a]concat=n=2:v=0:a=1[out]" -map "[out]" output.mp3 + List command = Lists.newArrayList(); + command.add(ffmpegPath); + command.add("-i"); + command.add(inFilePath); + command.add("-i"); + command.add(inFilePath2); + //command.add("-acodec copy"); + command.add("-filter_complex"); + command.add("[0:a][1:a]concat=n=2:v=0:a=1[out]"); + command.add("-map"); + command.add("[out]"); + command.add(outPath); + command.add("-y"); +// String[] commands = command.toArray(new String[]{}); +// +// StringBuilder sb = new StringBuilder(); +// sb.append(ffmpegPath); +// sb.append(" "); +// sb.append("-i"); +// sb.append(" "); +// sb.append(inFilePath); +// sb.append(" "); +// sb.append("-i"); +// sb.append(" "); +// sb.append(inFilePath2); +// sb.append(" "); +// sb.append("-filter_complex"); +// sb.append(" "); +// sb.append("\"[0:a][1:a]concat=n=2:v=0:a=1[out]\""); +// sb.append(" "); +// sb.append("-map"); +// sb.append(" "); +// sb.append("\"[out]\""); +// sb.append(" "); +// sb.append(outPath); +// sb.append(" -y");//强制覆盖 + log.info("执行此命令:{}",command); + //String res = RuntimeUtil.execForStr(sb.toString()); + + //手写吧。。。 + ProcessBuilder builder = new ProcessBuilder(command); + + + try { + Process process = builder.start(); +// int exitCode = process.exitValue(); + int exitCode = process.waitFor(); + if(exitCode == 0){ + log.info("正常退出!"); + }else{ + log.info("非正常退出!{}",exitCode); + } + InputStream is = process.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + String line; + while ((line = reader.readLine()) != null){ + log.info(line); + } + InputStream eis = process.getErrorStream(); + BufferedReader ereader = new BufferedReader(new InputStreamReader(eis)); + String eline; + while ((eline = ereader.readLine()) != null){ + log.info(eline); + } + process.destroy(); + } catch (IOException e) { + log.error("IO错误!"); + log.error(e.getMessage(),e); + } catch (InterruptedException e) { + log.error("中断错误!"); + log.error(e.getMessage(),e); + } + +// log.info("执行结果:{}",res); + } + + public static String getOsName(){ + return System.getProperty("os.name").toLowerCase(); + } + + public void mergeAllAudio(List inFilePathList,String outPath) { + if (inFilePathList == null || inFilePathList.isEmpty()) return; + if (StringUtils.isBlank(outPath)) return; + //ffmpeg -i "concat:01.mp3|02.mp3|03.mp3" -acodec copy testAll.mp3 + List command = Lists.newArrayList(); + command.add(ffmpegPath); + //多个 + for (String path : inFilePathList) { + command.add("-i"); + command.add(path); + } + command.add("-filter_complex");//过滤器 + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < inFilePathList.size(); i++) { + sb.append("[");sb.append(i);sb.append(":a]"); + } + sb.append("concat=n="); + sb.append(inFilePathList.size()); + sb.append(":v=0:a=1[out]"); + //[0:0] [1:0] [2:0] concat=n=3:v=0:a=1 [a] + //[0:0] [1:0] concat=n=${}:v=0:a=1 [a] + command.add(sb.toString()); + command.add("-map"); + command.add("[out]"); + command.add(outPath); + command.add("-y"); + log.info("执行此命令:{}",command); + //String res = RuntimeUtil.execForStr(sb.toString()); + + //手写吧。。。 + ProcessBuilder builder = new ProcessBuilder(command); + + try { + Process process = builder.start(); + int exitCode = process.waitFor(); + if(exitCode == 0){ + log.info("正常退出!"); + }else{ + log.info("非正常退出!{}",exitCode); + } + InputStream is = process.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + String line; + while ((line = reader.readLine()) != null){ + log.info(line); + } + InputStream eis = process.getErrorStream(); + BufferedReader ereader = new BufferedReader(new InputStreamReader(eis)); + String eline; + while ((eline = ereader.readLine()) != null){ + log.info(eline); + } + process.destroy(); + } catch (IOException e) { + log.error("IO错误!"); + log.error(e.getMessage(),e); + } catch (InterruptedException e) { + log.error("中断错误!"); + log.error(e.getMessage(),e); + } + + + + + } + + + //因为"字符无法在linux中使用,win下正常 + public void mergeAllAudio2(List inFilePathList,String outPath) { + log.info("系统名称:{}", getOsName()); + log.info("是win?:{}", StringUtils.contains(getOsName(), "win")); + log.info("是linux?:{}", StringUtils.contains(getOsName(), "linux")); + if (inFilePathList == null || inFilePathList.isEmpty()) return; + if (StringUtils.isBlank(outPath)) return; + //ffmpeg -i "concat:01.mp3|02.mp3|03.mp3" -acodec copy testAll.mp3 + List command = Lists.newArrayList(); + command.add(ffmpegPath); + command.add("-i"); + + StringBuilder sb = new StringBuilder(); +// if(StringUtils.contains(getOsName(), "linux")){ +// sb.append("\\\""); +// }else{ + sb.append("\""); +// } + sb.append("concat:"); +// if(StringUtils.contains(getOsName(), "linux")) { +// for (String path : inFilePathList) { +// sb.append(path); +// sb.append("\\|"); +// } +// //去除最后的| +// sb.deleteCharAt(sb.length() - 1); +// sb.deleteCharAt(sb.length() - 1); +// }else{ + for (String path : inFilePathList) { + sb.append(path); + sb.append("|"); + } + //去除最后的| + sb.deleteCharAt(sb.length() - 1); +// } +// if(StringUtils.contains(getOsName(), "linux")){ +// sb.append("\\\""); +// }else{ + sb.append("\""); +// } + command.add(sb.toString()); + command.add("-acodec"); + command.add("copy"); + command.add(outPath); + command.add("-y"); + +// if(StringUtils.contains(getOsName(), "linux")){ +// command.add("\""); +// } + + log.info("执行此命令:{}",command); + //手写吧。。。 + ProcessBuilder builder = new ProcessBuilder(command); + + try { + Process process = null; +// Process process = builder.start(); +// Process process = RuntimeUtil.exec(command.toArray(new String[]{})); +// if(StringUtils.contains(getOsName(), "linux")){ +// +// //process = Runtime.getRuntime().exec("sh -c",command.toArray(new String[]{})); +// process = Runtime.getRuntime().exec(new String[]{"/bin/sh","-c",ArrayUtil.join(command.toArray(new String[]{})," ")}); + +// String commandBase64 = Base64.encode(ArrayUtil.join(command.toArray(new String[]{})," ")); +// process = Runtime.getRuntime().exec(new String[]{"bash","-c","{echo," + commandBase64 + "}|{base64,-d}|{bash,-i}"}); +// +// +// log.info("执行此命令:{}","bash -c {echo," + commandBase64 + "}|{base64,-d}|{bash,-i}"); + +// }else{ + process = builder.start(); +// String commandBase64 = Base64.encode(ArrayUtil.join(command.toArray(new String[]{})," ")); +// process = Runtime.getRuntime().exec("bash -c {echo," + commandBase64 + "}|{base64,-d}|{bash,-i}"); +// } + +// process.createCommandLine +// int exitCode = process.exitValue(); + int exitCode = process.waitFor(); + if(exitCode == 0){ + log.info("正常退出!"); + }else{ + log.info("非正常退出!{}",exitCode); + } + InputStream is = process.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + String line; + while ((line = reader.readLine()) != null){ + log.info(line); + } + InputStream eis = process.getErrorStream(); + BufferedReader ereader = new BufferedReader(new InputStreamReader(eis)); + String eline; + while ((eline = ereader.readLine()) != null){ + log.info(eline); + } + process.destroy(); + } catch (IOException e) { + log.error("IO错误!"); + log.error(e.getMessage(),e); + } catch (InterruptedException e) { + log.error("中断错误!"); + log.error(e.getMessage(),e); + } + } + + public static void main(String[] args) { +// for (int i = 0; i < 200; i++) { +// //用原生合并的,,,只能合并出wav文件。文件特大。。。 +// new FFmpeg().montageAudioByJavaIo("F:\\temp\\000\\all.mp3","F:\\temp\\000\\01.mp3","F:\\temp\\000\\all.mp3"); +// } + System.out.println(getOsName()); + FFmpeg fFmpeg = new FFmpeg(); + fFmpeg.ffmpegPath = "D:\\ProgramGreeFile\\ffmpeg\\bin\\ffmpeg.exe"; + + List audioList = Lists.newArrayList(); + audioList.add("F:\\temp\\000\\01.mp3"); + audioList.add("F:\\temp\\000\\02.mp3"); + audioList.add("F:\\temp\\000\\03.mp3"); + fFmpeg.mergeAllAudio(audioList,"F:\\temp\\000\\all250.mp3"); + } + +} diff --git a/src/main/java/com/sqx/map/CommonMapUtils.java b/src/main/java/com/sqx/map/CommonMapUtils.java new file mode 100644 index 0000000..0670436 --- /dev/null +++ b/src/main/java/com/sqx/map/CommonMapUtils.java @@ -0,0 +1,352 @@ +package com.sqx.map; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.sqx.common.utils.SpringContextUtils; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.utils.HttpClientUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; + +import java.util.HashMap; +import java.util.Map; + +//获取各种清空的地图api +@Slf4j +public class CommonMapUtils { + + private static final CommonInfoService commonInfoService = SpringContextUtils.getBean(CommonInfoService.class); + + /** + * 地图枚举 + */ + public enum MapEnum { + TX/*腾讯地图*/, TDT/*天地图*/, GD/*高德地图*/, DEF/*默认值*/ + } + + /** + * 从数据库里获取当前生效的地图接口 + * @return { @link com.sqx.map.CommonMapUtils.MapEnum } + */ + public static MapEnum getMapType(){ + String mapType = commonInfoService.findOne(414).getValue(); + switch (mapType){ + case "1": { + return MapEnum.TX; + } + case "2": { + return MapEnum.TDT; + } + case "3": { + return MapEnum.GD; + } + default: { + return MapEnum.DEF; + } + } + } + + //一个通用的接口请求器 + + /** + * 使用Get方式请求数据并转成json对象 + * @param url URL地址 + * @param params 参数 + * @return { @link com.alibaba.fastjson.JSONObject } 对象的map + */ + public static JSONObject getHtmlToJson(String url, Map params){ + String data = HttpClientUtil.doGet(url, params); + return JSON.parseObject(data); + } + + + /** + * 获取【逆地理编码】接口 + * @param mapType + * @param longitude + * @param latitude + * @return + */ + public static JSONObject getReverseGeocoding(MapEnum mapType, String longitude, String latitude){ + JSONObject result = null; + switch (mapType){ + case TX: { + //腾讯地图API + CommonInfo oneData = commonInfoService.findOne(217); + String url = "https://apis.map.qq.com/ws/geocoder/v1/"; + Map params = new HashMap<>(); + params.put("location", latitude + "," + longitude); + params.put("key", oneData.getValue()); + JSONObject jsonObject = getHtmlToJson(url, params); + String status = jsonObject.getString("status"); + if ("0".equals(status)) { + result = jsonObject.getJSONObject("result"); + } else { + log.error("转换失败!!!原因:" + jsonObject.getString("message")); + } + break; + } + case GD: { + //高德API + CommonInfo oneData = commonInfoService.findOne(427); + String url = "https://restapi.amap.com/v3/geocode/regeo"; + Map params = new HashMap<>(); + params.put("location", longitude + "," + latitude); + params.put("key", oneData.getValue()); + JSONObject jsonObject = getHtmlToJson(url, params); + String status = jsonObject.getString("status"); + if ("1".equals(status)) { + result = jsonObject.getJSONObject("regeocode"); + }else { + log.error("转换失败!!!原因:" + jsonObject.getString("info")); + } + break; + } + case TDT: { + //天地图API + String value = commonInfoService.findOne(415).getValue(); + String url="http://api.tianditu.gov.cn/geocoder"; + Map params = new HashMap<>(); + JSONObject postStr=new JSONObject(); + postStr.put("lon",longitude); + postStr.put("lat",latitude); + postStr.put("ver","1"); + params.put("postStr",postStr.toJSONString()); + params.put("type","geocode"); + params.put("tk",value); + JSONObject jsonObject = getHtmlToJson(url, params); + String status = jsonObject.getString("status"); + if("0".equals(status)){ + result = jsonObject.getJSONObject("result"); + } + log.error("转换失败!!!原因:" + jsonObject.getString("msg")); + break; + } + default: break; + } + return result; + } + + /** + * 根据经纬度获取实际地址 + * @param longitude 经度 116.307490 + * @param latitude 纬度 39.984154 + * @return 经纬度所对应的文字地址 如【北京市东城区东华门街道天安门-城楼】以行政区划+道路+门牌号等信息组成的标准格式化地址 + */ + public static String getLocationToAddress(String longitude, String latitude){ + String address = ""; + MapEnum mapType = getMapType(); + JSONObject result = getReverseGeocoding(mapType, longitude, latitude); + if(result != null) { + switch (mapType){ + case TX: { + //腾讯地图API + address = result.getString("address"); + break; + } + case GD: case TDT: { + //高德API/天地图 + address = result.getString("formatted_address"); + break; + } + default: break; + } + } + return address; + } + + /** + * 按坐标获取行政区划信息 + * @param longitude 经度 116.307490 + * @param latitude 纬度 39.984154 + * @return province:省/直辖市,city:市/地级区 及同级行政区划,如果当前城市为省直辖县级区划,city与district字段均会返回此城市,district:区/县级市 及同级行政区划,address:经纬度所对应的文字地址 如【北京市东城区东华门街道天安门-城楼】以行政区划+道路+门牌号等信息组成的标准格式化地址 + */ + + public static JSONObject getLocationToAdInfo(String longitude, String latitude){ + MapEnum mapType = getMapType(); + JSONObject result = getReverseGeocoding(mapType, longitude, latitude); + JSONObject resObject = null; + if(result != null) { + switch (mapType){ + case TX: { + //腾讯地图API + resObject = result.getJSONObject("ad_info");//行政区划信息 + String address = result.getString("address"); + resObject.put("address",address); + log.info("最终返回的地址对象:{}",resObject); + break; + } + case GD: case TDT: { + //高德API/天地图 + JSONObject addressComponent = result.getJSONObject("addressComponent"); + String province = addressComponent.getString("province"); + String city = addressComponent.getString("city"); + String adcode = addressComponent.getString("adcode"); + + if(StringUtils.equals("[]",city)){ + city = ""; + } + + String district = ""; + if(mapType == MapEnum.GD){ + district = addressComponent.getString("district"); + }else { + district = addressComponent.getString("county"); + } + String address = result.getString("formatted_address"); + resObject = new JSONObject(); + resObject.put("province",province);//省 / 直辖市 + resObject.put("city",city);//市 / 地级区 及同级行政区划,如果当前城市为省直辖县级区划,city与district字段均会返回此城市 + resObject.put("adcode", adcode);//市代码 + resObject.put("district",district);//区 / 县级市 及同级行政区划 + resObject.put("address",address);//经纬度所对应的文字地址 如【北京市东城区东华门街道天安门-城楼】以行政区划+道路+门牌号等信息组成的标准格式化地址 + log.info("最终返回的地址对象:{}",resObject); + break; + } + default: break; + } + } + return resObject; + } + + + /** + * 根据开始位置和结束位置根据出行方式获取米 + * @param mapType + * @param tripWay + * @param longitude + * @param latitude + * @param toLongitude + * @param toLatitude + * @return + */ + public static JSONObject calcTaxiMoney(MapEnum mapType,Integer tripWay, String longitude, String latitude, String toLongitude, String toLatitude, String city, String cityCode){ + JSONObject result = null; + if(tripWay == null) tripWay = 1; + if(tripWay != 1 && tripWay != 2) return null; + switch (mapType){ + case TX: { + //腾讯地图API + CommonInfo oneData = commonInfoService.findOne(217); + String url = "https://apis.map.qq.com/ws/direction/v1/transit/?";//公交(transit)路线规划 + if(tripWay == 2){ + url="https://apis.map.qq.com/ws/direction/v1/driving/?";//驾车(driving)路线规划 + } + Map params = new HashMap<>(); + params.put("from", latitude + "," + longitude); + params.put("to", toLatitude + "," + toLongitude); + if(tripWay == 2){ + params.put("no_step", "1"); + } + params.put("key", oneData.getValue()); + JSONObject jsonObject = getHtmlToJson(url, params); + String status = jsonObject.getString("status"); + if ("0".equals(status)) { + result = jsonObject.getJSONObject("result"); + } else { + log.error("{}路线计算失败: {}",tripWay == 1?"公交":"驾车" , jsonObject.getString("message")); + } + break; + } + case GD: { + //高德API + CommonInfo oneData = commonInfoService.findOne(427); + String url = "https://restapi.amap.com/v5/direction/transit/integrated";//公交 + if(tripWay == 2){ + url="https://restapi.amap.com/v5/direction/driving";//驾车 + } + Map params = new HashMap<>(); + params.put("origin", longitude + "," + latitude); + params.put("destination", toLongitude + "," + toLatitude); + params.put("key", oneData.getValue()); + //默认是公交,需要加城市 + if(tripWay != 2){ + //城市 + params.put("city1", cityCode); + params.put("city2", cityCode); + } + + JSONObject jsonObject = getHtmlToJson(url, params); + String status = jsonObject.getString("status"); + if ("1".equals(status)) { + result = jsonObject.getJSONObject("route"); + }else { + log.error("{}路线计算失败: {}",tripWay == 1?"公交":"驾车" , jsonObject.getString("message")); + } + break; + } + case TDT: { + break; + } + default: break; + } + return result; + } + + /** + * 根据开始位置和结束位置根据出行方式获取米 + * @param tripWay + * @param longitude + * @param latitude + * @param toLongitude + * @param toLatitude + * @return + */ + public static JSONObject calcTaxiMoneyInfo(Integer tripWay, String longitude, String latitude, String toLongitude, String toLatitude, String city, String cityCode){ + MapEnum mapType = getMapType(); + JSONObject result = calcTaxiMoney(mapType, tripWay, longitude, latitude, toLongitude, toLatitude, city, cityCode); + JSONObject resObject = null; + if(result != null) { + switch (mapType){ + case TX: { + //腾讯地图API + JSONArray routes = result.getJSONArray("routes"); + if(!routes.isEmpty()){ + resObject = new JSONObject(); + String distance = routes.getJSONObject(0).getString("distance"); + resObject.put("distance",Integer.parseInt(distance)); + log.info("从n到n2距离 {} 米",distance); + } + break; + } + case GD: { + //高德API + if(tripWay == 2){ + //驾车 + JSONArray routes = result.getJSONArray("paths"); + if(!routes.isEmpty()){ + resObject = new JSONObject(); + String distance = routes.getJSONObject(0).getString("distance"); + resObject.put("distance",Integer.parseInt(distance)); + log.info("从n到n2距离 {} 米",distance); + }else{ + resObject = new JSONObject(); + resObject.put("distance",0); + } + }else if(tripWay == 1){ + //公交 + JSONArray routes = result.getJSONArray("transits"); + if(!routes.isEmpty()){ + resObject = new JSONObject(); + String distance = routes.getJSONObject(0).getString("distance"); + resObject.put("distance",Integer.parseInt(distance)); + log.info("从n到n2距离 {} 米",distance); + }else{ + resObject = new JSONObject(); + resObject.put("distance",0); + } + } + break; + } + case TDT: break; + default: break; + } + } + return resObject; + } + + + +} diff --git a/src/main/java/com/sqx/modules/app/annotation/Login.java b/src/main/java/com/sqx/modules/app/annotation/Login.java new file mode 100644 index 0000000..c4a0d48 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/annotation/Login.java @@ -0,0 +1,12 @@ +package com.sqx.modules.app.annotation; + +import java.lang.annotation.*; + +/** + * app登录效验 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface Login { +} diff --git a/src/main/java/com/sqx/modules/app/annotation/LoginUser.java b/src/main/java/com/sqx/modules/app/annotation/LoginUser.java new file mode 100644 index 0000000..531a9dd --- /dev/null +++ b/src/main/java/com/sqx/modules/app/annotation/LoginUser.java @@ -0,0 +1,16 @@ +package com.sqx.modules.app.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 登录用户信息 + * + */ +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +public @interface LoginUser { + +} diff --git a/src/main/java/com/sqx/modules/app/config/WebMvcConfig.java b/src/main/java/com/sqx/modules/app/config/WebMvcConfig.java new file mode 100644 index 0000000..92bc78f --- /dev/null +++ b/src/main/java/com/sqx/modules/app/config/WebMvcConfig.java @@ -0,0 +1,38 @@ +package com.sqx.modules.app.config; + +import com.sqx.modules.app.interceptor.AuthorizationInterceptor; +import com.sqx.modules.app.resolver.LoginUserHandlerMethodArgumentResolver; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import java.util.List; + +/** + * MVC配置 + * + */ +@Configuration +public class WebMvcConfig implements WebMvcConfigurer { + @Autowired + private AuthorizationInterceptor authorizationInterceptor; + @Autowired + private LoginUserHandlerMethodArgumentResolver loginUserHandlerMethodArgumentResolver; + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(authorizationInterceptor).addPathPatterns("/app/**"); + } + + @Override + public void addArgumentResolvers(List argumentResolvers) { + argumentResolvers.add(loginUserHandlerMethodArgumentResolver); + } + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/app/controller/AddressController.java b/src/main/java/com/sqx/modules/app/controller/AddressController.java new file mode 100644 index 0000000..25245ee --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/AddressController.java @@ -0,0 +1,43 @@ +package com.sqx.modules.app.controller; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.annotation.LoginUser; +import com.sqx.modules.app.entity.Address; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.AddressService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 地址 + */ +@RestController +@RequestMapping("/address") +@Api(value = "用户地址", tags = {"用户地址"}) +public class AddressController { + + @Autowired + private AddressService addressService; + + @GetMapping("/selectAddressListById") + @ApiOperation("获取我的所有地址") + public Result selectAddressListById(Long userId,Integer page,Integer limit){ + IPage
addressIPage = addressService.page(new Page<>(page, limit), new QueryWrapper
().eq("user_id", userId)); + return Result.success().put("data",new PageUtils(addressIPage)); + } + + + + +} diff --git a/src/main/java/com/sqx/modules/app/controller/AppUpgradeController.java b/src/main/java/com/sqx/modules/app/controller/AppUpgradeController.java new file mode 100644 index 0000000..a09d2a6 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/AppUpgradeController.java @@ -0,0 +1,70 @@ +package com.sqx.modules.app.controller; + + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.App; +import com.sqx.modules.app.service.AppService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * APP登录授权 + * + */ +@RestController +@RequestMapping("/appinfo") +@Api(value = "APP升级管理", tags = {"APP升级管理"}) +public class AppUpgradeController { + + @Autowired + private AppService iAppService; + + @RequestMapping(value = "/list", method = RequestMethod.GET) + @ApiOperation("管理平台升级详情") + @ResponseBody + public Result list(Integer page,Integer limit) { + IPage pages =new Page<>(page,limit); + return Result.success().put("data",iAppService.page(pages)); + } + + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ApiOperation("管理平台升级详情") + @ResponseBody + public Result getBanner(@PathVariable Long id) { + return Result.success().put("data",iAppService.selectAppById(id)); + } + + @RequestMapping(value = "/save", method = RequestMethod.POST) + @ApiOperation("管理平台添加升级信息") + @ResponseBody + public Result addBanner(@RequestBody App app) { + if(app.getId()!=null){ + iAppService.updateAppById(app); + }else{ + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + app.setCreateAt(sdf.format(new Date())); + iAppService.insertApp(app); + } + return Result.success(); + } + + @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET) + @ApiOperation("管理平台删除升级信息") + public Result deleteBanner(@PathVariable Long id) { + iAppService.deleteAppById(id); + return Result.success(); + } + + + + + +} diff --git a/src/main/java/com/sqx/modules/app/controller/UserBrowseController.java b/src/main/java/com/sqx/modules/app/controller/UserBrowseController.java new file mode 100644 index 0000000..9b600d7 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/UserBrowseController.java @@ -0,0 +1,45 @@ +package com.sqx.modules.app.controller; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.service.UserBrowseService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; +@RestController +@AllArgsConstructor +@RequestMapping("/userBrowse") +@Api(value = "访客|浏览", tags = {"访客|浏览"}) +public class UserBrowseController { + private UserBrowseService userBrowseService; + + @ApiOperation("查询我的访客") + @RequestMapping(value = "/myVisitor", method = RequestMethod.GET) + public Result selectMyVisitor(@ApiParam("用户id") Long userId, @ApiParam("页") Long page, @ApiParam("行") Long limit) { + return userBrowseService.selectMyVisitor(userId, page, limit); + } + + @RequestMapping(value = "/myBrowse", method = RequestMethod.GET) + @ApiOperation("浏览足迹") + public Result selectMyBrowse(Long userId, Long page, Long limit) { + return userBrowseService.selectMyBrowse(userId, page, limit); + } + + @ApiOperation("删除我的访客") + @RequestMapping(value = "/deleteMyVisitor", method = RequestMethod.POST) + public Result deleteMyVisitor(Long id) { + + return userBrowseService.deleteMyVisitor(id); + } + @ApiOperation(("删除足迹")) + @RequestMapping(value = "/deleteMyBrowse", method = RequestMethod.POST) + public Result deleteMyBrowse(Long id) { + + return userBrowseService.deleteMyBrowse(id); + } + + + +} diff --git a/src/main/java/com/sqx/modules/app/controller/UserCertificationController.java b/src/main/java/com/sqx/modules/app/controller/UserCertificationController.java new file mode 100644 index 0000000..20646e0 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/UserCertificationController.java @@ -0,0 +1,58 @@ +package com.sqx.modules.app.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserCertification; +import com.sqx.modules.app.service.UserCertificationService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@AllArgsConstructor +@RequestMapping("/userCertification") +@Api("实 名 认 证") +public class UserCertificationController { + private UserCertificationService userCertificationService; + + + /** + * 实名列表 + */ + @RequestMapping("/queryCertification") + @ApiOperation("实名列表") + public Result queryCertification(Long page, Long limit, @ApiParam("状态") String status, @ApiParam("姓名") String name,Integer classify) { + + return userCertificationService.queryCertification(page, limit, status, name,classify); + } + + /** + * 查询已经进行实名的用户 + */ + @RequestMapping("/queryUserCertification") + @ApiOperation("查询已经进行实名的用户") + public Result queryUserCertification(Long page, Long limit, String name,String phone) { + if (page == null || limit == null) { + return Result.error("分页条件为空"); + } else { + IPage iPage = new Page<>(page, limit); + + return userCertificationService.queryUserCertification(iPage,name,phone); + } + } + + /** + * 审核实名认证 + */ + @RequestMapping("/auditorUserCertification") + @ApiOperation("审核实名认证") + public Result auditorUserCertification(Long status, Long id, String remek) { + return userCertificationService.auditorUserCertification(status, id, remek); + } + + +} diff --git a/src/main/java/com/sqx/modules/app/controller/UserController.java b/src/main/java/com/sqx/modules/app/controller/UserController.java new file mode 100644 index 0000000..b0de522 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/UserController.java @@ -0,0 +1,632 @@ +package com.sqx.modules.app.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.dao.UserMoneyDao; +import com.sqx.modules.app.dao.UserVipDao; +import com.sqx.modules.app.dao.VipDetailsDao; +import com.sqx.modules.app.entity.*; +import com.sqx.modules.app.response.HomeMessageResponse; +import com.sqx.modules.app.response.UserMessageResponse; +import com.sqx.modules.app.service.UserMoneyDetailsService; +import com.sqx.modules.app.service.UserMoneyService; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.dao.OrdersDao; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.Certification; +import com.sqx.modules.artificer.service.ArtificerService; +import com.sqx.modules.artificer.service.RealNameService; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.service.MessageService; +import com.sqx.modules.pay.entity.PayDetails; +import com.sqx.modules.pay.service.CashOutService; +import com.sqx.modules.pay.service.PayDetailsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import jodd.util.StringUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * @author fang + * @date 2020/7/30 + */ +@RestController +@Api(value = "用户管理", tags = {"用户管理"}) +@RequestMapping(value = "/user") +public class UserController { + + @Autowired + private UserService userService; + @Autowired + private UserMoneyDetailsService userMoneyDetailsService; + @Autowired + private UserMoneyService userMoneyService; + @Autowired + private PayDetailsService payDetailsService; + @Autowired + private ArtificerService artificerService; + @Autowired + private UserMoneyDao userMoneyDao; + @Autowired + private OrdersDao ordersDao; + @Autowired + private RealNameService realNameService; + @Autowired + private CashOutService cashOutService; + @Autowired + private VipDetailsDao vipDetailsDao; + @Autowired + private UserVipDao userVipDao; + @Autowired + private MessageService messageService; + @Autowired + private CommonInfoService commonInfoService; + + @GetMapping("/queryByInvitationCode") + @ApiOperation("通过邀请码查询用户") + public Result queryByInvitationCode(String invitationCode){ + UserEntity userEntity = userService.queryByInvitationCode(invitationCode); + return Result.success().put("data",userEntity); + } + @GetMapping("/merchantPromotion") + @ApiOperation("商家推广统计") + public Result merchantPromotion(UserEntity userEntity,Integer page, Integer limit){ + IPage ResultUserEntity = userService.merchantPromotion(userEntity,page,limit); + return Result.success().put("data",ResultUserEntity); + } + + + @RequestMapping(value = "/{userId}", method = RequestMethod.GET) + @ApiOperation("获取用户详细信息") + @ResponseBody + public Result selectUserById(@ApiParam("用户id") @PathVariable Long userId) { + Map map = new HashMap<>(); + UserEntity userEntity = userService.queryByUserId(userId); + UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(userId); + //查询用户钱包 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String date = simpleDateFormat.format(new Date()); + //查询本月充值 + Double consume = payDetailsService.instantselectSumPay(date, userId); + //查询本月提现 + Double income = cashOutService.sumMoneyMonthByUserId(date, userId); + //查询邀请人数 + int count = userService.queryInviterCount(userEntity.getInvitationCode()); + //本月订单数 + int ordersCount = ordersDao.selectCountOrderByUserId(userId,null, date); + Artificer artificer = artificerService.selectArtificerByUserId(userId); + //本月收入 + BigDecimal ordersMoney=new BigDecimal("0.00"); + if(artificer!=null){ + ordersMoney = ordersDao.selectSumMoneyMonth(artificer.getArtificerId(), date); + } + UserVip userVip = userVipDao.selectById(userId); + if(userVip!=null){ + userEntity.setMember(userVip.getIsVip().intValue()); + userEntity.setVipEndTime(userVip.getEndTime()); + } + + map.put("artificer", artificer); + map.put("userEntity", userEntity); + map.put("money", userMoney); + map.put("consume", consume); + map.put("income", income); + map.put("count", count); + map.put("ordersCount", ordersCount); + map.put("ordersMoney", ordersMoney); + return Result.success().put("data", map); + } + + @PostMapping("/updateSafetyMoney") + @ApiOperation("修改") + public Result updateSafetyMoney(Long userId,Integer type, BigDecimal money){ + userMoneyDao.updateCashDeposit(type, userId, money.doubleValue()); + UserMoneyDetails userMoneyDetails=new UserMoneyDetails(); + userMoneyDetails.setClassify(1); + userMoneyDetails.setUserId(userId); + if(type==1){ + userMoneyDetails.setTitle("[保证金]增加保证金"); + userMoneyDetails.setContent("系统增加保证金"); + }else{ + userMoneyDetails.setTitle("[保证金]减少保证金"); + userMoneyDetails.setContent("系统减少保证金"); + } + userMoneyDetails.setType(type); + userMoneyDetails.setMoney(money); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userMoneyDetails.setCreateTime(sdf.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(userId); + if(userMoney.getCashDeposit().doubleValue()>0){ + UserEntity userEntity = userService.selectUserById(userId); + userEntity.setIsCashDeposit(2); + userService.updateById(userEntity); + }else{ + UserEntity userEntity = userService.selectUserById(userId); + userEntity.setIsCashDeposit(1); + userService.updateById(userEntity); + } + return Result.success(); + } + + + + @RequestMapping(value = "/addCannotMoney/{userId}/{money}/{type}", method = RequestMethod.POST) + @ApiOperation("修改金额") + @ResponseBody + public Result addCannotMoney(@PathVariable("userId") Long userId,@PathVariable("money") Double money,@PathVariable("type") Integer type){ + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String format = simpleDateFormat.format(new Date()); + if(type==1){ + userMoneyService.updateMoney(1,userId,money); + UserMoneyDetails userMoneyDetails=new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(userId); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(BigDecimal.valueOf(money)); + userMoneyDetails.setUserId(userId); + userMoneyDetails.setContent("管理端充值:"+money); + userMoneyDetails.setTitle("管理端充值金额"); + userMoneyDetails.setType(1); + userMoneyDetails.setCreateTime(format); + userMoneyDetailsService.save(userMoneyDetails); + PayDetails payDetails = new PayDetails(); + payDetails.setState(1); + payDetails.setCreateTime(format); + payDetails.setOrderId("系统充值金额"); + payDetails.setUserId(userId); + payDetails.setMoney(money); + payDetails.setClassify(5); + payDetailsService.save(payDetails); + }else{ + userMoneyService.updateMoney(2,userId,money); + + UserMoneyDetails userMoneyDetails=new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(userId); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(BigDecimal.valueOf(money)); + userMoneyDetails.setUserId(userId); + userMoneyDetails.setContent("管理端减少:"+money); + userMoneyDetails.setTitle("管理端减少金额"); + userMoneyDetails.setType(2); + userMoneyDetails.setCreateTime(format); + userMoneyDetailsService.save(userMoneyDetails); + PayDetails payDetails = new PayDetails(); + payDetails.setState(1); + payDetails.setCreateTime(format); + payDetails.setOrderId("系统减少金额"); + payDetails.setUserId(userId); + payDetails.setMoney(money); + payDetails.setClassify(5); + payDetailsService.save(payDetails); + } + return Result.success(); + } + + + @RequestMapping(value = "/selectUserList", method = RequestMethod.GET) + @ApiOperation("查询所有用户列表") + @ResponseBody + public Result selectUserList(Integer page, Integer limit, + @ApiParam("用户id 手机号 昵称 模糊搜索") String phone, + @ApiParam("性别 1男 2女") Integer sex, + @ApiParam("来源 ") String platform, + @ApiParam("0全部 1用户 2技师 ") Integer isAuthentication, + @ApiParam("手机终端") String sysPhone, + @ApiParam("状态 1正常 2封禁") Integer status, + String userName,String invitationCode,Integer member, + Integer ordersUser,String inviterCode,Integer isAgency, + Integer isShop,String artificerName) { + return Result.success().put("data", userService.selectUserPage(page, limit, phone, sex, platform, isAuthentication,sysPhone, + status,userName,invitationCode,inviterCode,member,ordersUser,isAgency,isShop,artificerName)); + } + + + @RequestMapping(value = "/deleteUserByUserId/{userId}", method = RequestMethod.POST) + @ApiOperation("删除用户") + @ResponseBody + public Result deleteUserByUserId(@PathVariable("userId") Long userId) { + userService.removeById(userId); + return Result.success(); + } + + @RequestMapping(value = "/updateUserByUserId", method = RequestMethod.POST) + @ApiOperation("修改用户") + @ResponseBody + public Result updateUserByUserId(@RequestBody UserEntity userEntity) { + userService.updateById(userEntity); + return Result.success(); + } + + @RequestMapping(value = "/updateUserStatusByUserId", method = RequestMethod.GET) + @ApiOperation("禁用或启用用户") + @ResponseBody + public Result updateUserByUserId(Long userId) { + UserEntity byId = userService.getById(userId); + if (byId.getStatus().equals(1)) { + byId.setStatus(2); + userService.sendMsg(byId.getPhone(),"fh"); + } else { + byId.setStatus(1); + } + userService.updateById(byId); + return Result.success(); + } + + + /** + * 获取openid + * + * @param code 微信code + * @return openid + */ + @GetMapping("/openId/{code:.+}/{userId}") + @ApiOperation("根据code获取openid") + public Result getOpenid(@PathVariable("code") String code, @PathVariable("userId") Long userId) { + return userService.getOpenId(code, userId); + } + + /** + * 信息分析 + * + * @return + */ + @GetMapping("/homeMessage") + @ApiOperation("信息分析") + public Result homeMessage() { + HomeMessageResponse homeMessageResponse = new HomeMessageResponse(); + // 0查总 1查天 2查月 3查年 + //设置总用户人数 + homeMessageResponse.setTotalUsers(userService.queryUserCount(0, null, null,null)); + //设置今日新增 + homeMessageResponse.setNewToday(userService.queryUserCount(1, null, null,null)); + //设置本月新增 + homeMessageResponse.setNewMonth(userService.queryUserCount(2, null, null,null)); + //设置本年新增 + homeMessageResponse.setNewYear(userService.queryUserCount(3, null, null,null)); + + //设置总收入 + homeMessageResponse.setTotalRevenue(userService.queryPayMoney(0)); + //设置今日收入 + homeMessageResponse.setTodayRevenue(userService.queryPayMoney(1)); + //设置本月收入 + homeMessageResponse.setMonthRevenue(userService.queryPayMoney(2)); + //设置本年收入 + homeMessageResponse.setYearRevenue(userService.queryPayMoney(3)); + + return Result.success().put("data", homeMessageResponse); + } + + + /** + * 用户统计 + */ + @GetMapping("/selectUserMessage") + @ApiOperation("用户统计") + public Result selectUserMessage(String date, Integer type){ + //统计总用户、用户、技师、手机号用户 + int userCount = userService.queryUserCount(type, date,null,null); + int puUserCount = userService.queryUserCount(type, date,1,null); + int jiUserCount = userService.queryUserCount(type, date,2,null); + int phoneUserCount = userService.queryUserCount(type, date,null,1); + int appCount = userService.userPlatform("app", date, type); + int wxCount = userService.userPlatform("小程序", date, type); + int wapCount = userService.userPlatform("H5", date, type); + Map result=new HashMap<>(); + result.put("userCount",userCount); + result.put("puUserCount",puUserCount); + result.put("jiUserCount",jiUserCount); + result.put("phoneUserCount",phoneUserCount); + result.put("appCount",appCount); + result.put("wxCount",wxCount); + result.put("wapCount",wapCount); + return Result.success().put("data",result); + } + + /** + * 服务收益 + */ + @GetMapping("/selectOrdersMoney") + @ApiOperation("服务收益") + public Result selectOrdersMoney(String date, Integer type){ + //总收入 1待支付 2进行中 3待评论 4已取消 5已完成 + BigDecimal sumMoney = ordersDao.selectOrdersMoney(date, type, 1); + //进行中订单 + BigDecimal jinMoney = ordersDao.selectOrdersMoney(date, type, 2); + //已完成订单 + BigDecimal wanMoney = ordersDao.selectOrdersMoney(date, type, 3); + //平台收益 + BigDecimal pingMoney = ordersDao.selectOrdersMoney(date, type, 4); + Map result=new HashMap<>(); + result.put("sumMoney",sumMoney.setScale(2,BigDecimal.ROUND_DOWN)); + result.put("jinMoney",jinMoney.setScale(2,BigDecimal.ROUND_DOWN)); + result.put("wanMoney",wanMoney.setScale(2,BigDecimal.ROUND_DOWN)); + result.put("pingMoney",pingMoney.setScale(2,BigDecimal.ROUND_DOWN)); + return Result.success().put("data",result); + } + + /** + * 订单统计 + */ + @GetMapping("/selectCountOrders") + @ApiOperation("订单统计") + public Result selectCountOrders(String date, Integer type){ + //状态 1待支付 2待服务 3待评论 4已取消 5已完成 6进行中 7出发 8到达 + int ordersCount = ordersDao.selectCountOrders(date, type, null); + int dzfCount = ordersDao.selectCountOrders(date, type, 1); + int dfwCount = ordersDao.selectCountOrders(date, type, 2); + int dplCount = ordersDao.selectCountOrders(date, type, 3); + int yqxCount = ordersDao.selectCountOrders(date, type, 4); + int ywcCount = ordersDao.selectCountOrders(date, type, 5); + int jxzCount = ordersDao.selectCountOrders(date, type, 6); + int cfCount = ordersDao.selectCountOrders(date, type, 7); + int ddCount = ordersDao.selectCountOrders(date, type, 8); + Map result=new HashMap<>(); + result.put("ordersCount",ordersCount); + result.put("dzfCount",dzfCount); + result.put("dfwCount",dfwCount); + result.put("dplCount",dplCount); + result.put("yqxCount",yqxCount); + result.put("ywcCount",ywcCount); + result.put("jxzCount",jxzCount); + result.put("cfCount",cfCount); + result.put("ddCount",ddCount); + return Result.success().put("data",result); + } + + + @GetMapping("/selectMoneyCount") + @ApiOperation("统计收益") + public Result selectMoneyCount(String date,Integer type){ + //支付类型 1订单 2实名认证 3充值 4优惠券 5会员 + Double ordersMoney = payDetailsService.selectSumPayByType(date, type, 1); + Double realMoney = payDetailsService.selectSumPayByType(date, type, 2); + Double money = payDetailsService.selectSumPayByType(date, type, 3); + Double couponMoney = payDetailsService.selectSumPayByType(date, type, 4); + Double memberMoney = payDetailsService.selectSumPayByType(date, type, 5); + Map result=new HashMap<>(); + BigDecimal sumMoney = BigDecimal.valueOf(ordersMoney).add(BigDecimal.valueOf(realMoney)); + sumMoney = sumMoney.add(BigDecimal.valueOf(money)); + sumMoney = sumMoney.add(BigDecimal.valueOf(couponMoney)); + sumMoney = sumMoney.add(BigDecimal.valueOf(memberMoney)); + result.put("ordersMoney",ordersMoney);result.put("realMoney",realMoney); + result.put("money",money);result.put("couponMoney",couponMoney); + result.put("memberMoney",memberMoney);result.put("sumMoney",sumMoney); + return Result.success().put("data",result); + } + + + /** + * 接单分析 + * + * @return + */ + @GetMapping("/takingOrdersMessage") + @ApiOperation("接单分析") + public Result takingOrdersMessage(Long page, Long limit, String date, Long type) { + Page> iPage = new Page<>(page, limit); + return userService.takingOrdersMessage(iPage, type, date); + } + + /** + * 用户分析 + */ + @GetMapping("/userMessage") + @ApiOperation("用户分析") + public Result userMessage(String date, int type) { + UserMessageResponse userMessageResponse = new UserMessageResponse(); + userMessageResponse.setTotalNumber(userService.queryUserCount(type, date, null,null)); + userMessageResponse.setVipUserNumber(userService.userMessage(date, type)); + userMessageResponse.setUserNumber(userService.queryUserCount(type, date, null,null) - userService.userMessage(date, type)); + return Result.success().put("data", userMessageResponse); + } + + @PostMapping("/updateArtificer") + @ApiOperation("修改用户为技师") + public Result updateArtificer(@RequestBody Certification certification){ + if(certification.getStatus().equals(1)){ + UserEntity user = userService.getById(certification.getUserId()); + certification.setStatus(1); + certification.setUpdateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + user.setIsAuthentication(2); + Artificer artificer = artificerService.selectArtificerByUserId(user.getUserId()); + if(artificer==null){ + artificer=new Artificer(); + artificer.setStatus(2); + artificer.setUserId(certification.getUserId()); + artificer.setArtificerSales(0); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + artificer.setCreateTime(sdf.format(new Date())); + artificer.setCreditScore(BigDecimal.valueOf(100)); + artificer.setTripWay(1); + artificer.setRate(new BigDecimal(commonInfoService.findOne(381).getValue())); + } + artificer.setArtificerName(certification.getName()); + artificer.setArtificerImg(certification.getAvatar()); + artificer.setLifePhoto(certification.getImagePhoto()); + artificer.setCertificate(certification.getCertification()); + artificer.setContent(certification.getIndividualResume()); + artificer.setClassifyId(certification.getClassifyId()); + if(artificer.getArtificerId()!=null){ + artificerService.updateById(artificer); + }else{ + artificerService.save(artificer); + } + + + BigDecimal cashDeposit = certification.getMoney(); + Long userId = user.getUserId(); + userMoneyDao.updateCashDeposit(1, userId, cashDeposit.doubleValue()); + user.setIsCashDeposit(2); + userService.updateById(user); + }else{ + UserEntity user = userService.getById(certification.getUserId()); + Artificer artificer = artificerService.selectArtificerByUserId(user.getUserId()); + if(artificer!=null){ + UserEntity userEntity = userService.selectUserById(artificer.getUserId()); + if(userEntity!=null){ + userEntity.setIsAuthentication(0); + userService.updateById(userEntity); + realNameService.remove(new QueryWrapper().eq("user_id",userEntity.getUserId())); + } + artificerService.removeById(artificer.getArtificerId()); + } + + } + return Result.success(); + } + + + @PostMapping("/updateUserIsAgency") + @ApiOperation("修改是否为推广员") + public Result updateUserIsAgency(Long userId,Integer isAgency){ + UserEntity userEntity=new UserEntity(); + userEntity.setUserId(userId); + userEntity.setIsAgency(isAgency); + userService.updateById(userEntity); + return Result.success(); + } + + @GetMapping("/selectAgencyOrdersMoneyList") + @ApiOperation("查询推广员收益排行榜") + public Result selectAgencyOrdersMoneyList(Integer page,Integer limit,String userName,String phone,String startTime,String endTime){ + return userService.selectAgencyOrdersMoneyList(page, limit, userName, phone, startTime, endTime); + } + + + @PostMapping("/giveUserVip") + @ApiOperation("赠送用户会员") + public Result giveUserVip(Long userId,Integer day){ + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + //查看用户是否是会员 + UserVip userVip = userVipDao.selectOne(new QueryWrapper().eq("user_id", userId)); + Calendar cal = Calendar.getInstance(); + if(userVip!=null){ + Date endDate = null; + try { + endDate = sdf.parse(userVip.getEndTime()); + if (endDate != null && System.currentTimeMillis() < (endDate.getTime())) { + cal.setTime(endDate); + } + } catch (Exception e) { + e.getMessage(); + } + }else{ + userVip=new UserVip(); + //设置会员类型 + userVip.setVipNameType(1); + //设置开通会员的用户id + userVip.setUserId(userId); + //设置会员的购买时间 + userVip.setCreateTime(sdf.format(new Date())); + userVip.setIsVip(1L); + } + BigDecimal money=BigDecimal.ZERO; + MessageInfo messageInfo=new MessageInfo(); + UserMoneyDetails userMoneyDetails=new UserMoneyDetails(); + userMoneyDetails.setMoney(money); + userMoneyDetails.setUserId(userId); + + userMoneyDetails.setContent("系统赠送"+day+"天会员"); + messageInfo.setContent("系统赠送"+day+"天会员"); + cal.add(Calendar.DAY_OF_MONTH, day); + + userVip.setEndTime(sdf.format(cal.getTime())); + if(userVip.getVipId()!=null){ + userVipDao.updateById(userVip); + }else{ + userVipDao.insert(userVip); + } + userMoneyDetails.setTitle("开通会员"); + userMoneyDetails.setType(2); + userMoneyDetails.setCreateTime(sdf.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + UserEntity userEntity = userService.selectUserById(userId); + messageInfo.setTitle("开通会员"); + messageInfo.setState(String.valueOf(4)); + messageInfo.setUserName(userEntity.getUserName()); + messageInfo.setUserId(String.valueOf(userEntity.getUserId())); + messageInfo.setCreateAt(sdf.format(new Date())); + messageInfo.setIsSee("0"); + messageService.saveBody(messageInfo); + if(StringUtil.isNotBlank(userEntity.getClientid())){ + userService.pushToSingle(messageInfo.getTitle(),messageInfo.getContent(),userEntity.getClientid()); + } + return Result.success(); + } + + @PostMapping("/removeUserVip") + @ApiOperation("取消用户会员") + public Result removeUserVip(Long userId){ + UserVip userVip = userVipDao.selectOne(new QueryWrapper().eq("user_id", userId)); + if(userVip!=null){ + userVipDao.deleteById(userVip.getVipId()); + } + UserEntity userEntity = userService.selectUserById(userId); + MessageInfo messageInfo=new MessageInfo(); + messageInfo.setTitle("取消会员"); + messageInfo.setContent("系统取消了你的会员"); + messageInfo.setState(String.valueOf(4)); + messageInfo.setUserName(userEntity.getUserName()); + messageInfo.setUserId(String.valueOf(userEntity.getUserId())); + messageInfo.setCreateAt(DateUtils.format(new Date())); + messageInfo.setIsSee("0"); + messageService.saveBody(messageInfo); + return Result.success(); + } + + @GetMapping("/selectUserCountStatisticsByTime") + @ApiOperation("用户统计") + public Result selectUserCountStatisticsByTime(String startTime,String endTime){ + List userCountList=new ArrayList<>(); + List year=new ArrayList<>(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar=Calendar.getInstance(); + Date parse = null; + try { + parse = simpleDateFormat.parse(startTime); + } catch (ParseException e) { + e.printStackTrace(); + } + calendar.setTime(parse); + while (true){ + String dateTime = simpleDateFormat.format(calendar.getTime()); + int i = userService.queryUserCount(1, dateTime,null,null); + userCountList.add(i); + year.add(dateTime); + if(dateTime.equals(endTime)){ + break; + } + calendar.add(Calendar.DATE,1); + } + Map result=new HashMap<>(); + result.put("userCountList",userCountList); + result.put("year",year); + return Result.success().put("data",result); + } + + @PostMapping("/integral") + @ApiOperation("积分") + public Result integral(String type,Integer current,Integer size,String date,String artificerId) throws ParseException { + return Result.success(userService.integral(type,current,size,date,artificerId)); + } +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/app/controller/UserFollowController.java b/src/main/java/com/sqx/modules/app/controller/UserFollowController.java new file mode 100644 index 0000000..b2e143e --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/UserFollowController.java @@ -0,0 +1,47 @@ +package com.sqx.modules.app.controller; + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.service.UserFollowService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +@RestController +@AllArgsConstructor +@RequestMapping("/userFollow") +@Api(value = "关注|粉丝", tags = {"关注|粉丝"}) +public class UserFollowController { + private UserFollowService userFollowService; + + + /** + * 查看我的关注 + */ + @GetMapping("/selectMyFollow") + @ApiOperation("查看我的关注") + public Result selectMyFollow(Long userId, Long page, Long limit) { + return userFollowService.selectMyFollow(userId, page, limit); + } + + /** + * 查看我的粉丝 + */ + @GetMapping("/selectFans") + @ApiOperation("查看我的粉丝") + public Result selectFans(Long userId, Long page, Long limit) { + return userFollowService.selectFans(userId, page, limit); + } + + /** + * 关注 / 取消关注 + **/ + + @PostMapping("/insert") + @ApiOperation("关注/取消关注") + public Result insert(Long userId, Long followUserId) { + return userFollowService.insert(userId, followUserId); + } + +} diff --git a/src/main/java/com/sqx/modules/app/controller/UserMoneyDetailsController.java b/src/main/java/com/sqx/modules/app/controller/UserMoneyDetailsController.java new file mode 100644 index 0000000..4ee5773 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/UserMoneyDetailsController.java @@ -0,0 +1,101 @@ +package com.sqx.modules.app.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.entity.UserMoneyArtificer; +import com.sqx.modules.app.entity.UserMoneyDetails; +import com.sqx.modules.app.service.UserMoneyArtificerService; +import com.sqx.modules.app.service.UserMoneyDetailsService; +import com.sqx.modules.app.service.UserMoneyService; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.ArtificerTime; +import com.sqx.modules.artificer.service.ArtificerService; +import com.sqx.modules.common.service.CommonInfoService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +@RestController +@RequestMapping("/Details") +@Api("钱包明细") +public class UserMoneyDetailsController { + + @Autowired + private UserMoneyDetailsService userMoneyDetailsService; + @Autowired + private UserMoneyArtificerService userMoneyArtificerService; + @Autowired + private ArtificerService artificerService; + + @Autowired + private UserMoneyService userMoneyService; + + @ApiOperation("钱包明细") + @GetMapping("/queryUserMoneyDetails") + public Result queryUserMoneyDetails(Integer page, Integer limit, Long userId,Integer classify,Integer type,Long artificerId) { + return userMoneyDetailsService.queryUserMoneyDetails(page, limit, userId,classify,type,artificerId); + } + + @GetMapping("/selectUserMoneyArtificer") + @ApiOperation("查询用户充值师傅钱包") + public Result selectUserMoneyArtificer(Integer page,Integer limit,Long userId){ + return userMoneyDetailsService.selectUserMoneyArtificer(page, limit, userId,null,null); + } + + @PostMapping("/updateUserMoneyArtificer") + @ApiOperation("修改用户充值师傅钱包") + public Result updateUserMoneyArtificer(Long userId, Long artificerId, BigDecimal money,Integer type){ + UserMoneyArtificer userMoneyArtificer = userMoneyArtificerService.getOne(new QueryWrapper().eq("user_id", userId).eq("artificer_id", artificerId)); + if(userMoneyArtificer==null){ + userMoneyArtificer=new UserMoneyArtificer(); + userMoneyArtificer.setUserId(userId); + userMoneyArtificer.setArtificerId(artificerId); + userMoneyArtificer.setMoney(money); + userMoneyArtificer.setCreateTime(DateUtils.format(new Date())); + userMoneyArtificerService.save(userMoneyArtificer); + }else{ + userMoneyArtificerService.updateMoney(type,userId,artificerId,money.doubleValue()); + } + UserMoneyDetails userMoneyDetails =new UserMoneyDetails(); + userMoneyDetails.setClassify(8); + userMoneyDetails.setMoney(money); + userMoneyDetails.setUserId(userId); + Artificer artificer = artificerService.getById(artificerId); + if(type==null || type==1){ + userMoneyDetails.setTitle("系统充值"); + userMoneyDetails.setContent("指定技师“"+artificer.getArtificerName()+"”钱包系统充值:"+money); + userMoneyDetails.setType(1); + }else{ + userMoneyDetails.setTitle("系统扣除"); + userMoneyDetails.setContent("指定技师“"+artificer.getArtificerName()+"”钱包系统扣除:"+money); + userMoneyDetails.setType(2); + } + userMoneyDetails.setCreateTime(DateUtils.format(new Date())); + userMoneyDetails.setArtificerId(artificerId); + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(userId); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetailsService.save(userMoneyDetails); + return Result.success(); + } + + +} diff --git a/src/main/java/com/sqx/modules/app/controller/VipDetailsController.java b/src/main/java/com/sqx/modules/app/controller/VipDetailsController.java new file mode 100644 index 0000000..381d5b5 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/VipDetailsController.java @@ -0,0 +1,48 @@ +package com.sqx.modules.app.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.VipDetails; +import com.sqx.modules.app.service.VipDetailsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value = "会员管理", tags = {"会员管理"}) +@RequestMapping(value = "/vipDetails") +public class VipDetailsController { + + @Autowired + private VipDetailsService vipDetailsService; + + @ApiParam("添加会员的详情信息") + @PostMapping("/insertVipDetails") + public Result insertVipDetails(@RequestBody VipDetails vipDetails) { + return vipDetailsService.insertVipDetails(vipDetails); + } + + + @ApiParam("修改会员的详情信息") + @PostMapping("/updateVipDetails") + public Result updateVipDetails(@RequestBody VipDetails vipDetails) { + vipDetailsService.updateById(vipDetails); + return Result.success(); + } + + @ApiParam("删除的详情信息") + @PostMapping("/deleteVipDetails") + public Result deleteVipDetails(Long id) { + vipDetailsService.removeById(id); + return Result.success(); + } + + @ApiParam("查询会员列表") + @GetMapping("/selectVipDetailsList") + public Result selectVipDetailsList(Integer page,Integer limit) { + return Result.success().put("data",new PageUtils(vipDetailsService.page(new Page<>(page,limit)))); + } + +} diff --git a/src/main/java/com/sqx/modules/app/controller/app/AppAddressController.java b/src/main/java/com/sqx/modules/app/controller/app/AppAddressController.java new file mode 100644 index 0000000..3ec0437 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/app/AppAddressController.java @@ -0,0 +1,105 @@ +package com.sqx.modules.app.controller.app; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.annotation.LoginUser; +import com.sqx.modules.app.entity.Address; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.AddressService; +import com.sqx.modules.app.service.AppService; +import com.sqx.modules.app.service.UserService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.codec.digest.DigestUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 地址 + */ +@RestController +@RequestMapping("/app/address") +@Api(value = "用户地址", tags = {"用户地址"}) +public class AppAddressController { + + @Autowired + private AddressService addressService; + + @Login + @PostMapping("/insertAddress") + @ApiOperation("添加地址") + public Result insertAddress(@LoginUser UserEntity user,@RequestBody Address address){ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + address.setCreateTime(sdf.format(new Date())); + if(address.getIsDefault()==1){ + addressService.updateAddressIsDefault(user.getUserId()); + } + address.setUserId(user.getUserId()); + addressService.save(address); + return Result.success(); + } + + @Login + @PostMapping("/updateAddress") + @ApiOperation("修改地址") + public Result updateAddress(@LoginUser UserEntity user,@RequestBody Address address){ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + address.setCreateTime(sdf.format(new Date())); + if(address.getIsDefault()==1){ + addressService.updateAddressIsDefault(user.getUserId()); + } + address.setUserId(user.getUserId()); + addressService.updateById(address); + return Result.success(); + } + + @Login + @PostMapping("/deleteAddress") + @ApiOperation("删除我的地址") + public Result deleteAddress(Long addressId){ + addressService.removeById(addressId); + return Result.success(); + } + + + @Login + @GetMapping("/selectAddressListById") + @ApiOperation("获取我的所有地址") + public Result selectAddressListById(@LoginUser UserEntity user,Integer page,Integer limit){ + IPage
addressIPage = addressService.page(new Page<>(page, limit), new QueryWrapper
().eq("user_id", user.getUserId())); + return Result.success().put("data",new PageUtils(addressIPage)); + } + + @Login + @GetMapping("/selectAddressById") + @ApiOperation("获取我的默认地址") + public Result selectAddressById(@LoginUser UserEntity user){ + Address one = addressService.getOne(new QueryWrapper
().eq("user_id", user.getUserId()).orderByDesc("is_default").last(" limit 1")); + return Result.success().put("data",one); + } + + + @Login + @GetMapping("selectAddressByAddressId") + @ApiOperation("根据地址id查询地址详细信息") + public Result selectAddressByAddressId(Long addressId){ + return Result.success().put("data",addressService.getById(addressId)); + } + + + + + + + + + +} diff --git a/src/main/java/com/sqx/modules/app/controller/app/AppController.java b/src/main/java/com/sqx/modules/app/controller/app/AppController.java new file mode 100644 index 0000000..36cb749 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/app/AppController.java @@ -0,0 +1,256 @@ +package com.sqx.modules.app.controller.app; + +import com.alibaba.fastjson.JSON; +import com.aliyun.dyplsapi20170525.models.BindAxnResponse; +import com.aliyun.dyplsapi20170525.models.BindAxnResponseBody; +import com.aliyun.dyplsapi20170525.models.UpdateSubscriptionResponse; +import com.aliyun.dyplsapi20170525.models.UpdateSubscriptionResponseBody; +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.IAcsClient; +import com.aliyuncs.profile.DefaultProfile; +import com.aliyun.tea.TeaException; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.annotation.LoginUser; +import com.sqx.modules.app.dao.UserCertificationDao; +import com.sqx.modules.app.entity.UserCertification; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.service.AppService; +import com.sqx.modules.app.service.UserMoneyService; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.service.ArtificerService; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.coupon.entity.CouponUser; +import com.sqx.modules.coupon.service.CouponUserService; +import com.sqx.modules.message.dao.MessageInfoDao; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.utils.MD5Util; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.codec.digest.DigestUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * APP登录授权 + */ +@RestController +@RequestMapping("/app/user") +@Api(value = "APP管理", tags = {"APP管理"}) +@Slf4j +public class AppController { + + @Autowired + private UserService userService; + @Autowired + private AppService appService; + @Autowired + private CommonInfoService commonInfoService; + @Autowired + private MessageInfoDao messageInfoDao; + @Autowired + private UserMoneyService userMoneyService; + @Autowired + private CouponUserService couponUserService; + @Autowired + private ArtificerService artificerService; + + @Login + @ApiOperation("生成虚拟号码") + @GetMapping("/insertVirtualPhone") + public Result insertVirtualPhone(String phoneA, String phoneB) { + MessageInfo messageInfo1 = messageInfoDao.selectOne(new QueryWrapper().eq("user_name", phoneA).eq("by_user_name", phoneB)); + if (messageInfo1 == null) { + messageInfo1 = messageInfoDao.selectOne(new QueryWrapper().eq("user_name", phoneB).eq("by_user_name", phoneA)); + } + String accessKeyId = commonInfoService.findOne(386).getValue(); + String accessKeySecret = commonInfoService.findOne(387).getValue(); + com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config() + // 必填,您的 AccessKey ID + .setAccessKeyId(accessKeyId) + // 必填,您的 AccessKey Secret + .setAccessKeySecret(accessKeySecret); + // 访问的域名 + config.endpoint = "dyplsapi.aliyuncs.com"; + try { + String poolKey = commonInfoService.findOne(382).getValue(); + com.aliyun.dyplsapi20170525.Client client = new com.aliyun.dyplsapi20170525.Client(config); + if (messageInfo1 != null) { + com.aliyun.dyplsapi20170525.models.UpdateSubscriptionRequest updateSubscriptionRequest = new com.aliyun.dyplsapi20170525.models.UpdateSubscriptionRequest(); + com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions(); + updateSubscriptionRequest.setPoolKey(poolKey); + updateSubscriptionRequest.setSubsId(messageInfo1.getTitle()); + updateSubscriptionRequest.setPhoneNoX(messageInfo1.getContent()); + String value = commonInfoService.findOne(418).getValue(); + if("是".equals(value)){ + updateSubscriptionRequest.setIsRecordingEnabled(true); + } + Calendar calendar=Calendar.getInstance(); + calendar.add(Calendar.HOUR,1); + updateSubscriptionRequest.setExpiration(DateUtils.format(calendar.getTime())); + updateSubscriptionRequest.setOperateType("updateExpire"); + UpdateSubscriptionResponse updateSubscriptionResponse = client.updateSubscriptionWithOptions(updateSubscriptionRequest, runtime); + UpdateSubscriptionResponseBody body = updateSubscriptionResponse.getBody(); + String code = body.getCode(); + if("OK".equals(code)){ + return Result.success().put("data", messageInfo1.getContent()); + } + messageInfoDao.deleteById(messageInfo1.getId()); + } + MessageInfo messageInfo = new MessageInfo(); + messageInfo.setState("18"); + messageInfo.setUserName(phoneA); + messageInfo.setByUserName(phoneB); + com.aliyun.dyplsapi20170525.models.BindAxnRequest bindAxnRequest = new com.aliyun.dyplsapi20170525.models.BindAxnRequest(); + bindAxnRequest.setPoolKey(poolKey); + bindAxnRequest.setPhoneNoA(phoneA); + bindAxnRequest.setPhoneNoB(phoneB); + String value = commonInfoService.findOne(418).getValue(); + if("是".equals(value)){ + bindAxnRequest.setIsRecordingEnabled(true); + } + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.HOUR, 1); + bindAxnRequest.setExpiration(DateUtils.format(calendar.getTime())); + com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions(); + BindAxnResponse bindAxnResponse = client.bindAxnWithOptions(bindAxnRequest, runtime); + BindAxnResponseBody body = bindAxnResponse.getBody(); + String code = body.code; + if (!"OK".equals(code)) { + return Result.error("获取号码失败!" + body.getMessage()); + } + BindAxnResponseBody.BindAxnResponseBodySecretBindDTO secretBindDTO = body.getSecretBindDTO(); + messageInfo.setContent(secretBindDTO.getSecretNo()); + messageInfo.setTitle(secretBindDTO.getSubsId()); + messageInfo.setCreateAt(DateUtils.format(new Date())); + messageInfoDao.insert(messageInfo); + return Result.success().put("data", secretBindDTO.getSecretNo()); + } catch (TeaException error) { + // 如有需要,请打印 error + com.aliyun.teautil.Common.assertAsString(error.message); + } catch (Exception _error) { + TeaException error = new TeaException(_error.getMessage(), _error); + // 如有需要,请打印 error + com.aliyun.teautil.Common.assertAsString(error.message); + } + return Result.error("获取号码失败!"); + } + + + + @Login + @RequestMapping(value = "/updatePwd", method = RequestMethod.POST) + @ResponseBody + @ApiOperation("用户端修改密码") + public Result updatePwd(@LoginUser UserEntity user, String pwd, String oldPwd) { + if (!user.getPassword().equals(DigestUtils.sha256Hex(oldPwd))) { + return Result.error("原始密码不正确!"); + } + if (pwd.equals(oldPwd)) { + return Result.error("新密码不能与旧密码相同!"); + } + user.setPassword(DigestUtils.sha256Hex(pwd)); + userService.updateById(user); + return Result.success(); + } + + @Login + @RequestMapping(value = "/updatePhone", method = RequestMethod.POST) + @ApiOperation("用户端换绑手机号") + @ResponseBody + public Result updatePhone(@RequestAttribute("userId") Long userId, @RequestParam String phone, @RequestParam String msg) { + return userService.updatePhone(phone, msg, userId); + } + + @Login + @RequestMapping(value = "/updateUser", method = RequestMethod.POST) + @ApiOperation("用户修改个人信息") + @ResponseBody + public Result updateUser(@RequestBody UserEntity userEntity,@RequestAttribute("userId") Long userId) { + userEntity.setUserId(userId); + userService.updateById(userEntity); + //更新artificer 技师主表 + UpdateWrapper uw = new UpdateWrapper<>(); + uw.set("artificer_img",userEntity.getAvatar()); + uw.eq("user_id",userId); + artificerService.update(uw); + return Result.success(); + } + + @Login + @RequestMapping(value = "/updateUserImageUrl", method = RequestMethod.POST) + @ApiOperation("用户修改头像") + @ResponseBody + public Result updateUserImageUrl(@LoginUser UserEntity user, String avatar) { + user.setAvatar(avatar); + userService.updateById(user); + return Result.success(); + } + + @Login + @RequestMapping(value = "/updateUserName", method = RequestMethod.POST) + @ApiOperation("用户修改昵称") + @ResponseBody + public Result updateUserName(@LoginUser UserEntity user, String userName) { + user.setUserName(userName); + userService.updateById(user); + return Result.success(); + } + + @Login + @RequestMapping(value = "/selectUserById", method = RequestMethod.GET) + @ApiOperation("获取用户详细信息") + @ResponseBody + public Result selectUserById(@LoginUser UserEntity user) { + UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(user.getUserId()); + user.setMoney(userMoney.getMoney()); + + CouponUser couponUser = couponUserService.selectCountByUserId(user.getUserId()); + user.setMember(couponUser.getNum()); + + //获取地址及更新时间 + Artificer artificer = artificerService.selectArtificerByUserId(user.getUserId()); + if(artificer != null){ + user.setLoglattime(artificer.getUpdateTime()); + user.setLoglataddress(artificer.getAddress()); + } + + + return Result.success().put("data", user); + } + + + @RequestMapping(value = "/selectNewApp", method = RequestMethod.GET) + @ApiOperation("升级检测") + @ResponseBody + public Result selectNewApp(Integer classify) { + return Result.success().put("data", appService.selectNewApp(classify)); + } + + @RequestMapping(value = "/updateClientId", method = RequestMethod.POST) + @ApiOperation("绑定ClientId") + @ResponseBody + public Result updateClientId(String clientId,Long userId,Integer sysPhone ) { + userService.updateUserClientIdIsNull(clientId); + UserEntity userEntity=new UserEntity(); + userEntity.setSysPhone(sysPhone); + userEntity.setUserId(userId); + userEntity.setClientid(clientId); + userService.updateById(userEntity); + return Result.success(); + } + + + +} diff --git a/src/main/java/com/sqx/modules/app/controller/app/AppLoginController.java b/src/main/java/com/sqx/modules/app/controller/app/AppLoginController.java new file mode 100644 index 0000000..2c7174f --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/app/AppLoginController.java @@ -0,0 +1,211 @@ +package com.sqx.modules.app.controller.app; + + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.sqx.common.utils.Result; +import com.sqx.map.CommonMapUtils; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.IAppleService; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.app.utils.UserConstantInterface; +import com.sqx.modules.app.utils.WxPhone; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.utils.HttpClientUtil; +import com.sqx.modules.utils.MD5Util; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import weixin.popular.api.SnsAPI; +import weixin.popular.bean.sns.SnsToken; +import weixin.popular.bean.user.User; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.HashMap; +import java.util.Map; + +/** + * APP登录授权 + * + */ +@RestController +@RequestMapping("/app/Login") +@Api("APP登录接口") +@Slf4j +public class AppLoginController { + @Autowired + private UserService userService; + @Autowired + private IAppleService appleService; + @Autowired + private CommonInfoService commonInfoService; + + + @ApiOperation("微信小程序登陆") + @RequestMapping(value = "/wxLogin", method = RequestMethod.GET) + public Result wxLogin(@ApiParam("小程序code码") String code,Integer type){ + return userService.wxLogin(code,type); + } + + + @ApiOperation("小程序登录新增或修改个人信息") + @RequestMapping(value = "/insertWxUser", method = RequestMethod.POST) + public Result insertWxUser(@RequestBody UserEntity userInfo){ + return userService.wxRegister(userInfo); + } + + + @RequestMapping(value = "/appleLogin", method = RequestMethod.GET) + @ApiOperation("苹果登陆获取appleUserId") + public Result loginVerify(@RequestParam("identityToken") String identityToken) { + try { + log.info("苹果token:{}", identityToken); + JSONObject jsonObject = JSON.parseObject(identityToken); + JSONObject userInfo = jsonObject.getJSONObject("userInfo"); + String identityTokens = userInfo.getString("identityToken"); + return appleService.getAppleUserInfo(identityTokens); + } catch (Exception e) { + log.error("苹果token校验失败:{}", identityToken, e); + return Result.error("苹果账号验证失败,请退出重试!"); + } + } + + + @ApiOperation("苹果登录") + @RequestMapping(value = "/insertAppleUser", method = RequestMethod.GET) + public Result insertAppleUser(@RequestParam String appleId){ + return userService.iosRegister(appleId); + } + + @RequestMapping(value = "/iosBindMobile", method = RequestMethod.POST) + @ApiOperation("苹果登录绑定手机号") + @ResponseBody + public Result iosBindMobile(@RequestParam String phone,@RequestParam String code,@RequestParam String appleId,@RequestParam String platform,@RequestParam Integer sysPhone) { + return userService.iosBindMobile(phone, code, appleId, platform, sysPhone); + } + + + @RequestMapping(value = "/wxAppLogin", method = RequestMethod.POST) + @ApiOperation("微信APP登录") + @ResponseBody + public Result wxAppLogin(@RequestParam String wxOpenId,@RequestParam String token) { + return userService.wxAppLogin(wxOpenId,token); + } + + + @RequestMapping(value = "/wxBindMobile", method = RequestMethod.POST) + @ApiOperation("微信登录绑定手机号") + @ResponseBody + public Result wxBindMobile(@RequestParam String phone,@RequestParam String code,@RequestParam String wxOpenId,@RequestParam String token,@RequestParam String platform,@RequestParam Integer sysPhone) { + return userService.wxBindMobile(phone, code, wxOpenId, token, platform, sysPhone); + } + + @ApiOperation("用户端openid登录呢") + @RequestMapping(value = "/openid/login", method = RequestMethod.GET) + @ResponseBody + public Result loginByOpenId(@RequestParam String openId) { + return userService.loginByOpenId(openId); + } + + + @RequestMapping(value = "/registerCode", method = RequestMethod.POST) + @ApiOperation("app或h5注册或登录") + @ResponseBody + public Result registerCode( String phone, String msg,String platform, Integer sysPhone,String openId,String inviterCode,String password,String userName,String avatar,String scanningChannel) { + return userService.registerCode(phone,msg,platform,sysPhone,openId,inviterCode,password,userName,avatar,scanningChannel); + } + + @ApiOperation("用户端发送验证码") + @RequestMapping(value = "/sendMsg/{phone}/{state}", method = RequestMethod.GET) + @ResponseBody + public Result sendMsg(@PathVariable String phone, @PathVariable String state) { + return userService.sendMsg(phone, state); + } + + @ApiOperation("解密手机号") + @RequestMapping(value = "/selectPhone",method = RequestMethod.POST) + public Result getPhoneNumberBeanS5(@RequestBody WxPhone wxPhone) { + return UserConstantInterface.decryptS5(wxPhone.getDecryptData(), wxPhone.getKey(), wxPhone.getIv()); + } + @ApiParam("登录app") + @RequestMapping(value = "/loginApp",method = RequestMethod.POST) + public Result loginApp(@RequestParam String phone,@RequestParam String password){ + return userService.loginApp(phone,password); + } + @CrossOrigin + @ApiParam("注册app") + @RequestMapping(value = "/registApp",method = RequestMethod.POST) + public Result registApp(@RequestParam String userName,@RequestParam String phone,@RequestParam String password,String msg,@RequestParam String platform,String invitation){ + return userService.registApp(userName,phone,password,msg,platform,invitation); + } + + @ApiOperation("用户端忘记密码") + @RequestMapping(value = "/forgetPwd", method = RequestMethod.POST) + @ResponseBody + public Result forgetPwd(String pwd, String phone, String msg) { + return userService.forgetPwd(pwd, phone, msg); + } + + + @GetMapping("/selectCity") + @ApiOperation("根据经纬度获取城市") + public Result selectCity(String lat, String lng) { + JSONObject adInfo = CommonMapUtils.getLocationToAdInfo(lng, lat);//根据坐标获取行政区划信息 + if(adInfo == null) return Result.error("获取定位失败!"); + return Result.success().put("data", adInfo); + } + + + @GetMapping("/getOpenId") + @ApiOperation("公众号根据code换取openId") + public Result getOpenId(String code,Long userId) { + try { + //微信appid + CommonInfo one = commonInfoService.findOne(5); + //微信秘钥 + CommonInfo two = commonInfoService.findOne(21); + SnsToken snsToken = SnsAPI.oauth2AccessToken(one.getValue(), two.getValue(), code); + + String openid = snsToken.getOpenid(); + User user = SnsAPI.userinfo(snsToken.getAccess_token(), openid, "zh_CN"); + return Result.success().put("data",user); + } catch (Exception e) { + throw new RuntimeException("GET_OPENID_FAIL"); + } + + } + + + @GetMapping("/bindOpenId") + @ApiOperation("用户绑定公众号openId") + public Result bindOpenId(Long userId,String openId){ + UserEntity userEntity=new UserEntity(); + userEntity.setUserId(userId); + userEntity.setOpenId(openId); + userService.updateById(userEntity); + return Result.success(); + } + + @GetMapping("/daySub") + @ApiOperation("两个日期之间的差值") + public Result daySub(String startTime,String endTime) throws ParseException { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + Calendar cal = Calendar.getInstance(); + cal.setTime(sdf.parse(startTime)); + long time1 = cal.getTimeInMillis(); + cal.setTime(sdf.parse(endTime)); + long time2 = cal.getTimeInMillis(); + long between_days=(time2-time1)/(1000*3600*24); + return Result.success().put("data",Integer.parseInt(String.valueOf(between_days))+1); + } + + + +} diff --git a/src/main/java/com/sqx/modules/app/controller/app/AppUserBrowseController.java b/src/main/java/com/sqx/modules/app/controller/app/AppUserBrowseController.java new file mode 100644 index 0000000..3cba3e9 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/app/AppUserBrowseController.java @@ -0,0 +1,55 @@ +package com.sqx.modules.app.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.entity.UserBrowse; +import com.sqx.modules.app.service.UserBrowseService; +import com.sqx.modules.app.service.UserFollowService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +@RestController +@AllArgsConstructor +@RequestMapping("/app/userBrowse") +@Api(value = "app 访问 | 浏览 ", tags = {"app 访问 | 浏览 "}) +public class AppUserBrowseController { + private UserBrowseService userBrowseService; + + @ApiOperation("查询我的访客") + @Login + @RequestMapping("/myVisitor") + public Result selectMyVisitor(@RequestAttribute Long userId, Long page, Long limit) { + return userBrowseService.selectMyVisitor(userId, page, limit); + } + + @Login + @RequestMapping("/myBrowse") + @ApiOperation("浏览足迹") + public Result selectMyBrowse(@RequestAttribute Long userId, Long page, Long limit) { + return userBrowseService.selectMyBrowse(userId, page, limit); + } + + @Login + @RequestMapping("/selectAmount") + @ApiOperation("粉丝量 关注量 访客量 足迹量") + public Result selectAmount(@RequestAttribute Long userId) { + return userBrowseService.selectAmount(userId); + } + + @ApiOperation("删除我的访客") + @RequestMapping(value = "/deleteMyVisitor", method = RequestMethod.POST) + public Result deleteMyVisitor(Long id) { + return userBrowseService.deleteMyVisitor(id); + } + + @ApiOperation(("删除我的足迹")) + @RequestMapping(value = "/deleteMyBrowse", method = RequestMethod.POST) + public Result deleteMyBrowse(Long id) { + + return userBrowseService.deleteMyBrowse(id); + } + + +} diff --git a/src/main/java/com/sqx/modules/app/controller/app/AppUserCertificationController.java b/src/main/java/com/sqx/modules/app/controller/app/AppUserCertificationController.java new file mode 100644 index 0000000..1da3b8f --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/app/AppUserCertificationController.java @@ -0,0 +1,67 @@ +package com.sqx.modules.app.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.entity.UserCertification; +import com.sqx.modules.app.service.UserCertificationService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +@RestController +@AllArgsConstructor +@RequestMapping("/app/userCertification") +@Api("app实 名 认 证") +public class AppUserCertificationController { + + private UserCertificationService userCertificationService; + + /** + * 实名认证 + **/ + @RequestMapping("/insert") + @Login + @ApiOperation("实名认证") + public Result insert(@RequestAttribute Long userId, @ApiParam("真实姓名") String name, + @ApiParam("身份证号") String idNumber, @ApiParam("正面") String front, + @ApiParam("反面") String back,Integer classify,String phone,String address, + Integer sex,String infantImg,String infantImgs,String birthdate) { + return userCertificationService.insert(userId, name, idNumber, front, back,classify,phone,address,sex,infantImg,infantImgs,birthdate,null); + } + + /** + * 是否进行实名 + */ + @RequestMapping("/isInsert") + @Login + @ApiOperation("是否进行实名") + public Result isInsert(@RequestAttribute Long userId) { + return userCertificationService.isInsert(userId); + } + + /** + * 查询自己的实名信息 + */ + @RequestMapping("/queryInsert") + @Login + @ApiOperation("查询自己的实名信息") + public Result queryInsert(@RequestAttribute Long userId,Integer classify) { + + return userCertificationService.queryInsert(userId,classify); + } + + + + @PostMapping("/exitMoney") + @ApiOperation("退保证金") + @Login + public Result exitMoney(@RequestAttribute Long userId){ + return userCertificationService.exitMoney(userId); + } + + +} diff --git a/src/main/java/com/sqx/modules/app/controller/app/AppUserFollowController.java b/src/main/java/com/sqx/modules/app/controller/app/AppUserFollowController.java new file mode 100644 index 0000000..beec555 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/app/AppUserFollowController.java @@ -0,0 +1,56 @@ +package com.sqx.modules.app.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.entity.UserFollow; +import com.sqx.modules.app.service.UserFollowService; +import io.swagger.annotations.Api; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.RequestAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@AllArgsConstructor +@RequestMapping("/app/userFollow") +@Api("app 关注") +public class AppUserFollowController { + private UserFollowService userFollowService; + + /** + * 关注 / 取消关注 + **/ + + @RequestMapping("/insert") + @Login + public Result insert(@RequestAttribute Long userId, Long followUserId) { + return userFollowService.insert(userId, followUserId); + } + + /** + * 查看我的关注 + */ + @RequestMapping("/selectMyFollow") + @Login + public Result selectMyFollow(@RequestAttribute Long userId,Long page,Long limit) { + return userFollowService.selectMyFollow(userId,page,limit); + } + /** + * 查看我的粉丝 + */ + @RequestMapping("/selectFans") + @Login + public Result selectFans(@RequestAttribute Long userId,Long page,Long limit) { + return userFollowService.selectFans(userId,page,limit); + } + /** + * 查看我是否关注 + */ + @RequestMapping("/selectFollowUser") + @Login + public Result selectFollowUser(@RequestAttribute Long userId,Long followUserId) { + return userFollowService.selectFollowUser(userId,followUserId); + } + +} diff --git a/src/main/java/com/sqx/modules/app/controller/app/AppUserMoneyController.java b/src/main/java/com/sqx/modules/app/controller/app/AppUserMoneyController.java new file mode 100644 index 0000000..a069513 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/app/AppUserMoneyController.java @@ -0,0 +1,158 @@ +package com.sqx.modules.app.controller.app; + +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.entity.UserMoneyArtificer; +import com.sqx.modules.app.entity.UserMoneyDetails; +import com.sqx.modules.app.entity.UserMoneyResult; +import com.sqx.modules.app.service.UserMoneyArtificerService; +import com.sqx.modules.app.service.UserMoneyDetailsService; +import com.sqx.modules.app.service.UserMoneyService; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.entity.Period; +import com.sqx.modules.artificer.service.ArtificerService; +import com.sqx.modules.utils.PeriodUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +@RestController +@AllArgsConstructor +@RequestMapping("/app/userMoney") +@Api("app 钱包 ") +public class AppUserMoneyController { + + private UserMoneyService userMoneyService; + private UserMoneyDetailsService userMoneyDetailsService; + private UserMoneyArtificerService userMoneyArtificerService; + private UserService userService; + private ArtificerService artificerService; + + @Login + @GetMapping("/selectUserMoneyArtificer") + @ApiOperation("查询用户充值师傅钱包") + public Result selectUserMoneyArtificer(Integer page,Integer limit,Long artificerId,@RequestAttribute Long userId){ + return userMoneyDetailsService.selectUserMoneyArtificer(page, limit, userId,artificerId,1); + } + + @Login + @GetMapping("/selectUserMoneyArtificers") + @ApiOperation("查询用户充值师傅钱包") + public Result selectUserMoneyArtificers(Integer page,Integer limit,Long artificerId){ + IPage page1 = userMoneyArtificerService.page(new Page<>(page, limit), new QueryWrapper().eq(artificerId != null, "artificer_id", artificerId)); + List records = page1.getRecords(); + for(UserMoneyArtificer userMoneyArtificer:records){ + userMoneyArtificer.setUserEntity(userService.getById(userMoneyArtificer.getUserId())); + userMoneyArtificer.setArtificer(artificerService.selectArtificerById(null,userMoneyArtificer.getArtificerId(),null,null)); + } + + return Result.success().put("data",new PageUtils(page1)); + } + + @Login + @PostMapping("/payUserMoneyArtificer") + @ApiOperation("钱包充值 用户指定师傅钱包") + public Result payUserMoneyArtificer(@RequestAttribute Long userId,Long artificerId,BigDecimal money){ + return userMoneyService.payUserMoneyArtificer(userId, artificerId, money); + } + + + + @GetMapping("/selectMyMoney") + @Login + @ApiOperation("我的钱包余额") + public Result selectMyMoney(@RequestAttribute Long userId) { + UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(userId); + UserMoneyResult userMoneyResult = new UserMoneyResult(); + userMoneyResult.setUserId(userMoney.getUserId()); + userMoneyResult.setMoney(userMoney.getMoney()); + userMoneyResult.setCashDeposit(userMoney.getCashDeposit()); + userMoneyResult.setId(userMoney.getId()); + //获取当前时间 + Date CurrentPeriod = new Date(); + //获取当前时间周期的上一个周期 + Period periodDate= PeriodUtil.previousIssue(CurrentPeriod); + Period period = new Period(); + period.setArtificerId(String.valueOf(userId)); + period.setDetailsType(1); + //获取上一周期的最后一天 + period.setStartFundData(periodDate.getStartFundData()); + period.setEndFundData(CurrentPeriod); + List filteredPersons = userMoneyDetailsService.selectIncome(period); + //进账 + Long incomeLong= filteredPersons.stream() + .filter(UserMoneyDetails -> UserMoneyDetails.getType() == 1) + .mapToLong(UserMoneyDetails -> UserMoneyDetails.getMoney().longValue()) + .sum(); + //出账 + Long outgoingLong= filteredPersons.stream() + .filter(UserMoneyDetails -> UserMoneyDetails.getType() == 2) + .mapToLong(UserMoneyDetails -> UserMoneyDetails.getMoney().longValue()) + .sum(); + BigDecimal income = new BigDecimal(incomeLong); + BigDecimal outgoing = new BigDecimal(outgoingLong); + BigDecimal balance = income.subtract(outgoing); + //插入可提现金额 + userMoneyResult.setWithdrawableAmount(userMoney.getMoney().subtract(balance)); + return Result.success().put("data",userMoneyResult); + } + + /** + * 我的收益 + */ + @GetMapping("/selectMyProfit") + @Login + @ApiOperation("我的收益") + public Result selectMyProfit(@RequestAttribute Long userId) { + return Result.success().put("data", userMoneyService.selectMyProfit(userId)); + } + + + /** + * 余额明细 + */ + @GetMapping("/balanceDetailed") + @Login + @ApiOperation("余额明细") + public Result balanceDetailed(@RequestAttribute Long userId, Long page, Long limit) { + Page pages = new Page<>(page, limit); + return Result.success().put("data", userMoneyService.balanceDetailed(userId, pages)); + } + + @Login + @ApiOperation("钱包明细") + @GetMapping("/queryUserMoneyDetails") + public Result queryUserMoneyDetails(Integer page, Integer limit,@RequestAttribute Long userId,Integer classify,Integer type,Long artificerId) { + + return userMoneyDetailsService.queryUserMoneyDetails(page, limit, userId,classify,type,artificerId); + } + + /** + * 收益明细 + */ + @GetMapping("/profitDetailed") + @Login + @ApiOperation("收益明细") + public Result profitDetailed(@RequestAttribute Long userId, Long page, Long limit) { + if (page != null || limit != null) { + return Result.error("分页条件为空"); + } else { + IPage ipage = new Page(page, limit); + return Result.success().put("data", userMoneyService.profitDetailed(userId, ipage)); + } + } + + + +} diff --git a/src/main/java/com/sqx/modules/app/controller/app/AppUserVipController.java b/src/main/java/com/sqx/modules/app/controller/app/AppUserVipController.java new file mode 100644 index 0000000..af64f6f --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/app/AppUserVipController.java @@ -0,0 +1,37 @@ +package com.sqx.modules.app.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.service.UserVipService; +import com.sqx.modules.sys.controller.AbstractController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Api(value = "app 用户会员信息", tags = {"app 用户会员信息"}) +@RequestMapping(value = "/app/UserVip") +public class AppUserVipController extends AbstractController { + @Autowired + private UserVipService userVipService; + + @Login + @GetMapping("/selectUserVip") + @ApiOperation("查询用户会员信息") + public Result selectUserVip(@RequestAttribute Long userId) { + return Result.success().put("data", userVipService.selectUserVipByUserId(userId)); + } + + @Login + @GetMapping("/isUserVip") + @ApiOperation("查询用户是否是会员") + public Result isUserVip(@RequestAttribute Long userId) { + return userVipService.isUserVip(userId); + } + + +} diff --git a/src/main/java/com/sqx/modules/app/controller/app/AppVipDetailsController.java b/src/main/java/com/sqx/modules/app/controller/app/AppVipDetailsController.java new file mode 100644 index 0000000..b36db45 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/controller/app/AppVipDetailsController.java @@ -0,0 +1,46 @@ +package com.sqx.modules.app.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.entity.VipDetails; +import com.sqx.modules.app.service.VipDetailsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/app/VipDetails") +@AllArgsConstructor +@Api("app 会员详情信息") +public class AppVipDetailsController { + private VipDetailsService appVipDetailsService; + /** + * 查询会员的详情信息 + * + * @return + */ + @Login + @ApiParam("查询会员的详情信息") + @GetMapping("/selectVipDetails") + public Result selectVipDetails() { + return appVipDetailsService.selectVipDetails(); + } + + /** + * 添加会员的详情信息 + * + * @return + */ + @Login + @ApiParam("添加会员的详情信息") + @GetMapping("/insertVipDetails") + public Result insertVipDetails(VipDetails vipDetails) { + return appVipDetailsService.insertVipDetails(vipDetails); + + } +} + + diff --git a/src/main/java/com/sqx/modules/app/dao/AddressDao.java b/src/main/java/com/sqx/modules/app/dao/AddressDao.java new file mode 100644 index 0000000..10f368d --- /dev/null +++ b/src/main/java/com/sqx/modules/app/dao/AddressDao.java @@ -0,0 +1,20 @@ +package com.sqx.modules.app.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.app.entity.Address; +import com.sqx.modules.app.entity.App; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 地址 + * + */ +@Mapper +public interface AddressDao extends BaseMapper
{ + + int updateAddressIsDefault(@Param("userId") Long userId); + +} diff --git a/src/main/java/com/sqx/modules/app/dao/AppDao.java b/src/main/java/com/sqx/modules/app/dao/AppDao.java new file mode 100644 index 0000000..7c67b01 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/dao/AppDao.java @@ -0,0 +1,20 @@ +package com.sqx.modules.app.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.app.entity.App; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 用户升级 + * + */ +@Mapper +public interface AppDao extends BaseMapper { + + List selectNewApp(Integer classify); + + + +} diff --git a/src/main/java/com/sqx/modules/app/dao/MsgDao.java b/src/main/java/com/sqx/modules/app/dao/MsgDao.java new file mode 100644 index 0000000..cc0c790 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/dao/MsgDao.java @@ -0,0 +1,20 @@ +package com.sqx.modules.app.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.app.entity.Msg; +import org.apache.ibatis.annotations.Mapper; + +/** + * 用户 + * + */ +@Mapper +public interface MsgDao extends BaseMapper { + + Msg findByPhone(String phone); + + Msg findByPhoneAndCode(String phone, String msg); + + + +} diff --git a/src/main/java/com/sqx/modules/app/dao/UserBrowseDao.java b/src/main/java/com/sqx/modules/app/dao/UserBrowseDao.java new file mode 100644 index 0000000..921043e --- /dev/null +++ b/src/main/java/com/sqx/modules/app/dao/UserBrowseDao.java @@ -0,0 +1,21 @@ +package com.sqx.modules.app.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.sqx.modules.app.entity.UserBrowse; +import com.sqx.modules.app.response.UserFollowResponse; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +@Mapper +public interface UserBrowseDao extends BaseMapper { + + IPage> selectMyBrowse(IPage iPage, Long userId); + + List selectMyVisitor1(Long userId); + + List selectMyBrowse1(Long userId); + +} diff --git a/src/main/java/com/sqx/modules/app/dao/UserCertificationDao.java b/src/main/java/com/sqx/modules/app/dao/UserCertificationDao.java new file mode 100644 index 0000000..bb634ec --- /dev/null +++ b/src/main/java/com/sqx/modules/app/dao/UserCertificationDao.java @@ -0,0 +1,20 @@ +package com.sqx.modules.app.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserCertification; +import com.sqx.modules.app.entity.UserEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +@Mapper +public interface UserCertificationDao extends BaseMapper { + + IPage> queryCertification(IPage iPage, @Param("status") String status, @Param("name") String name,@Param("classify") Integer classify); + + IPage> queryUserCertification(IPage iPage, @Param("name") String name,@Param("phone")String phone); +} diff --git a/src/main/java/com/sqx/modules/app/dao/UserDao.java b/src/main/java/com/sqx/modules/app/dao/UserDao.java new file mode 100644 index 0000000..e9f726d --- /dev/null +++ b/src/main/java/com/sqx/modules/app/dao/UserDao.java @@ -0,0 +1,55 @@ +package com.sqx.modules.app.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.artificer.vo.UserArtificerVO; +import com.sqx.modules.material.entity.Material; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * 用户 + */ +@Mapper +public interface UserDao extends BaseMapper { + + + IPage selectUserPage(Page page, String search, Integer sex, String platform, + Integer isAuthentication, String sysPhone, Integer status, + String userName,String invitationCode,String inviterCode, + Integer member,Integer ordersCount,Integer isAgency,Integer isShop,String artificerName); + + int queryInviterCount(@Param("inviterCode") String inviterCode); + + int queryUserCount(@Param("type") int type, @Param("date") String date,@Param("isAuthentication") Integer isAuthentication,@Param("phone") Integer phone); + + Double queryPayMoney(@Param("type") int type, @Param("date") String date); + + IPage> queryCourseOrder(Page iPage, @Param("type") int type, @Param("date") String date); + + int userMessage(String date, int type); + + int insertUser(UserEntity userEntity); + + IPage> takingOrdersMessage(Page> iPage, @Param("type") Long type, @Param("date") String date); + + int updateUserClientIdIsNull(String clientid); + + int updateUserConsortiaIdIsNull(Long userId); + + int updateUserClientIdIsNullByClientId(Long consortiaId); + + int userPlatform(String platform,String date,Integer type); + + IPage> selectAgencyOrdersMoneyList(Page> page,String userName,String phone,String startTime,String endTime); + + + List getArtificerInfo(); + + IPage merchantPromotion(IPage pages,@Param("userEntity")UserEntity userEntity); +} diff --git a/src/main/java/com/sqx/modules/app/dao/UserFollowDao.java b/src/main/java/com/sqx/modules/app/dao/UserFollowDao.java new file mode 100644 index 0000000..01d9eb3 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/dao/UserFollowDao.java @@ -0,0 +1,26 @@ +package com.sqx.modules.app.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserFollow; +import com.sqx.modules.app.response.UserFollowResponse; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +@Mapper +public interface UserFollowDao extends BaseMapper { + + IPage> selectMyFollow(IPage iPage, Long userId); + + IPage> selectFans(IPage iPage, Long userId); + + List selectMyFollow1(Long userId); + + List selectFans1(Long userId); + + +} diff --git a/src/main/java/com/sqx/modules/app/dao/UserMoneyArtificerDao.java b/src/main/java/com/sqx/modules/app/dao/UserMoneyArtificerDao.java new file mode 100644 index 0000000..edbbb9d --- /dev/null +++ b/src/main/java/com/sqx/modules/app/dao/UserMoneyArtificerDao.java @@ -0,0 +1,14 @@ +package com.sqx.modules.app.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.entity.UserMoneyArtificer; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +@Mapper +public interface UserMoneyArtificerDao extends BaseMapper { + + int updateMoney(@Param("type") Integer type, @Param("userId") Long userId,@Param("artificerId") Long artificerId,@Param("money") Double money); + +} diff --git a/src/main/java/com/sqx/modules/app/dao/UserMoneyDao.java b/src/main/java/com/sqx/modules/app/dao/UserMoneyDao.java new file mode 100644 index 0000000..3e7ade9 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/dao/UserMoneyDao.java @@ -0,0 +1,17 @@ +package com.sqx.modules.app.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.app.entity.UserMoney; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; + +@Mapper +public interface UserMoneyDao extends BaseMapper { + + void updateMayMoney(@Param("type") Integer type, @Param("userId") Long userId, @Param("money") Double money); + + void updateCashDeposit(@Param("type") Integer type, @Param("userId") Long userId,@Param("cashDeposit") Double cashDeposit); + +} diff --git a/src/main/java/com/sqx/modules/app/dao/UserMoneyDetailsDao.java b/src/main/java/com/sqx/modules/app/dao/UserMoneyDetailsDao.java new file mode 100644 index 0000000..0e0b8d3 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/dao/UserMoneyDetailsDao.java @@ -0,0 +1,16 @@ +package com.sqx.modules.app.dao; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.app.entity.UserMoneyDetails; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; + +@Mapper +public interface UserMoneyDetailsDao extends BaseMapper { + Double monthIncome(@Param("date") String date,@Param("userId") Long userId); + Double selectMyProfit(Long userId); + + BigDecimal selectSumRefund(Long userId,String startTime,String endTime); + +} diff --git a/src/main/java/com/sqx/modules/app/dao/UserVipDao.java b/src/main/java/com/sqx/modules/app/dao/UserVipDao.java new file mode 100644 index 0000000..20e6ffe --- /dev/null +++ b/src/main/java/com/sqx/modules/app/dao/UserVipDao.java @@ -0,0 +1,9 @@ +package com.sqx.modules.app.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.app.entity.UserVip; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface UserVipDao extends BaseMapper { +} diff --git a/src/main/java/com/sqx/modules/app/dao/UserVisitorDao.java b/src/main/java/com/sqx/modules/app/dao/UserVisitorDao.java new file mode 100644 index 0000000..2e51012 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/dao/UserVisitorDao.java @@ -0,0 +1,17 @@ +package com.sqx.modules.app.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.sqx.modules.app.entity.UserVisitor; +import com.sqx.modules.app.response.UserFollowResponse; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +@Mapper +public interface UserVisitorDao extends BaseMapper { + IPage> selectMyVisitor(IPage iPage, Long userId); + + List selectMyVisitor1(Long userId); +} diff --git a/src/main/java/com/sqx/modules/app/dao/VipDetailsDao.java b/src/main/java/com/sqx/modules/app/dao/VipDetailsDao.java new file mode 100644 index 0000000..ef194b4 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/dao/VipDetailsDao.java @@ -0,0 +1,9 @@ +package com.sqx.modules.app.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.app.entity.VipDetails; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface VipDetailsDao extends BaseMapper { +} diff --git a/src/main/java/com/sqx/modules/app/dao/VipDiscountDao.java b/src/main/java/com/sqx/modules/app/dao/VipDiscountDao.java new file mode 100644 index 0000000..56cb27a --- /dev/null +++ b/src/main/java/com/sqx/modules/app/dao/VipDiscountDao.java @@ -0,0 +1,11 @@ +package com.sqx.modules.app.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.app.entity.VipDiscount; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface VipDiscountDao extends BaseMapper { + + +} diff --git a/src/main/java/com/sqx/modules/app/entity/Address.java b/src/main/java/com/sqx/modules/app/entity/Address.java new file mode 100644 index 0000000..9cc26c8 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/Address.java @@ -0,0 +1,74 @@ +package com.sqx.modules.app.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description address + * @author fang + * @date 2021-11-10 + */ +@Data +@TableName("address") +public class Address implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 地址id + */ + private Integer addressId; + + /** + * 姓名 + */ + private String name; + + /** + * 电话 + */ + private String phone; + + /** + * 省 + */ + private String province; + + /** + * 市 + */ + private String city; + + /** + * 区 + */ + private String district; + + /** + * 详细地址 + */ + private String detailsAddress; + + /** + * 是否是默认地址 + */ + private Integer isDefault; + + /** + * 时间 + */ + private String createTime; + + private Long userId; + + private String longitude; + + private String latitude; + + public Address() {} +} diff --git a/src/main/java/com/sqx/modules/app/entity/App.java b/src/main/java/com/sqx/modules/app/entity/App.java new file mode 100644 index 0000000..9670f9e --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/App.java @@ -0,0 +1,37 @@ +package com.sqx.modules.app.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 广告位 + */ +@Data +@TableName("app") +public class App implements Serializable { + @TableId + private Long id; + + private String createAt; + + private String androidWgtUrl; + + private String iosWgtUrl; + + private String wgtUrl; + + private String version; + + private String iosVersion; + + private String method; + + private String des; + + private Integer classify;//1用户端 2技师端 + +} + diff --git a/src/main/java/com/sqx/modules/app/entity/AppUserInfo.java b/src/main/java/com/sqx/modules/app/entity/AppUserInfo.java new file mode 100644 index 0000000..11691cb --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/AppUserInfo.java @@ -0,0 +1,23 @@ +package com.sqx.modules.app.entity; + +import lombok.Data; + +import java.util.List; + +@Data +public class AppUserInfo { + + + + private String openid; + private String nickname; + private int sex; + private String province; + private String city; + private String country; + private String headimgurl; + private String unionid; + private List privilege; + + +} diff --git a/src/main/java/com/sqx/modules/app/entity/Msg.java b/src/main/java/com/sqx/modules/app/entity/Msg.java new file mode 100644 index 0000000..58a67ad --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/Msg.java @@ -0,0 +1,27 @@ +package com.sqx.modules.app.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author fang + * @date 2020/7/10 + */ +@Data +@TableName("msg") +public class Msg implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId + private Long id; + + private String code; + + private String phone; + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/app/entity/UserBrowse.java b/src/main/java/com/sqx/modules/app/entity/UserBrowse.java new file mode 100644 index 0000000..2326a02 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/UserBrowse.java @@ -0,0 +1,54 @@ +package com.sqx.modules.app.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description user_browse + * @author liyuan + * @date 2021-08-12 + */ +@Data +@ApiModel("user_browse") +public class UserBrowse implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 浏览访客id + */ + @ApiModelProperty("浏览访客id") + private Long id; + + /** + * 用户id + */ + @ApiModelProperty("用户id") + private Long userId; + + /** + * 被浏览id + */ + @ApiModelProperty("被浏览id") + private Long byBrowseId; + + + /** + * 接单id + */ + @ApiModelProperty("接单id") + private Long takingId; + /** + * 更新时间 + */ + @ApiModelProperty("更新时间") + private String updateTime; + + public UserBrowse() {} +} diff --git a/src/main/java/com/sqx/modules/app/entity/UserCertification.java b/src/main/java/com/sqx/modules/app/entity/UserCertification.java new file mode 100644 index 0000000..9d766b5 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/UserCertification.java @@ -0,0 +1,105 @@ +package com.sqx.modules.app.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author liyuan + * @description user_certification + * @date 2021-08-13 + */ +@Data +@ApiModel("user_certification") +public class UserCertification implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 用户实名认证id + */ + @ApiModelProperty("用户实名认证id") + private Long id; + + /** + * 真实姓名 + */ + @ApiModelProperty("真实姓名") + private String name; + + /** + * 身份证号码 + */ + @ApiModelProperty("身份证号码") + private String idNumber; + + /** + * 用户id + */ + @ApiModelProperty("用户id") + private Long userId; + + @TableField(exist = false) + private UserEntity userEntity; + + /** + * 创建时间 + */ + @ApiModelProperty("创建时间") + private String createTime; + /** + * 正面 + */ + private String front; + /** + * 反面 + */ + private String back; + + private Integer sex; + + /** + * 母婴护理 + */ + private String infantImg; + + private String birthdate; + + /** + * 育婴资格 + */ + private String infantImgs; + + + /** + * 状态 + */ + private Long status; + + /** + * 说明 + */ + private String remek; + + /** + * 修改时间 + */ + private String updateTime; + + private Integer classify; + + private String address; + + private String phone; + + private String ordersNo; + + public UserCertification() { + } +} diff --git a/src/main/java/com/sqx/modules/app/entity/UserDetails.java b/src/main/java/com/sqx/modules/app/entity/UserDetails.java new file mode 100644 index 0000000..77ee340 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/UserDetails.java @@ -0,0 +1,27 @@ +package com.sqx.modules.app.entity; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class UserDetails { + /** + * 本月订单数量 + */ + private int monthlyOrderNum; + /** + * 本月充值金额 + */ + private BigDecimal monthlyRechargeMoney; + /** + *本月提现数量 + */ + private int monthWithdrawalNum; + /** + * 本月提现金额 + */ + private BigDecimal monthlyWithdrawalMoney; + + +} diff --git a/src/main/java/com/sqx/modules/app/entity/UserEntity.java b/src/main/java/com/sqx/modules/app/entity/UserEntity.java new file mode 100644 index 0000000..8b95aac --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/UserEntity.java @@ -0,0 +1,243 @@ +package com.sqx.modules.app.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + + +/** + * 用户 + * + */ +@Data +@ApiModel("用户") +@TableName("tb_user") +public class UserEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 用户ID + */ + @ApiModelProperty("用户id") + @TableId(type = IdType.AUTO,value = "user_id") + private Long userId; + + /** + * 用户类型 1普通用户 2技师 + */ + @ApiModelProperty("用户类型 1普通用户 2技师") + @TableField("type") + private Integer type; + + + /** + * 用户名 + */ + @ApiModelProperty("用户名") + @TableField("user_name") + private String userName; + + /** + * 手机号 + */ + @ApiModelProperty("手机号") + private String phone; + + /** + * 头像 + */ + @ApiModelProperty("头像") + private String avatar; + /** + * 扫码渠道 + */ + @ApiModelProperty("扫码渠道") + private String scanningChannel; + /** + * 性别 1男 2女 + */ + @ApiModelProperty("性别 1男 2女") + private Integer sex; + /** + * 年龄 + */ + @ApiModelProperty("年龄") + private Integer age; + + /** + * 微信小程序openid + */ + @ApiModelProperty("微信小程序openid") + @TableField("open_id") + private String openId; + + private String artificerOpenId; + + /** + * 微信app openid + */ + @ApiModelProperty("微信公众号openid") + @TableField("wx_open_id") + private String wxOpenId; + + /** + * 密码 + */ + private String password; + + /** + * 创建时间 + */ + @TableField("create_time") + private String createTime; + + /** + * 更新时间 + */ + @TableField("update_time") + private String updateTime; + + /** + * 苹果id + */ + @TableField("apple_id") + private String appleId; + + /** + * 手机类型 1安卓 2ios + */ + @TableField("sys_phone") + private Integer sysPhone; + + /** + * 状态 1正常 2禁用 + */ + private Integer status; + + /** + * 来源 app 小程序 公众号 + */ + private String platform; + + /** + * 积分 + */ + private Integer jifen; + + /** + * 邀请码 + */ + @TableField("invitation_code") + private String invitationCode; + + /** + * 邀请人邀请码 + */ + @TableField("inviter_code") + private String inviterCode; + + private String clientid; + + private String zhiFuBao; + + private String zhiFuBaoName; + + /** + * 0未认证 1个人认证审核中 2个人认证成功 3个人认证失败 + */ + private Integer isAuthentication; + + /** + * 保证金状态 1待缴纳 2已缴纳 3申请退款中 + */ + private Integer isCashDeposit; + + /** + * 申请时间 + */ + private String cashDepositTime; + + /** + * 是否领取新人优惠券 + */ + private Integer isCoupon; + + private Integer risk; + + /** + * 申请代理商 + */ + private Integer isAgency; + + private BigDecimal userRate; + + private BigDecimal shopRate; + + /** + * 公会id + */ + private Long consortiaId; + + /** + * 是否是商家 1是 + */ + private Integer isShop; + + /** + * 银行卡号 + */ + private String bankCard; + + /** + * 银行名称 + */ + private String bankCardName; + + /** + * 银行卡用户名 + */ + private String bankCardUserName; + + /** + * 银行卡开户行地址 + */ + private String bankCardAddress; + + @TableField(exist = false) + private Integer member; + @TableField(exist = false) + private Integer scanningChannelCount; + + @TableField(exist = false) + private Integer ordersCount; + + @TableField(exist = false) + private String vipEndTime; + + @TableField(exist = false) + private BigDecimal money; + + @TableField(exist = false) + private String shopName; + + @TableField(exist = false) + private Long artificerId; + + @TableField(exist = false) + private String artificerName; + + + @TableField(exist = false) + private String loglattime; + + @TableField(exist = false) + private String loglataddress; + +} diff --git a/src/main/java/com/sqx/modules/app/entity/UserFollow.java b/src/main/java/com/sqx/modules/app/entity/UserFollow.java new file mode 100644 index 0000000..3bcff60 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/UserFollow.java @@ -0,0 +1,48 @@ +package com.sqx.modules.app.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description user_follow + * @author liyuan + * @date 2021-08-12 + */ +@Data +@ApiModel("user_follow") +public class UserFollow implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * id + */ + @ApiModelProperty("id") + private Long followId; + + /** + * 用户id + */ + @ApiModelProperty("用户id") + private Long userId; + + /** + * 关注用户id + */ + @ApiModelProperty("关注用户id") + private Long followUserId; + + /** + * 创建时间 + */ + @ApiModelProperty("创建时间") + private String createTime; + + public UserFollow() {} +} diff --git a/src/main/java/com/sqx/modules/app/entity/UserMoney.java b/src/main/java/com/sqx/modules/app/entity/UserMoney.java new file mode 100644 index 0000000..b8f615a --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/UserMoney.java @@ -0,0 +1,48 @@ +package com.sqx.modules.app.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@TableName("user_money") +@ApiModel("用户钱包") +public class UserMoney implements Serializable { + /** + * 主键id + */ + @ApiModelProperty("主键id") + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 钱包金额 + */ + @ApiModelProperty("钱包金额") + private BigDecimal money; + + /** + * 保证金 + */ + @ApiModelProperty("保证金") + private BigDecimal cashDeposit; + + /** + * 用户id + */ + @ApiModelProperty("用户id") + @TableField("user_id") + private Long userId; + +} diff --git a/src/main/java/com/sqx/modules/app/entity/UserMoneyArtificer.java b/src/main/java/com/sqx/modules/app/entity/UserMoneyArtificer.java new file mode 100644 index 0000000..ca91e29 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/UserMoneyArtificer.java @@ -0,0 +1,60 @@ +package com.sqx.modules.app.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.sqx.modules.artificer.entity.Artificer; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @description user_money_artificer + * @author fang + * @date 2023-02-16 + */ +@Data +@ApiModel("用户充值师傅钱包") +@TableName("user_money_artificer") +public class UserMoneyArtificer implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 用户充值师傅钱包 + */ + private Long userMoneyArtificerId; + + /** + * 用户id + */ + private Long userId; + + @TableField(exist = false) + private UserEntity userEntity; + + /** + * 师傅id + */ + private Long artificerId; + + @TableField(exist = false) + private Artificer artificer; + + /** + * 金额 + */ + private BigDecimal money; + + /** + * 时间 + */ + private String createTime; + + public UserMoneyArtificer() {} +} diff --git a/src/main/java/com/sqx/modules/app/entity/UserMoneyDetails.java b/src/main/java/com/sqx/modules/app/entity/UserMoneyDetails.java new file mode 100644 index 0000000..1a4d571 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/UserMoneyDetails.java @@ -0,0 +1,89 @@ +package com.sqx.modules.app.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@TableName("user_money_details") +@ApiModel("钱包详情") +public class UserMoneyDetails implements Serializable { + /** + * 钱包详情id + */ + @ApiModelProperty("钱包详情id") + @TableId(type = IdType.AUTO) + private Long id; + /** + * 用户id + */ + @TableField("user_id") + @ApiModelProperty("用户id") + private Long userId; + /** + * 对应用户id + */ + @TableField("by_user_id") + @ApiModelProperty("对应用户id") + private Long byUserId; + /** + * 标题 + */ + @ApiModelProperty("标题") + private String title; + /** + * 1注册 2购买 4提现 + */ + @ApiModelProperty("1注册 2购买 3提现 7商家 8指定钱包") + private Integer classify; + /** + * 类型 + */ + @ApiModelProperty("类型1充值 2.提现") + private Integer type; + /** + * 状态 1待支付 2已到账 3取消 + */ + @ApiModelProperty("状态 1待支付 2已到账 3取消") + private Integer state; + /** + * 金额 + */ + @ApiModelProperty("金额") + private BigDecimal money; + /** + * 内容 + */ + @ApiModelProperty("内容") + private String content; + /** + * 创建时间 + */ + @TableField("create_time") + @ApiModelProperty("创建时间") + private String createTime; + /** + * 余额 + */ + @ApiModelProperty("余额") + private BigDecimal balance; + /** + * 是否操作余额:1未操作余额 ,2操作余额 + */ + @ApiModelProperty("是否操作余额:1未操作余额 ,2操作余额") + private Integer manipulateType; + //技师id + private Long artificerId; + +} diff --git a/src/main/java/com/sqx/modules/app/entity/UserMoneyResult.java b/src/main/java/com/sqx/modules/app/entity/UserMoneyResult.java new file mode 100644 index 0000000..13aa8aa --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/UserMoneyResult.java @@ -0,0 +1,52 @@ +package com.sqx.modules.app.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@TableName("user_money") +@ApiModel("用户钱包") +public class UserMoneyResult implements Serializable { + /** + * 主键id + */ + @ApiModelProperty("主键id") + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 钱包金额 + */ + @ApiModelProperty("钱包金额") + private BigDecimal money; + /** + * 可提现金额 + */ + private BigDecimal withdrawableAmount; + + /** + * 保证金 + */ + @ApiModelProperty("保证金") + private BigDecimal cashDeposit; + + /** + * 用户id + */ + @ApiModelProperty("用户id") + @TableField("user_id") + private Long userId; + +} diff --git a/src/main/java/com/sqx/modules/app/entity/UserVip.java b/src/main/java/com/sqx/modules/app/entity/UserVip.java new file mode 100644 index 0000000..2cb8569 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/UserVip.java @@ -0,0 +1,42 @@ +package com.sqx.modules.app.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; +@Data +public class UserVip implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 用户会员ID + */ + @TableId + private Long vipId; + /** + * 会员类型 + */ + private Integer vipNameType; + @TableField(exist = false) + private VipDetails vipDetails; + + /** + * 用户ID + */ + private Long userId; + + /** + * 购买时间 + */ + private String createTime; + /** + * 到期时间 + */ + private String endTime; + + /** + *是否是会员 + */ + private Long isVip; + public UserVip() {} +} diff --git a/src/main/java/com/sqx/modules/app/entity/UserVisitor.java b/src/main/java/com/sqx/modules/app/entity/UserVisitor.java new file mode 100644 index 0000000..132cba6 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/UserVisitor.java @@ -0,0 +1,41 @@ +package com.sqx.modules.app.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description user_visitor + * @author liyuan + * @date 2021-08-23 + */ +@Data +public class UserVisitor implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 访客id + */ + private Long id; + + /** + * 用户id + */ + private Long userId; + + /** + * 访问用户id + */ + private Long byUserId; + + /** + * 更新时间 + */ + private String updateTime; + + public UserVisitor() {} +} diff --git a/src/main/java/com/sqx/modules/app/entity/VipDetails.java b/src/main/java/com/sqx/modules/app/entity/VipDetails.java new file mode 100644 index 0000000..b26d1da --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/VipDetails.java @@ -0,0 +1,38 @@ +package com.sqx.modules.app.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import weixin.popular.bean.card.Discount; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@TableName("vip_details") +@ApiModel("会员详情") +public class VipDetails implements Serializable { + + @TableId(type = IdType.AUTO) + private Long id; + + @ApiModelProperty("会员类型") + @TableField("vip_name_type") + private Integer vipNameType; + + @ApiModelProperty("会员价格") + private BigDecimal money; + + @TableField + private String vipName; + + private BigDecimal award; +} diff --git a/src/main/java/com/sqx/modules/app/entity/VipDiscount.java b/src/main/java/com/sqx/modules/app/entity/VipDiscount.java new file mode 100644 index 0000000..58587c8 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/entity/VipDiscount.java @@ -0,0 +1,32 @@ +package com.sqx.modules.app.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +@ApiModel("vip_discount") +public class VipDiscount implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * id + */ + @ApiModelProperty("id") + private Integer id; + + /** + * 优惠金币 + */ + @ApiModelProperty("优惠金币") + private BigDecimal discount; + + public VipDiscount() {} +} diff --git a/src/main/java/com/sqx/modules/app/form/LoginForm.java b/src/main/java/com/sqx/modules/app/form/LoginForm.java new file mode 100644 index 0000000..2680efd --- /dev/null +++ b/src/main/java/com/sqx/modules/app/form/LoginForm.java @@ -0,0 +1,20 @@ +package com.sqx.modules.app.form; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 登录表单 + * + */ +@Data +@ApiModel(value = "登录表单") +public class LoginForm { + @ApiModelProperty(value = "手机号") + private String mobile; + + @ApiModelProperty(value = "密码") + private String password; + +} diff --git a/src/main/java/com/sqx/modules/app/form/RegisterForm.java b/src/main/java/com/sqx/modules/app/form/RegisterForm.java new file mode 100644 index 0000000..c9052c8 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/form/RegisterForm.java @@ -0,0 +1,20 @@ +package com.sqx.modules.app.form; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 注册表单 + * + */ +@Data +@ApiModel(value = "注册表单") +public class RegisterForm { + @ApiModelProperty(value = "手机号") + private String mobile; + + @ApiModelProperty(value = "密码") + private String password; + +} diff --git a/src/main/java/com/sqx/modules/app/interceptor/AuthorizationInterceptor.java b/src/main/java/com/sqx/modules/app/interceptor/AuthorizationInterceptor.java new file mode 100644 index 0000000..bc9312a --- /dev/null +++ b/src/main/java/com/sqx/modules/app/interceptor/AuthorizationInterceptor.java @@ -0,0 +1,63 @@ +package com.sqx.modules.app.interceptor; + + +import com.sqx.common.exception.SqxException; +import com.sqx.modules.app.utils.JwtUtils; +import io.jsonwebtoken.Claims; +import com.sqx.modules.app.annotation.Login; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * 权限(Token)验证 + * + */ +@Component +public class AuthorizationInterceptor extends HandlerInterceptorAdapter { + @Autowired + private JwtUtils jwtUtils; + + public static final String USER_KEY = "userId"; + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + Login annotation; + if(handler instanceof HandlerMethod) { + annotation = ((HandlerMethod) handler).getMethodAnnotation(Login.class); + }else{ + return true; + } + + if(annotation == null){ + return true; + } + + //获取用户凭证 + String token = request.getHeader(jwtUtils.getHeader()); + if(StringUtils.isBlank(token)){ + token = request.getParameter(jwtUtils.getHeader()); + } + + //凭证为空 + if(StringUtils.isBlank(token)){ + throw new SqxException(jwtUtils.getHeader() + "不能为空", HttpStatus.UNAUTHORIZED.value()); + } + + Claims claims = jwtUtils.getClaimByToken(token); + if(claims == null || jwtUtils.isTokenExpired(claims.getExpiration())){ + throw new SqxException(jwtUtils.getHeader() + "失效,请重新登录", HttpStatus.UNAUTHORIZED.value()); + } + + //设置userId到request里,后续根据userId,获取用户信息 + request.setAttribute(USER_KEY, Long.parseLong(claims.getSubject())); + + return true; + } +} diff --git a/src/main/java/com/sqx/modules/app/resolver/LoginUserHandlerMethodArgumentResolver.java b/src/main/java/com/sqx/modules/app/resolver/LoginUserHandlerMethodArgumentResolver.java new file mode 100644 index 0000000..3ae6a96 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/resolver/LoginUserHandlerMethodArgumentResolver.java @@ -0,0 +1,44 @@ +package com.sqx.modules.app.resolver; + +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.interceptor.AuthorizationInterceptor; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.app.annotation.LoginUser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.MethodParameter; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.support.WebDataBinderFactory; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.method.support.ModelAndViewContainer; + +/** + * 有@LoginUser注解的方法参数,注入当前登录用户 + * + */ +@Component +public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver { + @Autowired + private UserService userService; + + @Override + public boolean supportsParameter(MethodParameter parameter) { + return parameter.getParameterType().isAssignableFrom(UserEntity.class) && parameter.hasParameterAnnotation(LoginUser.class); + } + + @Override + public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer container, + NativeWebRequest request, WebDataBinderFactory factory) throws Exception { + //获取用户ID + Object object = request.getAttribute(AuthorizationInterceptor.USER_KEY, RequestAttributes.SCOPE_REQUEST); + if(object == null){ + return null; + } + + //获取用户信息 + UserEntity user = userService.getById((Long)object); + + return user; + } +} diff --git a/src/main/java/com/sqx/modules/app/response/CourseOrderResponse.java b/src/main/java/com/sqx/modules/app/response/CourseOrderResponse.java new file mode 100644 index 0000000..aec06ea --- /dev/null +++ b/src/main/java/com/sqx/modules/app/response/CourseOrderResponse.java @@ -0,0 +1,25 @@ +package com.sqx.modules.app.response; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CourseOrderResponse implements Serializable { + /** + * 课程名称 + */ + private String coursename; + /** + * 售卖笔数 + */ + private int coursenum; + /** + * 售卖金额 + */ + private Double coursemoney; +} diff --git a/src/main/java/com/sqx/modules/app/response/HomeMessageResponse.java b/src/main/java/com/sqx/modules/app/response/HomeMessageResponse.java new file mode 100644 index 0000000..fa1d58c --- /dev/null +++ b/src/main/java/com/sqx/modules/app/response/HomeMessageResponse.java @@ -0,0 +1,52 @@ +package com.sqx.modules.app.response; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 首页信息返回实体 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class HomeMessageResponse implements Serializable { + /** + * 总用户数 + */ + private int totalUsers; + /** + *今日新增 + */ + private int newToday; + /** + *本月新增 + */ + private int newMonth; + /** + * 本年新增 + */ + private int newYear; + /** + * 总收入 + */ + private Double totalRevenue; + /** + * 今日收入 + */ + private Double todayRevenue; + /** + * 本月收入 + */ + private Double monthRevenue; + /** + * 本年收入 + */ + private Double yearRevenue; + +} diff --git a/src/main/java/com/sqx/modules/app/response/TakingOrderResponse.java b/src/main/java/com/sqx/modules/app/response/TakingOrderResponse.java new file mode 100644 index 0000000..c925ed4 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/response/TakingOrderResponse.java @@ -0,0 +1,20 @@ +package com.sqx.modules.app.response; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class TakingOrderResponse implements Serializable { + + private int orderNumber; + private String gameName; + private double payMoney; + + + + + + + +} diff --git a/src/main/java/com/sqx/modules/app/response/UserFollowResponse.java b/src/main/java/com/sqx/modules/app/response/UserFollowResponse.java new file mode 100644 index 0000000..6bd4306 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/response/UserFollowResponse.java @@ -0,0 +1,58 @@ +package com.sqx.modules.app.response; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class UserFollowResponse implements Serializable { + + /** + * id + */ + private Long id; + + /** + * 用户ID + */ + @ApiModelProperty("用户id") + private Long userId; + /** + * 用户名 + */ + @ApiModelProperty("用户名") + private String userName; + /** + * 头像 + */ + @ApiModelProperty("头像") + private String avatar; + /** + * 关注状态 + */ + private int status; + /** + * 时间 + */ + private String updateTime; + + private Integer sex; + + private Integer age; + + /** + * 接单id + */ + @TableField(exist = false) + private Long takingId; + private Integer authentication; + private String myLevel; + private String headImg; + private String orderTakingUserName; + private String birthdate; + + + +} diff --git a/src/main/java/com/sqx/modules/app/response/UserMessageResponse.java b/src/main/java/com/sqx/modules/app/response/UserMessageResponse.java new file mode 100644 index 0000000..f0e0962 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/response/UserMessageResponse.java @@ -0,0 +1,25 @@ +package com.sqx.modules.app.response; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class UserMessageResponse implements Serializable { + /** + * 总人数 + */ + private int totalNumber; + /** + * 普通用户人数 + */ + private int userNumber; + /** + * 会员人数 + */ + private int vipUserNumber; +} diff --git a/src/main/java/com/sqx/modules/app/service/AddressService.java b/src/main/java/com/sqx/modules/app/service/AddressService.java new file mode 100644 index 0000000..79858d5 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/AddressService.java @@ -0,0 +1,19 @@ +package com.sqx.modules.app.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.modules.app.entity.Address; +import com.sqx.modules.app.entity.App; + +import java.util.List; + +/** + * 地址 + * + */ +public interface AddressService extends IService
{ + + int updateAddressIsDefault(Long userId); + + +} diff --git a/src/main/java/com/sqx/modules/app/service/AppService.java b/src/main/java/com/sqx/modules/app/service/AppService.java new file mode 100644 index 0000000..3fabb74 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/AppService.java @@ -0,0 +1,25 @@ +package com.sqx.modules.app.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.modules.app.entity.App; + +import java.util.List; + +/** + * 升级 + * + */ +public interface AppService extends IService { + + App selectAppById(Long id); + + int insertApp(App app); + + int updateAppById(App app); + + int deleteAppById(Long id); + + List selectNewApp(Integer classify); + +} diff --git a/src/main/java/com/sqx/modules/app/service/IAppleService.java b/src/main/java/com/sqx/modules/app/service/IAppleService.java new file mode 100644 index 0000000..7879163 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/IAppleService.java @@ -0,0 +1,10 @@ +package com.sqx.modules.app.service; + + +import com.sqx.common.utils.Result; + +public interface IAppleService { + + Result getAppleUserInfo(String identityToken) throws Exception; + +} diff --git a/src/main/java/com/sqx/modules/app/service/MsgService.java b/src/main/java/com/sqx/modules/app/service/MsgService.java new file mode 100644 index 0000000..b422b2c --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/MsgService.java @@ -0,0 +1,17 @@ +package com.sqx.modules.app.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.modules.app.entity.Msg; + +/** + * 验证码 + * + */ +public interface MsgService extends IService { + + Msg findByPhone(String phone); + + Msg findByPhoneAndCode(String phone, String msg); + +} diff --git a/src/main/java/com/sqx/modules/app/service/UserBrowseService.java b/src/main/java/com/sqx/modules/app/service/UserBrowseService.java new file mode 100644 index 0000000..146804c --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/UserBrowseService.java @@ -0,0 +1,32 @@ +package com.sqx.modules.app.service; + +import com.sqx.common.utils.Result; +import org.springframework.web.bind.annotation.RequestAttribute; + +public interface UserBrowseService { + Result selectMyVisitor(Long userId, Long page, Long limit); + + Result selectMyBrowse(Long userId, Long page, Long limit); + + Result selectAmount(Long userId); + + Result addAmount(Long userId, Long byBrowseId, Long takingId); + + Result addVisitor(Long userId, Long byBrowseId); + + /** + * 删除我的访客 + * + * @param id + * @return + */ + Result deleteMyVisitor(Long id); + + /** + * 删除浏览足迹 + * + * @param id + * @return + */ + Result deleteMyBrowse(Long id); +} diff --git a/src/main/java/com/sqx/modules/app/service/UserCertificationService.java b/src/main/java/com/sqx/modules/app/service/UserCertificationService.java new file mode 100644 index 0000000..45e373b --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/UserCertificationService.java @@ -0,0 +1,25 @@ +package com.sqx.modules.app.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.entity.Certification; +import io.swagger.annotations.ApiParam; +import org.springframework.web.bind.annotation.RequestAttribute; + +public interface UserCertificationService { + Result insert(Long userId, String name, String idNumber, String front, String back,Integer classify,String phone,String address,Integer sex,String infantImg,String infantImgs,String birthdate,String ordersNo); + + Result isInsert(Long userId); + + Result queryCertification(Long page, Long limit, String status, String name,Integer classify); + + Result queryUserCertification(IPage iPage, String name,String phone); + + Result auditorUserCertification(Long status, Long id, String remek); + + Result queryInsert(Long userId,Integer classify); + + Result exitMoney(Long userId); + +} diff --git a/src/main/java/com/sqx/modules/app/service/UserFollowService.java b/src/main/java/com/sqx/modules/app/service/UserFollowService.java new file mode 100644 index 0000000..6c388e2 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/UserFollowService.java @@ -0,0 +1,32 @@ +package com.sqx.modules.app.service; +import com.sqx.common.utils.Result; +import org.springframework.web.bind.annotation.RequestAttribute; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @author liyuan + * @description user_follow + * @date 2021-08-12 + */ +public interface UserFollowService { + + /** + * 关注 / 取消关注 + */ + Result insert(Long userId, Long followUserId); + + /** + * 查看我的关注 + */ + Result selectMyFollow(Long userId,Long page,Long limit); + + /** + * 查看我的粉丝 + */ + Result selectFans(Long userId,Long page,Long limit); + + Result selectFollowUser( Long userId, Long followUserId); + /** + * 查询用户的最好 + */ +} diff --git a/src/main/java/com/sqx/modules/app/service/UserMoneyArtificerService.java b/src/main/java/com/sqx/modules/app/service/UserMoneyArtificerService.java new file mode 100644 index 0000000..9c73e99 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/UserMoneyArtificerService.java @@ -0,0 +1,17 @@ +package com.sqx.modules.app.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.entity.UserMoneyArtificer; +import com.sqx.modules.app.entity.UserMoneyDetails; +import org.springframework.web.bind.annotation.RequestAttribute; + +public interface UserMoneyArtificerService extends IService { + + void updateMoney(int i, Long userId,Long artificerId, double money); + +} diff --git a/src/main/java/com/sqx/modules/app/service/UserMoneyDetailsService.java b/src/main/java/com/sqx/modules/app/service/UserMoneyDetailsService.java new file mode 100644 index 0000000..d8de18d --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/UserMoneyDetailsService.java @@ -0,0 +1,26 @@ +package com.sqx.modules.app.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserMoneyDetails; +import com.sqx.modules.artificer.entity.Period; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; +import java.util.List; + +public interface UserMoneyDetailsService extends IService { + + Result queryUserMoneyDetails(Integer page, Integer limit, Long userId,Integer classify,Integer type,Long artificerId); + + Double monthIncome(String date,Long userId); + + BigDecimal selectSumRefund(Long userId, @Param("startTime") String startTime, @Param("endTime") String endTime); + + Result selectUserMoneyArtificer(Integer page,Integer limit,Long userId,Long artificerId,Integer user); + + Result selectIncomeByArtificerId(Integer page, Integer limit,Period period); + + List selectIncome(Period period); + +} diff --git a/src/main/java/com/sqx/modules/app/service/UserMoneyService.java b/src/main/java/com/sqx/modules/app/service/UserMoneyService.java new file mode 100644 index 0000000..d57e4f6 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/UserMoneyService.java @@ -0,0 +1,28 @@ +package com.sqx.modules.app.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.entity.UserMoneyDetails; +import org.springframework.web.bind.annotation.RequestAttribute; + +import java.math.BigDecimal; + +public interface UserMoneyService extends IService { + + Result payUserMoneyArtificer(@RequestAttribute Long userId, Long artificerId, BigDecimal money); + + UserMoney selectUserMoneyByUserId(Long userId); + + void updateMoney(int i, Long userId, double money); + + Double selectMyProfit(Long userId); + + PageUtils balanceDetailed(@RequestAttribute Long userId, Page ipage); + + Result profitDetailed(@RequestAttribute Long userId, IPage ipage); + +} diff --git a/src/main/java/com/sqx/modules/app/service/UserService.java b/src/main/java/com/sqx/modules/app/service/UserService.java new file mode 100644 index 0000000..1276d67 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/UserService.java @@ -0,0 +1,222 @@ +package com.sqx.modules.app.service; + + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserEntity; +import weixin.popular.bean.message.templatemessage.TemplateMessageItem; + +import java.text.ParseException; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * 用户 + * + * @author fang + * @date 2021/2/27 + */ +public interface UserService extends IService { + + /** + * 根据手机号查询用户 + * + * @param phone 手机号 + * @return + */ + UserEntity queryByPhone(String phone); + + /** + * 根据小程序微信openId查询用户 + * + * @param openId 微信小程序openId + * @return + */ + UserEntity queryByOpenId(String openId); + + UserEntity queryByArtificerOpenId(String openId); + + /** + * 根据微信APP openId查询用户 + * + * @param openId 微信APP openId + * @return + */ + UserEntity queryByWxOpenId(String openId); + + /** + * 根据userId查询用户 + * + * @param userId userId + * @return + */ + UserEntity queryByUserId(Long userId); + + UserEntity queryByInvitationCode(String invitationCode); + + /** + * 根据用户appleId查询用户 + * + * @param appleId + * @return + */ + UserEntity queryByAppleId(String appleId); + + + Result wxLogin(String code,Integer userType); + + /** + * 注册或更新用户信息 + * + * @param userInfo1 用户信息 + * @return 用户信息 + */ + Result wxRegister(UserEntity userInfo1); + + /** + * 注册或更新用户信息 + * + * @param appleId 苹果账号id + * @return 用户信息 + */ + Result iosRegister(String appleId); + + /** + * 发送验证码 + * + * @param phone 手机号 + * @param state 验证码类型 + * @return + */ + Result sendMsg(String phone, String state); + + /** + * 绑定手机号 + * + * @param phone 手机号 + * @param code 验证码 + * @return + */ + Result wxBindMobile(String phone, String code, String wxOpenId, String token, String platform, Integer sysPhone); + + /** + * @param phone + * @param code + * @param appleId + * @param platform + * @param sysPhone + * @return + */ + Result iosBindMobile(String phone, String code, String appleId, String platform, Integer sysPhone); + + /** + * 换绑手机号 + * + * @param phone 手机号 + * @param msg 验证码 + * @param userId 用户id + * @return + */ + Result updatePhone(String phone, String msg, Long userId); + + /** + * 登录token + * + * @param user 用户信息 + * @return + */ + Result getResult(UserEntity user); + + /** + * app注册或h5注册 + * + * @param pwd 密码 + * @param phone 手机号 + * @param msg 验证按 + * @param platform 来源 app h5 + * @param scanningChannel + * @return + */ + Result registerCode(String phone, String msg, String platform, Integer sysPhone, String openId, String inviterCode, String password, String userName, String avatar, String scanningChannel); + + + Result loginByOpenId(String openId); + + + Result wxAppLogin(String wxOpenId, String token); + + + /** + * app或h5登录 + * + * @param phone 手机号 + * @param pwd 密码 + * @return + */ + Result login(String phone, String pwd); + + + /** + * 根据 code 获取openId + * + * @param code + * @param userId + * @return + */ + Result getOpenId(String code, Long userId); + + + /** + * 根据用户id查询用户 + * + * @param userId 用户id + * @return + */ + UserEntity selectUserById(Long userId); + + void pushToSingle(String title, String content, String clientId); + + PageUtils selectUserPage(Integer page, Integer limit, String search, Integer sex, String platform, + Integer type,String sysPhone, Integer status, + String userName,String invitationCode,String inviterCode,Integer member, + Integer ordersUser,Integer isAgency,Integer isShop,String artificerName); + + + int queryInviterCount(String inviterCode); + + int queryUserCount(int type, String date,Integer isAuthentication,Integer phone ); + + int userPlatform(String platform,String date,Integer type); + + Double queryPayMoney(int type); + + IPage> queryCourseOrder(Page> iPage, int type, String date); + + int userMessage(String date, int type); + + Result loginApp(String phone, String password); + + Result registApp(String userName, String phone, String password, String msg, String platform, String inviterCode); + + Result takingOrdersMessage(Page> iPage, Long type, String date); + + Result forgetPwd(String pwd, String phone, String msg); + + void sendWxMessage(String templateId, LinkedHashMap data, String openid); + + int updateUserClientIdIsNull(String clientid); + + int updateUserConsortiaIdIsNull(Long userId); + + int updateUserClientIdIsNullByClientId(Long consortiaId); + + Result selectAgencyOrdersMoneyList(Integer page,Integer limit,String userName,String phone,String startTime,String endTime); + + Result integral(String type, Integer current, Integer size, String date,String artificerId) throws ParseException; + + IPage merchantPromotion(UserEntity userEntity, Integer page, Integer limit); +} diff --git a/src/main/java/com/sqx/modules/app/service/UserVipService.java b/src/main/java/com/sqx/modules/app/service/UserVipService.java new file mode 100644 index 0000000..f50765e --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/UserVipService.java @@ -0,0 +1,12 @@ +package com.sqx.modules.app.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserVip; +import org.springframework.web.bind.annotation.RequestAttribute; + +public interface UserVipService extends IService { + + UserVip selectUserVipByUserId(Long UserId); + Result isUserVip(@RequestAttribute Long userId); +} diff --git a/src/main/java/com/sqx/modules/app/service/VipDetailsService.java b/src/main/java/com/sqx/modules/app/service/VipDetailsService.java new file mode 100644 index 0000000..3c436f3 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/VipDetailsService.java @@ -0,0 +1,23 @@ +package com.sqx.modules.app.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.VipDetails; + +public interface VipDetailsService extends IService { + /** + * 查询会员的详情信息 + * + * @return + */ + Result selectVipDetails(); + + /** + * 添加会员的详情信息 + * + * @return + */ + Result insertVipDetails(VipDetails vipDetails); + +} diff --git a/src/main/java/com/sqx/modules/app/service/impl/AddressServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/AddressServiceImpl.java new file mode 100644 index 0000000..b39f1a3 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/impl/AddressServiceImpl.java @@ -0,0 +1,27 @@ +package com.sqx.modules.app.service.impl; + + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.modules.app.dao.AddressDao; +import com.sqx.modules.app.dao.AppDao; +import com.sqx.modules.app.entity.Address; +import com.sqx.modules.app.entity.App; +import com.sqx.modules.app.service.AddressService; +import com.sqx.modules.app.service.AppService; +import org.apache.ibatis.annotations.Param; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + + +@Service("AddressService") +public class AddressServiceImpl extends ServiceImpl implements AddressService { + + @Override + public int updateAddressIsDefault(Long userId){ + return baseMapper.updateAddressIsDefault(userId); + } + + +} diff --git a/src/main/java/com/sqx/modules/app/service/impl/AppServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/AppServiceImpl.java new file mode 100644 index 0000000..743210c --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/impl/AppServiceImpl.java @@ -0,0 +1,45 @@ +package com.sqx.modules.app.service.impl; + + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.modules.app.dao.AppDao; +import com.sqx.modules.app.entity.App; +import com.sqx.modules.app.service.AppService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + + +@Service("AppService") +public class AppServiceImpl extends ServiceImpl implements AppService { + + @Autowired + private AppDao appDao; + + + @Override + public App selectAppById(Long id) { + return appDao.selectById(id); + } + + @Override + public int insertApp(App app) { + return appDao.insert(app); + } + + @Override + public int updateAppById(App app) { + return appDao.updateById(app); + } + + @Override + public int deleteAppById(Long id) { + return appDao.deleteById(id); + } + + @Override + public List selectNewApp(Integer classify) { + return appDao.selectNewApp(classify); + } +} diff --git a/src/main/java/com/sqx/modules/app/service/impl/AppleServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/AppleServiceImpl.java new file mode 100644 index 0000000..60a89d3 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/impl/AppleServiceImpl.java @@ -0,0 +1,156 @@ +package com.sqx.modules.app.service.impl; + + +import com.auth0.jwk.Jwk; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.service.IAppleService; +import io.jsonwebtoken.*; +import lombok.extern.slf4j.Slf4j; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.apache.tomcat.util.codec.binary.Base64; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +import java.security.PublicKey; + +/** + * @Description 苹果登录service + * @author fang + * @date 2020/11/4 + */ + +@Slf4j +@Component +public class AppleServiceImpl implements IAppleService { + + @Override + public Result getAppleUserInfo(String identityToken) throws Exception { + //验证identityToken + if (!verify(identityToken)) { + log.error("苹果解析失败!"); + return Result.error("苹果账号验证失败,请退出重试!"); + } + //对identityToken解码 + JSONObject json = parserIdentityToken(identityToken); + if (json == null) { + return Result.error("苹果账号验证失败,请退出重试!"); + } + String appleUserId = String.valueOf(json.get("sub")); + log.error("苹果账号解析成功:"+appleUserId); + System.err.println(appleUserId); + return Result.success().put("data",appleUserId); + } + + /** + * 对前端传来的JWT字符串identityToken的第二部分进行解码 + * 主要获取其中的aud和sub,aud大概对应ios前端的包名,sub大概对应当前用户的授权的openID + * + * @param identityToken 身份token + * @return {"aud":"com.xkj.****","sub":"000***.8da764d3f9e34d2183e8da08a1057***.0***","c_hash":"UsKAuEoI-****","email_verified":"true","auth_time":1574673481,"iss":"https://appleid.apple.com","exp":1574674081,"iat":1574673481,"email":"****@qq.com"} + */ + private JSONObject parserIdentityToken(String identityToken) { + String[] arr = identityToken.split("\\."); + String decode = new String(Base64.decodeBase64(arr[1])); + String substring = decode.substring(0, decode.indexOf("}") + 1); + return JSONObject.fromObject(substring); + } + + + public Boolean verify(String jwt) throws Exception { + JSONArray arr = getAuthKeys(); + if (arr == null) { + log.error("获取不到苹果的验证秘钥!!"); + return false; + } + + JSONObject authKey = null; + //先取苹果第一个key进行校验 + if(arr.size()==2){ + authKey = JSONObject.fromObject(arr.getString(0)); + if (verifyExc(jwt, authKey)) { + log.error("苹果解析成功!1"); + return true; + } else { + //再取第二个key校验 + authKey = JSONObject.fromObject(arr.getString(1)); + return verifyExc(jwt, authKey); + } + }else{ + authKey = JSONObject.fromObject(arr.getString(0)); + if (verifyExc(jwt, authKey)) { + log.error("苹果解析成功!1"); + return true; + } + //再取第二个key校验 + authKey = JSONObject.fromObject(arr.getString(1)); + if(verifyExc(jwt, authKey)){ + log.error("苹果解析成功!2"); + return true; + }else{ + authKey = JSONObject.fromObject(arr.getString(2)); + return verifyExc(jwt, authKey); + } + } + } + + + /** + * 对前端传来的identityToken进行验证 + * + * @param jwt 对应前端传来的 identityToken + * @param authKey 苹果的公钥 authKey + * @return + * @throws Exception + */ + private static Boolean verifyExc(String jwt, JSONObject authKey) throws Exception { + + Jwk jwa = Jwk.fromValues(authKey); + PublicKey publicKey = jwa.getPublicKey(); + + String aud = ""; + String sub = ""; + if (jwt.split("\\.").length > 1) { + String claim = new String(Base64.decodeBase64(jwt.split("\\.")[1])); + aud = JSONObject.fromObject(claim).get("aud").toString(); + sub = JSONObject.fromObject(claim).get("sub").toString(); + } + JwtParser jwtParser = Jwts.parser().setSigningKey(publicKey); + jwtParser.requireIssuer("https://appleid.apple.com"); + jwtParser.requireAudience(aud); + jwtParser.requireSubject(sub); + + try { + Jws claim = jwtParser.parseClaimsJws(jwt); + if (claim != null && claim.getBody().containsKey("auth_time")) { + System.out.println(claim); + return true; + } + return false; + } catch (ExpiredJwtException e) { + log.error("[AppleServiceImpl.verifyExc] [error] [apple identityToken expired]", e); + return false; + } catch (Exception e) { + log.error("[AppleServiceImpl.verifyExc] [error] [apple identityToken illegal]", e); + return false; + } + } + + + /** + * 获取苹果的公钥 + * + * @return + */ + private static JSONArray getAuthKeys() { + String url = "https://appleid.apple.com/auth/keys"; + RestTemplate restTemplate = new RestTemplate(); + JSONObject json = restTemplate.getForObject(url, JSONObject.class); + if (json != null) { + return json.getJSONArray("keys"); + } + return null; + } + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/app/service/impl/MsgServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/MsgServiceImpl.java new file mode 100644 index 0000000..f7912d7 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/impl/MsgServiceImpl.java @@ -0,0 +1,30 @@ +package com.sqx.modules.app.service.impl; + + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.modules.app.dao.MsgDao; +import com.sqx.modules.app.entity.Msg; +import com.sqx.modules.app.service.MsgService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +@Service("MsgService") +public class MsgServiceImpl extends ServiceImpl implements MsgService { + + @Autowired + private MsgDao msgDao; + + @Override + public Msg findByPhone(String phone){ + return msgDao.findByPhone(phone); + } + + @Override + public Msg findByPhoneAndCode(String phone, String msg){ + return msgDao.findByPhoneAndCode(phone,msg); + } + + + +} diff --git a/src/main/java/com/sqx/modules/app/service/impl/UserBrowseServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/UserBrowseServiceImpl.java new file mode 100644 index 0000000..5669168 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/impl/UserBrowseServiceImpl.java @@ -0,0 +1,135 @@ +package com.sqx.modules.app.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.dao.UserBrowseDao; +import com.sqx.modules.app.dao.UserFollowDao; +import com.sqx.modules.app.dao.UserVisitorDao; +import com.sqx.modules.app.entity.UserBrowse; +import com.sqx.modules.app.entity.UserVisitor; +import com.sqx.modules.app.response.UserFollowResponse; +import com.sqx.modules.app.service.UserBrowseService; +import com.sqx.modules.taking.dao.GameDao; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +@AllArgsConstructor +public class UserBrowseServiceImpl extends ServiceImpl implements UserBrowseService { + private UserFollowDao userFollowDao; + private UserVisitorDao userVisitorDao; + private GameDao gameDao; + private UserBrowseDao userBrowseDao; + + @Override + public Result selectMyVisitor(Long userId, Long page, Long limit) { + //查询我的访客 + IPage iPage = new Page(page, limit); + return Result.success().put("data", new PageUtils(userVisitorDao.selectMyVisitor(iPage, userId))); + } + + @Override + public Result selectMyBrowse(Long userId, Long page, Long limit) { + //查询我的浏览 + IPage iPage = new Page(page, limit); + IPage iPage1 = baseMapper.selectMyBrowse(iPage, userId); + return Result.success().put("data", new PageUtils(iPage1)); + } + + @Override + public Result selectAmount(Long userId) { + Map map = new HashMap<>(); + baseMapper.selectMyVisitor1(userId); + map.put("fans", userFollowDao.selectFans1(userId).size()); + map.put("follow", userFollowDao.selectMyFollow1(userId).size()); + map.put("visitor", userVisitorDao.selectMyVisitor1(userId).size()); + map.put("browse", baseMapper.selectMyBrowse1(userId).size()); + return Result.success().put("data", map); + } + + @Override + public Result addAmount(Long userId, Long byBrowseId, Long takingId) { + + UserBrowse userBrowse = baseMapper.selectOne(new QueryWrapper().eq("user_id", userId).eq("by_browse_id", byBrowseId).eq("taking_id", takingId)); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (userBrowse != null) { + userBrowse.setUpdateTime(simpleDateFormat.format(new Date())); + baseMapper.updateById(userBrowse); + } else { + UserBrowse userBrowse1 = new UserBrowse(); + userBrowse1.setUserId(userId); + userBrowse1.setByBrowseId(byBrowseId); + userBrowse1.setTakingId(takingId); + userBrowse1.setUpdateTime(simpleDateFormat.format(new Date())); + baseMapper.insert(userBrowse1); + } + return Result.success(); + } + + @Override + public Result addVisitor(Long userId, Long byBrowseId) { + if (userId.equals(byBrowseId)) { + return Result.success(); + } else if (byBrowseId == null) { + return Result.success(); + } else { + UserVisitor userVisitor = userVisitorDao.selectOne(new QueryWrapper().eq("user_id", userId).eq("by_user_id", byBrowseId)); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (userVisitor != null) { + userVisitor.setUpdateTime(simpleDateFormat.format(new Date())); + userVisitorDao.updateById(userVisitor); + } else { + UserVisitor userVisitor1 = new UserVisitor(); + userVisitor1.setUserId(userId); + userVisitor1.setByUserId(byBrowseId); + userVisitor1.setUpdateTime(simpleDateFormat.format(new Date())); + userVisitorDao.insert(userVisitor1); + } + return Result.success(); + } + } + + @Override + public Result deleteMyVisitor(Long id) { + UserVisitor userVisitor = userVisitorDao.selectById(id); + if (userVisitor == null) { + return Result.error("访客已被删除!"); + } else { + int i = userVisitorDao.deleteById(userVisitor.getId()); + if (i > 0) { + return Result.success(); + } else { + return Result.error(); + } + } + + } + + @Override + public Result deleteMyBrowse(Long id) { + + UserBrowse userBrowse = userBrowseDao.selectById(id); + if (userBrowse == null) { + return Result.error("足迹已被删除!"); + } else { + int i = userBrowseDao.deleteById(id); + if (i > 0) { + return Result.success(); + } else { + return Result.error(); + } + } + } + + +} diff --git a/src/main/java/com/sqx/modules/app/service/impl/UserCertificationImpl.java b/src/main/java/com/sqx/modules/app/service/impl/UserCertificationImpl.java new file mode 100644 index 0000000..994a6e8 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/impl/UserCertificationImpl.java @@ -0,0 +1,267 @@ +package com.sqx.modules.app.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.dao.UserCertificationDao; +import com.sqx.modules.app.dao.UserDao; +import com.sqx.modules.app.entity.UserCertification; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.entity.UserMoneyDetails; +import com.sqx.modules.app.service.UserCertificationService; +import com.sqx.modules.app.service.UserMoneyDetailsService; +import com.sqx.modules.app.service.UserMoneyService; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.pay.dao.PayDetailsDao; +import com.sqx.modules.pay.entity.PayDetails; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +@Service +public class UserCertificationImpl extends ServiceImpl implements UserCertificationService { + + @Autowired + private UserDao userDao; + @Autowired + private UserMoneyDetailsService userMoneyDetailsService; + @Autowired + private UserMoneyService userMoneyService; + @Autowired + private CommonInfoService commonInfoService; + @Autowired + private PayDetailsDao payDetailsDao; + + + @Override + public Result insert(Long userId, String name, String idNumber, String front, String back,Integer classify,String phone,String address,Integer sex,String infantImg,String infantImgs,String birthdate,String ordersNo) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + //查询身份证是否被绑定 + UserCertification userCertification = baseMapper.selectOne(new QueryWrapper().eq("id_number", idNumber).eq("status", 1)); + if (userCertification != null) { + return Result.error("身份证号已经被绑定"); + } else { + //查询是否实名过 + UserCertification userCertification1 = baseMapper.selectOne(new QueryWrapper().eq("user_id", userId)); + if (userCertification1 == null) { + //没有实名过 + UserCertification userCertification2 = new UserCertification(); + userCertification2.setUserId(userId); + userCertification2.setIdNumber(idNumber); + userCertification2.setName(name); + userCertification2.setCreateTime(simpleDateFormat.format(new Date())); + userCertification2.setFront(front); + userCertification2.setBack(back); + userCertification2.setStatus((long) 0); + userCertification2.setUpdateTime(simpleDateFormat.format(new Date())); + userCertification2.setClassify(classify); + userCertification2.setPhone(phone); + userCertification2.setAddress(address); + userCertification2.setSex(sex); + userCertification2.setInfantImg(infantImg); + userCertification2.setInfantImgs(infantImgs); + userCertification2.setBirthdate(birthdate); + userCertification2.setOrdersNo(ordersNo); + baseMapper.insert(userCertification2); + } else { + //实名过 + userCertification1.setName(name); + userCertification1.setIdNumber(idNumber); + userCertification1.setFront(front); + userCertification1.setBack(back); + userCertification1.setStatus((long) 0); + userCertification1.setUpdateTime(simpleDateFormat.format(new Date())); + userCertification1.setClassify(classify); + userCertification1.setPhone(phone); + userCertification1.setAddress(address); + userCertification1.setInfantImg(infantImg); + userCertification1.setInfantImgs(infantImgs); + userCertification1.setBirthdate(birthdate); + userCertification1.setOrdersNo(ordersNo); + baseMapper.updateById(userCertification1); + } + UserEntity userEntity = userDao.selectById(userId); + if(classify==1){ + userEntity.setIsAuthentication(1); + }else{ + userEntity.setIsAuthentication(4); + } + userDao.updateById(userEntity); + return Result.success(); + } + } + + @Override + public Result isInsert(Long userId) { + UserCertification userCertification = baseMapper.selectOne(new QueryWrapper().eq("user_id", userId).eq("status", 1)); + if (userCertification != null) { + return Result.success(); + } else { + return Result.error(); + } + } + + public static Integer getAgeByCertId(String certId) { + String birthday = ""; + if (certId.length() == 18) { + birthday = certId.substring(6, 10) + "/" + + certId.substring(10, 12) + "/" + + certId.substring(12, 14); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); + Date now = new Date(); + Date birth = new Date(); + try { + birth = sdf.parse(birthday); + } catch (ParseException e) { + } + long intervalMilli = now.getTime() - birth.getTime(); + int age = (int) (intervalMilli/(24 * 60 * 60 * 1000))/365; + return age; + } + + + + + @Override + public Result queryCertification(Long page, Long limit, String status, String name,Integer classify) { + + if (page == null || limit == null) { + return Result.error("分页参数为空"); + } else { + IPage iPage = new Page(page, limit); + String nname = null; + if (name != null && !(name.equals(""))) { + nname = "%" + name + "%"; + } + IPage iPage1 = baseMapper.queryCertification(iPage, status, nname,classify); + List userCertifications = iPage1.getRecords(); + for (UserCertification userCertification : userCertifications) { + if (userCertification != null) { + //关联用户 + userCertification.setUserEntity(userDao.selectById(userCertification.getUserId())); + } + } + return Result.success().put("data", new PageUtils(iPage1)); + } + } + + @Override + public Result queryUserCertification(IPage iPage, String name,String phone) { + String nname = null; + if (name != null && !(name.equals(""))) { + nname = "%" + name + "%"; + } + String nphone=null; + if(phone != null && !(phone.equals(""))){ + nphone = "%" + phone + "%"; + } + + return Result.success().put("data", baseMapper.queryUserCertification(iPage, nname,nphone)); + } + + @Override + public Result auditorUserCertification(Long status, Long id, String remek) { + UserCertification userCertification = baseMapper.selectById(id); + if (userCertification != null) { + if(status==1){ + UserEntity userEntity = userDao.selectById(userCertification.getUserId()); + if(userCertification.getClassify()==1){ + userEntity.setIsAuthentication(2); + }else{ + userEntity.setIsAuthentication(5); + } + userDao.updateById(userEntity); + }else{ + UserEntity userEntity = userDao.selectById(userCertification.getUserId()); + if(userCertification.getClassify()==1){ + userEntity.setIsAuthentication(3); + }else{ + userEntity.setIsAuthentication(6); + } + userDao.updateById(userEntity); + PayDetails payDetails = payDetailsDao.selectByOrderId(userCertification.getOrdersNo()); + userMoneyService.updateMoney(1,userCertification.getUserId(),payDetails.getMoney()); + UserMoneyDetails userMoneyDetails=new UserMoneyDetails(); + userMoneyDetails.setMoney(BigDecimal.valueOf(payDetails.getMoney())); + userMoneyDetails.setUserId(userCertification.getUserId()); + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(userCertification.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setContent("实名认证审核失败,资金退还至钱包"); + userMoneyDetails.setTitle("实名认证审核失败"); + userMoneyDetails.setType(1); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + } + userCertification.setStatus(status); + userCertification.setRemek(remek); + baseMapper.updateById(userCertification); + return Result.success(); + } else { + return Result.error("要审核的信息不存在!"); + } + } + + @Override + public Result queryInsert(Long userId,Integer classify) { + return Result.success().put("data", baseMapper.selectOne(new QueryWrapper().eq("user_id", userId).eq("classify",classify))); + } + + + @Override + public Result exitMoney(Long userId){ + UserCertification userCertification = baseMapper.selectOne(new QueryWrapper().eq("user_id", userId)); + if(userCertification==null){ + return Result.error("您还没有提交实名认证信息!"); + } + if(userCertification.getStatus()!=1){ + return Result.error("您的认证信息未通过!"); + } + + + + PayDetails payDetails = payDetailsDao.selectByOrderId(userCertification.getOrdersNo()); + userMoneyService.updateMoney(1,userCertification.getUserId(),payDetails.getMoney()); + + UserMoneyDetails userMoneyDetails=new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(userCertification.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(BigDecimal.valueOf(payDetails.getMoney())); + userMoneyDetails.setUserId(userCertification.getUserId()); + userMoneyDetails.setContent("您的实名认证信息已失效,保证金已经退款至您的账户"); + userMoneyDetails.setTitle("退保证金"); + userMoneyDetails.setType(1); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + + baseMapper.deleteById(userCertification.getId()); + UserEntity userEntity = userDao.selectById(userId); + userEntity.setIsAuthentication(0); + userDao.updateById(userEntity); + + return Result.success(); + + } + + + +} diff --git a/src/main/java/com/sqx/modules/app/service/impl/UserFollowServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/UserFollowServiceImpl.java new file mode 100644 index 0000000..ee1e230 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/impl/UserFollowServiceImpl.java @@ -0,0 +1,139 @@ +package com.sqx.modules.app.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.dao.UserDao; +import com.sqx.modules.app.dao.UserFollowDao; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.entity.UserFollow; +import com.sqx.modules.app.response.UserFollowResponse; +import com.sqx.modules.app.service.UserFollowService; +import lombok.AllArgsConstructor; +import org.checkerframework.checker.units.qual.A; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +@Service +public class UserFollowServiceImpl extends ServiceImpl implements UserFollowService { + + @Autowired + private UserDao userDao; + private ReentrantReadWriteLock reentrantReadWriteLock=new ReentrantReadWriteLock(true); + + @Override + public Result insert(Long userId, Long followUserId) { + reentrantReadWriteLock.writeLock().lock(); + try{ + //查询是否关注过此接单 + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("user_id", userId); + queryWrapper.eq("follow_user_id", followUserId); + UserFollow user = baseMapper.selectOne(queryWrapper); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + //如果没关注 关注 + if (user == null) { + String data = simpleDateFormat.format(new Date()); + UserFollow userFollow = new UserFollow(); + userFollow.setUserId(userId); + userFollow.setFollowUserId(followUserId); + userFollow.setCreateTime(data); + baseMapper.insert(userFollow); + return Result.success("关注成功"); + } else { + //关注了 取消关注 + baseMapper.deleteById(user.getFollowId()); + return Result.success("取消关注成功"); + } + }catch (Exception e){ + e.printStackTrace(); + log.error("关注出错了!"+e.getMessage(),e); + }finally { + reentrantReadWriteLock.writeLock().unlock(); + } + return Result.error("系统繁忙,请稍后再试!"); + } + + @Override + public Result selectMyFollow(Long userId, Long page, Long limit) { + IPage iPage = new Page<>(page, limit); + //查看我的关注 + IPage iPage1 = baseMapper.selectMyFollow(iPage, userId); + List lists = iPage1.getRecords(); + for (UserFollowResponse userFollowResponse : lists) { + if (userFollowResponse != null) { + //用我关注的用户id 去查询是否关注过我 + List list = baseMapper.selectMyFollow1(userFollowResponse.getUserId()); + if (list.size() > 0) { + for (UserFollowResponse userFollow : list) { + if (userFollow.getUserId().equals(userId)) { + //他也关注我 state 1 + userFollowResponse.setStatus(1); + break; + } else { + //他没关注我 state 2 + userFollowResponse.setStatus(2); + } + } + } else { + //他没关注我 state 2 + userFollowResponse.setStatus(2); + } + } + } + + return Result.success().put("data", new PageUtils(iPage1)); + } + + @Override + public Result selectFans(Long userId, Long page, Long limit) { + IPage iPage = new Page<>(page, limit); + //查看我的粉丝 + IPage page1 = baseMapper.selectFans(iPage, userId); + List lists = page1.getRecords(); + for (UserFollowResponse userFollowResponse : lists) { + if (userFollowResponse != null) { + //查询我是否关注我的粉丝 + List list = baseMapper.selectFans1(userFollowResponse.getUserId()); + if (list.size() > 0) { + for (UserFollowResponse userFollow : list) { + if (userFollow.getUserId().equals(userId)) { + //我关注了 state 1 + userFollowResponse.setStatus(1); + break; + } else { + //我没关注 state 2 + userFollowResponse.setStatus(2); + } + } + } else { + //他没关注我 state 2 + userFollowResponse.setStatus(2); + } + } + + } + return Result.success().put("data", new PageUtils(page1)); + } + + @Override + public Result selectFollowUser(Long userId, Long followUserId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("user_id", userId); + queryWrapper.eq("follow_user_id", followUserId); + UserFollow userFollow = baseMapper.selectOne(queryWrapper); + if (userFollow != null) { + return Result.success().put("data", true); + } else { + return Result.success().put("data", false); + } + } +} diff --git a/src/main/java/com/sqx/modules/app/service/impl/UserMoneyArtificerServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/UserMoneyArtificerServiceImpl.java new file mode 100644 index 0000000..403b6eb --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/impl/UserMoneyArtificerServiceImpl.java @@ -0,0 +1,32 @@ +package com.sqx.modules.app.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.dao.UserMoneyArtificerDao; +import com.sqx.modules.app.dao.UserMoneyDao; +import com.sqx.modules.app.dao.UserMoneyDetailsDao; +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.entity.UserMoneyArtificer; +import com.sqx.modules.app.entity.UserMoneyDetails; +import com.sqx.modules.app.service.UserMoneyArtificerService; +import com.sqx.modules.app.service.UserMoneyService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; + +@Service +@Slf4j +public class UserMoneyArtificerServiceImpl extends ServiceImpl implements UserMoneyArtificerService { + + @Override + public void updateMoney(int i, Long userId,Long artificerId, double money) { + baseMapper.updateMoney(i, userId,artificerId, money); + } + +} diff --git a/src/main/java/com/sqx/modules/app/service/impl/UserMoneyDetailsServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/UserMoneyDetailsServiceImpl.java new file mode 100644 index 0000000..d24d4ec --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/impl/UserMoneyDetailsServiceImpl.java @@ -0,0 +1,355 @@ +package com.sqx.modules.app.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.dao.UserMoneyDetailsDao; +import com.sqx.modules.app.entity.UserMoneyArtificer; +import com.sqx.modules.app.entity.UserMoneyDetails; +import com.sqx.modules.app.service.UserMoneyArtificerService; +import com.sqx.modules.app.service.UserMoneyDetailsService; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.ArtificerTime; +import com.sqx.modules.artificer.entity.Period; +import com.sqx.modules.artificer.entity.FundDetailsResult; +import com.sqx.modules.artificer.service.ArtificerService; +import com.sqx.modules.artificer.service.ArtificerTimeService; +import com.sqx.modules.common.service.CommonInfoService; +import jodd.util.StringUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Service +public class UserMoneyDetailsServiceImpl extends ServiceImpl implements UserMoneyDetailsService { + + + @Autowired + private CommonInfoService commonInfoService; + @Autowired + private UserMoneyArtificerService userMoneyArtificerService; + @Autowired + private ArtificerTimeService artificerTimeService; + @Autowired + private ArtificerService artificerService; + @Autowired + private UserService userService; + + @Override + public Result queryUserMoneyDetails(Integer page, Integer limit, Long userId,Integer classify,Integer type,Long artificerId) { + IPage page1 = new Page(page, limit); + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("user_id", userId); + if(classify!=null){ + queryWrapper.eq("classify", classify); + } + if(type!=null){ + queryWrapper.eq("type", type); + } + if(artificerId!=null){ + queryWrapper.eq("artificer_id", artificerId); + } + queryWrapper.orderByDesc("create_time"); + return Result.success().put("data", baseMapper.selectPage(page1, queryWrapper)); + } + + @Override + public Double monthIncome(String date, Long userId) { + return baseMapper.monthIncome(date,userId); + } + + @Override + public BigDecimal selectSumRefund(Long userId,String startTime,String endTime) { + + return baseMapper.selectSumRefund(userId,startTime,endTime); + } + + @Override + public Result selectUserMoneyArtificer(Integer page,Integer limit,Long userId,Long artificerId,Integer user){ + IPage userMoneyArtificerIPage = userMoneyArtificerService.page(new Page<>(page, limit), + new QueryWrapper() + .eq(userId!=null,"user_id", userId) + .eq(artificerId!=null,"artificer_id",artificerId)); + List records = userMoneyArtificerIPage.getRecords(); + + String value = commonInfoService.findOne(392).getValue(); + for(UserMoneyArtificer userMoneyArtificer:records){ + userMoneyArtificer.setUserEntity(userService.getById(userMoneyArtificer.getUserId())); + Artificer artificer = artificerService.selectArtificerById(userId,userMoneyArtificer.getArtificerId(),null,null); + if(artificer!=null){ + if("30".equals(value)){ + + SimpleDateFormat sdfHour=new SimpleDateFormat("HH"); + SimpleDateFormat sdfMinute=new SimpleDateFormat("mm"); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat md = new SimpleDateFormat("MM-dd"); + Date dateTime = new Date(); + Calendar calendar=Calendar.getInstance(); + String hour = sdfHour.format(dateTime); + String minute = sdfMinute.format(dateTime); + int minuteInt = Integer.parseInt(minute); + int hourInt = Integer.parseInt(hour); + StringBuilder stringBuilders=new StringBuilder(); + if(minuteInt>=30){ + if(hourInt==23){ + hourInt=0; + minuteInt=0; + }else{ + minuteInt=0; + hourInt=hourInt+1; + } + }else{ + minuteInt=30; + } + + if(hourInt<10){ + stringBuilders.append("0").append(hourInt); + }else{ + stringBuilders.append(hourInt); + } + stringBuilders.append(":"); + if(minuteInt<10){ + stringBuilders.append("0").append(minuteInt); + }else{ + stringBuilders.append(minuteInt); + } + + calendar=Calendar.getInstance(); + String date = simpleDateFormat.format(dateTime); + String oldDate = simpleDateFormat.format(dateTime); + hour = sdfHour.format(dateTime); + minute = sdfMinute.format(dateTime); + minuteInt = Integer.parseInt(minute); + hourInt = Integer.parseInt(hour); + if(minuteInt>=30){ + if(hourInt==23){ + hourInt=0; + minuteInt=0; + calendar.add(Calendar.DAY_OF_MONTH,1); + date = simpleDateFormat.format(calendar.getTime()); + }else{ + minuteInt=0; + hourInt=hourInt+1; + } + }else{ + minuteInt=30; + } + while (true){ + StringBuilder stringBuilder=new StringBuilder(); + if(hourInt<10){ + stringBuilder.append("0").append(hourInt); + }else{ + stringBuilder.append(hourInt); + } + stringBuilder.append(":"); + if(minuteInt<10){ + stringBuilder.append("0").append(minuteInt); + }else{ + stringBuilder.append(minuteInt); + } + ArtificerTime artificerTime = artificerTimeService.getOne(new QueryWrapper().eq("artificer_id", artificer.getArtificerId()).eq("artificer_date", date).eq("artificer_time", stringBuilder.toString())); + if(artificerTime==null){ + if(oldDate.equals(date)){ + artificer.setTime(stringBuilder.toString()); + }else{ + artificer.setTime(md.format(calendar.getTime())+" "+stringBuilder.toString()); + } + if(artificer.getStatus()!=null && artificer.getStatus()==2){ + artificer.setState(3); + }else{ + if(stringBuilder.toString().equals(stringBuilders.toString())){ + artificer.setState(1); + }else{ + artificer.setState(2); + } + } + + break; + } + if(minuteInt==30){ + if(hourInt==23){ + hourInt=0; + minuteInt=0; + calendar.add(Calendar.DAY_OF_MONTH,1); + date = simpleDateFormat.format(calendar.getTime()); + }else{ + minuteInt=0; + hourInt=hourInt+1; + } + }else{ + minuteInt=30; + } + } + }else{ + + SimpleDateFormat sdf=new SimpleDateFormat("HH"); + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat md = new SimpleDateFormat("MM-dd"); + Date dateTime = new Date(); + String date = simpleDateFormat.format(dateTime); + String oldDate = simpleDateFormat.format(dateTime); + String time = sdf.format(dateTime); + String times=""; + if("23".equals(time)){ + time="00"; + times=time+":00"; + }else{ + time=String.valueOf(Integer.parseInt(time)+1); + times=time+":00"; + } + String nowTimes=times; + + Calendar calendar=Calendar.getInstance(); + date = simpleDateFormat.format(dateTime); + oldDate = simpleDateFormat.format(dateTime); + time = sdf.format(dateTime); + times=""; + if("23".equals(time)){ + time="00"; + times=time+":00"; + calendar.add(Calendar.DAY_OF_MONTH,1); + date = simpleDateFormat.format(calendar.getTime()); + }else{ + time=String.valueOf(Integer.parseInt(time)+1); + times=time+":00"; + } + while (true){ + ArtificerTime artificerTime = artificerTimeService.getOne(new QueryWrapper().eq("artificer_id", artificer.getArtificerId()).eq("artificer_date", date).eq("artificer_time", times)); + if(artificerTime==null){ + if(oldDate.equals(date)){ + times=time+":00"; + artificer.setTime(times); + }else{ + times=time+":00"; + artificer.setTime(md.format(calendar.getTime())+" "+times); + } + if(artificer.getStatus()!=null && artificer.getStatus()==2){ + artificer.setState(3); + }else{ + if(times.equals(nowTimes)){ + artificer.setState(1); + }else{ + artificer.setState(2); + } + } + break; + } + if("23".equals(time)){ + time="00"; + times=time+":00"; + calendar.add(Calendar.DAY_OF_MONTH,1); + date = simpleDateFormat.format(calendar.getTime()); + }else{ + time=String.valueOf(Integer.parseInt(time)+1); + times=time+":00"; + } + } + } + } + userMoneyArtificer.setArtificer(artificer); + } + if(user!=null && user==1){ + return Result.success().put("data",new PageUtils(userMoneyArtificerIPage)); + } + return Result.success().put("data",userMoneyArtificerIPage); + } + + @Override + public Result selectIncomeByArtificerId(Integer page, Integer limit,Period period) { + IPage page1 = new Page(page, limit); + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("user_id", period.getArtificerId()); + if(StringUtil.isNotEmpty(period.getStartFundData().toString())){ + queryWrapper.between("create_time", period.getStartFundData(), period.getEndFundData()); + } + if(period.getDetailsType()!= null){ + //方便前端判断 传1则查询全部 2查询收入 3查询支出 + switch (period.getDetailsType()){ + case 1: + break; + case 2: + queryWrapper.eq("type", 1); + break; + case 3: + queryWrapper.eq("type", 2); + break; + } + } + //只查询操作余额的数据 + queryWrapper.eq("manipulate_type", 2); + queryWrapper.orderByDesc("create_time"); + IPage page2 = baseMapper.selectPage(page1, queryWrapper); + //资金明细添加到返回对象中 + FundDetailsResult fundDetailsResult = new FundDetailsResult(); + fundDetailsResult.setUserMoneyDetailsList(page2); + QueryWrapper queryWrapper1 = new QueryWrapper(); + queryWrapper1.eq("user_id", period.getArtificerId()); + queryWrapper1.select("sum(money) as sum_value"); + if(StringUtil.isNotEmpty(period.getStartFundData().toString())){ + queryWrapper1.between("create_time", period.getStartFundData(), period.getEndFundData()); + } + //设置类型为进账 + queryWrapper1.eq("type", "1"); + //查询进账 + Map map = baseMapper.selectMaps(queryWrapper1).get(0); + BigDecimal income = new BigDecimal(0); + if(map != null) { + income = new BigDecimal(map.get("sum_value").toString()) ; + } + //设置类型为出账 + queryWrapper1.eq("type", "2"); + //查询出账 + Map map2 = baseMapper.selectMaps(queryWrapper1).get(0); + BigDecimal outgoing = new BigDecimal(0); + //如果结果为空则没有出账使用默认值0计算 + if(map2 != null){ + outgoing = new BigDecimal(map2.get("sum_value").toString()) ; + } + //计算进账减去出账结果为用户该阶段可提现数据 + income.subtract(outgoing); + //赋值资金明细 + fundDetailsResult.setIncome(income.subtract(outgoing).toString()); + //赋值查询数据开始时间 + fundDetailsResult.setStartFundData(period.getStartFundData()); + //赋值查询数据结束时间 + fundDetailsResult.setEndFundData(period.getEndFundData()); + return Result.success().put("data", fundDetailsResult); + } + @Override + public List selectIncome(Period period) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("user_id", period.getArtificerId()); + if(StringUtil.isNotEmpty(period.getStartFundData().toString())){ + queryWrapper.between("create_time", period.getStartFundData(), period.getEndFundData()); + } + if(period.getDetailsType()!= null){ + //方便前端判断 传1则查询全部 2查询收入 3查询支出 + switch (period.getDetailsType()){ + case 1: + break; + case 2: + queryWrapper.eq("type", 1); + break; + case 3: + queryWrapper.eq("type", 2); + break; + } + } + //只查询操作余额的数据 + queryWrapper.eq("manipulate_type", 2); + queryWrapper.orderByDesc("create_time"); + List page2 = baseMapper.selectList(queryWrapper); + return page2; + } +} diff --git a/src/main/java/com/sqx/modules/app/service/impl/UserMoneyServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/UserMoneyServiceImpl.java new file mode 100644 index 0000000..8a77cd9 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/impl/UserMoneyServiceImpl.java @@ -0,0 +1,139 @@ +package com.sqx.modules.app.service.impl; + +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.dao.*; +import com.sqx.modules.app.entity.*; +import com.sqx.modules.app.service.*; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.Period; +import com.sqx.modules.artificer.service.ArtificerService; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.service.MessageService; +import com.sqx.modules.utils.PeriodUtil; +import jodd.util.StringUtil; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestAttribute; + +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +@Service +@Slf4j +public class UserMoneyServiceImpl extends ServiceImpl implements UserMoneyService { + + @Autowired + private UserMoneyDetailsDao userMoneyDetailsDao; + @Autowired + private UserMoneyArtificerService userMoneyArtificerService; + @Autowired + private ArtificerService artificerService; + @Autowired + private UserMoneyDetailsServiceImpl userMoneyDetailsService; + @Override + public Result payUserMoneyArtificer(@RequestAttribute Long userId, Long artificerId, BigDecimal money){ + UserMoney userMoney = selectUserMoneyByUserId(userId); + if(userMoney.getMoney().doubleValue()().eq("user_id",userId).eq("artificer_id", artificerId)); + if(userMoneyArtificer==null){ + userMoneyArtificer=new UserMoneyArtificer(); + userMoneyArtificer.setUserId(userId); + userMoneyArtificer.setArtificerId(artificerId); + userMoneyArtificer.setMoney(money); + userMoneyArtificer.setCreateTime(DateUtils.format(new Date())); + userMoneyArtificerService.save(userMoneyArtificer); + }else{ + userMoneyArtificerService.updateMoney(1,userId,artificerId,money.doubleValue()); + } + + /*userMoneyDetails = new UserMoneyDetails(); + userMoneyDetails.setClassify(8); + userMoneyDetails.setUserId(userId); + userMoneyDetails.setTitle("钱包充值技师钱包"); + userMoneyDetails.setContent("指定技师“"+artificer.getArtificerName()+"”钱包充值:"+money); + userMoneyDetails.setType(1); + userMoneyDetails.setMoney(money); + userMoneyDetails.setCreateTime(format); + userMoneyDetails.setArtificerId(artificerId); + userMoneyDetailsDao.insert(userMoneyDetails);*/ + + return Result.success(); + } + + + + + @Override + public void updateMoney(int i, Long userId, double money) { + baseMapper.updateMayMoney(i, userId, money); + } + + @Override + public UserMoney selectUserMoneyByUserId(Long userId) { + UserMoney userMoney = baseMapper.selectOne(new QueryWrapper().eq("user_id", userId)); + if(userMoney==null){ + userMoney=new UserMoney(); + userMoney.setMoney(BigDecimal.ZERO); + userMoney.setUserId(userId); + userMoney.setCashDeposit(BigDecimal.ZERO); + baseMapper.insert(userMoney); + } + return userMoney; + } + + @Override + public Double selectMyProfit(Long userId) { + + return userMoneyDetailsDao.selectMyProfit(userId); + } + + + + @Override + public PageUtils balanceDetailed(Long userId, Page pages) { + return new PageUtils(userMoneyDetailsDao.selectPage(pages,new QueryWrapper().eq("user_id",userId).orderByDesc("create_time "))); + } + + @Override + public Result profitDetailed(Long userId, IPage ipage) { + //收益明细 + return null; + } + +} diff --git a/src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..e3289c5 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java @@ -0,0 +1,1275 @@ +package com.sqx.modules.app.service.impl; + +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.aliyun.oss.ClientException; +import com.aliyuncs.CommonRequest; +import com.aliyuncs.CommonResponse; +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.IAcsClient; +import com.aliyuncs.http.MethodType; +import com.aliyuncs.profile.DefaultProfile; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.getui.push.v2.sdk.ApiHelper; +import com.getui.push.v2.sdk.GtApiConfiguration; +import com.getui.push.v2.sdk.api.PushApi; +import com.getui.push.v2.sdk.common.ApiResult; +import com.getui.push.v2.sdk.dto.req.Audience; +import com.getui.push.v2.sdk.dto.req.message.PushChannel; +import com.getui.push.v2.sdk.dto.req.message.PushDTO; +import com.getui.push.v2.sdk.dto.req.message.PushMessage; +import com.getui.push.v2.sdk.dto.req.message.android.GTNotification; +import com.getui.push.v2.sdk.dto.req.message.ios.Alert; +import com.getui.push.v2.sdk.dto.req.message.ios.Aps; +import com.getui.push.v2.sdk.dto.req.message.ios.IosDTO; +import com.github.qcloudsms.SmsSingleSenderResult; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.dao.MsgDao; +import com.sqx.modules.app.dao.UserDao; +import com.sqx.modules.app.dao.UserMoneyDao; +import com.sqx.modules.app.entity.*; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.app.utils.JwtUtils; +import com.sqx.modules.app.utils.UserConstantInterface; +import com.sqx.modules.artificer.dao.UserRechargeDao; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.service.ArtificerService; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.file.utils.Md5Utils; +import com.sqx.modules.invite.service.InviteService; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.service.MessageService; +import com.sqx.modules.utils.HttpClientUtil; +import com.sqx.modules.utils.InvitationCodeUtil; +import com.tencentcloudapi.common.Credential; +import com.tencentcloudapi.common.exception.TencentCloudSDKException; +import com.tencentcloudapi.common.profile.ClientProfile; +import com.tencentcloudapi.common.profile.HttpProfile; +import com.tencentcloudapi.sms.v20210111.SmsClient; +import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest; +import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import weixin.popular.api.MessageAPI; +import weixin.popular.api.SnsAPI; +import weixin.popular.bean.message.templatemessage.TemplateMessage; +import weixin.popular.bean.message.templatemessage.TemplateMessageItem; +import weixin.popular.bean.message.templatemessage.TemplateMessageResult; +import weixin.popular.util.JsonUtil; + +import javax.websocket.SendResult; +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +import static com.sqx.modules.utils.PeriodUtil.obtainCycle; + +/** + * 用户 + * + * @author fang + * @date 2021/2/27 + */ + +@Service("userService") +@Slf4j +public class UserServiceImpl extends ServiceImpl implements UserService { + + @Autowired + private CommonInfoService commonInfoService; + @Autowired + private MsgDao msgDao; + @Autowired + private JwtUtils jwtUtils; + @Autowired + private InviteService inviteService; + @Autowired + private UserMoneyDao userMoneyDao; + @Autowired + private MessageService messageService; + @Autowired + private ArtificerService artificerService; + @Autowired + private UserRechargeDao userRechargeDao; + + @Override + public UserEntity queryByPhone(String phone) { + return baseMapper.selectOne(new QueryWrapper().eq("phone", phone)); + } + + @Override + public UserEntity queryByOpenId(String openId) { + return baseMapper.selectOne(new QueryWrapper().eq("open_id", openId)); + } + + @Override + public UserEntity queryByArtificerOpenId(String openId) { + return baseMapper.selectOne(new QueryWrapper().eq("artificer_open_id", openId)); + } + + @Override + public UserEntity queryByWxOpenId(String openId) { + return baseMapper.selectOne(new QueryWrapper().eq("wx_open_id", openId)); + } + + @Override + public UserEntity queryByAppleId(String appleId) { + return baseMapper.selectOne(new QueryWrapper().eq("apple_id", appleId)); + } + + @Override + public UserEntity queryByUserId(Long userId) { + UserEntity userEntity = baseMapper.selectOne(new QueryWrapper().eq("user_id", userId)); + return userEntity; + } + + @Override + public UserEntity queryByInvitationCode(String invitationCode) { + return baseMapper.selectOne(new QueryWrapper().eq("invitation_code", invitationCode)); + } + + @Override + public Result updatePhone(String phone, String msg, Long userId) { + Msg msg1 = msgDao.findByPhoneAndCode(phone, msg); + //校验短信验证码 + if (msg1 != null) { + UserEntity userInfo = queryByPhone(phone); + if (userInfo != null) { + return Result.error("手机号已经被其他账号绑定"); + } else { + UserEntity one = baseMapper.selectById(userId); + one.setPhone(phone); + baseMapper.updateById(one); + return Result.success(); + } + } + return Result.error("验证码不正确"); + } + + @Override + public Result iosRegister(String appleId) { + if (StringUtils.isEmpty(appleId)) { + return Result.error("账号信息获取失败,请退出重试!"); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String date = sdf.format(new Date()); + // 根据返回的user实体类,判断用户是否是新用户,不是的话,更新最新登录时间,是的话,将用户信息存到数据库 + UserEntity userInfo = queryByAppleId(appleId); + if (userInfo != null) { + if (userInfo.getStatus().equals(2)) { + return Result.error("账号已被封禁,请联系客服处理!"); + } + userInfo.setUpdateTime(date); + baseMapper.updateById(userInfo); + //返回用户信息 + UserEntity user = queryByAppleId(appleId); + return getResult(user); + } else { + return Result.error(-200, "请先绑定手机号账号!"); + } + } + + @Override + public Result wxLogin(String code,Integer userType) { + try { + //微信小程序APPID + String appid; + //微信小程序秘钥 + String secret; + if(userType==null || userType==1){ + appid = commonInfoService.findOne(45).getValue(); + secret = commonInfoService.findOne(46).getValue(); + }else{ + appid = commonInfoService.findOne(243).getValue(); + secret = commonInfoService.findOne(244).getValue(); + } + // 配置请求参数 + Map param = new HashMap<>(); + param.put("appid", appid); + param.put("secret", secret); + param.put("js_code", code); + param.put("grant_type", UserConstantInterface.WX_LOGIN_GRANT_TYPE); + param.put("scope", "snsapi_userinfo"); + // 发送请求 + String wxResult = HttpClientUtil.doGet(UserConstantInterface.WX_LOGIN_URL, param); + log.info(wxResult); + JSONObject jsonObject = JSONObject.parseObject(wxResult); + // 获取参数返回的 + String session_key = jsonObject.get("session_key").toString(); + //返回微信小程序openId + String open_id = jsonObject.get("openid").toString(); + UserEntity userEntity; + //判断是否注册过 + if(userType==null || userType==1){ + userEntity = queryByOpenId(open_id); + }else{ + userEntity = queryByArtificerOpenId(open_id); + } + Map map = new HashMap<>(); + // 封装返回小程序 + map.put("session_key", session_key); + map.put("open_id", open_id); + if (jsonObject.get("unionid") != null) { + String unionid = jsonObject.get("unionid").toString(); + map.put("unionid", unionid); + } else { + map.put("unionid", "-1"); + } + + if (userEntity == null) { + map.put("flag", "1"); + } else { + if(StringUtils.isEmpty(userEntity.getPhone())){ + map.put("flag", "1"); + }else{ + map.put("flag", userEntity.getPhone()); + } + + } + return Result.success("登陆成功").put("data", map); + } catch (Exception e) { + System.err.println(e.toString()); + return Result.success("登录失败!"); + } + } + + + @Override + public Result wxRegister(UserEntity userInfo1) { + if (StringUtils.isEmpty(userInfo1.getOpenId())) { + return Result.error("账号信息获取失败,请退出重试!"); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String date = sdf.format(new Date()); + // 根据返回的user实体类,判断用户是否是新用户,不是的话,更新最新登录时间,是的话,将用户信息存到数据库 + + //判断是否在app登陆过 手机号是否有账号 + UserEntity userByMobile = queryByPhone(userInfo1.getPhone()); + if (userByMobile != null) { + //有账号则绑定账号 + if(userInfo1.getType()!=null && userInfo1.getType()==2){ + userByMobile.setArtificerOpenId(userInfo1.getOpenId()); + userInfo1.setArtificerOpenId(userInfo1.getOpenId()); + }else{ + userByMobile.setOpenId(userInfo1.getOpenId()); + } + baseMapper.updateById(userByMobile); + if (userByMobile.getStatus().equals(2)) { + return Result.error("账号已被封禁,请联系客服处理!"); + } + if(userInfo1.getType()!=null && userInfo1.getType()==2){ + Artificer artificer = artificerService.selectArtificerByUserId(userByMobile.getUserId()); + if(artificer==null){ + artificer=new Artificer(); + artificer.setStatus(2); + artificer.setUserId(userByMobile.getUserId()); + artificer.setArtificerName(userByMobile.getUserName()); + artificer.setArtificerImg(userByMobile.getAvatar()); + artificer.setArtificerSales(0); + artificer.setCreateTime(sdf.format(new Date())); + artificer.setCreditScore(BigDecimal.valueOf(100)); + artificer.setTripWay(1); + artificer.setRate(new BigDecimal(commonInfoService.findOne(381).getValue())); + artificerService.save(artificer); + } + } + } else { + UserEntity userInfo; + if(userInfo1.getType()!=null && userInfo1.getType()==2){ + userInfo1.setArtificerOpenId(userInfo1.getOpenId()); + userInfo1.setOpenId(null); + userInfo = queryByArtificerOpenId(userInfo1.getArtificerOpenId()); + }else{ + userInfo = queryByOpenId(userInfo1.getOpenId()); + } + + if (userInfo != null) { + if (userInfo.getStatus().equals(2)) { + return Result.error("账号已被封禁,请联系客服处理!"); + } + if (StringUtils.isBlank(userInfo1.getUserName()) || "微信用户".equals(userInfo1.getUserName())) { + if (StringUtils.isNotEmpty(userInfo1.getPhone())) { + userInfo1.setUserName(userInfo1.getPhone().replaceAll("(\\d{3})\\d*([0-9a-zA-Z]{4})", "$1****$2")); + } + } + userInfo.setUpdateTime(date); + baseMapper.updateById(userInfo); + if(userInfo1.getType()!=null && userInfo1.getType()==2){ + Artificer artificer = artificerService.selectArtificerByUserId(userInfo.getUserId()); + if(artificer==null){ + artificer=new Artificer(); + artificer.setStatus(2); + artificer.setUserId(userInfo.getUserId()); + artificer.setArtificerName(userInfo.getUserName()); + artificer.setArtificerImg(userInfo.getAvatar()); + artificer.setArtificerSales(0); + artificer.setCreateTime(sdf.format(new Date())); + artificer.setCreditScore(BigDecimal.valueOf(100)); + artificer.setTripWay(1); + artificer.setRate(new BigDecimal(commonInfoService.findOne(381).getValue())); + artificerService.save(artificer); + } + } + } else { + + if (StringUtils.isEmpty(userInfo1.getInviterCode())) { + userInfo1.setInviterCode(commonInfoService.findOne(88).getValue()); + } + if (StringUtils.isBlank(userInfo1.getUserName()) || "微信用户".equals(userInfo1.getUserName())) { + if (StringUtils.isNotEmpty(userInfo1.getPhone())) { + userInfo1.setUserName(userInfo1.getPhone().replaceAll("(\\d{3})\\d*([0-9a-zA-Z]{4})", "$1****$2")); + } + } + //没有则生成新账号 + userInfo1.setCreateTime(date); + userInfo1.setUserRate(new BigDecimal(commonInfoService.findOne(295).getValue())); + userInfo1.setShopRate(new BigDecimal(commonInfoService.findOne(296).getValue())); + userInfo1.setPlatform("小程序"); + userInfo1.setStatus(1); + if(StringUtils.isNotEmpty(userInfo1.getPhone())){ + userInfo1.setPassword(DigestUtils.sha256Hex(userInfo1.getPhone())); + }else{ + if(userInfo1.getType()!=null && userInfo1.getType()==2){ + userInfo1.setPassword(DigestUtils.sha256Hex(userInfo1.getArtificerOpenId())); + }else{ + userInfo1.setPassword(DigestUtils.sha256Hex(userInfo1.getOpenId())); + } + } + userInfo1.setType(userInfo1.getType()==null?1:userInfo1.getType()); + baseMapper.insertUser(userInfo1); + userInfo1.setInvitationCode(InvitationCodeUtil.toSerialCode(userInfo1.getUserId())); + baseMapper.updateById(userInfo1); + //给用户创建钱包 + UserMoney userMoney = new UserMoney(); + userMoney.setUserId(userInfo1.getUserId()); + userMoney.setMoney(BigDecimal.valueOf(0)); + userMoney.setCashDeposit(BigDecimal.valueOf(0)); + userMoneyDao.insert(userMoney); + MessageInfo messageInfo = new MessageInfo(); + messageInfo.setContent("恭喜您,账号注册成功!"); + messageInfo.setTitle("系统通知"); + messageInfo.setState(String.valueOf(5)); + messageInfo.setUserName(userInfo1.getUserName()); + messageInfo.setUserId(String.valueOf(userInfo1.getUserId())); + messageInfo.setCreateAt(sdf.format(new Date())); + messageInfo.setIsSee("0"); + messageService.saveBody(messageInfo); + if(userInfo1.getType()!=null && userInfo1.getType()==2){ + Artificer artificer=new Artificer(); + artificer.setRate(new BigDecimal(commonInfoService.findOne(381).getValue())); + artificer.setStatus(2); + artificer.setUserId(userInfo1.getUserId()); + artificer.setArtificerName(userInfo1.getUserName()); + artificer.setArtificerImg(userInfo1.getAvatar()); + artificer.setArtificerSales(0); + artificer.setCreateTime(sdf.format(new Date())); + artificer.setCreditScore(BigDecimal.valueOf(100)); + artificer.setTripWay(1); + artificer.setRate(new BigDecimal(commonInfoService.findOne(381).getValue())); + artificerService.save(artificer); + } + } + } + UserEntity user; + //返回用户信息 + if(userInfo1.getType()!=null && userInfo1.getType()==2){ + user = queryByArtificerOpenId(userInfo1.getArtificerOpenId()); + }else{ + user = queryByOpenId(userInfo1.getOpenId()); + } + return getResult(user); + } + + + @Override + public Result wxBindMobile(String phone, String code, String wxOpenId, String token, String platform, Integer sysPhone) { + Msg byPhoneAndCode = msgDao.findByPhoneAndCode(phone, code); + if (byPhoneAndCode == null) { + return Result.error("验证码错误"); + } + msgDao.deleteById(byPhoneAndCode.getId()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String time = simpleDateFormat.format(new Date()); + UserEntity userInfo = queryByPhone(phone); + if (userInfo != null) { + if (StringUtils.isNotEmpty(userInfo.getWxOpenId())) { + return Result.error("当前手机号已经被其他微信绑定"); + } + //小程序登陆过 + userInfo.setWxOpenId(wxOpenId); + String s = HttpClientUtil.doGet("https://api.weixin.qq.com/sns/userinfo?access_token=" + token + "&openid=" + wxOpenId); + AppUserInfo user = JsonUtil.parseObject(s, AppUserInfo.class); + if (user != null && user.getNickname() != null) { + if (user.getHeadimgurl() != null) { + userInfo.setAvatar(user.getHeadimgurl()); + } + userInfo.setSex(user.getSex()); + if (user.getNickname() != null) { + userInfo.setUserName(user.getNickname().replaceAll("(\\d{3})\\d*([0-9a-zA-Z]{4})", "$1****$2")); + } + } + baseMapper.updateById(userInfo); + } else { + //小程序没有登陆过 + userInfo = new UserEntity(); + String s = HttpClientUtil.doGet("https://api.weixin.qq.com/sns/userinfo?access_token=" + token + "&openid=" + wxOpenId); + AppUserInfo user = JsonUtil.parseObject(s, AppUserInfo.class); + if (user != null && user.getNickname() != null) { + if (user.getHeadimgurl() != null) { + userInfo.setAvatar(user.getHeadimgurl()); + } + userInfo.setSex(user.getSex()); + if (user.getNickname() != null) { + userInfo.setUserName(user.getNickname().replaceAll("(\\d{3})\\d*([0-9a-zA-Z]{4})", "$1****$2")); + } + } + userInfo.setUserRate(new BigDecimal(commonInfoService.findOne(295).getValue())); + userInfo.setShopRate(new BigDecimal(commonInfoService.findOne(296).getValue())); + userInfo.setWxOpenId(wxOpenId); + userInfo.setPhone(phone); + userInfo.setPlatform(platform); + userInfo.setCreateTime(time); + userInfo.setSysPhone(sysPhone); + userInfo.setStatus(1); + userInfo.setUpdateTime(time); + baseMapper.insert(userInfo); + } + UserEntity userEntity = queryByWxOpenId(userInfo.getWxOpenId()); + return getResult(userEntity); + } + + @Override + public Result iosBindMobile(String phone, String code, String appleId, String platform, Integer sysPhone) { + Msg byPhoneAndCode = msgDao.findByPhoneAndCode(phone, code); + if (byPhoneAndCode == null) { + return Result.error("验证码错误"); + } + msgDao.deleteById(byPhoneAndCode.getId()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String time = simpleDateFormat.format(new Date()); + UserEntity userInfo = queryByPhone(phone); + if (userInfo != null) { + if (StringUtils.isNotEmpty(userInfo.getAppleId())) { + return Result.error("当前手机号已经被其他苹果绑定"); + } + userInfo.setAppleId(appleId); + userInfo.setUpdateTime(simpleDateFormat.format(new Date())); + baseMapper.updateById(userInfo); + } else { + userInfo = new UserEntity(); + userInfo.setSex(0); + userInfo.setUserName(phone.replaceAll("(\\d{3})\\d*([0-9a-zA-Z]{4})", "$1****$2")); + userInfo.setPhone(phone); + userInfo.setPlatform(platform); + userInfo.setCreateTime(time); + userInfo.setSysPhone(sysPhone); + userInfo.setStatus(1); + userInfo.setUpdateTime(time); + baseMapper.insert(userInfo); + } + UserEntity userEntity = queryByAppleId(userInfo.getAppleId()); + return getResult(userEntity); + } + + + @Override + public Result wxAppLogin(String wxOpenId, String token) { + UserEntity userEntity = queryByWxOpenId(wxOpenId); + if (userEntity != null) { + if (userEntity.getStatus().equals(2)) { + return Result.error("账号已被禁用,请联系客服处理!"); + } + String s = HttpClientUtil.doGet("https://api.weixin.qq.com/sns/userinfo?access_token=" + token + "&openid=" + wxOpenId); + AppUserInfo user = JsonUtil.parseObject(s, AppUserInfo.class); + if (user != null && user.getNickname() != null) { + if (user.getHeadimgurl() != null) { + userEntity.setAvatar(user.getHeadimgurl()); + } + userEntity.setSex(user.getSex()); + if (user.getNickname() != null) { + userEntity.setUserName(user.getNickname().replaceAll("(\\d{3})\\d*([0-9a-zA-Z]{4})", "$1****$2")); + } + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userEntity.setUpdateTime(sdf.format(new Date())); + baseMapper.updateById(userEntity); + return getResult(userEntity); + } else { + return Result.error(-200, "请先绑定手机号账号!"); + } + } + + + @Override + public Result loginByOpenId(String openId) { + UserEntity userEntity = queryByWxOpenId(openId); + if(userEntity==null){ + return Result.error(-200,"未注册!"); + } + + String token = jwtUtils.generateToken(userEntity.getUserId()); + Map map = new HashMap<>(); + map.put("token", token); + map.put("expire", jwtUtils.getExpire()); + map.put("user", userEntity); + return Result.success(map); + } + + + + @Override + public Result registerCode(String phone, String msg, String platform, Integer sysPhone, String openId, String inviterCode, String password, String userName, String avatar, String scanningChannel) { + Msg msg1 = msgDao.findByPhoneAndCode(phone, msg); + //校验短信验证码 + if (msg1 == null) { + return Result.error("验证码不正确"); + } + msgDao.deleteById(msg1.getId()); + //校验手机号是否存在 + UserEntity userInfo = queryByPhone(phone); + if (userInfo != null) { + if (userInfo.getStatus().equals(2)) { + return Result.error("账号已被禁用,请联系客服处理!"); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userInfo.setWxOpenId(openId); + if(StringUtils.isNotEmpty(password)){ + userInfo.setPassword(DigestUtils.sha256Hex(password)); + } + userInfo.setUpdateTime(sdf.format(new Date())); + baseMapper.updateById(userInfo); + return getResult(userInfo); + } else { + if (StringUtils.isEmpty(inviterCode)) { + inviterCode=commonInfoService.findOne(88).getValue(); + } + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String time = simpleDateFormat.format(new Date()); + userInfo = new UserEntity(); + if(StringUtils.isNotEmpty(userName)){ + userInfo.setUserName(userName); + }else{ + userInfo.setUserName(phone.replaceAll("(\\d{3})\\d*([0-9a-zA-Z]{4})", "$1****$2")); + } + if(StringUtils.isNotEmpty(avatar)){ + userInfo.setAvatar(avatar); + } + userInfo.setUserRate(new BigDecimal(commonInfoService.findOne(295).getValue())); + userInfo.setShopRate(new BigDecimal(commonInfoService.findOne(296).getValue())); + userInfo.setPhone(phone); + userInfo.setInviterCode(inviterCode); + userInfo.setScanningChannel(scanningChannel); + userInfo.setPlatform(platform); + userInfo.setCreateTime(time); + userInfo.setSysPhone(sysPhone); + userInfo.setStatus(1); + userInfo.setWxOpenId(openId); + if(StringUtils.isNotEmpty(password)){ + userInfo.setPassword(DigestUtils.sha256Hex(password)); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userInfo.setUpdateTime(sdf.format(new Date())); + baseMapper.insertUser(userInfo); + + + userInfo.setInvitationCode(InvitationCodeUtil.toSerialCode(userInfo.getUserId())); + baseMapper.updateById(userInfo); + if(userInfo.getType()!=null && userInfo.getType()==2){ + Artificer artificer=new Artificer(); + artificer.setRate(new BigDecimal(commonInfoService.findOne(381).getValue())); + artificer.setStatus(2); + artificer.setUserId(userInfo.getUserId()); + artificer.setArtificerName(userInfo.getUserName()); + artificer.setArtificerImg(userInfo.getAvatar()); + artificer.setArtificerSales(0); + artificer.setCreateTime(sdf.format(new Date())); + artificer.setCreditScore(BigDecimal.valueOf(100)); + artificer.setTripWay(1); + artificer.setRate(new BigDecimal(commonInfoService.findOne(381).getValue())); + artificerService.save(artificer); + } + msgDao.deleteById(msg1.getId()); + //给用户创建钱包 + UserMoney userMoney = new UserMoney(); + userMoney.setUserId(userInfo.getUserId()); + userMoney.setMoney(BigDecimal.valueOf(0)); + userMoney.setCashDeposit(BigDecimal.valueOf(0)); + userMoneyDao.insert(userMoney); + MessageInfo messageInfo = new MessageInfo(); + messageInfo.setContent("恭喜您,账号注册成功!"); + messageInfo.setTitle("系统通知"); + messageInfo.setState(String.valueOf(5)); + messageInfo.setUserName(userInfo.getUserName()); + messageInfo.setUserId(String.valueOf(userInfo.getUserId())); + messageInfo.setCreateAt(sdf.format(new Date())); + messageInfo.setIsSee("0"); + messageService.saveBody(messageInfo); + return getResult(userInfo); + } + } + + + @Override + public Result login(String phone, String pwd) { + UserEntity userEntity = queryByPhone(phone); + if (userEntity == null) { + return Result.error("手机号未注册!"); + } + if (!userEntity.getPassword().equals(DigestUtils.sha256Hex(pwd))) { + return Result.error("密码不正确!"); + } + if (userEntity.getStatus().equals(2)) { + return Result.error("账号已被禁用,请联系客服处理!"); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userEntity.setUpdateTime(sdf.format(new Date())); + baseMapper.updateById(userEntity); + return getResult(userEntity); + } + + + @Override + public Result getResult(UserEntity user) { + //生成token + String token = jwtUtils.generateToken(user.getUserId()); + Map map = new HashMap<>(); + map.put("token", token); + map.put("expire", jwtUtils.getExpire()); + map.put("user", user); + return Result.success(map); + } + + + @Override + public Result sendMsg(String phone, String state) { + int code = (int) ((Math.random() * 9 + 1) * 100000); + System.out.println("sendMsg code is " + code); + SmsSingleSenderResult result = null; + /*if ("bindWx".equals(state)) { + UserEntity userByPhone = queryByPhone(phone); + if (userByPhone != null && StringUtils.isNotEmpty(userByPhone.getWxOpenId())) { + return Result.error("当前手机号已被其他微信账号绑定"); + } + } else if ("bindIos".equals(state)) { + UserEntity userByPhone = queryByPhone(phone); + if (userByPhone != null && StringUtils.isNotEmpty(userByPhone.getAppleId())) { + return Result.error("当前手机号已被其他苹果账号绑定"); + } + }*/ + try{ + if (phone != null) { + if("forget".equals(state)){ + UserEntity userByPhone = queryByPhone(phone); + if (userByPhone == null) { + return Result.error("手机号未注册"); + } + }else if("gzg".equals(state) || "fh".equals(state) || "touSu".equals(state) || "send".equals(state) || "end".equals(state)){ + //不做校验手机号 + }else{ + UserEntity userByPhone = queryByPhone(phone); + if (userByPhone != null) { + return Result.error("当前手机号已被其他账号绑定"); + } + } + + } + CommonInfo three = commonInfoService.findOne(79); + //默认使用腾讯云 + if (three == null || "1".equals(three.getValue())) { + //腾讯云短信发送 + return sendMsgTencent(phone, state, code); + } else if("2".equals(three.getValue())){ + //阿里云短信发送 + return sendMsgAlibaba(phone, code); + }else{ + return sendMsgDXB(phone,state,code); + } + }catch (Exception e){ + e.printStackTrace(); + log.error("短信推送失败!"); + } + return Result.success(); + } + + + private Result sendMsgAlibaba(String phone, int code) { + //阿里云短信accessKeyId + CommonInfo three = commonInfoService.findOne(83); + String accessKeyId = three.getValue(); + //阿里云短信accessSecret + CommonInfo four = commonInfoService.findOne(84); + String accessSecret = four.getValue(); + DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessSecret); + IAcsClient client = new DefaultAcsClient(profile); + CommonInfo name = commonInfoService.findOne(6); + CommonRequest request = new CommonRequest(); + request.setSysMethod(MethodType.POST); + request.setSysDomain("dysmsapi.aliyuncs.com"); + request.setSysVersion("2017-05-25"); + request.setSysAction("SendSms"); + request.putQueryParameter("RegionId", "cn-hangzhou"); + request.putQueryParameter("PhoneNumbers", phone); + request.putQueryParameter("SignName", name.getValue()); + String value = commonInfoService.findOne(80).getValue(); + request.putQueryParameter("TemplateCode", value); + request.putQueryParameter("TemplateParam", "{\"code\":\"" + code + "\"}"); + try { + CommonResponse response = client.getCommonResponse(request); + System.out.println(response.getData()); + String data = response.getData(); + JSONObject jsonObject = JSON.parseObject(data); + if ("OK".equals(jsonObject.get("Code"))) { + Msg byPhone = msgDao.findByPhone(phone); + if (byPhone != null) { + byPhone.setCode(String.valueOf(code)); + byPhone.setPhone(phone); + msgDao.updateById(byPhone); + } else { + Msg msg = new Msg(); + msg.setCode(String.valueOf(code)); + msg.setPhone(phone); + msgDao.insert(msg); + } + /* UserEntity userByPhone = queryByPhone(phone); + if (userByPhone != null) { + return Result.success("login"); + } else { + return Result.success("register"); + }*/ + return Result.success("login"); + } else { + if (jsonObject.get("Message").toString().contains("分钟")) { + return Result.error("短信发送过于频繁,请一分钟后再试!"); + } else if (jsonObject.get("Message").toString().contains("小时")) { + return Result.error("短信发送过于频繁,请一小时后再试!"); + } else if (jsonObject.get("Message").toString().contains("天")) { + return Result.error("短信发送过于频繁,请明天再试!"); + } + log.info(jsonObject.get("Message").toString()); + return Result.error("短信发送失败!"); + } + } catch (ClientException | com.aliyuncs.exceptions.ClientException e) { + e.printStackTrace(); + } + return Result.error("验证码发送失败"); + } + + private Result sendMsgTencent(String phone, String state, int code) { + SmsSingleSenderResult result = null; + + CommonInfo three = commonInfoService.findOne(31); + String clientId = three.getValue(); + CommonInfo four = commonInfoService.findOne(32); + String clientSecret = four.getValue(); + try { + String secretId = commonInfoService.findOne(397).getValue(); + String secretKey = commonInfoService.findOne(398).getValue(); + // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密 + // 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305 + // 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取 + Credential cred = new Credential(secretId, secretKey); + // 实例化一个http选项,可选的,没有特殊需求可以跳过 + HttpProfile httpProfile = new HttpProfile(); + httpProfile.setEndpoint("sms.tencentcloudapi.com"); + // 实例化一个client选项,可选的,没有特殊需求可以跳过 + ClientProfile clientProfile = new ClientProfile(); + clientProfile.setHttpProfile(httpProfile); + // 实例化要请求产品的client对象,clientProfile是可选的 + SmsClient client = new SmsClient(cred, "ap-beijing", clientProfile); + // 实例化一个请求对象,每个接口都会对应一个request对象 + SendSmsRequest req = new SendSmsRequest(); + String[] phoneNumberSet1 = {phone}; + req.setPhoneNumberSet(phoneNumberSet1); + + req.setSmsSdkAppId(clientId); + CommonInfo one = commonInfoService.findOne(6); + req.setSignName(one.getValue()); + switch (state) { + case "register": + req.setTemplateId(commonInfoService.findOne(399).getValue()); + break; + case "forget": + req.setTemplateId(commonInfoService.findOne(400).getValue()); + break; + case "bind": + req.setTemplateId(commonInfoService.findOne(401).getValue()); + break; + case "send": + req.setTemplateId(commonInfoService.findOne(402).getValue()); + break; + case "end": + req.setTemplateId(commonInfoService.findOne(403).getValue()); + break; + case "fh": + req.setTemplateId(commonInfoService.findOne(404).getValue()); + break; + case "touSu": + req.setTemplateId(commonInfoService.findOne(405).getValue()); + break; + default: + req.setTemplateId(commonInfoService.findOne(399).getValue()); + break; + } + String[] templateParamSet1 = {String.valueOf(code)}; + req.setTemplateParamSet(templateParamSet1); + switch (state) { + case "send": + req.setTemplateParamSet(null); + break; + case "end": + req.setTemplateParamSet(null); + break; + case "fh": + req.setTemplateParamSet(null); + break; + case "touSu": + req.setTemplateParamSet(null); + break; + default: + req.setTemplateId(commonInfoService.findOne(399).getValue()); + break; + } + // 返回的resp是一个SendSmsResponse的实例,与请求对象对应 + SendSmsResponse resp = client.SendSms(req); + // 输出json格式的字符串回包 + JSONObject jsonObject = JSONObject.parseObject(SendSmsResponse.toJsonString(resp)); + JSONArray sendStatusSet = jsonObject.getJSONArray("SendStatusSet"); + JSONObject jsonObject1 = sendStatusSet.getJSONObject(0); + if ("Ok".equals(jsonObject1.getString("Code"))) { + Msg byPhone = msgDao.findByPhone(phone); + if (byPhone != null) { + byPhone.setCode(String.valueOf(code)); + byPhone.setPhone(phone); + msgDao.updateById(byPhone); + } else { + Msg msg = new Msg(); + msg.setCode(String.valueOf(code)); + msg.setPhone(phone); + msgDao.insert(msg); + } + UserEntity userByPhone = queryByPhone(phone); + if (userByPhone != null) { + return Result.success("login"); + } else { + return Result.success("register"); + } + } + } catch (TencentCloudSDKException e) { + System.out.println(e.toString()); + } + return Result.error("验证码发送失败"); + } + + + + private Result sendMsgDXB(String phone, String state, int code) { + CommonInfo three = commonInfoService.findOne(164); + CommonInfo four = commonInfoService.findOne(165); + CommonInfo name = commonInfoService.findOne(6); + String testUsername = three.getValue(); //在短信宝注册的用户名 + String testPassword = four.getValue(); //在短信宝注册的密码 + String value=""; + switch (state) { + case "register": + value = "【" + name.getValue() + "】验证码: " + code + ",此验证码可用于登录或注册,10分钟内有效,如非您本人操作,可忽略本条消息"; + break; + case "forget": + value = "【" + name.getValue() + "】验证码: " + code + ",您正在执行找回密码操作,10分钟内有效,如非您本人操作,可忽略本条消息"; + break; + case "bind": + value = "【" + name.getValue() + "】验证码: " + code + ",您正在执行绑定手机号操作,10分钟内有效,如非您本人操作,可忽略本条消息"; + break; + case "send": + value = "【" + name.getValue() + "】有用户下单了,赶快上线查看吧!"; + break; + case "end": + value = "【" + name.getValue() + "】订单即将结束,请与客户进行确认!"; + break; + case "fh": + value = "【" + name.getValue() + "】您的账号存在违规,已被封禁。如有疑问,请联系客服!"; + break; + case "touSu": + value = "【" + name.getValue() + "】您好,客户对您进行了投诉,平台对您的信誉分进行了扣除,请规范您的服务!"; + break; + default: + value = "【" + name.getValue() + "】验证码: " + code + ",此验证码可用于登录或注册,10分钟内有效,如非您本人操作,可忽略本条消息"; + break; + } + StringBuilder httpArg = new StringBuilder(); + httpArg.append("u=").append(testUsername).append("&"); + httpArg.append("p=").append(Md5Utils.md5s(testPassword)).append("&"); + httpArg.append("m=").append(phone).append("&"); + httpArg.append("c=").append(Md5Utils.encodeUrlString(value, "UTF-8")); + String result = Md5Utils.request("https://api.smsbao.com/sms", httpArg.toString()); + log.error("短信包返回值:"+result); + if ("0".equals(result)) { + Msg byPhone = msgDao.findByPhone(phone); + if (byPhone != null) { + byPhone.setCode(String.valueOf(code)); + byPhone.setPhone(phone); + msgDao.updateById(byPhone); + } else { + Msg msg = new Msg(); + msg.setCode(String.valueOf(code)); + msg.setPhone(phone); + msgDao.insert(msg); + } + UserEntity userByPhone = queryByPhone(phone); + if (userByPhone != null) { + return Result.success("login"); + } else { + return Result.success("register"); + } + } else { +// return ResultUtil.error(6, result.errMsg); + if("30".equals(result)){ + return Result.error( "错误密码"); + }else if("40".equals(result)){ + return Result.error( "账号不存在"); + }else if("41".equals(result)){ + return Result.error( "余额不足"); + }else if("43".equals(result)){ + return Result.error( "IP地址限制"); + }else if("50".equals(result)){ + return Result.error( "内容含有敏感词"); + }else if("51".equals(result)){ + return Result.error( "手机号码不正确"); + } + } + + return Result.error("验证码发送失败"); + } + + + @Override + public Result getOpenId(String code, Long userId) { + try { + //微信appid + CommonInfo one = commonInfoService.findOne(5); + //微信秘钥 + CommonInfo two = commonInfoService.findOne(21); + String openid = SnsAPI.oauth2AccessToken(one.getValue(), two.getValue(), code).getOpenid(); + if (StringUtils.isNotEmpty(openid)) { + UserEntity userEntity = new UserEntity(); + userEntity.setUserId(userId); + userEntity.setOpenId(openid); + baseMapper.updateById(userEntity); + return Result.success().put("data", openid); + } + return Result.error("获取失败"); + } catch (Exception e) { + log.error("GET_OPENID_FAIL"); + return Result.error("获取失败,出错了!"); + } + } + + @Override + public UserEntity selectUserById(Long userId) { + return baseMapper.selectById(userId); + } + + + @Override + public PageUtils selectUserPage(Integer page, Integer limit, String search, Integer sex, String platform, + Integer isAuthentication,String sysPhone, Integer status, + String userName,String invitationCode,String inviterCode, + Integer member,Integer ordersUser,Integer isAgency,Integer isShop,String artificerName) { + Page pages = new Page<>(page, limit); + return new PageUtils(baseMapper.selectUserPage(pages,search,sex,platform,isAuthentication, + sysPhone,status,userName,invitationCode,inviterCode,member,ordersUser,isAgency,isShop,artificerName)); + } + + @Override + public int queryInviterCount(String inviterCode) { + return baseMapper.queryInviterCount(inviterCode); + } + + @Override + public int queryUserCount(int type, String date,Integer isAuthentication,Integer phone ) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm"); + if (date == null || date == "") { + date = simpleDateFormat.format(new Date()); + } + return baseMapper.queryUserCount(type, date,isAuthentication,phone); + } + + @Override + public int userPlatform(String platform,String date,Integer type){ + return baseMapper.userPlatform(platform, date, type); + } + + + @Override + public Double queryPayMoney(int type) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm"); + String date = simpleDateFormat.format(new Date()); + return baseMapper.queryPayMoney(type, date); + } + + @Override + public IPage> queryCourseOrder(Page> iPage, int type, String date) { + return baseMapper.queryCourseOrder(iPage, type, date); + } + + @Override + public int userMessage(String date, int type) { + return baseMapper.userMessage(date, type); + } + + + @Override + public void pushToSingle(String title, String content, String clientId) { + try { + if (StringUtils.isNotEmpty(clientId)) { + UserEntity userEntity = baseMapper.selectOne(new QueryWrapper().eq("clientid", clientId)); + GtApiConfiguration apiConfiguration = new GtApiConfiguration(); + //填写应用配置 + apiConfiguration.setAppId(commonInfoService.findOne(61).getValue()); + apiConfiguration.setAppKey(commonInfoService.findOne(60).getValue()); + apiConfiguration.setMasterSecret(commonInfoService.findOne(62).getValue()); + // 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId + apiConfiguration.setDomain("https://restapi.getui.com/v2/"); + // 实例化ApiHelper对象,用于创建接口对象 + ApiHelper apiHelper = ApiHelper.build(apiConfiguration); + // 创建对象,建议复用。目前有PushApi、StatisticApi、UserApi + PushApi pushApi = apiHelper.creatApi(PushApi.class); + //根据cid进行单推 + PushDTO pushDTO = new PushDTO(); + // 设置推送参数 + pushDTO.setRequestId(System.currentTimeMillis() + ""); + PushMessage pushMessage = new PushMessage(); + if (userEntity == null || userEntity.getSysPhone() == null || userEntity.getSysPhone() == 1) { + //安卓推送 + GTNotification notification = new GTNotification(); + pushDTO.setPushMessage(pushMessage); + // 配置通知栏图标 + notification.setLogo(commonInfoService.findOne(19).getValue() + "/logo.png"); //配置通知栏图标,需要在客户端开发时嵌入,默认为push.png + // 配置通知栏网络图标 + notification.setLogoUrl(commonInfoService.findOne(19).getValue() + "/logo.png"); + notification.setTitle(title); + notification.setBody(content); + notification.setClickType("startapp"); + notification.setUrl(commonInfoService.findOne(19).getValue()); + notification.setChannelLevel("3"); + pushMessage.setNotification(notification); + } else { + pushMessage.setTransmission(title); + pushDTO.setPushMessage(pushMessage); + PushChannel pushChannel = new PushChannel(); + IosDTO iosDTO = new IosDTO(); + Aps aps = new Aps(); + Alert alert = new Alert(); + alert.setTitle(title); + alert.setBody(content); + aps.setAlert(alert); + aps.setSound("default"); + iosDTO.setAps(aps); + pushChannel.setIos(iosDTO); + pushDTO.setPushChannel(pushChannel); + } + // 设置接收人信息 + Audience audience = new Audience(); + audience.addCid(clientId); + pushDTO.setAudience(audience); + // 进行cid单推 + ApiResult>> apiResult = pushApi.pushToSingleByCid(pushDTO); + if (apiResult.isSuccess()) { + // success + log.info("消息推送成功:" + apiResult.getData()); + } else { + // failed + log.error("消息推送失败:code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg()); + } + } + } catch (Exception e) { + e.printStackTrace(); + log.error("消息推送异常:" + e.getMessage(), e); + } + } + + @Override + public Result loginApp(String phone, String password) { + //md5加密 + String pwd = DigestUtils.sha256Hex(password); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("phone", phone); + UserEntity userEntity = baseMapper.selectOne(queryWrapper); + if (userEntity == null) { + return Result.error("手机号未注册!"); + } + if (!userEntity.getPassword().equals(pwd)) { + return Result.error("密码不正确!"); + } + if (userEntity.getStatus().equals(2)) { + return Result.error("账号已被禁用,请联系客服处理!"); + } + if (userEntity.getStatus().equals(3)) { + return Result.error("账号已被停牌禁用,请联系客服处理!"); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userEntity.setUpdateTime(sdf.format(new Date())); + baseMapper.updateById(userEntity); + return getResult(userEntity); + + } + + @Override + public Result registApp(String userName, String phone, String password, String msg, String platform, String inviterCode) { + Msg msg1 = msgDao.findByPhoneAndCode(phone, msg); + //校验短信验证码 + if (msg1 == null) { + return Result.error("验证码不正确"); + } + msgDao.deleteById(msg1.getId()); + //校验手机号是否存在 + UserEntity userInfo = queryByPhone(phone); + if (userInfo != null) { + return Result.error("手机号已经被注册!"); + + } else { + if(StringUtils.isEmpty(inviterCode)){ + inviterCode=commonInfoService.findOne(88).getValue(); + } + UserEntity userEntity = queryByInvitationCode(inviterCode); + if(userEntity==null){ + return Result.error("邀请码不正确"); + } + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String time = simpleDateFormat.format(new Date()); + userInfo = new UserEntity(); + userInfo.setPhone(phone); + userInfo.setUserName(userName); + userInfo.setUserRate(new BigDecimal(commonInfoService.findOne(295).getValue())); + userInfo.setShopRate(new BigDecimal(commonInfoService.findOne(296).getValue())); + //对密码进行MD5加密 + userInfo.setPassword(DigestUtils.sha256Hex(password)); + userInfo.setPlatform(platform); + userInfo.setCreateTime(time); + userInfo.setStatus(1); + userInfo.setInviterCode(inviterCode); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userInfo.setCreateTime(sdf.format(new Date())); + baseMapper.insertUser(userInfo); + userInfo.setInvitationCode(InvitationCodeUtil.toSerialCode(userInfo.getUserId())); + //设置自己邀请码 + baseMapper.updateById(userInfo); + //给用户创建钱包 + UserMoney userMoney = new UserMoney(); + userMoney.setUserId(userInfo.getUserId()); + userMoney.setMoney(BigDecimal.valueOf(0)); + userMoney.setCashDeposit(BigDecimal.valueOf(0)); + userMoneyDao.insert(userMoney); + MessageInfo messageInfo = new MessageInfo(); + messageInfo.setContent("恭喜您,账号注册成功!"); + messageInfo.setTitle("系统通知"); + messageInfo.setState(String.valueOf(5)); + messageInfo.setUserName(userInfo.getUserName()); + messageInfo.setUserId(String.valueOf(userInfo.getUserId())); + messageInfo.setCreateAt(sdf.format(new Date())); + messageInfo.setIsSee("0"); + messageService.saveBody(messageInfo); + return getResult(userInfo); + } + + } + + + @Override + public Result forgetPwd(String pwd, String phone, String msg) { + try { + Msg byPhoneAndCode = msgDao.findByPhoneAndCode(phone, msg); + //校验短信验证码 + if (byPhoneAndCode == null) { + return Result.error("验证码不正确"); + } + UserEntity userByPhone = queryByPhone(phone); + userByPhone.setPassword(DigestUtils.sha256Hex(pwd)); + msgDao.deleteById(byPhoneAndCode.getId()); + baseMapper.updateById(userByPhone); + return Result.success(); + } catch (Exception e) { + e.printStackTrace(); + return Result.error("服务器内部错误"); + } + } + + @Override + public Result takingOrdersMessage(Page> iPage, Long type, String date) { + //接单分析 + return Result.success().put("data", new PageUtils(baseMapper.takingOrdersMessage(iPage, type, date))); + } + + @Override + public void sendWxMessage(String templateId, LinkedHashMap data, String openid) { + String url=commonInfoService.findOne(19).getValue(); + TemplateMessage templateMessage = new TemplateMessage(); + templateMessage.setTouser(openid); + templateMessage.setTemplate_id(templateId); + templateMessage.setData(data); + templateMessage.setUrl(url); + TemplateMessageResult templateMessageResult = MessageAPI.messageTemplateSend(getWxToken(), templateMessage); + if (templateMessageResult.isSuccess()) { + new SendResult(); + } else { + new SendResult(); + } + } + + private String getWxToken() { + String appid = commonInfoService.findOne(5).getValue(); + String secret = commonInfoService.findOne(21).getValue(); + String jsonResult = HttpClientUtil.doPost("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret); + JSONObject parseObject = JSON.parseObject(jsonResult); + log.info("=========accessTokenOut--gzh========="+parseObject.toJSONString()); + + String errcode = parseObject.getString("errcode"); + return parseObject.getString("access_token"); + } + + @Override + public int updateUserClientIdIsNull(String clientid){ + return baseMapper.updateUserClientIdIsNull(clientid); + } + + @Override + public int updateUserConsortiaIdIsNull(Long userId){ + return baseMapper.updateUserConsortiaIdIsNull(userId); + } + + @Override + public int updateUserClientIdIsNullByClientId(Long consortiaId){ + return baseMapper.updateUserClientIdIsNullByClientId(consortiaId); + } + + @Override + public Result selectAgencyOrdersMoneyList(Integer page,Integer limit,String userName,String phone,String startTime,String endTime){ + return Result.success().put("data",new PageUtils(baseMapper.selectAgencyOrdersMoneyList(new Page<>(page,limit),userName,phone,startTime,endTime))); + } + + @Override + public Result integral(String type, Integer current, Integer size, String date,String artificerId) throws ParseException { + if (org.apache.commons.lang3.StringUtils.isEmpty(date)) { + date = DateUtil.formatDate(DateUtil.date()); + } + String startDate = DateUtil.formatDateTime(obtainCycle(DateUtil.parse(date)).getStartFundData()); + String endDate = DateUtil.formatDate(obtainCycle(DateUtil.parse(date)).getEndFundData()) + " 23:59:59"; + return Result.success().put("data", userRechargeDao.integralArtificerId(new Page<>(current, size), type, startDate, endDate, artificerId)); + } + + @Override + public IPage merchantPromotion(UserEntity userEntity,Integer page, Integer limit) { + IPage pages = new Page<>(page, limit); + return baseMapper.merchantPromotion(pages,userEntity); + } +} diff --git a/src/main/java/com/sqx/modules/app/service/impl/UserVipServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/UserVipServiceImpl.java new file mode 100644 index 0000000..cf2f5b3 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/impl/UserVipServiceImpl.java @@ -0,0 +1,65 @@ +package com.sqx.modules.app.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.dao.UserVipDao; +import com.sqx.modules.app.entity.UserVip; +import com.sqx.modules.app.service.UserVipService; +import com.sqx.modules.common.service.CommonInfoService; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Date; + +@Service +public class UserVipServiceImpl extends ServiceImpl implements UserVipService { + + @Autowired + private CommonInfoService commonInfoService; + + + @Override + public UserVip selectUserVipByUserId(Long userId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("user_id", userId); + return baseMapper.selectOne(queryWrapper); + } + + @Override + public Result isUserVip(Long userId) { + String value = commonInfoService.findOne(321).getValue(); + if(StringUtils.isEmpty(value) || "否".equals(value)){ + return Result.success().put("data",false); + } + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + //查询用户是否是会员 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("user_id", userId); + UserVip userVip = baseMapper.selectOne(queryWrapper); + if (userVip != null) { + //获取用户到期时间 + Date date = null; + try { + date = simpleDateFormat.parse(userVip.getEndTime()); + } catch (Exception e) { + e.getMessage(); + } + if (date.getTime() >= System.currentTimeMillis()) { + userVip.setIsVip((long) 1); + baseMapper.updateById(userVip); + return Result.success().put("data", true); + } else { + userVip.setIsVip((long) 2); + baseMapper.updateById(userVip); + return Result.success().put("data", false); + } + } else { + return Result.success().put("data", false); + } + } + + +} diff --git a/src/main/java/com/sqx/modules/app/service/impl/VipDetailsServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/VipDetailsServiceImpl.java new file mode 100644 index 0000000..d704aed --- /dev/null +++ b/src/main/java/com/sqx/modules/app/service/impl/VipDetailsServiceImpl.java @@ -0,0 +1,27 @@ +package com.sqx.modules.app.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.dao.VipDetailsDao; +import com.sqx.modules.app.entity.VipDetails; +import com.sqx.modules.app.service.VipDetailsService; +import org.springframework.stereotype.Service; + +@Service +public class VipDetailsServiceImpl extends ServiceImpl implements VipDetailsService { + + @Override + public Result selectVipDetails() { + return Result.success().put("data", baseMapper.selectList(null)); + } + + @Override + public Result insertVipDetails(VipDetails vipDetails) { + int cpunt = baseMapper.insert(vipDetails); + if (cpunt > 0) { + return Result.success("添加成功!"); + } else { + return Result.error("添加失败"); + } + } +} diff --git a/src/main/java/com/sqx/modules/app/utils/JwtUtils.java b/src/main/java/com/sqx/modules/app/utils/JwtUtils.java new file mode 100644 index 0000000..06a7ad5 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/utils/JwtUtils.java @@ -0,0 +1,86 @@ +package com.sqx.modules.app.utils; + +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.util.Date; + +/** + * jwt工具类 + * + */ +@ConfigurationProperties(prefix = "sqx.jwt") +@Component +public class JwtUtils { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private String secret; + private long expire; + private String header; + + /** + * 生成jwt token + */ + public String generateToken(long userId) { + Date nowDate = new Date(); + //过期时间 + Date expireDate = new Date(nowDate.getTime() + expire * 1000); + + return Jwts.builder() + .setHeaderParam("typ", "JWT") + .setSubject(userId+"") + .setIssuedAt(nowDate) + .setExpiration(expireDate) + .signWith(SignatureAlgorithm.HS512, secret) + .compact(); + } + + public Claims getClaimByToken(String token) { + try { + return Jwts.parser() + .setSigningKey(secret) + .parseClaimsJws(token) + .getBody(); + }catch (Exception e){ + logger.debug("validate is token error ", e); + return null; + } + } + + /** + * token是否过期 + * @return true:过期 + */ + public boolean isTokenExpired(Date expiration) { + return expiration.before(new Date()); + } + + public String getSecret() { + return secret; + } + + public void setSecret(String secret) { + this.secret = secret; + } + + public long getExpire() { + return expire; + } + + public void setExpire(long expire) { + this.expire = expire; + } + + public String getHeader() { + return header; + } + + public void setHeader(String header) { + this.header = header; + } +} diff --git a/src/main/java/com/sqx/modules/app/utils/UserConstantInterface.java b/src/main/java/com/sqx/modules/app/utils/UserConstantInterface.java new file mode 100644 index 0000000..1366c62 --- /dev/null +++ b/src/main/java/com/sqx/modules/app/utils/UserConstantInterface.java @@ -0,0 +1,53 @@ +package com.sqx.modules.app.utils; + + +import cn.hutool.core.codec.Base64; +import com.alibaba.fastjson.JSON; +import com.sqx.common.utils.Result; + +import javax.crypto.Cipher; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.security.spec.AlgorithmParameterSpec; + +/** + * 参数配置 + */ +public interface UserConstantInterface { + + + /** + * 请求的网址 + */ + String WX_LOGIN_URL = "https://api.weixin.qq.com/sns/jscode2session"; + + /** + * 固定参数 + */ + String WX_LOGIN_GRANT_TYPE = "authorization_code"; + + /** + * 解密手机号 + * @param decryptData 加密手机号(微信返回) + * @param key session_key + * @param iv iv(微信返回) + * @return + */ + static Result decryptS5(String decryptData, String key, String iv) { + try { + byte[] encData = Base64.decode(decryptData); + byte[] ivs = Base64.decode(iv); + byte[] keys = Base64.decode(key); + AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivs); + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); + SecretKeySpec keySpec = new SecretKeySpec(keys, "AES"); + cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec); + return Result.success("获取手机号成功").put("data", JSON.parseObject(new String(cipher.doFinal(encData), "UTF-8"))); + } catch (Exception e) { + e.printStackTrace(); + return Result.error(-1,"获取手机号失败"); + } + } + +} + diff --git a/src/main/java/com/sqx/modules/app/utils/WxPhone.java b/src/main/java/com/sqx/modules/app/utils/WxPhone.java new file mode 100644 index 0000000..d82119b --- /dev/null +++ b/src/main/java/com/sqx/modules/app/utils/WxPhone.java @@ -0,0 +1,14 @@ +package com.sqx.modules.app.utils; + +import lombok.Data; + +@Data +public class WxPhone { + + private String decryptData; + + private String key; + + private String iv; + +} diff --git a/src/main/java/com/sqx/modules/apply/controller/ApplyController.java b/src/main/java/com/sqx/modules/apply/controller/ApplyController.java new file mode 100644 index 0000000..a6b57c3 --- /dev/null +++ b/src/main/java/com/sqx/modules/apply/controller/ApplyController.java @@ -0,0 +1,64 @@ +package com.sqx.modules.apply.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.sqx.common.utils.Result; +import com.sqx.modules.apply.entity.Apply; +import com.sqx.modules.apply.service.ApplyService; +import com.sqx.modules.artificer.entity.Certification; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value = "申请", tags = {"申请"}) +@RequestMapping(value = "/apply") +public class ApplyController { + + @Autowired + private ApplyService applyService; + + @PostMapping("/insertApply") + @ApiOperation("发起申请") + public Result insertApply(@RequestBody Apply apply){ + return applyService.insertApply(apply); + } + + @PostMapping("/updateApply") + @ApiOperation("修改申请") + public Result updateApply(@RequestBody Apply apply){ + return applyService.updateApply(apply); + } + + @PostMapping("/deleteApply") + @ApiOperation("删除申请") + public Result deleteApply(Long applyId){ + return applyService.deleteApply(applyId); + } + + @GetMapping("/selectApplyList") + @ApiOperation("查询申请列表") + public Result selectApplyList(Integer page,Integer limit,String applyName,String applyPhone,Integer status,Integer classify){ + return applyService.selectApplyList(page, limit, applyName, applyPhone, status, classify); + } + + @GetMapping("/selectApplyByUserIdAndClassify") + @ApiOperation("查询申请详情") + public Result selectApplyByUserIdAndClassify(Long userId,Integer classify){ + return Result.success().put("data",applyService.selectApplyByUserIdAndClassify(userId, classify)); + } + + @PostMapping("/auditApply") + @ApiOperation("审核申请") + public Result auditApply(String ids,String content,Integer status){ + return applyService.auditApply(ids, status, content); + } + + @GetMapping("/selectApplyCount") + @ApiOperation("查询代理待审核总和") + public Result selectApplyCount(){ + return Result.success().put("data",applyService.count(new QueryWrapper().eq("status",1))); + } + + +} diff --git a/src/main/java/com/sqx/modules/apply/controller/app/AppApplyController.java b/src/main/java/com/sqx/modules/apply/controller/app/AppApplyController.java new file mode 100644 index 0000000..6ec58ce --- /dev/null +++ b/src/main/java/com/sqx/modules/apply/controller/app/AppApplyController.java @@ -0,0 +1,58 @@ +package com.sqx.modules.apply.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.apply.entity.Apply; +import com.sqx.modules.apply.service.ApplyService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value = "申请", tags = {"申请"}) +@RequestMapping(value = "/app/apply") +public class AppApplyController { + + @Autowired + private ApplyService applyService; + + @Login + @PostMapping("/insertApply") + @ApiOperation("发起申请") + public Result insertApply(@RequestBody Apply apply,@RequestAttribute Long userId){ + apply.setUserId(userId); + return applyService.insertApply(apply); + } + + @Login + @PostMapping("/updateApply") + @ApiOperation("修改申请") + public Result updateApply(@RequestBody Apply apply){ + return applyService.updateApply(apply); + } + + @Login + @PostMapping("/deleteApply") + @ApiOperation("删除申请") + public Result deleteApply(Long applyId){ + return applyService.deleteApply(applyId); + } + + @GetMapping("/selectApplyList") + @ApiOperation("查询申请列表") + public Result selectApplyList(Integer page,Integer limit,String applyName,String applyPhone,Integer status,Integer classify){ + return applyService.selectApplyList(page, limit, applyName, applyPhone, status, classify); + } + + @Login + @GetMapping("/selectApplyByUserIdAndClassify") + @ApiOperation("查询申请详情") + public Result selectApplyByUserIdAndClassify(@RequestAttribute Long userId,Integer classify){ + return Result.success().put("data",applyService.selectApplyByUserIdAndClassify(userId, classify)); + } + + + + +} diff --git a/src/main/java/com/sqx/modules/apply/dao/ApplyDao.java b/src/main/java/com/sqx/modules/apply/dao/ApplyDao.java new file mode 100644 index 0000000..2b9a984 --- /dev/null +++ b/src/main/java/com/sqx/modules/apply/dao/ApplyDao.java @@ -0,0 +1,16 @@ +package com.sqx.modules.apply.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.apply.entity.Apply; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author fang + * @date 2022/8/3 + */ +@Mapper +public interface ApplyDao extends BaseMapper { + + + +} diff --git a/src/main/java/com/sqx/modules/apply/entity/Apply.java b/src/main/java/com/sqx/modules/apply/entity/Apply.java new file mode 100644 index 0000000..59bb8a1 --- /dev/null +++ b/src/main/java/com/sqx/modules/apply/entity/Apply.java @@ -0,0 +1,77 @@ +package com.sqx.modules.apply.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.sqx.modules.app.entity.UserEntity; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description apply + * @author fang + * @date 2022-08-05 + */ +@Data +public class Apply implements Serializable { + + private static final long serialVersionUID = 1L; + + + /** + * 申请id + */ + @TableId(type = IdType.AUTO) + private Long applyId; + + /** + * 姓名 + */ + private String applyName; + + /** + * 电话 + */ + private String applyPhone; + + /** + * 年龄 + */ + private String applyAge; + + /** + * 内容 + */ + private String applyContent; + + /** + * 分类 1推广员 2代理商 + */ + private Integer classify; + + /** + * 用户id + */ + private Long userId; + + /** + * 状态 1待审核 2通过 3拒绝 + */ + private Integer status; + + /** + * 审核内容 + */ + private String auditContent; + + /** + * 创建时间 + */ + private String createTime; + + @TableField(exist = false) + private UserEntity user; + + public Apply() {} +} diff --git a/src/main/java/com/sqx/modules/apply/service/ApplyService.java b/src/main/java/com/sqx/modules/apply/service/ApplyService.java new file mode 100644 index 0000000..215f01b --- /dev/null +++ b/src/main/java/com/sqx/modules/apply/service/ApplyService.java @@ -0,0 +1,23 @@ +package com.sqx.modules.apply.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.apply.entity.Apply; + +public interface ApplyService extends IService { + + Result insertApply(Apply apply); + + Result updateApply(Apply apply); + + Result deleteApply(Long applyId); + + Result selectApplyList(Integer page,Integer limit,String applyName,String applyPhone,Integer status,Integer classify); + + Apply selectApplyByUserIdAndClassify(Long userId,Integer classify); + + Result auditApply(String ids,Integer status,String content); + + +} diff --git a/src/main/java/com/sqx/modules/apply/service/impl/ApplyServiceImpl.java b/src/main/java/com/sqx/modules/apply/service/impl/ApplyServiceImpl.java new file mode 100644 index 0000000..10b21fa --- /dev/null +++ b/src/main/java/com/sqx/modules/apply/service/impl/ApplyServiceImpl.java @@ -0,0 +1,101 @@ +package com.sqx.modules.apply.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.apply.dao.ApplyDao; +import com.sqx.modules.apply.entity.Apply; +import com.sqx.modules.apply.service.ApplyService; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +/** + * 申请 + */ +@Service +public class ApplyServiceImpl extends ServiceImpl implements ApplyService { + + @Autowired + private UserService userService; + + @Override + public Result insertApply(Apply apply){ + Apply oldApply = selectApplyByUserIdAndClassify(apply.getUserId(), apply.getClassify()); + if(oldApply!=null){ + return Result.error("您已经提交过了!"); + } + apply.setStatus(1); + apply.setCreateTime(DateUtils.format(new Date())); + baseMapper.insert(apply); + return Result.success(); + } + + @Override + public Result updateApply(Apply apply){ + apply.setStatus(1); + baseMapper.updateById(apply); + return Result.success(); + } + + @Override + public Result deleteApply(Long applyId){ + baseMapper.deleteById(applyId); + return Result.success(); + } + + + @Override + public Result selectApplyList(Integer page,Integer limit,String applyName,String applyPhone,Integer status,Integer classify){ + IPage applyPage = baseMapper.selectPage(new Page<>(page, limit), + new QueryWrapper() + .eq(StringUtils.isNotBlank(applyName), "apply_name", applyName) + .eq(StringUtils.isNotBlank(applyPhone), "apply_phone", applyPhone) + .eq(status != null && status != 0, "status", status) + .eq(classify!=null,"classify",classify).orderByDesc("create_time")); + List records = applyPage.getRecords(); + for(Apply apply:records){ + apply.setUser(userService.getById(apply.getUserId())); + } + return Result.success().put("data",new PageUtils(applyPage)); + } + + @Override + public Apply selectApplyByUserIdAndClassify(Long userId,Integer classify){ + return baseMapper.selectOne(new QueryWrapper().eq("user_id",userId).eq("classify",classify)); + } + + @Override + public Result auditApply(String ids,Integer status,String content){ + for(String id:ids.split(",")){ + Apply apply = baseMapper.selectById(Long.parseLong(id)); + UserEntity user = userService.getById(apply.getUserId()); + if(apply.getStatus().equals(1)){ + if(status==1){ + user.setIsAgency(1); + apply.setStatus(2); + apply.setApplyContent("通过"); + userService.updateById(user); + }else{ + apply.setStatus(3); + apply.setAuditContent(content); + } + baseMapper.updateById(apply); + } + } + return Result.success(); + } + + + + +} diff --git a/src/main/java/com/sqx/modules/artificer/controller/ArtificerController.java b/src/main/java/com/sqx/modules/artificer/controller/ArtificerController.java new file mode 100644 index 0000000..4e4b7d8 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/controller/ArtificerController.java @@ -0,0 +1,501 @@ +package com.sqx.modules.artificer.controller; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.dao.UserMoneyDao; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserCertificationService; +import com.sqx.modules.app.service.UserMoneyService; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.entity.*; +import com.sqx.modules.artificer.service.*; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.service.MessageService; +import com.sqx.modules.utils.excel.ExcelData; +import com.sqx.modules.utils.excel.ExportExcelUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +@RestController +@RequestMapping("/artificer") +@Api(value = "技师管理", tags = {"技师管理"}) +public class ArtificerController { + + @Autowired + private ArtificerService artificerService; + @Autowired + private ArtificerMassageService artificerMassageService; + @Autowired + private MassageTypeService massageTypeService; + @Autowired + private RealNameService realNameService; + @Autowired + private OrdersService ordersService; + @Autowired + private AgencyService agencyService; + @Autowired + private UserService userService; + @Autowired + private UserMoneyDao userMoneyDao; + @Autowired + private RealNameService userCertificationService; + @Autowired + private MessageService messageService; + @Autowired + private CommonInfoService commonInfoService; + + @PostMapping("/insertMassageType") + @ApiOperation("添加按摩分类") + public Result insertMassageType(@RequestBody MassageType massageType){ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + massageType.setCreateTime(sdf.format(new Date())); + massageType.setSales(0); + massageTypeService.save(massageType); + return Result.success(); + } + + @PostMapping("/updateMassageType") + @ApiOperation("修改按摩分类") + public Result updateMassageType(@RequestBody MassageType massageType){ + MassageType massageType1 = massageTypeService.getById(massageType.getMassageTypeId()); + if(massageType1!=null && !massageType1.getStatus().equals(massageType.getStatus())){ + artificerMassageService.updateArtificerMassageStatus(massageType1.getMassageTypeId()); + } + massageTypeService.updateById(massageType); + return Result.success(); + } + + @PostMapping("/deleteMassageType") + @ApiOperation("删除按摩分类") + public Result deleteMassageType(Long massageTypeId){ + massageTypeService.removeById(massageTypeId); + artificerMassageService.remove(new QueryWrapper().eq("massage_type_id",massageTypeId)); + return Result.success(); + } + + + @GetMapping("/selectMassageTypePage") + @ApiOperation("查询按摩分类(分页)") + public Result selectMassageTypePage(Integer page,Integer limit,Integer status,Integer sort,String city,Integer authentication,Integer by,String title,Long artificerId,Long userId,Integer parentId,Long classifyId){ + return massageTypeService.selectMassageTypePage(page, limit, status, city, sort,authentication,by,title,artificerId,userId,parentId,classifyId); + } + @GetMapping("/selectMassageTypeChildrenPage") + @ApiOperation("查询按摩分类子项目(分页)") + public Result selectMassageTypeChildrenPage(Integer page,Integer limit,Integer status,Integer sort,String city,Integer authentication,Integer by,String title,Long artificerId,Long userId,Integer parentId,Long classifyId){ + return massageTypeService.selectMassageTypeChildrenPage(page, limit, status, city, sort,authentication,by,title,artificerId,userId,parentId,classifyId); + } + @GetMapping("/selectMassageTypeList") + @ApiOperation("查询按摩分类(不带分页)") + public Result selectMassageTypeList(Integer status){ + return Result.success().put("data",massageTypeService.list(new QueryWrapper().eq(status!=0,"status",status))); + } + + @GetMapping("/selectMassageTypeById") + @ApiOperation("查询详情") + public Result selectMassageTypeById(Long massageTypeId){ + return Result.success().put("data",massageTypeService.getById(massageTypeId)); + } + + @GetMapping("/selectArtificerList") + @ApiOperation("查询技师列表") + public Result selectArtificerList(Integer page, Integer limit, Long massageTypeId, String artificerName, + String longitude,String latitude,Integer sort,Integer authentication, + Integer by,String city,Long classifyId,String phone){ + return artificerService.selectArtificerList(page, limit, massageTypeId, artificerName,longitude,latitude, + sort,authentication,by,null,city,classifyId,phone,null); + } + + @GetMapping("/selectArtificer") + @ApiOperation("查询技师列表(不带分页)") + public Result selectArtificer(String city,String classifyId,String artificerName){ + List artificerList = artificerService.list(new QueryWrapper() + .eq("status",1) + .eq(StringUtils.isNotBlank(classifyId),"classify_id",classifyId) + .like(StringUtils.isNotBlank(artificerName),"artificer_name",artificerName) + .like(StringUtils.isNotBlank(city), "city", city)); + for(Artificer artificer:artificerList){ + artificer.setServiceCount(ordersService.count(new QueryWrapper() + .eq("status",2) + .eq("artificer_id",artificer.getArtificerId()).isNull("parent_id"))); + } + return Result.success().put("data",artificerList); + } + + @GetMapping("/selectArtificerMassageList") + @ApiOperation("查询技师服务列表") + public Result selectArtificerMassageList(Long artificerId,Integer status){ + return massageTypeService.selectArtificerMassageList(artificerId,status); + } + + @GetMapping("/selectArtificerById") + @ApiOperation("查询技师详情") + public Result selectArtificerById(Long artificerId){ + return Result.success().put("data",artificerService.selectArtificerById(null,artificerId,null,null)); + } + + @PostMapping("/updateArtificers") + @ApiOperation("修改技师") + public Result updateArtificers(@RequestBody Artificer artificer){ + artificerService.updateById(artificer); + return Result.success(); + } + + @PostMapping("/cancellationSuspension/{userId}") + @ApiOperation("解除停牌") + public Result cancellationSuspension(@PathVariable("userId") Long userId){ + userService.update(Wrappers.lambdaUpdate().eq(UserEntity::getUserId, userId).set(UserEntity::getStatus, 1)); + return Result.success(); + } + + + @PostMapping("/deleteArtificer") + @ApiOperation("删除技师") + public Result deleteArtificer(Long artificerId){ + Artificer artificer = artificerService.getById(artificerId); + if(artificer!=null){ + UserEntity userEntity = userService.selectUserById(artificer.getUserId()); + if(userEntity!=null){ + userEntity.setIsAuthentication(0); + userService.updateById(userEntity); + realNameService.remove(new QueryWrapper().eq("user_id",userEntity.getUserId())); + } + artificerService.removeById(artificer.getArtificerId()); + } + return Result.success(); + } + + @PostMapping("/accomplishOrders") + @ApiOperation("完成订单") + public Result accomplishOrders(Long ordersId){ + return ordersService.accomplishOrders(ordersId,1,null,null); + } + + + @GetMapping("/selectOrdersList") + @ApiOperation("查询订单列表") + public Result selectOrdersList(Long userId,Integer page,Integer limit,Integer status,String city, + String name,String phone,Long artificerId,Long parentId,String startTime, + String endTime,Integer isAdd,String ordersNo,String artificerName, + String oneUserName,String oneArtificerUserName, + String startServeTime,String endServeTime,Integer overTimeOrders,Long shopId, + String shopName,Integer warning,String title,String classifyId){ + return ordersService.selectOrdersList(userId, page, limit, status, city, name, phone, + artificerId, parentId, startTime, endTime, isAdd, ordersNo, artificerName, + oneUserName, oneArtificerUserName, startServeTime, endServeTime,overTimeOrders,shopId,shopName,warning,title,classifyId); + } + + @GetMapping("/excelOrdersList") + @ApiOperation("导出订单列表") + public void excelOrdersList(Long userId,Integer status,String city, + String name,String phone,Long artificerId,Long parentId,String startTime, + String endTime,Integer isAdd,String ordersNo,String artificerName, + String oneUserName,String oneArtificerUserName, + String startServeTime,String endServeTime,Integer overTimeOrders,Long shopId, + String shopName,Integer warning,String title,String classifyId, HttpServletResponse response) throws Exception{ + ExcelData excelData = ordersService.excelOrdersList(userId, status, city, name, phone, artificerId, parentId, + startTime, endTime, isAdd, ordersNo, artificerName, oneUserName, oneArtificerUserName, startServeTime, + endServeTime,overTimeOrders,shopId,shopName,warning,title,classifyId); + ExportExcelUtils.exportExcel(response,"订单列表.xlsx",excelData); + } + + @PostMapping("/deleteOrders") + @ApiOperation("删除订单") + public Result deleteOrders(Long ordersId){ + ordersService.removeById(ordersId); + return Result.success(); + } + + @PostMapping("/cancelOrders") + @ApiOperation("取消订单") + public Result cancelOrders(Long ordersId){ + return ordersService.cancelOrders(null,ordersId); + } + + @PostMapping("/updateOrders") + @ApiOperation("修改订单") + public Result updateOrders(@RequestBody Orders orders){ + return ordersService.updateOrders(orders); + } + + @PostMapping("/refundOrdersMoney") + @ApiOperation("退款订单(可部分退款)") + public Result refundOrdersMoney(Long ordersId,BigDecimal refundMoney){ + return ordersService.refundOrdersMoney(ordersId,refundMoney); + } + + + @GetMapping("/selectAgencyList") + @ApiOperation("查询申请记录") + public Result selectAgencyList(Integer page,Integer limit,String city,String phone,String userName){ + return Result.success().put("data",agencyService.page(new Page<>(page,limit),new QueryWrapper().eq(StringUtils.isNotBlank(city),"city",city).eq(StringUtils.isNotBlank(phone),"phone",phone).eq(StringUtils.isNotBlank(userName),"name",userName).orderByDesc("create_time"))); + } + + + @PostMapping("/auditArtificer") + @ApiOperation("审核申请记录") + public Result auditArtificer(@RequestBody Certification certification){ + Certification certification1 = userCertificationService.getById(certification.getId()); + Agency agency = agencyService.selectAgencyByUserId(certification1.getUserId()); + if(agency.getStatus().equals(0)){ + agency.setStatus(certification.getStatus()); + if(certification.getStatus().equals(1)){ + UserEntity user = userService.getById(certification1.getUserId()); + certification1.setStatus(1); + certification1.setUpdateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + user.setIsAuthentication(2); + Artificer artificer = artificerService.selectArtificerByUserId(user.getUserId()); + if(artificer==null){ + artificer=new Artificer(); + artificer.setStatus(2); + artificer.setUserId(certification1.getUserId()); + artificer.setArtificerSales(0); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + artificer.setCreateTime(sdf.format(new Date())); + artificer.setCreditScore(BigDecimal.valueOf(100)); + artificer.setTripWay(1); + artificer.setRate(new BigDecimal(commonInfoService.findOne(381).getValue())); + } + artificer.setArtificerName(certification1.getName()); + artificer.setArtificerImg(certification1.getAvatar()); + artificer.setLifePhoto(certification1.getImagePhoto()); + artificer.setCertificate(certification1.getCertification()); + artificer.setContent(certification1.getIndividualResume()); + artificerService.updateById(artificer); + + BigDecimal cashDeposit = certification1.getMoney(); + Long userId = user.getUserId(); + userMoneyDao.updateCashDeposit(1, userId, cashDeposit.doubleValue()); + user.setIsCashDeposit(2); + userService.updateById(user); + } + agencyService.updateById(agency); + }else{ + return Result.error("已经审核过了!"); + } + return Result.success(); + } + + + @ApiOperation("技师添加服务") + @PostMapping(value = "insertArtificerMassage") + public Result insertArtificerMassage(Long userId, String artificerMassages){ + return artificerMassageService.insertArtificerMassage(artificerMassages, userId); + } + + @ApiOperation("技师删除服务") + @PostMapping(value = "deleteArtificerMassage") + public Result deleteArtificerMassage(Long artificerMassageId){ + return artificerMassageService.deleteArtificerMassage(artificerMassageId); + } + + @ApiOperation("查看商户主页信息") + @GetMapping(value = "selectArtificerIndex") + public Result selectArtificerIndex(Long userId,String startTime,String endTime){ + Artificer artificer = artificerService.selectArtificerByUserId(userId); + return ordersService.selectArtificerIndex(artificer.getArtificerId(),startTime,endTime); + } + + @ApiOperation("退款订单") + @PostMapping("/refundOrders") + public Result refundOrders(Long ordersId){ + return ordersService.refundOrders(ordersId); + } + + @PostMapping("/updateArtificerCreditScore") + @ApiOperation("修改技师信誉分") + public Result updateArtificerCreditScore(Integer type,BigDecimal creditScore,Long artificerId){ + return ordersService.updateArtificerCreditScore(type, creditScore, artificerId); + } + + @Scheduled(cron = "0 */1 * * * ?") + public void endOrders(){ + ordersService.endOrders(); + } + + + @GetMapping("/selectTeamUserList") + @ApiOperation("获取团队列表") + public Result selectTeamUserList(Long userId, Integer page, Integer limit, Integer type){ + UserEntity user = userService.selectUserById(userId); + return ordersService.selectTeamUserList(page,limit,user.getInvitationCode(),type,userId); + } + + + @PostMapping("/updateArtificer") + @ApiOperation("技师上线下线") + public Result updateArtificer(Long userId,String longitude,String latitude,String city){ + Artificer artificer = artificerService.selectArtificerByUserId(userId); + UserEntity userEntity = userService.selectUserById(userId); + String value = commonInfoService.findOne(320).getValue(); + if("是".equals(value)){ + if(userEntity.getIsCashDeposit()==null || !userEntity.getIsCashDeposit().equals(2)){ + return Result.error("当前账号未缴纳保证金,暂无法上线接单!"); + } + } + + if(userEntity.getIsAuthentication()==null || !userEntity.getIsAuthentication().equals(2)){ + return Result.error("当前账号未实名认证,暂无法上线接单!"); + } + artificer.setLongitude(longitude); + artificer.setLatitude(latitude); + artificer.setCity(city); + if(artificer.getStatus()==1){ + artificer.setStatus(2); + }else{ + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String time = simpleDateFormat.format(new Date()); + MessageInfo messageInfo = messageService.selectMessageByUserIdAndTime(userId, time); + if(messageInfo==null){ + return Result.error("您今天还没签到,请签到后进行上线!"); + } + artificer.setStatus(1); + } + artificerService.updateById(artificer); + return Result.success(); + } + + @GetMapping("/selectOrdersCountStatisticsByYear") + @ApiOperation("订单数量统计") + public Result selectOrdersCountStatisticsByYear(String startTime,String endTime){ + //总数量 1待支付 2待服务 3待评论 4已取消 5已完成 6进行中 + List ordersCountList=new ArrayList<>(); + List ordersDaiFuKuanCountList=new ArrayList<>(); + List ordersDaiFuWuCountList=new ArrayList<>(); + List ordersDaiPingLunCountList=new ArrayList<>(); + List ordersYiQuXiaoCountList=new ArrayList<>(); + List ordersYiWanCengCountList=new ArrayList<>(); + List ordersJinxXinZhongCountList=new ArrayList<>(); + List year=new ArrayList<>(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar=Calendar.getInstance(); + Date parse = null; + try { + parse = simpleDateFormat.parse(startTime); + } catch (ParseException e) { + e.printStackTrace(); + } + calendar.setTime(parse); + while (true){ + String dateTime = simpleDateFormat.format(calendar.getTime()); + //状态 1待支付 2待服务 3待评论 4已取消 5已完成 6进行中 + //总订单数 + Integer ordersCount = ordersService.selectOrdersCountStatisticsByYear(1, dateTime, null); + ordersCountList.add(ordersCount); + //待付款 + Integer ordersDaiFuKuanCount = ordersService.selectOrdersCountStatisticsByYear(1, dateTime, 1); + ordersDaiFuKuanCountList.add(ordersDaiFuKuanCount); + //2待服务 + Integer ordersJinXinCount = ordersService.selectOrdersCountStatisticsByYear(1, dateTime, 2); + ordersDaiFuWuCountList.add(ordersJinXinCount); + //3待评论 + Integer ordersQuXiaoCount = ordersService.selectOrdersCountStatisticsByYear(1, dateTime, 3); + ordersDaiPingLunCountList.add(ordersQuXiaoCount); + //4已取消 + Integer ordersBuFeiCount = ordersService.selectOrdersCountStatisticsByYear(1, dateTime, 4); + ordersYiQuXiaoCountList.add(ordersBuFeiCount); + //5已完成 + Integer ordersTuiFeiCount = ordersService.selectOrdersCountStatisticsByYear(1, dateTime, 5); + ordersYiWanCengCountList.add(ordersTuiFeiCount); + //6进行中 + Integer ordersShenSuCount = ordersService.selectOrdersCountStatisticsByYear(1, dateTime, 6); + ordersJinxXinZhongCountList.add(ordersShenSuCount); + year.add(dateTime); + if(dateTime.equals(endTime)){ + break; + } + calendar.add(Calendar.DATE,1); + } + Map result=new HashMap<>(); + result.put("ordersCountList",ordersCountList); + result.put("ordersDaiFuKuanCountList",ordersDaiFuKuanCountList); + result.put("ordersDaiFuWuCountList",ordersDaiFuWuCountList); + result.put("ordersDaiPingLunCountList",ordersDaiPingLunCountList); + result.put("ordersYiQuXiaoCountList",ordersYiQuXiaoCountList); + result.put("ordersYiWanCengCountList",ordersYiWanCengCountList); + result.put("ordersJinxXinZhongCountList",ordersJinxXinZhongCountList); + result.put("year",year); + return Result.success().put("data",result); + } + + @GetMapping("/selectArtificerMoneyList") + @ApiOperation("技师收益排行榜") + public Result selectArtificerMoneyList(Integer page,Integer limit,String startTime,String endTime,String title,String classifyId){ + return artificerService.selectArtificerMoneyList(page, limit, startTime, endTime, title,classifyId); + } + + + @GetMapping("/selectArtificerOrdersList") + @ApiOperation("查询进行中的技师订单") + public Result selectArtificerOrdersList(Integer page,Integer limit,String artificerName, + String artificerPhone,String userName,String phone, + Integer warning,Integer overTimeOrders){ + return ordersService.selectArtificerOrdersList(page, limit, artificerName, artificerPhone, userName, phone,warning,overTimeOrders); + } + + @GetMapping("/selectWarningOrdersCount") + @ApiOperation("查询警告订单总数") + public Result selectWarningOrdersCount(){ + return Result.success().put("data",ordersService.count(new QueryWrapper().in("status",6,7,8).eq("warning",1))); + } + + @GetMapping("/selectOverTimeOrdersCount") + @ApiOperation("查询超时订单总数") + public Result selectOverTimeOrdersCount(){ + return Result.success().put("data",ordersService.count(new QueryWrapper().in("status",6,7,8).eq("over_time_orders",1))); + } + + @GetMapping("/selectShopMoney") + @ApiOperation("查询商家抽成") + public Result selectShopMoney(Integer page,Integer limit,String userName,String phone,String flag,String time){ + return ordersService.selectShopMoney(page, limit, userName,phone, flag, time); + } + + @GetMapping("/selectOneUserMoney") + @ApiOperation("查询用户代理抽成") + public Result selectOneUserMoney(Integer page,Integer limit,String userName,String phone,String flag,String time){ + return ordersService.selectOneUserMoney(page, limit, userName,phone, flag, time); + } + + @GetMapping("/selectOneArtificerMoney") + @ApiOperation("查询技师代理抽成") + public Result selectOneArtificerMoney(Integer page,Integer limit,String userName,String phone,String flag,String time){ + return ordersService.selectOneArtificerMoney(page, limit, userName,phone, flag, time); + } + + @GetMapping("/selectArtificerMoney") + @ApiOperation("查询技师抽成") + public Result selectArtificerMoney(Integer page,Integer limit,String userName,String phone,String flag,String time){ + return ordersService.selectArtificerMoney(page, limit, userName,phone, flag, time); + } + + @GetMapping("/selectNewUserOrdersCount") + @ApiOperation("查询新用户下单数") + public Result selectNewUserOrdersCount(Integer page,Integer limit,String userName,String phone){ + return ordersService.selectNewUserOrdersCount(page, limit, userName, phone); + } + + @GetMapping("/selectNewUserOrdersRate") + @ApiOperation("查询新用户下单数") + public Result selectNewUserOrdersRate(){ + return ordersService.selectNewUserOrdersRate(); + } + + +} diff --git a/src/main/java/com/sqx/modules/artificer/controller/ArtificerTimeController.java b/src/main/java/com/sqx/modules/artificer/controller/ArtificerTimeController.java new file mode 100644 index 0000000..eed0461 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/controller/ArtificerTimeController.java @@ -0,0 +1,47 @@ +package com.sqx.modules.artificer.controller; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.dao.UserMoneyDao; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.entity.*; +import com.sqx.modules.artificer.service.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; + +@RestController +@RequestMapping("/artificerTime") +@Api(value = "师傅时间管理", tags = {"师傅时间管理"}) +public class ArtificerTimeController { + + @Autowired + private ArtificerTimeService artificerTimeService; + + + @GetMapping("/selectArtificerTimeByArtificerId") + @ApiOperation("查看时间") + public Result selectArtificerTimeByArtificerId(Long artificerId,String artificerDate){ + return artificerTimeService.selectArtificerTimeByArtificerId(artificerId,artificerDate); + } + + @PostMapping("/updateArtificerTime") + @ApiOperation("修改时间管理") + public Result updateArtificerTime(String artificerDate,String times, Long userId){ + return artificerTimeService.updateArtificerTime( artificerDate, times, userId); + } + + + + +} diff --git a/src/main/java/com/sqx/modules/artificer/controller/RealNameController.java b/src/main/java/com/sqx/modules/artificer/controller/RealNameController.java new file mode 100644 index 0000000..7a1456d --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/controller/RealNameController.java @@ -0,0 +1,89 @@ +package com.sqx.modules.artificer.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.Certification; +import com.sqx.modules.artificer.service.ArtificerService; +import com.sqx.modules.artificer.service.RealNameService; +import com.sqx.modules.message.entity.MessageInfo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/admin/realname") +@Api(value = "管理端-技师实名认证", tags = {"管理端-技师实名认证"}) +public class RealNameController { + + @Autowired + private RealNameService realNameService; + @Autowired + private UserService userService; + @Autowired + private ArtificerService artificerService; + + @ApiOperation("查看实名认证列表") + @GetMapping(value = "selectRealNameList") + public Result selectRealNameList(Integer page, Integer limit, Integer status, String userName, String phone,Long classifyId){ + return realNameService.selectRealNameList(page, limit, status, userName, phone,classifyId); + } + + @GetMapping("/selectRealNameCount") + @ApiOperation("查询实名待审核总和") + public Result selectRealNameCount(){ + return Result.success().put("data",realNameService.count(new QueryWrapper().eq("status",0))); + } + + @PostMapping("/deleteRealName") + @ApiOperation("删除技师实名认证") + public Result deleteRealName(Long id){ + Certification certification = realNameService.getById(id); + realNameService.removeById(id); + UserEntity userEntity = userService.selectUserById(certification.getUserId()); + userEntity.setIsAuthentication(0); + userService.updateById(userEntity); + Artificer artificer = artificerService.selectArtificerByUserId(certification.getUserId()); + if(artificer!=null){ + artificer.setStatus(2); + artificerService.updateById(artificer); + } + return Result.success(); + } + + @PostMapping("/updateRealName") + @ApiOperation("修改技师实名认证") + public Result updateRealName(@RequestBody Certification certification){ + realNameService.updateById(certification); + return Result.success(); + } + + @ApiOperation("按id查看实名认证信息") + @GetMapping(value = "selectRealNameById") + public Result selectRealNameById(Long userId){ + return realNameService.selectRealNameById(userId); + } + + @ApiOperation("审核实名认证") + @PostMapping(value = "auditRealName") + public Result auditRealName(@RequestBody Certification certification){ + return realNameService.auditRealName(certification); + } + + @ApiOperation("管理端审核退还保证金") + @PostMapping(value = "auditRefund") + public Result auditRefund(Long userId, Integer type){ + return realNameService.auditRefund(userId, type); + } + + @ApiOperation("查询保证金退款列表") + @GetMapping("/selectRefundCashDepositList") + public Result selectRefundCashDepositList(Integer page,Integer limit,String userName,String phone){ + return realNameService.selectRefundCashDepositList(page, limit, userName, phone); + } + + +} diff --git a/src/main/java/com/sqx/modules/artificer/controller/app/AppArtificerController.java b/src/main/java/com/sqx/modules/artificer/controller/app/AppArtificerController.java new file mode 100644 index 0000000..e07f8b6 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/controller/app/AppArtificerController.java @@ -0,0 +1,497 @@ +package com.sqx.modules.artificer.controller.app; + + +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.map.CommonMapUtils; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.dao.ArtificerDao; +import com.sqx.modules.artificer.dao.UserRechargeDao; +import com.sqx.modules.artificer.entity.*; +import com.sqx.modules.artificer.service.*; +import com.sqx.modules.common.dao.CommonInfoDao; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.service.MessageService; +import com.sqx.modules.sys.entity.SysDictEntity; +import com.sqx.modules.sys.service.SysDictService; +import com.sqx.modules.trip.entity.Trip; +import com.sqx.modules.trip.service.TripService; +import com.sqx.modules.utils.HttpClientUtil; +import com.sqx.modules.utils.LonLatUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.gavaghan.geodesy.Ellipsoid; +import org.gavaghan.geodesy.GlobalCoordinates; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Slf4j +@RestController +@RequestMapping("/app/artificer") +@Api(value = "技师管理", tags = {"技师管理"}) +public class AppArtificerController { + + @Autowired + private ArtificerService artificerService; + @Autowired + private ArtificerMassageService artificerMassageService; + @Autowired + private MassageTypeService massageTypeService; + @Autowired + private UserService userService; + @Autowired + private OrdersService ordersService; + @Autowired + private CollectArtificerService collectArtificerService; + @Autowired + private AgencyService agencyService; + @Autowired + private MessageService messageService; + @Autowired + private TripService tripService; + @Autowired + private SysDictService sysDictService; + @Autowired + private CommonInfoService commonInfoService; + @Autowired + private CommonInfoDao commonInfoDao; + @Autowired + private ArtificerDao artificerDao; + @Autowired + private UserRechargeDao userRechargeDao; + + + @GetMapping("/selectMassageTypePage") + @ApiOperation("查询按摩分类(分页)") + public Result selectMassageTypePage(Integer page,Integer limit,Integer status,Integer sort,String city,Integer authentication,Integer by,String title,Long artificerId,Long userId,Integer parentId,Long classifyId){ + return massageTypeService.selectMassageTypePage(page, limit, status, city, sort,authentication,by,title,artificerId,userId,parentId,classifyId); + } + @GetMapping("/selectMassageTypeChildrenPage") + @ApiOperation("查询按摩分类子项目(分页)") + public Result selectMassageTypeChildrenPage(Integer page,Integer limit,Integer status,Integer sort,String city,Integer authentication,Integer by,String title,Long artificerId,Long userId,Integer parentId,Long classifyId){ + return massageTypeService.selectMassageTypeChildrenPage(page, limit, status, city, sort,authentication,by,title,artificerId,userId,parentId,classifyId); + } + @GetMapping("/selectMassageTypeList") + @ApiOperation("查询按摩分类(不带分页)") + public Result selectMassageTypeList(Integer status,Integer sort,String city,Integer authentication,Integer by,String title,Long artificerId,Long userId,Integer parentId,Long classifyId){ + return massageTypeService.selectMassageTypeList(status, city, sort,authentication,by,title,artificerId,userId,parentId,classifyId); + } + + @GetMapping("/selectMassageTypeById") + @ApiOperation("查询详情") + public Result selectMassageTypeById(Long massageTypeId){ + MassageType massageType = massageTypeService.getById(massageTypeId); + SysDictEntity sysDictEntity = sysDictService.getById(massageType.getClassifyId()); + if(sysDictEntity!=null){ + massageType.setClassifyName(sysDictEntity.getCode()); + } + return Result.success().put("data",massageType); + } + + @GetMapping("/selectArtificerList") + @ApiOperation("查询技师列表") + public Result selectArtificerList(Integer page, Integer limit, Long massageTypeId, String artificerName, + String longitude,String latitude,Integer sort,Integer authentication, + Integer by,String city,Long classifyId,String phone){ + return artificerService.selectArtificerList(page, limit, massageTypeId, artificerName,longitude,latitude, + sort,authentication,by,-1,city,classifyId,phone,1); + } + + @GetMapping("/selectArtificerMassageList") + @ApiOperation("查询技师服务列表") + public Result selectArtificerMassageList(Long artificerId,Integer status){ + return massageTypeService.selectArtificerMassageList(artificerId,status); + } + + + @GetMapping("/selectArtificerById") + @ApiOperation("查询技师详情") + public Result selectArtificerById(Long userId,Long artificerId,String longitude,String latitude){ + return Result.success().put("data",artificerService.selectArtificerById(userId,artificerId,longitude,latitude)); + } + @GetMapping("/selectArtificerByArtificerId") + @ApiOperation("查询技师详情by技师id") + public Result selectArtificerByArtificerId(Long artificerId){ + return artificerService.selectArtificerByArtificerId(artificerId); + } + @Login + @GetMapping("/selectArtificer") + @ApiOperation("查询当前登陆用户技师") + public Result selectArtificer(@RequestAttribute("userId") Long userId){ + return Result.success().put("data",artificerService.selectArtificerByUserId(userId)); + } + + @Login + @GetMapping("/selectTaxiMoney") + @ApiOperation("查询出行价格") + public Result selectTaxiMoney(Long artificerId,String latitude,String longitude,String city){ + JSONObject adInfo = CommonMapUtils.getLocationToAdInfo(longitude, latitude); + city = adInfo.getString("city"); + + Trip trip = tripService.getOne(new QueryWrapper().like("city", city)); + if(trip==null){ + return Result.error("当前地址暂无出行方式,请更换其他地址!"); + } + return Result.success().put("data",ordersService.selectTaxiMoney(artificerId, latitude, longitude, city)); + } + + + @Login + @PostMapping("/insertOrders") + @ApiOperation("添加订单") + public Result insertOrders(@RequestBody Orders orders){ + return ordersService.insertOrders(orders); + } + + @Login + @PostMapping("/removeOrders") + @ApiOperation("删除订单") + public Result removeOrders(Long ordersId){ + return ordersService.removeOrders(ordersId); + } + + @Login + @PostMapping("/deleteOrders") + @ApiOperation("取消订单") + public Result deleteOrders(@RequestAttribute Long userId,Long ordersId){ + return ordersService.cancelOrders(userId,ordersId); + } + + @Login + @GetMapping("/selectOrdersDetails") + @ApiOperation("查询订单详情") + public Result selectOrdersDetails(Long ordersId){ + return ordersService.selectOrdersDetails(ordersId); + } + + @Login + @GetMapping("/selectOrdersList") + @ApiOperation("查询订单列表") + public Result selectOrdersList(@RequestAttribute("userId") Long userId,Integer page,Integer limit,Integer status,String city, + String userName,String phone,Long artificerId,Long parentId,String startTime,String endTime, + Integer isAdd,String ordersNo,String artificerName, + String oneUserName,String oneArtificerUserName, + String startServeTime,String endServeTime,Integer overTimeOrders, + Long shopId,String shopName,Integer warning,String title,String classifyId){ + return ordersService.selectOrdersList(userId, page, limit, status, city, userName, phone, artificerId, + parentId, startTime, endTime, isAdd, ordersNo, artificerName, oneUserName, oneArtificerUserName, + startServeTime, endServeTime,overTimeOrders,shopId,shopName,warning,title,classifyId); + } + + @Login + @GetMapping("/selectOrdersLists") + @ApiOperation("查询订单列表") + public Result selectOrdersLists(Long userId,Integer page,Integer limit,Integer status,String city, + String userName,String phone,Long artificerId,Long parentId,String startTime,String endTime, + Integer isAdd,String ordersNo,String artificerName, + String oneUserName,String oneArtificerUserName, + String startServeTime,String endServeTime,Integer overTimeOrders,Long shopId, + String shopName,Integer warning,String title,String classifyId){ + return ordersService.selectOrdersList(userId, page, limit, status, city, userName, phone, artificerId, + parentId, startTime, endTime, isAdd, ordersNo, artificerName, oneUserName, oneArtificerUserName, + startServeTime, endServeTime,overTimeOrders,shopId,shopName,warning,title,classifyId); + } + + @Login + @PostMapping("/payOrders") + @ApiOperation("钱包支付订单") + public Result payOrders(Long ordersId,Integer type){ + return ordersService.payOrders(ordersId,type); + } + + @Login + @PostMapping("/payUserVip") + @ApiOperation("钱包支付会员") + public Result payUserVip(@RequestAttribute("userId") Long userId,Long vipDetailsId){ + return ordersService.payUserVip(userId,vipDetailsId); + } + + @Login + @ApiOperation("查看技师订单") + @GetMapping(value = "selectArtificerOrder") + public Result selectArtificerOrder(@RequestAttribute Long userId, Integer status, Integer page, Integer limit){ + return ordersService.selectArtificerOrder(userId, status, page, limit); + } + + + + @PostMapping("/accomplishOrders") + @ApiOperation("完成订单") + public Result accomplishOrders(Long ordersId,String accomplishLongitude,String accomplishLatitude){ + return ordersService.accomplishOrders(ordersId,2,accomplishLongitude,accomplishLatitude); + } + + @PostMapping("/startOrders") + @ApiOperation("开始服务") + public Result startOrders(Long ordersId,String startLongitude,String startLatitude,String startImg){ + return ordersService.startOrders(ordersId,startLongitude,startLatitude,startImg); + } + + @PostMapping("/artificerStartOrEndTime") + @ApiOperation("技师出发或到达") + public Result artificerStartOrEndTime(Long ordersId){ + return ordersService.artificerStartOrEndTime(ordersId); + } + + + @Login + @PostMapping("/insertCollect") + @ApiOperation("添加取消收藏") + public Result insertCollect(@RequestBody CollectArtificer collectArtificer){ + collectArtificer.setClassify(1); + return collectArtificerService.insertCollect(collectArtificer); + } + + @Login + @GetMapping("/selectCollectList") + @ApiOperation("查看收藏列表") + public Result selectCollectList(@RequestAttribute("userId") Long userId,Integer page,Integer limit,String longitude,String latitude){ + return collectArtificerService.selectCollectList(userId, page, limit,longitude,latitude); + } + + @Login + @ApiOperation("技师添加服务") + @PostMapping(value = "insertArtificerMassage") + public Result insertArtificerMassage(@RequestAttribute Long userId, String artificerMassages){ + return artificerMassageService.insertArtificerMassage(artificerMassages, userId); + } + + @Login + @ApiOperation("技师修改服务") + @PostMapping(value = "updateArtificerMassage") + public Result updateArtificerMassage(@RequestAttribute Long userId, @RequestBody ArtificerMassage artificerMassage){ + Artificer artificer = artificerService.selectArtificerByUserId(userId); + artificerMassage.setArtificerId(artificer.getArtificerId()); + ArtificerMassage artificerMassage1 = artificerMassageService.getById(artificerMassage.getArtificerMassageId()); + if(!artificerMassage1.getStatus().equals(artificerMassage.getStatus())){ + if(artificerMassage.getStatus().equals(1)){ + MassageType massageType = massageTypeService.getById(artificerMassage1.getMassageTypeId()); + if(massageType.getStatus().equals(2)){ + return Result.error("系统下架了此服务,暂不支持上架,如有疑问请联系客服!"); + } + } + } + return artificerMassageService.updateArtificerMassage(artificerMassage); + } + + @Login + @ApiOperation("技师删除服务") + @PostMapping(value = "deleteArtificerMassage") + public Result deleteArtificerMassage(Long id){ + + return artificerMassageService.deleteArtificerMassage(id); + } + + @Login + @ApiOperation("回显技师已添加的服务") + @GetMapping(value = "selectArtificerMassage") + public Result selectArtificerMassage(@RequestAttribute Long userId, Integer page, Integer limit, Integer status){ + Artificer artificer = artificerService.selectArtificerByUserId(userId); + return artificerMassageService.selectArtificerMassage(artificer.getArtificerId(), page, limit, status); + } + + @Login + @ApiOperation("查看商户主页信息") + @GetMapping(value = "selectArtificerIndex") + public Result selectArtificerIndex(@RequestAttribute Long userId,String startTime,String endTime){ + Artificer artificer = artificerService.selectArtificerByUserId(userId); + return ordersService.selectArtificerIndex(artificer.getArtificerId(),startTime,endTime); + } + + @Login + @ApiOperation("技师今日订单") + @GetMapping(value = "selectTodayOrder") + public Result selectTodayOrder(@RequestAttribute Long userId, Integer page, Integer limit,Integer type,String startTime,String endTime){ + Artificer artificer = artificerService.selectArtificerByUserId(userId); + return ordersService.selectTodayOrder(artificer.getArtificerId(), page, limit,type,startTime,endTime); + } + + @Login + @PostMapping("/insertAgency") + @ApiOperation("申请成为按摩师") + public Result insertAgency(@RequestBody Agency agency){ + return agencyService.insertAgency(agency); + } + + @Login + @GetMapping("/selectAgencyById") + @ApiOperation("查询申请记录") + public Result selectAgencyById(@RequestAttribute Long userId){ + return Result.success().put("data",agencyService.selectAgencyByUserId(userId)); + } + + @Login + @GetMapping("/selectArtificerMoney") + @ApiOperation("技师收益") + public Result selectArtificerMoney(@RequestAttribute Long userId){ + Artificer artificer = artificerService.selectArtificerByUserId(userId); + return artificerService.selectArtificerMoney(userId,artificer.getArtificerId()); + } + + @Login + @PostMapping("/updateArtificer") + @ApiOperation("技师上线下线") + public Result updateArtificer(@RequestAttribute Long userId,String longitude,String latitude,String city){ + Artificer artificer = artificerService.selectArtificerByUserId(userId); + UserEntity userEntity = userService.selectUserById(userId); + String value = commonInfoService.findOne(320).getValue(); + if("是".equals(value)){ + if(userEntity.getIsCashDeposit()==null || !userEntity.getIsCashDeposit().equals(2)){ + return Result.error("当前账号未缴纳保证金,暂无法上线接单!"); + } + } + if(userEntity.getIsAuthentication()==null || !userEntity.getIsAuthentication().equals(2)){ + return Result.error("当前账号未实名认证,暂无法上线接单!"); + } + artificer.setLongitude(longitude); + artificer.setLatitude(latitude); + artificer.setCity(city); + if(artificer.getStatus()==1){ + artificer.setStatus(2); + Integer i = Integer.valueOf(commonInfoDao.findOne(100000).getValue()); + Date upTime = artificer.getUpTime(); + long betweenDay = DateUtil.between(upTime, new Date(), DateUnit.MINUTE); + int i1 = new Long(betweenDay).intValue(); + int count = i1 / i; + if(count>0){ + UserRecharge userRecharge = new UserRecharge(); + userRecharge.setArtificerId(artificer.getArtificerId().intValue()); + userRecharge.setUserRecharge(new BigDecimal(count)); + userRecharge.setType("1"); + userRecharge.setUserId(userId.intValue()); + upTime = DateUtil.offsetMinute(upTime, i1); + userRecharge.setCreateTime(upTime.toString()); + userRechargeDao.insert(userRecharge); + } + }else{ + String value1 = commonInfoService.findOne(385).getValue(); + BigDecimal minScore = new BigDecimal(value1); + if(artificer.getCreditScore().doubleValue()0){ + UserRecharge userRecharge = new UserRecharge(); + userRecharge.setArtificerId(artificer.getArtificerId().intValue()); + userRecharge.setUserRecharge(new BigDecimal(count)); + userRecharge.setType("1"); + userRecharge.setUserId(userId.intValue()); + upTime = DateUtil.offsetMinute(upTime, i1); + userRecharge.setCreateTime(upTime.toString()); + userRechargeDao.insert(userRecharge); + } + artificerService.updateById(artificer); + return Result.success(); + } + @Login + @PostMapping("/timing") + @ApiOperation("10分钟定时请求接口加1积分") + public Result timing(Long artificerId){ + artificerService.timing(artificerId); + return Result.success(); + } + +// @Login + @PostMapping("/integral") + @ApiOperation("积分") + public Result integral(String artificerId,String type,Integer current,Integer size,String date,Integer fundType){ + return Result.success(artificerService.integral(artificerId,type,current,size,date,fundType)); + } + + @PostMapping("/stored/value") + @ApiOperation("储值积分") + public Result storedValue(String date,String type,String artificerId){ + return Result.success(artificerService.storedValue(date,type,artificerId)); + } + + + @Login + @PostMapping("/updateArtificerTripWay") + @ApiOperation("修改技师出行方式") + public Result updateArtificerTripWay(@RequestAttribute Long userId,Integer tripWay){ + Artificer artificer = artificerService.selectArtificerByUserId(userId); + artificer.setTripWay(tripWay); + artificerService.updateById(artificer); + return Result.success(); + } + + @Login + @PostMapping("/signIn") + @ApiOperation("签到") + public Result signIn(@RequestAttribute Long userId,String longitude,String latitude,String city,String address){ + return artificerService.signIn(userId,longitude,latitude,city,address); + } + + + @GetMapping("/selectTeamOrdersList") + @ApiOperation("获取团队订单") + public Result selectTeamOrdersList(Long userId, Integer page, Integer limit, Integer type, Integer status){ + return ordersService.selectTeamOrdersList(page,limit,userId,type,status); + } + + + @GetMapping("/selectTeamUserList") + @ApiOperation("获取团队列表") + public Result selectTeamUserList(Long userId, Integer page, Integer limit, Integer type){ + UserEntity user = userService.selectUserById(userId); + return ordersService.selectTeamUserList(page,limit,user.getInvitationCode(),type,userId); + } + + @GetMapping("/selectTeamStatistics") + @ApiOperation("团队统计") + public Result selectTeamStatistics(Long userId,Integer type){ + UserEntity user = userService.selectUserById(userId); + Double teamMoney = ordersService.selectOrdersMoneyCountByUserId(user.getUserId(), type,null); + Integer teamCount = ordersService.selectUserCountByInvitationCode(user.getInvitationCode(), type); + Map result=new HashMap<>(); + result.put("teamMoney",teamMoney); + result.put("teamCount",teamCount); + return Result.success().put("data",result); + } + + + +} diff --git a/src/main/java/com/sqx/modules/artificer/controller/app/AppArtificerIntegralController.java b/src/main/java/com/sqx/modules/artificer/controller/app/AppArtificerIntegralController.java new file mode 100644 index 0000000..9960a37 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/controller/app/AppArtificerIntegralController.java @@ -0,0 +1,114 @@ +package com.sqx.modules.artificer.controller.app; + + +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.artificer.dao.ArtificerDao; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.service.AppArtificerIntegralService; +import com.sqx.modules.artificer.vo.HomeVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Date; + +@Slf4j +@RestController +@RequestMapping("/app/artificer/integral/") +@Api(value = "技师积分", tags = {"技师积分"}) +@AllArgsConstructor +public class AppArtificerIntegralController { + + private final AppArtificerIntegralService appArtificerIntegralService; + private final ArtificerDao artificerDao; + @GetMapping("/home") + @ApiOperation("技师首页查询") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = HomeVO.class),}) + public Result home(@RequestParam Long artificerId) { + return appArtificerIntegralService.home(artificerId); + } + + @GetMapping("/upgrade") + @ApiOperation("技师升级定时任务手动入口(精油)") + @Deprecated + public Result upgrade(String date) { + return appArtificerIntegralService.upgrade(date); + } + + @GetMapping("/upgrade/zy") + @ApiOperation("技师升级定时任务手动入口(中医)") + @Deprecated + public Result upgradeZy(String date) { + return appArtificerIntegralService.upgradeZy(date); + } + + @GetMapping("/stop") + @ApiOperation("技师停牌定时任务手动入口") + public Result upgrade() { + return appArtificerIntegralService.line(); + } + + @Login + @GetMapping("/time") + @ApiOperation("前端获取多长时间积一分") + public Result time() { + return appArtificerIntegralService.time(); + } + + /** + * 每个月11号 21号和月末 在线时间不对问题(更新所有技师本周期在线时间为00:00:00) + */ + public void updArtificerTime() { + artificerDao.update(null, Wrappers.lambdaUpdate().set(Artificer::getUpTime, DateUtil.format(new Date(), "yyyy-MM-dd")+" 00:00:00")); + } + + /** + * 每个月11号 21号执行一次 定时任务 + * + * @return + */ + @Scheduled(cron = "0 0 0 11,21 * ?") + @ApiOperation("技师停牌处理+升级处理") + public Result line() { + //每个月11号 21号和月末 在线时间不对问题(更新所有技师本周期在线时间为00:00:00) + updArtificerTime(); + //精油升级 + appArtificerIntegralService.upgrade(""); + //中医升级 + appArtificerIntegralService.upgradeZy(""); + //停牌 +// appArtificerIntegralService.line(); + return Result.success(); + } + + /** + * 每月最后一日触发 定时任务 + * + * @return + */ + @Scheduled(cron = "0 0 0 L * ?") + @ApiOperation("技师停牌处理+升级处理") + public Result lines() { + //每个月11号 21号和月末在线离线时间不对问题(更新所有技师在线时间为00:00:00) + updArtificerTime(); + //精油升级 + appArtificerIntegralService.upgrade(""); + //中医升级 + appArtificerIntegralService.upgradeZy(""); + //停牌 +// appArtificerIntegralService.line(); + return Result.success(); + } + +} diff --git a/src/main/java/com/sqx/modules/artificer/controller/app/AppArtificerTimeController.java b/src/main/java/com/sqx/modules/artificer/controller/app/AppArtificerTimeController.java new file mode 100644 index 0000000..3fdb2f4 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/controller/app/AppArtificerTimeController.java @@ -0,0 +1,43 @@ +package com.sqx.modules.artificer.controller.app; + + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.artificer.service.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/app/artificerTime") +@Api(value = "师傅时间管理", tags = {"师傅时间管理"}) +public class AppArtificerTimeController { + + @Autowired + private ArtificerTimeService artificerTimeService; + + @PostMapping("/updateArtificerTime") + @ApiOperation("修改时间管理") + @Login + public Result updateArtificerTime(String artificerDate,String times,@RequestAttribute("userId") Long userId){ + return artificerTimeService.updateArtificerTime( artificerDate, times, userId); + } + + @GetMapping("/selectArtificerTimeByArtificerId") + @ApiOperation("查看时间") + public Result selectArtificerTimeByArtificerId(Long artificerId,String artificerDate){ + return artificerTimeService.selectArtificerTimeByArtificerId(artificerId,artificerDate); + } + + + @GetMapping("/selectArtificerTimeListByArtificerId") + @ApiOperation("查看时间(连续查最近五天)") + public Result selectArtificerTimeListByArtificerId(Long artificerId,String artificerDate){ + return artificerTimeService.selectArtificerTimeListByArtificerId(artificerId,artificerDate); + } + + + + +} diff --git a/src/main/java/com/sqx/modules/artificer/controller/app/AppRealNameController.java b/src/main/java/com/sqx/modules/artificer/controller/app/AppRealNameController.java new file mode 100644 index 0000000..503caac --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/controller/app/AppRealNameController.java @@ -0,0 +1,55 @@ +package com.sqx.modules.artificer.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.artificer.entity.Certification; +import com.sqx.modules.artificer.service.RealNameService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/app/realname") +@Api(value = "技师端-技师实名认证", tags = {"技师端-技师实名认证"}) +public class AppRealNameController { + + @Autowired + private RealNameService realNameService; + + @Login + @ApiOperation("回显实名认证信息") + @GetMapping(value = "selectRealName") + public Result selectRealName(@RequestAttribute Long userId){ + + return realNameService.selectRealName(userId); + } + + @Login + @ApiOperation("修改实名认证信息") + @PostMapping(value = "updateRealName") + public Result updateRealName(@RequestAttribute Long userId, @RequestBody Certification certification){ + certification.setUserId(userId); + return realNameService.updateRealName(certification); + } + + //申请退还保证金 + @Login + @ApiOperation("申请退还保证金") + @PostMapping(value = "retreatCashDeposit") + public Result retreatCashDeposit(@RequestAttribute Long userId){ + + return realNameService.retreatCashDeposit(userId); + } + + @Login + @ApiOperation("实名认证") + @PostMapping("/auditRealName") + public Result auditRealName(@RequestAttribute Long userId,@RequestBody Certification certification){ + certification.setUserId(userId); + return realNameService.updateRealName(certification); + } + + + +} diff --git a/src/main/java/com/sqx/modules/artificer/controller/app/DividedIntoDetailsController.java b/src/main/java/com/sqx/modules/artificer/controller/app/DividedIntoDetailsController.java new file mode 100644 index 0000000..2b220e7 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/controller/app/DividedIntoDetailsController.java @@ -0,0 +1,43 @@ +package com.sqx.modules.artificer.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.entity.Period; +import com.sqx.modules.artificer.service.OrdersService; +import com.sqx.modules.utils.PeriodUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/app/dividedIntoDetails") +@Api(value = "技师端-分成明细", tags = {"技师端-分成明细查询"}) +public class DividedIntoDetailsController { + @Autowired + private OrdersService ordersService; + //@Login + @ApiOperation("分成明细-总收益查询") + @PostMapping(value = "selectDividedIntoDetail") + public Result selectDividedIntoDetail(Period period){ + period = PeriodUtil.calculationPeriod(period); + Result result = ordersService.selectDividedIntoDetail(period); + return result; + } + //@Login + @ApiOperation("分成明细-收益列表") + @PostMapping(value = "selectDividedIntoDetails") + public Result selectDividedIntoDetails(Integer page, Integer limit,Period period) { + period = PeriodUtil.calculationPeriod(period); + Result result = ordersService.selectDividedIntoDetails(page,limit, period); + return result; + } + //@Login + @ApiOperation("分成明细-列表详情") + @PostMapping(value = "splitDetails") + public Result splitDetails(Period period){ + Result result = ordersService.splitDetails(period); + return result; + } +} diff --git a/src/main/java/com/sqx/modules/artificer/controller/app/FundDetailsController.java b/src/main/java/com/sqx/modules/artificer/controller/app/FundDetailsController.java new file mode 100644 index 0000000..ec21663 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/controller/app/FundDetailsController.java @@ -0,0 +1,31 @@ +package com.sqx.modules.artificer.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.service.UserMoneyDetailsService; +import com.sqx.modules.artificer.entity.Period; +import com.sqx.modules.utils.PeriodUtil; +import com.winnerlook.model.VoiceNotifyBody; +import com.winnerlook.model.VoiceResponseResult; +import com.winnerlook.service.VoiceSender; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.LinkedHashMap; + +@RestController +@RequestMapping("/app/fundDetails") +@Api(value = "技师端-资金明细", tags = {"技师端-资金明细"}) +public class FundDetailsController { + @Autowired + private UserMoneyDetailsService userMoneyDetailsService; + //@Login + @ApiOperation("资金明细查询") + @PostMapping(value = "selectFundDetails") + public Result selectFundDetails(Integer page, Integer limit, Period period) { + period = PeriodUtil.calculationPeriod(period); + Result result = userMoneyDetailsService.selectIncomeByArtificerId(page,limit, period); + return result; + } +} diff --git a/src/main/java/com/sqx/modules/artificer/dao/AgencyDao.java b/src/main/java/com/sqx/modules/artificer/dao/AgencyDao.java new file mode 100644 index 0000000..79a1d06 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/dao/AgencyDao.java @@ -0,0 +1,17 @@ +package com.sqx.modules.artificer.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.artificer.entity.Agency; +import com.sqx.modules.artificer.entity.Artificer; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + + +@Mapper +public interface AgencyDao extends BaseMapper { + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/dao/ArtificerDao.java b/src/main/java/com/sqx/modules/artificer/dao/ArtificerDao.java new file mode 100644 index 0000000..7167edd --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/dao/ArtificerDao.java @@ -0,0 +1,35 @@ +package com.sqx.modules.artificer.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.artificer.entity.Artificer; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Map; + + +@Mapper +public interface ArtificerDao extends BaseMapper { + + IPage selectArtificerList(Page page,@Param("massageTypeId") Long massageTypeId, + @Param("artificerName") String artificerName,@Param("longitude")String longitude, + @Param("latitude")String latitude,@Param("sort") Integer sort, + @Param("authentication") Integer authentication,@Param("by") Integer by, + @Param("status") Integer status,@Param("city") String city, + @Param("classifyId") Long classifyId,@Param("phone") String phone,Integer user); + + Artificer selectArtificerById(@Param("userId") Long userId,@Param("artificerId") Long artificerId,@Param("longitude") String longitude,@Param("latitude") String latitude); + + Artificer selectArtificerByUserId(Long userId); + + int selectArtificerByStatus(Long userId, Integer status); + + IPage> selectArtificerMoneyList(Page> page,String startTime,String endTime,String title,String classifyId); + + IPage selectUserListByConsortiaId(Page page, String userName, String phone, Long consortiaId, Long shopId, Integer flag, String time); + + Integer selectArtificerMassageDuration(Long artificerId); +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/dao/ArtificerMassageDao.java b/src/main/java/com/sqx/modules/artificer/dao/ArtificerMassageDao.java new file mode 100644 index 0000000..318d355 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/dao/ArtificerMassageDao.java @@ -0,0 +1,20 @@ +package com.sqx.modules.artificer.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.ArtificerMassage; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + + +@Mapper +public interface ArtificerMassageDao extends BaseMapper { + + IPage selectArtificerMassage(Page pages, Long userId, Integer status); + + int updateArtificerMassageStatus(@Param("massageTypeId") Long massageTypeId); + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/dao/ArtificerTimeDao.java b/src/main/java/com/sqx/modules/artificer/dao/ArtificerTimeDao.java new file mode 100644 index 0000000..832453c --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/dao/ArtificerTimeDao.java @@ -0,0 +1,17 @@ +package com.sqx.modules.artificer.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.ArtificerTime; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + + +@Mapper +public interface ArtificerTimeDao extends BaseMapper { + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/dao/CollectArtificerDao.java b/src/main/java/com/sqx/modules/artificer/dao/CollectArtificerDao.java new file mode 100644 index 0000000..520208f --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/dao/CollectArtificerDao.java @@ -0,0 +1,21 @@ +package com.sqx.modules.artificer.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.CollectArtificer; +import com.sqx.modules.artificer.entity.Orders; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + + +@Mapper +public interface CollectArtificerDao extends BaseMapper { + + IPage selectArtificerListByCollectUserId(Page page,Long userId,@Param("longitude")String longitude,@Param("latitude")String latitude); + + int selectCountByUserId(@Param("artificerId") Long artificerId,@Param("startTime") String startTime,@Param("endTime") String endTime); + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/dao/MassageTypeDao.java b/src/main/java/com/sqx/modules/artificer/dao/MassageTypeDao.java new file mode 100644 index 0000000..7423401 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/dao/MassageTypeDao.java @@ -0,0 +1,25 @@ +package com.sqx.modules.artificer.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.MassageType; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + + +@Mapper +public interface MassageTypeDao extends BaseMapper { + + List selectArtificerMassageList(@Param("artificerId") Long artificerId,@Param("status") Integer status); + + IPage selectMassageTypePage(Page page,@Param("status") Integer status,@Param("city") String city,@Param("sort") Integer sort,@Param("authentication") Integer authentication,@Param("by")Integer by,@Param("title") String title,@Param("artificerId") Long artificerId,@Param("parentId") Integer parentId,@Param("classifyId") Long classifyId); + + List selectMassageTypeList(@Param("status") Integer status,@Param("city") String city,@Param("sort") Integer sort,@Param("authentication") Integer authentication,@Param("by")Integer by,@Param("title") String title,@Param("artificerId") Long artificerId,@Param("parentId") Integer parentId,@Param("classifyId") Long classifyId); + + IPage selectMassageTypeChildrenPage(Page pages, Integer status, String city, Integer sort, Integer authentication, Integer by, String title, Long artificerId, Integer parentId, Long classifyId); +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/dao/OrdersDao.java b/src/main/java/com/sqx/modules/artificer/dao/OrdersDao.java new file mode 100644 index 0000000..31e3254 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/dao/OrdersDao.java @@ -0,0 +1,109 @@ +package com.sqx.modules.artificer.dao; + + +import cn.hutool.core.date.DateTime; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.artificer.entity.Orders; +import com.sqx.modules.artificer.vo.HomeVO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + + +@Mapper +public interface OrdersDao extends BaseMapper { + + int insertOrders(Orders orders); + + IPage selectOrdersList(Page page,@Param("userId") Long userId,@Param("status") Integer status, + @Param("city") String city,@Param("userName") String userName,@Param("phone") String phone, + @Param("artificerId") Long artificerId,@Param("parentId") Long parentId,@Param("startTime") String startTime, + @Param("endTime") String endTime,@Param("isAdd") Integer isAdd,String ordersNo,String artificerName, + String oneUserName,String oneArtificerUserName, + String startServeTime,String endServeTime,Integer overTimeOrders,Long shopId,String shopName,Integer warning, + String title,String classifyId); + + List excelOrdersList(@Param("userId") Long userId,@Param("status") Integer status, + @Param("city") String city,@Param("userName") String userName,@Param("phone") String phone, + @Param("artificerId") Long artificerId,@Param("parentId") Long parentId,@Param("startTime") String startTime, + @Param("endTime") String endTime,@Param("isAdd") Integer isAdd,String ordersNo,String artificerName, + String oneUserName,String oneArtificerUserName, + String startServeTime,String endServeTime,Integer overTimeOrders,Long shopId,String shopName,Integer warning, + String title,String classifyId); + + BigDecimal selectOrdersMoney(String time, Integer type,Integer status); + + BigDecimal selectSumMoney(Long userId,@Param("startTime") String startTime,@Param("endTime") String endTime); + + BigDecimal selectSumMoneyMonth(Long userId,@Param("time") String time); + + BigDecimal selectEstimationSumMoneyBy(Long userId,@Param("time") String time,@Param("type") Integer type); + + int selectCountOrderNum(Long userId,@Param("startTime") String startTime,@Param("endTime") String endTime); + + int selectCountOrders(String time, Integer type,Integer status); + + int selectCountOrder(Long userId,@Param("status") Integer status,@Param("startTime") String startTime,@Param("endTime") String endTime); + + int selectCountOrderByUserId(Long userId,Integer status,String time); + + IPage selectTodayOrder(Page pages,@Param("artificerId") Long artificerId,@Param("type") Integer type,@Param("startTime") String startTime,@Param("endTime") String endTime); + + IPage selectArtificerOrder(Page pages, Long userId, Integer status); + + int selectOrdersCountByUnderway(@Param("artificerId") Long artificerId); + + + Double selectOrdersMoneyCountByUserId(Long userId,Integer type,String time); + + Integer selectUserCountByInvitationCode(String invitationCode,Integer type); + + IPage> selectTeamOrdersList(Page> page, @Param("userId") Long userId, @Param("type") Integer type, @Param("status") Integer status); + + IPage> selectTeamUserList(Page> page,@Param("invitationCode") String invitationCode,@Param("type") Integer type,@Param("userId") Long userId); + + List selectOrdersByEndTime(String minute); + + Integer selectOrdersCountStatisticsByYear(Integer flag,String time,Integer status); + + IPage selectArtificerOrdersList(Page page,@Param("artificerName") String artificerName,@Param("artificerPhone") String artificerPhone, + @Param("userName") String userName,@Param("phone") String phone,@Param("warning")Integer warning, + @Param("overTimeOrders") Integer overTimeOrders); + + int updateOrdersWarning(String time); + + List selectOrdersStatusByTime(String time); + + IPage> selectShopMoney(Page page,String userName,String phone,String flag,String time); + + IPage> selectOneUserMoney(Page page,String userName,String phone,String flag,String time); + + IPage> selectOneArtificerMoney(Page page,String userName,String phone,String flag,String time); + + IPage> selectArtificerMoney(Page page,String userName,String phone,String flag,String time); + + IPage> selectNewUserOrdersCount(Page page,String userName,String phone); + + Double selectNewUserOrdersRate(); + + Integer selectOrdersArtificerIntegralEarnings(Long artificerId, String endDate, String startDate); + + String selectOrdersArtificerIntegral(Long artificerId, String endDate, String startDate); + + String selectOrdersArtificerIntegraladdNum(Long artificerId, String endDate, String startDate); + + String selectOrdersCurrentPeriodRechargeSum(Long artificerId, String endDate, String startDate); + + String selectOrdersStoredValueIntegral(Long artificerId, String endDate, String startDate); + + String selectOnlineCredits(Long artificerId, String endDate, String startDate); + + String selectTaxiMoney(Long artificerId, String endDate, String startDate); + + String earnings(Long artificerId, String endDate, String startDate); +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/dao/OrdersMassageDao.java b/src/main/java/com/sqx/modules/artificer/dao/OrdersMassageDao.java new file mode 100644 index 0000000..9caf815 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/dao/OrdersMassageDao.java @@ -0,0 +1,15 @@ +package com.sqx.modules.artificer.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.artificer.entity.Orders; +import com.sqx.modules.artificer.entity.OrdersMassage; +import org.apache.ibatis.annotations.Mapper; + + +@Mapper +public interface OrdersMassageDao extends BaseMapper { + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/dao/RealNameDao.java b/src/main/java/com/sqx/modules/artificer/dao/RealNameDao.java new file mode 100644 index 0000000..cfe0b18 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/dao/RealNameDao.java @@ -0,0 +1,16 @@ +package com.sqx.modules.artificer.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.artificer.entity.Certification; +import org.apache.ibatis.annotations.Mapper; + +import java.util.Map; + +@Mapper +public interface RealNameDao extends BaseMapper { + + IPage> selectRefundCashDepositList(Page> page,String userName,String phone); + +} diff --git a/src/main/java/com/sqx/modules/artificer/dao/UserRechargeDao.java b/src/main/java/com/sqx/modules/artificer/dao/UserRechargeDao.java new file mode 100644 index 0000000..671d9b8 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/dao/UserRechargeDao.java @@ -0,0 +1,37 @@ +package com.sqx.modules.artificer.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.artificer.entity.UserRecharge; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + + +@Mapper +public interface UserRechargeDao extends BaseMapper { + + List integral(@Param("artificerId") String artificerId, + @Param("pages") Page pages, + @Param("type") String type, + @Param("start") String start, + @Param("end") String end); + + IPage integralArtificerId(@Param("pages") Page pages, + @Param("type") String type, + @Param("start") String start, + @Param("end") String end, + @Param("artificerId") String artificerId); + + + String storedValue(@Param("start") String start, + @Param("end") String end, + @Param("type") String type, + @Param("artificerId") String artificerId); + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/entity/Agency.java b/src/main/java/com/sqx/modules/artificer/entity/Agency.java new file mode 100644 index 0000000..e4dd0af --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/entity/Agency.java @@ -0,0 +1,66 @@ +package com.sqx.modules.artificer.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description agency + * @author fang + * @date 2021-12-30 + */ +@Data +public class Agency implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 申请id + */ + private Long id; + + /** + * 城市 + */ + private String city; + + /** + * 姓名 + */ + private String name; + + /** + * 电话 + */ + private String phone; + + /** + * 年龄 + */ + private Integer age; + + /** + * 头像 + */ + private String img; + + /** + * 用户id + */ + private Long userId; + + /** + * 时间 + */ + private String createTime; + + /** + * 状态 0待审核 1同意 2拒绝 + */ + private Integer status; + + public Agency() {} +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/entity/Artificer.java b/src/main/java/com/sqx/modules/artificer/entity/Artificer.java new file mode 100644 index 0000000..7cf05a4 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/entity/Artificer.java @@ -0,0 +1,179 @@ +package com.sqx.modules.artificer.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; +import org.joda.time.DateTime; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @description artificer + * @author fang + * @date 2021-12-18 + */ +@Data +public class Artificer implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 技师id + */ + private Long artificerId; + + /** + * 用户id + */ + private Long userId; + + /** + * 技师名称 + */ + private String artificerName; + + /** + * 技师图片 + */ + private String artificerImg; + + private String city; + + /** + * 经度 + */ + private String longitude; + + /** + * 纬度 + */ + private String latitude; + + /** + * 技师生活照 + */ + private String lifePhoto; + + /** + * 证书 + */ + private String certificate; + + /** + * 描述 + */ + private String content; + + /** + * 从业时长 + */ + private String workingTime; + + /** + * 创建时间 + */ + private String createTime; + private String updateTime; + + /** + * 技师销量 + */ + private Integer artificerSales; + + /** + * 技师上班时间 + */ + private String beginTime; + + /** + * 技师下班时间 + */ + private String finishTime; + + private Integer status; + + /** + * 分类id + */ + private Long classifyId; + + /** + * 出行方式 1公交 2出租 3免费 + */ + private Integer tripWay; + + /** + * 信用分 + */ + private BigDecimal creditScore; + + /** + * 是否是优选 + */ + private Integer isGoods; + + /** + * 是否热度最高 + */ + private Integer isHot; + + private String address; + /** + * 上线时间 + */ + private Date upTime; + + private BigDecimal rate; + + /** + * 1可服务 2可预约 3休息中 + */ + @TableField(exist = false) + private Integer state; + + @TableField(exist = false) + private String classifyName; + + @TableField(exist = false) + private Integer ordersCount; + + @TableField(exist = false) + private Integer ordersScore; + + @TableField(exist = false) + private Integer distance; + + @TableField(exist = false) + private Integer collectCount; + + @TableField(exist = false) + private String phone; + + @TableField(exist = false) + private Integer artificerStatus; + + @TableField(exist = false) + private Integer serviceCount; + + @TableField(exist = false) + private Integer commentCount; + + @TableField(exist = false) + private String time; + + @TableField(exist = false) + private BigDecimal money; + + @TableField(exist = false) + private Long consortiaId; + /** + * 当前等级 + */ + private String grade; + + public Artificer() {} +} diff --git a/src/main/java/com/sqx/modules/artificer/entity/ArtificerMassage.java b/src/main/java/com/sqx/modules/artificer/entity/ArtificerMassage.java new file mode 100644 index 0000000..a5bae25 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/entity/ArtificerMassage.java @@ -0,0 +1,136 @@ +package com.sqx.modules.artificer.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @description artificer_massage + * @author fang + * @date 2021-12-18 + */ +@Data +public class ArtificerMassage implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 技术服务id + */ + private Long artificerMassageId; + + /** + * 技师id + */ + private Long artificerId; + + /** + * 服务id + */ + private Long massageTypeId; + + /** + * 创建时间 + */ + private String createTime; + + + + /** + * 服务是否上架 0上架 1下架 + */ + private Integer status; + + + + /** + * 图片 + */ + @TableField(exist = false) + private String massageImg; + + /** + * 标题 + */ + @TableField(exist = false) + private String title; + + /** + * 内容 + */ + @TableField(exist = false) + private String content; + + /** + * 详细内容 + */ + @TableField(exist = false) + private String contentImg; + + /** + * 原价 + */ + @TableField(exist = false) + private BigDecimal oldPrice; + + /** + * 现价 + */ + @TableField(exist = false) + private BigDecimal price; + + /** + * 会员价 + */ + @TableField(exist = false) + private BigDecimal memberPrice; + + /** + * 技师价 + */ + @TableField(exist = false) + private BigDecimal artificerPrice; + + /** + * 时长 + */ + @TableField(exist = false) + private Double duration; + + /** + * 销量 + */ + @TableField(exist = false) + private Integer sales; + + /** + * 是否限制性别 0不限制 1男 2女 + */ + @TableField(exist = false) + private Integer isSex; + + /** + * 状态 1上 2下 + */ + @TableField(exist = false) + private Integer mStatus; + + /** + * 创建时间 + */ + @TableField(exist = false) + private String mCreateTime; + + /** + * 城市 + */ + @TableField(exist = false) + private String city; + + public ArtificerMassage() {} +} diff --git a/src/main/java/com/sqx/modules/artificer/entity/ArtificerTime.java b/src/main/java/com/sqx/modules/artificer/entity/ArtificerTime.java new file mode 100644 index 0000000..ddf9bab --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/entity/ArtificerTime.java @@ -0,0 +1,59 @@ +package com.sqx.modules.artificer.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * @description artificer_time + * @author fang + * @date 2023-01-05 + */ +@Data +public class ArtificerTime implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 师傅时间配置id + */ + private Long artificerTimeId; + + /** + * 技师id + */ + private Long artificerId; + + /** + * 日期 + */ + private String artificerDate; + + /** + * 时分秒 + */ + private String artificerTime; + + /** + * 1订单占用 2技师设置 + */ + private Integer classify; + + /** + * 订单id + */ + private Long ordersId; + + /** + * 创建时间 + */ + private String createTime; + + public ArtificerTime() {} +} diff --git a/src/main/java/com/sqx/modules/artificer/entity/Certification.java b/src/main/java/com/sqx/modules/artificer/entity/Certification.java new file mode 100644 index 0000000..0ae8d06 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/entity/Certification.java @@ -0,0 +1,98 @@ +package com.sqx.modules.artificer.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +public class Certification implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + + @ApiModelProperty("用户实名认证id") + private Long id; + + + @ApiModelProperty("用户id") + private Long userId; + + + @ApiModelProperty("真实姓名") + private String name; + + + @ApiModelProperty("身份证号码") + private String idNumber; + + + @ApiModelProperty("出生年月日") + private String birthdate; + + + @ApiModelProperty("性别 1男 2女") + private Integer sex; + + + @ApiModelProperty("电话") + private String phone; + + @ApiModelProperty("个人简介") + public String individualResume; + + @ApiModelProperty("正面照") + private String front; + + + @ApiModelProperty("反面照") + private String back; + + + @ApiModelProperty("资格证书") + private String certification; + + + @ApiModelProperty("形象照") + private String imagePhoto; + + + @ApiModelProperty("创建时间") + private String createTime; + + + @ApiModelProperty("0审核中1审核成功2拒绝3申请退还保证金") + private Integer status; + + + @ApiModelProperty("说明") + private String remek; + + + @ApiModelProperty("修改时间") + private String updateTime; + + @ApiModelProperty("地址") + private String address; + + @ApiModelProperty("头像") + private String avatar; + + private Long classifyId; + + @TableField(exist = false) + private String classifyName; + + @TableField(exist = false) + private BigDecimal money; + + @TableField(exist = false) + private Long agencyId; + public Certification() {} +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/entity/CollectArtificer.java b/src/main/java/com/sqx/modules/artificer/entity/CollectArtificer.java new file mode 100644 index 0000000..7be2ff0 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/entity/CollectArtificer.java @@ -0,0 +1,51 @@ +package com.sqx.modules.artificer.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 浏览记录 + * @author 房 2020-05-14 + */ +@Data +@TableName("collect_artificer") +public class CollectArtificer implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 浏览记录id + */ + @TableId(type = IdType.INPUT) + private long collectId; + + /** + * 技师id + */ + + private Long artificerId; + + /** + * 用户id + */ + + private Long userId; + + /** + * 创建时间 + */ + + private String createTime; + + /** + * 1收藏 2浏览记录 + */ + private Integer classify; + + + +} diff --git a/src/main/java/com/sqx/modules/artificer/entity/FundDetailsResult.java b/src/main/java/com/sqx/modules/artificer/entity/FundDetailsResult.java new file mode 100644 index 0000000..691ea5e --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/entity/FundDetailsResult.java @@ -0,0 +1,44 @@ +package com.sqx.modules.artificer.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.sqx.modules.app.entity.UserMoneyDetails; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @description agency + * @author fang + * @date 2021-12-30 + */ +@Data +public class FundDetailsResult implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 收益 + */ + private String income; + /** + * 钱包明细 + */ + private IPage userMoneyDetailsList; + /** + * 查询开始时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date startFundData; + /** + * 查询结束时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date endFundData; +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/entity/MassageType.java b/src/main/java/com/sqx/modules/artificer/entity/MassageType.java new file mode 100644 index 0000000..1f17232 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/entity/MassageType.java @@ -0,0 +1,137 @@ +package com.sqx.modules.artificer.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @description massage_type + * @author fang + * @date 2021-12-18 + */ +@Data +public class MassageType implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 按摩类型id + */ + private Long massageTypeId; + + /** + * 图片 + */ + private String massageImg; + + /** + * 标题 + */ + private String title; + + /** + * 内容 + */ + private String content; + + /** + * 详细内容 + */ + private String contentImg; + + /** + * 原价 + */ + private BigDecimal oldPrice; + + /** + * 现价 + */ + private BigDecimal price; + + /** + * 会员价 + */ + private BigDecimal memberPrice; + + /** + * 技师价 + */ + private BigDecimal artificerPrice; + + /** + * 时长 + */ + private Integer duration; + + /** + * 销量 + */ + private Integer sales; + + /** + * 是否限制性别 0不限制 1男 2女 + */ + private Integer isSex; + + /** + * 状态 1上 2下 + */ + private Integer status; + + /** + * 创建时间 + */ + private String createTime; + + /** + * 城市 + */ + private String city; + + private String labels; + + /** + * 下级id 加钟项目 + */ + private Integer parentId; + + /** + * 分类id + */ + private Long classifyId; + + /** + * 加钟次数 + */ + private Integer addNum; + + /** + * 适用人群 + */ + private String applyPeople; + + private String score; + + private String jianjie; + + @TableField(exist = false) + private String classifyName; + + @TableField(exist = false) + private Long artificerMassageId; + + @TableField(exist = false) + private BigDecimal massageScore; + + @TableField(exist = false) + private Integer artificerMassageStatus; + + + public MassageType() {} +} diff --git a/src/main/java/com/sqx/modules/artificer/entity/Orders.java b/src/main/java/com/sqx/modules/artificer/entity/Orders.java new file mode 100644 index 0000000..f3cc064 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/entity/Orders.java @@ -0,0 +1,363 @@ +package com.sqx.modules.artificer.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +/** + * @description orders + * @author fang + * @date 2021-12-18 + */ +@Data +public class Orders implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 订单id + */ + private Long ordersId; + + /** + * 技师id + */ + private Long artificerId; + + /** + * 用户id + */ + private Long userId; + + /** + * 服务时间 + */ + private String serveTime; + + /** + * 联系电话 + */ + private String phone; + + /** + * 地址 + */ + private String address; + + /** + * 开始服务地址 + */ + private String startAddress; + + /** + * 完成服务地址 + */ + private String accomplishAddress; + + /** + * 备注 + */ + private String remark; + + /** + * 是否是超时订单 1是 2不是 + */ + private Integer overTimeOrders; + + /** + * 支付金额 + */ + private BigDecimal payMoney; + + /** + * 服务费用 + */ + private BigDecimal price; + + /** + * 技师价格 + */ + private BigDecimal artificerMoney; + + + /** + * 订单号 + */ + private String ordersNo; + + /** + * 支付时间 + */ + private String payTime; + + /** + * 支付方式 1app微信 2微信公众号 3微信小程序 4微信公众号 外链支付 6支付宝 5零钱 + */ + private Integer payWay; + + /** + * 状态 1待支付 2待服务 3待评论 4已取消 5已完成 6进行中 7技师出发 8技师到达 + */ + private Integer status; + + /** + * 技师出发时间 + */ + private String artificerStartTime; + + /** + * 技师到达时间 + */ + private String artificerEndTime; + + /** + * 经度 + */ + private String longitude; + + /** + * 纬度 + */ + private String latitude; + + private String startLongitude; + + private String startLatitude; + + /** + * 创建时间 + */ + private String createTime; + + /** + * 加钟次数 + */ + private Integer addNum; + + /** + * 总金额 + */ + private BigDecimal sumMoney; + + /** + * 加钟时长 + */ + private Integer addTime; + + /** + * 加钟价格 + */ + private BigDecimal addMoney; + + /** + * 加钟技师价 + */ + private BigDecimal addArtificerMoney; + + /** + * 技师总收益 + */ + private BigDecimal sumArtificerMoney; + + /** + * 出行费用 + */ + private BigDecimal taxiMoney; + //技师打车费 + private BigDecimal artificerTaxiMoney; + //平台扣除打车费 + private BigDecimal pingTaxiMoney; + + /** + * 出行方式 1公交 2出租 3免费 + */ + private Integer tripWay; + + /** + * 全程公里 + */ + private String km; + + /** + * 上级id 加钟项目 + */ + private Long parentId; + + /** + * 开始服务时间 + */ + private String startTime; + + /** + * 开始服务图片 + */ + private String startImg; + + /** + * 优惠券id + */ + private Long couponId; + + /** + * 优惠券金额 + */ + private BigDecimal couponMoney; + + /** + * 优惠券名称 + */ + private String couponName; + + /** + * 服务完成时间 + */ + private String endTimes; + + /** + * 服务预估完成时间 + */ + private String endTime; + + private Integer isSend; + + /** + * 一级推广用户佣金 + */ + private BigDecimal oneUserMoney; + + private Long oneUserId; + + private String oneUserName; + + /** + * 一级推广技师佣金 + */ + private BigDecimal oneArtificerMoney; + + private Long oneArtificerUserId; + + private String oneArtificerUserName; + + private BigDecimal shopMoney; + + private Long shopUserId; + + private String shopUserName; + + /** + * 平台收益 + */ + private BigDecimal pingMoney; + + /** + * 服务id + */ + private Long massageTypeId; + + private Long consortiaId; + + /** + * 师傅完成经度 + */ + private String accomplishLongitude; + + /** + * 师傅完成纬度 + */ + private String accomplishLatitude; + + /** + * 是否是警告订单 1是 + */ + private Integer warning; + + /** + * 是否是储蓄金支付 1是 + */ + private Integer userArtificerMoney; + /** + * 技师分成比例 + */ + private BigDecimal artificerRate; + /** + * 渠道扣费 + */ + private BigDecimal channelDeduction; + /** + * 储值扣费 + */ + private BigDecimal valueStorageDeduction; + /** + * 项目收益 + */ + private BigDecimal projectBenefits; + /** + * 项目名称 + */ + private String entryName; + @TableField(exist = false) + private List ordersMassageList; + + @TableField(exist = false) + private Artificer artificer; + + @TableField(exist = false) + private String artificerName; + + /** + * 分类id 91 精油 95 中医 + */ + + @TableField(exist = false) + private Long classifyId; + + @TableField(exist = false) + private String artificerPhone; + + @TableField(exist = false) + private String artificerImg; + + private String userName; + + @TableField(exist = false) + private String artificerUserId; + + @TableField(exist = false) + private String title; + + @TableField(exist = false) + private String massageImg; + + @TableField(exist = false) + private MassageType massageType; + + @TableField(exist = false) + private String city; + + @TableField(exist = false) + private String artificerLongitude; + + @TableField(exist = false) + private String artificerLatitude; + + @TableField(exist = false) + private String artificerAddress; + + @TableField(exist = false) + private String shopName; + + @TableField(exist = false) + private String shopAddress; + + @TableField(exist = false) + private String shopPhone; + + + public Orders() {} +} diff --git a/src/main/java/com/sqx/modules/artificer/entity/OrdersMassage.java b/src/main/java/com/sqx/modules/artificer/entity/OrdersMassage.java new file mode 100644 index 0000000..49da892 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/entity/OrdersMassage.java @@ -0,0 +1,45 @@ +package com.sqx.modules.artificer.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description orders_massage + * @author fang + * @date 2021-12-18 + */ +@Data +public class OrdersMassage implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 订单服务id + */ + private Long ordersMassageId; + + /** + * 订单id + */ + private Long ordersId; + + /** + * 服务id + */ + private Long massageId; + + /** + * 数量 + */ + private Integer num; + + @TableField(exist = false) + private MassageType massageType; + + public OrdersMassage() {} +} diff --git a/src/main/java/com/sqx/modules/artificer/entity/Period.java b/src/main/java/com/sqx/modules/artificer/entity/Period.java new file mode 100644 index 0000000..39b5c4a --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/entity/Period.java @@ -0,0 +1,59 @@ +package com.sqx.modules.artificer.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.models.auth.In; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.util.Date; + +/** + * @description agency + * @author fang + * @date 2021-12-30 + */ +@Data +public class Period implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 查询类型 + */ + private Integer fundType; + /** + * 充值类型 + */ + private Integer detailsType; + /** + * 查询时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date fundData; + /** + * 技师id + */ + private String artificerId; + /** + * 订单 + */ + private String orderId; + /** + * 查询开始时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date startFundData; + /** + * 查询结束时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date endFundData; + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/entity/UserMoneyArtificerDetails.java b/src/main/java/com/sqx/modules/artificer/entity/UserMoneyArtificerDetails.java new file mode 100644 index 0000000..55bb3d1 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/entity/UserMoneyArtificerDetails.java @@ -0,0 +1,49 @@ +package com.sqx.modules.artificer.entity; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.sqx.modules.app.entity.UserMoneyDetails; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +@Data +public class UserMoneyArtificerDetails implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 当期收益 + */ + private BigDecimal totalRevenue; + /** + * 项目收益 + */ + private BigDecimal projectBenefits; + /** + * 车费金额 + */ + private BigDecimal vehicleFareAmount; + /** + * 渠道扣款 + */ + private BigDecimal channelDeduction; + /** + * 储值扣款 + */ + private BigDecimal valueStorageDeduction; + /** + * 查询开始时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date startFundData; + /** + * 查询结束时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date endFundData; +} diff --git a/src/main/java/com/sqx/modules/artificer/entity/UserRecharge.java b/src/main/java/com/sqx/modules/artificer/entity/UserRecharge.java new file mode 100644 index 0000000..f19d424 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/entity/UserRecharge.java @@ -0,0 +1,54 @@ +package com.sqx.modules.artificer.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + + +/** + * @description: + * @author:zc. + * @createData:2024-1-17 上午 10:34 + * @projectName:anmo + * @className:userRecharge + * @packageName:com.sqx.modules.artificer.entity + */ +@Data +@TableName("user_recharge") +public class UserRecharge implements Serializable { + private static final long serialVersionUID = 1L; + + + @TableId(type = IdType.AUTO) + private Long id; + + private String type; + /** + * 积分类型(1在线积分2储值积分) + */ + private Integer artificerId; + private Integer userId; + private Integer ordersId; + /** + * 用户充值积分 + */ + private BigDecimal userRecharge; + + @ApiModelProperty("创建时间") + private String createTime; + + @TableField(exist = false) + private String formattedDate; + @TableField(exist = false) + private String ordersNo; + @TableField(exist = false) + private List children; + +} diff --git a/src/main/java/com/sqx/modules/artificer/service/AgencyService.java b/src/main/java/com/sqx/modules/artificer/service/AgencyService.java new file mode 100644 index 0000000..2dc6a9b --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/AgencyService.java @@ -0,0 +1,15 @@ +package com.sqx.modules.artificer.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.entity.Agency; +import com.sqx.modules.artificer.entity.ArtificerMassage; + +public interface AgencyService extends IService { + + Result insertAgency(Agency agency); + + Agency selectAgencyByUserId(Long userId); + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/AppArtificerIntegralService.java b/src/main/java/com/sqx/modules/artificer/service/AppArtificerIntegralService.java new file mode 100644 index 0000000..72956ea --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/AppArtificerIntegralService.java @@ -0,0 +1,19 @@ +package com.sqx.modules.artificer.service; + + +import com.sqx.common.utils.Result; + + + +public interface AppArtificerIntegralService { + + Result home(Long artificerId); + + Result time(); + + Result line(); + + Result upgrade(String date); + + Result upgradeZy(String date); +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/ArtificerMassageService.java b/src/main/java/com/sqx/modules/artificer/service/ArtificerMassageService.java new file mode 100644 index 0000000..267caf8 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/ArtificerMassageService.java @@ -0,0 +1,23 @@ +package com.sqx.modules.artificer.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.ArtificerMassage; + +import java.util.List; + +public interface ArtificerMassageService extends IService { + + Result insertArtificerMassage(String artificerMassages, Long userId); + + Result updateArtificerMassage(ArtificerMassage artificerMassage); + + Result deleteArtificerMassage(Long id); + + Result selectArtificerMassage(Long userId, Integer page, Integer limit, Integer status); + + int updateArtificerMassageStatus(Long massageTypeId); + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/ArtificerService.java b/src/main/java/com/sqx/modules/artificer/service/ArtificerService.java new file mode 100644 index 0000000..161d470 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/ArtificerService.java @@ -0,0 +1,40 @@ +package com.sqx.modules.artificer.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.chat.entity.ChatContent; + +import java.text.ParseException; + + +public interface ArtificerService extends IService { + + Result selectArtificerList(Integer page, Integer limit, Long massageTypeId, String artificerName, + String longitude,String latitude,Integer sort,Integer authentication, + Integer by,Integer status,String city,Long classifyId,String phone,Integer user); + + Artificer selectArtificerById(Long userId,Long artificerId,String longitude,String latitude); + + Artificer selectArtificerByUserId(Long userId); + + int selectArtificerByStatus(Long userId, Integer status); + + Result selectArtificerMoney(Long userId,Long artificerId); + + Result signIn(Long userId, String longitude, String latitude, String city,String address); + + Result selectArtificerMoneyList(Integer page,Integer limit,String startTime,String endTime,String title,String classifyId); + + Result selectUserListByConsortiaId(Integer page,Integer limit,String userName,String phone,Long consortiaId,Long shopId,Integer flag,String time); + + void timing(Long artificerId); + + Result integral(String artificerId,String type,Integer current,Integer size,String date,Integer fundType); + + Result storedValue(String date,String type,String artificerId); + + Result selectArtificerByArtificerId(Long artificerId); +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/ArtificerTimeService.java b/src/main/java/com/sqx/modules/artificer/service/ArtificerTimeService.java new file mode 100644 index 0000000..3b5b1e2 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/ArtificerTimeService.java @@ -0,0 +1,17 @@ +package com.sqx.modules.artificer.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.ArtificerTime; + +public interface ArtificerTimeService extends IService { + + Result updateArtificerTime(String date,String times,Long userId); + + Result selectArtificerTimeByArtificerId(Long artificerId,String artificerDate); + + Result selectArtificerTimeListByArtificerId(Long artificerId,String artificerDate); + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/CollectArtificerService.java b/src/main/java/com/sqx/modules/artificer/service/CollectArtificerService.java new file mode 100644 index 0000000..8cc01f9 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/CollectArtificerService.java @@ -0,0 +1,19 @@ +package com.sqx.modules.artificer.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.entity.ArtificerMassage; +import com.sqx.modules.artificer.entity.CollectArtificer; +import org.apache.ibatis.annotations.Param; + +public interface CollectArtificerService extends IService { + + Result insertCollect(CollectArtificer collectArtificer); + + CollectArtificer selectCollectArtificerByUserId(Long userId,Long artificerId,Integer classify); + + Result selectCollectList(Long userId,Integer page,Integer limit,String longitude,String latitude); + + int selectCountByUserId(Long artificerId, String startTime,String endTime); +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/MassageTypeService.java b/src/main/java/com/sqx/modules/artificer/service/MassageTypeService.java new file mode 100644 index 0000000..7412d32 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/MassageTypeService.java @@ -0,0 +1,19 @@ +package com.sqx.modules.artificer.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.entity.ArtificerMassage; +import com.sqx.modules.artificer.entity.MassageType; + +public interface MassageTypeService extends IService { + + Result selectArtificerMassageList(Long artificerId,Integer status); + + Result selectMassageTypePage(Integer page,Integer limit,Integer status,String city,Integer sort,Integer authentication,Integer by,String title,Long artificerId,Long userId,Integer parentId,Long classifyId); + + Result selectMassageTypeList(Integer status,String city,Integer sort,Integer authentication,Integer by,String title,Long artificerId,Long userId,Integer parentId,Long classifyId); + + + Result selectMassageTypeChildrenPage(Integer page, Integer limit, Integer status, String city, Integer sort, Integer authentication, Integer by, String title, Long artificerId, Long userId, Integer parentId, Long classifyId); +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/OrdersMassageService.java b/src/main/java/com/sqx/modules/artificer/service/OrdersMassageService.java new file mode 100644 index 0000000..e469c51 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/OrdersMassageService.java @@ -0,0 +1,11 @@ +package com.sqx.modules.artificer.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.modules.artificer.entity.ArtificerMassage; +import com.sqx.modules.artificer.entity.OrdersMassage; + +public interface OrdersMassageService extends IService { + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/OrdersService.java b/src/main/java/com/sqx/modules/artificer/service/OrdersService.java new file mode 100644 index 0000000..3d07c41 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/OrdersService.java @@ -0,0 +1,100 @@ +package com.sqx.modules.artificer.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.entity.Period; +import com.sqx.modules.artificer.entity.Orders; +import com.sqx.modules.utils.excel.ExcelData; + +import java.math.BigDecimal; +import java.util.Map; + +public interface OrdersService extends IService { + + Map selectTaxiMoney(Long artificerId, String latitude, String longitude, String city); + + Result insertOrders(Orders orders); + + Result updateOrders(Orders orders); + + Result cancelOrders(Long userId,Long ordersId); + + Result removeOrders(Long ordersId); + + Result refundOrdersMoney(Long ordersId,BigDecimal refundMoney); + + Result selectOrdersDetails(Long ordersId); + + Result selectOrdersList(Long userId,Integer page,Integer limit,Integer status,String city, + String name,String phone,Long artificerId,Long parentId,String startTime, + String endTime,Integer isAdd,String ordersNo,String artificerName, + String oneUserName,String oneArtificerUserName, + String startServeTime,String endServeTime,Integer overTimeOrders,Long shopId, + String shopName,Integer warning,String title,String classifyId); + + ExcelData excelOrdersList(Long userId,Integer status,String city, + String name,String phone,Long artificerId,Long parentId,String startTime, + String endTime,Integer isAdd,String ordersNo,String artificerName, + String oneUserName,String oneArtificerUserName, + String startServeTime,String endServeTime,Integer overTimeOrders,Long shopId, + String shopName,Integer warning,String title,String classifyId); + + Orders selectOrdersByOrderNo(String ordersNo); + + Result payOrders(Long ordersId,Integer type); + + void sendMsg(Orders orders); + + Result payUserVip(Long userId,Long vipDetailsId); + + Result accomplishOrders(Long ordersId,Integer type,String accomplishLongitude,String accomplishLatitude); + + Result startOrders(Long ordersId,String startLongitude,String startLatitude,String startImg); + + Result artificerStartOrEndTime(Long ordersId); + + Result selectArtificerIndex(Long artificerId,String startTime,String endTime); + + Result selectTodayOrder(Long artificerId, Integer page, Integer limit,Integer type,String startTime,String endTime); + + Result selectArtificerOrder(Long userId, Integer status, Integer page, Integer limit); + + Result refundOrders(Long ordersId); + + Result updateArtificerCreditScore(Integer type,BigDecimal creditScore,Long artificerId); + + void endOrders(); + + Result selectTeamOrdersList(Integer page, Integer limit, Long userId, Integer type, Integer status); + + Result selectTeamUserList(Integer page, Integer limit, String invitationCode, Integer type, Long userId); + + Double selectOrdersMoneyCountByUserId(Long userId, Integer type, String time); + + Integer selectUserCountByInvitationCode(String invitationCode, Integer type); + + Integer selectOrdersCountStatisticsByYear(Integer flag,String time,Integer status); + + Result selectArtificerOrdersList(Integer page,Integer limit,String artificerName,String artificerPhone, + String userName,String phone,Integer warning,Integer overTimeOrders); + + Result selectShopMoney(Integer page,Integer limit,String userName,String phone,String flag,String time); + + Result selectOneUserMoney(Integer page,Integer limit,String userName,String phone,String flag,String time); + + Result selectOneArtificerMoney(Integer page,Integer limit,String userName,String phone,String flag,String time); + + Result selectArtificerMoney(Integer page,Integer limit,String userName,String phone,String flag,String time); + + Result selectNewUserOrdersCount(Integer page,Integer limit,String userName,String phone); + + Result selectNewUserOrdersRate(); + + + Result selectDividedIntoDetail(Period period); + + Result selectDividedIntoDetails(Integer page, Integer limit, Period period); + + Result splitDetails(Period period); +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/RealNameService.java b/src/main/java/com/sqx/modules/artificer/service/RealNameService.java new file mode 100644 index 0000000..99e2fd3 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/RealNameService.java @@ -0,0 +1,25 @@ +package com.sqx.modules.artificer.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.entity.Certification; + +public interface RealNameService extends IService { + + Result selectRealName(Long userId); + + Result updateRealName(Certification certification); + + Result selectRealNameList(Integer page, Integer limit, Integer status, String userName, String phone,Long classifyId); + + Result auditRealName(Certification certification); + + Result selectRealNameById(Long userId); + + Result retreatCashDeposit(Long userId); + + Result auditRefund(Long userId, Integer type); + + Result selectRefundCashDepositList(Integer page,Integer limit,String userName,String phone); + +} diff --git a/src/main/java/com/sqx/modules/artificer/service/impl/AgencyServiceImpl.java b/src/main/java/com/sqx/modules/artificer/service/impl/AgencyServiceImpl.java new file mode 100644 index 0000000..a3a22fb --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/impl/AgencyServiceImpl.java @@ -0,0 +1,64 @@ +package com.sqx.modules.artificer.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.dao.AgencyDao; +import com.sqx.modules.artificer.dao.ArtificerMassageDao; +import com.sqx.modules.artificer.entity.Agency; +import com.sqx.modules.artificer.entity.ArtificerMassage; +import com.sqx.modules.artificer.service.AgencyService; +import com.sqx.modules.artificer.service.ArtificerMassageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.concurrent.locks.ReentrantReadWriteLock; + + +@Service +public class AgencyServiceImpl extends ServiceImpl implements AgencyService { + + @Autowired + private UserService userService; + + private ReentrantReadWriteLock reentrantReadWriteLock=new ReentrantReadWriteLock(true); + + @Override + public Result insertAgency(Agency agency){ + reentrantReadWriteLock.writeLock().lock(); + try{ + UserEntity userEntity = userService.selectUserById(agency.getUserId()); + if(userEntity.getIsAuthentication()!=null && userEntity.getIsAuthentication()==2){ + return Result.error("您已经是技师了,请不要重复申请"); + } + Agency agency1 = selectAgencyByUserId(agency.getUserId()); + if(agency1!=null){ + return Result.error("您已经提交过申请了!"); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + agency.setStatus(0); + agency.setCreateTime(sdf.format(new Date())); + baseMapper.insert(agency); + return Result.success(); + }catch (Exception e){ + e.printStackTrace(); + }finally { + reentrantReadWriteLock.writeLock().unlock(); + } + return Result.error("系统繁忙,请稍后再试!"); + } + + @Override + public Agency selectAgencyByUserId(Long userId){ + return baseMapper.selectOne(new QueryWrapper().eq("user_id",userId)); + } + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/impl/AppArtificerIntegralServiceImpl.java b/src/main/java/com/sqx/modules/artificer/service/impl/AppArtificerIntegralServiceImpl.java new file mode 100644 index 0000000..9746846 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/impl/AppArtificerIntegralServiceImpl.java @@ -0,0 +1,536 @@ +package com.sqx.modules.artificer.service.impl; + + +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.NumberUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.sqx.common.utils.Result; + +import com.sqx.modules.app.dao.UserDao; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.artificer.dao.ArtificerDao; +import com.sqx.modules.artificer.dao.OrdersDao; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.Period; +import com.sqx.modules.artificer.service.AppArtificerIntegralService; +import com.sqx.modules.artificer.vo.HomeVO; +import com.sqx.modules.artificer.vo.UserArtificerVO; +import com.sqx.modules.common.dao.ArtificerPartitioningDetailsMapper; +import com.sqx.modules.common.dao.CommonInfoDao; +import com.sqx.modules.common.entity.ArtificerPartitioningDetails; +import com.sqx.modules.common.entity.CommonInfo; +import lombok.AllArgsConstructor; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; + + +import static com.sqx.common.utils.Result.success; +import static com.sqx.modules.utils.PeriodUtil.obtainCycle; +import static com.sqx.modules.utils.PeriodUtil.previousIssue; +import static java.math.BigDecimal.ROUND_CEILING; + + +@Service +@AllArgsConstructor +public class AppArtificerIntegralServiceImpl implements AppArtificerIntegralService { + + private final OrdersDao ordersDao; + private final ArtificerPartitioningDetailsMapper artificerPartitioningDetailsMapper; + private final CommonInfoDao commonInfoDao; + private final ArtificerDao artificerDao; + private final UserDao userDao; + + + @Override + public Result home(Long artificerId) { + Artificer artificer = artificerDao.selectById(artificerId); + //91精油 95 中医 + String classifyId = artificer.getClassifyId().toString(); + + HomeVO orders = new HomeVO(); + String startDate = DateUtil.formatDateTime(obtainCycle(new Date()).getStartFundData()); + String endDate = DateUtil.formatDateTime(obtainCycle(new Date()).getEndFundData()); + + String grade = artificer.getGrade(); + if (StringUtils.isEmpty(grade)) { + grade = "新"; + } + orders.setGrade(grade); + + //当期业绩 + Integer currentPerformance = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, endDate, startDate); + orders.setCurrentPerformance(String.valueOf(currentPerformance)); + + //当期收益 + String earnings = ordersDao.earnings(artificerId, endDate, startDate); + orders.setEarnings(earnings); + + //当日收益 + String todayEndIncome = DateUtil.formatDateTime(DateUtil.endOfDay(new Date())); + String dailyEarnings = ordersDao.earnings(artificerId, todayEndIncome, String.valueOf(DateUtil.beginOfDay(new Date()))); + orders.setDailyEarnings(dailyEarnings); + + //当月收益 + //当月结束日 + String startFundDataformat = DateUtil.formatDateTime(DateUtil.beginOfMonth(new Date())); + String endFundDataformat = DateUtil.formatDateTime(DateUtil.endOfMonth(new Date())); + String currentMonthsIncome = ordersDao.earnings(artificerId, endFundDataformat, startFundDataformat); + orders.setCurrentMonthsIncome(currentMonthsIncome); + + //当期结束日 + Period period = obtainCycle(new Date()); + orders.setCurrentEndDate(DateUtil.formatDateTime(period.getEndFundData())); + + //当前周期储值积分数 + String storedValueIntegral = ordersDao.selectOrdersStoredValueIntegral(artificerId, endDate, startDate); + //当前周在线积分数 + String onlineCredits = ordersDao.selectOnlineCredits(artificerId, endDate, startDate); + BigDecimal a = new BigDecimal(storedValueIntegral); + BigDecimal b = new BigDecimal(onlineCredits); + //储存积分数 加上在线积分数 等于当期积分 + BigDecimal add = a.add(b); + orders.setIntegral(add); + + //当期订单数:计算订单发生了按摩行为的订单数,订单状态经历了开始服务到订单结束。 + String currentPeriodOrdersSum = ordersDao.selectOrdersArtificerIntegral(artificerId, endDate, startDate); + orders.setCurrentPeriodOrdersSum(currentPeriodOrdersSum); + + //当期加钟率:本周期内,加钟数/本单数 + String v = ordersDao.selectOrdersArtificerIntegraladdNum(artificerId, endDate, startDate); + //加钟数 + BigDecimal currentPeriodAddBellsSumBig = new BigDecimal(v); + //订单数 + BigDecimal currentPeriodOrdersSumBig = new BigDecimal(currentPeriodOrdersSum); + BigDecimal clockRate = null; + //充值率 + BigDecimal divide1 = null; + if (currentPeriodOrdersSumBig.compareTo(new BigDecimal("0")) != 0) { + clockRate = currentPeriodAddBellsSumBig.divide(currentPeriodOrdersSumBig, 2, RoundingMode.HALF_UP); + orders.setCurrentPeriodAddBellsSum(clockRate.toString()); + + //当前周期充值率(本周期内充值订单数/本单数) + String currentPeriodRechargeSum = ordersDao.selectOrdersCurrentPeriodRechargeSum(artificerId, endDate, startDate); + BigDecimal c = new BigDecimal(currentPeriodRechargeSum); + divide1 = c.divide(currentPeriodOrdersSumBig, 2, RoundingMode.HALF_UP); + orders.setCurrentPeriodRechargeSum(divide1.toString()); + } else { + clockRate = new BigDecimal("0"); + orders.setCurrentPeriodAddBellsSum(String.valueOf(clockRate)); + orders.setCurrentPeriodRechargeSum(String.valueOf(clockRate)); + } + if (currentPeriodOrdersSumBig.compareTo(new BigDecimal("0")) == 0) { + divide1 = new BigDecimal("0"); + } + + //业绩后面的显示 + List lists = artificerPartitioningDetailsMapper.selectList(Wrappers.lambdaQuery() + .eq(ArtificerPartitioningDetails::getClassifyId, classifyId)); + for (int i = 0; i < lists.size(); i++) { + if (currentPerformance >= lists.get(i).getOutstandingAchievement().intValue()) { + if (i + 1 < lists.size()) { + BigDecimal bigDecimal = lists.get(i + 1).getOutstandingAchievement(); + if (Objects.nonNull(bigDecimal)) { + orders.setSuffix(NumberUtil.toStr(bigDecimal)); + } + } + } else if (currentPerformance <= lists.get(i).getOutstandingAchievement().intValue()) { + orders.setSuffix(NumberUtil.toStr(artificerPartitioningDetailsMapper.selectById(5).getOutstandingAchievement())); + } + } + return getResult(currentPerformance, clockRate, divide1, b, add, orders, artificer, classifyId); + } + + private Result getResult(Integer currentPerformance, BigDecimal clockRate, BigDecimal divide1, BigDecimal b, BigDecimal add, HomeVO orders, Artificer artificer, String classifyId) { + List artificerPartitioningDetails = artificerPartitioningDetailsMapper.selectList(Wrappers.lambdaQuery() + .eq(ArtificerPartitioningDetails::getClassifyId, classifyId) + .ne(ArtificerPartitioningDetails::getGrade, "A0")); + + for (int i = 0; i < artificerPartitioningDetails.size(); i++) { + ArtificerPartitioningDetails item = artificerPartitioningDetails.get(i); + //技师业绩 + BigDecimal outstandingAchievement = item.getOutstandingAchievement(); + //加钟率 + BigDecimal clockRate1 = item.getClockRate(); + //充值率 + BigDecimal depositRate = item.getDepositRate(); + //在线时长 + Integer durationOnline = item.getDurationOnline(); + //积分 + String integral = item.getIntegral(); + + //多少分钟等1积分 + CommonInfo commonInfo = commonInfoDao.findOne(100000); + String value = commonInfo.getValue(); + + if (i + 1 < artificerPartitioningDetails.size()) { + + ArtificerPartitioningDetails items = artificerPartitioningDetails.get(i + 1); + + if (currentPerformance >= outstandingAchievement.intValue() + && clockRate.compareTo(clockRate1) > -1 + && divide1.compareTo(depositRate) > -1 + && b.intValue() >= durationOnline + && add.intValue() >= Integer.valueOf(integral) + && Objects.nonNull(items) + ) { + BigDecimal p1 = new BigDecimal(currentPerformance); + + //还差多少业绩加钟率积分提升等级 + BigDecimal siq = new BigDecimal(items.getOutstandingAchievement().toString()); + BigDecimal jf = new BigDecimal(items.getIntegral()); + BigDecimal jzl = new BigDecimal(items.getClockRate().toString()); + BigDecimal czl = new BigDecimal(items.getDepositRate().toString()); + + //差的业绩 + BigDecimal subtract = siq.subtract(p1); + if (p1.intValue() >= siq.intValue()) { + subtract = new BigDecimal("0"); + } + //差的加钟率 + BigDecimal clockRateJzl1 = jzl.subtract(clockRate); + if (clockRate.compareTo(jzl) > -1) { + clockRateJzl1 = new BigDecimal("0"); + } + //差的充值率 + BigDecimal divide11 = czl.subtract(divide1); + if (clockRate.compareTo(jzl) > -1) { + divide11 = new BigDecimal("0"); + } + //差的在线时长 + BigDecimal shi = new BigDecimal(value); + BigDecimal multiply1 = b.multiply(shi); + BigDecimal divide = multiply1.divide(new BigDecimal("60"), ROUND_CEILING); + BigDecimal bs = new BigDecimal(items.getDurationOnline().toString()); + BigDecimal subtract2 = bs.subtract(divide); + + if (divide.compareTo(bs) > -1) { + subtract2 = new BigDecimal("0"); + } + + //差的积分 + BigDecimal subtract1 = jf.subtract(add); + if (add.intValue() >= jf.intValue()) { + subtract1 = new BigDecimal("0"); + } + + //差的业绩 + orders.setDifferenceOutstandingAchievement(subtract.stripTrailingZeros().toPlainString()); + //差的积分 + orders.setDifferenceIntegral(NumberUtil.toStr(subtract1)); + //差的加钟率 + orders.setDifferenceClockRate(String.valueOf(clockRateJzl1)); + //差的充值率 + orders.setDepositRate(String.valueOf(divide11)); + //差的在线时长 + orders.setDifferenceDurationOnline(String.valueOf(subtract2)); + //差的等级 + orders.setDifferenceGrade(items.getGrade()); + String ultimately = "上周期等级:" + artificer.getGrade() + ";" + "本周期等级:" + item.getGrade() + ";" + "还差" + subtract.stripTrailingZeros().toPlainString() + "业绩;" + subtract1 + "积分;" + clockRateJzl1 + "加钟率;" + divide11 + "充值率;" + subtract2 + "在线时长;" + "可以升级" + items.getGrade(); + orders.setUltimately(ultimately); + if (subtract.stripTrailingZeros().toPlainString().equals("0") + && subtract1.stripTrailingZeros().toPlainString().equals("0") + && clockRateJzl1.stripTrailingZeros().toPlainString().equals("0") + && divide11.stripTrailingZeros().toPlainString().equals("0") + && subtract2.stripTrailingZeros().toPlainString().equals("0") + && items.getGrade().equals("A5") + ) { + orders.setMaxStatus(true); + } else { + orders.setMaxStatus(false); + } + + } + } + } + return Result.success().put("data", orders); + } + + @Override + public Result upgrade(String dateTime) { + Date newDate = null; + if (StringUtils.isNotEmpty(dateTime) && !dateTime.equals("null")) { + newDate = DateUtil.parse(dateTime); + } else { + newDate = new Date(); + } + List artificers = artificerDao.selectList(Wrappers.lambdaQuery() + .eq(Artificer::getStatus, 1) + .eq(Artificer::getClassifyId, 91)); + for (Artificer list : artificers) { + Long artificerId = list.getArtificerId(); + String createTime = list.getCreateTime(); + //每十天定时扫描一次 + //查询当前周期的 上周期 在线时长是否达到10小时 并且至少有一个订单 + Period period1 = previousIssue(newDate); + Date startFundData = period1.getStartFundData(); + Date endFundData = period1.getEndFundData(); + String date = DateUtil.formatDateTime(endFundData); + //startFundData转换String + String cycleTime = DateUtil.formatDateTime(startFundData); + + //当前一周期业绩 + Integer currentPerformance = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, date, cycleTime); + + //当前一周期储值积分数 + String storedValueIntegral = ordersDao.selectOrdersStoredValueIntegral(artificerId, date, cycleTime); + //当前一周在线积分数 + String onlineCredits = ordersDao.selectOnlineCredits(artificerId, date, cycleTime); + BigDecimal a = new BigDecimal(storedValueIntegral); + BigDecimal b = new BigDecimal(onlineCredits); + //储存积分数 加上在线积分数等于当期积分 + BigDecimal add = a.add(b); + + //当期订单数:计算订单发生了按摩行为的订单数,订单状态经历了开始服务到订单结束。 + String currentPeriodOrdersSum = ordersDao.selectOrdersArtificerIntegral(artificerId, date, cycleTime); + + //当期加钟率:本周期内,加钟数/本单数 + String v = ordersDao.selectOrdersArtificerIntegraladdNum(artificerId, date, cycleTime); + //加钟数 + BigDecimal currentPeriodAddBellsSumBig = new BigDecimal(v); + //订单数 + BigDecimal currentPeriodOrdersSumBig = new BigDecimal(currentPeriodOrdersSum); + //加钟率 + BigDecimal clockRate = null; + //充值率 + BigDecimal divide1 = null; + if (currentPeriodOrdersSumBig.compareTo(new BigDecimal("0")) != 0) { + clockRate = currentPeriodAddBellsSumBig.divide(currentPeriodOrdersSumBig, 2, RoundingMode.HALF_UP); + //当前周期充值率(本周期内充值订单数/本单数) + String currentPeriodRechargeSum = ordersDao.selectOrdersCurrentPeriodRechargeSum(artificerId, date, cycleTime); + BigDecimal c = new BigDecimal(currentPeriodRechargeSum); + divide1 = c.divide(currentPeriodOrdersSumBig, 2, RoundingMode.HALF_UP); + } else { + clockRate = new BigDecimal("0"); + divide1 = new BigDecimal("0"); + } + + Date date1 = DateUtil.parse(createTime); + long betweenDay = DateUtil.between(date1, new Date(), DateUnit.DAY); + + List artificerPartitioningDetails = artificerPartitioningDetailsMapper.selectList(Wrappers.lambdaQuery() + .eq(ArtificerPartitioningDetails::getClassifyId, 91)); + //判断betweenDay大于10天 说明过了 新人扶持阶段 设置等级为A0 + if (betweenDay > 10) { + artificerPartitioningDetails.remove(0); + extractedRate(artificerId, artificerPartitioningDetailsMapper.selectById(3).getProportionalSharing(), artificerPartitioningDetailsMapper.selectById(3).getGrade()); + } + + for (ArtificerPartitioningDetails item : artificerPartitioningDetails) { + //技师等级 + String grade = item.getGrade(); + //技师业绩 + BigDecimal outstandingAchievement = item.getOutstandingAchievement(); + //加钟率 + BigDecimal clockRate1 = item.getClockRate(); + //充值率 + BigDecimal depositRate = item.getDepositRate(); + //在线时长 + Integer durationOnline = item.getDurationOnline(); + //积分 + String integral = item.getIntegral(); + //分成比例 + String proportionalSharing = item.getProportionalSharing(); + if ( + //1.业绩要求 + currentPerformance >= outstandingAchievement.intValue() + //2.加钟率要求 + && clockRate.compareTo(clockRate1) > -1 + //充值率要求 + && divide1.compareTo(depositRate) > -1 + //3.在线时长要求 + && b.intValue() >= durationOnline + //4.积分要求 + && add.intValue() >= Integer.valueOf(integral) + ) { + //更新技师表分成比例和等级 + extractedRate(artificerId, proportionalSharing, grade); + } + } + } + + + return success(); + } + + @Override + public Result upgradeZy(String dateTime) { + Date newDate = null; + if (StringUtils.isNotEmpty(dateTime) && !dateTime.equals("null")) { + newDate = DateUtil.parse(dateTime); + } else { + newDate = new Date(); + } + + List artificers = artificerDao.selectList(Wrappers.lambdaQuery() + .eq(Artificer::getStatus, 1) + .eq(Artificer::getClassifyId, 95)); + + for (Artificer list : artificers) { + Long artificerId = list.getArtificerId(); + String createTime = list.getCreateTime(); + //每十天定时扫描一次 + //查询当前周期的 上周期 在线时长是否达到10小时 并且至少有一个订单 + Period period1 = previousIssue(newDate); + Date startFundData = period1.getStartFundData(); + Date endFundData = period1.getEndFundData(); + String date = DateUtil.formatDateTime(endFundData); + //startFundData转换String + String cycleTime = DateUtil.formatDateTime(startFundData); + + //当前一周期业绩 + Integer currentPerformance = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, date, cycleTime); + + //当前一周期储值积分数 + String storedValueIntegral = ordersDao.selectOrdersStoredValueIntegral(artificerId, date, cycleTime); + //当前一周在线积分数 + String onlineCredits = ordersDao.selectOnlineCredits(artificerId, date, cycleTime); + BigDecimal a = new BigDecimal(storedValueIntegral); + BigDecimal b = new BigDecimal(onlineCredits); + //储存积分数 加上在线积分数等于当期积分 + BigDecimal add = a.add(b); + + //当期订单数:计算订单发生了按摩行为的订单数,订单状态经历了开始服务到订单结束。 + String currentPeriodOrdersSum = ordersDao.selectOrdersArtificerIntegral(artificerId, date, cycleTime); + + //当期加钟率:本周期内,加钟数/本单数 + String v = ordersDao.selectOrdersArtificerIntegraladdNum(artificerId, date, cycleTime); + //加钟数 + BigDecimal currentPeriodAddBellsSumBig = new BigDecimal(v); + //订单数 + BigDecimal currentPeriodOrdersSumBig = new BigDecimal(currentPeriodOrdersSum); + //加钟率 + BigDecimal clockRate = null; + //充值率 + BigDecimal divide1 = null; + if (currentPeriodOrdersSumBig.compareTo(new BigDecimal("0")) != 0) { + clockRate = currentPeriodAddBellsSumBig.divide(currentPeriodOrdersSumBig, 2, RoundingMode.HALF_UP); + //当前周期充值率(本周期内充值订单数/本单数) + String currentPeriodRechargeSum = ordersDao.selectOrdersCurrentPeriodRechargeSum(artificerId, date, cycleTime); + BigDecimal c = new BigDecimal(currentPeriodRechargeSum); + divide1 = c.divide(currentPeriodOrdersSumBig, 2, RoundingMode.HALF_UP); + } else { + clockRate = new BigDecimal("0"); + divide1 = new BigDecimal("0"); + } + + Date date1 = DateUtil.parse(createTime); + long betweenDay = DateUtil.between(date1, new Date(), DateUnit.DAY); + + + List artificerPartitioningDetails = artificerPartitioningDetailsMapper.selectList(Wrappers.lambdaQuery() + .eq(ArtificerPartitioningDetails::getClassifyId, 95)); + + //判断betweenDay大于10天 说明过了 新人扶持阶段 设置等级为A0 + if (betweenDay > 10) { + artificerPartitioningDetails.remove(0); + extractedRate(artificerId, artificerPartitioningDetailsMapper.selectById(29).getProportionalSharing(), artificerPartitioningDetailsMapper.selectById(29).getGrade()); + } + + for (ArtificerPartitioningDetails item : artificerPartitioningDetails) { + //技师等级 + String grade = item.getGrade(); + //技师业绩 + BigDecimal outstandingAchievement = item.getOutstandingAchievement(); + //加钟率 + BigDecimal clockRate1 = item.getClockRate(); + //充值率 + BigDecimal depositRate = item.getDepositRate(); + //在线时长 + Integer durationOnline = item.getDurationOnline(); + //积分 + String integral = item.getIntegral(); + //分成比例 + String proportionalSharing = item.getProportionalSharing(); + if ( + //1.业绩要求 + currentPerformance >= outstandingAchievement.intValue() + //2.加钟率要求 + && clockRate.compareTo(clockRate1) > -1 + //充值率要求 + && divide1.compareTo(depositRate) > -1 + //3.在线时长要求 + && b.intValue() >= durationOnline + //4.积分要求 + && add.intValue() >= Integer.valueOf(integral)) { + //更新技师表分成比例和等级&订单表技师等级 + extractedRate(artificerId, proportionalSharing, grade); + } + } + } + + + return success(); + } + + /** + * 更新技师表分成比例 + * + * @param artificerId 技师id + * @param proportionalSharing 分成明细 + * @param grade 技师等级 + */ + private void extractedRate(Long artificerId, String proportionalSharing, String grade) { + Artificer artificer = new Artificer(); + artificer.setRate(new BigDecimal(proportionalSharing)); + artificer.setArtificerId(artificerId); + artificer.setGrade(grade); + artificerDao.updateById(artificer); + } + + @Override + public Result time() { + return Result.success().put("data", commonInfoDao.findOne(100000).getValue()); + } + + @Override + public Result line() { + //每十天定时扫描一次 + //查询当前周期的 上周期 在线时长是否达到10小时 并且至少有一个订单 + Period period1 = obtainCycle(new Date()); + Date startFundData = period1.getStartFundData(); + Date endFundData = period1.getEndFundData(); + String startFundDataformat = DateUtil.formatDateTime(startFundData); + String endFundDataformat = DateUtil.formatDateTime(endFundData); + + //多少分钟等1积分 + CommonInfo commonInfo = commonInfoDao.findOne(100000); + Integer value = Integer.valueOf(commonInfo.getValue()); + + List artificerInfo = userDao.getArtificerInfo(); + for (UserArtificerVO userArtificerVO : artificerInfo) { + Long artificerId = userArtificerVO.getArtificerId(); + //上周在线积分数 + + String onlineCredits = ordersDao.selectOnlineCredits(artificerId, endFundDataformat, startFundDataformat); + String s = NumberUtil.toStr(new BigDecimal(onlineCredits)); + + //积分*多少分钟等1积分*60 =多少小时 + int i = Integer.valueOf(s) * value / 60; + //订单数 + String currentPeriodOrdersSum = ordersDao.selectOrdersArtificerIntegral(artificerId, endFundDataformat, startFundDataformat); + + Integer i1 = Integer.valueOf(currentPeriodOrdersSum); + //更新停牌 + if (i < 10 && i1 < 1) { + UserEntity userEntity = new UserEntity(); + userEntity.setStatus(3); + userEntity.setUserId(userArtificerVO.getUserId()); + int ii = userDao.updateById(userEntity); + if (ii > 0) { + Artificer artificer = new Artificer(); + artificer.setGrade("A0"); + artificer.setArtificerId(artificerId); + artificerDao.updateById(artificer); + } + } + } + + + return Result.success(); + } +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/impl/ArtificerMassageServiceImpl.java b/src/main/java/com/sqx/modules/artificer/service/impl/ArtificerMassageServiceImpl.java new file mode 100644 index 0000000..fdb20ae --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/impl/ArtificerMassageServiceImpl.java @@ -0,0 +1,100 @@ +package com.sqx.modules.artificer.service.impl; + +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.dao.ArtificerDao; +import com.sqx.modules.artificer.dao.ArtificerMassageDao; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.ArtificerMassage; +import com.sqx.modules.artificer.entity.MassageType; +import com.sqx.modules.artificer.service.ArtificerMassageService; +import com.sqx.modules.artificer.service.ArtificerService; +import com.sqx.modules.artificer.service.MassageTypeService; +import com.sqx.modules.material.dao.MaterialArtificerMapper; +import com.sqx.modules.material.dao.MaterialMassageMapper; +import com.sqx.modules.material.entity.MaterialArtificer; +import com.sqx.modules.material.entity.MaterialMassage; +import com.sqx.modules.material.service.MaterialArtificerService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + + +@Service +public class ArtificerMassageServiceImpl extends ServiceImpl implements ArtificerMassageService { + + @Autowired + private ArtificerMassageDao artificerMassageDao; + @Autowired + private ArtificerService artificerService; + @Autowired + private MassageTypeService massageTypeService; + @Autowired + private MaterialArtificerService materialArtificerService; + @Autowired + private MaterialMassageMapper materialMassageMapper; + @Override + public Result insertArtificerMassage(String artificerMassages, Long userId) { + String[] artificerMassageList = artificerMassages.split(","); + Artificer artificer = artificerService.selectArtificerByUserId(userId); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String format = sdf.format(new Date()); + for(int i = 0;i().eq("massage_type_id", Long.parseLong(artificerMassageList[i])).eq("artificer_id", artificer.getArtificerId())); + List materialMassages = materialMassageMapper.selectList(new QueryWrapper().eq("massage_type_id", Long.parseLong(artificerMassageList[i]))); + for(MaterialMassage materialMassage : materialMassages){ + MaterialArtificer materialArtificer = new MaterialArtificer(); + materialArtificer.setCreateUser(Long.valueOf("1")); + materialArtificer.setCreateTime(DateUtil.date()); + materialArtificer.setMaterialId(materialMassage.getMaterialId()); + materialArtificer.setArtificerId(Math.toIntExact(artificer.getArtificerId())); + materialArtificerService.insertMaterialArtificer(materialArtificer); + } + if(integer>0){ + MassageType massageType = massageTypeService.getById(Long.parseLong(artificerMassageList[i])); + return Result.error(massageType.getTitle()+",已经添加过了!"); + } + } + for(int i = 0;i pages=new Page<>(page,limit); + PageUtils pageUtils = new PageUtils(artificerMassageDao.selectArtificerMassage(pages, userId, status)); + return Result.success().put("data", pageUtils); + } + + @Override + public int updateArtificerMassageStatus(Long massageTypeId){ + return baseMapper.updateArtificerMassageStatus(massageTypeId); + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/impl/ArtificerServiceImpl.java b/src/main/java/com/sqx/modules/artificer/service/impl/ArtificerServiceImpl.java new file mode 100644 index 0000000..625be21 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/impl/ArtificerServiceImpl.java @@ -0,0 +1,425 @@ +package com.sqx.modules.artificer.service.impl; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.NumberUtil; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.sqx.common.utils.*; +import com.sqx.map.CommonMapUtils; +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.service.UserMoneyService; +import com.sqx.modules.artificer.dao.*; +import com.sqx.modules.artificer.entity.*; +import com.sqx.modules.artificer.service.ArtificerService; +import com.sqx.modules.artificer.service.ArtificerTimeService; +import com.sqx.modules.artificer.service.CollectArtificerService; +import com.sqx.modules.common.dao.CommonInfoDao; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.service.MessageService; +import com.sqx.modules.pay.dao.CashOutDao; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +import static com.sqx.modules.utils.PeriodUtil.*; + + +@Service +public class ArtificerServiceImpl extends ServiceImpl implements ArtificerService { + + @Autowired + private ArtificerDao artificerDao; + + @Autowired + private CollectArtificerService collectArtificerService; + @Autowired + private OrdersDao ordersDao; + @Autowired + private CashOutDao cashOutDao; + @Autowired + private UserMoneyService userMoneyService; + @Autowired + private MessageService messageService; + @Autowired + private ArtificerTimeService artificerTimeService; + @Autowired + private CommonInfoService commonInfoService; + @Autowired + private UserRechargeDao userRechargeDao; + @Autowired + private CommonInfoDao commonInfoDao; + + + + @Override + public Result selectArtificerList(Integer page, Integer limit, Long massageTypeId,String artificerName, + String longitude,String latitude,Integer sort,Integer authentication, + Integer by,Integer status,String city,Long classifyId,String phone,Integer user){ + Page pages=new Page<>(page,limit); + IPage artificerIPage = baseMapper.selectArtificerList(pages, massageTypeId, artificerName, + longitude, latitude, sort, authentication, by, status, city, classifyId,phone,user); + List records = artificerIPage.getRecords(); + String value = commonInfoService.findOne(392).getValue(); + if("30".equals(value)){ + SimpleDateFormat sdfHour=new SimpleDateFormat("HH"); + SimpleDateFormat sdfMinute=new SimpleDateFormat("mm"); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat md = new SimpleDateFormat("MM-dd"); + Date dateTime = new Date(); + Calendar calendar=Calendar.getInstance(); + String hour = sdfHour.format(dateTime); + String minute = sdfMinute.format(dateTime); + int minuteInt = Integer.parseInt(minute); + int hourInt = Integer.parseInt(hour); + StringBuilder stringBuilders=new StringBuilder(); + if(minuteInt>=30){ + if(hourInt==23){ + hourInt=0; + minuteInt=30; + }else{ + minuteInt=30; + hourInt=hourInt+1; + } + }else{ + hourInt=hourInt+1; + minuteInt=0; + } + + if(hourInt<10){ + stringBuilders.append("0").append(hourInt); + }else{ + stringBuilders.append(hourInt); + } + stringBuilders.append(":"); + if(minuteInt<10){ + stringBuilders.append("0").append(minuteInt); + }else{ + stringBuilders.append(minuteInt); + } + + for(Artificer artificer:records){ + calendar=Calendar.getInstance(); + String date = simpleDateFormat.format(dateTime); + String oldDate = simpleDateFormat.format(dateTime); + hour = sdfHour.format(dateTime); + minute = sdfMinute.format(dateTime); + minuteInt = Integer.parseInt(minute); + hourInt = Integer.parseInt(hour); + if(minuteInt>=30){ + if(hourInt==23){ + hourInt=0; + minuteInt=30; + calendar.add(Calendar.DAY_OF_MONTH,1); + date = simpleDateFormat.format(calendar.getTime()); + }else{ + minuteInt=30; + hourInt=hourInt+1; + } + }else{ + hourInt=hourInt+1; + minuteInt=0; + } + while (true){ + StringBuilder stringBuilder=new StringBuilder(); + if(hourInt<10){ + stringBuilder.append("0").append(hourInt); + }else{ + stringBuilder.append(hourInt); + } + stringBuilder.append(":"); + if(minuteInt<10){ + stringBuilder.append("0").append(minuteInt); + }else{ + stringBuilder.append(minuteInt); + } + ArtificerTime artificerTime = artificerTimeService.getOne(new QueryWrapper().eq("artificer_id", artificer.getArtificerId()).eq("artificer_date", date).eq("artificer_time", stringBuilder.toString())); + if(artificerTime==null){ + if(oldDate.equals(date)){ + artificer.setTime(stringBuilder.toString()); + }else{ + artificer.setTime(md.format(calendar.getTime())+" "+stringBuilder.toString()); + } + if(artificer.getStatus()!=null && artificer.getStatus()==2){ + artificer.setState(3); + }else{ + if(stringBuilder.toString().equals(stringBuilders.toString())){ + artificer.setState(1); + }else{ + artificer.setState(2); + } + } + + break; + } + if(minuteInt==30){ + if(hourInt==23){ + hourInt=0; + minuteInt=0; + calendar.add(Calendar.DAY_OF_MONTH,1); + date = simpleDateFormat.format(calendar.getTime()); + }else{ + minuteInt=0; + hourInt=hourInt+1; + } + }else{ + minuteInt=30; + } + } + //2.服务开始前及结束后预留出行时间 + //精油往后延30 分钟,中医往后延60 分钟 + if(artificer.getClassifyId()==95){ + String time = artificer.getTime(); + //在精油的基础上加30 分钟就是中医~~ + DateTime dateTime1 = DateUtil.offsetMinute(DateUtil.parse(time), 30); + artificer.setTime(DateUtil.format(dateTime1,"HH:mm")); + } + } + }else{ + + SimpleDateFormat sdf=new SimpleDateFormat("HH"); + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat md = new SimpleDateFormat("MM-dd"); + Date dateTime = new Date(); + String date = simpleDateFormat.format(dateTime); + String oldDate = simpleDateFormat.format(dateTime); + String time = sdf.format(dateTime); + String times=""; + if("23".equals(time)){ + time="00"; + times=time+":30"; + }else{ + time=String.valueOf(Integer.parseInt(time)+1); + times=time+":30"; + } + String nowTimes=times; + + for(Artificer artificer:records){ + Calendar calendar=Calendar.getInstance(); + date = simpleDateFormat.format(dateTime); + oldDate = simpleDateFormat.format(dateTime); + time = sdf.format(dateTime); + times=""; + if("23".equals(time)){ + time="00"; + times=time+":30"; + calendar.add(Calendar.DAY_OF_MONTH,1); + date = simpleDateFormat.format(calendar.getTime()); + }else{ + time=String.valueOf(Integer.parseInt(time)+1); + times=time+":30"; + } + while (true){ + ArtificerTime artificerTime = artificerTimeService.getOne(new QueryWrapper().eq("artificer_id", artificer.getArtificerId()).eq("artificer_date", date).eq("artificer_time", times)); + if(artificerTime==null){ + if(oldDate.equals(date)){ + times=time+":00"; + artificer.setTime(times); + }else{ + times=time+":00"; + artificer.setTime(md.format(calendar.getTime())+" "+times); + } + if(artificer.getStatus()!=null && artificer.getStatus()==2){ + artificer.setState(3); + }else{ + if(times.equals(nowTimes)){ + artificer.setState(1); + }else{ + artificer.setState(2); + } + } + break; + } + if("23".equals(time)){ + time="00"; + times=time+":30"; + calendar.add(Calendar.DAY_OF_MONTH,1); + date = simpleDateFormat.format(calendar.getTime()); + }else{ + time=String.valueOf(Integer.parseInt(time)+1); + times=time+":30"; + } + } + } + } + + + return Result.success().put("data",new PageUtils(artificerIPage)); + } + + @Override + public Artificer selectArtificerById(Long userId,Long artificerId,String longitude,String latitude){ + if(userId!=null){ + CollectArtificer collectArtificer=new CollectArtificer(); + collectArtificer.setClassify(2); + collectArtificer.setUserId(userId); + collectArtificer.setArtificerId(artificerId); + collectArtificerService.insertCollect(collectArtificer); + } + return baseMapper.selectArtificerById(userId,artificerId,longitude,latitude); + } + + @Override + public Artificer selectArtificerByUserId(Long userId){ + return baseMapper.selectArtificerByUserId(userId); + } + + @Override + public int selectArtificerByStatus(Long userId, Integer status) { + + return artificerDao.selectArtificerByStatus(userId, status); + } + + + @Override + public Result selectArtificerMoney(Long userId,Long artificerId){ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String dayTime = sdf.format(new Date()); + //累计收益 今日收益 本月预估收益 本月预估提现 + BigDecimal sumMoney = ordersDao.selectSumMoney(artificerId, null, null); + BigDecimal dayMoney = ordersDao.selectEstimationSumMoneyBy(artificerId, dayTime, 1); + BigDecimal monthMoney = ordersDao.selectEstimationSumMoneyBy(artificerId, dayTime, 2); + BigDecimal cashMoney = cashOutDao.sumMoneyByUserId(userId, dayTime, 2); + UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(userId); + Map result=new HashMap<>(); + result.put("sumMoney",sumMoney); + result.put("dayMoney",dayMoney); + result.put("monthMoney",monthMoney); + result.put("cashMoney",cashMoney); + result.put("money",userMoney.getMoney()); + return Result.success().put("data",result); + } + + @Override + public Result signIn(Long userId, String longitude, String latitude, String city,String address){ + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String time = simpleDateFormat.format(new Date()); + MessageInfo messageInfo = messageService.selectMessageByUserIdAndTime(userId, time); + if(messageInfo!=null){ + return Result.error("今天已经签过到了!"); + } + if(StringUtils.isEmpty(longitude) || StringUtils.isEmpty(latitude)){ + return Result.error("请在小程序设置中开启位置信息"); + } + Artificer artificer = selectArtificerByUserId(userId); + messageInfo=new MessageInfo(); + messageInfo.setContent(address); + messageInfo.setUserName(artificer.getArtificerName()); + messageInfo.setUserId(String.valueOf(userId)); + messageInfo.setState("10"); + messageInfo.setTypeId(longitude); + messageInfo.setTypeName(latitude); + messageService.saveBody(messageInfo); + artificer.setLatitude(latitude); + artificer.setLongitude(longitude); + if(StringUtils.isNotEmpty(latitude) && StringUtils.isNotEmpty(longitude)){ + JSONObject adInfo = CommonMapUtils.getLocationToAdInfo(messageInfo.getTypeId(), messageInfo.getTypeName()); + String cityName = adInfo.getString("city"); + artificer.setCity(cityName); + } + updateById(artificer); + return Result.success(); + } + + @Override + public Result selectArtificerMoneyList(Integer page,Integer limit,String startTime,String endTime,String title,String classifyId){ + return Result.success().put("data",new PageUtils(baseMapper.selectArtificerMoneyList(new Page<>(page,limit),startTime,endTime,title,classifyId))); + } + + @Override + public Result selectUserListByConsortiaId(Integer page,Integer limit,String userName,String phone,Long consortiaId,Long shopId,Integer flag,String time){ + return Result.success().put("data",new PageUtils(baseMapper.selectUserListByConsortiaId(new Page<>(page,limit),userName,phone,consortiaId,shopId,flag,time))); + } + + @Override + public void timing(Long artificerId) { + UserRecharge userRecharge = new UserRecharge(); + userRecharge.setType("1"); + userRecharge.setCreateTime(LocalDateTime.now().toString()); + BigDecimal bigDecimal = new BigDecimal(1); + userRecharge.setUserRecharge(bigDecimal); + userRecharge.setArtificerId(artificerId.intValue()); + userRechargeDao.insert(userRecharge); + } + + @Override + public Result integral(String artificerId, String type, Integer current, Integer size, String date, Integer fundType) { + Period period = new Period(); + period.setFundType(fundType); + period.setFundData(DateUtil.parse(date)); + Period period1 = calculationPeriod(period); + Date startFundData = period1.getStartFundData(); + Date endFundData = period1.getEndFundData(); + + String start = DateUtil.formatDateTime(startFundData); + String end = DateUtil.formatDateTime(endFundData); + + List req = Lists.newArrayList(); + List integral = userRechargeDao.integral(artificerId, new Page<>(current, size), type, start, end); + List count = userRechargeDao.integral(artificerId, new Page<>(current, 10000000), type, start, end); + + //根据formattedDate去分组 + Map> collect = integral.stream().collect(Collectors.groupingBy(UserRecharge::getFormattedDate)); + + collect.forEach((k, v) -> { + UserRecharge userRecharge = new UserRecharge(); + userRecharge.setFormattedDate(k); + userRecharge.setChildren(v); + req.add(userRecharge); + }); + //倒叙排列 + req.sort(Comparator.comparing(UserRecharge::getFormattedDate, Comparator.reverseOrder())); + return Result.success().put("data", req).put("count", count.size()); + } + + @Override + public Result storedValue(String date, String type, String artificerId) { + Map map = Maps.newHashMap(); + Period period = new Period(); + period.setFundType(Integer.valueOf(type)); + period.setFundData(DateUtil.parse(date)); + Period period1 = calculationPeriod(period); + Date startFundData = period1.getStartFundData(); + Date endFundData = period1.getEndFundData(); + + String start = DateUtil.formatDateTime(startFundData); + String end = DateUtil.formatDateTime(endFundData); + + int i = Integer.parseInt(commonInfoDao.findOne(100000).getValue()); + //储存积分 + String storedValue = userRechargeDao.storedValue(start, end, "2", artificerId); + //在线积分 + String onlineCredits = userRechargeDao.storedValue(start, end, "1", artificerId); + map.put("storedValue", storedValue); + map.put("onlineCredits", onlineCredits); + //长时间 + map.put("intervalDatesUltimately", start + "-" + end); + int num1 = Integer.parseInt((NumberUtil.toStr(new BigDecimal(storedValue)))); + int num2 = Integer.parseInt(NumberUtil.toStr(new BigDecimal(onlineCredits))); + int i1 = num2 * i / 60; + //在线时长 + map.put("onLineTime", i1 + ""); + map.put("sum", String.valueOf(num1 + num2)); + + return Result.success().put("data", map); + } + + @Override + public Result selectArtificerByArtificerId(Long artificerId) { + return Result.success().put("data", baseMapper.selectById(artificerId)); + } +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/impl/ArtificerTimeServiceImpl.java b/src/main/java/com/sqx/modules/artificer/service/impl/ArtificerTimeServiceImpl.java new file mode 100644 index 0000000..fb3cc32 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/impl/ArtificerTimeServiceImpl.java @@ -0,0 +1,102 @@ +package com.sqx.modules.artificer.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.service.UserMoneyService; +import com.sqx.modules.artificer.dao.ArtificerDao; +import com.sqx.modules.artificer.dao.ArtificerTimeDao; +import com.sqx.modules.artificer.dao.OrdersDao; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.ArtificerTime; +import com.sqx.modules.artificer.entity.CollectArtificer; +import com.sqx.modules.artificer.entity.Orders; +import com.sqx.modules.artificer.service.ArtificerService; +import com.sqx.modules.artificer.service.ArtificerTimeService; +import com.sqx.modules.artificer.service.CollectArtificerService; +import com.sqx.modules.pay.dao.CashOutDao; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.*; + + +@Service +public class ArtificerTimeServiceImpl extends ServiceImpl implements ArtificerTimeService { + + @Autowired + private ArtificerService artificerService; + @Autowired + private OrdersDao ordersDao; + + @Override + public Result updateArtificerTime(String date,String times,Long userId){ + Artificer artificer = artificerService.selectArtificerByUserId(userId); + baseMapper.delete(new QueryWrapper().eq("artificer_date",date).eq("classify",2).eq("artificer_id",artificer.getArtificerId())); + if(StringUtils.isNotEmpty(times)){ + for(String time:times.split(",")){ + Integer counts = baseMapper.selectCount(new QueryWrapper().eq("artificer_date", date).eq("artificer_id", artificer.getArtificerId()).eq("artificer_time", time)); + if(counts==0){ + ArtificerTime artificerTime=new ArtificerTime(); + artificerTime.setArtificerDate(date); + artificerTime.setArtificerTime(time); + artificerTime.setArtificerId(artificer.getArtificerId()); + artificerTime.setClassify(2); + artificerTime.setCreateTime(DateUtils.format(new Date())); + baseMapper.insert(artificerTime); + } + } + } + + return Result.success(); + } + + @Override + public Result selectArtificerTimeByArtificerId(Long artificerId,String artificerDate){ + List artificerTimes = baseMapper.selectList(new QueryWrapper() + .eq("artificer_id", artificerId) + .eq("artificer_date", artificerDate)); + for (ArtificerTime artificerTime:artificerTimes){ + if(artificerTime.getClassify()==1){ + //如果是订单占用 判断订单是否完成 + Orders orders = ordersDao.selectById(artificerTime.getOrdersId()); + if(orders==null){ + artificerTime.setClassify(2); + baseMapper.updateById(artificerTime); + continue; + } + if(orders.getStatus()==3 || orders.getStatus()==5){ + artificerTime.setClassify(2); + baseMapper.updateById(artificerTime); + } + } + } + return Result.success().put("data", artificerTimes); + } + + @Override + public Result selectArtificerTimeListByArtificerId(Long artificerId,String artificerDate){ + List> list=new ArrayList<>(); + Calendar calendar=Calendar.getInstance(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + for(int i=0;i<5;i++){ + List artificerTimes = baseMapper.selectList(new QueryWrapper().eq("artificer_id", artificerId).eq("artificer_date", artificerDate)); + list.add(artificerTimes); + calendar.add(Calendar.DAY_OF_MONTH,1); + artificerDate=simpleDateFormat.format(calendar.getTime()); + } + return Result.success().put("data",list); + } + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/impl/CollectArtificerServiceImpl.java b/src/main/java/com/sqx/modules/artificer/service/impl/CollectArtificerServiceImpl.java new file mode 100644 index 0000000..4f6488f --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/impl/CollectArtificerServiceImpl.java @@ -0,0 +1,254 @@ +package com.sqx.modules.artificer.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.dao.ArtificerMassageDao; +import com.sqx.modules.artificer.dao.CollectArtificerDao; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.ArtificerMassage; +import com.sqx.modules.artificer.entity.ArtificerTime; +import com.sqx.modules.artificer.entity.CollectArtificer; +import com.sqx.modules.artificer.service.ArtificerMassageService; +import com.sqx.modules.artificer.service.ArtificerTimeService; +import com.sqx.modules.artificer.service.CollectArtificerService; +import com.sqx.modules.common.service.CommonInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.concurrent.locks.ReentrantReadWriteLock; + + +@Service +public class CollectArtificerServiceImpl extends ServiceImpl implements CollectArtificerService { + + @Autowired + private ArtificerTimeService artificerTimeService; + @Autowired + private CommonInfoService commonInfoService; + + private ReentrantReadWriteLock reentrantReadWriteLock=new ReentrantReadWriteLock(true); + + @Override + public Result insertCollect(CollectArtificer collectArtificer){ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + reentrantReadWriteLock.writeLock().lock(); + try { + CollectArtificer collectArtificer1 = selectCollectArtificerByUserId(collectArtificer.getUserId(), collectArtificer.getArtificerId(),collectArtificer.getClassify()); + if(collectArtificer1!=null){ + if(collectArtificer1.getClassify()==1){ + baseMapper.deleteById(collectArtificer1.getCollectId()); + }else{ + collectArtificer1.setCreateTime(sdf.format(new Date())); + baseMapper.updateById(collectArtificer1); + } + }else{ + collectArtificer.setCreateTime(sdf.format(new Date())); + baseMapper.insert(collectArtificer); + } + return Result.success(); + }catch (Exception e){ + e.printStackTrace(); + }finally { + reentrantReadWriteLock.writeLock().unlock(); + } + return Result.error("系统繁忙,请稍后再试!"); + } + + + @Override + public CollectArtificer selectCollectArtificerByUserId(Long userId,Long artificerId,Integer classify){ + return baseMapper.selectOne(new QueryWrapper().eq("user_id",userId).eq("artificer_id",artificerId).eq("classify",classify)); + } + + @Override + public Result selectCollectList(Long userId,Integer page,Integer limit,String longitude,String latitude){ + Page pages=new Page<>(page,limit); + IPage artificerIPage = baseMapper.selectArtificerListByCollectUserId(pages, userId, longitude, latitude); + List records = artificerIPage.getRecords(); + + String value = commonInfoService.findOne(392).getValue(); + if("30".equals(value)){ + + SimpleDateFormat sdfHour=new SimpleDateFormat("HH"); + SimpleDateFormat sdfMinute=new SimpleDateFormat("mm"); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat md = new SimpleDateFormat("MM-dd"); + Date dateTime = new Date(); + + String hour = sdfHour.format(dateTime); + String minute = sdfMinute.format(dateTime); + int minuteInt = Integer.parseInt(minute); + int hourInt = Integer.parseInt(hour); + if(minuteInt>=30){ + if(hourInt==23){ + hourInt=0; + minuteInt=0; + }else{ + minuteInt=0; + hourInt=hourInt+1; + } + }else{ + minuteInt=30; + } + StringBuilder stringBuilders=new StringBuilder(); + if(hourInt<10){ + stringBuilders.append("0").append(hourInt); + }else{ + stringBuilders.append(hourInt); + } + stringBuilders.append(":"); + if(minuteInt<10){ + stringBuilders.append("0").append(minuteInt); + }else{ + stringBuilders.append(minuteInt); + } + + for(Artificer artificer:records){ + Calendar calendar=Calendar.getInstance(); + String date = simpleDateFormat.format(dateTime); + String oldDate = simpleDateFormat.format(dateTime); + hour = sdfHour.format(dateTime); + minute = sdfMinute.format(dateTime); + minuteInt = Integer.parseInt(minute); + hourInt = Integer.parseInt(hour); + if(minuteInt>=30){ + if(hourInt==23){ + hourInt=0; + minuteInt=0; + }else{ + minuteInt=0; + hourInt=hourInt+1; + } + }else{ + minuteInt=30; + } + while (true){ + StringBuilder stringBuilder=new StringBuilder(); + if(hourInt<10){ + stringBuilder.append("0").append(hourInt); + }else{ + stringBuilder.append(hourInt); + } + stringBuilder.append(":"); + if(minuteInt<10){ + stringBuilder.append("0").append(minuteInt); + }else{ + stringBuilder.append(minuteInt); + } + ArtificerTime artificerTime = artificerTimeService.getOne(new QueryWrapper().eq("artificer_id", artificer.getArtificerId()).eq("artificer_date", date).eq("artificer_time", stringBuilder.toString())); + if(artificerTime==null){ + if(oldDate.equals(date)){ + artificer.setTime(stringBuilder.toString()); + }else{ + artificer.setTime(md.format(calendar.getTime())+" "+stringBuilder.toString()); + } + if(artificer.getStatus()!=null && artificer.getStatus()==2){ + artificer.setState(3); + }else{ + if(stringBuilder.toString().equals(stringBuilders.toString())){ + artificer.setState(1); + }else{ + artificer.setState(2); + } + } + + break; + } + if(minuteInt==30){ + if(hourInt==23){ + hourInt=0; + minuteInt=0; + calendar.add(Calendar.DAY_OF_MONTH,1); + date = simpleDateFormat.format(calendar.getTime()); + }else{ + minuteInt=0; + hourInt=hourInt+1; + } + }else{ + minuteInt=30; + } + } + } + }else{ + + SimpleDateFormat sdf=new SimpleDateFormat("HH"); + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat md = new SimpleDateFormat("MM-dd"); + Date dateTime = new Date(); + String date = simpleDateFormat.format(dateTime); + String oldDate = simpleDateFormat.format(dateTime); + String time = sdf.format(dateTime); + String times=""; + if("23".equals(time)){ + time="01"; + times=time+":00"; + }else{ + time=String.valueOf(Integer.parseInt(time)+1); + times=time+":00"; + } + String nowTimes=times; + + for(Artificer artificer:records){ + Calendar calendar=Calendar.getInstance(); + date = simpleDateFormat.format(dateTime); + oldDate = simpleDateFormat.format(dateTime); + time = sdf.format(dateTime); + times=""; + if("23".equals(time)){ + time="01"; + times=time+":00"; + }else{ + time=String.valueOf(Integer.parseInt(time)+1); + times=time+":00"; + } + while (true){ + ArtificerTime artificerTime = artificerTimeService.getOne(new QueryWrapper().eq("artificer_id", artificer.getArtificerId()).eq("artificer_date", date).eq("artificer_time", times)); + if(artificerTime==null){ + if(oldDate.equals(date)){ + times=time+":00"; + artificer.setTime(times); + }else{ + times=time+":00"; + artificer.setTime(md.format(calendar.getTime())+" "+times); + } + if(artificer.getStatus()!=null && artificer.getStatus()==2){ + artificer.setState(3); + }else{ + if(times.equals(nowTimes)){ + artificer.setState(1); + }else{ + artificer.setState(2); + } + } + break; + } + if("23".equals(time)){ + time="01"; + times=time+":00"; + calendar.add(Calendar.DAY_OF_MONTH,1); + date = simpleDateFormat.format(calendar.getTime()); + }else{ + time=String.valueOf(Integer.parseInt(time)+1); + times=time+":00"; + } + } + } + } + return Result.success().put("data",new PageUtils(artificerIPage)); + } + + @Override + public int selectCountByUserId(Long artificerId, String startTime,String endTime ) { + return baseMapper.selectCountByUserId(artificerId,startTime,endTime); + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/impl/MassageTypeServiceImpl.java b/src/main/java/com/sqx/modules/artificer/service/impl/MassageTypeServiceImpl.java new file mode 100644 index 0000000..fa5c3e8 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/impl/MassageTypeServiceImpl.java @@ -0,0 +1,58 @@ +package com.sqx.modules.artificer.service.impl; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.dao.ArtificerDao; +import com.sqx.modules.artificer.dao.MassageTypeDao; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.MassageType; +import com.sqx.modules.artificer.service.ArtificerService; +import com.sqx.modules.artificer.service.MassageTypeService; +import com.sqx.modules.search.service.AppSearchService; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + + +@Service +public class MassageTypeServiceImpl extends ServiceImpl implements MassageTypeService { + + @Autowired + private AppSearchService appSearchService; + + @Override + public Result selectArtificerMassageList(Long artificerId,Integer status){ + List massageTypes = baseMapper.selectArtificerMassageList(artificerId, status); + return Result.success().put("data",massageTypes); + } + + @Override + public Result selectMassageTypePage(Integer page,Integer limit,Integer status,String city,Integer sort,Integer authentication,Integer by,String title,Long artificerId,Long userId,Integer parentId,Long classifyId){ + if(StringUtils.isNotEmpty(title) && userId!=null){ + appSearchService.insetAppSearch(title, userId); + } + Page pages=new Page<>(page,limit); + return Result.success().put("data",new PageUtils(baseMapper.selectMassageTypePage(pages,status,city,sort,authentication,by,title,artificerId,parentId,classifyId))); + } + @Override + public Result selectMassageTypeChildrenPage(Integer page,Integer limit,Integer status,String city,Integer sort,Integer authentication,Integer by,String title,Long artificerId,Long userId,Integer parentId,Long classifyId){ + if(StringUtils.isNotEmpty(title) && userId!=null){ + appSearchService.insetAppSearch(title, userId); + } + Page pages=new Page<>(page,limit); + return Result.success().put("data",new PageUtils(baseMapper.selectMassageTypeChildrenPage(pages,status,city,sort,authentication,by,title,artificerId,parentId,classifyId))); + } + + @Override + public Result selectMassageTypeList(Integer status,String city,Integer sort,Integer authentication,Integer by,String title,Long artificerId,Long userId,Integer parentId,Long classifyId){ + if(StringUtils.isNotEmpty(title) && userId!=null){ + appSearchService.insetAppSearch(title, userId); + } + return Result.success().put("data",baseMapper.selectMassageTypeList(status,city,sort,authentication,by,title,artificerId,parentId,classifyId)); + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/impl/OrdersMassageServiceImpl.java b/src/main/java/com/sqx/modules/artificer/service/impl/OrdersMassageServiceImpl.java new file mode 100644 index 0000000..a8691f8 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/impl/OrdersMassageServiceImpl.java @@ -0,0 +1,18 @@ +package com.sqx.modules.artificer.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.modules.artificer.dao.MassageTypeDao; +import com.sqx.modules.artificer.dao.OrdersMassageDao; +import com.sqx.modules.artificer.entity.MassageType; +import com.sqx.modules.artificer.entity.OrdersMassage; +import com.sqx.modules.artificer.service.MassageTypeService; +import com.sqx.modules.artificer.service.OrdersMassageService; +import org.springframework.stereotype.Service; + + +@Service +public class OrdersMassageServiceImpl extends ServiceImpl implements OrdersMassageService { + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/impl/OrdersServiceImpl.java b/src/main/java/com/sqx/modules/artificer/service/impl/OrdersServiceImpl.java new file mode 100644 index 0000000..fe0c43e --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/impl/OrdersServiceImpl.java @@ -0,0 +1,2646 @@ +package com.sqx.modules.artificer.service.impl; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.lang.tree.Tree; +import cn.hutool.core.lang.tree.TreeNodeConfig; +import cn.hutool.core.lang.tree.TreeUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.aliyun.dyvmsapi20170525.Client; +import com.aliyun.dyvmsapi20170525.models.*; +import com.aliyun.teaopenapi.models.Config; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.map.CommonMapUtils; +import com.sqx.modules.app.dao.UserVipDao; +import com.sqx.modules.app.dao.VipDetailsDao; +import com.sqx.modules.app.entity.*; +import com.sqx.modules.app.service.*; +import com.sqx.modules.artificer.dao.ArtificerDao; +import com.sqx.modules.artificer.dao.OrdersDao; +import com.sqx.modules.artificer.entity.*; +import com.sqx.modules.artificer.service.*; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.consortia.entity.Consortia; +import com.sqx.modules.consortia.service.ConsortiaService; +import com.sqx.modules.coupon.entity.CouponUser; +import com.sqx.modules.coupon.service.CouponUserService; +import com.sqx.modules.material.service.MaterialArtificerService; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.service.MessageService; +import com.sqx.modules.pay.controller.app.AliPayController; +import com.sqx.modules.pay.service.WxService; +import com.sqx.modules.sys.entity.SysDictEntity; +import com.sqx.modules.sys.service.SysDictService; +import com.sqx.modules.taking.dao.OrderTakingCommentDao; +import com.sqx.modules.trip.entity.Trip; +import com.sqx.modules.trip.service.TripService; +import com.sqx.modules.utils.AppNotifyUtil; +import com.sqx.modules.utils.LonLatUtil; +import com.sqx.modules.utils.SenInfoCheckUtil; +import com.sqx.modules.utils.address.AddressUtil; +import com.sqx.modules.utils.address.WSSsdrAddress; +import com.sqx.modules.utils.excel.ExcelData; +import jodd.util.StringUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.gavaghan.geodesy.Ellipsoid; +import org.gavaghan.geodesy.GlobalCoordinates; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; +import weixin.popular.bean.message.templatemessage.TemplateMessageItem; + +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.*; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.stream.Collectors; + +@Slf4j +@Service +public class OrdersServiceImpl extends ServiceImpl implements OrdersService { + + @Autowired + private OrdersDao ordersDao; + @Autowired + private MassageTypeService massageTypeService; + @Autowired + private UserVipService userVipService; + @Autowired + private OrdersMassageService ordersMassageService; + @Autowired + private UserMoneyDetailsService userMoneyDetailsService; + @Autowired + private UserMoneyService userMoneyService; + @Autowired + private ArtificerService artificerService; + @Autowired + private VipDetailsDao vipDetailsDao; + @Autowired + private UserService userService; + @Autowired + private MessageService messageService; + @Autowired + private UserVipDao userVipDao; + @Autowired + private OrderTakingCommentDao orderTakingCommentDao; + @Autowired + private CommonInfoService commonInfoService; + @Autowired + private CollectArtificerService collectArtificerService; + @Autowired + private ArtificerTimeService artificerTimeService; + @Autowired + private CouponUserService couponUserService; + @Autowired + private WxService wxService; + @Autowired + private AliPayController aliPayController; + @Autowired + private TripService tripService; + @Autowired + private ConsortiaService consortiaService; + @Autowired + private UserMoneyArtificerService userMoneyArtificerService; + @Autowired + private SysDictService sysDictService; + @Autowired + private MaterialArtificerService materialArtificerService; + @Autowired + private ArtificerDao artificerDao; + + private ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(true); + + private ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().build(); + private ExecutorService singleThreadPool = new ThreadPoolExecutor(30, 100, + 0L, TimeUnit.MILLISECONDS, + new LinkedBlockingQueue<>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); + + + @Override + public Map selectTaxiMoney(Long artificerId, String latitude, String longitude, String city) { + + + Artificer artificer = artificerService.getById(artificerId); + GlobalCoordinates source = new GlobalCoordinates(Double.parseDouble(latitude), Double.parseDouble(longitude)); + GlobalCoordinates target = new GlobalCoordinates(Double.parseDouble(artificer.getLatitude()), Double.parseDouble(artificer.getLongitude())); + Integer distances = (int) LonLatUtil.getDistanceMeter(source, target, Ellipsoid.Sphere); + + //起步价 + String tripPrice; + //每公里价格 + String tripMoney; + //起步公里数 + String tripNum; + Trip trip = tripService.getOne(new QueryWrapper().like("city", city)); + if (trip == null) { + return Result.error("当前地址暂无出行方式,请更换其他地址!"); + } + + //获取城市名称 + JSONObject mapAdRes = CommonMapUtils.getLocationToAdInfo(longitude, latitude); + String cityName = mapAdRes.getString("city"); + String cityCode = mapAdRes.getString("adcode"); + JSONObject mapRes = CommonMapUtils.calcTaxiMoneyInfo(artificer.getTripWay(), longitude, latitude, artificer.getLongitude(), artificer.getLatitude(), cityName, cityCode);//根据出行方式计算距离 + + //判断技师的出行方式 + if (artificer.getTripWay() == null || artificer.getTripWay() == 1) { + //公交 + tripPrice = trip.getBusStartingFare(); + tripMoney = trip.getBusKmMoney(); + tripNum = trip.getBusStartingKm(); + distances = mapRes.getInteger("distance"); + } else if (artificer.getTripWay() == 2) { + //出租 + tripPrice = trip.getTaxiStartingFare(); + tripMoney = trip.getTaxiKmMoney(); + tripNum = trip.getTaxiStartingKm(); + distances = mapRes.getInteger("distance"); + } else { + tripPrice = "0"; + tripMoney = "0"; + tripNum = "1"; + } + + + int i = Integer.parseInt(tripNum); + i = i * 1000; + BigDecimal taxiMoney = new BigDecimal(tripPrice); + if (artificer.getTripWay() == null || artificer.getTripWay() == 1 || artificer.getTripWay() == 2) { + if (distances > i) { + int distancess = distances; + //大于起步公里 + distances = distances - i; + BigDecimal bigDecimal = BigDecimal.valueOf(distances).divide(BigDecimal.valueOf(1000), 0, BigDecimal.ROUND_UP); + double downd = Math.ceil(bigDecimal.doubleValue()); + distances = new Double(downd).intValue(); + BigDecimal xuMoney = BigDecimal.valueOf(distances).multiply(new BigDecimal(tripMoney)); + taxiMoney = taxiMoney.add(xuMoney); + distances = distancess; + bigDecimal = BigDecimal.valueOf(distances).divide(BigDecimal.valueOf(1000), 0, BigDecimal.ROUND_UP); + downd = Math.ceil(bigDecimal.doubleValue()); + distances = new Double(downd).intValue(); + } else { + BigDecimal bigDecimal = BigDecimal.valueOf(distances).divide(BigDecimal.valueOf(1000), 0, BigDecimal.ROUND_UP); + double downd = Math.ceil(bigDecimal.doubleValue()); + distances = new Double(downd).intValue(); + } + } else { + BigDecimal bigDecimal = BigDecimal.valueOf(distances).divide(BigDecimal.valueOf(1000), 0, BigDecimal.ROUND_UP); + double downd = Math.ceil(bigDecimal.doubleValue()); + distances = new Double(downd).intValue(); + } + + String value = commonInfoService.findOne(426).getValue(); + if ("是".equals(value)) { + distances = distances * 2; + taxiMoney = taxiMoney.multiply(BigDecimal.valueOf(2)); + } + + Map result = new HashMap<>(); + result.put("tripPrice", tripPrice); + result.put("tripNum", tripNum); + result.put("distances", distances); + result.put("xuMoney", tripMoney); + result.put("taxiMoney", taxiMoney); + return result; + } + + + @Override + public Result insertOrders(Orders orders) { + reentrantReadWriteLock.writeLock().lock(); + Artificer artificer1 = artificerDao.selectOne(Wrappers.lambdaQuery() + .eq(Artificer::getArtificerId, orders.getArtificerId())); + orders.setClassifyId(artificer1.getClassifyId()); + try { + CouponUser couponUser = couponUserService.getById(orders.getCouponId()); + if (couponUser != null) { + if (!couponUser.getStatus().equals(0)) { + return Result.error("优惠券已被使用!"); + } + + } + + List ordersMassageList = orders.getOrdersMassageList(); + + MassageType massageType = massageTypeService.getById(ordersMassageList.get(0).getMassageId()); + String value1 = commonInfoService.findOne(395).getValue(); + int i = 0; + //1.锁定本单服务时间问题 + //项目时间 + Integer duration = massageType.getDuration(); + //精油 + String jyValue = commonInfoService.findOne(392).getValue(); + //中医 + String zyValue = commonInfoService.findOne(436).getValue(); + int minute=0; + int jyMinuteInt = Integer.parseInt(jyValue); + // todo 这块只是满足当时的需求 (后续有变化需要改动!!!) +// int zyMinuteInt = Integer.parseInt(zyValue); + //公交1h,出租30 , 免费 1h(加出行时间) + Integer tripWay = orders.getTripWay(); + if(Objects.nonNull(tripWay)&&(tripWay==1 || tripWay==3)){ + duration=duration+30; + } + if ("是".equals(value1)) { + if(orders.getClassifyId() == 91){ + minute=jyMinuteInt; + if (duration % minute == 0) { + i = duration / minute; + } else { + i = duration / minute; + i++; + } + }else{ + minute=jyMinuteInt; + if (duration % minute == 0) { + i = duration / minute; + } else { + i = duration / minute; + i++; + } + } + } + + + BigDecimal payMoney = BigDecimal.ZERO; + BigDecimal taxiMoney = BigDecimal.ZERO; + if (orders.getParentId() == null || orders.getParentId() == 0) { + String serveTime = orders.getServeTime(); + String date = serveTime.substring(0, 10); + String time = serveTime.substring(11, 16); + ArtificerTime artificerTime = artificerTimeService.getOne( + new QueryWrapper() + .eq("artificer_id", orders.getArtificerId()) + .eq("artificer_date", date).eq("artificer_time", time)); + if (artificerTime != null) { + return Result.error("预约时间正忙,请更换其他时间!"); + } + + if (i > 1) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date parse = sdf.parse(serveTime); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(parse); + for (int j = 1; j < i; j++) { + calendar.add(Calendar.MINUTE, minute); + String format = sdf.format(calendar.getTime()); + date = format.substring(0, 10); + time = format.substring(11, 16); + artificerTime = artificerTimeService.getOne( + new QueryWrapper() + .eq("artificer_id", orders.getArtificerId()) + .eq("artificer_date", date).eq("artificer_time", time)); + if (artificerTime != null) { + return Result.error("预约时间正忙,请更换其他时间!"); + } + } + } + + WSSsdrAddress wsSsdrAddress = AddressUtil.resolveAddress(orders.getAddress()); + Map result = selectTaxiMoney(orders.getArtificerId(), orders.getLatitude(), orders.getLongitude(), wsSsdrAddress.getCity()); + if (result == null) { + return Result.error("暂不支持当前地址,请更换其他地址!"); + } + taxiMoney = new BigDecimal(String.valueOf(result.get("taxiMoney"))); + orders.setTaxiMoney(taxiMoney); + } else { + if ("是".equals(value1)) { + ArtificerTime artificerTime = artificerTimeService.getOne(new QueryWrapper().eq("orders_id", orders.getParentId()).last(" order by artificer_time_id desc limit 1 ")); + String serveTime = artificerTime.getArtificerDate() + " " + artificerTime.getArtificerTime(); + String date = null; + String time = null; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date parse = sdf.parse(serveTime); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(parse); + for (int j = 0; j < i; j++) { + calendar.add(Calendar.MINUTE, minute); + String format = sdf.format(calendar.getTime()); + date = format.substring(0, 10); + time = format.substring(11, 16); + artificerTime = artificerTimeService.getOne( + new QueryWrapper() + .eq("artificer_id", orders.getArtificerId()) + .eq("artificer_date", date).eq("artificer_time", time)); + if (artificerTime != null) { + return Result.error("预约时间正忙,请更换其他时间!"); + } + } + } + + } + + + BigDecimal price = BigDecimal.ZERO; + String massageTypeName = ""; + BigDecimal artificerPrice = new BigDecimal("0.00"); + Result userVip = userVipService.isUserVip(orders.getUserId()); + String data = String.valueOf(userVip.get("data")); + boolean isVip = false; + if ("true".equals(data)) { + isVip = true; + } + for (OrdersMassage ordersMassage : ordersMassageList) { + BigDecimal massagePrice; + BigDecimal aprice = massageType.getPrice().multiply(BigDecimal.valueOf(ordersMassage.getNum())); + if (isVip) { + massagePrice = massageType.getMemberPrice().multiply(BigDecimal.valueOf(ordersMassage.getNum())); + } else { + massagePrice = massageType.getPrice().multiply(BigDecimal.valueOf(ordersMassage.getNum())); + } + price = massagePrice; + massageTypeName = massageType.getTitle(); + payMoney = massagePrice.add(payMoney); + artificerPrice = aprice; + if (orders.getParentId() != null && orders.getParentId() != 0) { + orders.setAddTime(massageType.getDuration()); + } + orders.setMassageTypeId(massageType.getMassageTypeId()); + } + orders.setPayMoney(payMoney.add(taxiMoney)); + if (couponUser != null) { + orders.setCouponMoney(couponUser.getMoney()); + orders.setCouponName(couponUser.getCouponName()); + orders.setPayMoney(orders.getPayMoney().subtract(couponUser.getMoney())); + couponUser.setStatus(1); + couponUserService.updateById(couponUser); + } + Artificer artificer = artificerService.getById(orders.getArtificerId()); + //查询是否计算出租车扣费 + String taxi = commonInfoService.findOne(394).getValue(); + //计算技师出租车收益(按照技师表收益计算) + if ("是".equals(taxi)) { + //计算技师应该收取的出租车费用 + BigDecimal artificerTaxiMoney = taxiMoney.multiply(artificer.getRate()); + //计算出租车扣款 + BigDecimal pingTaxiMoney = taxiMoney.subtract(artificerTaxiMoney); + //赋值技师出租收款 + orders.setArtificerTaxiMoney(artificerTaxiMoney); + //赋值出租车扣款 + orders.setPingTaxiMoney(pingTaxiMoney); + //赋值技师收益 + artificerPrice = orders.getPayMoney().multiply(artificer.getRate()); + } else { + //平台不扣费 出租车收益全由技师收取 + orders.setArtificerTaxiMoney(orders.getTaxiMoney()); + //设置出租车扣款为0 + orders.setPingTaxiMoney(BigDecimal.ZERO); + //用户支付减去通行费用 + BigDecimal subtract = orders.getPayMoney().subtract(taxiMoney); + //计算用户收益 !计算前先减去通行费用再计算技师抽成 + artificerPrice = subtract.multiply(artificer.getRate()); + //用户收益加上通行费用 + artificerPrice = artificerPrice.add(taxiMoney); + } + + orders.setPrice(price); + orders.setEntryName(massageTypeName); + //计算项目收益 + if (couponUser != null) { + //去掉优惠卷金额的项目金额 + BigDecimal projectBenefits = price.subtract(couponUser.getMoney()); + orders.setProjectBenefits(projectBenefits.multiply(artificer.getRate()).setScale(2,BigDecimal.ROUND_HALF_UP)); + } + else { + orders.setProjectBenefits(price.multiply(artificer.getRate()).setScale(2,BigDecimal.ROUND_HALF_UP)); + } + orders.setArtificerMoney(artificerPrice); + orders.setSumArtificerMoney(orders.getArtificerMoney()); + orders.setOrdersNo(getGeneralOrder()); + orders.setStatus(1); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + orders.setCreateTime(sdf.format(new Date())); + //留存订单生成时的技师分成比例 + orders.setArtificerRate(artificer.getRate()); + orders.setSumMoney(orders.getPayMoney()); + baseMapper.insert(orders); + if(ObjectUtil.equals(orders.getParentId(),null) || ObjectUtil.equals(orders.getParentId(),0L)){ + //技师电话通知业务 + UserEntity byId = userService.getById(artificer.getUserId()); + //accountId + String accountId = commonInfoService.findOne(428).getValue(); + //token + String token = commonInfoService.findOne(429).getValue(); + //templateId + String templateId = commonInfoService.findOne(430).getValue(); + AppNotifyUtil.AppNotify(byId.getPhone(),accountId,token,templateId); + } + for (OrdersMassage ordersMassage : ordersMassageList) { + ordersMassage.setOrdersId(orders.getOrdersId()); + ordersMassageService.save(ordersMassage); + } + if (orders.getParentId() == null || orders.getParentId() == 0) { + String serveTime = orders.getServeTime(); + if (i > 0) { + SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date parse = sdf1.parse(serveTime); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(parse); + //3.预约时间前及服务完成时间后问题 + DateTime dateTime = DateUtil.offsetMinute(parse, -30); + Calendar calendar1 = Calendar.getInstance(); + calendar1.setTime(dateTime); + String format1 = sdf1.format(calendar1.getTime()); + String date1 = format1.substring(0, 10); + String time1 = format1.substring(11, 16); + ArtificerTime artificerTime1 = new ArtificerTime(); + artificerTime1.setArtificerId(orders.getArtificerId()); + artificerTime1.setArtificerDate(date1); + artificerTime1.setArtificerTime(time1); + artificerTime1.setClassify(1); + artificerTime1.setOrdersId(orders.getOrdersId()); + artificerTime1.setCreateTime(DateUtils.format(new Date())); + artificerTimeService.save(artificerTime1); + + for (int j = 0; j < i; j++) { + String format = sdf1.format(calendar.getTime()); + String date = format.substring(0, 10); + String time = format.substring(11, 16); + ArtificerTime artificerTime = new ArtificerTime(); + artificerTime.setArtificerId(orders.getArtificerId()); + artificerTime.setArtificerDate(date); + artificerTime.setArtificerTime(time); + artificerTime.setClassify(1); + artificerTime.setOrdersId(orders.getOrdersId()); + artificerTime.setCreateTime(DateUtils.format(new Date())); + artificerTimeService.save(artificerTime); + calendar.add(Calendar.MINUTE, minute); + } + } + // todo 这块只是满足当时的需求注释的 (后续有变化需要改动!!!) +// else { +// String date = serveTime.substring(0, 10); +// String time = serveTime.substring(11, 16); +// ArtificerTime artificerTime = new ArtificerTime(); +// artificerTime.setArtificerId(orders.getArtificerId()); +// artificerTime.setArtificerDate(date); +// artificerTime.setArtificerTime(time); +// artificerTime.setClassify(1); +// artificerTime.setOrdersId(orders.getOrdersId()); +// artificerTime.setCreateTime(DateUtils.format(new Date())); +// artificerTimeService.save(artificerTime); +// } + } + return Result.success().put("data", orders); + } catch (Exception e) { + e.printStackTrace(); + log.error("添加订单异常" + e.getMessage(), e); + } finally { + reentrantReadWriteLock.writeLock().unlock(); + } + return Result.error("系统繁忙,请稍后再试!"); + } + + @Override + public Result updateOrders(Orders orders) { + Orders oldOrders = baseMapper.selectById(orders.getOrdersId()); + if (StringUtils.isNotBlank(orders.getServeTime()) && !orders.getServeTime().equals(oldOrders.getServeTime())) { + //修改预约时间 + //判断订单是否开始 + if (oldOrders.getStatus() != 2) { + return Result.error("只有待服务的订单可以修改预约时间!"); + } + String value1 = commonInfoService.findOne(395).getValue(); + List ordersMassageList = ordersMassageService.list(new QueryWrapper().eq("orders_id", orders.getOrdersId())); + int i = 0; + MassageType massageType = massageTypeService.getById(ordersMassageList.get(0).getMassageId()); + Integer duration = massageType.getDuration(); + String value = commonInfoService.findOne(392).getValue(); + int minute = Integer.parseInt(value); + if ("是".equals(value1)) { + if (duration % minute == 0) { + i = duration / minute; + } else { + i = duration / minute; + i++; + } + } + String serveTime = orders.getServeTime(); + String date = serveTime.substring(0, 10); + String time = serveTime.substring(11, 16); + ArtificerTime artificerTime = artificerTimeService.getOne( + new QueryWrapper() + .eq("artificer_id", oldOrders.getArtificerId()) + .eq("artificer_date", date).eq("artificer_time", time)); + if (artificerTime != null && (artificerTime.getOrdersId() == null || !artificerTime.getOrdersId().equals(orders.getOrdersId()))) { + return Result.error("预约时间正忙,请更换其他时间!"); + } + + if (i > 1) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date parse = null; + try { + parse = sdf.parse(serveTime); + } catch (ParseException e) { + e.printStackTrace(); + } + Calendar calendar = Calendar.getInstance(); + calendar.setTime(parse); + for (int j = 1; j < i; j++) { + calendar.add(Calendar.MINUTE, minute); + String format = sdf.format(calendar.getTime()); + date = format.substring(0, 10); + time = format.substring(11, 16); + artificerTime = artificerTimeService.getOne( + new QueryWrapper() + .eq("artificer_id", oldOrders.getArtificerId()) + .eq("artificer_date", date).eq("artificer_time", time)); + if (artificerTime != null && (artificerTime.getOrdersId() == null || !artificerTime.getOrdersId().equals(orders.getOrdersId()))) { + return Result.error("预约时间正忙,请更换其他时间!"); + } + } + } + artificerTimeService.remove(new QueryWrapper().eq("orders_id", orders.getOrdersId())); + if (i > 0) { + SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date parse = null; + try { + parse = sdf1.parse(serveTime); + } catch (ParseException e) { + e.printStackTrace(); + } + Calendar calendar = Calendar.getInstance(); + calendar.setTime(parse); + for (int j = 0; j < i; j++) { + String format = sdf1.format(calendar.getTime()); + date = format.substring(0, 10); + time = format.substring(11, 16); + artificerTime = new ArtificerTime(); + artificerTime.setArtificerId(oldOrders.getArtificerId()); + artificerTime.setArtificerDate(date); + artificerTime.setArtificerTime(time); + artificerTime.setClassify(1); + artificerTime.setOrdersId(orders.getOrdersId()); + artificerTime.setCreateTime(DateUtils.format(new Date())); + artificerTimeService.save(artificerTime); + calendar.add(Calendar.MINUTE, minute); + } + } else { + date = serveTime.substring(0, 10); + time = serveTime.substring(11, 16); + artificerTime = new ArtificerTime(); + artificerTime.setArtificerId(oldOrders.getArtificerId()); + artificerTime.setArtificerDate(date); + artificerTime.setArtificerTime(time); + artificerTime.setClassify(1); + artificerTime.setOrdersId(orders.getOrdersId()); + artificerTime.setCreateTime(DateUtils.format(new Date())); + artificerTimeService.save(artificerTime); + } + } + baseMapper.updateById(orders); + return Result.success(); + } + + + @Override + public Result cancelOrders(Long userId, Long ordersId) { + Orders orders = baseMapper.selectById(ordersId); + //状态 1待支付 2待服务 3待评论 4已取消 5已完成 6进行中 7技师出发 8技师到达 + if (orders.getStatus() == 4) { + return Result.error("订单已经取消了!"); + } else if (orders.getStatus() == 3 || orders.getStatus() == 5) { + return Result.error("订单已经完成了,无法取消!"); + } else if (orders.getStatus() == 6) { + return Result.error("订单正在进行中,无法取消!"); + } + artificerTimeService.remove(new QueryWrapper().eq("orders_id", ordersId)); + + if (orders.getCouponId() != null) { + CouponUser couponUser = couponUserService.getById(orders.getCouponId()); + if (couponUser != null && couponUser.getStatus().equals(1)) { + couponUser.setStatus(0); + couponUserService.updateById(couponUser); + } + } + if (orders.getStatus() == 1) { + orders.setStatus(4); + } else { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String time = simpleDateFormat.format(new Date()); + BigDecimal rate = BigDecimal.ZERO; + BigDecimal userMoney = orders.getPayMoney(); + if (orders.getStatus().equals(7) || orders.getStatus().equals(8)) { + String rateValue = commonInfoService.findOne(419).getValue(); + BigDecimal money = orders.getPayMoney().subtract(orders.getTaxiMoney()); + rate = money.multiply(new BigDecimal(rateValue)); + userMoney = money.subtract(rate); + } + + if (orders.getPayWay() == 1 || orders.getPayWay() == 2 || orders.getPayWay() == 3 || orders.getPayWay() == 4) { + boolean refund = wxService.refund(orders.getOrdersNo(), orders.getPayMoney(), userMoney, orders.getPayWay()); + if (!refund) { + return Result.error("退款失败,请联系客服!"); + } + } else if (orders.getPayWay() == 6) { + String data = aliPayController.alipayRefund(orders.getOrdersNo(), userMoney); + if (StringUtils.isNotBlank(data)) { + log.error(data); + JSONObject jsonObject = JSON.parseObject(data); + JSONObject alipay_trade_refund_response = jsonObject.getJSONObject("alipay_trade_refund_response"); + String code1 = alipay_trade_refund_response.getString("code"); + if (!"10000".equals(code1)) { + return Result.error("退款失败!" + alipay_trade_refund_response.getString("sub_msg")); + } + } else { + return Result.error("退款失败!"); + } + } else { + if (orders.getUserArtificerMoney() != null && orders.getUserArtificerMoney() == 1) { + userMoneyArtificerService.updateMoney(1, orders.getUserId(), orders.getArtificerId(), userMoney.doubleValue()); + } else { + userMoneyService.updateMoney(1, orders.getUserId(), userMoney.doubleValue()); + } + } + UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); + + userMoneyDetails.setMoney(userMoney); + userMoneyDetails.setUserId(orders.getUserId()); + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(orders.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + if (orders.getStatus().equals(7) || orders.getStatus().equals(8)) { + userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",已原路退款!扣除订单:" + rate + ",车费:" + orders.getTaxiMoney()); + } else { + userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",已原路退款!"); + } + + userMoneyDetails.setTitle("订单退款"); + userMoneyDetails.setType(1); + userMoneyDetails.setCreateTime(time); + userMoneyDetails.setArtificerId(orders.getArtificerId()); + userMoneyDetailsService.save(userMoneyDetails); + if (orders.getStatus().equals(7) || orders.getStatus().equals(8)) { + //按照比例 将扣除的钱进行分佣 + BigDecimal taxiMoney = orders.getTaxiMoney(); + BigDecimal sumMoney = rate.add(taxiMoney); + Artificer artificer = artificerService.getById(orders.getArtificerId()); + BigDecimal artificerTaxiMoney = taxiMoney; + BigDecimal pingTaxiMoney = BigDecimal.ZERO; + BigDecimal artificerMoney = rate.multiply(artificer.getRate()); + String taxi = commonInfoService.findOne(394).getValue(); + if ("是".equals(taxi)) { + artificerTaxiMoney = taxiMoney.multiply(artificer.getRate()); + pingTaxiMoney = taxiMoney.subtract(artificerTaxiMoney); + } + + UserEntity user = userService.selectUserById(orders.getUserId()); + + UserEntity oneUser = userService.queryByInvitationCode(user.getInviterCode()); + + BigDecimal oneUserMoney = BigDecimal.ZERO; + if (oneUser != null && oneUser.getIsAgency() != null && oneUser.getIsAgency() == 1) { + orders.setOneUserId(oneUser.getUserId()); + orders.setOneUserName(oneUser.getUserName()); + oneUserMoney = rate.multiply(oneUser.getUserRate()); + } + + UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); + + UserEntity oneArtificerUser = userService.queryByInvitationCode(artificerUser.getInviterCode()); + + BigDecimal oneArtificerMoney = BigDecimal.ZERO; + if (oneArtificerUser != null && oneArtificerUser.getIsAgency() != null && oneArtificerUser.getIsAgency() == 1) { + orders.setOneArtificerUserId(oneArtificerUser.getUserId()); + orders.setOneArtificerUserName(oneArtificerUser.getUserName()); + oneArtificerMoney = rate.multiply(oneArtificerUser.getShopRate()); + } + + BigDecimal shopMoney = BigDecimal.ZERO; + if (artificerUser.getConsortiaId() != null) { + Consortia consortia = consortiaService.getById(artificerUser.getConsortiaId()); + if (consortia != null && consortia.getUserId() != null) { + UserEntity consortiaUser = userService.getById(consortia.getUserId()); + if (consortiaUser != null) { + shopMoney = rate.multiply(consortia.getRate()); + } + } + } + rate = rate.subtract(artificerMoney); + rate = rate.subtract(oneUserMoney); + rate = rate.subtract(shopMoney); + rate = rate.subtract(oneArtificerMoney).setScale(2, BigDecimal.ROUND_DOWN); + orders.setShopMoney(shopMoney.setScale(2, BigDecimal.ROUND_DOWN)); + orders.setArtificerMoney(artificerMoney.setScale(2, BigDecimal.ROUND_DOWN)); + orders.setSumArtificerMoney(artificerMoney.add(artificerTaxiMoney).setScale(2, BigDecimal.ROUND_DOWN)); + orders.setOneUserMoney(oneUserMoney.setScale(2, BigDecimal.ROUND_DOWN)); + orders.setOneArtificerMoney(oneArtificerMoney.setScale(2, BigDecimal.ROUND_DOWN)); + orders.setPingMoney(rate.setScale(2, BigDecimal.ROUND_DOWN)); + orders.setArtificerTaxiMoney(artificerTaxiMoney.setScale(2, BigDecimal.ROUND_DOWN)); + orders.setPingTaxiMoney(pingTaxiMoney.setScale(2, BigDecimal.ROUND_DOWN)); + //分账 + userMoneyService.updateMoney(1, artificerUser.getUserId(), orders.getSumArtificerMoney().doubleValue()); + userMoneyDetails = new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney1 = userMoneyService.selectUserMoneyByUserId(artificerUser.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney1.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(orders.getSumArtificerMoney()); + userMoneyDetails.setUserId(artificerUser.getUserId()); + userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",订单取消!"); + String value = commonInfoService.findOne(394).getValue(); + if ("是".equals(value)) { + if (orders.getShopUserId() != null) { + userMoneyDetails.setTitle("用户取消订单,总扣除:" + sumMoney + ",平台扣除:" + rate + + ",商家扣除:" + orders.getShopMoney() + ",用户代理扣除:" + orders.getOneUserMoney() + ",技师代理扣除:" + orders.getOneArtificerMoney() + + ",打车费:" + orders.getTaxiMoney() + ",平台扣除打车费:" + orders.getPingTaxiMoney() + ",到账打车费:" + orders.getArtificerTaxiMoney() + + ",到账总金额:" + orders.getSumArtificerMoney()); + } else { + userMoneyDetails.setTitle("用户取消订单,总扣除:" + sumMoney + ",平台扣除:" + orders.getPingMoney() + + ",用户代理扣除:" + orders.getOneUserMoney() + ",技师代理扣除:" + orders.getOneArtificerMoney() + + ",打车费:" + orders.getTaxiMoney() + ",平台扣除打车费:" + orders.getPingTaxiMoney() + ",到账打车费:" + orders.getArtificerTaxiMoney() + + ",到账总金额:" + orders.getSumArtificerMoney()); + } + } else { + if (orders.getShopUserId() != null) { + userMoneyDetails.setTitle("用户取消订单,总扣除:" + sumMoney + ",平台扣除:" + orders.getPingMoney() + + ",商家扣除:" + orders.getShopMoney() + ",用户代理扣除:" + orders.getOneUserMoney() + ",技师代理扣除:" + orders.getOneArtificerMoney() + + ",打车费:" + orders.getTaxiMoney() + + ",到账总金额:" + orders.getSumArtificerMoney()); + } else { + userMoneyDetails.setTitle("用户取消订单,总扣除:" + sumMoney + ",平台扣除:" + orders.getPingMoney() + + ",用户代理扣除:" + orders.getOneUserMoney() + ",技师代理扣除:" + orders.getOneArtificerMoney() + + ",打车费:" + orders.getTaxiMoney() + + ",到账总金额:" + orders.getSumArtificerMoney()); + } + } + + userMoneyDetails.setType(1); + + userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + + if (oneUser != null && oneUser.getIsAgency() != null && oneUser.getIsAgency() == 1) { + userMoneyService.updateMoney(1, oneUser.getUserId(), orders.getOneUserMoney().doubleValue()); + userMoneyDetails = new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney3 = userMoneyService.selectUserMoneyByUserId(oneUser.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney3.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(orders.getOneUserMoney()); + userMoneyDetails.setUserId(oneUser.getUserId()); + userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",订单取消!"); + userMoneyDetails.setTitle("推广用户收益"); + userMoneyDetails.setType(1); + userMoneyDetails.setClassify(5); + userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + + orders.setOneUserId(oneUser.getUserId()); + orders.setOneUserName(oneUser.getUserName()); + } + + + if (oneArtificerUser != null && oneArtificerUser.getIsAgency() != null && oneArtificerUser.getIsAgency() == 1) { + userMoneyService.updateMoney(1, oneArtificerUser.getUserId(), orders.getOneArtificerMoney().doubleValue()); + userMoneyDetails = new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney4 = userMoneyService.selectUserMoneyByUserId(oneArtificerUser.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney4.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(orders.getOneArtificerMoney()); + userMoneyDetails.setUserId(oneArtificerUser.getUserId()); + userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",订单取消!"); + userMoneyDetails.setTitle("推广师傅收益"); + userMoneyDetails.setType(1); + userMoneyDetails.setClassify(6); + userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + + orders.setOneArtificerUserId(oneArtificerUser.getUserId()); + orders.setOneArtificerUserName(oneArtificerUser.getUserName()); + } + + if (orders.getShopUserId() != null) { + userMoneyService.updateMoney(1, orders.getShopUserId(), orders.getShopMoney().doubleValue()); + userMoneyDetails = new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney5 = userMoneyService.selectUserMoneyByUserId(orders.getShopUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney5.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(orders.getShopMoney()); + userMoneyDetails.setUserId(orders.getShopUserId()); + userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",订单取消!"); + userMoneyDetails.setTitle("商家收益"); + userMoneyDetails.setType(1); + userMoneyDetails.setClassify(7); + userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + } + + + } else { + orders.setShopMoney(BigDecimal.ZERO); + orders.setArtificerMoney(BigDecimal.ZERO); + orders.setSumArtificerMoney(BigDecimal.ZERO); + orders.setOneUserMoney(BigDecimal.ZERO); + orders.setOneArtificerMoney(BigDecimal.ZERO); + orders.setPingMoney(BigDecimal.ZERO); + orders.setArtificerTaxiMoney(BigDecimal.ZERO); + orders.setPingTaxiMoney(BigDecimal.ZERO); + } + + + List ordersList = baseMapper.selectList(new QueryWrapper().isNotNull("pay_way").eq("parent_id", orders.getOrdersId())); + for (Orders orders1 : ordersList) { + if (orders1.getPayWay() == 1 || orders1.getPayWay() == 2 || orders1.getPayWay() == 3 || orders1.getPayWay() == 4) { + boolean refund = wxService.refund(orders1.getOrdersNo(), orders1.getPayMoney(), orders1.getPayMoney(), orders1.getPayWay()); + if (!refund) { + return Result.error("退款失败,请联系客服!"); + } + } else if (orders1.getPayWay() == 6) { + String data = aliPayController.alipayRefund(orders1.getOrdersNo(), orders1.getPayMoney()); + if (StringUtils.isNotBlank(data)) { + log.error(data); + JSONObject jsonObject = JSON.parseObject(data); + JSONObject alipay_trade_refund_response = jsonObject.getJSONObject("alipay_trade_refund_response"); + String code1 = alipay_trade_refund_response.getString("code"); + if (!"10000".equals(code1)) { + return Result.error("退款失败!" + alipay_trade_refund_response.getString("sub_msg")); + } + } else { + return Result.error("退款失败!"); + } + } else { + if (orders1.getUserArtificerMoney() != null && orders1.getUserArtificerMoney() == 1) { + userMoneyArtificerService.updateMoney(1, orders1.getUserId(), orders1.getArtificerId(), orders1.getPayMoney().doubleValue()); + } else { + userMoneyService.updateMoney(1, orders1.getUserId(), orders1.getPayMoney().doubleValue()); + } + } + userMoneyDetails = new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney6 = userMoneyService.selectUserMoneyByUserId(orders1.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney6.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(orders1.getPayMoney()); + userMoneyDetails.setUserId(orders1.getUserId()); + userMoneyDetails.setContent("订单号:" + orders1.getOrdersNo() + ",已原路退款!"); + userMoneyDetails.setTitle("订单退款"); + userMoneyDetails.setType(1); + userMoneyDetails.setCreateTime(time); + userMoneyDetails.setArtificerId(orders.getArtificerId()); + + userMoneyDetailsService.save(userMoneyDetails); + orders1.setStatus(4); + baseMapper.updateById(orders1); + } + orders.setStatus(4); + + Artificer artificer = artificerService.getById(orders.getArtificerId()); + if (userId != null && artificer.getUserId().equals(userId)) { + BigDecimal newCreditScore = BigDecimal.ZERO; + MessageInfo messageInfo = new MessageInfo(); + messageInfo.setState("8"); + messageInfo.setUserId(String.valueOf(artificer.getUserId())); + messageInfo.setTitle("取消订单:" + orders.getOrdersNo()); + String value1 = commonInfoService.findOne(384).getValue(); + BigDecimal creditScore = new BigDecimal(value1); + newCreditScore = artificer.getCreditScore().subtract(creditScore); + messageInfo.setContent("扣除信誉分:" + creditScore); + artificer.setCreditScore(newCreditScore); + String value = commonInfoService.findOne(385).getValue(); + BigDecimal minScore = new BigDecimal(value); + if (artificer.getCreditScore().doubleValue() < minScore.doubleValue()) { + artificer.setStatus(2); + } + artificerService.updateById(artificer); + messageService.saveBody(messageInfo); + } + + + UserEntity userEntity = userService.selectUserById(orders.getUserId()); + + List ordersMassageList = ordersMassageService.list(new QueryWrapper().eq("orders_id", orders.getOrdersId())); + MassageType massageType = massageTypeService.getById(ordersMassageList.get(0).getMassageId()); + //超过十个字 则截取 + String content = massageType.getTitle(); + if (content.length() >= 15) { + content = content.substring(0, 15) + "..."; + } + + //消息推送 + if (StringUtils.isNotEmpty(userEntity.getOpenId())) { + CommonInfo one = commonInfoService.findOne(248); + List msgList = new ArrayList<>(); + msgList.add(orders.getOrdersNo()); + + msgList.add(content); + msgList.add("订单已取消,金额已原路退还!"); + SenInfoCheckUtil.sendMsg(userEntity.getOpenId(), one.getValue(), msgList, 2); + } + + if (StringUtils.isNotEmpty(userEntity.getClientid())) { + userService.pushToSingle("订单通知", "订单已取消,金额已原路退还!", userEntity.getClientid()); + } + + if (StringUtils.isNotBlank(userEntity.getWxOpenId())) { + String apkey = commonInfoService.findOne(313).getValue(); + LinkedHashMap data = new LinkedHashMap<>(); + data.put("character_string12", new TemplateMessageItem(orders.getOrdersNo(), "#d71345")); + data.put("thing17", new TemplateMessageItem(content, "#d71345")); + data.put("time14", new TemplateMessageItem(DateUtils.format(new Date()), "#d71345")); + userService.sendWxMessage(apkey, data, userEntity.getWxOpenId()); + } + } + + baseMapper.updateById(orders); + return Result.success(); + } + + + @Override + public Result refundOrdersMoney(Long ordersId, BigDecimal refundMoney) { + Orders orders = baseMapper.selectById(ordersId); + //状态 1待支付 2待服务 3待评论 4已取消 5已完成 6进行中 7技师出发 8技师到达 + if (orders.getStatus() == 4) { + return Result.error("订单已经取消了!"); + } + artificerTimeService.remove(new QueryWrapper().eq("orders_id", ordersId)); + + if (orders.getCouponId() != null) { + CouponUser couponUser = couponUserService.getById(orders.getCouponId()); + if (couponUser != null && couponUser.getStatus().equals(1)) { + couponUser.setStatus(0); + couponUserService.updateById(couponUser); + } + } + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String time = simpleDateFormat.format(new Date()); + BigDecimal refundMoneys = BigDecimal.ZERO; + if (orders.getSumMoney().doubleValue() < refundMoney.doubleValue()) { + return Result.error("退款金额不能大于支付金额!"); + } + //判断退款金额是否大于单笔支付的金额 如果大于 则代表 有加钟项目 + if (orders.getPayMoney().doubleValue() < refundMoney.doubleValue()) { + refundMoney = orders.getPayMoney(); + refundMoneys = refundMoney.subtract(orders.getPayMoney()); + } + + + if (orders.getPayWay() == 1 || orders.getPayWay() == 2 || orders.getPayWay() == 3 || orders.getPayWay() == 4) { + boolean refund = wxService.refund(orders.getOrdersNo(), orders.getPayMoney(), refundMoney, orders.getPayWay()); + if (!refund) { + return Result.error("退款失败,请联系客服!"); + } + } else if (orders.getPayWay() == 6) { + String data = aliPayController.alipayRefund(orders.getOrdersNo(), refundMoney); + if (StringUtils.isNotBlank(data)) { + log.error(data); + JSONObject jsonObject = JSON.parseObject(data); + JSONObject alipay_trade_refund_response = jsonObject.getJSONObject("alipay_trade_refund_response"); + String code1 = alipay_trade_refund_response.getString("code"); + if (!"10000".equals(code1)) { + return Result.error("退款失败!" + alipay_trade_refund_response.getString("sub_msg")); + } + } else { + return Result.error("退款失败!"); + } + } else { + if (orders.getUserArtificerMoney() != null && orders.getUserArtificerMoney() == 1) { + userMoneyArtificerService.updateMoney(1, orders.getUserId(), orders.getArtificerId(), refundMoney.doubleValue()); + } else { + userMoneyService.updateMoney(1, orders.getUserId(), refundMoney.doubleValue()); + } + } + UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney1 = userMoneyService.selectUserMoneyByUserId(orders.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney1.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(refundMoney); + userMoneyDetails.setUserId(orders.getUserId()); + userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",已原路退款!"); + userMoneyDetails.setTitle("订单退款"); + userMoneyDetails.setType(1); + userMoneyDetails.setCreateTime(time); + userMoneyDetails.setArtificerId(orders.getArtificerId()); + userMoneyDetailsService.save(userMoneyDetails); + + if (refundMoneys.doubleValue() > 0) { + List ordersList = baseMapper.selectList(new QueryWrapper().isNotNull("pay_way").eq("parent_id", orders.getOrdersId())); + for (Orders orders1 : ordersList) { + BigDecimal refundMoney1 = BigDecimal.ZERO; + if (orders1.getPayMoney().doubleValue() < refundMoneys.doubleValue()) { + refundMoneys = refundMoneys.subtract(orders1.getPayMoney()); + refundMoney1 = orders1.getPayMoney(); + } else { + refundMoney1 = refundMoneys; + refundMoneys = BigDecimal.ZERO; + } + + if (orders1.getPayWay() == 1 || orders1.getPayWay() == 2 || orders1.getPayWay() == 3 || orders1.getPayWay() == 4) { + boolean refund = wxService.refund(orders1.getOrdersNo(), orders1.getPayMoney(), refundMoney1, orders1.getPayWay()); + if (!refund) { + return Result.error("退款失败,请联系客服!"); + } + } else if (orders1.getPayWay() == 6) { + String data = aliPayController.alipayRefund(orders1.getOrdersNo(), refundMoney1); + if (StringUtils.isNotBlank(data)) { + log.error(data); + JSONObject jsonObject = JSON.parseObject(data); + JSONObject alipay_trade_refund_response = jsonObject.getJSONObject("alipay_trade_refund_response"); + String code1 = alipay_trade_refund_response.getString("code"); + if (!"10000".equals(code1)) { + return Result.error("退款失败!" + alipay_trade_refund_response.getString("sub_msg")); + } + } else { + return Result.error("退款失败!"); + } + } else { + if (orders1.getUserArtificerMoney() != null && orders1.getUserArtificerMoney() == 1) { + userMoneyArtificerService.updateMoney(1, orders1.getUserId(), orders1.getArtificerId(), refundMoney1.doubleValue()); + } else { + userMoneyService.updateMoney(1, orders1.getUserId(), refundMoney1.doubleValue()); + } + } + userMoneyDetails = new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney8 = userMoneyService.selectUserMoneyByUserId(orders1.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney8.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(refundMoney1); + userMoneyDetails.setUserId(orders1.getUserId()); + userMoneyDetails.setContent("订单号:" + orders1.getOrdersNo() + ",已原路退款!"); + userMoneyDetails.setTitle("订单退款"); + userMoneyDetails.setType(1); + userMoneyDetails.setCreateTime(time); + userMoneyDetails.setArtificerId(orders.getArtificerId()); + + userMoneyDetailsService.save(userMoneyDetails); + orders1.setStatus(4); + baseMapper.updateById(orders1); + if (refundMoneys.doubleValue() <= 0) { + break; + } + } + } + + orders.setShopMoney(BigDecimal.ZERO); + orders.setArtificerMoney(BigDecimal.ZERO); + orders.setSumArtificerMoney(BigDecimal.ZERO); + orders.setOneUserMoney(BigDecimal.ZERO); + orders.setOneArtificerMoney(BigDecimal.ZERO); + orders.setPingMoney(BigDecimal.ZERO); + orders.setArtificerTaxiMoney(BigDecimal.ZERO); + orders.setPingTaxiMoney(BigDecimal.ZERO); + orders.setStatus(4); + UserEntity userEntity = userService.selectUserById(orders.getUserId()); + + List ordersMassageList = ordersMassageService.list(new QueryWrapper().eq("orders_id", orders.getOrdersId())); + MassageType massageType = massageTypeService.getById(ordersMassageList.get(0).getMassageId()); + //超过十个字 则截取 + String content = massageType.getTitle(); + if (content.length() >= 15) { + content = content.substring(0, 15) + "..."; + } + + //消息推送 + if (StringUtils.isNotEmpty(userEntity.getOpenId())) { + CommonInfo one = commonInfoService.findOne(248); + List msgList = new ArrayList<>(); + msgList.add(orders.getOrdersNo()); + + msgList.add(content); + msgList.add("订单已取消,金额已原路退款!"); + SenInfoCheckUtil.sendMsg(userEntity.getOpenId(), one.getValue(), msgList, 2); + } + + if (StringUtils.isNotEmpty(userEntity.getClientid())) { + userService.pushToSingle("订单通知", "订单已取消,金额已原路退款!", userEntity.getClientid()); + } + + if (StringUtils.isNotBlank(userEntity.getWxOpenId())) { + String apkey = commonInfoService.findOne(313).getValue(); + LinkedHashMap data = new LinkedHashMap<>(); + data.put("character_string12", new TemplateMessageItem(orders.getOrdersNo(), "#d71345")); + data.put("thing17", new TemplateMessageItem(content, "#d71345")); + data.put("time14", new TemplateMessageItem(DateUtils.format(new Date()), "#d71345")); + userService.sendWxMessage(apkey, data, userEntity.getWxOpenId()); + } + + + baseMapper.updateById(orders); + return Result.success(); + } + + @Override + public Result removeOrders(Long ordersId) { + Orders orders = baseMapper.selectById(ordersId); + if (orders.getStatus().equals(2)) { + return Result.error("订单正在进行中!"); + } + artificerTimeService.remove(new QueryWrapper().eq("orders_id", ordersId)); + + if (orders.getCouponId() != null) { + CouponUser couponUser = couponUserService.getById(orders.getCouponId()); + if (couponUser != null && couponUser.getStatus().equals(1)) { + couponUser.setStatus(0); + couponUserService.updateById(couponUser); + } + } + baseMapper.deleteById(ordersId); + return Result.success(); + } + + + @Override + public Result selectOrdersDetails(Long ordersId) { + Orders orders = baseMapper.selectById(ordersId); + List ordersMassageList = ordersMassageService.list(new QueryWrapper().eq("orders_id", ordersId)); + for (OrdersMassage ordersMassage : ordersMassageList) { + ordersMassage.setMassageType(massageTypeService.getById(ordersMassage.getMassageId())); + } + orders.setOrdersMassageList(ordersMassageList); + Artificer artificer = artificerService.getById(orders.getArtificerId()); + if (artificer != null) { + UserEntity userEntity = userService.selectUserById(artificer.getUserId()); + if (userEntity != null) { + artificer.setPhone(userEntity.getPhone()); + } + orders.setArtificer(artificer); + } + return Result.success().put("data", orders); + } + + @Override + public Result selectOrdersList(Long userId, Integer page, Integer limit, Integer status, String city, + String name, String phone, Long artificerId, Long parentId, String startTime, + String endTime, Integer isAdd, String ordersNo, String artificerName, + String oneUserName, String oneArtificerUserName, + String startServeTime, String endServeTime, Integer overTimeOrders, + Long shopId, String shopName, Integer warning, String title, String classifyId) { + Page pages = new Page<>(page, limit); + IPage ordersIPage = baseMapper.selectOrdersList(pages, userId, status, + city, name, phone, artificerId, parentId, startTime, endTime, isAdd, ordersNo, + artificerName, oneUserName, oneArtificerUserName, startServeTime, endServeTime, overTimeOrders, shopId, shopName, warning, title, classifyId); + List records = ordersIPage.getRecords(); + for (Orders orders : records) { + List ordersMassageList = ordersMassageService.list(new QueryWrapper().eq("orders_id", orders.getOrdersId())); + for (OrdersMassage ordersMassage : ordersMassageList) { + MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId()); + ordersMassage.setMassageType(massageType); + if (massageType != null) { + SysDictEntity sysDictEntity = sysDictService.getById(massageType.getClassifyId()); + if (sysDictEntity != null) { + massageType.setClassifyName(sysDictEntity.getValue()); + } + } + } + orders.setOrdersMassageList(ordersMassageList); + } + return Result.success().put("data", new PageUtils(ordersIPage)); + } + + @Override + public ExcelData excelOrdersList(Long userId, Integer status, String city, + String name, String phone, Long artificerId, Long parentId, String startTime, + String endTime, Integer isAdd, String ordersNo, String artificerName, + String oneUserName, String oneArtificerUserName, + String startServeTime, String endServeTime, Integer overTimeOrders, Long shopId, + String shopName, Integer warning, String title, String classifyId) { + List ordersList = baseMapper.excelOrdersList(userId, status, city, name, phone, artificerId, + parentId, startTime, endTime, isAdd, ordersNo, artificerName, oneUserName, oneArtificerUserName, + startServeTime, endServeTime, overTimeOrders, shopId, shopName, warning, title, classifyId); + ExcelData data = new ExcelData(); + data.setName("订单列表"); + List titles = new ArrayList(); + titles.add("编号"); + titles.add("下单用户"); + titles.add("技师用户"); + titles.add("订单编号"); + titles.add("商家名称"); + titles.add("项目价格"); + titles.add("优惠券名称"); + titles.add("优惠券金额"); + titles.add("技师收益"); + titles.add("支付金额"); + titles.add("打车费"); + titles.add("推广用户名称"); + titles.add("推广用户佣金"); + titles.add("推广技师名称"); + titles.add("推广技师佣金"); + titles.add("商家收益"); + titles.add("平台收益"); + titles.add("加钟价格"); + titles.add("加钟时长"); + titles.add("加钟次数"); + titles.add("加钟师傅收益"); + titles.add("技师总收益"); + titles.add("订单总金额"); + titles.add("支付方式"); + titles.add("联系电话"); + titles.add("服务地址"); + titles.add("预约时间"); + titles.add("备注"); + titles.add("开始服务时间"); + titles.add("预估结束时间"); + titles.add("订单完成时间"); + titles.add("商家电话"); + titles.add("商家地址"); + titles.add("创建时间"); + titles.add("是否超时"); + titles.add("是否加钟"); + titles.add("订单状态"); + data.setTitles(titles); + List> rows = new ArrayList(); + for (Orders order : ordersList) { + List row = new ArrayList(); + row.add(order.getOrdersId()); + row.add(order.getUserName()); + row.add(order.getArtificerName()); + row.add(order.getOrdersNo()); + if (StringUtils.isNotBlank(order.getShopName())) { + row.add(order.getShopName()); + } else { + row.add(""); + } + row.add(order.getPrice()); + row.add(order.getCouponName()); + row.add(order.getCouponMoney()); + row.add(order.getArtificerMoney()); + row.add(order.getPayMoney()); + row.add(order.getTaxiMoney()); + row.add(order.getOneUserName()); + row.add(order.getOneUserMoney()); + row.add(order.getOneArtificerUserName()); + row.add(order.getOneArtificerMoney()); + row.add(order.getShopMoney()); + row.add(order.getPingMoney()); + row.add(order.getAddMoney()); + row.add(order.getAddTime()); + row.add(order.getAddNum()); + row.add(order.getAddArtificerMoney()); + row.add(order.getSumArtificerMoney()); + row.add(order.getSumMoney()); + if (order.getPayWay() == null) { + row.add("待支付"); + } else if (order.getPayWay() == 1) { + row.add("app微信"); + } else if (order.getPayWay() == 2) { + row.add("微信公众号"); + } else if (order.getPayWay() == 3) { + row.add("微信小程序"); + } else if (order.getPayWay() == 4) { + row.add("支付宝"); + } else { + row.add("零钱"); + } + row.add(order.getPhone()); + row.add(order.getAddress()); + row.add(order.getServeTime()); + row.add(order.getRemark()); + row.add(order.getStartTime()); + row.add(order.getEndTime()); + row.add(order.getEndTimes()); + row.add(order.getShopPhone()); + row.add(order.getShopAddress()); + row.add(order.getCreateTime()); + if (order.getOverTimeOrders() != null && order.getOverTimeOrders() == 1) { + row.add("是"); + } else { + row.add("否"); + } + if (order.getAddNum() != null && order.getAddNum() > 0) { + row.add("是"); + } else { + row.add("否"); + } + if (order.getStatus().equals(1)) { + row.add("待支付"); + } else if (order.getStatus().equals(2)) { + row.add("待服务"); + } else if (order.getStatus().equals(3)) { + row.add("待评论"); + } else if (order.getStatus().equals(4)) { + row.add("已取消"); + } else if (order.getStatus().equals(5)) { + row.add("已完成"); + } else if (order.getStatus().equals(6)) { + row.add("进行中"); + } else if (order.getStatus().equals(7)) { + row.add("技师出发"); + } else if (order.getStatus().equals(8)) { + row.add("技师到达"); + } else { + row.add("未知"); + } + rows.add(row); + } + data.setRows(rows); + return data; + } + + + @Override + public Orders selectOrdersByOrderNo(String ordersNo) { + return baseMapper.selectOne(new QueryWrapper().eq("orders_no", ordersNo)); + } + + @Override + public Result payOrders(Long ordersId, Integer type) { + reentrantReadWriteLock.writeLock().lock(); + try { + Orders orders = baseMapper.selectById(ordersId); + if (orders == null) { + return Result.error("订单生成失败,请重新下单!"); + } else if (orders.getStatus() != 1) { + return Result.error("订单状态异常,请刷新页面后重试!"); + } + + UserMoneyArtificer userMoneyArtificer = userMoneyArtificerService.getOne(new QueryWrapper().eq("user_id", orders.getUserId()).eq("artificer_id", orders.getArtificerId())); + if (userMoneyArtificer != null && userMoneyArtificer.getMoney().doubleValue() >= orders.getPayMoney().doubleValue()) { + type = 2; + } else { + type = 1; + UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(orders.getUserId()); + if (userMoney.getMoney().doubleValue() < orders.getPayMoney().doubleValue()) { + return Result.error("钱包余额不足,请充值!"); + } + } + + Integer duration = 0; + if (orders.getParentId() != null && orders.getParentId() != 0) { + Orders orders1 = baseMapper.selectById(orders.getParentId()); + OrdersMassage ordersMassage = ordersMassageService.getOne(new QueryWrapper().eq("orders_id", orders1.getOrdersId())); + MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId()); + if (massageType.getAddNum() == null || massageType.getAddNum() == 0) { + return Result.error("当前项目不允许加钟!"); + } else if (massageType.getAddNum() > 0) { + if (orders1.getAddNum() != null && orders1.getAddNum() >= massageType.getAddNum()) { + return Result.error("当前项目已超过最大加钟次数!"); + } + } + duration = massageType.getDuration(); + String value1 = commonInfoService.findOne(395).getValue(); + if ("是".equals(value1)) { + String value = commonInfoService.findOne(392).getValue(); + int minute = Integer.parseInt(value); + int i = 1; + if (duration % minute == 0) { + i = duration / minute; + } else { + i = duration / minute; + i++; + } + ArtificerTime artificerTime = artificerTimeService.getOne(new QueryWrapper().eq("orders_id", orders.getParentId()).last(" order by artificer_time_id desc limit 1 ")); + String serveTime = artificerTime.getArtificerDate() + " " + artificerTime.getArtificerTime(); + String date = null; + String time = null; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date parse = sdf.parse(serveTime); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(parse); + for (int j = 0; j < i; j++) { + calendar.add(Calendar.MINUTE, minute); + String format = sdf.format(calendar.getTime()); + date = format.substring(0, 10); + time = format.substring(11, 16); + artificerTime = artificerTimeService.getOne( + new QueryWrapper() + .eq("artificer_id", orders.getArtificerId()) + .eq("artificer_date", date).eq("artificer_time", time)); + if (artificerTime != null) { + return Result.error("预约时间正忙,请更换其他时间!"); + } + } + + SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + calendar.setTime(parse); + for (int j = 0; j < i; j++) { + calendar.add(Calendar.MINUTE, minute); + String format = sdf1.format(calendar.getTime()); + date = format.substring(0, 10); + time = format.substring(11, 16); + artificerTime = new ArtificerTime(); + artificerTime.setArtificerId(orders.getArtificerId()); + artificerTime.setArtificerDate(date); + artificerTime.setArtificerTime(time); + artificerTime.setClassify(1); + artificerTime.setOrdersId(orders.getParentId()); + artificerTime.setCreateTime(DateUtils.format(new Date())); + artificerTimeService.save(artificerTime); + } + } + + } + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (type == 2) { + userMoneyArtificerService.updateMoney(2, orders.getUserId(), orders.getArtificerId(), orders.getPayMoney().doubleValue()); + UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); + userMoneyDetails.setClassify(8); + userMoneyDetails.setMoney(orders.getPayMoney()); + userMoneyDetails.setUserId(orders.getUserId()); + userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",已经下单成功!"); + userMoneyDetails.setTitle("储蓄金支付订单"); + userMoneyDetails.setType(2); + userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date())); + userMoneyDetails.setArtificerId(orders.getArtificerId()); + userMoneyDetailsService.save(userMoneyDetails); + orders.setUserArtificerMoney(1); + } else { + userMoneyService.updateMoney(2, orders.getUserId(), orders.getPayMoney().doubleValue()); + UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(orders.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(orders.getPayMoney()); + userMoneyDetails.setUserId(orders.getUserId()); + userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",已经下单成功!"); + userMoneyDetails.setTitle("支付订单"); + userMoneyDetails.setType(2); + userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + } + + + orders.setStatus(2); + orders.setPayWay(5); + orders.setPayTime(simpleDateFormat.format(new Date())); + + BigDecimal pingMoney = orders.getPayMoney(); + UserEntity user = userService.selectUserById(orders.getUserId()); + + UserEntity oneUser = userService.queryByInvitationCode(user.getInviterCode()); + + BigDecimal oneUserMoney = BigDecimal.ZERO; + if (oneUser != null && oneUser.getIsAgency() != null && oneUser.getIsAgency() == 1) { + orders.setOneUserId(oneUser.getUserId()); + orders.setOneUserName(oneUser.getUserName()); + oneUserMoney = pingMoney.multiply(oneUser.getUserRate()); + } + + Artificer artificer = artificerService.getById(orders.getArtificerId()); + + UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); + + UserEntity oneArtificerUser = userService.queryByInvitationCode(artificerUser.getInviterCode()); + + BigDecimal oneArtificerMoney = BigDecimal.ZERO; + if (oneArtificerUser != null && oneArtificerUser.getIsAgency() != null && oneArtificerUser.getIsAgency() == 1) { + orders.setOneArtificerUserId(oneArtificerUser.getUserId()); + orders.setOneArtificerUserName(oneArtificerUser.getUserName()); + oneArtificerMoney = pingMoney.multiply(oneArtificerUser.getShopRate()); + } + + BigDecimal shopMoney = BigDecimal.ZERO; + if (artificerUser.getConsortiaId() != null) { + Consortia consortia = consortiaService.getById(artificerUser.getConsortiaId()); + if (consortia != null && consortia.getUserId() != null) { + UserEntity consortiaUser = userService.getById(consortia.getUserId()); + if (consortiaUser != null) { + shopMoney = pingMoney.multiply(consortia.getRate()); + orders.setConsortiaId(consortia.getConsortiaId()); + orders.setShopUserId(consortiaUser.getUserId()); + orders.setShopUserName(consortiaUser.getUserName()); + } + } + } + pingMoney = pingMoney.subtract(orders.getArtificerMoney()); + pingMoney = pingMoney.subtract(oneUserMoney); + pingMoney = pingMoney.subtract(shopMoney); + pingMoney = pingMoney.subtract(oneArtificerMoney); + orders.setShopMoney(shopMoney); + orders.setOneUserMoney(oneUserMoney); + orders.setOneArtificerMoney(oneArtificerMoney); + orders.setPingMoney(pingMoney); + baseMapper.updateById(orders); + if (orders.getParentId() != null && orders.getParentId() != 0) { + Orders orders1 = baseMapper.selectById(orders.getParentId()); + if (orders1.getAddNum() == null) { + orders1.setAddNum(1); + } else { + orders1.setAddNum(orders1.getAddNum() + 1); + } + //获取加钟项目的时长 + if (orders1.getAddTime() != null) { + orders1.setAddTime(orders1.getAddTime() + orders.getAddTime()); + } else { + orders1.setAddTime(orders.getAddTime()); + } + boolean flag = false; + if (StringUtils.isNotBlank(orders1.getEndTime())) { + Calendar calendar = Calendar.getInstance(); + Date date = DateUtils.stringToDate(orders1.getEndTime(), "yyyy-MM-dd HH:mm:ss"); + calendar.setTime(date); + calendar.add(Calendar.MINUTE, orders.getAddTime()); + orders1.setEndTime(DateUtils.format(calendar.getTime())); + flag = true; + } + if (orders1.getAddMoney() != null) { + orders1.setAddMoney(orders1.getAddMoney().add(orders.getPayMoney())); + orders1.setAddArtificerMoney(orders1.getAddArtificerMoney().add(orders.getArtificerMoney())); + } else { + orders1.setAddMoney(orders.getPayMoney()); + orders1.setAddArtificerMoney(orders.getArtificerMoney()); + } + orders1.setSumMoney(orders1.getSumMoney().add(orders.getPayMoney())); + orders1.setSumArtificerMoney(orders1.getSumArtificerMoney().add(orders.getArtificerMoney())); + pingMoney = orders1.getSumMoney(); + oneUserMoney = BigDecimal.ZERO; + if (oneUser != null && oneUser.getIsAgency() != null && oneUser.getIsAgency() == 1) { + oneUserMoney = pingMoney.multiply(oneUser.getUserRate()); + } + oneArtificerMoney = BigDecimal.ZERO; + if (oneArtificerUser != null && oneArtificerUser.getIsAgency() != null && oneArtificerUser.getIsAgency() == 1) { + oneArtificerMoney = pingMoney.multiply(oneArtificerUser.getShopRate()); + } + shopMoney = BigDecimal.ZERO; + if (artificerUser.getConsortiaId() != null) { + Consortia consortia = consortiaService.getById(artificerUser.getConsortiaId()); + if (consortia != null && consortia.getUserId() != null) { + UserEntity consortiaUser = userService.getById(consortia.getUserId()); + if (consortiaUser != null) { + shopMoney = pingMoney.multiply(consortia.getRate()); + + } + } + } + pingMoney = pingMoney.subtract(orders1.getSumArtificerMoney()); + pingMoney = pingMoney.subtract(oneUserMoney); + pingMoney = pingMoney.subtract(oneArtificerMoney); + pingMoney = pingMoney.subtract(shopMoney); + orders1.setShopMoney(shopMoney); + orders1.setOneUserMoney(oneUserMoney); + orders1.setOneArtificerMoney(oneArtificerMoney); + orders1.setPingMoney(pingMoney); + if (orders1.getStatus().equals(6)) { + String endTime = orders1.getEndTime(); + Date date = DateUtils.stringToDate(endTime, "yyyy-MM-dd HH:mm:ss"); + Calendar calendar = Calendar.getInstance(); + if (date.getTime() > System.currentTimeMillis()) { + calendar.setTime(date); + } + calendar.add(Calendar.MINUTE, duration); + orders1.setEndTime(endTime); + } + + baseMapper.updateById(orders1); + if (flag) { + baseMapper.update(null, Wrappers.lambdaUpdate() + .set(Orders::getWarning, null) + .eq(Orders::getOrdersId, orders1.getOrdersId())); + } + } else { + MessageInfo messageInfo = new MessageInfo(); + messageInfo.setState("16"); + messageInfo.setTitle("新订单通知"); + messageInfo.setUserId("0"); + messageInfo.setIsSee("0"); + messageService.saveBody(messageInfo); + } + sendMsg(orders); + + return Result.success(); + } catch (Exception e) { + e.printStackTrace(); + log.error("钱包支付订单异常:" + e.getMessage(), e); + } finally { + reentrantReadWriteLock.writeLock().unlock(); + } + return Result.error("系统繁忙,请稍后再试!"); + + } + @Override + public void sendMsg(Orders orders) { + try { + String adminPhone = commonInfoService.findOne(393).getValue(); + if (StringUtils.isNotBlank(adminPhone)) { + singleThreadPool.submit(new Runnable() { + @Override + public void run() { + userService.sendMsg(adminPhone, "send"); + } + }); + } + Artificer artificer = artificerService.getById(orders.getArtificerId()); + MessageInfo messageInfo = new MessageInfo(); + messageInfo.setState("51"); + messageInfo.setUserId(String.valueOf(artificer.getUserId())); + messageInfo.setIsSee("0"); + messageInfo.setTitle("新订单提醒"); + messageInfo.setCreateAt(DateUtils.format(new Date())); + messageService.save(messageInfo); + UserEntity userEntity = userService.selectUserById(artificer.getUserId()); + //消息推送 + List ordersMassageList = ordersMassageService.list(new QueryWrapper().eq("orders_id", orders.getOrdersId())); + MassageType massageType = massageTypeService.getById(ordersMassageList.get(0).getMassageId()); + //超过十个字 则截取 + String content = massageType.getTitle(); + if (content.length() >= 15) { + content = content.substring(0, 15) + "..."; + } + if (userEntity != null) { + if (StringUtils.isNotEmpty(userEntity.getArtificerOpenId())) { + CommonInfo one = commonInfoService.findOne(247); + List msgList = new ArrayList<>(); + msgList.add(orders.getOrdersNo()); + msgList.add(content); + msgList.add(orders.getCreateTime()); + msgList.add("用户已经下单,请尽快联系!"); + SenInfoCheckUtil.sendMsg(userEntity.getArtificerOpenId(), one.getValue(), msgList, 1); + } + if (StringUtils.isNotEmpty(userEntity.getClientid())) { + userService.pushToSingle("订单通知", "用户已经下单,请尽快联系!", userEntity.getClientid()); + } + /*if(StringUtils.isNotBlank(userEntity.getWxOpenId())){ + String apkey = commonInfoService.findOne(312).getValue(); + LinkedHashMap data = new LinkedHashMap<>(); + data.put("thing1", new TemplateMessageItem(content, "#d71345")); + data.put("time4", new TemplateMessageItem(orders.getServeTime(), "#d71345")); + data.put("thing2", new TemplateMessageItem(orders.getUserName(), "#d71345")); + data.put("phone_number3", new TemplateMessageItem(orders.getPhone(), "#d71345")); + String address=orders.getAddress(); + if(address.length()>15){ + address=address.substring(0,15)+"..."; + } + data.put("thing5", new TemplateMessageItem(address, "#d71345")); + userService.sendWxMessage(apkey, data, userEntity.getWxOpenId()); + }*/ + + singleThreadPool.submit(new Runnable() { + @Override + public void run() { +// sendAliPhone(userEntity.getPhone(), 1); + } + }); + } + CommonInfo one = commonInfoService.findOne(251); + if ("是".equals(one.getValue())) { + if (userEntity != null && StringUtils.isNotEmpty(userEntity.getPhone())) { + userService.sendMsg(userEntity.getPhone(), "send"); + } + } + } catch (Exception e) { + e.printStackTrace(); + log.error("消息推送异常:" + e.getMessage(), e); + } + + } + + + @Override + public Result payUserVip(Long userId, Long vipDetailsId) { + VipDetails vipDetails = vipDetailsDao.selectOne(new QueryWrapper().eq("id", vipDetailsId)); + BigDecimal money = vipDetails.getMoney(); + UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(userId); + if (userMoney.getMoney().doubleValue() < money.doubleValue()) { + return Result.error("钱包余额不足,请充值!"); + } + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + UserEntity userEntity = userService.selectUserById(userId); + UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); + MessageInfo messageInfo = new MessageInfo(); + userMoneyDetails.setMoney(money); + userMoneyDetails.setUserId(userId); + + //查看用户是否是会员 + UserVip userVip = userVipDao.selectOne(new QueryWrapper().eq("user_id", userId)); + Calendar cal = Calendar.getInstance(); + if (userVip != null) { + Date endDate = null; + try { + endDate = simpleDateFormat.parse(userVip.getEndTime()); + if (endDate != null && System.currentTimeMillis() < (endDate.getTime())) { + cal.setTime(endDate); + } + } catch (Exception e) { + e.getMessage(); + } + } else { + userVip = new UserVip(); + //设置会员类型 + userVip.setVipNameType(vipDetails.getVipNameType()); + //设置开通会员的用户id + userVip.setUserId(userId); + //设置会员的购买时间 + userVip.setCreateTime(simpleDateFormat.format(new Date())); + } + + if ((vipDetails.getVipNameType().equals(0))) { + //月 + userMoneyDetails.setContent("开通月卡会员"); + messageInfo.setContent("订单下单成功"); + cal.add(Calendar.MONTH, 1); + } else if ((vipDetails.getVipNameType()).equals(1)) { + //季 + userMoneyDetails.setContent("开通季卡会员"); + messageInfo.setContent("订单下单成功"); + cal.add(Calendar.MONTH, 3); + } else { + //年 + userMoneyDetails.setContent("开通年费会员"); + messageInfo.setContent("开通年费会员"); + cal.add(Calendar.YEAR, 1); + } + + userVip.setEndTime(simpleDateFormat.format(cal.getTime())); + if (userVip.getVipId() != null) { + userVipDao.updateById(userVip); + } else { + userVipDao.insert(userVip); + } + + //修改我的的余额 + userMoneyService.updateMoney(2, userId, money.doubleValue()); + + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(userId); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setTitle("开通会员"); + userMoneyDetails.setType(2); + userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + messageInfo.setTitle("开通会员"); + messageInfo.setState(String.valueOf(4)); + messageInfo.setUserName(userEntity.getUserName()); + messageInfo.setUserId(String.valueOf(userEntity.getUserId())); + messageInfo.setCreateAt(simpleDateFormat.format(new Date())); + messageInfo.setIsSee("0"); + messageService.saveBody(messageInfo); + if (StringUtil.isNotBlank(userEntity.getClientid())) { + userService.pushToSingle(messageInfo.getTitle(), messageInfo.getContent(), userEntity.getClientid()); + } + + return Result.success(); + } + + + @Override + public Result accomplishOrders(Long ordersId, Integer type, String accomplishLongitude, String accomplishLatitude) { + reentrantReadWriteLock.writeLock().lock(); + try { + Orders orders = baseMapper.selectById(ordersId); + if (StringUtil.isEmpty(accomplishLatitude)) { + return Result.error("技师定位异常,请检查定位!"); + } + if (type == 1) { + if (orders.getStatus().equals(1)) { + return Result.error("订单未付款!"); + } else if (orders.getStatus().equals(3) || orders.getStatus().equals(5)) { + return Result.error("订单已经完成了!"); + } else if (orders.getStatus().equals(4)) { + return Result.error("订单已经取消!"); + } + } else { + if (!orders.getStatus().equals(6)) { + return Result.error("请刷新页面后重试!"); + } + GlobalCoordinates source = new GlobalCoordinates(Double.parseDouble(orders.getLatitude()), Double.parseDouble(orders.getLongitude())); + GlobalCoordinates target = new GlobalCoordinates(Double.parseDouble(accomplishLatitude), Double.parseDouble(accomplishLongitude)); + Integer distances = (int) LonLatUtil.getDistanceMeter(source, target, Ellipsoid.Sphere); + String value = commonInfoService.findOne(373).getValue(); + if (distances < Integer.parseInt(value)) { + return Result.error("请离开当前位置" + value + "m后点击完成!"); + } + } + String accomplishAddress = CommonMapUtils.getLocationToAddress(accomplishLongitude, accomplishLatitude);//按坐标获取地理位置 + orders.setAccomplishAddress(accomplishAddress); + Artificer artificer = artificerService.getById(orders.getArtificerId()); + List ordersMassageList = ordersMassageService.list(new QueryWrapper().eq("orders_id", orders.getOrdersId())); + artificer.setArtificerSales(artificer.getArtificerSales() + ordersMassageList.size()); + artificerService.updateById(artificer); + + for (OrdersMassage ordersMassage : ordersMassageList) { + MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId()); + int num = massageType.getSales() == null ? 0 : massageType.getSales(); + massageType.setSales(num + ordersMassage.getNum()); + massageTypeService.updateById(massageType); + } + UserEntity userEntity = userService.selectUserById(artificer.getUserId()); + userMoneyService.updateMoney(1, userEntity.getUserId(), orders.getSumArtificerMoney().doubleValue()); + UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney1 = userMoneyService.selectUserMoneyByUserId(userEntity.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney1.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(orders.getSumArtificerMoney()); + userMoneyDetails.setUserId(userEntity.getUserId()); + userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",订单完成!"); + String value = commonInfoService.findOne(394).getValue(); + if ("是".equals(value)) { + if (orders.getShopUserId() != null) { + userMoneyDetails.setTitle("支付金额:" + orders.getSumMoney() + ",平台扣除:" + orders.getPingMoney() + + ",商家扣除:" + orders.getShopMoney() + ",用户代理扣除:" + orders.getOneUserMoney() + ",技师代理扣除:" + orders.getOneArtificerMoney() + + ",打车费:" + orders.getTaxiMoney() + ",平台扣除打车费:" + orders.getPingTaxiMoney() + ",到账打车费:" + orders.getArtificerTaxiMoney() + + ",到账总金额:" + orders.getSumArtificerMoney()); + } else { + userMoneyDetails.setTitle("支付金额:" + orders.getSumMoney() + ",平台扣除:" + orders.getPingMoney() + + ",用户代理扣除:" + orders.getOneUserMoney() + ",技师代理扣除:" + orders.getOneArtificerMoney() + + ",打车费:" + orders.getTaxiMoney() + ",平台扣除打车费:" + orders.getPingTaxiMoney() + ",到账打车费:" + orders.getArtificerTaxiMoney() + + ",到账总金额:" + orders.getSumArtificerMoney()); + } + } else { + if (orders.getShopUserId() != null) { + userMoneyDetails.setTitle("支付金额:" + orders.getSumMoney() + ",平台扣除:" + orders.getPingMoney() + + ",商家扣除:" + orders.getShopMoney() + ",用户代理扣除:" + orders.getOneUserMoney() + ",技师代理扣除:" + orders.getOneArtificerMoney() + + ",打车费:" + orders.getTaxiMoney() + + ",到账总金额:" + orders.getSumArtificerMoney()); + } else { + userMoneyDetails.setTitle("支付金额:" + orders.getSumMoney() + ",平台扣除:" + orders.getPingMoney() + + ",用户代理扣除:" + orders.getOneUserMoney() + ",技师代理扣除:" + orders.getOneArtificerMoney() + + ",打车费:" + orders.getTaxiMoney() + + ",到账总金额:" + orders.getSumArtificerMoney()); + } + } + userMoneyDetails.setType(1); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + orders.setStatus(3); + orders.setAccomplishLatitude(accomplishLatitude); + orders.setAccomplishLongitude(accomplishLongitude); + UserEntity user = userService.selectUserById(orders.getUserId()); + UserEntity oneUser = userService.queryByInvitationCode(user.getInviterCode()); + if (oneUser != null && oneUser.getIsAgency() != null && oneUser.getIsAgency() == 1) { + userMoneyService.updateMoney(1, oneUser.getUserId(), orders.getOneUserMoney().doubleValue()); + userMoneyDetails = new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney11 = userMoneyService.selectUserMoneyByUserId(orders.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney11.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(orders.getOneUserMoney()); + userMoneyDetails.setUserId(oneUser.getUserId()); + userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",订单完成!"); + userMoneyDetails.setTitle("推广用户收益"); + userMoneyDetails.setType(1); + userMoneyDetails.setClassify(5); + userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + orders.setOneUserId(oneUser.getUserId()); + orders.setOneUserName(oneUser.getUserName()); + } + UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); + UserEntity oneArtificerUser = userService.queryByInvitationCode(artificerUser.getInviterCode()); + if (oneArtificerUser != null && oneArtificerUser.getIsAgency() != null && oneArtificerUser.getIsAgency() == 1) { + userMoneyService.updateMoney(1, oneArtificerUser.getUserId(), orders.getOneArtificerMoney().doubleValue()); + userMoneyDetails = new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney12 = userMoneyService.selectUserMoneyByUserId(oneArtificerUser.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney12.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(orders.getOneArtificerMoney()); + userMoneyDetails.setUserId(oneArtificerUser.getUserId()); + userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",订单完成!"); + userMoneyDetails.setTitle("推广师傅收益"); + userMoneyDetails.setType(1); + userMoneyDetails.setClassify(6); + userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + orders.setOneArtificerUserId(oneArtificerUser.getUserId()); + orders.setOneArtificerUserName(oneArtificerUser.getUserName()); + } + if (orders.getShopUserId() != null) { + userMoneyService.updateMoney(1, orders.getShopUserId(), orders.getShopMoney().doubleValue()); + userMoneyDetails = new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney9 = userMoneyService.selectUserMoneyByUserId(orders.getShopUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney9.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(orders.getShopMoney()); + userMoneyDetails.setUserId(orders.getShopUserId()); + userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",订单完成!"); + userMoneyDetails.setTitle("商家收益"); + userMoneyDetails.setType(1); + userMoneyDetails.setClassify(7); + userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + } + orders.setEndTimes(DateUtils.format(new Date())); + //修改订单表类型 + baseMapper.updateById(orders); + //修改订单下所有加钟的状态为待评价 + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("parent_id", orders.getOrdersId()); + Orders orders2 = new Orders(); + orders2.setStatus(3); + baseMapper.update(orders2,updateWrapper); + //消息推送 + List msgList = new ArrayList<>(); + msgList.add(orders.getOrdersNo()); + MassageType massageType = massageTypeService.getById(ordersMassageList.get(0).getMassageId()); + //超过十个字 则截取 + String content = massageType.getTitle(); + if (content.length() >= 15) { + content = content.substring(0, 15) + "..."; + } + msgList.add(content); + msgList.add(userMoneyDetails.getCreateTime()); + if (StringUtils.isNotEmpty(userEntity.getArtificerOpenId())) { + CommonInfo one = commonInfoService.findOne(249); + SenInfoCheckUtil.sendMsg(userEntity.getArtificerOpenId(), one.getValue(), msgList, 4); + } + if (StringUtils.isNotEmpty(userEntity.getClientid())) { + userService.pushToSingle("订单通知", "订单完成了,请点击查看详细信息!", userEntity.getClientid()); + } + /*if(StringUtils.isNotBlank(userEntity.getWxOpenId())){ + String apkey = commonInfoService.findOne(314).getValue(); + LinkedHashMap data = new LinkedHashMap<>(); + data.put("character_string1", new TemplateMessageItem(orders.getOrdersNo(), "#d71345")); + data.put("thing3", new TemplateMessageItem(content, "#d71345")); + userService.sendWxMessage(apkey, data, userEntity.getWxOpenId()); + }*/ + if (StringUtils.isNotEmpty(user.getOpenId())) { + CommonInfo one = commonInfoService.findOne(250); + SenInfoCheckUtil.sendMsg(user.getOpenId(), one.getValue(), msgList, 3); + } + + if (StringUtils.isNotEmpty(user.getClientid())) { + userService.pushToSingle("订单通知", "订单完成了,请点击查看详细信息!", user.getClientid()); + } + + if (StringUtils.isNotBlank(user.getWxOpenId())) { + String apkey = commonInfoService.findOne(314).getValue(); + LinkedHashMap data = new LinkedHashMap<>(); + data.put("character_string1", new TemplateMessageItem(orders.getOrdersNo(), "#d71345")); + data.put("thing3", new TemplateMessageItem(content, "#d71345")); + userService.sendWxMessage(apkey, data, user.getWxOpenId()); + } + //执行对应项目减去技师物料包 + materialArtificerService.accomplishOrders(orders.getMassageTypeId(),orders.getArtificerId()); + return Result.success(); + } catch (Exception e) { + e.printStackTrace(); + log.error("完成订单异常:" + e.getMessage(), e); + return Result.error("系统错误,请联系管理员"); + } finally { + reentrantReadWriteLock.writeLock().unlock(); + } + + } + + @Override + public Result startOrders(Long ordersId, String startLongitude, String startLatitude, String startImg) { + Calendar calendar = Calendar.getInstance(); + Orders orders = baseMapper.selectById(ordersId); + //判断开始服务时间 是否超过预定时间 + if (StringUtils.isNotBlank(orders.getServeTime())) { + String value = commonInfoService.findOne(325).getValue(); + Calendar calendar1 = Calendar.getInstance(); + Date serveTime = DateUtils.stringToDate(orders.getServeTime(), "yyyy-MM-dd HH:mm"); + if (serveTime != null) { + calendar1.setTime(serveTime); + calendar1.add(Calendar.MINUTE, Integer.parseInt(value)); + if (System.currentTimeMillis() > calendar1.getTime().getTime()) { + //当前时间超过预定时间 判定为超时订单 + orders.setOverTimeOrders(1); + } + } + } + + if (orders.getOverTimeOrders() == null) { + orders.setOverTimeOrders(2); + } + orders.setStartImg(startImg); + orders.setStartLatitude(startLatitude); + orders.setStartLongitude(startLongitude); + + String startAddress = CommonMapUtils.getLocationToAddress(startLongitude, startLatitude);//按坐标获取地理位置 + + orders.setStartAddress(startAddress); + orders.setStartTime(DateUtils.format(calendar.getTime())); + orders.setStatus(6); + //开始服务 同时计算结束时间 + OrdersMassage ordersMassage = ordersMassageService.getOne(new QueryWrapper().eq("orders_id", orders.getOrdersId())); + MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId()); + int duration = massageType.getDuration(); + if (orders.getAddTime() != null) { + duration = duration * ordersMassage.getNum() + orders.getAddTime(); + }else{ + duration = duration * ordersMassage.getNum(); + } + calendar.add(Calendar.MINUTE, duration); + orders.setEndTime(DateUtils.format(calendar.getTime())); + baseMapper.updateById(orders); + return Result.success(); + } + + @Override + public Result artificerStartOrEndTime(Long ordersId) { + Orders orders = baseMapper.selectById(ordersId); + if (orders.getStatus().equals(2)) { + orders.setStatus(7); + orders.setArtificerStartTime(DateUtils.format(new Date())); + } else if (orders.getStatus().equals(7)) { + orders.setStatus(8); + orders.setArtificerEndTime(DateUtils.format(new Date())); + } else { + return Result.error("系统繁忙,请刷新后重试!"); + } + baseMapper.updateById(orders); + return Result.success(); + } + + + @Override + public Result selectArtificerIndex(Long artificerId, String startTime, String endTime) { + Map result = new HashMap(); + //总收益 + BigDecimal sumMoney = ordersDao.selectSumMoney(artificerId, startTime, endTime); + //总销量 + int countOrderNum = ordersDao.selectCountOrderNum(artificerId, startTime, endTime); + //评价分数 + Double countTakingByUserId = orderTakingCommentDao.selectCountTakingByUserId(artificerId, startTime, endTime); + //订单收入 + BigDecimal orderMoney = sumMoney; + //总订单数 + int countOrder = ordersDao.selectCountOrder(artificerId, null, startTime, endTime); + //退款金额 + BigDecimal sumRefund = userMoneyDetailsService.selectSumRefund(artificerId, startTime, endTime); + //访客人数 + int countByUserId = collectArtificerService.selectCountByUserId(artificerId, startTime, endTime); + //待服务 + int countOrderIng = ordersDao.selectCountOrder(artificerId, 2, startTime, endTime); + //待评价 + int countOrderAppraise = ordersDao.selectCountOrder(artificerId, 3, startTime, endTime); + //已取消 + int countOrderCancel = ordersDao.selectCountOrder(artificerId, 4, startTime, endTime); + //已完成 + int countOrderEnd = ordersDao.selectCountOrder(artificerId, 5, startTime, endTime); + int countOrderJin = ordersDao.selectCountOrder(artificerId, 6, startTime, endTime); + + Integer scoreCount = orderTakingCommentDao.selectCommentCount(artificerId, null, startTime, endTime); + Integer goodsScoreCount = orderTakingCommentDao.selectCommentCount(artificerId, 1, startTime, endTime); + Integer loseScoreCount = orderTakingCommentDao.selectCommentCount(artificerId, 2, startTime, endTime); + BigDecimal goodsRate = BigDecimal.ZERO; + BigDecimal loseRate = BigDecimal.ZERO; + if (scoreCount != 0) { + if (goodsScoreCount != null) { + goodsRate = BigDecimal.valueOf(goodsScoreCount).divide(BigDecimal.valueOf(scoreCount), 2, BigDecimal.ROUND_HALF_UP); + } + if (loseScoreCount != null) { + loseRate = BigDecimal.valueOf(loseScoreCount).divide(BigDecimal.valueOf(scoreCount), 2, BigDecimal.ROUND_HALF_UP); + } + } + BigDecimal succeedRate = BigDecimal.ZERO; + if (countOrderEnd != 0 && countOrder != 0) { + succeedRate = BigDecimal.valueOf(countOrderEnd + countOrderAppraise).divide(new BigDecimal(countOrder), 2, BigDecimal.ROUND_HALF_UP); + } + + result.put("sumMoney", sumMoney); + result.put("countOrderNum", countOrderNum); + result.put("countTakingByUserId", BigDecimal.valueOf(countTakingByUserId).setScale(2, BigDecimal.ROUND_HALF_DOWN)); + result.put("orderMoney", orderMoney); + result.put("countOrder", countOrder); + result.put("sumRefund", sumRefund); + result.put("countByUserId", countByUserId); + result.put("countOrderIng", countOrderIng); + result.put("countOrderAppraise", countOrderAppraise); + result.put("countOrderCancel", countOrderCancel); + result.put("countOrderEnd", countOrderEnd + countOrderAppraise); + result.put("countOrderJin", countOrderJin); + result.put("succeedRate", succeedRate); + result.put("sumCount", countOrderEnd + countOrderAppraise); + result.put("goodsRate", goodsRate); + result.put("loseRate", loseRate); + return Result.success().put("data", result); + } + + @Override + public Result selectTodayOrder(Long artificerId, Integer page, Integer limit, Integer type, String startTime, String endTime) { + Page pages = new Page<>(page, limit); + PageUtils pageUtils = new PageUtils(ordersDao.selectTodayOrder(pages, artificerId, type, startTime, endTime)); + return Result.success().put("data", pageUtils); + } + + @Override + public Result selectArtificerOrder(Long userId, Integer status, Integer page, Integer limit) { + Page pages = new Page<>(page, limit); + PageUtils pageUtils = new PageUtils(ordersDao.selectArtificerOrder(pages, userId, status)); + return Result.success().put("data", pageUtils); + } + + + public String getGeneralOrder() { + Date date = new Date(); + String newString = String.format("%0" + 4 + "d", (int) ((Math.random() * 9 + 1) * 1000)); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String format = sdf.format(date); + return format + newString; + } + + @Override + public Result refundOrders(Long ordersId) { + Orders orders = baseMapper.selectById(ordersId); + if (orders.getCouponId() != null) { + CouponUser couponUser = couponUserService.getById(orders.getCouponId()); + if (couponUser != null && couponUser.getStatus().equals(1)) { + couponUser.setStatus(0); + couponUserService.updateById(couponUser); + } + } + artificerTimeService.remove(new QueryWrapper().eq("orders_id", ordersId)); + if (orders.getStatus() != 1 && orders.getStatus() != 4) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String time = simpleDateFormat.format(new Date()); + List ordersList = baseMapper.selectList(new QueryWrapper().isNotNull("pay_way").eq("parent_id", orders.getOrdersId())); + if (orders.getPayWay() == 1 || orders.getPayWay() == 2 || orders.getPayWay() == 3 || orders.getPayWay() == 4) { + boolean refund = wxService.refund(orders.getOrdersNo(), orders.getPayMoney(), orders.getPayMoney(), orders.getPayWay()); + if (!refund) { + return Result.error("退款失败,请联系客服!"); + } + } else if (orders.getPayWay() == 6) { + String data = aliPayController.alipayRefund(orders.getOrdersNo(), orders.getPayMoney()); + if (StringUtils.isNotBlank(data)) { + log.error(data); + JSONObject jsonObject = JSON.parseObject(data); + JSONObject alipay_trade_refund_response = jsonObject.getJSONObject("alipay_trade_refund_response"); + String code1 = alipay_trade_refund_response.getString("code"); + if (!"10000".equals(code1)) { + return Result.error("退款失败!" + alipay_trade_refund_response.getString("sub_msg")); + } + } else { + return Result.error("退款失败!"); + } + } else { + if (orders.getUserArtificerMoney() != null && orders.getUserArtificerMoney() == 1) { + userMoneyArtificerService.updateMoney(1, orders.getUserId(), orders.getArtificerId(), orders.getPayMoney().doubleValue()); + } else { + userMoneyService.updateMoney(1, orders.getUserId(), orders.getPayMoney().doubleValue()); + } + + } + UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(orders.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(orders.getPayMoney()); + userMoneyDetails.setUserId(orders.getUserId()); + userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",已原路退款!"); + userMoneyDetails.setTitle("订单退款"); + userMoneyDetails.setType(1); + userMoneyDetails.setCreateTime(time); + userMoneyDetails.setArtificerId(orders.getArtificerId()); + userMoneyDetailsService.save(userMoneyDetails); + for (Orders orders1 : ordersList) { + if (orders1.getPayWay() == 1 || orders1.getPayWay() == 2 || orders1.getPayWay() == 3 || orders1.getPayWay() == 4) { + boolean refund = wxService.refund(orders1.getOrdersNo(), orders1.getPayMoney(), orders1.getPayMoney(), orders1.getPayWay()); + if (!refund) { + return Result.error("退款失败,请联系客服!"); + } + } else if (orders1.getPayWay() == 6) { + String data = aliPayController.alipayRefund(orders1.getOrdersNo(), orders1.getPayMoney()); + if (StringUtils.isNotBlank(data)) { + log.error(data); + JSONObject jsonObject = JSON.parseObject(data); + JSONObject alipay_trade_refund_response = jsonObject.getJSONObject("alipay_trade_refund_response"); + String code1 = alipay_trade_refund_response.getString("code"); + if (!"10000".equals(code1)) { + return Result.error("退款失败!" + alipay_trade_refund_response.getString("sub_msg")); + } + } else { + return Result.error("退款失败!"); + } + } else { + if (orders1.getUserArtificerMoney() != null && orders1.getUserArtificerMoney() == 1) { + userMoneyArtificerService.updateMoney(1, orders1.getUserId(), orders1.getArtificerId(), orders1.getPayMoney().doubleValue()); + } else { + userMoneyService.updateMoney(1, orders1.getUserId(), orders1.getPayMoney().doubleValue()); + } + } + userMoneyDetails = new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney12 = userMoneyService.selectUserMoneyByUserId(orders1.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney12.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(orders1.getPayMoney()); + userMoneyDetails.setUserId(orders1.getUserId()); + userMoneyDetails.setContent("订单号:" + orders1.getOrdersNo() + ",已原路退款!"); + userMoneyDetails.setTitle("加钟订单退款"); + userMoneyDetails.setType(1); + userMoneyDetails.setCreateTime(time); + userMoneyDetails.setArtificerId(orders.getArtificerId()); + userMoneyDetailsService.save(userMoneyDetails); + orders1.setStatus(4); + baseMapper.updateById(orders1); + } + orders.setStatus(4); + baseMapper.updateById(orders); + UserEntity userEntity = userService.selectUserById(orders.getUserId()); + + List ordersMassageList = ordersMassageService.list(new QueryWrapper().eq("orders_id", orders.getOrdersId())); + MassageType massageType = massageTypeService.getById(ordersMassageList.get(0).getMassageId()); + //超过十个字 则截取 + String content = massageType.getTitle(); + if (content.length() >= 15) { + content = content.substring(0, 15) + "..."; + } + + //消息推送 + if (StringUtils.isNotEmpty(userEntity.getOpenId())) { + CommonInfo one = commonInfoService.findOne(248); + List msgList = new ArrayList<>(); + msgList.add(orders.getOrdersNo()); + + msgList.add(content); + msgList.add("订单已取消,金额已原路退款!"); + SenInfoCheckUtil.sendMsg(userEntity.getOpenId(), one.getValue(), msgList, 2); + } + + if (StringUtils.isNotEmpty(userEntity.getClientid())) { + userService.pushToSingle("订单通知", "订单已取消,金额已原路退款!", userEntity.getClientid()); + } + + if (StringUtils.isNotBlank(userEntity.getWxOpenId())) { + String apkey = commonInfoService.findOne(313).getValue(); + LinkedHashMap data = new LinkedHashMap<>(); + data.put("character_string12", new TemplateMessageItem(orders.getOrdersNo(), "#d71345")); + data.put("thing17", new TemplateMessageItem(content, "#d71345")); + data.put("time14", new TemplateMessageItem(DateUtils.format(new Date()), "#d71345")); + userService.sendWxMessage(apkey, data, userEntity.getWxOpenId()); + } + } + return Result.success(); + } + + @Override + public Result updateArtificerCreditScore(Integer type, BigDecimal creditScore, Long artificerId) { + Artificer artificer = artificerService.getById(artificerId); + BigDecimal newCreditScore = BigDecimal.ZERO; + MessageInfo messageInfo = new MessageInfo(); + messageInfo.setState("8"); + messageInfo.setUserId(String.valueOf(artificer.getUserId())); + messageInfo.setTitle("系统修改信誉分"); + if (type == 1) { + newCreditScore = artificer.getCreditScore().add(creditScore); + messageInfo.setContent("增加信誉分:" + creditScore); + } else { + newCreditScore = artificer.getCreditScore().subtract(creditScore); + messageInfo.setContent("扣除信誉分:" + creditScore); + } + artificer.setCreditScore(newCreditScore); + String value = commonInfoService.findOne(385).getValue(); + BigDecimal minScore = new BigDecimal(value); + if (artificer.getCreditScore().doubleValue() < minScore.doubleValue()) { + artificer.setStatus(2); + } + artificerService.updateById(artificer); + messageService.saveBody(messageInfo); + return Result.success(); + } + + @Override + public void endOrders() { + String value = commonInfoService.findOne(316).getValue(); + List ordersList = baseMapper.selectOrdersByEndTime(value); + for (Orders orders : ordersList) { + Artificer artificer = artificerService.getById(orders.getArtificerId()); + orders.setIsSend(1); + updateById(orders); + UserEntity userEntity = userService.selectUserById(artificer.getUserId()); + singleThreadPool.submit(new Runnable() { + @Override + public void run() { +// sendAliPhone(userEntity.getPhone(), 2); + } + }); + + + if (userEntity != null) { + + if (StringUtils.isNotEmpty(userEntity.getClientid())) { + userService.pushToSingle("订单通知", "订单即将结束,请与客户进行确认", userEntity.getClientid()); + } + CommonInfo sms = commonInfoService.findOne(396); + if ("是".equals(sms.getValue())) { + if (StringUtils.isNotEmpty(userEntity.getPhone())) { + userService.sendMsg(userEntity.getPhone(), "end"); + } + } + + + List ordersMassageList = ordersMassageService.list(new QueryWrapper().eq("orders_id", orders.getOrdersId())); + MassageType massageType = massageTypeService.getById(ordersMassageList.get(0).getMassageId()); + //超过十个字 则截取 + String content = massageType.getTitle(); + if (content.length() >= 15) { + content = content.substring(0, 15) + "..."; + } + + if (StringUtils.isNotEmpty(userEntity.getArtificerOpenId())) { + CommonInfo one = commonInfoService.findOne(309); + List msgList = new ArrayList<>(); + msgList.add(orders.getOrdersNo()); + + msgList.add(content); + msgList.add("订单即将结束,请与客户进行确认"); + msgList.add(orders.getEndTime()); + SenInfoCheckUtil.sendMsg(userEntity.getOpenId(), one.getValue(), msgList, 5); + } + /*if(StringUtils.isNotBlank(userEntity.getWxOpenId())){ + String apkey = commonInfoService.findOne(315).getValue(); + LinkedHashMap data = new LinkedHashMap<>(); + data.put("character_string1", new TemplateMessageItem(orders.getOrdersNo(), "#d71345")); + data.put("thing2", new TemplateMessageItem(content, "#d71345")); + data.put("time7", new TemplateMessageItem(orders.getEndTime(), "#d71345")); + userService.sendWxMessage(apkey, data, userEntity.getWxOpenId()); + }*/ + } + + + } + } + + + public void sendAliPhone(String phone, Integer classify) { + String value1 = commonInfoService.findOne(311).getValue(); + if ("是".equals(value1)) { + String accessKeyId = commonInfoService.findOne(288).getValue(); + String accessKeySecret = commonInfoService.findOne(289).getValue(); + Config config = new Config() + // 您的AccessKey ID + .setAccessKeyId(accessKeyId) + // 您的AccessKey Secret + .setAccessKeySecret(accessKeySecret); + // 访问的域名 + config.endpoint = "dyvmsapi.aliyuncs.com"; + + String value2 = commonInfoService.findOne(317).getValue(); + if ("1".equals(value2)) { + + try { + Client client = new Client(config); + //使用公共模式发起语音通知时,CalledShowNumber参数必须为空。 + //使用专属号码发起语音通知时,CalledShowNumber参数必须为已购买的手机号码。 + SingleCallByTtsRequest singleCallByTtsRequest = new SingleCallByTtsRequest(); + String value = commonInfoService.findOne(290).getValue(); + if ("2".equals(value)) { + singleCallByTtsRequest.setCalledShowNumber(commonInfoService.findOne(291).getValue()); + } + singleCallByTtsRequest.setCalledNumber(phone); + if (classify == 1) { + singleCallByTtsRequest.setTtsCode(commonInfoService.findOne(310).getValue()); + } else { + singleCallByTtsRequest.setTtsCode(commonInfoService.findOne(292).getValue()); + } + + // 复制代码运行请自行打印API的返回值 + SingleCallByTtsResponse singleCallByTtsResponse = client.singleCallByTts(singleCallByTtsRequest); + SingleCallByTtsResponseBody body = singleCallByTtsResponse.getBody(); + log.error("阿里云语音通知返回值:" + body.getMessage() + ",状态值:" + body.getCode()); + } catch (Exception e) { + e.printStackTrace(); + log.error("阿里云语音通知异常:" + e.getMessage(), e); + } + + } else { + try { + Client client = new Client(config); + //使用公共模式发起语音通知时,CalledShowNumber参数必须为空。 + //使用专属号码发起语音通知时,CalledShowNumber参数必须为已购买的手机号码。 + SingleCallByVoiceRequest singleCallByVoiceRequest = new SingleCallByVoiceRequest(); + String value = commonInfoService.findOne(290).getValue(); + if ("2".equals(value)) { + singleCallByVoiceRequest.setCalledShowNumber(commonInfoService.findOne(291).getValue()); + } + singleCallByVoiceRequest.setCalledNumber(phone); + if (classify == 1) { + singleCallByVoiceRequest.setVoiceCode(commonInfoService.findOne(310).getValue()); + } else { + singleCallByVoiceRequest.setVoiceCode(commonInfoService.findOne(292).getValue()); + } + + // 复制代码运行请自行打印API的返回值 + SingleCallByVoiceResponse singleCallByVoiceResponse = client.singleCallByVoice(singleCallByVoiceRequest); + SingleCallByVoiceResponseBody body = singleCallByVoiceResponse.getBody(); + log.error("阿里云语音通知返回值:" + body.getMessage() + ",状态值:" + body.getCode()); + } catch (Exception e) { + e.printStackTrace(); + log.error("阿里云语音通知异常:" + e.getMessage(), e); + } + } + + + } + } + + @Override + public Result selectTeamOrdersList(Integer page, Integer limit, Long userId, Integer type, Integer status) { + return Result.success().put("data", new PageUtils(baseMapper.selectTeamOrdersList(new Page<>(page, limit), userId, type, status))); + } + + @Override + public Result selectTeamUserList(Integer page, Integer limit, String invitationCode, Integer type, Long userId) { + return Result.success().put("data", new PageUtils(baseMapper.selectTeamUserList(new Page<>(page, limit), invitationCode, type, userId))); + } + + @Override + public Double selectOrdersMoneyCountByUserId(Long userId, Integer type, String time) { + return baseMapper.selectOrdersMoneyCountByUserId(userId, type, time); + } + + @Override + public Integer selectUserCountByInvitationCode(String invitationCode, Integer type) { + return baseMapper.selectUserCountByInvitationCode(invitationCode, type); + } + + @Override + public Integer selectOrdersCountStatisticsByYear(Integer flag, String time, Integer status) { + return baseMapper.selectOrdersCountStatisticsByYear(flag, time, status); + } + + @Override + public Result selectArtificerOrdersList(Integer page, Integer limit, String artificerName, String artificerPhone, + String userName, String phone, Integer warning, Integer overTimeOrders) { + return Result.success().put("data", + new PageUtils(baseMapper.selectArtificerOrdersList(new Page<>(page, limit), artificerName, artificerPhone, userName, phone, warning, overTimeOrders))); + } + + @Scheduled(cron = "0 */1 * * * ?") + public void updateOrdersWarning() { + String value = commonInfoService.findOne(376).getValue(); + baseMapper.updateOrdersWarning(value); + String value1 = commonInfoService.findOne(388).getValue(); + List ordersList = baseMapper.selectOrdersStatusByTime(value1); + for (Orders orders : ordersList) { + orders.setStatus(4); + baseMapper.updateById(orders); + artificerTimeService.remove(new QueryWrapper().eq("orders_id", orders.getOrdersId())); + if (orders.getCouponId() != null) { + CouponUser couponUser = couponUserService.getById(orders.getCouponId()); + if (couponUser != null && couponUser.getStatus().equals(1)) { + couponUser.setStatus(0); + couponUserService.updateById(couponUser); + } + } + } + } + + @Override + public Result selectShopMoney(Integer page, Integer limit, String userName, String phone, String flag, String time) { + return Result.success().put("data", baseMapper.selectShopMoney(new Page<>(page, limit), userName, phone, flag, time)); + } + + @Override + public Result selectOneUserMoney(Integer page, Integer limit, String userName, String phone, String flag, String time) { + return Result.success().put("data", baseMapper.selectOneUserMoney(new Page<>(page, limit), userName, phone, flag, time)); + } + + @Override + public Result selectOneArtificerMoney(Integer page, Integer limit, String userName, String phone, String flag, String time) { + return Result.success().put("data", baseMapper.selectOneArtificerMoney(new Page<>(page, limit), userName, phone, flag, time)); + } + + @Override + public Result selectArtificerMoney(Integer page, Integer limit, String userName, String phone, String flag, String time) { + return Result.success().put("data", baseMapper.selectArtificerMoney(new Page<>(page, limit), userName, phone, flag, time)); + } + + @Override + public Result selectNewUserOrdersCount(Integer page, Integer limit, String userName, String phone) { + return Result.success().put("data", baseMapper.selectNewUserOrdersCount(new Page<>(page, limit), userName, phone)); + } + + @Override + public Result selectNewUserOrdersRate() { + return Result.success().put("data", baseMapper.selectNewUserOrdersRate()); + } + + @Override + public Result selectDividedIntoDetail(Period period) { + QueryWrapper queryWrapper = new QueryWrapper(); + if(StringUtil.isNotEmpty(period.getArtificerId())) { + Result.error("系统异常,请联系管理员"); + } + queryWrapper.eq("artificer_id", period.getArtificerId()); + if(StringUtil.isNotEmpty(period.getStartFundData().toString())){ + queryWrapper.between("create_time", period.getStartFundData(), period.getEndFundData()); + } + //只查询已完成和待评价的订单 + queryWrapper.in("status", Arrays.asList(5, 3)); + queryWrapper.orderByDesc("create_time"); + List orderList = baseMapper.selectList(queryWrapper); + UserMoneyArtificerDetails userMoneyArtificerDetails = new UserMoneyArtificerDetails(); + + //计算项目收益 + userMoneyArtificerDetails.setProjectBenefits(orderList.stream().map(e -> e.getProjectBenefits()).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP)); + //计算车费收益 + userMoneyArtificerDetails.setVehicleFareAmount(orderList.stream().map(e -> e.getArtificerTaxiMoney()).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP)); + //计算渠道扣款 + userMoneyArtificerDetails.setChannelDeduction(orderList.stream().map(e -> e.getChannelDeduction()).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP)); + //计算储值扣款 + userMoneyArtificerDetails.setValueStorageDeduction(orderList.stream().map(e -> e.getValueStorageDeduction()).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP)); + //计算当期收益 项目收益加上车费收益减去渠道扣款和储值扣款 + BigDecimal all = new BigDecimal(String.valueOf(userMoneyArtificerDetails.getProjectBenefits().add(userMoneyArtificerDetails.getVehicleFareAmount()).subtract(userMoneyArtificerDetails.getChannelDeduction()).subtract(userMoneyArtificerDetails.getValueStorageDeduction()))).setScale(2, BigDecimal.ROUND_HALF_UP); + userMoneyArtificerDetails.setTotalRevenue(all); + //插入开始结束时间 + userMoneyArtificerDetails.setStartFundData(period.getStartFundData()); + userMoneyArtificerDetails.setEndFundData(period.getEndFundData()); + //资金明细添加到返回对象中 + return Result.success().put("data", userMoneyArtificerDetails); + } + @Override + public Result selectDividedIntoDetails(Integer page, Integer limit, Period period) { + IPage page1 = new Page(page, limit); + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("artificer_id", period.getArtificerId()); + if(StringUtil.isNotEmpty(period.getStartFundData().toString())){ + queryWrapper.between("create_time", period.getStartFundData(), period.getEndFundData()); + } + //只查询已完成和待评价的订单 + queryWrapper.in("status", Arrays.asList(5, 3)); + //只查询根节点数据 + queryWrapper.eq("parent_id", 0); + queryWrapper.orderByDesc("create_time"); + IPage page2 = baseMapper.selectPage(page1, queryWrapper); + //分成明细添加到返回对象中 + return Result.success().put("data", page2); + } + + @Override + public Result splitDetails(Period period) { + QueryWrapper queryWrapper = new QueryWrapper(); + //查询对应技师id以及 + queryWrapper.eq("orders_id", period.getOrderId()).or().eq("parent_id", period.getOrderId()); + //只查询已完成和待评价的订单 + queryWrapper.in("status", Arrays.asList(5, 3)); + List ordersList = baseMapper.selectList(queryWrapper); + TreeNodeConfig treeNodeConfig = new TreeNodeConfig(); + treeNodeConfig.setIdKey("ordersId"); + treeNodeConfig.setParentIdKey("parentId"); + List> trees = TreeUtil.build(ordersList, 0L, treeNodeConfig, ((object, treeNode) -> { + treeNode.setId(object.getOrdersId());//id + treeNode.setParentId(object.getParentId());//父id + treeNode.putExtra("entryName", object.getEntryName());//项目名称 + treeNode.putExtra("serveTime", object.getServeTime());//服务时间 + treeNode.putExtra("payTime", object.getPayTime());//下单时间 + treeNode.putExtra("ordersNo", object.getOrdersNo());//订单号 + treeNode.putExtra("couponMoney", object.getCouponMoney());//优惠卷金额 + treeNode.putExtra("price", object.getPrice());//服务金额 + treeNode.putExtra("artificerRate", object.getArtificerRate());//提成比例 + treeNode.putExtra("projectBenefits", object.getProjectBenefits());//项目收益 + treeNode.putExtra("channelDeduction", object.getChannelDeduction());//渠道扣费 + treeNode.putExtra("valueStorageDeduction",object.getValueStorageDeduction());//储值扣费 + treeNode.putExtra("totalDeduction", object.getChannelDeduction().add(object.getValueStorageDeduction()));//合计扣费 + treeNode.putExtra("artificerTaxiMoney", object.getArtificerTaxiMoney());//车费金额 +// treeNode.putExtra("revenueAmount",object.getArtificerTaxiMoney().add(object.getProjectBenefits()).subtract(object.getChannelDeduction().add(object.getValueStorageDeduction())));//收益金额 + })); + //项目金额 + BigDecimal Price = BigDecimal.valueOf(ordersList.stream().map(Orders->new BigDecimal(String.valueOf(Orders.getPrice()))).collect(Collectors.reducing(BigDecimal.ZERO, BigDecimal::add)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + BigDecimal couponMoney = new BigDecimal(trees.get(0).get("couponMoney").toString()); + //实际项目金额 + trees.get(0).put("allPrice",Price.subtract(couponMoney)); + //项目收益 + BigDecimal projectBenefits = BigDecimal.valueOf(ordersList.stream().map(Orders->new BigDecimal(String.valueOf(Orders.getProjectBenefits()))).collect(Collectors.reducing(BigDecimal.ZERO, BigDecimal::add)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + //实际项目收益 + trees.get(0).put("actualProjectBenefits",projectBenefits); + BigDecimal artificerTaxiMoney = new BigDecimal(trees.get(0).get("artificerTaxiMoney").toString()); + //实际总收益 + trees.get(0).put("totalRevenue",artificerTaxiMoney.add(projectBenefits)); + //分成明细添加到返回对象中 + return Result.success().put("data", trees); + } +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/impl/RealNameServiceImpl.java b/src/main/java/com/sqx/modules/artificer/service/impl/RealNameServiceImpl.java new file mode 100644 index 0000000..da862d2 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/service/impl/RealNameServiceImpl.java @@ -0,0 +1,259 @@ +package com.sqx.modules.artificer.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.dao.UserMoneyDao; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.entity.UserMoneyDetails; +import com.sqx.modules.app.service.UserMoneyDetailsService; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.dao.OrdersDao; +import com.sqx.modules.artificer.dao.RealNameDao; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.Certification; +import com.sqx.modules.artificer.service.ArtificerService; +import com.sqx.modules.artificer.service.OrdersService; +import com.sqx.modules.artificer.service.RealNameService; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.sys.entity.SysDictEntity; +import com.sqx.modules.sys.service.SysDictService; +import com.sqx.modules.utils.VerifyIdCardUtils; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +@Service +public class RealNameServiceImpl extends ServiceImpl implements RealNameService { + + @Autowired + private CommonInfoService commonInfoService; + @Autowired + private UserMoneyDao userMoneyDao; + @Autowired + private UserService userService; + @Autowired + private ArtificerService artificerService; + @Autowired + private OrdersDao ordersDao; + @Autowired + private UserMoneyDetailsService userMoneyDetailsService; + @Autowired + private SysDictService sysDictService; + + private ReentrantReadWriteLock reentrantReadWriteLock=new ReentrantReadWriteLock(true); + + @Override + public Result selectRealName(Long userId) { + Certification certification = baseMapper.selectOne(new QueryWrapper().eq("user_id", userId).orderByDesc("update_time").last("limit 1")); + return Result.success().put("data", certification); + } + + @Override + public Result updateRealName(Certification certification) { + + UserEntity user = userService.getById(certification.getUserId()); + /*CommonInfo one = commonInfoService.findOne(240); + if("是".equals(one.getValue())) { + //判断身份证是否合法 + String result = VerifyIdCardUtils.verifyIdCard(certification.getIdNumber(), certification.getName()); + if("ok".equals(result)){ + certification.setStatus(1); + certification.setUpdateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + user.setIsAuthentication(2); + Artificer artificer = artificerService.selectArtificerByUserId(user.getUserId()); + artificer.setStatus(2); + artificer.setArtificerName(certification.getName()); + artificer.setArtificerImg(certification.getAvatar()); + artificer.setLifePhoto(certification.getImagePhoto()); + artificer.setCertificate(certification.getCertification()); + artificer.setContent(certification.getIndividualResume()); + artificerService.updateById(artificer); + }else{ + return Result.error("您填写的信息有误,请检查后重试!"); + } + }else { + user.setIsAuthentication(1); + certification.setStatus(0); + certification.setUpdateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + }*/ + user.setIsAuthentication(1); + certification.setStatus(0); + certification.setUpdateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + userService.updateById(user); + if(certification.getId()!=null){ + baseMapper.updateById(certification); + }else{ + certification.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + baseMapper.delete(new QueryWrapper().eq("user_id",certification.getUserId())); + baseMapper.insert(certification); + } + return Result.success(); + } + + @Override + public Result selectRealNameList(Integer page, Integer limit, Integer status, String userName, String phone,Long classifyId) { + Page pages = new Page<>(page, limit); + IPage certificationIPage = baseMapper.selectPage(pages, new QueryWrapper() + .eq(status != null, "status", status) + .eq(StringUtils.isNotEmpty(userName), "name", userName) + .eq(classifyId != null, "classify_id", classifyId) + .eq(StringUtils.isNotEmpty(phone), "phone", phone).orderByDesc("create_time")); + List records = certificationIPage.getRecords(); + for (Certification certification:records){ + if(certification.getClassifyId()!=null){ + SysDictEntity sysDictEntity = sysDictService.getById(certification.getClassifyId()); + if(sysDictEntity!=null){ + certification.setClassifyName(sysDictEntity.getValue()); + } + } + } + PageUtils pageUtils = new PageUtils(certificationIPage); + return Result.success().put("data", pageUtils); + } + + @Override + public Result auditRealName(Certification certification) { + baseMapper.updateById(certification); + Certification certification1 = baseMapper.selectById(certification.getId()); + if(certification.getStatus()==1){ + Artificer artificer = artificerService.selectArtificerByUserId(certification1.getUserId()); + if(artificer==null){ + artificer=new Artificer(); + }else { + return Result.error("该技师已存在"); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + artificer.setUserId(certification1.getUserId()); + artificer.setCreateTime(sdf.format(new Date())); + artificer.setArtificerSales(0); + artificer.setStatus(2); + artificer.setArtificerName(certification1.getName()); + artificer.setArtificerImg(certification1.getAvatar()); + artificer.setLifePhoto(certification1.getImagePhoto()); + artificer.setCertificate(certification1.getCertification()); + artificer.setContent(certification1.getIndividualResume()); + artificer.setClassifyId(certification1.getClassifyId()); + artificer.setCreditScore(BigDecimal.valueOf(100)); + artificer.setTripWay(1); + if(artificer.getArtificerId()!=null){ + artificerService.updateById(artificer); + }else{ + artificer.setRate(new BigDecimal(commonInfoService.findOne(381).getValue())); + artificerService.save(artificer); + } + + UserEntity userEntity = userService.selectUserById(artificer.getUserId()); + userEntity.setIsAuthentication(2); + userService.updateById(userEntity); + }else{ + UserEntity userEntity = userService.selectUserById(certification1.getUserId()); + userEntity.setIsAuthentication(3); + userService.updateById(userEntity); + } + return Result.success(); + } + + @Override + public Result selectRealNameById(Long userId) { + Certification certification = baseMapper.selectOne(new QueryWrapper().eq("user_id", userId).orderByDesc("update_time").last("limit 1")); + return Result.success().put("data", certification); + } + + @Override + public Result retreatCashDeposit(Long userId) { + UserEntity userEntity = userService.selectUserById(userId); + if(userEntity.getIsCashDeposit()==null || userEntity.getIsCashDeposit()==1){ + return Result.error("保证金未缴纳!"); + }else if(userEntity.getIsCashDeposit()==2){ + //判断有没有进行中的订单 + Artificer artificer = artificerService.selectArtificerByUserId(userId); + int i = ordersDao.selectOrdersCountByUnderway(artificer.getArtificerId()); + if(i>0){ + return Result.error("当前还有未完成的订单,请完成后再进行退款!"); + } + + UserMoney userMoney = userMoneyDao.selectOne(new QueryWrapper().eq("user_id", userId)); + userMoneyDao.updateCashDeposit(2, userId, userMoney.getCashDeposit().doubleValue()); + userMoneyDao.updateMayMoney(1, userId, userMoney.getCashDeposit().doubleValue()); + UserMoneyDetails userMoneyDetails =new UserMoneyDetails(); + userMoneyDetails.setMoney(userMoney.getCashDeposit()); + userMoneyDetails.setUserId(userId); + userMoneyDetails.setContent("保证金退款成功,资金已到您的钱包!"); + userMoneyDetails.setTitle("保证金退款"); + userMoneyDetails.setType(1); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String format = simpleDateFormat.format(new Date()); + userMoneyDetails.setCreateTime(format); + userMoneyDetailsService.save(userMoneyDetails); + + userMoneyDetails=new UserMoneyDetails(); + userMoneyDetails.setUserId(userId); + userMoneyDetails.setTitle("保证金退款"); + userMoneyDetails.setContent("保证金退款成功,资金已到您的钱包!"); + userMoneyDetails.setType(2); + userMoneyDetails.setMoney(userMoney.getCashDeposit()); + userMoneyDetails.setState(2); + userMoneyDetails.setClassify(1); + userMoneyDetails.setCreateTime(format); + userMoneyDetailsService.save(userMoneyDetails); + userEntity.setIsCashDeposit(1); + artificer.setStatus(2); + artificerService.updateById(artificer); + userService.updateById(userEntity); + return Result.success(); + } + return Result.error("保证金申请退款中!"); + } + + @Override + public Result auditRefund(Long userId, Integer type) { + reentrantReadWriteLock.writeLock().lock(); + try { + UserEntity userEntity = userService.selectUserById(userId); + if(userEntity.getIsCashDeposit()!=3){ + return Result.error("保证金已退款或未申请,请刷新后重试!"); + } + if(type==1){ + UserMoney userMoney = userMoneyDao.selectOne(new QueryWrapper().eq("user_id", userId)); + userMoneyDao.updateCashDeposit(2, userId, userMoney.getCashDeposit().doubleValue()); + userMoneyDao.updateMayMoney(1, userId, userMoney.getCashDeposit().doubleValue()); + userEntity.setIsCashDeposit(1); + Artificer artificer = artificerService.selectArtificerByUserId(userId); + artificer.setStatus(2); + artificerService.updateById(artificer); + }else{ + userEntity.setIsCashDeposit(2); + } + userService.updateById(userEntity); + return Result.success(); + }catch (Exception e){ + e.printStackTrace(); + log.error("保证金退还异常:"+e.getMessage(),e); + }finally { + reentrantReadWriteLock.writeLock().unlock(); + } + return Result.error("系统繁忙,请刷新后重试!"); + } + + @Override + public Result selectRefundCashDepositList(Integer page,Integer limit,String userName,String phone){ + Page> pages=new Page<>(page,limit); + return Result.success().put("data",new PageUtils(baseMapper.selectRefundCashDepositList(pages,userName,phone))); + } + + + +} diff --git a/src/main/java/com/sqx/modules/artificer/vo/HomeVO.java b/src/main/java/com/sqx/modules/artificer/vo/HomeVO.java new file mode 100644 index 0000000..66370e1 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/vo/HomeVO.java @@ -0,0 +1,82 @@ +package com.sqx.modules.artificer.vo; + + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @author zc + * @description HomeVo + * @date 2024-01-16 + */ +@Data +@ApiModel(value = "HomeVO", description = "响应参数说明") +public class HomeVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "当期等级", required = true) + private String grade; + + @ApiModelProperty(value = "当前业绩", required = true) + private String currentPerformance; + + @ApiModelProperty(value = "当前收益", required = true) + private String earnings; + + @ApiModelProperty(value = "当期积分=(储值积分+在线积分)", required = true) + private BigDecimal integral; + + + @ApiModelProperty(value = "当期订单数量", required = true) + private String currentPeriodOrdersSum; + + @ApiModelProperty(value = "当期加钟率", required = true) + private String currentPeriodAddBellsSum; + + @ApiModelProperty(value = "当期充值率", required = true) + private String currentPeriodRechargeSum; + + @ApiModelProperty(value = "当日收益", required = true) + private String dailyEarnings; + + @ApiModelProperty(value = "当月收益", required = true) + private String currentMonthsIncome; + + @ApiModelProperty(value = "当期结束日", required = true) + private String currentEndDate; + + @ApiModelProperty(value = "差的业绩", required = true) + private String differenceOutstandingAchievement; + + @ApiModelProperty(value = "差的积分", required = true) + private String differenceIntegral; + + @ApiModelProperty(value = "差的加钟率", required = true) + private String differenceClockRate; + + @ApiModelProperty(value = "差的在线时长", required = true) + private String differenceDurationOnline; + + @ApiModelProperty(value = "差的等级", required = true) + private String differenceGrade; + + @ApiModelProperty(value = "差多少业绩积分在线时长加重钟率提升等级", required = true) + private String ultimately; + + @ApiModelProperty(value = "等级后缀显示", required = true) + private String suffix; + + @ApiModelProperty(value = "是否满级", required = true) + private Boolean maxStatus; + + @ApiModelProperty(value = "项目类型(91精油;95中医)", required = true) + private String depositRate; + + +} diff --git a/src/main/java/com/sqx/modules/artificer/vo/UserArtificerVO.java b/src/main/java/com/sqx/modules/artificer/vo/UserArtificerVO.java new file mode 100644 index 0000000..e5444f1 --- /dev/null +++ b/src/main/java/com/sqx/modules/artificer/vo/UserArtificerVO.java @@ -0,0 +1,27 @@ +package com.sqx.modules.artificer.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description: + * @author:zc. + * @createData:2024-2-4 下午 2:33 + * @projectName:anmo + * @className:UserArtificerVO + * @packageName:com.sqx.modules.artificer.vo + */ +@Data +public class UserArtificerVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "技师id", required = true) + private Long artificerId; + + @ApiModelProperty(value = "技师用户id", required = true) + private Long userId; + +} diff --git a/src/main/java/com/sqx/modules/banner/controller/ActivityController.java b/src/main/java/com/sqx/modules/banner/controller/ActivityController.java new file mode 100644 index 0000000..91a7192 --- /dev/null +++ b/src/main/java/com/sqx/modules/banner/controller/ActivityController.java @@ -0,0 +1,97 @@ +package com.sqx.modules.banner.controller; + + +import com.sqx.common.utils.Result; +import com.sqx.modules.banner.entity.Activity; +import com.sqx.modules.banner.service.ActivityService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * @author fang + * @date 2020/7/9 + */ +@Slf4j +@RestController +@Api(value = "菜单和活动管理", tags = {"菜单和活动管理"}) +@RequestMapping(value = "/activity") +public class ActivityController { + + + @Autowired + private ActivityService activityService; + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ApiOperation("管理平台详情") + @ResponseBody + public Result getBanner(@PathVariable Long id) { + return Result.success().put("data",activityService.selectActivityById(id)); + } + + @RequestMapping(value = "/state/{state}", method = RequestMethod.GET) + @ApiOperation("根据状态查询菜单列表") + @ResponseBody + public Result getBannerState(@PathVariable String state) { + return Result.success().put("data",activityService.selectByState(state)); + } + + @RequestMapping(value = "/updateActivity", method = RequestMethod.POST) + @ApiOperation("管理平台修改") + @ResponseBody + public Result addBanner(@RequestBody Activity activity) { + activityService.updateActivity(activity); + return Result.success(); + } + + @RequestMapping(value = "/updateActivityStatus", method = RequestMethod.POST) + @ApiOperation("管理平台修改状态") + @ResponseBody + public Result updateActivity(Long id) { + Activity activity = activityService.selectActivityById(id); + if("1".equals(activity.getState())){ + activity.setState("2"); + activityService.updateActivity(activity); + }else{ + activity.setState("1"); + activityService.updateActivity(activity); + } + return Result.success(); + } + + @PostMapping("/insertActivity") + @ApiOperation("添加") + @ResponseBody + public Result insertActivity(@RequestBody Activity activity){ + activityService.insertActivity(activity); + return Result.success(); + } + + @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST) + @ApiOperation("管理平台删除") + public Result deleteBanner(@PathVariable Long id) { + activityService.deleteActivity(id); + return Result.success(); + } + + @RequestMapping(value = "/", method = RequestMethod.GET) + @ApiOperation("用户端获取广告位") + @ResponseBody + public Result getBannerList() { + return Result.success().put("data",activityService.selectActivity()); + } + + @RequestMapping(value = "/selectActivity", method = RequestMethod.GET) + @ApiOperation("管理平台获取全部广告位") + @ResponseBody + public Result selectActivity() { + return Result.success().put("data",activityService.selectActivitys()); + } + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/banner/controller/BannerController.java b/src/main/java/com/sqx/modules/banner/controller/BannerController.java new file mode 100644 index 0000000..a26756f --- /dev/null +++ b/src/main/java/com/sqx/modules/banner/controller/BannerController.java @@ -0,0 +1,86 @@ +package com.sqx.modules.banner.controller; + + +import com.sqx.common.utils.Result; +import com.sqx.modules.banner.entity.Banner; +import com.sqx.modules.banner.service.BannerService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Arrays; + +/** + * @author fang + * @date 2020/7/9 + */ +@Slf4j +@RestController +@Api(value = "banner图", tags = {"banner图"}) +@RequestMapping(value = "/banner") +public class BannerController { + + + @Autowired + private BannerService bannerService; + + + @RequestMapping(value = "/selectBannerList", method = RequestMethod.GET) + @ApiOperation("查询所有banner图") + @ResponseBody + public Result selectBannerList(Integer classify){ + return Result.success().put("data",bannerService.selectBannerLists(classify)); + } + + + @RequestMapping(value = "/selectBannerPage", method = RequestMethod.GET) + @ApiOperation("查询所有banner图") + @ResponseBody + public Result selectBannerPage(Integer page,Integer limit,Integer classify,Integer state){ + return Result.success().put("data",bannerService.selectPage(page,limit,classify,state)); + } + + + @RequestMapping(value = "/selectBannerById", method = RequestMethod.GET) + @ApiOperation("根据id查看详细信息") + @ResponseBody + public Result selectBannerById(Long id){ + return Result.success().put("data",bannerService.selectBannerById(id)); + } + + @RequestMapping(value = "/updateBannerStateById", method = RequestMethod.POST) + @ApiOperation("隐藏banner图") + @ResponseBody + public Result updateBannerStateById(Long id){ + return bannerService.updateBannerStateById(id); + } + + @RequestMapping(value = "/updateBannerById", method = RequestMethod.POST) + @ApiOperation("修改banner图") + @ResponseBody + public Result updateBannerById(@RequestBody Banner banner){ + bannerService.updateBannerById(banner); + return Result.success(); + } + + @RequestMapping(value = "/deleteBannerById", method = RequestMethod.GET) + @ApiOperation("删除banner图") + @ResponseBody + public Result deleteBannerById(String ids){ + bannerService.removeByIds(Arrays.asList(ids.split(","))); + return Result.success(); + } + + @RequestMapping(value = "/insertBanner", method = RequestMethod.POST) + @ApiOperation("添加banner图") + @ResponseBody + public Result insertBanner(@RequestBody Banner banner){ + bannerService.insertBanner(banner); + return Result.success(); + } + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/banner/controller/app/AppBannerController.java b/src/main/java/com/sqx/modules/banner/controller/app/AppBannerController.java new file mode 100644 index 0000000..51edaa0 --- /dev/null +++ b/src/main/java/com/sqx/modules/banner/controller/app/AppBannerController.java @@ -0,0 +1,38 @@ +package com.sqx.modules.banner.controller.app; + + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.Result; +import com.sqx.modules.banner.service.BannerService; +import com.sqx.modules.taking.response.OrderTakingResponse; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * @author liyuan + * @date 2021/8/9 + */ +@Slf4j +@RestController +@Api(value = "app banner图", tags = {"app banner图"}) +@RequestMapping(value = "/app/banner") +public class AppBannerController { + + + @Autowired + private BannerService bannerService; + + @RequestMapping(value = "/selectBannerList", method = RequestMethod.GET) + @ApiOperation("查询所有banner图") + @ResponseBody + public Result selectBannerList(Integer classify) { + return Result.success().put("data", bannerService.selectBannerList(classify)); + } + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/banner/dao/ActivityDao.java b/src/main/java/com/sqx/modules/banner/dao/ActivityDao.java new file mode 100644 index 0000000..04b26e3 --- /dev/null +++ b/src/main/java/com/sqx/modules/banner/dao/ActivityDao.java @@ -0,0 +1,19 @@ +package com.sqx.modules.banner.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.banner.entity.Activity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @author fang + * @date 2020/7/9 + */ +@Mapper +public interface ActivityDao extends BaseMapper { + + + List selectByState(String state); + +} diff --git a/src/main/java/com/sqx/modules/banner/dao/BannerDao.java b/src/main/java/com/sqx/modules/banner/dao/BannerDao.java new file mode 100644 index 0000000..b3fe689 --- /dev/null +++ b/src/main/java/com/sqx/modules/banner/dao/BannerDao.java @@ -0,0 +1,27 @@ +package com.sqx.modules.banner.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.banner.entity.Banner; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @author fang + * @date 2020/7/9 + */ +@Mapper +public interface BannerDao extends BaseMapper { + + + List selectLists(@Param("classify") Integer classify); + + List selectList(@Param("classify") Integer classify); + + Page selectPage(IPage page, @Param("classify") Integer classify, @Param("state")Integer state); + +} diff --git a/src/main/java/com/sqx/modules/banner/entity/Activity.java b/src/main/java/com/sqx/modules/banner/entity/Activity.java new file mode 100644 index 0000000..c1facbd --- /dev/null +++ b/src/main/java/com/sqx/modules/banner/entity/Activity.java @@ -0,0 +1,29 @@ +package com.sqx.modules.banner.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 活动推广 + */ +@Data +@TableName("activity") +public class Activity implements Serializable { + @TableId(type = IdType.INPUT) + private Long id; + + private String createAt; + + private String imageUrl; + + private String url; + + private String title; + + private String state; + +} diff --git a/src/main/java/com/sqx/modules/banner/entity/Banner.java b/src/main/java/com/sqx/modules/banner/entity/Banner.java new file mode 100644 index 0000000..93b2623 --- /dev/null +++ b/src/main/java/com/sqx/modules/banner/entity/Banner.java @@ -0,0 +1,67 @@ +package com.sqx.modules.banner.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.io.Serializable; +/** + * @author fang + * @date 2020/7/9 + */ +@Data +@TableName("banner") +@AllArgsConstructor +@NoArgsConstructor +public class Banner implements Serializable { + + private static final long serialVersionUID = 1L; + /** + * banner图id + */ + @TableId(type = IdType.INPUT) + private Long id; + + /** + * 创建时间 + */ + private String createTime; + + /** + * 名称 + */ + private String name; + + /** + * 图片地址 + */ + private String imageUrl; + + /** + * 状态 1正常 2隐藏 + */ + private Integer state; + + /** + * 分类 1 banner图 2 首页分类 + */ + private Integer classify; + + /** + * 跳转地址 + */ + private String url; + + /** + * 顺序 + */ + private Integer sort; + + /** + * 描述 + */ + private String describes; + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/banner/service/ActivityService.java b/src/main/java/com/sqx/modules/banner/service/ActivityService.java new file mode 100644 index 0000000..af91c58 --- /dev/null +++ b/src/main/java/com/sqx/modules/banner/service/ActivityService.java @@ -0,0 +1,27 @@ +package com.sqx.modules.banner.service; + + +import com.sqx.modules.banner.entity.Activity; + +import java.util.List; + +public interface ActivityService { + + + List selectByState(String state); + + Activity selectActivityById(Long id); + + int insertActivity(Activity info); + + int updateActivity(Activity info); + + int deleteActivity(Long id); + + List selectActivity(); + + List selectActivitys(); + + + +} diff --git a/src/main/java/com/sqx/modules/banner/service/BannerService.java b/src/main/java/com/sqx/modules/banner/service/BannerService.java new file mode 100644 index 0000000..1948bec --- /dev/null +++ b/src/main/java/com/sqx/modules/banner/service/BannerService.java @@ -0,0 +1,30 @@ +package com.sqx.modules.banner.service; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.banner.entity.Banner; +import com.sqx.modules.taking.response.OrderTakingResponse; +import io.swagger.annotations.ApiParam; + +import java.util.List; + +public interface BannerService extends IService { + + List selectBannerList(Integer classify); + + List selectBannerLists(Integer classify); + + int saveBody(String image, String url, Integer sort); + + Banner selectBannerById(Long id); + + Result updateBannerStateById(Long id); + + int updateBannerById(Banner banner); + + int insertBanner(Banner banner); + + PageUtils selectPage(Integer page, Integer limit, Integer classify, Integer state); + +} diff --git a/src/main/java/com/sqx/modules/banner/service/impl/ActivityServiceImpl.java b/src/main/java/com/sqx/modules/banner/service/impl/ActivityServiceImpl.java new file mode 100644 index 0000000..ec7be7b --- /dev/null +++ b/src/main/java/com/sqx/modules/banner/service/impl/ActivityServiceImpl.java @@ -0,0 +1,65 @@ +package com.sqx.modules.banner.service.impl; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.modules.banner.dao.ActivityDao; +import com.sqx.modules.banner.entity.Activity; +import com.sqx.modules.banner.service.ActivityService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +/** + * 活动推广 + */ +@Service +public class ActivityServiceImpl extends ServiceImpl implements ActivityService { + + + @Autowired + private ActivityDao activityDao; + + @Override + public List selectByState(String state) { + return activityDao.selectByState(state); + } + + @Override + public Activity selectActivityById(Long id) { + return activityDao.selectById(id); + } + + @Override + public int insertActivity(Activity activity) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + activity.setCreateAt(sdf.format(now)); + return activityDao.insert(activity); + } + + @Override + public int updateActivity(Activity activity) { + return activityDao.updateById(activity); + } + + @Override + public int deleteActivity(Long id) { + return activityDao.deleteById(id); + } + + @Override + public List selectActivity() { + return activityDao.selectList(new QueryWrapper().eq("state", 1)); + } + + @Override + public List selectActivitys() { + return activityDao.selectList(null); + } + + +} diff --git a/src/main/java/com/sqx/modules/banner/service/impl/BannerServiceImpl.java b/src/main/java/com/sqx/modules/banner/service/impl/BannerServiceImpl.java new file mode 100644 index 0000000..5627dc7 --- /dev/null +++ b/src/main/java/com/sqx/modules/banner/service/impl/BannerServiceImpl.java @@ -0,0 +1,95 @@ +package com.sqx.modules.banner.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.banner.dao.BannerDao; +import com.sqx.modules.banner.entity.Banner; +import com.sqx.modules.banner.service.BannerService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +/** + * banner图 + */ +@Service +public class BannerServiceImpl extends ServiceImpl implements BannerService { + + @Autowired + private BannerDao bannerDao; + + + @Override + public List selectBannerList(Integer classify) { + return bannerDao.selectList(classify); + } + + @Override + public List selectBannerLists(Integer classify) { + return bannerDao.selectLists(classify); + } + + @Override + public PageUtils selectPage(Integer page, Integer limit, Integer classify, Integer state){ + IPage pages=new Page<>(page,limit); + return new PageUtils(bannerDao.selectPage(pages,classify,state)); + } + + + @Override + public int saveBody(String image, String url, Integer sort) { + Banner banner = new Banner(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + banner.setImageUrl(image); + banner.setCreateTime(sdf.format(now)); + banner.setState(1); + banner.setUrl(url); + banner.setSort(sort == null ? 1 : sort); + return bannerDao.insert(banner); + } + + @Override + public int insertBanner(Banner banner) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + banner.setCreateTime(sdf.format(now)); + banner.setState(2); + return bannerDao.insert(banner); + } + + + @Override + public Banner selectBannerById(Long id) { + return bannerDao.selectById(id); + } + + @Override + public Result updateBannerStateById(Long id) { + Banner banner = selectBannerById(id); + if (banner != null) { + if (banner.getState() == 1) { + banner.setState(2); + } else { + banner.setState(1); + } + bannerDao.updateById(banner); + return Result.success(); + } else { + return Result.error("修改对象为空!"); + } + } + + @Override + public int updateBannerById(Banner banner) { + return bannerDao.updateById(banner); + } + + +} diff --git a/src/main/java/com/sqx/modules/chat/controller/ChatController.java b/src/main/java/com/sqx/modules/chat/controller/ChatController.java new file mode 100644 index 0000000..cc7d02e --- /dev/null +++ b/src/main/java/com/sqx/modules/chat/controller/ChatController.java @@ -0,0 +1,50 @@ +package com.sqx.modules.chat.controller; + +import com.sqx.common.utils.Result; +import com.sqx.modules.chat.service.ChatContentService; +import com.sqx.modules.chat.service.ChatConversationService; +import com.sqx.modules.chats.service.ChatsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Api(value = "聊天", tags = {"聊天"}) +@RequestMapping(value = "/chat") +public class ChatController { + + @Autowired + private ChatContentService chatContentService; + @Autowired + private ChatConversationService chatConversationService; + + @GetMapping("/selectChatConversationPage") + @ApiOperation("获取聊天会话") + public Result selectChatConversationPage(Integer page, Integer limit, Long userId, String nickName){ + return Result.success().put("data",chatConversationService.selectChatConversationPage(page, limit, userId,nickName)); + } + + + @GetMapping("/selectChatContent") + @ApiOperation("获取聊天记录") + public Result selectChatContent(Integer page,Integer limit,Long chatConversationId,String content){ + return Result.success().put("data",chatContentService.selectChatContentPage(page, limit, chatConversationId,content)); + } + + + @PostMapping("/deleteChatContentById") + @ApiOperation("删除某一句聊天记录") + public Result deleteChatContentById(Long chatContentId){ + chatContentService.removeById(chatContentId); + return Result.success(); + } + + + + + +} diff --git a/src/main/java/com/sqx/modules/chat/controller/app/AppChatController.java b/src/main/java/com/sqx/modules/chat/controller/app/AppChatController.java new file mode 100644 index 0000000..854ad4e --- /dev/null +++ b/src/main/java/com/sqx/modules/chat/controller/app/AppChatController.java @@ -0,0 +1,65 @@ +package com.sqx.modules.chat.controller.app; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.chat.entity.ChatConversation; +import com.sqx.modules.chat.service.ChatContentService; +import com.sqx.modules.chat.service.ChatConversationService; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.service.MessageService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.Map; + +@RestController +@Api(value = "聊天", tags = {"聊天"}) +@RequestMapping(value = "/app/chat") +public class AppChatController { + + @Autowired + private ChatContentService chatContentService; + @Autowired + private ChatConversationService chatConversationService; + @Autowired + private MessageService messageService; + + @Login + @GetMapping("/selectChatConversationPage") + @ApiOperation("获取聊天会话") + public Result selectChatConversationPage(Integer page,Integer limit,@RequestAttribute("userId") Long userId){ + return Result.success().put("data",chatConversationService.selectChatConversationPage(page, limit, userId,null)); + } + + @Login + @PostMapping("/insertChatConversation") + @ApiOperation("发起聊天") + public Result insertChatConversation(@RequestBody ChatConversation chatConversation){ + return chatConversationService.insertChatConversations(chatConversation); + } + + @Login + @GetMapping("/selectChatContent") + @ApiOperation("获取聊天记录") + public Result selectChatContent(Integer page,Integer limit,Long chatConversationId,@RequestAttribute("userId") Long userId){ + //清空未读消息 + chatContentService.updateChatContentStatusByUserIdAndChatId(userId, chatConversationId); + return Result.success().put("data",chatContentService.selectChatContentPage(page, limit, chatConversationId,null)); + } + + @Login + @GetMapping("/selectChatCount") + @ApiOperation("获取未读消息数量") + public Result selectChatCount(@RequestAttribute("userId") Long userId){ + int chatCount = chatContentService.selectChatCount(userId); + int messageCount = messageService.count(new QueryWrapper().eq("is_see", 0).eq("user_id", userId)); + Map result=new HashMap<>(); + result.put("chatCount",chatCount); + result.put("messageCount",messageCount); + return Result.success().put("data",result); + } +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/chat/controller/app/AppChatSocket.java b/src/main/java/com/sqx/modules/chat/controller/app/AppChatSocket.java new file mode 100644 index 0000000..9e62ec0 --- /dev/null +++ b/src/main/java/com/sqx/modules/chat/controller/app/AppChatSocket.java @@ -0,0 +1,181 @@ +package com.sqx.modules.chat.controller.app; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.chat.entity.ChatContent; +import com.sqx.modules.chat.service.ChatContentService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.websocket.*; +import javax.websocket.server.PathParam; +import javax.websocket.server.ServerEndpoint; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +@Slf4j +@Component +@ServerEndpoint("/chatSocket/{userId}") +public class AppChatSocket {//用户聊天 + + /** + * 在线人数 + */ + public static int onlineNumber = 0; + /** + * 以用户的id为key,WebSocket为对象保存起来 + */ + private static Map clients = new ConcurrentHashMap(); + private static SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + /** + * 会话 + */ + private Session session; + /** + * 用户id + */ + private String userId; + + // 这里使用静态,让 service 属于类 + private static ChatContentService chatContentService; + private static UserService userService; + + // 注入的时候,给类的 service 注入 + @Autowired + public void setWxChatContentService(ChatContentService chatContentService,UserService userService) { + AppChatSocket.chatContentService = chatContentService; + AppChatSocket.userService = userService; + } + + + + /** + * 建立连接 + * + * @param session + */ + @OnOpen + public void onOpen(@PathParam("userId") String userId, Session session) + { + onlineNumber++; + log.error("现在来连接的客户id:"+userId); + this.userId = userId; + this.session = session; + log.error("有新连接加入! 当前在线人数" + onlineNumber); + try { + //把自己的信息加入到map当中去 + AppChatSocket appChatSocket = clients.get(userId); + if(appChatSocket!=null){ + clients.remove(userId); + } + clients.put(userId, this); + + /*sendMessageTo("恭喜你连接成功!",wxUserId);*/ + } + catch (Exception e){ + log.error(userId+"上线的时候通知所有人发生了错误"); + } + + } + + @OnError + public void onError(Session session, Throwable error) { + log.error("服务端发生了错误"+error.getMessage()); + //error.printStackTrace(); + } + /** + * 连接关闭 + */ + @OnClose + public void onClose() + { + onlineNumber--; + //webSockets.remove(this); + clients.remove(userId); + log.error("有连接关闭! 当前在线人数" + onlineNumber); + } + + /** + * 收到客户端的消息 + * + * @param message 消息 + * @param session 会话 + */ + @OnMessage + public void onMessage(String message, Session session) + { + try { + JSONObject jsonObject = JSON.parseObject(message); + String textMessage = jsonObject.getString("content"); + String messageType = jsonObject.getString("messageType"); + String width = jsonObject.getString("width"); + String height = jsonObject.getString("height"); + String userId = jsonObject.getString("userId"); + String chatConversationId = jsonObject.getString("chatConversationId"); + chatContentService.updateChatContentStatusByUserIdAndChatId(Long.parseLong(this.userId), Long.parseLong(chatConversationId)); + //将聊天记录保存包数据库中 + ChatContent wxChatContent=new ChatContent(); + wxChatContent.setChatConversationId(Long.parseLong(chatConversationId)); + wxChatContent.setUserId(Long.parseLong(this.userId)); + wxChatContent.setWidth(width); + wxChatContent.setHeight(height); + wxChatContent.setContent(textMessage); + wxChatContent.setMessageType(messageType); + wxChatContent.setCreateTime(sdf.format(new Date())); + //判断对方是否在线 + AppChatSocket chatSocket = clients.get(userId); + if (chatSocket!=null) { + chatSocket.session.getAsyncRemote().sendText(message); + } + wxChatContent.setStatus(0); + chatContentService.save(wxChatContent); + UserEntity userEntity = userService.selectUserById(Long.parseLong(userId)); + if(userEntity!=null && StringUtils.isNotBlank(userEntity.getClientid())){ + UserEntity user = userService.selectUserById(Long.parseLong(this.userId)); + if("2".equals(messageType)){ + textMessage="[图片]"; + }else if("3".equals(messageType)){ + textMessage="[语音]"; + } + userService.pushToSingle("新消息提醒",user.getUserName()+":"+textMessage,userEntity.getClientid()); + } + /*AppChatSocket chatSocket = clients.get(userId); + if (chatSocket!=null) { + chatSocket.session.getAsyncRemote().sendText(message); + }*/ + } + catch (Exception e){ + log.error("发生了错误了"+e.getMessage(),e); + } + + } + + + public void sendMessageTo(String message, String ToUserName) throws IOException { + for (AppChatSocket item : clients.values()) { + if (item.userId.equals(ToUserName) ) { + item.session.getAsyncRemote().sendText(message); + System.err.println(this.userId+"发送成功:"+ToUserName); + break; + } + } + } + + public void sendMessageAll(String message,String FromUserName) throws IOException { + for (AppChatSocket item : clients.values()) { + item.session.getAsyncRemote().sendText(message); + } + } + + public static synchronized int getOnlineCount() { + return onlineNumber; + } + +} diff --git a/src/main/java/com/sqx/modules/chat/dao/ChatContentDao.java b/src/main/java/com/sqx/modules/chat/dao/ChatContentDao.java new file mode 100644 index 0000000..2f02c60 --- /dev/null +++ b/src/main/java/com/sqx/modules/chat/dao/ChatContentDao.java @@ -0,0 +1,25 @@ +package com.sqx.modules.chat.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.chat.entity.ChatContent; +import com.sqx.modules.common.entity.CommonInfo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + + +@Mapper +public interface ChatContentDao extends BaseMapper { + + IPage> selectChatContentPage(Page> page,@Param("chatConversationId") Long chatConversationId,@Param("content") String content); + + int updateChatContentStatusByUserIdAndChatId(@Param("userId") Long userId,@Param("chatConversationId") Long chatConversationId); + + int selectChatCount(@Param("userId") Long userId); + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/chat/dao/ChatConversationDao.java b/src/main/java/com/sqx/modules/chat/dao/ChatConversationDao.java new file mode 100644 index 0000000..c2113e4 --- /dev/null +++ b/src/main/java/com/sqx/modules/chat/dao/ChatConversationDao.java @@ -0,0 +1,22 @@ +package com.sqx.modules.chat.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.chat.entity.ChatContent; +import com.sqx.modules.chat.entity.ChatConversation; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Map; + + +@Mapper +public interface ChatConversationDao extends BaseMapper { + + IPage> selectChatConversationPage(Page> page,@Param("userId") Long userId,@Param("nickName") String nickName); + + int insertChatConversation(ChatConversation chatConversation); + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/chat/entity/ChatContent.java b/src/main/java/com/sqx/modules/chat/entity/ChatContent.java new file mode 100644 index 0000000..3db86fe --- /dev/null +++ b/src/main/java/com/sqx/modules/chat/entity/ChatContent.java @@ -0,0 +1,52 @@ +package com.sqx.modules.chat.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import java.util.Date; + +/** + * 聊天内容对象 chat_content + * + * @author fang + * @date 2020-03-17 + */ +@Data +@TableName("chat_content") +public class ChatContent { + private static final long serialVersionUID = 1L; + + /** 聊天内容id */ + @TableId(type = IdType.INPUT) + private Long chatContentId; + + /** 聊天会话id */ + private Long chatConversationId; + + /** 聊天内容 */ + private String content; + + /** 聊天类型 */ + private String messageType; + + /** 宽度 */ + private String width; + + /** 高度 */ + private String height; + + /** 发送人 */ + private Long userId; + + /** 状态(0未读 1已读) */ + private Integer status; + /** + * 创建时间 + */ + private String createTime; + +} diff --git a/src/main/java/com/sqx/modules/chat/entity/ChatConversation.java b/src/main/java/com/sqx/modules/chat/entity/ChatConversation.java new file mode 100644 index 0000000..8b21610 --- /dev/null +++ b/src/main/java/com/sqx/modules/chat/entity/ChatConversation.java @@ -0,0 +1,47 @@ +package com.sqx.modules.chat.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + + +/** + * 聊天会话对象 chat_conversation + * + * @author fang + * @date 2020-03-17 + */ +@Data +@TableName("chat_conversation") +public class ChatConversation { + private static final long serialVersionUID = 1L; + + /** 聊天会话id */ + @TableId(type = IdType.INPUT) + private Long chatConversationId; + + /** 发起人id */ + private Long userId; + + /** 接收人id */ + private Long focusedUserId; + + /** 状态 */ + private Long status; + + /** + * 创建时间 + */ + private String createTime; + + /** + * 修改时间 + */ + private String updateTime; + + /** 备注 */ + private String remark; + + +} diff --git a/src/main/java/com/sqx/modules/chat/service/ChatContentService.java b/src/main/java/com/sqx/modules/chat/service/ChatContentService.java new file mode 100644 index 0000000..6420b35 --- /dev/null +++ b/src/main/java/com/sqx/modules/chat/service/ChatContentService.java @@ -0,0 +1,17 @@ +package com.sqx.modules.chat.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.PageUtils; +import com.sqx.modules.chat.entity.ChatContent; +import org.apache.ibatis.annotations.Param; + +public interface ChatContentService extends IService { + + PageUtils selectChatContentPage(Integer page, Integer limit, Long chatConversationId,String content); + + int updateChatContentStatusByUserIdAndChatId(Long userId,Long chatConversationId); + + int selectChatCount(Long userId); + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/chat/service/ChatConversationService.java b/src/main/java/com/sqx/modules/chat/service/ChatConversationService.java new file mode 100644 index 0000000..55fce8a --- /dev/null +++ b/src/main/java/com/sqx/modules/chat/service/ChatConversationService.java @@ -0,0 +1,20 @@ +package com.sqx.modules.chat.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.chat.entity.ChatContent; +import com.sqx.modules.chat.entity.ChatConversation; + + +public interface ChatConversationService extends IService { + + PageUtils selectChatConversationPage(Integer page, Integer limit, Long userId,String nickName); + + int insertChatConversation(ChatConversation chatConversation); + + ChatConversation selectChatConversation(Long userId,Long focusedUserId); + + Result insertChatConversations(ChatConversation chatConversation); + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/chat/service/impl/ChatContentServiceImpl.java b/src/main/java/com/sqx/modules/chat/service/impl/ChatContentServiceImpl.java new file mode 100644 index 0000000..17763d4 --- /dev/null +++ b/src/main/java/com/sqx/modules/chat/service/impl/ChatContentServiceImpl.java @@ -0,0 +1,39 @@ +package com.sqx.modules.chat.service.impl; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.chat.dao.ChatContentDao; +import com.sqx.modules.chat.entity.ChatContent; +import com.sqx.modules.chat.service.ChatContentService; +import com.sqx.modules.common.dao.CommonInfoDao; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Date; + + +@Service +public class ChatContentServiceImpl extends ServiceImpl implements ChatContentService { + + + @Override + public PageUtils selectChatContentPage(Integer page, Integer limit, Long chatConversationId,String content) { + return new PageUtils(baseMapper.selectChatContentPage(new Page<>(page,limit),chatConversationId,content)); + } + + @Override + public int updateChatContentStatusByUserIdAndChatId(Long userId,Long chatConversationId){ + return baseMapper.updateChatContentStatusByUserIdAndChatId(userId, chatConversationId); + } + + @Override + public int selectChatCount(Long userId) { + return baseMapper.selectChatCount(userId); + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/chat/service/impl/ChatConversationServiceImpl.java b/src/main/java/com/sqx/modules/chat/service/impl/ChatConversationServiceImpl.java new file mode 100644 index 0000000..9a13c22 --- /dev/null +++ b/src/main/java/com/sqx/modules/chat/service/impl/ChatConversationServiceImpl.java @@ -0,0 +1,75 @@ +package com.sqx.modules.chat.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.chat.dao.ChatContentDao; +import com.sqx.modules.chat.dao.ChatConversationDao; +import com.sqx.modules.chat.entity.ChatContent; +import com.sqx.modules.chat.entity.ChatConversation; +import com.sqx.modules.chat.service.ChatContentService; +import com.sqx.modules.chat.service.ChatConversationService; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestBody; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.concurrent.locks.ReentrantReadWriteLock; + + +@Service +public class ChatConversationServiceImpl extends ServiceImpl implements ChatConversationService { + + private ReentrantReadWriteLock reentrantReadWriteLock=new ReentrantReadWriteLock(); + + + + @Override + public PageUtils selectChatConversationPage(Integer page, Integer limit, Long userId,String nickName){ + return new PageUtils(baseMapper.selectChatConversationPage(new Page<>(page,limit),userId,nickName)); + } + + + @Override + public int insertChatConversation(ChatConversation chatConversation) { + return baseMapper.insertChatConversation(chatConversation); + } + + @Override + public ChatConversation selectChatConversation(Long userId,Long focusedUserId){ + ChatConversation chatConversation = baseMapper.selectOne(new QueryWrapper().eq("user_id", userId).eq("focused_user_id", focusedUserId)); + if(chatConversation!=null){ + return chatConversation; + } + return baseMapper.selectOne(new QueryWrapper().eq("focused_user_id", userId).eq("user_id", focusedUserId)); + } + + + @Override + public Result insertChatConversations(ChatConversation chatConversation){ + reentrantReadWriteLock.writeLock().lock(); + try{ + ChatConversation chatConversation1 = selectChatConversation(chatConversation.getUserId(), chatConversation.getFocusedUserId()); + if(chatConversation1==null){ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String format = sdf.format(new Date()); + chatConversation.setCreateTime(format); + chatConversation.setUpdateTime(format); + baseMapper.insertChatConversation(chatConversation); + return Result.success().put("data",chatConversation); + } + return Result.success().put("data",chatConversation1); + }catch (Exception e){ + e.printStackTrace(); + log.error("发起聊天出错"+e.getMessage(),e); + }finally { + reentrantReadWriteLock.writeLock().unlock(); + } + return Result.error("系统繁忙,请稍后再试"); + } + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/chats/controller/ChatsContentController.java b/src/main/java/com/sqx/modules/chats/controller/ChatsContentController.java new file mode 100644 index 0000000..a4e9317 --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/controller/ChatsContentController.java @@ -0,0 +1,55 @@ +package com.sqx.modules.chats.controller; + +import com.sqx.modules.chats.entity.ChatsContent; +import com.sqx.modules.chats.service.ChatsContentService; +import com.sqx.modules.chats.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="聊天会话内容",tags={"聊天会话内容"}) +@RequestMapping(value = "/chatsContent") +public class ChatsContentController { + @Autowired + private ChatsContentService service; + + + @GetMapping("/list") + @ApiOperation("用户端聊天内容列表") + public Result findAll(Long chatId) { + return service.findAll(chatId); + } + + @GetMapping("/storeList") + @ApiOperation("商户端聊天内容列表") + public Result storeList(Long chatId) { + return service.storeList(chatId); + } + + + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @PostMapping("/save") + @ApiOperation("发送消息") + public Result saveBody(@RequestBody ChatsContent entity) { + return service.saveBody(entity); + } + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody ChatsContent entity) { + return service.updateBody(entity); + } + + @GetMapping("/delete") + @ApiOperation("删除聊天会话内容") + public Result delete(String ids) { + return service.delete(ids); + } + +} diff --git a/src/main/java/com/sqx/modules/chats/controller/ChatsController.java b/src/main/java/com/sqx/modules/chats/controller/ChatsController.java new file mode 100644 index 0000000..2336437 --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/controller/ChatsController.java @@ -0,0 +1,69 @@ +package com.sqx.modules.chats.controller; + + +import com.sqx.modules.chats.entity.Chats; +import com.sqx.modules.chats.service.ChatsService; +import com.sqx.modules.chats.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="聊天会话",tags={"聊天会话"}) +@RequestMapping(value = "/chats") +public class ChatsController { + @Autowired + private ChatsService service; + + @GetMapping("/count") + @ApiOperation("商家端未读消息") + public Result count(@ApiParam("店铺id(总后台商户传0)") @RequestParam Long storeId) { + return service.count(storeId); + } + + @GetMapping("/userCount") + @ApiOperation("用户端未读消息") + public Result userCount(@ApiParam("店铺id(总后台商户传0)") @RequestParam Long userId) { + return service.userCount(userId); + } + + @GetMapping("/list") + @ApiOperation("商家端会话列表") + public Result findAll(@ApiParam("店铺id(总后台商户传0)") @RequestParam Long storeId, + @ApiParam("用户昵称") @RequestParam(required = false) String userName) { + return service.findAll(storeId, userName); + } + + @GetMapping("/userList") + @ApiOperation("用户端会话列表") + public Result userList(Long userId) { + return service.userList(userId); + } + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @PostMapping("/save") + @ApiOperation("用户端发起聊天") + public Result saveBody(@RequestBody Chats entity) { + return service.saveBody(entity); + } + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody Chats entity) { + return service.updateBody(entity); + } + + @GetMapping("/delete") + @ApiOperation("删除聊天会话") + public Result delete(Long id) { + return service.delete(id); + } + +} diff --git a/src/main/java/com/sqx/modules/chats/controller/WebSocket.java b/src/main/java/com/sqx/modules/chats/controller/WebSocket.java new file mode 100644 index 0000000..e3a3b8a --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/controller/WebSocket.java @@ -0,0 +1,164 @@ +package com.sqx.modules.chats.controller; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.sqx.modules.chats.entity.ChatsContent; +import com.sqx.modules.chats.service.ChatsContentService; +import com.sqx.modules.chats.utils.DateUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.websocket.*; +import javax.websocket.server.PathParam; +import javax.websocket.server.ServerEndpoint; +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * WebSocket聊天实现 + */ +@Component +@ServerEndpoint("/websocket/{wxUserId}") +public class WebSocket { + private Logger logger = LoggerFactory.getLogger(this.getClass()); + + //通过类似GET请求方式传递参数的方法(服务端采用第二种方法"WebSocketHandler"实现) + //websocket = new WebSocket("ws://127.0.0.1:18080/testWebsocket?id=23&name=Lebron"); + /** + * 在线人数 + */ + public static int onlineNumber = 0; + /** + * 以用户的id为key,WebSocket为对象保存起来 + */ + private static Map clients = new ConcurrentHashMap(); + /** + * 会话 + */ + private Session session; + /** + * 用户id + */ + private String wxUserId; + + //这里使用静态,让 service 属于类 + private static ChatsContentService chatContentService; + + //注入的时候,给类的 service 注入 + @Autowired + public void setWxChatContentService(ChatsContentService chatContentService) { + WebSocket.chatContentService = chatContentService; + } + + + /** + * 建立连接 + * + * @param session + */ + @OnOpen + public void onOpen(@PathParam("wxUserId") String wxUserId, Session session) { + onlineNumber++; + logger.info("现在来连接的客户id:" + wxUserId); + this.wxUserId = wxUserId; + this.session = session; + logger.info("有新连接加入! 当前在线人数" + onlineNumber); + try { + //把自己的信息加入到map当中去 + clients.remove(wxUserId); + clients.put(wxUserId, this); + /*sendMessageTo("恭喜你连接成功!",wxUserId);*/ + } catch (Exception e) { + logger.info(wxUserId + "上线的时候通知所有人发生了错误"); + } + } + + @OnError + public void onError(Session session, Throwable error) { + logger.info("服务端发生了错误" + error.getMessage()); + } + + /** + * 连接关闭 + */ + @OnClose + public void onClose() { + onlineNumber--; + //webSockets.remove(this); + clients.remove(wxUserId); + logger.info("有连接关闭! 当前在线人数" + onlineNumber); + } + + /** + * 接收客户端的消息,并把消息发送给所有连接的会话 + */ + @OnMessage + public void onMessage(String message) { + try { + //解析聊天内容 + JSONObject jsonObject = JSON.parseObject(message); + String type = jsonObject.getString("type"); + String content = jsonObject.getString("content"); + String sendType = jsonObject.getString("sendType"); + String userId = jsonObject.getString("userId"); + String storeId = jsonObject.getString("storeId"); + Long chatId = Long.valueOf(jsonObject.getString("chatId")); //会话id + if ("1".equals(sendType)) { + logger.info("用户发送消息:" + message); + } else { + logger.info("客服发送消息:" + message); + } + //聊天记录 + ChatsContent wxChatContent = new ChatsContent(); + wxChatContent.setContent(content); + wxChatContent.setType(Integer.valueOf(type)); + wxChatContent.setSendType(Integer.valueOf(sendType)); + wxChatContent.setUserId(Long.valueOf(userId)); + wxChatContent.setStoreId(Long.valueOf(storeId)); + wxChatContent.setChatId(chatId); + wxChatContent.setCreateTime(DateUtil.createTime()); //创建时间 + wxChatContent.setStatus(1); //未读 + //判断对方是否在线,消息设为已读 + for (WebSocket item : clients.values()) { + if ("1".equals(sendType)) { //用户发送 + if (item.wxUserId.equals(storeId)) { + wxChatContent.setStatus(2); //已读 + item.session.getAsyncRemote().sendText(message); + } + }else { + if (item.wxUserId.equals(userId)) { + wxChatContent.setStatus(2); //已读 + item.session.getAsyncRemote().sendText(message); + } + } + } + //保存消息内容 + chatContentService.saveBody(wxChatContent); + } catch (Exception e) { + logger.info("发生了错误了"); + } + } + + public void sendMessageTo(String message, String wxUserId) throws IOException { + for (WebSocket item : clients.values()) { + if (item.wxUserId.equals(wxUserId)) { + item.session.getAsyncRemote().sendText(message); + break; + } + } + } + + public void sendMessageAll(String message, String FromUserName) throws IOException { + for (WebSocket item : clients.values()) { + item.session.getAsyncRemote().sendText(message); + } + } + + public static synchronized int getOnlineCount() { + return onlineNumber; + } + +} diff --git a/src/main/java/com/sqx/modules/chats/controller/app/AppChatsController.java b/src/main/java/com/sqx/modules/chats/controller/app/AppChatsController.java new file mode 100644 index 0000000..8007f8c --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/controller/app/AppChatsController.java @@ -0,0 +1,35 @@ +package com.sqx.modules.chats.controller.app; + + +import com.sqx.modules.chats.entity.Chats; +import com.sqx.modules.chats.service.ChatsContentService; +import com.sqx.modules.chats.service.ChatsService; +import com.sqx.modules.chats.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="聊天会话",tags={"聊天会话"}) +@RequestMapping(value = "/app/chats") +public class AppChatsController { + + @Autowired + private ChatsService service; + @Autowired + private ChatsContentService chatsContentService; + + @PostMapping("/save") + @ApiOperation("用户端发起聊天") + public Result saveBody(@RequestBody Chats entity) { + return service.saveBody(entity); + } + + @GetMapping("/list") + @ApiOperation("用户端聊天内容列表") + public Result findAll(Long chatId) { + return chatsContentService.findAll(chatId); + } + +} diff --git a/src/main/java/com/sqx/modules/chats/entity/Chats.java b/src/main/java/com/sqx/modules/chats/entity/Chats.java new file mode 100644 index 0000000..59624c1 --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/entity/Chats.java @@ -0,0 +1,44 @@ +package com.sqx.modules.chats.entity; + +import lombok.Data; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * 聊天会话 + */ +@Data +@Entity +@org.hibernate.annotations.Table(appliesTo = "chats",comment = "聊天会话") +public class Chats implements Serializable { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(columnDefinition = "bigInt(20) comment '会话id'") + private Long chatId; + @Column(columnDefinition = "varchar(255) comment '创建时间'") + private String createTime; + /**用户信息*/ + @Column(columnDefinition = "bigInt(20) comment '用户id'") + private Long userId; + @Column(columnDefinition = "varchar(255) comment '用户头像'") + private String userHead; + @Column(columnDefinition = "varchar(255) comment '用户昵称'") + private String userName; + /**商户信息*/ + @Column(columnDefinition = "bigInt(20) comment '总后台id(总后台传0'") + private Long storeId; + @Column(columnDefinition = "varchar(255) comment '后台头像'") + private String storeHead; + @Column(columnDefinition = "varchar(255) comment '商户昵称'") + private String storeName; + /**聊天内容*/ + @Column(columnDefinition = "int default 0 comment'用户未读条数'") + private Integer userCount; + @Column(columnDefinition = "int default 0 comment'后台未读条数'") + private Integer storeCount; + @Transient + private String content; //聊天内容 + @Transient + private String contentTime; //消息时间 +} diff --git a/src/main/java/com/sqx/modules/chats/entity/ChatsContent.java b/src/main/java/com/sqx/modules/chats/entity/ChatsContent.java new file mode 100644 index 0000000..3a48d40 --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/entity/ChatsContent.java @@ -0,0 +1,39 @@ +package com.sqx.modules.chats.entity; + +import lombok.Data; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * 聊天会话内容 + */ + +@Data +@Entity +@org.hibernate.annotations.Table(appliesTo = "chats_content",comment = "聊天会话内容") +public class ChatsContent implements Serializable { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(columnDefinition = "bigInt(20) comment '会话内容id'") + private Long chatContentId; + @Column(columnDefinition = "text comment '聊天内容'") + private String content; + @Column(columnDefinition = "int(1) comment '类型(1文字 2图片 3订单 4商品)'") + private Integer type; + @Column(columnDefinition = "int default 1 comment '是否已读(1未读 2已读)'") + private Integer status; + @Column(columnDefinition = "varchar(255) comment '创建时间'") + private String createTime; + @Column(columnDefinition = "int(1) comment '消息来源(1用户消息 2后台消息)'") + private Integer sendType; + @Column(columnDefinition = "bigInt(20) comment '用户id'") + private Long userId; + @Column(columnDefinition = "bigInt(20) comment '后台id(总后台传0)'") + private Long storeId; + /**会话信息*/ + @Column(columnDefinition = "bigInt(20) comment '会话id'") + private Long chatId; + @Transient + private Chats chat; //聊天会话 +} diff --git a/src/main/java/com/sqx/modules/chats/respository/ChatContentRepository.java b/src/main/java/com/sqx/modules/chats/respository/ChatContentRepository.java new file mode 100644 index 0000000..2a56b05 --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/respository/ChatContentRepository.java @@ -0,0 +1,42 @@ +package com.sqx.modules.chats.respository; + + + +import com.sqx.modules.chats.entity.ChatsContent; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Repository +public interface ChatContentRepository extends JpaRepository { + + //条件查询带分页 + Page findAll(Specification specification, Pageable pageable); + + //条件查询 + List findAll(Specification specification); + + //根据会话id删除聊天内容 + void deleteAllByChatId(Long chatId); + + //用户消息设置为已读 + @Modifying + @Transactional + @Query(value = "update ChatsContent s set s.status=2 where s.chatId=:chatId and s.sendType=1") + Integer updateStatusByChantIdAndSendTye1(@Param("chatId") Long chatId); + + //店铺消息设置为已读 + @Modifying + @Transactional + @Query(value = "update ChatsContent s set s.status=2 where s.chatId=:chatId and s.sendType=2") + Integer updateStatusByChantIdAndSendTye2(@Param("chatId") Long chatId); + +} diff --git a/src/main/java/com/sqx/modules/chats/respository/ChatRepository.java b/src/main/java/com/sqx/modules/chats/respository/ChatRepository.java new file mode 100644 index 0000000..0f6b606 --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/respository/ChatRepository.java @@ -0,0 +1,77 @@ +package com.sqx.modules.chats.respository; + + +import com.sqx.modules.chats.entity.Chats; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Map; + +@Repository +public interface ChatRepository extends JpaRepository { + + //条件查询带分页 + Page findAll(Specification specification, Pageable pageable); + + //条件查询 + List findAll(Specification specification, Sort sort); + + //商家端未读消息统计 + @Query(value = "select sum(s.storeCount) from Chats s where s.storeId=:storeId") + Integer count(@Param("storeId") Long storeId); + + @Query(value = "select sum(s.userCount) from Chats s where s.userId=:userId") + Integer userCounts(@Param("userId") Long userId); + + //根据用户id和店铺id查询会话 + @Query(value = "from Chats s where s.userId=:userId and s.storeId=:storeId") + List findByUserIdAndStoreId(@Param("userId") Long userId, @Param("storeId") Long storeId); + + //商家端会话列表 + @Query(value = "select c.chat_id as chatId,c.store_count as storeCount,c.user_head as userHead,c.user_name as userName, cc.content, cc.create_time as contentContent from chats c left join chat_content cc on c.chat_id = cc.chat_id where c.store_id=:storeId order by cc.create_time desc", + nativeQuery=true) + List> findAllByStoreId(@Param("storeId") Long storeId); + + //商家端会话列表 + @Query(value = "select c.chat_id as chatId,c.store_count as storeCount,c.user_head as userHead,c.user_name as userName, cc.content, cc.create_time as contentContent from chats c left join chat_content cc on c.chat_id = cc.chat_id where c.store_id=:storeId and c.user_name like concat('%',:userName,'%') order by cc.create_time desc", + nativeQuery=true) + List> findAllByStoreIdAndUserName(@Param("storeId") Long storeId, @Param("userName") String userName); + + //用户端会话列表 + @Query(value = "select c.chat_id as chatId,c.store_head as storeHead,c.store_name as storeName,c.user_count as userCount, cc.content, cc.create_time as contentContent from chats c left join chat_content cc on c.chat_id = cc.chat_id where c.user_id=:userId order by cc.create_time desc limit 0,1", + nativeQuery=true) + List> findAllByUserId(@Param("userId") Long userId); + + //店铺未读+1 + @Modifying + @Transactional + @Query(value = "update Chats s set s.storeCount=s.storeCount+1, s.createTime=:createTime where s.chatId=:chatId") + Integer addStoreCount(@Param("chatId") Long chatId, @Param("createTime") String createTime); + + //店铺未读清空 + @Modifying + @Transactional + @Query(value = "update Chats s set s.storeCount=0 where s.chatId=:chatId") + Integer storeCount(@Param("chatId") Long chatId); + + //用户未读+1 + @Modifying + @Transactional + @Query(value = "update Chats s set s.userCount=s.userCount+1, s.createTime=:createTime where s.chatId=:chatId") + Integer addUserCount(@Param("chatId") Long chatId, @Param("createTime") String createTime); + + //用户未读清空 + @Modifying + @Transactional + @Query(value = "update Chats s set s.userCount=0 where s.chatId=:chatId") + Integer userCount(@Param("chatId") Long chatId); +} diff --git a/src/main/java/com/sqx/modules/chats/service/ChatsContentService.java b/src/main/java/com/sqx/modules/chats/service/ChatsContentService.java new file mode 100644 index 0000000..cae4189 --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/service/ChatsContentService.java @@ -0,0 +1,39 @@ +package com.sqx.modules.chats.service; + + +import com.sqx.modules.chats.entity.ChatsContent; +import com.sqx.modules.chats.utils.Result; + +public interface ChatsContentService { + + /** + * 用户聊天内容列表 + * @param chatId + * @return + */ + Result findAll(Long chatId); + + /** + * 店铺聊天内容列表 + * @param chatId + * @return + */ + Result storeList(Long chatId); + + //查询 + Result findOne(Long id); + + //删除 + Result delete(String ids); + + /** + * 发送消息 + * @param entity + * @return + */ + Result saveBody(ChatsContent entity); + + //修改 + Result updateBody(ChatsContent entity); + +} diff --git a/src/main/java/com/sqx/modules/chats/service/ChatsContentServiceImpl.java b/src/main/java/com/sqx/modules/chats/service/ChatsContentServiceImpl.java new file mode 100644 index 0000000..372de0a --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/service/ChatsContentServiceImpl.java @@ -0,0 +1,140 @@ +package com.sqx.modules.chats.service; + + +import com.sqx.modules.chats.entity.Chats; +import com.sqx.modules.chats.entity.ChatsContent; +import com.sqx.modules.chats.respository.ChatContentRepository; +import com.sqx.modules.chats.respository.ChatRepository; +import com.sqx.modules.chats.utils.DateUtil; +import com.sqx.modules.chats.utils.Result; +import com.sqx.modules.chats.utils.ResultUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import java.util.ArrayList; +import java.util.List; + +@Service +public class ChatsContentServiceImpl implements ChatsContentService { + @Autowired + private ChatContentRepository jpaRepository; + @Autowired + private ChatRepository chatRepository; + + /** + * 用户聊天内容列表 + * @param chatId 会话id + * @return + */ + @Override + public Result findAll(Long chatId) { + //构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + predicateList.add(criteriaBuilder.equal(root.get("chatId"), chatId)); + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + List list = jpaRepository.findAll(queryCondition); + /* + 用户调取消息内容列表 + 1.用户的未读数为0 + 2.店铺发送的消息为已读 + */ + chatRepository.userCount(chatId); //用户未读为0 + jpaRepository.updateStatusByChantIdAndSendTye2(chatId); //用户调取列表,设置店铺发送的消息为已读 + //聊天会话信息 + List allChat = chatRepository.findAll(); + for (ChatsContent cc : list) { + for (Chats c : allChat) { + if (c.getChatId().equals( cc.getChatId())){ + cc.setChat(c); + } + } + } + return ResultUtil.success(list); + } + + /** + * 店铺聊天内容列表 + * @param chatId + * @return + */ + @Override + public Result storeList(Long chatId) { + //构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + predicateList.add(criteriaBuilder.equal(root.get("chatId"), chatId)); + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + List list = jpaRepository.findAll(queryCondition); + /* + 店铺调取消息内容列表 + 1.店铺的未读数为0 + 2.用户发送的消息为已读 + */ + chatRepository.storeCount(chatId); //用户未读为0 + jpaRepository.updateStatusByChantIdAndSendTye1(chatId); //店铺调取列表,设置用户发送的消息为已读 + //聊天会话信息 + List allChat = chatRepository.findAll(); + for (ChatsContent cc : list) { + for (Chats c : allChat) { + if (c.getChatId().equals(cc.getChatId())){ + cc.setChat(c); + } + } + } + return ResultUtil.success(list); + } + + /** + * 发送消息 + * @param entity + * @return + */ + @Override + public Result saveBody(ChatsContent entity) { + //发送消息保存消息 + entity.setCreateTime(DateUtil.createTime()); + entity.setStatus(1); //未读 + ChatsContent save = jpaRepository.save(entity); + //会话列表未读加1 + if (save.getSendType() == 1){ + chatRepository.addStoreCount(save.getChatId(), DateUtil.createTime()); //用户发送消息,店铺未读+1 + }else { + chatRepository.addUserCount(save.getChatId(), DateUtil.createTime()); //店铺发送消息,用户未读+1 + } + return ResultUtil.success(save); + } + + @Override + public Result updateBody(ChatsContent entity) { + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result findOne(Long id) { + return ResultUtil.success(jpaRepository.findById(id).orElse(null)); + } + + @Override + public Result delete(String ids) { + String[] split = ids.split(","); + for (String id : split) { + jpaRepository.deleteById(Long.valueOf(id)); + } + return ResultUtil.success(); + } + +} diff --git a/src/main/java/com/sqx/modules/chats/service/ChatsService.java b/src/main/java/com/sqx/modules/chats/service/ChatsService.java new file mode 100644 index 0000000..d9522ca --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/service/ChatsService.java @@ -0,0 +1,43 @@ +package com.sqx.modules.chats.service; + + +import com.sqx.modules.chats.entity.Chats; +import com.sqx.modules.chats.utils.Result; + +public interface ChatsService { + + /** + * 商家端未读消息 + * @param storeId + * @return + */ + Result count(Long storeId); + Result userCount(Long count); + + /** + * 商家端会话列表 + * @param storeId + * @return + */ + Result findAll(Long storeId, String userName); + + /** + * 用户端会话列表 + * @param userId + * @return + */ + Result userList(Long userId); + + //查询 + Result findOne(Long id); + + //删除 + Result delete(Long id); + + //添加 + Result saveBody(Chats entity); + + //修改 + Result updateBody(Chats entity); + +} diff --git a/src/main/java/com/sqx/modules/chats/service/ChatsServiceImpl.java b/src/main/java/com/sqx/modules/chats/service/ChatsServiceImpl.java new file mode 100644 index 0000000..d085613 --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/service/ChatsServiceImpl.java @@ -0,0 +1,134 @@ +package com.sqx.modules.chats.service; + + +import com.sqx.modules.chat.entity.ChatContent; +import com.sqx.modules.chats.entity.Chats; +import com.sqx.modules.chats.entity.ChatsContent; +import com.sqx.modules.chats.respository.ChatContentRepository; +import com.sqx.modules.chats.respository.ChatRepository; +import com.sqx.modules.chats.utils.DateUtil; +import com.sqx.modules.chats.utils.Result; +import com.sqx.modules.chats.utils.ResultUtil; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import java.util.ArrayList; +import java.util.List; + +@Service +public class ChatsServiceImpl implements ChatsService { + @Autowired + private ChatRepository jpaRepository; + @Autowired + private ChatContentRepository chatContentRepository; + + @Override + public Result count(Long storeId) { + Integer count = jpaRepository.count(storeId); + return ResultUtil.success(count==null?0:count); + } + + @Override + public Result userCount(Long userId) { + Integer count = jpaRepository.userCounts(userId); + return ResultUtil.success(count==null?0:count); + } + + /** + * 商家端会话列表 + * @param storeId + * @return + */ + @Override + public Result findAll(Long storeId, String userName) { + //构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + predicateList.add(criteriaBuilder.equal(root.get("storeId"), storeId)); + if (StringUtils.isNotEmpty(userName)){ + predicateList.add(criteriaBuilder.like(root.get("userName"), "%"+userName+"%")); + } + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + List list = jpaRepository.findAll(queryCondition, Sort.by(new Sort.Order(Sort.Direction.DESC, "createTime"))); + //最新一条消息展示 + List allContent = chatContentRepository.findAll(); + for (Chats c : list) { + for (ChatsContent cc : allContent) { + if (c.getChatId().equals(cc.getChatId())){ + c.setContent(cc.getContent()); + c.setContentTime(cc.getCreateTime()); + } + } + } + return ResultUtil.success(list); + } + + /** + * 用户端会话列表 + * @param userId + * @return + */ + @Override + public Result userList(Long userId) { + //构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + predicateList.add(criteriaBuilder.equal(root.get("userId"), userId)); + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + List list = jpaRepository.findAll(queryCondition, Sort.by(new Sort.Order(Sort.Direction.DESC, "createTime"))); + return ResultUtil.success(list); + } + + /** + * 用户端发起聊天 + * @param entity + * @return + */ + @Override + public Result saveBody(Chats entity) { + //判断是否存在聊天 + List chatList = jpaRepository.findByUserIdAndStoreId(entity.getUserId(), entity.getStoreId()); + if (chatList.size() > 0){ + Chats chat = chatList.get(0); + return ResultUtil.success(chat); + }else { + //不存在会话,创建会话 + entity.setCreateTime(DateUtil.createTime()); + Chats save = jpaRepository.save(entity); + return ResultUtil.success(save); + } + } + + @Override + public Result updateBody(Chats entity) { + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result findOne(Long id) { + return ResultUtil.success(jpaRepository.findById(id).orElse(null)); + } + + + @Override + public Result delete(Long id) { + jpaRepository.deleteById(id); //删除会话 + chatContentRepository.deleteAllByChatId(id); //删除会话聊天内容 + return ResultUtil.success(); + } + +} diff --git a/src/main/java/com/sqx/modules/chats/utils/DateUtil.java b/src/main/java/com/sqx/modules/chats/utils/DateUtil.java new file mode 100644 index 0000000..498c43f --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/utils/DateUtil.java @@ -0,0 +1,547 @@ +package com.sqx.modules.chats.utils; + +import org.apache.commons.lang.time.DateUtils; +import org.apache.commons.lang3.StringUtils; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +public class DateUtil { + /** + * 判断是否是购物节日期 + * @param date + * @return true 是 + */ + public static boolean isShoppingFestival(Date date){ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + int month = calendar.get(Calendar.MONTH)+1; + int day = calendar.get(Calendar.DAY_OF_MONTH); + + //判断是否是双十一 + if(month==11 && day==11){ + return true; + } + + //判断是否是双十二 + if(month==12 && day==12){ + return true; + } + + return false; + } + + /** + * 获取两个日期之间左右年月 + * @param minDate + * @param maxDate + * @return + * @throws ParseException + */ + public static List getMonthBetween(Date minDate, Date maxDate) throws ParseException { + ArrayList result = new ArrayList(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");//格式化为年月 + + Calendar min = Calendar.getInstance(); + Calendar max = Calendar.getInstance(); + + min.setTime(minDate); + min.set(min.get(Calendar.YEAR), min.get(Calendar.MONTH), 1); + + max.setTime(maxDate); + max.set(max.get(Calendar.YEAR), max.get(Calendar.MONTH), 2); + + Calendar curr = min; + while (curr.before(max)) { + result.add(sdf.format(curr.getTime())); + curr.add(Calendar.MONTH, 1); + } + + return result; + } + + /** + * 获取指定月份天数 + * @param year 年份(四位数) + * @param month 月份(从1开始) + * @return + */ + public static int getMonthDays(int year, int month) { + if (month == 2) { + if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) { + return 29; + } else { + return 28; + } + } else if (month == 4 || month == 6 || month == 9 || month == 11) { + return 30; + } else { + return 31; + } + } + + /** + * 判断时间是否在时间段内 + * + * @param date + * 当前时间 yyyy-MM-dd HH:mm:ss + * @param strDateBegin + * 开始时间 00:00 + * @param strDateEnd + * 结束时间 00:05 + * @return 在时间段内返回true + */ + public static boolean isInDate(Date date, String strDateBegin, String strDateEnd) { + + if(date==null || StringUtils.isBlank(strDateBegin) || StringUtils.isBlank(strDateEnd)){ + return false; + } + + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); + String strDate = sdf.format(date); + // 截取当前时间时分秒 + int strDateH = Integer.parseInt(strDate.substring(0, 2)); + int strDateM = Integer.parseInt(strDate.substring(3, 5)); + // 截取开始时间时分秒 + int strDateBeginH = Integer.parseInt(strDateBegin.substring(0, 2)); + int strDateBeginM = Integer.parseInt(strDateBegin.substring(3, 5)); + // 截取结束时间时分秒 + int strDateEndH = Integer.parseInt(strDateEnd.substring(0, 2)); + int strDateEndM = Integer.parseInt(strDateEnd.substring(3, 5)); + + if(strDateH >= strDateBeginH && strDateH <= strDateEndH){ + + //判断开始时间和结束时间的小时是否一样 + if(strDateBeginH == strDateEndH){ //是 + + // + if(strDateH == strDateBeginH){ + if(strDateM >= strDateBeginM && strDateM <= strDateEndM){ + return true; + } + }else{ + return false; + } + + }else{ //否 + + if(strDateH == strDateBeginH){ + + if(strDateM >= strDateBeginM){ + return true; + }else{ + return false; + } + + }else if(strDateH == strDateEndH){ + + if(strDateM <= strDateEndM){ + return true; + }else{ + return false; + } + + }else{ + return true; + } + + } + }else{ + return false; + } + + return false; + } + /** + * + * @param pattern,字符串的format格式,例如:yyyy-MM-dd HH:mm:ss + * @param date,需要转换为指定格式的日期对象 + * @return + */ + public static String getFormatStrByPatternAndDate(String pattern,Date date){ + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); + return simpleDateFormat.format(date); + } + public static Date getDataByFormatString(String pattern,String dateFormatStr){ + try { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); + return simpleDateFormat.parse(dateFormatStr); + } catch (ParseException e) { + e.printStackTrace(); + return null; + } + } + + /** + * 将日期的时分秒转为 00:00:00 + * @param date + * @return + * @throws + */ + public static Date lowDate(Date date){ + String lowDate = getFormatStrByPatternAndDate("yyyy-MM-dd",date) + " 00:00:00"; + return getDataByFormatString("yyyy-MM-dd HH:mm:ss",lowDate); + } + + /** + * 将日期的时分秒转为 23:59:59 + * @param date + * @return + * @throws ParseException + */ + public static Date hightDate(Date date){ + String lowDate = getFormatStrByPatternAndDate("yyyy-MM-dd",date) + " 23:59:59"; + return getDataByFormatString("yyyy-MM-dd HH:mm:ss",lowDate); + } + + /** + * 计算d1 到 d2 相差多少时间 + * @param d1 未来的时间 + * @param d2 现在的时间 + * @return 数组下标 0 天 1 时 2 分 3 秒 + */ + public static long[] dateDiff(Date d1, Date d2) throws ParseException { + long nd = 1000*24*60*60;//一天的毫秒数 + long nh = 1000*60*60;//一小时的毫秒数 + long nm = 1000*60;//一分钟的毫秒数 + long ns = 1000;//一秒钟的毫秒数 + //获得两个时间的毫秒时间差异 + long diff = d1.getTime() - d2.getTime(); + long day = diff/nd;//计算差多少天 + long hour = diff%nd/nh;//计算差多少小时 + long min = diff%nd%nh/nm;//计算差多少分钟 + long sec = diff%nd%nh%nm/ns;//计算差多少秒 + return new long[]{day,hour,min,sec}; + } + + /** + * 判断 start 是否大于 end + * @param start + * @param end + * @return + * @throws ParseException + */ + public static boolean startThanEnd(Date start, Date end) throws ParseException{ + long[] result = dateDiff(start, end); + if(result[0]>=0 && result[1]>=0 && result[2]>=0 && result[3]>=0){ + return true; + } + return false; + } + + /** + * 获取指定日期指定分钟后的日期 + * @param date + * @param minute + * @return + */ + public static Date getLaterMinute(Date date, Long minute) { + minute = minute == null ? 0 : minute; + long curren = date.getTime(); + curren += minute * 60 * 1000; + return new Date(curren); + } + + /** + * 获取指定日期指定分钟前的日期 + * @param date + * @param minute + * @return + */ + public static Date getPreviouslyMinute(Date date, Long minute) { + minute = minute == null ? 0 : minute; + long curren = date.getTime(); + curren -= minute * 60 * 1000; + return new Date(curren); + } + + /** + * 获取指定日期指定天数后的日期 + * @param date 指定的时间 + * @param later 指定的天数 + * @return + */ + public static Date getLaterDay(Date date, Long later){ + later = later == null ? 0 : later; + long current = date.getTime(); + return new Date(current + later * 24 * 60 * 60 * 1000); + } + + + /** + * 获取指定日期指定天数前的日期 + * @param date 指定的时间 + * @param later 指定的天数 + * @return + */ + public static Date getPreviouslyDay(Date date, Long later){ + later = later == null ? 0 : later; + long current = date.getTime(); + return new Date(current - later * 24 * 60 * 60 * 1000); + } + + /** + * 获取指定日期指定小时后的日期 + * @param date 指定的时间 + * @param later 指定的小时 + * @return + */ + public static Date getLaterHour(Date date, Long later){ + later = later == null ? 0 : later; + long current = date.getTime(); + return new Date(current + later * 60 * 60 * 1000); + } + + /** + * 获取指定日期指定小时前的日期 + * @param date 指定的时间 + * @param later 指定的小时 + * @return + */ + public static Date getPreviouslyHour(Date date, Long later){ + later = later == null ? 0 : later; + long current = date.getTime(); + return new Date(current - later * 60 * 60 * 1000); + } + + /** + * 得到本周周一 + * @return + */ + public static Date getMondayOfWeek() { + Calendar c = Calendar.getInstance(); + int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1; + if (day_of_week == 0){ + day_of_week = 7; + } + c.add(Calendar.DATE, -day_of_week + 1); + return c.getTime(); + } + + /** + * 得到本周周日 + * @return + */ + public static Date getSundayOfWeek() { + Calendar c = Calendar.getInstance(); + int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1; + if (day_of_week == 0){ + day_of_week = 7; + } + c.add(Calendar.DATE, -day_of_week + 7); + return c.getTime(); + } + + /** + * 获取当前月的第一天 + * @return + */ + public static Date getFirstDayOfMonth(){ + Calendar c = Calendar.getInstance(); + c.add(Calendar.MONTH, 0); + c.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天 + return c.getTime(); + } + + /** + * 获取当前月的最后一天 + * @return + */ + public static Date getLastDayOfMonth(){ + Calendar ca = Calendar.getInstance(); + ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH)); + return ca.getTime(); + } + + /** + * 获取上一个月的第一天 + * @return + */ + public static Date getFirstDayOfPreviouslyMonth(){ + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, -1); + calendar.set(Calendar.DAY_OF_MONTH,1); + return calendar.getTime(); + } + + /** + * 获取上一个月的最后一天 + * @return + */ + public static Date getLastDayOfPreviouslyMonth(){ + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.DAY_OF_MONTH, 0); + return calendar.getTime(); + } + + /** + * 获取上上一个月的第一天 + * @return + */ + public static Date getFirstDayOfPPreviouslyMonth(){ + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, -2); + calendar.set(Calendar.DAY_OF_MONTH,1); + return calendar.getTime(); + } + + /** + * 获取上上一个月的最后一天 + * @return + */ + public static Date getLastDayOfPPreviouslyMonth(){ + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, -1); + calendar.set(Calendar.DAY_OF_MONTH, 0); + return calendar.getTime(); + } + + /** + * 获取指定日期是星期几 + * @param date + * @return + */ + public static int getDayOfWeek(Date date) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + //一周第一天是否为星期天 + boolean isFirstSunday = (cal.getFirstDayOfWeek() == Calendar.SUNDAY); + //获取周几 + int weekDay = cal.get(Calendar.DAY_OF_WEEK); + //若一周第一天为星期天,则-1 + if (isFirstSunday) { + weekDay = weekDay - 1; + if (weekDay == 0) { + weekDay = 7; + } + } + return weekDay; + } + + /** + * 获取创建时间 + * @return + */ + public static String createTime() { + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + } + + /** + * 获取创建时间 + * @return + */ + public static String createDate() { + return new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + } + + /** + * 结束时间 + * @return + */ + public static String endTime(Integer hours) { + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = DateUtils.addHours(new Date(), hours); + return sf.format(date); + } + + /** + * 结束时间 + * @param days 日期 + * @return + */ + public static String addDays(String nowTime, Integer days) { + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try{ + Date date = DateUtils.addDays(sf.parse(nowTime), days); + return sf.format(date); + }catch (Exception e){ + e.printStackTrace(); + return null; + } + } + + //判断是否在规定的时间内签到 nowTime 当前时间 beginTime规定开始时间 endTime规定结束时间 + public static boolean betweenStratEndTime(String startTime, String endTime) throws Exception{ + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String now = sf.format(new Date()); + //设置当前时间 + Calendar date = Calendar.getInstance(); + date.setTime(sf.parse(now)); + //设置开始时间 + Calendar start = Calendar.getInstance(); + start.setTime(sf.parse(startTime));//开始时间 + //设置结束时间 + Calendar end = Calendar.getInstance(); + start.setTime(sf.parse(endTime));//开始时间 + //处于开始时间之后,和结束时间之前的判断 + + if ((start.after(date) && end.before(date))) { + return true; + } else { + return false; + } + } + + /** + * 获取当前日期的几天前/后的日期:传入-1为一天前 + * @return + */ + public static String getBeforeDay(int num){ + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); + Calendar cal = Calendar.getInstance(); + cal.setTime(new Date()); + cal.add(Calendar.DATE, num); + return sf.format(cal.getTime()); + } + + /** + * 获取当前日期的几月前/后的日期:传入-1为上月 + * @return + */ + public static String getBeforeMonth(int num){ + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM"); + Calendar cal = Calendar.getInstance(); + cal.setTime(new Date()); + cal.add(Calendar.MONTH, num); + return sf.format(cal.getTime()); + } + + /** + * 是否开始 + * @param startTime 开始时间 + * @return true 已开始 + */ + public static boolean isStart(String startTime){ + try{ + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date f = sf.parse(startTime); + return f.before(new Date()); + }catch (Exception e){ + e.printStackTrace(); + } + return true; + } + + /** + * 获取指定时间几分钟前的时间 + * @return + */ + public static String getBeforeMinute(String time, int num){ + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Calendar cal = Calendar.getInstance(); + try{ + Date timeDate = sf.parse(time); + cal.setTime(timeDate); + cal.add(Calendar.MINUTE, -num); + return sf.format(cal.getTime()); + }catch (Exception e){ + e.printStackTrace(); + } + return time; + } + +} diff --git a/src/main/java/com/sqx/modules/chats/utils/DescribeException.java b/src/main/java/com/sqx/modules/chats/utils/DescribeException.java new file mode 100644 index 0000000..8c7799b --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/utils/DescribeException.java @@ -0,0 +1,34 @@ +package com.sqx.modules.chats.utils; + +public class DescribeException extends RuntimeException{ + + private Integer code; + + /** + * 继承exception,加入错误状态值 + * @param exceptionEnum + */ + public DescribeException(ExceptionEnum exceptionEnum) { + super(exceptionEnum.getMsg()); + this.code = exceptionEnum.getCode(); + } + + /** + * 自定义错误信息 + * @param message + * @param code + */ + public DescribeException(String message, Integer code) { + super(message); + this.code = code; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } +} + diff --git a/src/main/java/com/sqx/modules/chats/utils/ExceptionEnum.java b/src/main/java/com/sqx/modules/chats/utils/ExceptionEnum.java new file mode 100644 index 0000000..3240791 --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/utils/ExceptionEnum.java @@ -0,0 +1,49 @@ +package com.sqx.modules.chats.utils; + +public enum ExceptionEnum { + UNKNOW_ERROR(-1, "未知错误"), + LIMIT_USER(-100, "当前账户受限制请联系管理员"), + USER_NOT_FIND(-101, "用户未注册"), + USER_IS_BIND_FOR_ANTHER_OPENID(-99, "当前手机号已经被其他微信绑定"), + WRONT_TOKEN(-102, "用户信息失效,请重新登录"), + USER_PWD_EMPTY(-103, "用户名密码不能为空"), + USER_PWD_ERROR(-104, "用户名或密码错误"), + USER_IS_EXITS(-105, "手机号已经注册!"), + ERROR(-106, "服务器内部错误"), + UPDATE_PWD_ERROR(-107, "密码修改失败"), + STATE_PWD_ERROR(-108, "状态修改失败"), + DATA_EMPTY(-109, "添加数据不能为空"), + Return_ATA_EMPTY(-110, "暂无数据"), + ADD_ERROR(-111, "提现失败"), + CODE_ERROR(-112, "验证码不正确"), + BIND_ERROR(-113, "手机号已经被其他账号绑定"), + SEND_ERROR(-114, "验证码发送失败"), + USER_PHONE_ERROR(-115, "用户名不能为空"), + OLD_PWD_ERROR(-116, "原始密码错误"), + IS_REGISTER(-117, "当前手机号已经绑定其他微信账号"), + IS_BIND(-118, "当前淘宝账号已经绑定其他手机号"), + IS_BIND_RELATION(-119, "当前账号已经绑定其他淘宝账号"), + OLD_NOT_SAME_NEW_PWD_ERROR(-120, "新密码不能等于和原始密码一致"), + USER_IS_REGISTER(-121, "用户已经注册请前往登录"), + RELATIONID_IS_REGISTER(-122, "淘宝账号已经授权绑定其他手机号"), + CODE_NOT_FOUND(-123, "邀请码不存在"), + COMMON_IS_EXITS(-124, "已经存在"), + COUPONS_ZERO(-125, "优惠券被领完了"), + COUPONS_GET_OUT(-126, "优惠券超过领取次数"), + COUPONS_TIME_OUT(-127, "优惠券已过期"); + private Integer code; + private String msg; + ExceptionEnum(Integer code, String msg) { + this.code = code; + this.msg = msg; + } + + public Integer getCode() { + return code; + } + + public String getMsg() { + return msg; + } +} + diff --git a/src/main/java/com/sqx/modules/chats/utils/Result.java b/src/main/java/com/sqx/modules/chats/utils/Result.java new file mode 100644 index 0000000..02594ee --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/utils/Result.java @@ -0,0 +1,51 @@ +package com.sqx.modules.chats.utils; + +public class Result { + + // error_code 状态值:0 极为成功,其他数值代表失败 + private Integer status; + + // error_msg 错误信息,若status为0时,为success + private String msg; + + // content 返回体报文的出参,使用泛型兼容不同的类型 + private T data; + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer code) { + this.status = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public T getData(Object object) { + return data; + } + + public void setData(T data) { + this.data = data; + } + + public T getData() { + return data; + } + + @Override + public String toString() { + return "Result{" + + "status=" + status + + ", msg='" + msg + '\'' + + ", data=" + data + + '}'; + + } +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/chats/utils/ResultUtil.java b/src/main/java/com/sqx/modules/chats/utils/ResultUtil.java new file mode 100644 index 0000000..d844147 --- /dev/null +++ b/src/main/java/com/sqx/modules/chats/utils/ResultUtil.java @@ -0,0 +1,56 @@ +package com.sqx.modules.chats.utils; + +public class ResultUtil { + + /** + * 返回成功,传入返回体具体出參 + * + * @param object + * @return + */ + public static Result success(Object object) { + Result result = new Result(); + result.setStatus(0); + result.setMsg("success"); + result.setData(object); + return result; + } + + /** + * 提供给部分不需要出參的接口 + * + * @return + */ + public static Result success() { + return success(null); + } + + /** + * 自定义错误信息 + * + * @param code + * @param msg + * @return + */ + public static Result error(Integer code, String msg) { + Result result = new Result(); + result.setStatus(code); + result.setMsg(msg); + result.setData(null); + return result; + } + + /** + * 返回异常信息,在已知的范围内 + * + * @param exceptionEnum + * @return + */ + public static Result error(ExceptionEnum exceptionEnum) { + Result result = new Result(); + result.setStatus(exceptionEnum.getCode()); + result.setMsg(exceptionEnum.getMsg()); + result.setData(null); + return result; + } +} diff --git a/src/main/java/com/sqx/modules/common/controller/CommonController.java b/src/main/java/com/sqx/modules/common/controller/CommonController.java new file mode 100644 index 0000000..7ac3fa1 --- /dev/null +++ b/src/main/java/com/sqx/modules/common/controller/CommonController.java @@ -0,0 +1,90 @@ +package com.sqx.modules.common.controller; + +import com.sqx.common.utils.Result; +import com.sqx.modules.common.entity.ArtificerPartitioningDetails; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +@RestController +@Api(value = "通用配置管理", tags = {"通用配置管理"}) +@RequestMapping(value = "/common") +public class CommonController { + @Autowired + private CommonInfoService commonService; + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ApiOperation("管理平台通用配置详情") + @ResponseBody + public Result getCommon(@PathVariable Integer id) { + return Result.success().put("data",commonService.findOne(id)); + } + + @RequestMapping(value = "/update", method = RequestMethod.POST) + @ApiOperation("管理平台添加通用配置") + @ResponseBody + public Result addCommon(@RequestBody CommonInfo app) { + + return commonService.update(app); + } + + @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET) + @ApiOperation("管理平台删除通用配置") + public Result deleteCommon(@PathVariable int id) { + return commonService.delete(id); + } + + @RequestMapping(value = "/type/{type}", method = RequestMethod.GET) + @ApiOperation("用户端根据type获取对象 1客服二维码\n" + + " 2公众号二维码\n" + + " 3佣金开启\n" + + " 4注册邀请码\n" + + " 5微信APPID\n" + + " 21微信秘钥\n" + + " 6淘宝APPID\n" + + " 7淘宝秘钥\n" + + " 8淘宝授权地址\n" + + " 9淘宝PID\n" + + " 10好单库key\n" + + " 11淘宝名\n" + + " 12后台服务名称\n" + + " 13京东APPID\n" + + " 14京东秘钥\n" + + " 15私域邀请码(唯一不变)\n" + + " 16公众号Token\n" + + " 17公众号EncodingAESKey\n" + + " 18提现通知管理员openid\n" + + " 19后台服务域名配置\n" + + " 20后台管理平台域名配置\n" + + " 22拼多多优惠券地址") + @ResponseBody + public Result getCommonList(@PathVariable Integer type) { + return commonService.findByType(type); + } + + + @RequestMapping(value = "/type/condition/{condition}", method = RequestMethod.GET) + @ApiOperation("根据condition去查询 xitong xitongs shouye") + @ResponseBody + public Result findByTypeAndCondition(@PathVariable String condition) { + return commonService.findByTypeAndCondition(condition); + } + + @GetMapping("/fcmx/{type}") + @ApiOperation("技师分成规则查询") + public Result rules(@PathVariable(value = "type") String type) { + return commonService.rules(type); + } + + @PostMapping("/fcmx/upd") + @ApiOperation("技师分成规则修改") + public Result rulesUpd(@RequestBody ArtificerPartitioningDetails artificerPartitioningDetails) { + return commonService.rulesUpd(artificerPartitioningDetails); + } + + +} diff --git a/src/main/java/com/sqx/modules/common/controller/app/AppCommonController.java b/src/main/java/com/sqx/modules/common/controller/app/AppCommonController.java new file mode 100644 index 0000000..e9b186e --- /dev/null +++ b/src/main/java/com/sqx/modules/common/controller/app/AppCommonController.java @@ -0,0 +1,64 @@ +package com.sqx.modules.common.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.common.service.CommonInfoService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value = "通用配置管理", tags = {"通用配置管理"}) +@RequestMapping(value = "/app/common") +public class AppCommonController { + @Autowired + private CommonInfoService commonService; + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ApiOperation("管理平台通用配置详情") + @ResponseBody + public Result getCommon(@PathVariable Integer id) { + return Result.success().put("data",commonService.findOne(id)); + } + + + @RequestMapping(value = "/type/{type}", method = RequestMethod.GET) + @ApiOperation("用户端根据type获取对象 1客服二维码\n" + + " 2公众号二维码\n" + + " 3佣金开启\n" + + " 4注册邀请码\n" + + " 5微信APPID\n" + + " 21微信秘钥\n" + + " 6淘宝APPID\n" + + " 7淘宝秘钥\n" + + " 8淘宝授权地址\n" + + " 9淘宝PID\n" + + " 10好单库key\n" + + " 11淘宝名\n" + + " 12后台服务名称\n" + + " 13京东APPID\n" + + " 14京东秘钥\n" + + " 15私域邀请码(唯一不变)\n" + + " 16公众号Token\n" + + " 17公众号EncodingAESKey\n" + + " 18提现通知管理员openid\n" + + " 19后台服务域名配置\n" + + " 20后台管理平台域名配置\n" + + " 22拼多多优惠券地址") + @ResponseBody + public Result getCommonList(@PathVariable Integer type) { + return commonService.findByType(type); + } + + + @RequestMapping(value = "/type/condition/{condition}", method = RequestMethod.GET) + @ApiOperation("根据condition去查询 xitong xitongs shouye") + @ResponseBody + public Result findByTypeAndCondition(@PathVariable String condition) { + return commonService.findByTypeAndCondition(condition); + } + + + + +} diff --git a/src/main/java/com/sqx/modules/common/dao/ArtificerPartitioningDetailsMapper.java b/src/main/java/com/sqx/modules/common/dao/ArtificerPartitioningDetailsMapper.java new file mode 100644 index 0000000..806110a --- /dev/null +++ b/src/main/java/com/sqx/modules/common/dao/ArtificerPartitioningDetailsMapper.java @@ -0,0 +1,23 @@ +package com.sqx.modules.common.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.common.entity.ArtificerPartitioningDetails; +import org.apache.ibatis.annotations.Mapper; + +/** + * @description:分成明细规则Mapper + * @author:zc. + * @createData:2024-1-24 下午 4:04 + * @projectName:anmo + * @className:ArtificerPartitioningDetailsMapper + * @packageName:com.sqx.modules.common.dao + */ + +@Mapper +public interface ArtificerPartitioningDetailsMapper extends BaseMapper { + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/common/dao/CommonInfoDao.java b/src/main/java/com/sqx/modules/common/dao/CommonInfoDao.java new file mode 100644 index 0000000..558bf5e --- /dev/null +++ b/src/main/java/com/sqx/modules/common/dao/CommonInfoDao.java @@ -0,0 +1,24 @@ +package com.sqx.modules.common.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.common.entity.CommonInfo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author fang + * @date 2020/7/8 + */ +@Mapper +public interface CommonInfoDao extends BaseMapper { + + List findByCondition(@Param("condition") String condition); + + CommonInfo findOne(@Param("type") int type); + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/common/entity/ArtificerPartitioningDetails.java b/src/main/java/com/sqx/modules/common/entity/ArtificerPartitioningDetails.java new file mode 100644 index 0000000..8e6e9f0 --- /dev/null +++ b/src/main/java/com/sqx/modules/common/entity/ArtificerPartitioningDetails.java @@ -0,0 +1,52 @@ +package com.sqx.modules.common.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @description:分成明细规则 + * @author:zc. + * @createData:2024-1-24 下午 4:04 + * @projectName:anmo + * @className:ArtificerPartitioningDetails + * @packageName:com.sqx.modules.common.entity + */ +@Data +@TableName("artificer_partitioning_details") + +public class ArtificerPartitioningDetails implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("id") + private Long id; + + @ApiModelProperty("等级") + private String grade; + + @ApiModelProperty("最低业绩") + private BigDecimal outstandingAchievement; + + @ApiModelProperty("加钟率") + private BigDecimal clockRate; + + @ApiModelProperty("在线时长") + private Integer durationOnline; + + @ApiModelProperty("积分") + private String integral; + + @ApiModelProperty("分成比例") + private String proportionalSharing; + + @ApiModelProperty("充值率") + private BigDecimal depositRate; + + @ApiModelProperty("项目类型(91精油;95中医)") + private String classifyId; + +} diff --git a/src/main/java/com/sqx/modules/common/entity/CommonInfo.java b/src/main/java/com/sqx/modules/common/entity/CommonInfo.java new file mode 100644 index 0000000..5742bc6 --- /dev/null +++ b/src/main/java/com/sqx/modules/common/entity/CommonInfo.java @@ -0,0 +1,33 @@ +package com.sqx.modules.common.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 通用配置管理 + */ +@Data +@TableName("common_info") +public class CommonInfo implements Serializable { + + @TableId(type = IdType.INPUT) + private long id; + + private String createAt; + + private Integer type; //1表示客服二维码 2表示公众号二维码 3表示全局佣金是否开启 4注册客服渠道id配置 5、佣金规则 6、 + + private String value; + + private String max; + + private String min; + + private String conditionFrom; + +} + diff --git a/src/main/java/com/sqx/modules/common/service/CommonInfoService.java b/src/main/java/com/sqx/modules/common/service/CommonInfoService.java new file mode 100644 index 0000000..0aa0b2f --- /dev/null +++ b/src/main/java/com/sqx/modules/common/service/CommonInfoService.java @@ -0,0 +1,50 @@ +package com.sqx.modules.common.service; + +import com.sqx.common.utils.Result; +import com.sqx.modules.common.entity.ArtificerPartitioningDetails; +import com.sqx.modules.common.entity.CommonInfo; + +/** + * @author fang + * @date 2020/7/8 + */ +public interface CommonInfoService { + + /** + * 保存对象 + * + * @param + */ + Result update(CommonInfo commonInfo); + + /** + * 获取一个对象 + */ + CommonInfo findOne(int id); + + /** + * 删除一个 + */ + Result delete(long id); + + /** + * 修改 + */ + Result updateBody(CommonInfo commonInfo); + /** + * 通过类型查询 + */ + Result findByType(Integer type); + + /** + * 通过类型查询 + */ + Result findByTypeAndCondition(String condition); + + /** + * 通过类型查询 + */ + Result rules(String type); + + Result rulesUpd(ArtificerPartitioningDetails artificerPartitioningDetails); +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/common/service/impl/CommonInfoServiceImpl.java b/src/main/java/com/sqx/modules/common/service/impl/CommonInfoServiceImpl.java new file mode 100644 index 0000000..cd2e927 --- /dev/null +++ b/src/main/java/com/sqx/modules/common/service/impl/CommonInfoServiceImpl.java @@ -0,0 +1,87 @@ +package com.sqx.modules.common.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.dao.UserRechargeDao; +import com.sqx.modules.common.dao.ArtificerPartitioningDetailsMapper; +import com.sqx.modules.common.dao.CommonInfoDao; +import com.sqx.modules.common.entity.ArtificerPartitioningDetails; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * @author fang + * @date 2020/7/8 + */ +@Service +public class CommonInfoServiceImpl extends ServiceImpl implements CommonInfoService { + + + private final CommonInfoDao commonInfoDao; + private final UserRechargeDao userRechargeDao; + private final ArtificerPartitioningDetailsMapper artificerPartitioningDetailsMapper; + + @Autowired + public CommonInfoServiceImpl(CommonInfoDao commonInfoDao,UserRechargeDao userRechargeDao,ArtificerPartitioningDetailsMapper artificerPartitioningDetailsMapper) { + this.commonInfoDao = commonInfoDao; + this.userRechargeDao = userRechargeDao; + this.artificerPartitioningDetailsMapper = artificerPartitioningDetailsMapper; + } + + @Override + public Result update(CommonInfo commonInfo) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + commonInfo.setCreateAt(sdf.format(now)); + commonInfoDao.updateById(commonInfo); + return Result.success(); + } + + + @Override + public CommonInfo findOne(int id) { + return commonInfoDao.findOne(id); + } + + @Override + public Result delete(long id) { + commonInfoDao.deleteById(id); + return Result.success(); + } + + + @Override + public Result updateBody(CommonInfo commonInfo) { + commonInfoDao.updateById(commonInfo); + return Result.success(); + } + + @Override + public Result findByType(Integer type) { + return Result.success().put("data",commonInfoDao.findOne(type)); + } + + @Override + public Result findByTypeAndCondition(String condition) { + return Result.success().put("data",commonInfoDao.findByCondition(condition)); + } + + @Override + public Result rules(String type) { + return Result.success().put("data", artificerPartitioningDetailsMapper.selectList(Wrappers.lambdaQuery() + .eq(ArtificerPartitioningDetails::getClassifyId, type))); + } + + @Override + public Result rulesUpd(ArtificerPartitioningDetails artificerPartitioningDetails) { + artificerPartitioningDetailsMapper.updateById(artificerPartitioningDetails); + return Result.success(); + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/consortia/controller/ConsortiaController.java b/src/main/java/com/sqx/modules/consortia/controller/ConsortiaController.java new file mode 100644 index 0000000..da07b19 --- /dev/null +++ b/src/main/java/com/sqx/modules/consortia/controller/ConsortiaController.java @@ -0,0 +1,87 @@ +package com.sqx.modules.consortia.controller; + +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.consortia.entity.Consortia; +import com.sqx.modules.consortia.service.ConsortiaService; +import com.sqx.modules.coupon.entity.CouponCardType; +import com.sqx.modules.coupon.service.CouponCardService; +import com.sqx.modules.coupon.service.CouponCardTypeService; +import com.sqx.modules.sys.controller.AbstractController; +import com.sqx.modules.utils.excel.ExcelData; +import com.sqx.modules.utils.excel.ExportExcelUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.Date; + +@RestController +@Api(value = "商家", tags = {"商家"}) +@RequestMapping(value = "/consortia") +public class ConsortiaController extends AbstractController { + + @Autowired + private ConsortiaService consortiaService; + + @PostMapping("/insertConsortia") + @ApiOperation("添加商家") + public Result insertConsortia(@RequestBody Consortia consortia){ + return consortiaService.insertConsortia(consortia); + } + + @PostMapping("/updateConsortia") + @ApiOperation("修改商家") + public Result updateConsortia(@RequestBody Consortia consortia){ + return consortiaService.updateConsortia(consortia); + } + + @PostMapping("/deleteConsortia") + @ApiOperation("删除商家") + public Result deleteConsortia(Long consortiaId){ + return consortiaService.deleteConsortiaById(consortiaId); + } + + @GetMapping("/selectConsortiaList") + @ApiOperation("查询商家列表") + public Result selectConsortiaList(Integer page,Integer limit,String consortiaName,String userName,String phone){ + return consortiaService.selectConsortiaList(page, limit, consortiaName, userName, phone); + } + + @GetMapping("/selectConsortiaByUserId") + @ApiOperation("查询商家详情") + public Result selectConsortiaByUserId(Long consortiaId){ + return consortiaService.selectConsortiaByUserId(consortiaId); + } + + @PostMapping("/insertConsortiaUser") + @ApiOperation("关联师傅") + public Result insertConsortiaUser(Long userId,Long consortiaId){ + return consortiaService.insertConsortiaUser(userId, consortiaId); + } + + @PostMapping("/deleteConsortiaUser") + @ApiOperation("移除师傅") + public Result deleteConsortiaUser(Long userId){ + return consortiaService.deleteConsortiaUser(userId); + } + + @GetMapping("/selectUserListByConsortiaId") + @ApiOperation("查询师傅列表") + public Result selectUserListByConsortiaId(Integer page,Integer limit,String userName,String phone,Long consortiaId,Long shopId,Integer flag,String time){ + return consortiaService.selectUserListByConsortiaId(page, limit, userName, phone, consortiaId,shopId,flag,time); + } + + @GetMapping("/selectConsortiaMoney") + @ApiOperation("查询师傅带来的总收益") + public Result selectConsortiaMoney(Long shopId,Integer flag,String time){ + return consortiaService.selectConsortiaMoney(shopId, flag, time); + } + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/consortia/controller/app/AppConsortiaController.java b/src/main/java/com/sqx/modules/consortia/controller/app/AppConsortiaController.java new file mode 100644 index 0000000..f1237cc --- /dev/null +++ b/src/main/java/com/sqx/modules/consortia/controller/app/AppConsortiaController.java @@ -0,0 +1,42 @@ +package com.sqx.modules.consortia.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.consortia.entity.Consortia; +import com.sqx.modules.consortia.service.ConsortiaService; +import com.sqx.modules.sys.controller.AbstractController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value = "商家", tags = {"商家"}) +@RequestMapping(value = "/app/consortia") +public class AppConsortiaController extends AbstractController { + + @Autowired + private ConsortiaService consortiaService; + + @Login + @GetMapping("/selectConsortiaByUserId") + @ApiOperation("查询商家详情") + public Result selectConsortiaByUserId(Long consortiaId){ + return consortiaService.selectConsortiaByUserId(consortiaId); + } + + @Login + @GetMapping("/selectUserListByConsortiaId") + @ApiOperation("查询师傅列表") + public Result selectUserListByConsortiaId(Integer page,Integer limit,String userName,String phone,Long consortiaId,Long shopId,Integer flag,String time){ + return consortiaService.selectUserListByConsortiaId(page, limit, userName, phone, consortiaId,shopId,flag,time); + } + + @Login + @GetMapping("/selectConsortiaMoney") + @ApiOperation("查询师傅带来的总收益") + public Result selectConsortiaMoney(Long shopId,Integer flag,String time){ + return consortiaService.selectConsortiaMoney(shopId, flag, time); + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/consortia/dao/ConsortiaDao.java b/src/main/java/com/sqx/modules/consortia/dao/ConsortiaDao.java new file mode 100644 index 0000000..a17996e --- /dev/null +++ b/src/main/java/com/sqx/modules/consortia/dao/ConsortiaDao.java @@ -0,0 +1,19 @@ +package com.sqx.modules.consortia.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.consortia.entity.Consortia; +import com.sqx.modules.coupon.entity.CouponCard; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface ConsortiaDao extends BaseMapper { + + IPage selectConsortiaList(Page page,String consortiaName,String userName,String phone); + + int updateConsortiaUserIdIsNullByConsortId(Long consortiaId); + + Double selectConsortiaMoney(Long shopId,Integer flag,String time); + +} diff --git a/src/main/java/com/sqx/modules/consortia/entity/Consortia.java b/src/main/java/com/sqx/modules/consortia/entity/Consortia.java new file mode 100644 index 0000000..9ad61c3 --- /dev/null +++ b/src/main/java/com/sqx/modules/consortia/entity/Consortia.java @@ -0,0 +1,94 @@ +package com.sqx.modules.consortia.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @description consortia + * @author fang + * @date 2023-02-15 + */ +@Data +@ApiModel("consortia") +public class Consortia implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 商家id + */ + private Long consortiaId; + + /** + * 商家名称 + */ + private String consortiaName; + + /** + * 商家公告 + */ + private String consortiaContent; + + /** + * 头像 + */ + private String logo; + + /** + * 身份证号码 + */ + private String identityCard; + + /** + * 姓名 + */ + private String identityName; + + /** + * 电话 + */ + private String phone; + + /** + * 详细地址 + */ + private String address; + + /** + * 营业执照 + */ + private String businessLicense; + + /** + * 资质证书 + */ + private String qualificationCertificate; + + /** + * 佣金 + */ + private BigDecimal rate; + + /** + * 商家id + */ + private Long userId; + + /** + * 创建时间 + */ + private String createTime; + + @TableField(exist = false) + private String userName; + + public Consortia() {} +} diff --git a/src/main/java/com/sqx/modules/consortia/service/ConsortiaService.java b/src/main/java/com/sqx/modules/consortia/service/ConsortiaService.java new file mode 100644 index 0000000..7aba4ed --- /dev/null +++ b/src/main/java/com/sqx/modules/consortia/service/ConsortiaService.java @@ -0,0 +1,29 @@ +package com.sqx.modules.consortia.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.consortia.entity.Consortia; +import com.sqx.modules.coupon.entity.CouponCard; +import com.sqx.modules.utils.excel.ExcelData; + +public interface ConsortiaService extends IService { + + Result insertConsortia(Consortia consortia); + + Result updateConsortia(Consortia consortia); + + Result deleteConsortiaById(Long consortiaId); + + Result selectConsortiaList(Integer page,Integer limit,String consortiaName,String userName,String phone); + + Result selectConsortiaByUserId(Long consortiaId); + + Result insertConsortiaUser(Long userId,Long consortiaId); + + Result deleteConsortiaUser(Long userId); + + Result selectUserListByConsortiaId(Integer page,Integer limit,String userName,String phone,Long consortiaId,Long shopId,Integer flag,String time); + + Result selectConsortiaMoney(Long shopId,Integer flag,String time); + +} diff --git a/src/main/java/com/sqx/modules/consortia/service/impl/ConsortiaServiceImpl.java b/src/main/java/com/sqx/modules/consortia/service/impl/ConsortiaServiceImpl.java new file mode 100644 index 0000000..d0e18eb --- /dev/null +++ b/src/main/java/com/sqx/modules/consortia/service/impl/ConsortiaServiceImpl.java @@ -0,0 +1,133 @@ +package com.sqx.modules.consortia.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.service.ArtificerService; +import com.sqx.modules.consortia.dao.ConsortiaDao; +import com.sqx.modules.consortia.entity.Consortia; +import com.sqx.modules.consortia.service.ConsortiaService; +import com.sqx.modules.coupon.dao.CouponCardDao; +import com.sqx.modules.coupon.entity.Coupon; +import com.sqx.modules.coupon.entity.CouponCard; +import com.sqx.modules.coupon.entity.CouponCardType; +import com.sqx.modules.coupon.entity.CouponUser; +import com.sqx.modules.coupon.service.CouponCardService; +import com.sqx.modules.coupon.service.CouponCardTypeService; +import com.sqx.modules.coupon.service.CouponService; +import com.sqx.modules.coupon.service.CouponUserService; +import com.sqx.modules.utils.excel.ExcelData; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +@Service +public class ConsortiaServiceImpl extends ServiceImpl implements ConsortiaService { + + @Autowired + private UserService userService; + @Autowired + private ArtificerService artificerService; + + + @Override + public Result insertConsortia(Consortia consortia){ + UserEntity userEntity = userService.selectUserById(consortia.getUserId()); + if(userEntity.getConsortiaId()!=null){ + /*Consortia consortia1 = baseMapper.selectById(userEntity.getConsortiaId()); + if(consortia1!=null && consortia1.getUserId().equals(userEntity.getUserId())){ + baseMapper.updateConsortiaUserIdIsNullByConsortId(consortia1.getConsortiaId()); + }*/ + return Result.error("当前用户已经绑定商家,请移除后操作!"); + } + consortia.setCreateTime(DateUtils.format(new Date())); + baseMapper.insert(consortia); + userEntity.setConsortiaId(consortia.getConsortiaId()); + userEntity.setIsShop(1); + userService.updateById(userEntity); + return Result.success(); + } + + @Override + public Result updateConsortia(Consortia consortia){ + Consortia oldConsortia = baseMapper.selectById(consortia.getConsortiaId()); + if(consortia.getUserId()!=null && !consortia.getUserId().equals(oldConsortia.getUserId())){ + UserEntity user = userService.getById(consortia.getUserId()); + if(user.getConsortiaId()!=null){ + /*Consortia consortia1 = baseMapper.selectById(user.getConsortiaId()); + if(consortia1!=null && consortia1.getUserId().equals(user.getUserId())){ + baseMapper.updateConsortiaUserIdIsNullByConsortId(consortia1.getConsortiaId()); + }*/ + return Result.error("当前用户已经绑定商家,请移除后操作!"); + } + user.setConsortiaId(consortia.getConsortiaId()); + user.setIsShop(1); + userService.updateById(user); + userService.update( + null, + Wrappers.lambdaUpdate() + .set(UserEntity::getIsShop, null) + .set(UserEntity::getConsortiaId, null) + .eq(UserEntity::getUserId, oldConsortia.getUserId()) + ); + + } + baseMapper.updateById(consortia); + return Result.success(); + } + + @Override + public Result deleteConsortiaById(Long consortiaId){ + baseMapper.deleteById(consortiaId); + userService.updateUserClientIdIsNullByClientId(consortiaId); + return Result.success(); + } + + @Override + public Result selectConsortiaList(Integer page,Integer limit,String consortiaName,String userName,String phone){ + return Result.success().put("data",new PageUtils(baseMapper.selectConsortiaList(new Page<>(page,limit),consortiaName,userName,phone))); + } + + @Override + public Result selectConsortiaByUserId(Long consortiaId){ + return Result.success().put("data",baseMapper.selectById(consortiaId)); + } + + @Override + public Result insertConsortiaUser(Long userId,Long consortiaId){ + UserEntity userEntity = userService.selectUserById(userId); + userEntity.setConsortiaId(consortiaId); + userService.updateById(userEntity); + return Result.success(); + } + + @Override + public Result deleteConsortiaUser(Long userId){ + userService.updateUserConsortiaIdIsNull(userId); + return Result.success(); + } + + @Override + public Result selectUserListByConsortiaId(Integer page,Integer limit,String userName,String phone,Long consortiaId,Long shopId,Integer flag,String time){ + return artificerService.selectUserListByConsortiaId(page, limit, userName, phone, consortiaId,shopId,flag,time); + } + + @Override + public Result selectConsortiaMoney(Long shopId,Integer flag,String time){ + return Result.success().put("data",baseMapper.selectConsortiaMoney(shopId, flag, time)); + } + + +} diff --git a/src/main/java/com/sqx/modules/coupon/controller/CouponCardController.java b/src/main/java/com/sqx/modules/coupon/controller/CouponCardController.java new file mode 100644 index 0000000..5bd546b --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/controller/CouponCardController.java @@ -0,0 +1,96 @@ +package com.sqx.modules.coupon.controller; + +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.coupon.entity.CouponCardType; +import com.sqx.modules.coupon.service.CouponCardService; +import com.sqx.modules.coupon.service.CouponCardTypeService; +import com.sqx.modules.sys.controller.AbstractController; +import com.sqx.modules.utils.excel.ExcelData; +import com.sqx.modules.utils.excel.ExportExcelUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.Date; + +@RestController +@Api(value = "卡密优惠券", tags = {"卡密优惠券"}) +@RequestMapping(value = "/couponCard") +public class CouponCardController extends AbstractController { + + @Autowired + private CouponCardService couponCardService; + @Autowired + private CouponCardTypeService couponCardTypeService; + + + @PostMapping("/insertCouponCardType") + @ApiOperation("添加卡密分类") + public Result insertCouponCardType(@RequestBody CouponCardType couponCardType){ + couponCardType.setCreateTime(DateUtils.format(new Date())); + couponCardTypeService.save(couponCardType); + return Result.success(); + } + + @PostMapping("/updateCouponCardType") + @ApiOperation("修改卡密分类") + public Result updateCouponCardType(@RequestBody CouponCardType couponCardType){ + couponCardTypeService.updateById(couponCardType); + return Result.success(); + } + + @PostMapping("/deleteCouponCardTypeById") + @ApiOperation("删除卡密分类") + public Result deleteCouponCardTypeById(Long couponCardTypeId){ + couponCardTypeService.removeById(couponCardTypeId); + return Result.success(); + } + + @GetMapping("/selectCouponCardTypeList") + @ApiOperation("查询卡密分类列表") + public Result selectCouponCardTypeList(Integer page,Integer limit,String couponTypeName,Integer status){ + return couponCardTypeService.selectCouponCardTypeList(page, limit, couponTypeName, status); + } + + + @PostMapping("/insertCouponCard") + @ApiOperation("生成卡密优惠券") + public Result insertCouponCard(Integer num,Long couponCardTypeId){ + couponCardService.insertCouponCard(num,couponCardTypeId); + return Result.success(); + } + + @PostMapping("/deleteCouponCard") + @ApiOperation("删除卡密") + public Result deleteCouponCard(Long couponCardId){ + couponCardService.removeById(couponCardId); + return Result.success(); + } + + @GetMapping("/selectCouponCardList") + @ApiOperation("查询卡密列表") + public Result selectCouponCardList(Integer page,Integer limit,Integer status,String couponCardNo,Long couponCardTypeId,Long userId){ + return couponCardService.selectCouponCardList(page, limit, status, couponCardNo, couponCardTypeId, userId); + } + + @GetMapping("/excelCouponCardList") + @ApiOperation("导出卡密列表") + public void excelCouponCardList(Integer status,String couponCardNo,Long couponCardTypeId,Long userId, HttpServletResponse response) throws Exception{ + ExcelData excelData = couponCardService.excelCouponCardList(status, couponCardNo, couponCardTypeId, userId); + ExportExcelUtils.exportExcel(response,"卡密列表.xlsx",excelData); + } + + @PostMapping("/activateCouponCard") + @ApiOperation("激活卡密") + public Result activateCouponCard(Long userId,String couponCardNo){ + return couponCardService.activateCouponCard(userId, couponCardNo); + } + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/coupon/controller/CouponController.java b/src/main/java/com/sqx/modules/coupon/controller/CouponController.java new file mode 100644 index 0000000..d7d1761 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/controller/CouponController.java @@ -0,0 +1,56 @@ +package com.sqx.modules.coupon.controller; + +import com.sqx.common.utils.Result; +import com.sqx.modules.coupon.entity.Coupon; +import com.sqx.modules.coupon.service.CouponService; +import com.sqx.modules.sys.controller.AbstractController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Arrays; +import java.util.List; + +@RestController +@Api(value = "管理端-优惠券", tags = {"管理端-优惠券"}) +@RequestMapping(value = "/admin/coupon") +public class CouponController extends AbstractController { + + @Autowired + private CouponService couponService; + + + @ApiOperation("查看发布的优惠券") + @GetMapping(value = "/seleteAllCoupon") + public Result selectAllCoupon(Integer page, Integer limit){ + return couponService.selectAllCoupon(page, limit); + } + + @ApiOperation("发布优惠券") + @PostMapping(value = "/issueCoupon") + public Result issueCoupon(@RequestBody Coupon coupon){ + return couponService.issueCoupon(coupon); + } + + @ApiOperation("删除发布的优惠券") + @PostMapping(value = "/deleteCoupon") + public Result deleteCoupon(Long couponId){ + return couponService.deleteCoupon(couponId); + } + + @ApiOperation("修改优惠券信息") + @PostMapping(value = "/updateCoupon") + public Result updateCoupon(@RequestBody Coupon coupon){ + return couponService.updateCoupon(coupon); + } + + @ApiOperation("管理端赠送用户优惠券") + @GetMapping(value = "/giveCoupon") + public Result giveCoupon(Long couponId, String userIds, Long shopId){ + String[] userId = userIds.split(","); + List userIdList = Arrays.asList(userId); + return couponService.giveCoupon(couponId, userIdList, shopId); + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/coupon/controller/CouponIssueController.java b/src/main/java/com/sqx/modules/coupon/controller/CouponIssueController.java new file mode 100644 index 0000000..86d7369 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/controller/CouponIssueController.java @@ -0,0 +1,58 @@ +package com.sqx.modules.coupon.controller; + +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.coupon.entity.CouponIssue; +import com.sqx.modules.coupon.service.CouponIssueService; +import com.sqx.modules.sys.controller.AbstractController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Date; + +@RestController +@Api(value = "发布优惠券", tags = {"发布优惠券"}) +@RequestMapping(value = "/couponIssue") +public class CouponIssueController extends AbstractController { + + @Autowired + private CouponIssueService couponIssueService; + + @PostMapping("/insertCouponIssue") + @ApiOperation("添加发布优惠券") + public Result insertCouponIssue(@RequestBody CouponIssue couponIssue){ + couponIssue.setCreateTime(DateUtils.format(new Date())); + couponIssueService.save(couponIssue); + return Result.success(); + } + + @PostMapping("/updateCouponIssue") + @ApiOperation("修改发布优惠券") + public Result updateCouponIssue(@RequestBody CouponIssue couponIssue){ + couponIssueService.updateById(couponIssue); + return Result.success(); + } + + @PostMapping("/deleteCouponIssueById") + @ApiOperation("删除发布优惠券") + public Result deleteCouponIssueById(Long couponIssueId){ + couponIssueService.removeById(couponIssueId); + return Result.success(); + } + + @GetMapping("/selectCouponIssueList") + @ApiOperation("查询发布优惠券") + public Result selectCouponIssueList(Integer page,Integer limit,String couponIssueName,Integer classify,Integer status){ + return couponIssueService.selectCouponIssueList(page, limit, couponIssueName, classify, status); + } + + + + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/coupon/controller/CouponUserController.java b/src/main/java/com/sqx/modules/coupon/controller/CouponUserController.java new file mode 100644 index 0000000..17212d2 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/controller/CouponUserController.java @@ -0,0 +1,46 @@ +package com.sqx.modules.coupon.controller; + +import com.sqx.common.utils.Result; +import com.sqx.modules.coupon.entity.CouponUser; +import com.sqx.modules.coupon.service.CouponUserService; +import com.sqx.modules.sys.controller.AbstractController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Api(value = "用户优惠券", tags = {"用户优惠券"}) +@RequestMapping(value = "/couponUser") +public class CouponUserController extends AbstractController { + + @Autowired + private CouponUserService couponUserService; + + @GetMapping("/selectCouponUserList") + @ApiOperation("查询用户优惠券") + public Result selectCouponUserList(Integer page,Integer limit,Long userId,Integer status,String phone,String couponName){ + return couponUserService.selectCouponByUserId(page, limit, userId, status, phone,couponName); + } + + @PostMapping("/loseEfficacyCoupon") + @ApiOperation("设置优惠券为失效") + public Result loseEfficacyCoupon(Long id){ + CouponUser couponUser = couponUserService.getById(id); + couponUser.setStatus(2); + couponUserService.updateById(couponUser); + return Result.success(); + } + + @PostMapping("/deleteCoupon") + @ApiOperation("删除优惠券") + public Result deleteCoupon(Long id){ + couponUserService.removeById(id); + return Result.success(); + } + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/coupon/controller/app/AppCouponCardController.java b/src/main/java/com/sqx/modules/coupon/controller/app/AppCouponCardController.java new file mode 100644 index 0000000..0abbdd7 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/controller/app/AppCouponCardController.java @@ -0,0 +1,39 @@ +package com.sqx.modules.coupon.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.coupon.service.CouponCardService; +import com.sqx.modules.sys.controller.AbstractController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value = "卡密优惠券", tags = {"卡密优惠券"}) +@RequestMapping(value = "/app/couponCard") +public class AppCouponCardController extends AbstractController { + + @Autowired + private CouponCardService couponCardService; + + + @Login + @GetMapping("/selectCouponCardList") + @ApiOperation("查询卡密列表") + public Result selectCouponCardList(Integer page,Integer limit,Integer status,String couponCardNo,Long couponCardTypeId,@RequestAttribute Long userId){ + return couponCardService.selectCouponCardList(page, limit, status, couponCardNo, couponCardTypeId, userId); + } + + @Login + @PostMapping("/activateCouponCard") + @ApiOperation("激活卡密") + public Result activateCouponCard(@RequestAttribute Long userId,String couponCardNo){ + return couponCardService.activateCouponCard(userId, couponCardNo); + } + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/coupon/controller/app/AppCouponIssueController.java b/src/main/java/com/sqx/modules/coupon/controller/app/AppCouponIssueController.java new file mode 100644 index 0000000..06507c2 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/controller/app/AppCouponIssueController.java @@ -0,0 +1,39 @@ +package com.sqx.modules.coupon.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.coupon.service.CouponIssueService; +import com.sqx.modules.sys.controller.AbstractController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value = "发布优惠券", tags = {"发布优惠券"}) +@RequestMapping(value = "/app/couponIssue") +public class AppCouponIssueController extends AbstractController { + + @Autowired + private CouponIssueService couponIssueService; + + @Login + @GetMapping("/selectCouponIssueList") + @ApiOperation("查询发布优惠券") + public Result selectCouponIssueList(Integer page,Integer limit,Integer classify,@RequestAttribute Long userId){ + return couponIssueService.selectCouponIssueListByUserId(page, limit, classify, userId); + } + + @Login + @PostMapping("/insertCouponUser") + @ApiOperation("领取优惠券") + public Result insertCouponUser(@RequestAttribute Long userId,Long couponIssueId){ + return couponIssueService.insertCouponUser(userId, couponIssueId); + } + + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/coupon/controller/app/AppCouponUserController.java b/src/main/java/com/sqx/modules/coupon/controller/app/AppCouponUserController.java new file mode 100644 index 0000000..89d9ac4 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/controller/app/AppCouponUserController.java @@ -0,0 +1,59 @@ +package com.sqx.modules.coupon.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.annotation.LoginUser; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.coupon.service.CouponService; +import com.sqx.modules.coupon.service.CouponUserService; +import com.sqx.modules.sys.controller.AbstractController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.math.BigDecimal; + +@RestController +@Api(value = "用户端-优惠券", tags = {"用户端-优惠券"}) +@RequestMapping(value = "/app/coupon") +public class AppCouponUserController extends AbstractController { + + @Autowired + private CouponUserService couponUserService; + @Autowired + private CouponService couponService; + + @Login + @ApiOperation("使用时查看所有优惠券") + @GetMapping(value = "/selectUserCouponList") + public Result selectCouponList(@RequestAttribute Long userId, Integer page, Integer limit, BigDecimal minMoney,Long shopId){ + return couponUserService.selectCouponList(userId, page, limit, minMoney,shopId); + } + + + @Login + @GetMapping("/selectCouponUserList") + @ApiOperation("查询用户优惠券") + public Result selectCouponUserList(Integer page,Integer limit,@RequestAttribute Long userId,Integer status,String phone){ + return couponUserService.selectCouponByUserId(page, limit, userId, status, phone,null); + } + + //将所有超过失效时间的优惠券改为失效状态 + @Scheduled(cron = "0 */1 * * * ?", zone = "Asia/Shanghai") + public void couponEnd(){ + couponUserService.updateExpiration(); + } + + @Login + @GetMapping("/insertNewUserCoupon") + @ApiOperation("领取新人优惠券") + public Result insertNewUserCoupon(@LoginUser UserEntity userEntity){ + return couponUserService.insertNewUserCoupon(userEntity); + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/coupon/dao/CouponCardDao.java b/src/main/java/com/sqx/modules/coupon/dao/CouponCardDao.java new file mode 100644 index 0000000..87a0ba4 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/dao/CouponCardDao.java @@ -0,0 +1,11 @@ +package com.sqx.modules.coupon.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.coupon.entity.CouponCard; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface CouponCardDao extends BaseMapper { + + +} diff --git a/src/main/java/com/sqx/modules/coupon/dao/CouponCardTypeDao.java b/src/main/java/com/sqx/modules/coupon/dao/CouponCardTypeDao.java new file mode 100644 index 0000000..c95a702 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/dao/CouponCardTypeDao.java @@ -0,0 +1,11 @@ +package com.sqx.modules.coupon.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.coupon.entity.CouponCardType; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface CouponCardTypeDao extends BaseMapper { + + +} diff --git a/src/main/java/com/sqx/modules/coupon/dao/CouponDao.java b/src/main/java/com/sqx/modules/coupon/dao/CouponDao.java new file mode 100644 index 0000000..60b7e80 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/dao/CouponDao.java @@ -0,0 +1,18 @@ +package com.sqx.modules.coupon.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.coupon.entity.Coupon; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface CouponDao extends BaseMapper { + + IPage selectCouponPage(Page pages); + + List selectCouponList(); + +} diff --git a/src/main/java/com/sqx/modules/coupon/dao/CouponIssueDao.java b/src/main/java/com/sqx/modules/coupon/dao/CouponIssueDao.java new file mode 100644 index 0000000..ea95163 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/dao/CouponIssueDao.java @@ -0,0 +1,14 @@ +package com.sqx.modules.coupon.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.coupon.entity.CouponIssue; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface CouponIssueDao extends BaseMapper { + + IPage selectCouponIssueListByUserId(Page page,Integer classify,Long userId); + +} diff --git a/src/main/java/com/sqx/modules/coupon/dao/CouponUserDao.java b/src/main/java/com/sqx/modules/coupon/dao/CouponUserDao.java new file mode 100644 index 0000000..3e3a604 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/dao/CouponUserDao.java @@ -0,0 +1,32 @@ +package com.sqx.modules.coupon.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.coupon.entity.CouponUser; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; +import java.util.List; + +@Mapper +public interface CouponUserDao extends BaseMapper { + + IPage selectCouponList(Page pages, @Param("userId") Long userId, + @Param("minMoney") BigDecimal minMoney, @Param("format") String format,@Param("shopId") Long shopId); + + IPage CouponList(Page pages,@Param("userId") Long userId,@Param("status") Integer status); + + void updateExpiration(@Param("date") String date); + + IPage selectCouponByUserId(Page pages, @Param("userId") Long userId,@Param("status") Integer status, @Param("phone") String phone,@Param("couponName") String couponName); + + int selectCountCoupon(Long userId); + + int giveCoupon(List userIdList, @Param("couponName")String couponName, @Param("couponPicture")String couponPicture, + @Param("createTime") String createTime, @Param("expirationTime")String expirationTime, @Param("minMoney")BigDecimal minMoney, + @Param("money")BigDecimal money, @Param("status")Integer status, @Param("endTime")String endTime); + + CouponUser selectCountByUserId(@Param("userId") Long userId); +} diff --git a/src/main/java/com/sqx/modules/coupon/entity/Coupon.java b/src/main/java/com/sqx/modules/coupon/entity/Coupon.java new file mode 100644 index 0000000..19906a3 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/entity/Coupon.java @@ -0,0 +1,45 @@ +package com.sqx.modules.coupon.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +@ApiModel("coupon") +public class Coupon implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + + @ApiModelProperty("coupon_id") + private Long couponId; + + + @ApiModelProperty("优惠券名称") + private String couponName; + + + @ApiModelProperty("优惠券图片") + private String couponPicture; + + + @ApiModelProperty("有效期天数") + private Integer endDate; + + + @ApiModelProperty("优惠券可使用订单最低金额") + private BigDecimal minMoney; + + + @ApiModelProperty("优惠券金额") + private BigDecimal money; + + + public Coupon() {} +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/coupon/entity/CouponCard.java b/src/main/java/com/sqx/modules/coupon/entity/CouponCard.java new file mode 100644 index 0000000..6598f64 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/entity/CouponCard.java @@ -0,0 +1,57 @@ +package com.sqx.modules.coupon.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.sqx.modules.app.entity.UserEntity; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description coupon_card + * @author fang + * @date 2022-11-12 + */ +@Data +public class CouponCard implements Serializable { + + private static final long serialVersionUID = 1L; + + + /** + * 卡密优惠券 + */ + @TableId(type = IdType.AUTO) + private Long couponCardId; + + /** + * 卡密 + */ + private String couponCardNo; + + /** + * 卡密类型id + */ + private Long couponCardTypeId; + + /** + * 状态 1待使用 2已领取 + */ + private Integer status; + + /** + * 领取用户id + */ + private Long userId; + + @TableField(exist = false) + private UserEntity user; + + /** + * 创建时间 + */ + private String createTime; + + public CouponCard() {} +} diff --git a/src/main/java/com/sqx/modules/coupon/entity/CouponCardType.java b/src/main/java/com/sqx/modules/coupon/entity/CouponCardType.java new file mode 100644 index 0000000..732b401 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/entity/CouponCardType.java @@ -0,0 +1,60 @@ +package com.sqx.modules.coupon.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @description coupon_card_type + * @author fang + * @date 2022-11-12 + */ +@Data +public class CouponCardType implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 卡密类型id + */ + private Long couponCardTypeId; + + /** + * 卡密类型名称 + */ + private String couponCardName; + + /** + * 包含优惠券 + */ + private String couponIds; + @TableField(exist = false) + private List couponList; + /*//总优惠券数量 + @TableField(exist = false) + private Integer sumCount; + //未使用数量 + @TableField(exist = false) + private String unusedCount; + //已使用数量 + @TableField(exist = false) + private String finishCount;*/ + + + /** + * 状态 1开启 2关闭 + */ + private Integer status; + + /** + * 创建时间 + */ + private String createTime; + + public CouponCardType() {} +} diff --git a/src/main/java/com/sqx/modules/coupon/entity/CouponIssue.java b/src/main/java/com/sqx/modules/coupon/entity/CouponIssue.java new file mode 100644 index 0000000..e192bc9 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/entity/CouponIssue.java @@ -0,0 +1,93 @@ +package com.sqx.modules.coupon.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + + +/** + * @description coupon_issue + * @author fang + * @date 2022-11-12 + */ +@Data +public class CouponIssue implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 发布优惠券 + */ + private Long couponIssueId; + + /** + * 优惠券ids + */ + private String couponIds; + + @TableField(exist = false) + private List couponList; + + /** + * 发布优惠券名称 + */ + private String couponIssueName; + + /** + * 发布优惠券图片 + */ + private String couponIssueImage; + + /** + * 优惠券主页图 + */ + private String couponContentImage; + + /** + * 分类 1活动优惠券 2售卖优惠券 + */ + private Integer classify; + + /** + * 价格 + */ + private BigDecimal price; + + /** + * 价格 + */ + private BigDecimal originalPrice; + + /** + * 购买须知 + */ + private String payNotice; + + /** + * 是否限购 1是 2否 + */ + private Integer isLimit; + + /** + * 发放数量 + */ + private Integer couponNum; + + /** + * 状态 1开启 2关闭 + */ + private Integer status; + + /** + * 创建时间 + */ + private String createTime; + + public CouponIssue() {} +} diff --git a/src/main/java/com/sqx/modules/coupon/entity/CouponUser.java b/src/main/java/com/sqx/modules/coupon/entity/CouponUser.java new file mode 100644 index 0000000..558f73c --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/entity/CouponUser.java @@ -0,0 +1,77 @@ +package com.sqx.modules.coupon.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +@TableName("coupon_user") +public class CouponUser implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + + @ApiModelProperty("id") + private Long id; + + + @ApiModelProperty("用户id") + private Long userId; + + + @ApiModelProperty("优惠券名称") + private String couponName; + + + @ApiModelProperty("优惠券图片") + private String couponPicture; + + + @ApiModelProperty("优惠券领取时间") + private String createTime; + + + @ApiModelProperty("优惠券使用时间") + private String employTime; + + + @ApiModelProperty("优惠券过期时间") + private String expirationTime; + + + @ApiModelProperty("优惠券可使用订单最低金额") + private BigDecimal minMoney; + + + @ApiModelProperty("优惠券金额") + private BigDecimal money; + + @ApiModelProperty("优惠券状态 0正常 1已使用 2已失效") + private Integer status; + + @ApiModelProperty("领取id") + private Long couponIssueId; + + @TableField(exist = false) + private String nickName; + + @TableField(exist = false) + private String avatar; + + @TableField(exist = false) + private String phone; + + + @TableField(exist = false) + private Integer num; + + + public CouponUser() {} +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/coupon/service/CouponCardService.java b/src/main/java/com/sqx/modules/coupon/service/CouponCardService.java new file mode 100644 index 0000000..9d3136e --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/service/CouponCardService.java @@ -0,0 +1,20 @@ +package com.sqx.modules.coupon.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.coupon.entity.CouponCard; +import com.sqx.modules.utils.excel.ExcelData; + +public interface CouponCardService extends IService { + + void insertCouponCard(Integer num, Long couponCardTypeId); + + CouponCard selectCouponCard(String couponCardNo); + + Result selectCouponCardList(Integer page, Integer limit, Integer status, String couponCardNo, Long couponCardTypeId, Long userId); + + ExcelData excelCouponCardList(Integer status, String couponCardNo, Long couponCardTypeId, Long userId); + + Result activateCouponCard(Long userId,String couponCardNo); + +} diff --git a/src/main/java/com/sqx/modules/coupon/service/CouponCardTypeService.java b/src/main/java/com/sqx/modules/coupon/service/CouponCardTypeService.java new file mode 100644 index 0000000..d9f6d1f --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/service/CouponCardTypeService.java @@ -0,0 +1,11 @@ +package com.sqx.modules.coupon.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.coupon.entity.CouponCardType; + +public interface CouponCardTypeService extends IService { + + Result selectCouponCardTypeList(Integer page, Integer limit, String couponTypeName, Integer status); + +} diff --git a/src/main/java/com/sqx/modules/coupon/service/CouponIssueService.java b/src/main/java/com/sqx/modules/coupon/service/CouponIssueService.java new file mode 100644 index 0000000..df148db --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/service/CouponIssueService.java @@ -0,0 +1,15 @@ +package com.sqx.modules.coupon.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.coupon.entity.CouponIssue; + +public interface CouponIssueService extends IService { + + Result selectCouponIssueList(Integer page,Integer limit,String couponIssueName,Integer classify,Integer status); + + Result selectCouponIssueListByUserId(Integer page,Integer limit,Integer classify,Long userId); + + Result insertCouponUser(Long userId, Long couponIssueId); + +} diff --git a/src/main/java/com/sqx/modules/coupon/service/CouponService.java b/src/main/java/com/sqx/modules/coupon/service/CouponService.java new file mode 100644 index 0000000..4f7e8ed --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/service/CouponService.java @@ -0,0 +1,23 @@ +package com.sqx.modules.coupon.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.coupon.entity.Coupon; + +import java.util.List; + +public interface CouponService extends IService { + + Result issueCoupon(Coupon coupon); + + Result deleteCoupon(Long couponId); + + Result selectAllCoupon(Integer page, Integer limit); + + Result updateCoupon(Coupon coupon); + + Result selectCouponList(Integer page, Integer limit); + + Result giveCoupon(Long couponId, List userIdList, Long shopId); + +} diff --git a/src/main/java/com/sqx/modules/coupon/service/CouponUserService.java b/src/main/java/com/sqx/modules/coupon/service/CouponUserService.java new file mode 100644 index 0000000..321a839 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/service/CouponUserService.java @@ -0,0 +1,25 @@ +package com.sqx.modules.coupon.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.coupon.entity.CouponUser; + +import java.math.BigDecimal; + +public interface CouponUserService extends IService { + + Result selectCouponList(Long userId, Integer page, Integer limit, BigDecimal minMoney,Long shopId); + + Result couponList(Long userId, Integer page, Integer limit, Integer status); + + void updateExpiration(); + + Result buyCoupon(Long userId, Long couponId); + + Result selectCouponByUserId(Integer page, Integer limit, Long userId, Integer status, String phone,String couponName); + + Result insertNewUserCoupon(UserEntity userEntity); + + CouponUser selectCountByUserId(Long userId); +} diff --git a/src/main/java/com/sqx/modules/coupon/service/impl/CouponCardServiceImpl.java b/src/main/java/com/sqx/modules/coupon/service/impl/CouponCardServiceImpl.java new file mode 100644 index 0000000..d1de398 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/service/impl/CouponCardServiceImpl.java @@ -0,0 +1,192 @@ +package com.sqx.modules.coupon.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.coupon.dao.CouponCardDao; +import com.sqx.modules.coupon.entity.Coupon; +import com.sqx.modules.coupon.entity.CouponCard; +import com.sqx.modules.coupon.entity.CouponCardType; +import com.sqx.modules.coupon.entity.CouponUser; +import com.sqx.modules.coupon.service.CouponCardService; +import com.sqx.modules.coupon.service.CouponCardTypeService; +import com.sqx.modules.coupon.service.CouponService; +import com.sqx.modules.coupon.service.CouponUserService; +import com.sqx.modules.utils.excel.ExcelData; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +@Service +public class CouponCardServiceImpl extends ServiceImpl implements CouponCardService { + + @Autowired + private UserService userService; + @Autowired + private CouponCardTypeService couponCardTypeService; + @Autowired + private CouponService couponService; + @Autowired + private CouponUserService couponUserService; + private ReentrantReadWriteLock reentrantReadWriteLock=new ReentrantReadWriteLock(true); + + @Async + @Override + public void insertCouponCard(Integer num, Long couponCardTypeId){ + String createTime = DateUtils.format(new Date()); + for(int i=0;i().eq(StringUtils.isNotBlank(couponCardNo),"coupon_card_no",couponCardNo)); + } + + @Override + public Result selectCouponCardList(Integer page,Integer limit,Integer status,String couponCardNo,Long couponCardTypeId,Long userId){ + IPage couponCardPage = baseMapper.selectPage(new Page<>(page, limit), new QueryWrapper() + .eq(status!=null && status != 0, "status", status) + .eq(StringUtils.isNotBlank(couponCardNo), "coupon_card_no", couponCardNo) + .eq(userId!=null && userId!=0,"user_id",userId) + .eq(couponCardTypeId!=null && couponCardTypeId != 0, "coupon_card_type_id", couponCardTypeId)); + List records = couponCardPage.getRecords(); + for(CouponCard couponCard:records){ + if(couponCard.getUserId()!=null){ + couponCard.setUser(userService.selectUserById(couponCard.getUserId())); + } + } + return Result.success().put("data",new PageUtils(couponCardPage)); + } + + @Override + public ExcelData excelCouponCardList(Integer status, String couponCardNo, Long couponCardTypeId, Long userId){ + List couponCardList = baseMapper.selectList( new QueryWrapper() + .eq(status!=null && status != 0, "status", status) + .eq(StringUtils.isNotBlank(couponCardNo), "coupon_card_no", couponCardNo) + .eq(userId!=null && userId!=0,"user_id",userId) + .eq(couponCardTypeId!=null && couponCardTypeId != 0, "coupon_card_type_id", couponCardTypeId)); + + ExcelData data = new ExcelData(); + data.setName("提现列表"); + List titles = new ArrayList(); + titles.add("编号");titles.add("卡密");titles.add("领取用户"); + titles.add("状态");titles.add("创建时间"); + data.setTitles(titles); + List> rows = new ArrayList(); + for(CouponCard couponCard:couponCardList){ + List row = new ArrayList(); + row.add(couponCard.getCouponCardId()); + row.add(couponCard.getCouponCardNo()); + if(couponCard.getUserId()!=null){ + UserEntity userEntity = userService.selectUserById(couponCard.getUserId()); + if(userEntity!=null){ + row.add(userEntity.getUserName()); + }else{ + row.add("用户已被删除"); + } + }else{ + row.add("无"); + } + if(couponCard.getStatus()==1){ + row.add("待领取"); + }else{ + row.add("已领取"); + } + row.add(couponCard.getCreateTime()); + rows.add(row); + } + data.setRows(rows); + return data; + } + + @Override + public Result activateCouponCard(Long userId,String couponCardNo){ + reentrantReadWriteLock.writeLock().lock(); + try{ + CouponCard couponCard = selectCouponCard(couponCardNo); + if(couponCard==null){ + return Result.error("卡密错误!"); + }else if(couponCard.getStatus().equals(2)){ + return Result.error("卡密已被使用!"); + } + CouponCardType couponCardType = couponCardTypeService.getById(couponCard.getCouponCardTypeId()); + if(couponCardType.getStatus().equals(2)){ + return Result.error("卡密尚未开放!"); + } + couponCard.setUserId(userId); + couponCard.setStatus(2); + baseMapper.updateById(couponCard); + String[] couponIds = couponCardType.getCouponIds().split(","); + String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + List couponList=new ArrayList<>(); + for(String couponId:couponIds){ + Coupon coupon = couponService.getById(Long.parseLong(couponId)); + Integer endDate = coupon.getEndDate(); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DATE, endDate); + calendar.add(Calendar.DATE, 1); + Date date = calendar.getTime(); + String expirationTime = simpleDateFormat.format(date); + CouponUser couponUser=new CouponUser(); + couponUser.setUserId(userId); + couponUser.setCouponName(coupon.getCouponName()); + couponUser.setCouponPicture(coupon.getCouponPicture()); + couponUser.setCreateTime(createTime); + couponUser.setExpirationTime(expirationTime); + couponUser.setMinMoney(coupon.getMinMoney()); + couponUser.setMoney(coupon.getMoney()); + couponUser.setStatus(0); + couponUserService.save(couponUser); + couponList.add(coupon); + } + return Result.success().put("data",couponList); + }catch (Exception e){ + log.error("激活优惠券异常:"+e.getMessage(),e); + }finally { + reentrantReadWriteLock.writeLock().unlock(); + } + return Result.error("系统繁忙,请稍后再试!"); + } + + + + + public String randomCardNo(){ + Random random=new Random(); + while (true){ + StringBuilder str=new StringBuilder();//定义变长字符串 + //随机生成数字,并添加到字符串 + for(int j=0;j<8;j++){ + str.append(random.nextInt(10)); + } + //将字符串转换为数字并输出 + String couponCardNo=str.toString(); + CouponCard couponCard = selectCouponCard(couponCardNo); + if(couponCard==null){ + return couponCardNo; + } + } + } + + +} diff --git a/src/main/java/com/sqx/modules/coupon/service/impl/CouponCardTypeServiceImpl.java b/src/main/java/com/sqx/modules/coupon/service/impl/CouponCardTypeServiceImpl.java new file mode 100644 index 0000000..0f4d858 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/service/impl/CouponCardTypeServiceImpl.java @@ -0,0 +1,50 @@ +package com.sqx.modules.coupon.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.coupon.dao.CouponCardDao; +import com.sqx.modules.coupon.dao.CouponCardTypeDao; +import com.sqx.modules.coupon.dao.CouponDao; +import com.sqx.modules.coupon.entity.Coupon; +import com.sqx.modules.coupon.entity.CouponCardType; +import com.sqx.modules.coupon.service.CouponCardTypeService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class CouponCardTypeServiceImpl extends ServiceImpl implements CouponCardTypeService { + + @Autowired + private CouponCardDao couponCardDao; + @Autowired + private CouponDao couponDao; + + @Override + public Result selectCouponCardTypeList(Integer page, Integer limit, String couponTypeName, Integer status){ + IPage couponCardTypePage = baseMapper.selectPage(new Page<>(page, limit), new QueryWrapper() + .eq(StringUtils.isNotBlank(couponTypeName), "coupon_type_name", couponTypeName) + .eq(status != null && status != 0, "status", status).orderByAsc("create_time")); + List records = couponCardTypePage.getRecords(); + for(CouponCardType couponCardType:records){ + String[] split = couponCardType.getCouponIds().split(","); + List couponList=new ArrayList<>(); + for(String id:split){ + Coupon coupon = couponDao.selectById(Long.parseLong(id)); + couponList.add(coupon); + } + couponCardType.setCouponList(couponList); + } + return Result.success().put("data",new PageUtils(couponCardTypePage)); + } + + + +} diff --git a/src/main/java/com/sqx/modules/coupon/service/impl/CouponIssueServiceImpl.java b/src/main/java/com/sqx/modules/coupon/service/impl/CouponIssueServiceImpl.java new file mode 100644 index 0000000..6483e57 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/service/impl/CouponIssueServiceImpl.java @@ -0,0 +1,132 @@ +package com.sqx.modules.coupon.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.entity.UserMoneyDetails; +import com.sqx.modules.app.service.UserMoneyDetailsService; +import com.sqx.modules.app.service.UserMoneyService; +import com.sqx.modules.coupon.dao.CouponIssueDao; +import com.sqx.modules.coupon.dao.CouponUserDao; +import com.sqx.modules.coupon.entity.Coupon; +import com.sqx.modules.coupon.entity.CouponIssue; +import com.sqx.modules.coupon.entity.CouponUser; +import com.sqx.modules.coupon.service.CouponIssueService; +import com.sqx.modules.coupon.service.CouponService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +@Service +public class CouponIssueServiceImpl extends ServiceImpl implements CouponIssueService { + + @Autowired + private CouponUserDao couponUserDao; + @Autowired + private CouponService couponService; + @Autowired + private UserMoneyService userMoneyService; + @Autowired + private UserMoneyDetailsService userMoneyDetailsService; + + + @Override + public Result selectCouponIssueList(Integer page,Integer limit,String couponIssueName,Integer classify,Integer status){ + IPage couponIssuePage = baseMapper.selectPage(new Page<>(page, limit), + new QueryWrapper() + .eq(StringUtils.isNotBlank(couponIssueName), "coupon_issue_name", couponIssueName) + .eq(classify != 0, "classify", classify) + .eq(status != 0, "status", status)); + List records = couponIssuePage.getRecords(); + for(CouponIssue couponIssue:records){ + String[] couponIds = couponIssue.getCouponIds().split(","); + List couponList=new ArrayList<>(); + for(String couponId:couponIds) { + Coupon coupon = couponService.getById(Long.parseLong(couponId)); + couponList.add(coupon); + } + couponIssue.setCouponList(couponList); + } + return Result.success().put("data",new PageUtils(couponIssuePage)); + } + + @Override + public Result selectCouponIssueListByUserId(Integer page,Integer limit,Integer classify,Long userId){ + return Result.success().put("data",new PageUtils(baseMapper.selectCouponIssueListByUserId(new Page<>(page,limit),classify,userId))); + } + + + @Override + public Result insertCouponUser(Long userId, Long couponIssueId){ + CouponIssue couponIssue = baseMapper.selectById(couponIssueId); + if(couponIssue.getIsLimit()==1){ + //是否限购 + CouponUser couponUser = couponUserDao.selectOne(new QueryWrapper().eq("coupon_issue_id", couponIssueId)); + if(couponUser!=null){ + return Result.error("当前优惠券为限购,您已经拥有了!"); + } + if(couponIssue.getCouponNum()<=0){ + return Result.error("优惠券已经被抢完了!"); + } + } + String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + if(couponIssue.getClassify()==2){ + UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(userId); + if(couponIssue.getPrice().doubleValue()>userMoney.getMoney().doubleValue()){ + return Result.error("金额不足,请先充值 !"); + } + userMoneyService.updateMoney(2,userId,couponIssue.getPrice().doubleValue()); + UserMoneyDetails userMoneyDetails=new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(userId); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(couponIssue.getPrice()); + userMoneyDetails.setUserId(userId); + userMoneyDetails.setTitle("零钱购买优惠券,卷包:"+couponIssue.getCouponIssueName()); + userMoneyDetails.setContent("购买优惠券费用:"+couponIssue.getPrice()); + userMoneyDetails.setType(2); + userMoneyDetails.setCreateTime(createTime); + userMoneyDetailsService.save(userMoneyDetails); + } + String[] couponIds = couponIssue.getCouponIds().split(","); + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + for(String couponId:couponIds){ + Coupon coupon = couponService.getById(Long.parseLong(couponId)); + Integer endDate = coupon.getEndDate(); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DATE, endDate); + calendar.add(Calendar.DATE, 1); + Date date = calendar.getTime(); + String expirationTime = simpleDateFormat.format(date); + CouponUser couponUser=new CouponUser(); + couponUser.setUserId(userId); + couponUser.setCouponName(coupon.getCouponName()); + couponUser.setCouponPicture(coupon.getCouponPicture()); + couponUser.setCreateTime(createTime); + couponUser.setExpirationTime(expirationTime); + couponUser.setMinMoney(coupon.getMinMoney()); + couponUser.setMoney(coupon.getMoney()); + couponUser.setStatus(0); + couponUserDao.insert(couponUser); + } + couponIssue.setCouponNum(couponIssue.getCouponNum()-1); + baseMapper.updateById(couponIssue); + return Result.success(); + } + + +} diff --git a/src/main/java/com/sqx/modules/coupon/service/impl/CouponServiceImpl.java b/src/main/java/com/sqx/modules/coupon/service/impl/CouponServiceImpl.java new file mode 100644 index 0000000..5ef4175 --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/service/impl/CouponServiceImpl.java @@ -0,0 +1,85 @@ +package com.sqx.modules.coupon.service.impl; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.coupon.dao.CouponDao; +import com.sqx.modules.coupon.dao.CouponUserDao; +import com.sqx.modules.coupon.entity.Coupon; +import com.sqx.modules.coupon.service.CouponService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +@Service +public class CouponServiceImpl extends ServiceImpl implements CouponService { + + @Autowired + private CouponDao couponDao; + @Autowired + private CouponUserDao couponUserDao; + + @Override + public Result selectAllCoupon(Integer page, Integer limit) { + if(page == null || limit==null){ + List coupons = baseMapper.selectCouponList(); + return Result.success().put("data",coupons); + }else{ + Page pages = new Page<>(page, limit); + PageUtils pageUtils = new PageUtils(baseMapper.selectCouponPage(pages)); + return Result.success().put("data", pageUtils); + } + + } + + @Override + public Result issueCoupon(Coupon coupon) { + couponDao.insert(coupon); + return Result.success(); + } + + @Override + public Result updateCoupon(Coupon coupon) { + couponDao.updateById(coupon); + return Result.success(); + } + + @Override + public Result selectCouponList(Integer page, Integer limit) { + Page pages = new Page<>(page, limit); + PageUtils pageUtils = new PageUtils(baseMapper.selectPage(pages,null)); + return Result.success().put("data", pageUtils); + } + + + @Transactional + @Override + public Result giveCoupon(Long couponId, List userIdList, Long shopId) { + Coupon coupon = couponDao.selectById(couponId); + //计算优惠券过期时间 + Integer endDate = coupon.getEndDate(); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DATE, endDate); + calendar.add(Calendar.DATE, 1); + Date date = calendar.getTime(); + String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + String expirationTime = new SimpleDateFormat("yyyy-MM-dd").format(date); + couponUserDao.giveCoupon(userIdList, coupon.getCouponName(), coupon.getCouponPicture(), createTime, expirationTime, coupon.getMinMoney(), + coupon.getMoney(), 0,coupon.getEndDate().toString()); + return Result.success(); + } + + @Override + public Result deleteCoupon(Long couponId) { + couponDao.deleteById(couponId); + return Result.success(); + } + + +} diff --git a/src/main/java/com/sqx/modules/coupon/service/impl/CouponUserServiceImpl.java b/src/main/java/com/sqx/modules/coupon/service/impl/CouponUserServiceImpl.java new file mode 100644 index 0000000..c83f46e --- /dev/null +++ b/src/main/java/com/sqx/modules/coupon/service/impl/CouponUserServiceImpl.java @@ -0,0 +1,135 @@ +package com.sqx.modules.coupon.service.impl; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.coupon.dao.CouponDao; +import com.sqx.modules.coupon.dao.CouponUserDao; +import com.sqx.modules.coupon.entity.Coupon; +import com.sqx.modules.coupon.entity.CouponUser; +import com.sqx.modules.coupon.service.CouponUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +@Service +public class CouponUserServiceImpl extends ServiceImpl implements CouponUserService { + + @Autowired + private CouponUserDao CouponUserDao; + @Autowired + private CouponDao CouponDao; + @Autowired + private CommonInfoService commonInfoService; + @Autowired + private UserService userService; + + @Override + public Result selectCouponList(Long userId, Integer page, Integer limit, BigDecimal minMoney,Long shopId) { + Page pages=new Page<>(page,limit); + String format = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + PageUtils pageUtils = new PageUtils(CouponUserDao.selectCouponList(pages, userId, minMoney, format,shopId)); + return Result.success().put("data", pageUtils); + } + + @Override + public Result couponList(Long userId, Integer page, Integer limit, Integer status) { + Page pages=new Page<>(page,limit); + PageUtils pageUtils = new PageUtils(CouponUserDao.CouponList(pages, userId, status)); + return Result.success().put("data", pageUtils); + } + + @Override + public void updateExpiration() { + String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + CouponUserDao.updateExpiration(date); + } + + @Transactional + @Override + public Result buyCoupon(Long userId, Long couponId) { + + Coupon coupon = CouponDao.selectById(couponId); + //将优惠券添加到用户优惠券仓库 + CouponUser couponUser = new CouponUser(); + couponUser.setUserId(userId); + couponUser.setCouponName(coupon.getCouponName()); + couponUser.setCouponPicture(coupon.getCouponPicture()); + String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + couponUser.setCreateTime(format); + //计算优惠券过期时间 + Integer endDate = coupon.getEndDate(); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DATE, endDate); + calendar.add(Calendar.DATE, 1); + Date date = calendar.getTime(); + String format1 = new SimpleDateFormat("yyyy-MM-dd").format(date); + couponUser.setExpirationTime(format1); + couponUser.setMinMoney(coupon.getMinMoney()); + couponUser.setMoney(coupon.getMoney()); + couponUser.setStatus(0); + CouponUserDao.insert(couponUser); + + return Result.success(); + } + + @Override + public Result selectCouponByUserId(Integer page, Integer limit, Long userId, Integer status, String phone,String couponName) { + Page pages = new Page<>(page, limit); + PageUtils pageUtils = new PageUtils(CouponUserDao.selectCouponByUserId(pages, userId, status, phone,couponName)); + return Result.success().put("data", pageUtils); + } + + @Override + public Result insertNewUserCoupon(UserEntity userEntity){ + if(userEntity.getIsCoupon()!=null && userEntity.getIsCoupon()==1){ + return Result.error("您已经领取过新人优惠券了!"); + } + Long userId=userEntity.getUserId(); + String value = commonInfoService.findOne(281).getValue(); + String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + List couponList=new ArrayList<>(); + for(String couponId:value.split(",")){ + Coupon coupon = CouponDao.selectById(Long.parseLong(couponId)); + Integer endDate = coupon.getEndDate(); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DATE, endDate); + calendar.add(Calendar.DATE, 1); + Date date = calendar.getTime(); + String expirationTime = simpleDateFormat.format(date); + CouponUser couponUser=new CouponUser(); + couponUser.setUserId(userId); + couponUser.setCouponName(coupon.getCouponName()); + couponUser.setCouponPicture(coupon.getCouponPicture()); + couponUser.setCreateTime(createTime); + couponUser.setExpirationTime(expirationTime); + couponUser.setMinMoney(coupon.getMinMoney()); + couponUser.setMoney(coupon.getMoney()); + couponUser.setStatus(0); + baseMapper.insert(couponUser); + couponList.add(coupon); + } + userEntity.setIsCoupon(1); + userService.updateById(userEntity); + return Result.success().put("data",couponList); + } + + @Override + public CouponUser selectCountByUserId(Long userId) { + return CouponUserDao.selectCountByUserId(userId); + } + + +} diff --git a/src/main/java/com/sqx/modules/file/AliFileUploadController.java b/src/main/java/com/sqx/modules/file/AliFileUploadController.java new file mode 100644 index 0000000..8ff9949 --- /dev/null +++ b/src/main/java/com/sqx/modules/file/AliFileUploadController.java @@ -0,0 +1,300 @@ +package com.sqx.modules.file; + +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClientBuilder; +import com.sqx.common.utils.Result; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.file.utils.FileUploadUtils; +import com.sqx.modules.file.utils.ImageUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.jaudiotagger.audio.AudioFileIO; +import org.jaudiotagger.audio.mp3.MP3AudioHeader; +import org.jaudiotagger.audio.mp3.MP3File; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.*; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 阿里云文件上传 + * @author fang + * @date 2020/7/13 + */ +@RestController +@Api(value = "阿里云文件上传", tags = {"阿里云文件上传"}) +@RequestMapping(value = "/alioss") +@Slf4j +public class AliFileUploadController { + + + private final CommonInfoService commonRepository; + + @Autowired + public AliFileUploadController(CommonInfoService commonRepository) { + this.commonRepository = commonRepository; + } + + @RequestMapping(value = "/upload", method = RequestMethod.POST) + @ApiOperation("文件上传") + @ResponseBody + public Result upload(@RequestParam("file") MultipartFile file){ + String value = commonRepository.findOne(234).getValue(); + if("1".equals(value)){ + // 创建OSSClient实例。 + OSS ossClient = new OSSClientBuilder().build(commonRepository.findOne(68).getValue(), commonRepository.findOne(69).getValue(), commonRepository.findOne(70).getValue()); + String suffix = file.getOriginalFilename().substring(Objects.requireNonNull(file.getOriginalFilename()).lastIndexOf(".")); + // 上传文件流。 + InputStream inputStream = null; + try { + inputStream =new ByteArrayInputStream(file.getBytes()); + } catch (IOException e) { + e.printStackTrace(); + } + String completePath=getPath(suffix); + ossClient.putObject(commonRepository.findOne(71).getValue(), completePath, inputStream); + // 关闭OSSClient。 + ossClient.shutdown(); + // String src = commonRepository.findOne(72).getValue()+"/"+completePath; + String src = commonRepository.findOne(19).getValue()+"/img/"+completePath; + return Result.success().put("data",src); + }else{ + try + { + String http = commonRepository.findOne(19).getValue(); + String[] split = http.split("://"); + // 上传文件路径 + String filePath ="/www/wwwroot/"+split[1]+"/file/uploadPath"; + // 上传并返回新文件名称 + String fileName = FileUploadUtils.upload(filePath, file); + String url = http +fileName; + return Result.success().put("data",url); + } + catch (Exception e) + { + log.error("本地上传失败:"+e.getMessage(),e); + return Result.error(-100,"文件上传失败!"); + } + } + + } + + @RequestMapping(value = "/uploadWatermark", method = RequestMethod.POST) + @ApiOperation("文件上传(带水印版)") + @ResponseBody + public Result uploadWatermark(@RequestParam("file") MultipartFile file){ + String text = commonRepository.findOne(327).getValue(); + file=ImageUtil.addWatermark(text,null,file); + String value = commonRepository.findOne(234).getValue(); + if("1".equals(value)){ + // 创建OSSClient实例。 + OSS ossClient = new OSSClientBuilder().build(commonRepository.findOne(68).getValue(), commonRepository.findOne(69).getValue(), commonRepository.findOne(70).getValue()); + String suffix = file.getOriginalFilename().substring(Objects.requireNonNull(file.getOriginalFilename()).lastIndexOf(".")); + // 上传文件流。 + InputStream inputStream = null; + try { + inputStream =new ByteArrayInputStream(file.getBytes()); + } catch (IOException e) { + e.printStackTrace(); + } + String completePath=getPath(suffix); + ossClient.putObject(commonRepository.findOne(71).getValue(), completePath, inputStream); + // 关闭OSSClient。 + ossClient.shutdown(); + // String src = commonRepository.findOne(72).getValue()+"/"+completePath; + String src = commonRepository.findOne(19).getValue()+"/img/"+completePath; + return Result.success().put("data",src); + }else{ + try + { + String http = commonRepository.findOne(19).getValue(); + String[] split = http.split("://"); + // 上传文件路径 + String filePath ="/www/wwwroot/"+split[1]+"/file/uploadPath"; + // 上传并返回新文件名称 + String fileName = FileUploadUtils.upload(filePath, file); + String url = http +fileName; + return Result.success().put("data",url); + } + catch (Exception e) + { + log.error("本地上传失败:"+e.getMessage(),e); + return Result.error(-100,"文件上传失败!"); + } + } + + } + + @RequestMapping(value = "/uploadUniApp", method = RequestMethod.POST) + @ApiOperation("文件上传") + @ResponseBody + public String uploadUniApp(@RequestParam("file") MultipartFile file){ + String value = commonRepository.findOne(234).getValue(); + if("1".equals(value)){ + // 创建OSSClient实例。 + OSS ossClient = new OSSClientBuilder().build(commonRepository.findOne(68).getValue(), commonRepository.findOne(69).getValue(), commonRepository.findOne(70).getValue()); + String suffix = file.getOriginalFilename().substring(Objects.requireNonNull(file.getOriginalFilename()).lastIndexOf(".")); + // 上传文件流。 + InputStream inputStream = null; + try { + inputStream =new ByteArrayInputStream(file.getBytes()); + } catch (IOException e) { + e.printStackTrace(); + } + String completePath=getPath(suffix); + ossClient.putObject(commonRepository.findOne(71).getValue(), completePath, inputStream); + // 关闭OSSClient。 + ossClient.shutdown(); + return commonRepository.findOne(19).getValue()+"/img/"+completePath; + }else{ + try + { + String http = commonRepository.findOne(19).getValue(); + String[] split = http.split("://"); + // 上传文件路径 + String filePath ="/www/wwwroot/"+split[1]+"/file/uploadPath"; + // 上传并返回新文件名称 + String fileName = FileUploadUtils.upload(filePath, file); + String url = http +fileName; + return url; + } + catch (Exception e) + { + log.error("本地上传失败:"+e.getMessage(),e); + return null; + } + } + + } + + @RequestMapping(value = "/uploadMusic", method = RequestMethod.POST) + @ApiOperation("文件上传") + @ResponseBody + public Result uploadMusic(@RequestParam("file") MultipartFile file) { + String url=""; + String value = commonRepository.findOne(234).getValue(); + if("1".equals(value)){ + // 创建OSSClient实例。 + OSS ossClient = new OSSClientBuilder().build(commonRepository.findOne(68).getValue(), commonRepository.findOne(69).getValue(), commonRepository.findOne(70).getValue()); + String suffix = file.getOriginalFilename().substring(Objects.requireNonNull(file.getOriginalFilename()).lastIndexOf(".")); + // 上传文件流。 + InputStream inputStream = null; + try { + inputStream =new ByteArrayInputStream(file.getBytes()); + } catch (IOException e) { + e.printStackTrace(); + } + String completePath=getPath(suffix); + ossClient.putObject(commonRepository.findOne(71).getValue(), completePath, inputStream); + // 关闭OSSClient。 + ossClient.shutdown(); + url = commonRepository.findOne(19).getValue()+"/img/"+completePath; + }else{ + try + { + String http = commonRepository.findOne(19).getValue(); + String[] split = http.split("://"); + // 上传文件路径 + String filePath ="/www/wwwroot/"+split[1]+"/file/uploadPath"; + // 上传并返回新文件名称 + String fileName = FileUploadUtils.upload(filePath, file); + url = http +fileName; + } + catch (Exception e) + { + log.error("本地上传失败:"+e.getMessage(),e); + return null; + } + } + if("/".equals(url.substring(url.length()-1,url.length()))){ + url=url.substring(0,url.length()-1); + } + int trackLength=0; + try { + File file1 = multipartFileToFile(file); + MP3File f = (MP3File) AudioFileIO.read(file1); + MP3AudioHeader audioHeader = (MP3AudioHeader)f.getAudioHeader(); + trackLength = audioHeader.getTrackLength(); + delteTempFile(file1); + } catch (Exception e) { + e.printStackTrace(); + } + Map result=new HashMap<>(); + result.put("url",url); + result.put("sec",trackLength); + return Result.success().put("data",result ); + } + + + /** + * MultipartFile 转 File + * + * @param file + * @throws Exception + */ + public static File multipartFileToFile(MultipartFile file) throws Exception { + + File toFile = null; + if (file.equals("") || file.getSize() <= 0) { + file = null; + } else { + InputStream ins = null; + ins = file.getInputStream(); + toFile = new File(file.getOriginalFilename()); + inputStreamToFile(ins, toFile); + ins.close(); + } + return toFile; + } + + //获取流文件 + private static void inputStreamToFile(InputStream ins, File file) { + try { + OutputStream os = new FileOutputStream(file); + int bytesRead = 0; + byte[] buffer = new byte[8192]; + while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { + os.write(buffer, 0, bytesRead); + } + os.close(); + ins.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 删除本地临时文件 + * @param file + */ + public static void delteTempFile(File file) { + if (file != null) { + File del = new File(file.toURI()); + del.delete(); + } + } + + private String getPath(String suffix) { + //生成uuid + String uuid = UUID.randomUUID().toString().replaceAll("-", ""); + //文件路径 + String path =format(new Date()) + "/" + uuid; + return path + suffix; + } + + + private String format(Date date) { + if(date != null){ + SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd"); + return df.format(date); + } + return null; + } + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/file/utils/DescribeException.java b/src/main/java/com/sqx/modules/file/utils/DescribeException.java new file mode 100644 index 0000000..8ad4cb8 --- /dev/null +++ b/src/main/java/com/sqx/modules/file/utils/DescribeException.java @@ -0,0 +1,34 @@ +package com.sqx.modules.file.utils; + +public class DescribeException extends RuntimeException{ + + private Integer code; + + /** + * 继承exception,加入错误状态值 + * @param exceptionEnum + */ + public DescribeException(ExceptionEnum exceptionEnum) { + super(exceptionEnum.getMsg()); + this.code = exceptionEnum.getCode(); + } + + /** + * 自定义错误信息 + * @param message + * @param code + */ + public DescribeException(String message, Integer code) { + super(message); + this.code = code; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } +} + diff --git a/src/main/java/com/sqx/modules/file/utils/ExceptionEnum.java b/src/main/java/com/sqx/modules/file/utils/ExceptionEnum.java new file mode 100644 index 0000000..d7750d2 --- /dev/null +++ b/src/main/java/com/sqx/modules/file/utils/ExceptionEnum.java @@ -0,0 +1,49 @@ +package com.sqx.modules.file.utils; + +public enum ExceptionEnum { + UNKNOW_ERROR(-1, "未知错误"), + LIMIT_USER(-100, "账号已经禁用,请联系管理员!"), + USER_NOT_FIND(-101, "用户未注册"), + USER_IS_BIND_FOR_ANTHER_OPENID(-99, "当前手机号已经被其他微信绑定"), + WRONT_TOKEN(-102, "用户信息失效,请重新登录"), + USER_PWD_EMPTY(-103, "用户名密码不能为空"), + USER_PWD_ERROR(-104, "用户名或密码错误"), + USER_IS_EXITS(-105, "手机号已经注册!"), + ERROR(-106, "服务器内部错误"), + UPDATE_PWD_ERROR(-107, "密码修改失败"), + STATE_PWD_ERROR(-108, "状态修改失败"), + DATA_EMPTY(-109, "添加数据不能为空"), + Return_ATA_EMPTY(-110, "暂无数据"), + ADD_ERROR(-111, "提现失败"), + CODE_ERROR(-112, "验证码不正确"), + BIND_ERROR(-113, "手机号已经被其他账号绑定"), + SEND_ERROR(-114, "验证码发送失败"), + USER_PHONE_ERROR(-115, "用户名不能为空"), + OLD_PWD_ERROR(-116, "原始密码错误"), + IS_REGISTER(-117, "当前手机号已经绑定其他微信账号"), + IS_BIND(-118, "当前淘宝账号已经绑定其他手机号"), + IS_BIND_RELATION(-119, "当前账号已经绑定其他淘宝账号"), + OLD_NOT_SAME_NEW_PWD_ERROR(-120, "新密码不能等于和原始密码一致"), + USER_IS_REGISTER(-121, "用户已经注册请前往登录"), + RELATIONID_IS_REGISTER(-122, "淘宝账号已经授权绑定其他手机号"), + CODE_NOT_FOUND(-123, "邀请码不存在"), + COMMON_IS_EXITS(-124, "已经存在"), + COUPONS_ZERO(-125, "优惠券被领完了"), + COUPONS_GET_OUT(-126, "优惠券超过领取次数"), + COUPONS_TIME_OUT(-127, "优惠券已过期"); + private Integer code; + private String msg; + ExceptionEnum(Integer code, String msg) { + this.code = code; + this.msg = msg; + } + + public Integer getCode() { + return code; + } + + public String getMsg() { + return msg; + } +} + diff --git a/src/main/java/com/sqx/modules/file/utils/FileUploadUtils.java b/src/main/java/com/sqx/modules/file/utils/FileUploadUtils.java new file mode 100644 index 0000000..87842ef --- /dev/null +++ b/src/main/java/com/sqx/modules/file/utils/FileUploadUtils.java @@ -0,0 +1,238 @@ +package com.sqx.modules.file.utils; + +import com.sqx.modules.common.service.CommonInfoService; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.IOException; +import java.util.Date; + +/** + * 文件上传工具类 + * + * @author ruoyi + */ +public class FileUploadUtils +{ + /** + * 默认大小 50M + */ + public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024; + + /** + * 默认的文件名最大长度 100 + */ + public static final int DEFAULT_FILE_NAME_LENGTH = 100; + + private static int counter = 0; + + private static CommonInfoService commonRepository; + + @Autowired + public void setCommonRepository(CommonInfoService commonRepository) { + FileUploadUtils.commonRepository = commonRepository; + } + + public static String getDefaultBaseDir() + { + return commonRepository.findOne(19).getValue(); + } + + /** + * 以默认配置进行文件上传 + * + * @param file 上传的文件 + * @return 文件名称 + * @throws Exception + */ + public static final String upload(MultipartFile file) throws IOException + { + try + { + return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); + } + catch (Exception e) + { + throw new IOException(e.getMessage(), e); + } + } + + /** + * 根据文件路径上传 + * + * @param baseDir 相对应用的基目录 + * @param file 上传的文件 + * @return 文件名称 + * @throws IOException + */ + public static final String upload(String baseDir, MultipartFile file) throws IOException + { + try + { + return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); + } + catch (Exception e) + { + throw new IOException(e.getMessage(), e); + } + } + + /** + * 文件上传 + * + * @param baseDir 相对应用的基目录 + * @param file 上传的文件 + * @return 返回上传成功的文件名 + */ + public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension) + throws DescribeException,IOException + { + int fileNamelength = file.getOriginalFilename().length(); + if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) + { + throw new DescribeException("文件名太长",-100); + } + + assertAllowed(file, allowedExtension); + + String fileName = extractFilename(file); + + File desc = getAbsoluteFile(baseDir, fileName); + file.transferTo(desc); + String pathFileName = getPathFileName(baseDir, fileName); + return pathFileName; + } + + /** + * 编码文件名 + */ + public static final String extractFilename(MultipartFile file) + { + String fileName = file.getOriginalFilename(); + String extension = getExtension(file); + fileName =datePath() + "/" + encodingFilename(fileName) + "." + extension; + return fileName; + } + + /** + * 日期路径 即年/月/日 如2018/08/08 + */ + public static final String datePath() + { + Date now = new Date(); + return DateFormatUtils.format(now, "yyyy/MM/dd"); + } + + + + private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException + { + File desc = new File(uploadDir + File.separator + fileName); + + if (!desc.getParentFile().exists()) + { + desc.getParentFile().mkdirs(); + } + if (!desc.exists()) + { + desc.createNewFile(); + } + return desc; + } + + private static final String getPathFileName(String uploadDir, String fileName) throws IOException + { + int dirLastIndex = uploadDir.lastIndexOf("/") + 1; + String currentDir = StringUtils.substring(uploadDir, dirLastIndex); + String pathFileName = "/file/" + currentDir + "/" + fileName; + return pathFileName; + } + + /** + * 编码文件名 + */ + private static final String encodingFilename(String fileName) + { + fileName = fileName.replace("_", " "); + fileName = Md5Utils.hash(fileName + System.nanoTime() + counter++); + return fileName; + } + + /** + * 文件大小校验 + * + * @param file 上传的文件 + * @return + */ + public static final void assertAllowed(MultipartFile file, String[] allowedExtension) + throws DescribeException + { + long size = file.getSize(); + if (DEFAULT_MAX_SIZE != -1 && size > DEFAULT_MAX_SIZE) + { + throw new DescribeException("文件太大",-100); + } + + String fileName = file.getOriginalFilename(); + String extension = getExtension(file); + if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) + { + if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) + { + throw new DescribeException("",-100); + } + else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) + { + throw new DescribeException("",-100); + } + else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) + { + throw new DescribeException("",-100); + } + else + { + throw new DescribeException("",-100); + } + } + + } + + /** + * 判断MIME类型是否是允许的MIME类型 + * + * @param extension + * @param allowedExtension + * @return + */ + public static final boolean isAllowedExtension(String extension, String[] allowedExtension) + { + for (String str : allowedExtension) + { + if (str.equalsIgnoreCase(extension)) + { + return true; + } + } + return false; + } + + /** + * 获取文件名的后缀 + * + * @param file 表单文件 + * @return 后缀名 + */ + public static final String getExtension(MultipartFile file) + { + String extension = FilenameUtils.getExtension(file.getOriginalFilename()); + if (StringUtils.isEmpty(extension)) + { + extension = MimeTypeUtils.getExtension(file.getContentType()); + } + return extension; + } +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/file/utils/FileUtils.java b/src/main/java/com/sqx/modules/file/utils/FileUtils.java new file mode 100644 index 0000000..b424a41 --- /dev/null +++ b/src/main/java/com/sqx/modules/file/utils/FileUtils.java @@ -0,0 +1,137 @@ +package com.sqx.modules.file.utils; + +import javax.servlet.http.HttpServletRequest; +import java.io.*; +import java.net.URLEncoder; + +/** + * 文件处理工具类 + * + * @author ruoyi + */ +public class FileUtils +{ + public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"; + + /** + * 输出指定文件的byte数组 + * + * @param filePath 文件路径 + * @param os 输出流 + * @return + */ + public static void writeBytes(String filePath, OutputStream os) throws IOException + { + FileInputStream fis = null; + try + { + File file = new File(filePath); + if (!file.exists()) + { + throw new FileNotFoundException(filePath); + } + fis = new FileInputStream(file); + byte[] b = new byte[1024]; + int length; + while ((length = fis.read(b)) > 0) + { + os.write(b, 0, length); + } + } + catch (IOException e) + { + throw e; + } + finally + { + if (os != null) + { + try + { + os.close(); + } + catch (IOException e1) + { + e1.printStackTrace(); + } + } + if (fis != null) + { + try + { + fis.close(); + } + catch (IOException e1) + { + e1.printStackTrace(); + } + } + } + } + + /** + * 删除文件 + * + * @param filePath 文件 + * @return + */ + public static boolean deleteFile(String filePath) + { + boolean flag = false; + File file = new File(filePath); + // 路径为文件且不为空则进行删除 + if (file.isFile() && file.exists()) + { + file.delete(); + flag = true; + } + return flag; + } + + /** + * 文件名称验证 + * + * @param filename 文件名称 + * @return true 正常 false 非法 + */ + public static boolean isValidFilename(String filename) + { + return filename.matches(FILENAME_PATTERN); + } + + /** + * 下载文件名重新编码 + * + * @param request 请求对象 + * @param fileName 文件名 + * @return 编码后的文件名 + */ + public static String setFileDownloadHeader(HttpServletRequest request, String fileName) + throws UnsupportedEncodingException + { + final String agent = request.getHeader("USER-AGENT"); + String filename = fileName; + if (agent.contains("MSIE")) + { + // IE浏览器 + filename = URLEncoder.encode(filename, "utf-8"); + filename = filename.replace("+", " "); + } + else if (agent.contains("Firefox")) + { + // 火狐浏览器 + filename = new String(fileName.getBytes(), "ISO8859-1"); + } + else if (agent.contains("Chrome")) + { + // google浏览器 + filename = URLEncoder.encode(filename, "utf-8"); + } + else + { + // 其它浏览器 + filename = URLEncoder.encode(filename, "utf-8"); + } + return filename; + } +} diff --git a/src/main/java/com/sqx/modules/file/utils/ImageUtil.java b/src/main/java/com/sqx/modules/file/utils/ImageUtil.java new file mode 100644 index 0000000..c0b6890 --- /dev/null +++ b/src/main/java/com/sqx/modules/file/utils/ImageUtil.java @@ -0,0 +1,251 @@ +package com.sqx.modules.file.utils; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.*; +import java.net.MalformedURLException; +import java.net.URL; + +/** + * 图片工具 + */ +@Component +public class ImageUtil { + + public static MultipartFile addWatermark(String textWatermark,String imageWatermark,MultipartFile file){ + // 读取原图片信息 得到文件 + File srcImgFile = null; + try { + srcImgFile = multipartFileToFile(file); + } catch (Exception e) { + e.printStackTrace(); + } + //File srcImgFile =new File("E:\\data\\123.png"); + //将文件对象转化为图片对象 + Image srcImg = null; + try { + srcImg = ImageIO.read(srcImgFile); + } catch (IOException e) { + e.printStackTrace(); + } + delteTempFile(srcImgFile); + //获取图片的宽 + int srcImgWidth = srcImg.getWidth(null); + //获取图片的高 + int srcImgHeight = srcImg.getHeight(null); + + BufferedImage bufImg = new BufferedImage(srcImgWidth, srcImgHeight, BufferedImage.TYPE_INT_RGB); + // 加水印 + //创建画笔 + Graphics2D graphics2D = bufImg.createGraphics(); + //绘制原始图片 + graphics2D.drawImage(srcImg, 0, 0, srcImgWidth, srcImgHeight, null); + + //如果文字水印有值,就将其绘制在图的中间 + if(StringUtils.isNotEmpty(textWatermark)){ + addTextWatermark(graphics2D,srcImgWidth,srcImgHeight,textWatermark); + } + if(StringUtils.isNotEmpty(imageWatermark)){ + //如果图片水印有值,就将其绘制在图的右下角 + addImageWatermark(graphics2D,srcImgWidth,srcImgHeight,imageWatermark,4); + } + + //待存储的地址--测试用的 + //String tarImgPath="E:/data/test.png"; + //输出图片 + //FileOutputStream outImgStream = null; + ByteArrayOutputStream os = null; + MultipartFile multipartFile = null; + try { + //outImgStream = new FileOutputStream(tarImgPath); + //ImageIO.write(bufImg, "png", outImgStream); + + //创建一个ByteArrayOutputStream + os = new ByteArrayOutputStream(); + //把BufferedImage写入ByteArrayOutputStream + //此处要写PNG否则可能会出现遮罩层 + ImageIO.write(bufImg, "png", os); + //ByteArrayOutputStream转成InputStream + InputStream input = new ByteArrayInputStream(os.toByteArray()); + multipartFile =new MockMultipartFile("file", "file.png", "text/plain", input); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (null != os) { + os.close(); + } +// if (null != outImgStream) { +// outImgStream.flush(); +// outImgStream.close(); +// } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return multipartFile; + } + + public static void addTextWatermark(Graphics2D graphics2D,int srcImgWidth,int srcImgHeight,String textWatermark){ + //-------------------------文字水印 start---------------------------- + //根据图片的背景设置水印颜色 + graphics2D.setColor(new Color(0,0,0)); + //设置字体 画笔字体样式为微软雅黑,加粗,文字大小为60pt + graphics2D.setFont(new Font("黑体", Font.ITALIC, 30)); + graphics2D.rotate(Math.toRadians(315),(double)srcImgWidth/2, (double)srcImgHeight/2); + //设置水印的坐标(为原图片中间位置) + //textWatermark为水印内容 + /*int x=(srcImgWidth - getWatermarkLength(textWatermark, graphics2D)) / 2; + int y=srcImgHeight / 10;*/ + //画出水印 第一个参数是水印内容,第二个参数是x轴坐标,第三个参数是y轴坐标 +// graphics2D.drawString(textWatermark, x, y); + int width=40; + if(textWatermark.length()>0){ + width=width*textWatermark.length(); + } + for (int i = -200; i <= srcImgWidth+200; i += width) { + for (int j = -200; j <= srcImgHeight+200; j += 80) { + graphics2D.drawString(textWatermark, i, j); + } + } + graphics2D.dispose(); + //-------------------------文字水印 end---------------------------- + } + //水印方法重构 暂时不用 + public static void addTextWatermark2(Graphics2D graphics2D,int srcImgWidth,int srcImgHeight,String textWatermark){ + //-------------------------文字水印 start---------------------------- + //根据图片的背景设置水印颜色 + graphics2D.setColor(new Color(0,0,0)); + //设置字体 画笔字体样式为微软雅黑,加粗,文字大小为60pt + graphics2D.setFont(new Font("黑体", Font.ITALIC, 40)); + graphics2D.rotate(Math.toRadians(315),(double)srcImgWidth/2, (double)srcImgHeight/2); + //i为x坐标 j为y坐标 通过设置坐标来控制水印的位置 positionWidth和positionHeight 设置密度 + // 水印横向间隔 + int positionWidth = (int)(srcImgWidth * 0.1); + // 水印竖向间隔 + int positionHeight = (int)(srcImgHeight * 0.03); + for(int i = -400; i <= srcImgWidth * 3 ; i += positionWidth){ + for (int j = -400; j <= srcImgHeight * 3 ; j += positionHeight){ + graphics2D.drawString(textWatermark, i, j); + } + } + graphics2D.dispose(); + //-------------------------文字水印 end---------------------------- + } + public static void addImageWatermark(Graphics2D graphics2D,int srcImgWidth,int srcImgHeight,String imageWatermark,int type){ + //-------------------------图片水印 start---------------------------- + //水印文件 + //创建一个URL对象,获取网络图片的地址信息(网络图片) + URL url = null; + //将URL对象输入流转化为图片对象 (url.openStream()方法,获得一个输入流) + Image srcWaterMark = null; + try { + url = new URL(imageWatermark); + srcWaterMark = ImageIO.read(url.openStream()); + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + //设置 alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + graphics2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.5f)); + //x,y为章需要合成到A图片上的位置坐标,w,h为将章缩小到多少长宽比例 + //注意这行代码:graphics2D.drawlmage(img, x, y, w, h, null); + //绘制水印图片 坐标为自己选择 + int x = 0; + int y = 0; + int width = (int)(srcImgWidth*0.1); + int height = (int)(srcImgWidth*0.1); + if (type == 1) { + //覆盖图片位于左上角 + x = 0; + y = 0; + } else if (type == 2) { + //覆盖图片位于右上角 + x = srcImgWidth - width; + y = 0; + } else if (type == 3) { + //覆盖图片位于左下角 + x = 0; + y = srcImgHeight - height; + } else if (type == 4) { + //覆盖图片位于右下角 + x = srcImgWidth - width; + y = srcImgHeight - height; + } else if (type == 5 ){ + //覆盖图片位于中间 + x = (srcImgWidth - width) / 2; + y = (srcImgWidth - height) / 2; + } + graphics2D.drawImage(srcWaterMark, x, y ,width, height, null); + // 水印文件结束 + graphics2D.dispose(); + //-------------------------图片水印 end---------------------------- + } + + /** + * 获取水印文字的长度 + * @param waterMarkContent + * @param graphics2D + * @return + */ + public static int getWatermarkLength(String waterMarkContent, Graphics2D graphics2D) { + return graphics2D.getFontMetrics(graphics2D.getFont()).charsWidth(waterMarkContent.toCharArray(), 0, waterMarkContent.length()); + } + + + /** + * MultipartFile 转 File + * + * @param file + * @throws Exception + */ + public static File multipartFileToFile(MultipartFile file) throws Exception { + + File toFile = null; + if (file.equals("") || file.getSize() <= 0) { + file = null; + } else { + InputStream ins = null; + ins = file.getInputStream(); + toFile = new File(file.getOriginalFilename()); + inputStreamToFile(ins, toFile); + ins.close(); + } + return toFile; + } + + //获取流文件 + private static void inputStreamToFile(InputStream ins, File file) { + try { + OutputStream os = new FileOutputStream(file); + int bytesRead = 0; + byte[] buffer = new byte[8192]; + while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { + os.write(buffer, 0, bytesRead); + } + os.close(); + ins.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + public static void delteTempFile(File file) { + if (file != null) { + File del = new File(file.toURI()); + del.delete(); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/file/utils/Md5Utils.java b/src/main/java/com/sqx/modules/file/utils/Md5Utils.java new file mode 100644 index 0000000..ac2b848 --- /dev/null +++ b/src/main/java/com/sqx/modules/file/utils/Md5Utils.java @@ -0,0 +1,140 @@ +package com.sqx.modules.file.utils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * Md5加密方法 + * + * @author ruoyi + */ +public class Md5Utils +{ + private static final Logger log = LoggerFactory.getLogger(Md5Utils.class); + + private static byte[] md5(String s) + { + MessageDigest algorithm; + try + { + algorithm = MessageDigest.getInstance("MD5"); + algorithm.reset(); + algorithm.update(s.getBytes("UTF-8")); + byte[] messageDigest = algorithm.digest(); + return messageDigest; + } + catch (Exception e) + { + log.error("MD5 Error...", e); + } + return null; + } + + private static final String toHex(byte hash[]) + { + if (hash == null) + { + return null; + } + StringBuffer buf = new StringBuffer(hash.length * 2); + int i; + + for (i = 0; i < hash.length; i++) + { + if ((hash[i] & 0xff) < 0x10) + { + buf.append("0"); + } + buf.append(Long.toString(hash[i] & 0xff, 16)); + } + return buf.toString(); + } + + public static String hash(String s) + { + try + { + return new String(toHex(md5(s)).getBytes("UTF-8"), "UTF-8"); + } + catch (Exception e) + { + log.error("not supported charset...{}", e); + return s; + } + } + + public static String md5s(String plainText) { + StringBuffer buf = null; + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(plainText.getBytes()); + byte b[] = md.digest(); + int i; + buf = new StringBuffer(""); + for (int offset = 0; offset < b.length; offset++) { + i = b[offset]; + if (i < 0) + i += 256; + if (i < 16) + buf.append("0"); + buf.append(Integer.toHexString(i)); + } + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + return buf.toString(); + } + + public static String encodeUrlString(String str, String charset) { + String strret = null; + if (str == null){ + return str; + } + try { + strret = java.net.URLEncoder.encode(str, charset); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + return strret; + } + + public static String request(String httpUrl, String httpArg) { + BufferedReader reader = null; + String result = null; + StringBuffer sbf = new StringBuffer(); + httpUrl = httpUrl + "?" + httpArg; + + try { + URL url = new URL(httpUrl); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("GET"); + connection.connect(); + InputStream is = connection.getInputStream(); + reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); + String strRead = reader.readLine(); + if (strRead != null) { + sbf.append(strRead); + while ((strRead = reader.readLine()) != null) { + sbf.append("\n"); + sbf.append(strRead); + } + } + reader.close(); + result = sbf.toString(); + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } + + +} diff --git a/src/main/java/com/sqx/modules/file/utils/MimeTypeUtils.java b/src/main/java/com/sqx/modules/file/utils/MimeTypeUtils.java new file mode 100644 index 0000000..3fcef59 --- /dev/null +++ b/src/main/java/com/sqx/modules/file/utils/MimeTypeUtils.java @@ -0,0 +1,59 @@ +package com.sqx.modules.file.utils; + +/** + * 媒体类型工具类 + * + * @author ruoyi + */ +public class MimeTypeUtils +{ + public static final String IMAGE_PNG = "image/png"; + + public static final String IMAGE_JPG = "image/jpg"; + + public static final String IMAGE_JPEG = "image/jpeg"; + + public static final String IMAGE_BMP = "image/bmp"; + + public static final String IMAGE_GIF = "image/gif"; + + public static final String[] IMAGE_EXTENSION = { "bmp", "gif", "jpg", "jpeg", "png" }; + + public static final String[] FLASH_EXTENSION = { "swf", "flv" }; + + public static final String[] MEDIA_EXTENSION = { "swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg", + "asf", "rm", "rmvb" }; + + public static final String[] DEFAULT_ALLOWED_EXTENSION = { + // 图片 + "bmp", "gif", "jpg", "jpeg", "png", + // word excel powerpoint + "doc", "docx", "xls", "xlsx", "ppt", "pptx", "html", "htm", "txt", + // 压缩文件 + "rar", "zip", "gz", "bz2", + // 安卓ios更新包 + "apk", "ipa", + //视频格式 + "mp4","mp3","3GP","AVI","mov","rmvb", + // pdf + "pdf" }; + + public static String getExtension(String prefix) + { + switch (prefix) + { + case IMAGE_PNG: + return "png"; + case IMAGE_JPG: + return "jpg"; + case IMAGE_JPEG: + return "jpeg"; + case IMAGE_BMP: + return "bmp"; + case IMAGE_GIF: + return "gif"; + default: + return ""; + } + } +} diff --git a/src/main/java/com/sqx/modules/helpCenter/controller/HelpWordController.java b/src/main/java/com/sqx/modules/helpCenter/controller/HelpWordController.java new file mode 100644 index 0000000..54ed66e --- /dev/null +++ b/src/main/java/com/sqx/modules/helpCenter/controller/HelpWordController.java @@ -0,0 +1,112 @@ +package com.sqx.modules.helpCenter.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.helpCenter.entity.HelpClassify; +import com.sqx.modules.helpCenter.entity.HelpWord; +import com.sqx.modules.helpCenter.service.HelpClassifyService; +import com.sqx.modules.helpCenter.service.HelpWordService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Date; +import java.util.List; + +@RestController +@Api(value = "帮助中心", tags = {"帮助中心"}) +@RequestMapping(value = "/helpWord") +public class HelpWordController { + + @Autowired + private HelpClassifyService helpClassifyService; + @Autowired + private HelpWordService helpWordService; + + + @PostMapping("/insertHelpClassify") + @ApiOperation("添加帮助分类") + public Result insertHelpClassify(@RequestBody HelpClassify helpClassify){ + helpClassify.setCreateTime(DateUtils.format(new Date())); + helpClassifyService.save(helpClassify); + return Result.success(); + } + + @PostMapping("/updateHelpClassify") + @ApiOperation("修改帮助分类") + public Result updateHelpClassify(@RequestBody HelpClassify helpClassify){ + helpClassifyService.updateById(helpClassify); + return Result.success(); + } + + @PostMapping("/deleteHelpClassify") + @ApiOperation("删除帮助分类") + public Result deleteHelpClassify(Long helpClassifyId){ + helpClassifyService.removeById(helpClassifyId); + return Result.success(); + } + + + @GetMapping("/selectHelpClassifyList") + @ApiOperation("查询帮助分类") + public Result selectHelpClassifyList(Integer page,Integer limit,Long parentId,Integer types,String helpClassifyName){ + if(page==null || limit==null){ + List page1 = helpClassifyService.list( + new QueryWrapper() + .eq(types!=null,"types",types) + .eq(StringUtils.isNotBlank(helpClassifyName), "help_classify_name", helpClassifyName) + .eq(parentId != null, "parent_id", parentId).orderByAsc("sort")); + return Result.success().put("data",page1); + } + IPage page1 = helpClassifyService.page(new Page<>(page, limit), + new QueryWrapper() + .eq(types!=null,"types",types) + .eq(StringUtils.isNotBlank(helpClassifyName), "help_classify_name", helpClassifyName) + .eq(parentId != null, "parent_id", parentId).orderByAsc("sort")); + return Result.success().put("data",new PageUtils(page1)); + } + + + @PostMapping("/insertHelpWord") + @ApiOperation("添加帮助文档") + public Result insertHelpWord(@RequestBody HelpWord helpWord){ + helpWord.setCreateTime(DateUtils.format(new Date())); + helpWordService.save(helpWord); + return Result.success(); + } + + @PostMapping("/updateHelpWord") + @ApiOperation("修改帮助文档") + public Result updateHelpWord(@RequestBody HelpWord helpWord){ + helpWordService.updateById(helpWord); + return Result.success(); + } + + @PostMapping("/deleteHelpWord") + @ApiOperation("删除帮助文档") + public Result deleteHelpWord(Long helpWordId){ + helpWordService.removeById(helpWordId); + return Result.success(); + } + + + @GetMapping("/selectHelpWordList") + @ApiOperation("查询帮助文档") + public Result selectHelpWordList(Integer page,Integer limit,Long helpClassifyId,String helpWordTitle){ + IPage page1 = helpWordService.page(new Page<>(page, limit), new QueryWrapper() + .eq(helpClassifyId != null, "help_classify_id", helpClassifyId) + .eq(StringUtils.isNotBlank(helpWordTitle), "help_word_title", helpWordTitle).orderByAsc("sort")); + return Result.success().put("data",new PageUtils(page1)); + } + + + + + +} diff --git a/src/main/java/com/sqx/modules/helpCenter/controller/app/AppHelpWordController.java b/src/main/java/com/sqx/modules/helpCenter/controller/app/AppHelpWordController.java new file mode 100644 index 0000000..8087f97 --- /dev/null +++ b/src/main/java/com/sqx/modules/helpCenter/controller/app/AppHelpWordController.java @@ -0,0 +1,48 @@ +package com.sqx.modules.helpCenter.controller.app; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.sqx.common.utils.Result; +import com.sqx.modules.helpCenter.entity.HelpClassify; +import com.sqx.modules.helpCenter.entity.HelpWord; +import com.sqx.modules.helpCenter.service.HelpClassifyService; +import com.sqx.modules.helpCenter.service.HelpWordService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@Api(value = "帮助中心", tags = {"帮助中心"}) +@RequestMapping(value = "/app/helpWord") +public class AppHelpWordController { + + + @Autowired + private HelpClassifyService helpClassifyService; + @Autowired + private HelpWordService helpWordService; + + @GetMapping("/selectHelpList") + @ApiOperation("查询帮助列表") + public Result selectHelpList(Integer types){ + List helpClassifyList = helpClassifyService.list(new QueryWrapper().eq(types!=null,"types",types).orderByAsc("sort")); + for(HelpClassify helpClassify:helpClassifyList){ + List helpWordList = helpWordService.list(new QueryWrapper().eq("help_classify_id", helpClassify.getHelpClassifyId()).orderByAsc("sort")); + helpClassify.setHelpWordList(helpWordList); + } + return Result.success().put("data",helpClassifyList); + } + + @GetMapping("/selectHelpWordDetails") + @ApiOperation("查询文档详情") + public Result selectHelpWordDetails(Long helpWordId){ + return Result.success().put("data",helpWordService.getById(helpWordId)); + } + + + +} diff --git a/src/main/java/com/sqx/modules/helpCenter/dao/HelpClassifyDao.java b/src/main/java/com/sqx/modules/helpCenter/dao/HelpClassifyDao.java new file mode 100644 index 0000000..1fbeac4 --- /dev/null +++ b/src/main/java/com/sqx/modules/helpCenter/dao/HelpClassifyDao.java @@ -0,0 +1,12 @@ +package com.sqx.modules.helpCenter.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.helpCenter.entity.HelpClassify; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface HelpClassifyDao extends BaseMapper { + + + +} diff --git a/src/main/java/com/sqx/modules/helpCenter/dao/HelpWordDao.java b/src/main/java/com/sqx/modules/helpCenter/dao/HelpWordDao.java new file mode 100644 index 0000000..5969b72 --- /dev/null +++ b/src/main/java/com/sqx/modules/helpCenter/dao/HelpWordDao.java @@ -0,0 +1,12 @@ +package com.sqx.modules.helpCenter.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.helpCenter.entity.HelpWord; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface HelpWordDao extends BaseMapper { + + + +} diff --git a/src/main/java/com/sqx/modules/helpCenter/entity/HelpClassify.java b/src/main/java/com/sqx/modules/helpCenter/entity/HelpClassify.java new file mode 100644 index 0000000..ad1e52f --- /dev/null +++ b/src/main/java/com/sqx/modules/helpCenter/entity/HelpClassify.java @@ -0,0 +1,60 @@ +package com.sqx.modules.helpCenter.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @description help_classify + * @author fang + * @date 2022-06-06 + */ +@Data +public class HelpClassify implements Serializable { + + private static final long serialVersionUID = 1L; + + + /** + * 帮助中心分类 + */ + @TableId(type = IdType.AUTO) + private Long helpClassifyId; + + /** + * 分类名称 + */ + private String helpClassifyName; + + /** + * 排序 + */ + private Integer sort; + + /** + * 上级id + */ + private Long parentId; + + /** + * 创建时间 + */ + private String createTime; + + /** + * 类型 + */ + private Integer types; + + @TableField(exist = false) + private List helpClassifyList; + + @TableField(exist = false) + private List helpWordList; + + public HelpClassify() {} +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/helpCenter/entity/HelpWord.java b/src/main/java/com/sqx/modules/helpCenter/entity/HelpWord.java new file mode 100644 index 0000000..2c27591 --- /dev/null +++ b/src/main/java/com/sqx/modules/helpCenter/entity/HelpWord.java @@ -0,0 +1,51 @@ +package com.sqx.modules.helpCenter.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description help_word + * @author fang + * @date 2022-06-06 + */ +@Data +public class HelpWord implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 帮助文档id + */ + private Long helpWordId; + + /** + * 帮助标题 + */ + private String helpWordTitle; + + /** + * 帮助分类 + */ + private Integer helpClassifyId; + + /** + * 帮助文档内容 + */ + private String helpWordContent; + + /** + * 排序 + */ + private Integer sort; + + /** + * 创建时间 + */ + private String createTime; + + public HelpWord() {} +} diff --git a/src/main/java/com/sqx/modules/helpCenter/service/HelpClassifyService.java b/src/main/java/com/sqx/modules/helpCenter/service/HelpClassifyService.java new file mode 100644 index 0000000..d68ee43 --- /dev/null +++ b/src/main/java/com/sqx/modules/helpCenter/service/HelpClassifyService.java @@ -0,0 +1,10 @@ +package com.sqx.modules.helpCenter.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.modules.helpCenter.entity.HelpClassify; + + +public interface HelpClassifyService extends IService { + + +} diff --git a/src/main/java/com/sqx/modules/helpCenter/service/HelpWordService.java b/src/main/java/com/sqx/modules/helpCenter/service/HelpWordService.java new file mode 100644 index 0000000..fd054ca --- /dev/null +++ b/src/main/java/com/sqx/modules/helpCenter/service/HelpWordService.java @@ -0,0 +1,11 @@ +package com.sqx.modules.helpCenter.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.modules.helpCenter.entity.HelpWord; + + +public interface HelpWordService extends IService { + + + +} diff --git a/src/main/java/com/sqx/modules/helpCenter/service/impl/HelpClassifyServiceImpl.java b/src/main/java/com/sqx/modules/helpCenter/service/impl/HelpClassifyServiceImpl.java new file mode 100644 index 0000000..559656e --- /dev/null +++ b/src/main/java/com/sqx/modules/helpCenter/service/impl/HelpClassifyServiceImpl.java @@ -0,0 +1,23 @@ +package com.sqx.modules.helpCenter.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.modules.helpCenter.dao.HelpClassifyDao; +import com.sqx.modules.helpCenter.entity.HelpClassify; +import com.sqx.modules.helpCenter.service.HelpClassifyService; +import org.springframework.stereotype.Service; + +@Service +public class HelpClassifyServiceImpl extends ServiceImpl implements HelpClassifyService { + + + + + +} + + + + + + + diff --git a/src/main/java/com/sqx/modules/helpCenter/service/impl/HelpWordServiceImpl.java b/src/main/java/com/sqx/modules/helpCenter/service/impl/HelpWordServiceImpl.java new file mode 100644 index 0000000..77ed575 --- /dev/null +++ b/src/main/java/com/sqx/modules/helpCenter/service/impl/HelpWordServiceImpl.java @@ -0,0 +1,23 @@ +package com.sqx.modules.helpCenter.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.modules.helpCenter.dao.HelpWordDao; +import com.sqx.modules.helpCenter.entity.HelpWord; +import com.sqx.modules.helpCenter.service.HelpWordService; +import org.springframework.stereotype.Service; + +@Service +public class HelpWordServiceImpl extends ServiceImpl implements HelpWordService { + + + + + +} + + + + + + + diff --git a/src/main/java/com/sqx/modules/invite/controller/InviteController.java b/src/main/java/com/sqx/modules/invite/controller/InviteController.java new file mode 100644 index 0000000..8553167 --- /dev/null +++ b/src/main/java/com/sqx/modules/invite/controller/InviteController.java @@ -0,0 +1,143 @@ +package com.sqx.modules.invite.controller; + + +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.invite.entity.InviteMoney; +import com.sqx.modules.invite.service.InviteMoneyService; +import com.sqx.modules.invite.service.InviteService; +import com.sqx.modules.utils.InvitationCodeUtil; +import com.sqx.modules.utils.SenInfoCheckUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.Map; + +/** + * @author fang + * @date 2020/7/9 + */ +@Slf4j +@RestController +@Api(value = "邀请收益", tags = {"邀请收益"}) +@RequestMapping(value = "/invite") +public class InviteController { + + @Autowired + private InviteService inviteService; + @Autowired + private UserService userService; + @Autowired + private InviteMoneyService inviteMoneyService; + @Autowired + private CommonInfoService commonInfoService; + + @RequestMapping(value = "/selectInviteCount", method = RequestMethod.GET) + @ApiOperation("查看我邀请的人员数量") + @ResponseBody + public Result selectInviteCount(Integer state,Long userId){ + return Result.success().put("data",inviteService.selectInviteCount(state,userId)); + } + + @RequestMapping(value = "/selectInviteAndPoster", method = RequestMethod.GET) + @ApiOperation("查看我的邀请码和海报二维码") + @ResponseBody + public Result selectInviteAndPoster(Long userId){ + UserEntity userEntity = userService.queryByUserId(userId); + CommonInfo one = commonInfoService.findOne(19); + Map map=new HashMap<>(); + map.put("url",one.getValue()); + map.put("user",userEntity); + return Result.success().put("data",map); + } + + @RequestMapping(value = "/selectInviteByUserIdList", method = RequestMethod.GET) + @ApiOperation("查看我邀请的人员列表(只查看邀请成功成为会员))") + @ResponseBody + public Result selectInviteByUserIdList(int page,int limit,Long userId){ + PageUtils pageUtils = inviteService.selectInviteUser(page, limit, userId,1); + InviteMoney inviteMoney = inviteMoneyService.selectInviteMoneyByUserId(userId); + Map map=new HashMap<>(); + map.put("pageUtils",pageUtils); + map.put("inviteMoney",inviteMoney); + return Result.success().put("data",map); + } + + @GetMapping("/mpCreateQr") + @ApiOperation("小程序推广二维码") + public void mpCreateQr(@RequestParam String relation, HttpServletResponse response) { + SenInfoCheckUtil.getPoster(relation,response); + } + + + + + /*@RequestMapping(value = "/selectZhiFeiMoney", method = RequestMethod.GET) + @ApiOperation("查询直属非直属邀请收益") + @ResponseBody + public Result selectZhiFeiMoney(Long userId){ + UserEntity userEntity = userService.queryByUserId(userId); + //查询直属邀请人数数量 + Integer zhiUserInviteCount = userService.selectZhiUserInviteCount(userEntity.getInvitationCode()); + //查询非直属邀请人数量 + Integer feiUserInviteCount = userService.selectFeiUserInviteCount(userEntity.getInvitationCode()); + Map map=new HashMap<>(); + map.put("zhiUserInviteCount",zhiUserInviteCount); + map.put("feiUserInviteCount",feiUserInviteCount); + return Result.success().put("data",map); + }*/ + + /*@RequestMapping(value = "/selectZhiInviteByUserIdList", method = RequestMethod.GET) + @ApiOperation("直属") + @ResponseBody + public Result selectZhiInviteByUserIdList(int page,int limit,Long userId){ + return userService.selectZhiInviteByUserIdList(page,limit,userId); + } + + @RequestMapping(value = "/selectFeiInviteByUserIdList", method = RequestMethod.GET) + @ApiOperation("非直属用户") + @ResponseBody + public Result selectFeiInviteByUserIdList(int page,int limit,Long userId){ + return userService.selectFeiInviteByUserIdList(page,limit,userId); + }*/ + + + @RequestMapping(value = "/selectInviteByUserIdLists", method = RequestMethod.GET) + @ApiOperation("查看我邀请的人员列表(查看所有邀请列表)") + @ResponseBody + public Result selectInviteByUserIdLists(int page,int limit,Long userId){ + PageUtils pageUtils = inviteService.selectInviteUser(page, limit, userId,null); + Map map=new HashMap<>(); + map.put("pageUtils",pageUtils); + return Result.success().put("data",map); + } + + @RequestMapping(value = "/insertInvitationCode", method = RequestMethod.POST) + @ApiOperation("填写邀请码") + @ResponseBody + public Result insertInvitationCode(Long userId,String invitationCode) + { + if(StringUtils.isBlank(invitationCode)){ + return Result.error("邀请码不能为空!"); + } + long inviteeUserId = InvitationCodeUtil.codeToId(invitationCode); + UserEntity userEntity = userService.queryByUserId(inviteeUserId); + if(userEntity==null){ + return Result.error("邀请码填写错误!"); + } + inviteService.saveBody(userId,userEntity); + return Result.success(); + } + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/invite/controller/app/AppInviteController.java b/src/main/java/com/sqx/modules/invite/controller/app/AppInviteController.java new file mode 100644 index 0000000..d3dade9 --- /dev/null +++ b/src/main/java/com/sqx/modules/invite/controller/app/AppInviteController.java @@ -0,0 +1,98 @@ +package com.sqx.modules.invite.controller.app; + + +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.invite.entity.InviteMoney; +import com.sqx.modules.invite.service.InviteMoneyService; +import com.sqx.modules.invite.service.InviteService; +import com.sqx.modules.utils.SenInfoCheckUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.Map; + +/** + * @author fang + * @date 2020/7/9 + */ +@Slf4j +@RestController +@Api(value = "邀请收益", tags = {"邀请收益"}) +@RequestMapping(value = "/app/invite") +public class AppInviteController { + + @Autowired + private InviteService inviteService; + @Autowired + private UserService userService; + @Autowired + private InviteMoneyService inviteMoneyService; + @Autowired + private CommonInfoService commonInfoService; + + @RequestMapping(value = "/selectInviteCount", method = RequestMethod.GET) + @ApiOperation("查看我邀请的人员数量") + @ResponseBody + public Result selectInviteCount(Integer state,Long userId){ + return Result.success().put("data",inviteService.selectInviteCount(state,userId)); + } + @Login + @RequestMapping(value = "/selectInviteAndPoster", method = RequestMethod.GET) + @ApiOperation("查看我的邀请码和海报二维码") + @ResponseBody + public Result selectInviteAndPoster(@RequestAttribute Long userId){ + UserEntity userEntity = userService.queryByUserId(userId); + CommonInfo one = commonInfoService.findOne(19); + Map map=new HashMap<>(); + map.put("url",one.getValue()); + map.put("user",userEntity); + return Result.success().put("data",map); + } + + @Login + @RequestMapping(value = "/selectInviteMoney", method = RequestMethod.GET) + @ApiOperation("我的收益") + @ResponseBody + public Result selectInviteMoney(@RequestAttribute("userId") Long userId){ + InviteMoney inviteMoney = inviteMoneyService.selectInviteMoneyByUserId(userId); + Integer inviteCount = inviteService.selectInviteCount(-1, userId); + Map result=new HashMap<>(); + result.put("inviteMoney",inviteMoney); + result.put("inviteCount",inviteCount); + return Result.success().put("data",result); + } + + @GetMapping("/mpCreateQr") + @ApiOperation("小程序推广二维码") + public void mpCreateQr(@RequestParam String invitationCode, HttpServletResponse response) { + SenInfoCheckUtil.getPoster(invitationCode,response); + } + + @GetMapping("/jiMpCreateQr") + @ApiOperation("小程序推广二维码") + public void jiMpCreateQr(@RequestParam String invitationCode, HttpServletResponse response) { + SenInfoCheckUtil.jiMpCreateQr(invitationCode,response); + } + + + @Login + @RequestMapping(value = "/selectInviteByUserIdLists", method = RequestMethod.GET) + @ApiOperation("查看我邀请的人员列表(查看所有邀请列表)") + @ResponseBody + public Result selectInviteByUserIdLists(int page,int limit,@RequestAttribute("userId") Long userId){ + PageUtils pageUtils = inviteService.selectInviteUser(page, limit, userId,null); + return Result.success().put("data",pageUtils); + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/invite/dao/InviteDao.java b/src/main/java/com/sqx/modules/invite/dao/InviteDao.java new file mode 100644 index 0000000..ba1a321 --- /dev/null +++ b/src/main/java/com/sqx/modules/invite/dao/InviteDao.java @@ -0,0 +1,41 @@ +package com.sqx.modules.invite.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.invite.entity.Invite; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.Map; + +/** + * @author fang + * @date 2020/7/9 + */ +@Mapper +public interface InviteDao extends BaseMapper { + + IPage selectInviteList(Page> page, @Param("state") Integer state, @Param("userId") Long userId); + + Integer selectInviteCount(@Param("state") Integer state, @Param("userId") Long userId); + + Double selectInviteSum(@Param("state") Integer state, @Param("userId") Long userId); + + IPage> selectInviteUser(Page> page, @Param("userId") Long userId,@Param("state") Integer state); + + Invite selectInviteByUser(@Param("userId")Long userId,@Param("inviteeUserId") Long inviteeUserId); + + Integer selectInviteByUserIdCountNotTime(@Param("userId")Long userId); + + Integer selectInviteByUserIdCount(@Param("userId") Long userId, @Param("startTime")Date startTime,@Param("endTime")Date endTime); + + Double selectInviteByUserIdSum(@Param("userId") Long userId, @Param("startTime")Date startTime,@Param("endTime")Date endTime); + + Double sumInviteMoney(@Param("time")String time,@Param("flag")Integer flag); + + IPage> inviteAnalysis(Page> page,@Param("time")String time,@Param("flag")Integer flag); + + +} diff --git a/src/main/java/com/sqx/modules/invite/dao/InviteMoneyDao.java b/src/main/java/com/sqx/modules/invite/dao/InviteMoneyDao.java new file mode 100644 index 0000000..99ad3bb --- /dev/null +++ b/src/main/java/com/sqx/modules/invite/dao/InviteMoneyDao.java @@ -0,0 +1,23 @@ +package com.sqx.modules.invite.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.invite.entity.InviteMoney; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 邀请收益钱包 + * + */ +@Mapper +public interface InviteMoneyDao extends BaseMapper { + + + InviteMoney selectInviteMoneyByUserId(Long userId); + + int updateInviteMoneySum(@Param("money") Double money,@Param("userId") Long userId); + + int updateInviteMoneyCashOut(@Param("type") Integer type,@Param("money") Double money,@Param("userId") Long userId); + + +} diff --git a/src/main/java/com/sqx/modules/invite/entity/Invite.java b/src/main/java/com/sqx/modules/invite/entity/Invite.java new file mode 100644 index 0000000..956ffe7 --- /dev/null +++ b/src/main/java/com/sqx/modules/invite/entity/Invite.java @@ -0,0 +1,50 @@ +package com.sqx.modules.invite.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author fang + * @date 2020/7/9 + */ +@Data +@TableName("invite") +public class Invite implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 邀请id + */ + @TableId(type = IdType.INPUT) + private Long id; + + /** + * 邀请人id + */ + private Long userId; + + /** + * 被邀请人id + */ + private Long inviteeUserId; + + /** + * 状态 0非会员 1会员 + */ + private Integer state; + + /** + * 收益 + */ + private Double money; + + /** + * 创建时间 + */ + private String createTime; + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/invite/entity/InviteMoney.java b/src/main/java/com/sqx/modules/invite/entity/InviteMoney.java new file mode 100644 index 0000000..34b5a7b --- /dev/null +++ b/src/main/java/com/sqx/modules/invite/entity/InviteMoney.java @@ -0,0 +1,44 @@ +package com.sqx.modules.invite.entity; + +import lombok.Data; + +import java.io.Serializable; + +/** + * invite_money + * @author fang 2020-07-28 + */ +@Data +public class InviteMoney implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 邀请收益钱包id + */ + private Long id; + + /** + * 用户id + */ + private Long userId; + + /** + * 总获取收益 + */ + private Double moneySum; + + /** + * 当前金额 + */ + private Double money; + + /** + * 累计提现 + */ + private Double cashOut; + + public InviteMoney() { + } + +} diff --git a/src/main/java/com/sqx/modules/invite/service/InviteMoneyService.java b/src/main/java/com/sqx/modules/invite/service/InviteMoneyService.java new file mode 100644 index 0000000..7e66944 --- /dev/null +++ b/src/main/java/com/sqx/modules/invite/service/InviteMoneyService.java @@ -0,0 +1,20 @@ +package com.sqx.modules.invite.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.modules.invite.entity.InviteMoney; + +/** + * 邀请收益 + * + */ +public interface InviteMoneyService extends IService { + + InviteMoney selectInviteMoneyByUserId(Long userId); + + int updateInviteMoneySum(Double money,Long userId); + + int updateInviteMoneyCashOut(Double money,Long userId); + + +} diff --git a/src/main/java/com/sqx/modules/invite/service/InviteService.java b/src/main/java/com/sqx/modules/invite/service/InviteService.java new file mode 100644 index 0000000..76e948f --- /dev/null +++ b/src/main/java/com/sqx/modules/invite/service/InviteService.java @@ -0,0 +1,33 @@ +package com.sqx.modules.invite.service; + + +import com.sqx.common.utils.PageUtils; +import com.sqx.modules.app.entity.UserEntity; + +import java.util.Date; + +public interface InviteService { + + PageUtils selectInviteList(int page, int limit, Integer state, Long userId); + + Integer selectInviteCount(Integer state,Long userId); + + Double selectInviteSum(Integer state,Long userId); + + int saveBody(Long userId, UserEntity userEntity); + + PageUtils selectInviteUser(int page,int limit,Long userId,Integer state); + + Integer selectInviteByUserIdCountNotTime(Long userId); + + Integer selectInviteByUserIdCount(Long userId, Date startTime, Date endTime); + + Double selectInviteByUserIdSum(Long userId, Date startTime,Date endTime); + + Double sumInviteMoney(String time,Integer flag); + + PageUtils inviteAnalysis(int page,int limit, String time, Integer flag); + + void updateInvite(UserEntity userEntity,String format,Long userId); + +} diff --git a/src/main/java/com/sqx/modules/invite/service/impl/InviteMoneyServiceImpl.java b/src/main/java/com/sqx/modules/invite/service/impl/InviteMoneyServiceImpl.java new file mode 100644 index 0000000..237a3da --- /dev/null +++ b/src/main/java/com/sqx/modules/invite/service/impl/InviteMoneyServiceImpl.java @@ -0,0 +1,42 @@ +package com.sqx.modules.invite.service.impl; + + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.modules.invite.dao.InviteMoneyDao; +import com.sqx.modules.invite.entity.InviteMoney; +import com.sqx.modules.invite.service.InviteMoneyService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +@Service("InviteMoneyService") +public class InviteMoneyServiceImpl extends ServiceImpl implements InviteMoneyService { + + @Autowired + private InviteMoneyDao inviteMoneyDao; + + + @Override + public InviteMoney selectInviteMoneyByUserId(Long userId) { + InviteMoney inviteMoney = inviteMoneyDao.selectInviteMoneyByUserId(userId); + if(inviteMoney==null){ + inviteMoney=new InviteMoney(); + inviteMoney.setCashOut(0.00); + inviteMoney.setUserId(userId); + inviteMoney.setMoney(0.00); + inviteMoney.setMoneySum(0.00); + inviteMoneyDao.insert(inviteMoney); + } + return inviteMoney; + } + + @Override + public int updateInviteMoneySum(Double money, Long userId) { + return inviteMoneyDao.updateInviteMoneySum(money,userId); + } + + @Override + public int updateInviteMoneyCashOut(Double money, Long userId) { + return inviteMoneyDao.updateInviteMoneySum(money,userId); + } +} diff --git a/src/main/java/com/sqx/modules/invite/service/impl/InviteServiceImpl.java b/src/main/java/com/sqx/modules/invite/service/impl/InviteServiceImpl.java new file mode 100644 index 0000000..f8c13af --- /dev/null +++ b/src/main/java/com/sqx/modules/invite/service/impl/InviteServiceImpl.java @@ -0,0 +1,196 @@ +package com.sqx.modules.invite.service.impl; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.entity.UserMoneyDetails; +import com.sqx.modules.app.service.UserMoneyDetailsService; +import com.sqx.modules.app.service.UserMoneyService; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.invite.dao.InviteDao; +import com.sqx.modules.invite.entity.Invite; +import com.sqx.modules.invite.service.InviteMoneyService; +import com.sqx.modules.invite.service.InviteService; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.service.MessageService; +import com.sqx.modules.utils.AmountCalUtils; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; +import java.util.Random; + +/** + * 邀请记录 + */ +@Service +public class InviteServiceImpl extends ServiceImpl implements InviteService { + + + @Autowired + private InviteDao inviteDao; + @Autowired + private UserService userService; + @Autowired + private CommonInfoService commonInfoService; + @Autowired + private InviteMoneyService inviteMoneyService; + @Autowired + private UserMoneyService userMoneyService; + @Autowired + private UserMoneyDetailsService userMoneyDetailsService; + @Autowired + private MessageService messageService; + + @Override + public PageUtils selectInviteList(int page,int limit,Integer state,Long userId){ + Page> pages=new Page<>(page,limit); + if(state==null || state==-1){ + state=null; + } + return new PageUtils(inviteDao.selectInviteList(pages,state,userId)); + } + + + @Override + public PageUtils selectInviteUser(int page,int limit,Long userId,Integer state){ + Page> pages=new Page<>(page,limit); + return new PageUtils(inviteDao.selectInviteUser(pages,userId,state)); + } + + @Override + public Integer selectInviteByUserIdCountNotTime(Long userId) { + return inviteDao.selectInviteByUserIdCountNotTime(userId); + } + + @Override + public Integer selectInviteByUserIdCount(Long userId, Date startTime, Date endTime) { + return inviteDao.selectInviteByUserIdCount(userId,startTime,endTime); + } + + @Override + public Double selectInviteByUserIdSum(Long userId, Date startTime, Date endTime) { + return inviteDao.selectInviteByUserIdSum(userId,startTime,endTime); + } + + @Override + public Double sumInviteMoney(String time, Integer flag) { + return inviteDao.sumInviteMoney(time,flag); + } + + @Override + public PageUtils inviteAnalysis(int page,int limit, String time, Integer flag) { + Page> pages=new Page<>(page,limit); + return new PageUtils(inviteDao.inviteAnalysis(pages,time,flag)); + } + + @Override + public Integer selectInviteCount(Integer state,Long userId){ + if(state==null || state==-1){ + state=null; + } + return inviteDao.selectInviteCount(state,userId); + } + + @Override + public Double selectInviteSum(Integer state, Long userId) { + if(state==null || state==-1){ + state=null; + } + return inviteDao.selectInviteSum(state,userId); + } + + + @Transactional + @Override + public int saveBody(Long userId, UserEntity userEntity){ + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String format = sdf.format(new Date()); + Invite invite=new Invite(); + invite.setState(0); + invite.setMoney(0.00); + invite.setUserId(userEntity.getUserId()); + invite.setInviteeUserId(userId); + invite.setCreateTime(format); + inviteDao.insert(invite); + //给被邀请者增加上级id + UserEntity user=new UserEntity(); + user.setUserId(userId); + user.setInviterCode(userEntity.getInvitationCode()); + userService.updateById(user); + updateInvite(userEntity,format,userId); + return 1; + } + + + @Override + public void updateInvite(UserEntity userEntity,String format,Long userId){ + Invite invite1 = inviteDao.selectInviteByUser(userEntity.getUserId(), userId); + if(invite1==null){ + Invite invite=new Invite(); + invite.setState(0); + invite.setMoney(0.00); + invite.setUserId(userEntity.getUserId()); + invite.setInviteeUserId(userId); + invite.setCreateTime(format); + inviteDao.insert(invite); + invite1 = inviteDao.selectInviteByUser(userEntity.getUserId(), userId); + } + if(invite1.getState()==0){ + CommonInfo one = commonInfoService.findOne(189); + if(one!=null && StringUtils.isNotEmpty(one.getValue()) && Integer.parseInt(one.getValue())>0){ + Double money=Double.parseDouble(one.getValue()); + invite1.setState(1); + invite1.setMoney(money); + inviteDao.updateById(invite1); + inviteMoneyService.updateInviteMoneySum(money,userEntity.getUserId()); + userMoneyService.updateMoney(1,userEntity.getUserId(),money); + + UserMoneyDetails userMoneyDetails=new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(userEntity.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setUserId(userEntity.getUserId()); + UserEntity userEntity1 = userService.selectUserById(userId); + userMoneyDetails.setTitle("[邀请好友]好友名称:"+userEntity1.getUserName()); + userMoneyDetails.setContent("增加金额:"+money); + userMoneyDetails.setType(1); + userMoneyDetails.setMoney(new BigDecimal(money)); + userMoneyDetails.setCreateTime(format); + userMoneyDetailsService.save(userMoneyDetails); + MessageInfo messageInfo = new MessageInfo(); + messageInfo.setContent("恭喜您,邀请的好友注册成功了,赠送您:"+money+""); + messageInfo.setTitle("邀请赏金"); + messageInfo.setState(String.valueOf(5)); + messageInfo.setUserName(userEntity.getUserName()); + messageInfo.setUserId(String.valueOf(userEntity.getUserId())); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + messageInfo.setCreateAt(sdf.format(new Date())); + messageInfo.setIsSee("0"); + messageService.saveBody(messageInfo); + if(StringUtils.isNotEmpty(userEntity.getClientid())){ + userService.pushToSingle("邀请赏金","恭喜您,邀请的好友注册成功了,赠送您:"+money,userEntity.getClientid()); + } + + + + } + } + } + + +} diff --git a/src/main/java/com/sqx/modules/map/MapWebSocket.java b/src/main/java/com/sqx/modules/map/MapWebSocket.java new file mode 100644 index 0000000..9d96e86 --- /dev/null +++ b/src/main/java/com/sqx/modules/map/MapWebSocket.java @@ -0,0 +1,203 @@ +package com.sqx.modules.map; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.common.collect.Maps; +import com.sqx.common.utils.RedisUtils; +import com.sqx.common.utils.SpringContextUtils; +import com.sqx.ws.BaseInfoModel; +import com.sqx.ws.BaseModelEncoder; +import com.sqx.ws.HashMapEncoder; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import javax.websocket.*; +import javax.websocket.server.PathParam; +import javax.websocket.server.ServerEndpoint; +import java.io.IOException; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +/** + * WebSocket聊天实现 + */ +@Component +@Scope("prototype") +@ServerEndpoint(value = "/mapWebsocket/{businessId}", encoders = { HashMapEncoder.class, BaseModelEncoder.class }) +public class MapWebSocket { + private static final Logger log = LoggerFactory.getLogger(MapWebSocket.class); + + //通过类似GET请求方式传递参数的方法(服务端采用第二种方法"WebSocketHandler"实现) + //websocket = new WebSocket("ws://127.0.0.1:18080/testWebsocket?id=23&name=Lebron"); + /** + * 在线人数 + */ + public static int onlineNumber = 0; + /** + * 以用户的id为key,WebSocket为对象保存起来 + */ + private static final Map clients = new ConcurrentHashMap<>(); + /** + * 会话 + */ + private Session session; + /** + * 用户id + */ + private String businessId; + + //此处不需要 +// //这里使用静态,让 service 属于类 +// private static ChatsContentService chatContentService; +// +// //注入的时候,给类的 service 注入 +// @Autowired +// public void setWxChatContentService(ChatsContentService chatContentService) { +// MapWebSocket.chatContentService = chatContentService; +// } + + private static RedisUtils redisUtils = SpringContextUtils.getBean(RedisUtils.class); + + @Autowired + public void setRedisUtils(RedisUtils redisUtils) { + MapWebSocket.redisUtils = redisUtils; + } + + + + + /** + * 建立连接 + * + * @param session + */ + @OnOpen + public void onOpen(@PathParam("businessId") String businessId, Session session) { + onlineNumber++; + log.info("客户端连接Id: {}", businessId); + this.businessId = businessId; + this.session = session; + log.info("有新连接加入! 当前在线设备: {}", onlineNumber); + try { + //把自己的信息加入到map当中去 + clients.remove(businessId); + clients.put(businessId, this); + /*sendMessageTo("恭喜你连接成功!",wxUserId);*/ + } catch (Exception e) { + log.info("{} 连接发生了错误", businessId); + } + } + + @OnError + public void onError(Session session, Throwable error) { + log.info("服务端发生了错误: {}", error.getMessage()); + } + + /** + * 连接关闭 + */ + @OnClose + public void onClose() { + onlineNumber--; + //webSockets.remove(this); + clients.remove(businessId); + log.info("有连接关闭! 当前在线设备: {}", onlineNumber); + } + + /** + * 接收客户端的消息,并把消息发送给所有连接的会话 + */ + @OnMessage + public void onMessage(String message) { + try { + log.info("客户端发来的消息:{}", message); + //解析聊天内容 + JSONObject jsonObject = JSON.parseObject(message); + String sendType = jsonObject.getString("sendType"); + String userId = jsonObject.getString("userId"); + String businessId = jsonObject.getString("businessId"); + String[] businessIds = StringUtils.split(businessId,","); + switch (sendType){ + case "coordinate": { + //开始记录坐标值 + String coordinate = jsonObject.getString("coordinate"); + //往redis里存入坐标 + //map:location:businessId:userId + for (String $businessId: businessIds){ + //带,拆分 + //redisUtils.set("map:location:" + $businessId +":" + userId, coordinate,-1);//60秒 + redisUtils.set("map:location:" + $businessId +":" + userId, coordinate,60);//60秒 + } + sendMessageObject(session,BaseInfoModel.success("coordinate","收到回执坐标信息是:" + coordinate + " businessId: " + businessId));//回执,告知已记录 + break; + } + case "clearCoordinate": { + //结束动作,清空坐标 + for (String $businessId: businessIds){ + //带,拆分 + redisUtils.delete("map:location:" + $businessId +":" + userId); + } + + sendMessageObject(session,BaseInfoModel.success("clearCoordinate","ok"));//回执,告知已记录 + break; + } + case "getCoordinate": { + //获取坐标 + String rkey = jsonObject.getString("rkey"); + log.info(rkey); +// String v = redisUtils.get(rkey); + Set keys = redisUtils.keys(rkey); + Map rmap = Maps.newHashMap(); + for(String k: keys){ + String v = redisUtils.get(k); + log.info(v); + String[] ks = StringUtils.split(k,":"); + rmap.put(ks[ks.length-1],v);//返回用户ID-坐标的map + } + sendMessageObject(session,BaseInfoModel.success("getCoordinate",rmap));//回执,告知已记录 + break; + } + default: { + log.info("默认无处理的客户端发来的坐标消息:{}", message); + } + } + } catch (Exception e) { + log.info("发生了错误了",e); + } + } + + /** + * 发送消息,实践表明,每次浏览器刷新,session会发生变化。 + * @param session + * @param message + */ + public static void sendMessage(Session session, String message) throws IOException { + try { +// session.getBasicRemote().sendText(String.format("%s (From Server,Session ID=%s)",message,session.getId())); + session.getBasicRemote().sendText(message); + } catch (IOException e) { + log.error("发送消息出错:{}", e.getMessage()); + log.error(e.getMessage(),e); + } + } + + public static void sendMessageObject(Session session, Object message) throws IOException { + try { + session.getBasicRemote().sendObject(message); + } catch (IOException | EncodeException e) { + log.error("发送消息出错!"); + log.error(e.getMessage(),e); + } + } + + + public static synchronized int getOnlineCount() { + return onlineNumber; + } + +} diff --git a/src/main/java/com/sqx/modules/material/controller/MaterialController.java b/src/main/java/com/sqx/modules/material/controller/MaterialController.java new file mode 100644 index 0000000..48b0be9 --- /dev/null +++ b/src/main/java/com/sqx/modules/material/controller/MaterialController.java @@ -0,0 +1,138 @@ +package com.sqx.modules.material.controller; + +import java.util.List; + +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.entity.Period; +import com.sqx.modules.material.entity.Material; +import com.sqx.modules.material.entity.MaterialArtificer; +import com.sqx.modules.material.entity.MaterialMassage; +import com.sqx.modules.material.service.MaterialArtificerService; +import com.sqx.modules.material.service.MaterialMassageService; +import com.sqx.modules.material.service.MaterialService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +@RestController +@Api(value = "物料包", tags = {"物料包"}) +@RequestMapping(value = "/material") +public class MaterialController { + + @Autowired + private MaterialService materialService; + @Autowired + private MaterialArtificerService materialArtificerService; + @Autowired + private MaterialMassageService materialMassageService; + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + @GetMapping("materialList") + @ApiOperation("查询物料包列表(无分页)") + public Result materialList(Material material) { + return materialService.materialList(material); + } + @GetMapping("list") + @ApiOperation("查询列表(带分页)") + public Result listAll(Integer page, Integer limit, Material material) { + return materialService.selectPage(page,limit, material); + } + /** + * 查询技师关联物料包数据 + * + * @return 返回集合,没有返回空List + */ + @GetMapping("selectMaterialArtificer") + @ApiOperation("查询技师关联物料包数据") + public Result selectMaterialArtificer(Integer page, Integer limit, MaterialArtificer materialArtificer) { + return materialService.selectMaterialArtificer(page,limit, materialArtificer); + } + @GetMapping("selectMaterialMassage") + @ApiOperation("查询服务关联物料包数据") + public Result selectMaterialMassage(Integer page, Integer limit, MaterialMassage materialMassage) { + return materialService.selectMaterialMassage(page,limit, materialMassage); + } + @PostMapping("materialArtificerInsert") + @ApiOperation("新增技师关联物料包数据") + public Result materialArtificerInsert(MaterialArtificer materialArtificer) { + return materialArtificerService.insertMaterialArtificer(materialArtificer); + } + @PostMapping("materialArtificerUpdata") + @ApiOperation("修改技师关联物料包数据") + public Result materialArtificerUpdata(MaterialArtificer materialArtificer) { + return materialArtificerService.materialArtificerUpdata(materialArtificer); + } + @PostMapping("materialArtificerDelete") + @ApiOperation("删除技师关联物料包数据") + public Result materialArtificerDelete(MaterialArtificer materialArtificer) { + return materialArtificerService.materialArtificerDelete(materialArtificer); + } + @PostMapping("materialMassageInsert") + @ApiOperation("新增服务关联物料包数据") + public Result materialMassageInsert(@RequestBody MaterialMassage materialMassage ) { + return materialMassageService.insert(materialMassage); + } + @PostMapping("materialMassageDelete") + @ApiOperation("删除服务关联物料包数据") + public Result materialMassageDelete( MaterialMassage materialMassage) { + return materialMassageService.materialMassageDelete(materialMassage); + } + @PostMapping("materialMassageUpdata") + @ApiOperation("修改服务关联物料包数据") + public Result materialMassageUpdata(@RequestBody MaterialMassage materialMassage) { + return materialMassageService.materialMassageUpdata(materialMassage); + } + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + @GetMapping("getById") + @ApiOperation("根据主键查询物料包") + public Result getById(Integer id) { + return Result.success().put("data", materialService.getById(id)) ; + } + + /** + * 新增,忽略null字段 + * + * @param material 新增的记录 + * @return 返回影响行数 + */ + @PostMapping("insert") + @ApiOperation("新增物料包,忽略null字段") + public Result insert(Material material) { + return materialService.insertIgnoreNull(material) ; + } + + /** + * 修改,忽略null字段 + * + * @param material 修改的记录 + * @return 返回影响行数 + */ + @PostMapping("update") + @ApiOperation("修改物料包") + public Result update(Material material) { + return materialService.updateIgnoreNull(material) ; + } + + /**xaX + * 删除记录 + * + * @param material 待删除的记录 + * @return 返回影响行数 + */ + @PostMapping("delete") + @ApiOperation("删除物料包记录(伪删除)") + public Result delete(Material material) { + return materialService.delete(material); + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/material/controller/MaterialRecordController.java b/src/main/java/com/sqx/modules/material/controller/MaterialRecordController.java new file mode 100644 index 0000000..534ee2c --- /dev/null +++ b/src/main/java/com/sqx/modules/material/controller/MaterialRecordController.java @@ -0,0 +1,44 @@ +package com.sqx.modules.material.controller; + +import com.sqx.common.utils.Result; +import com.sqx.modules.material.entity.Material; +import com.sqx.modules.material.entity.MaterialArtificer; +import com.sqx.modules.material.entity.MaterialMassage; +import com.sqx.modules.material.entity.MaterialRecord; +import com.sqx.modules.material.service.MaterialArtificerService; +import com.sqx.modules.material.service.MaterialMassageService; +import com.sqx.modules.material.service.MaterialRecordService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +@RestController +@Api(value = "物料包历史记录", tags = {"物料包"}) +@RequestMapping(value = "/materialRecord") +public class MaterialRecordController { + + @Autowired + private MaterialRecordService materialRecordService; + /** + * 查询物料包历史记录 + * + * @return 返回集合,没有返回空List + */ + @GetMapping("list") + @ApiOperation("查询物料包历史记录") + public Result listAll(Integer page, Integer limit, MaterialRecord materialRecord) { + return materialRecordService.selectPage(page,limit, materialRecord); + } + /** + * 历史记录新增 + * + * @return 成功返回1失败打返回error + */ + @GetMapping("addMaterialRecord") + @ApiOperation("历史记录新增") + public Result addMaterialRecord(MaterialRecord materialRecord) { + return materialRecordService.addMaterialRecord(materialRecord); + } +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/material/controller/app/AppMaterialController.java b/src/main/java/com/sqx/modules/material/controller/app/AppMaterialController.java new file mode 100644 index 0000000..35d867b --- /dev/null +++ b/src/main/java/com/sqx/modules/material/controller/app/AppMaterialController.java @@ -0,0 +1,30 @@ +package com.sqx.modules.material.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.material.entity.MaterialArtificer; +import com.sqx.modules.material.service.MaterialArtificerService; +import com.sqx.modules.material.service.MaterialMassageService; +import com.sqx.modules.material.service.MaterialService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +@RestController +@Api(value = "物料包", tags = {"物料包"}) +@RequestMapping(value = "/app/material") +public class AppMaterialController { + + @Autowired + private MaterialService materialService; + @Autowired + private MaterialArtificerService materialArtificerService; + @Autowired + private MaterialMassageService materialMassageService; + @GetMapping("/selectMaterialArtificer") + @ApiOperation("app查询技师关联物料包数据") + public Result selectMaterialArtificer(Integer page, Integer limit, MaterialArtificer materialArtificer) { + return materialService.selectMaterialArtificer(page,limit, materialArtificer); + } +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/material/dao/MaterialArtificerMapper.java b/src/main/java/com/sqx/modules/material/dao/MaterialArtificerMapper.java new file mode 100644 index 0000000..be772b4 --- /dev/null +++ b/src/main/java/com/sqx/modules/material/dao/MaterialArtificerMapper.java @@ -0,0 +1,20 @@ +package com.sqx.modules.material.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.material.entity.MaterialArtificer; +import org.apache.ibatis.annotations.Mapper; + +/** +* @author Administrator +* @description 针对表【material_artificer(物料包与技师中间表)】的数据库操作Mapper +* @createDate 2024-02-27 15:30:46 +* @Entity generator.dao.MaterialArtificer +*/ +@Mapper +public interface MaterialArtificerMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/sqx/modules/material/dao/MaterialMapper.java b/src/main/java/com/sqx/modules/material/dao/MaterialMapper.java new file mode 100644 index 0000000..6a7f533 --- /dev/null +++ b/src/main/java/com/sqx/modules/material/dao/MaterialMapper.java @@ -0,0 +1,77 @@ +package com.sqx.modules.material.dao; + +import java.util.List; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.sqx.modules.material.entity.*; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +@Mapper +public interface MaterialMapper extends BaseMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + Material getById(Integer id); + + /** + * 新增,插入所有字段 + * + * @param material 新增的记录 + * @return 返回影响行数 + */ + int insert(Material material); + + /** + * 新增,忽略null字段 + * + * @param material 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(Material material); + + /** + * 修改,修改所有字段 + * + * @param material 修改的记录 + * @return 返回影响行数 + */ + int update(Material material); + + /** + * 修改,忽略null字段 + * + * @param material 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(Material material); + + /** + * 删除记录 + * + * @param material 待删除的记录 + * @return 返回影响行数 + */ + int delete(Material material); + + IPage selectMaterialArtificer(IPage page1, @Param("materialArtificer")MaterialArtificer materialArtificer); + List selectMaterialArtificerList( @Param("materialArtificer")MaterialArtificer materialArtificer); + + IPage selectMaterialMassage(IPage page1, @Param("materialMassage") MaterialMassage materialMassage); + + IPage selectPages(IPage page1, @Param("material")Material material); +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/material/dao/MaterialMassageMapper.java b/src/main/java/com/sqx/modules/material/dao/MaterialMassageMapper.java new file mode 100644 index 0000000..5d9e4d9 --- /dev/null +++ b/src/main/java/com/sqx/modules/material/dao/MaterialMassageMapper.java @@ -0,0 +1,20 @@ +package com.sqx.modules.material.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.material.entity.MaterialMassage; +import org.apache.ibatis.annotations.Mapper; + +/** +* @author Administrator +* @description 针对表【material_massage(物料包与服务表中间表)】的数据库操作Mapper +* @createDate 2024-02-27 15:29:44 +* @Entity generator.dao.MaterialMassage +*/ +@Mapper +public interface MaterialMassageMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/sqx/modules/material/dao/MaterialRecordMapper.java b/src/main/java/com/sqx/modules/material/dao/MaterialRecordMapper.java new file mode 100644 index 0000000..67483d4 --- /dev/null +++ b/src/main/java/com/sqx/modules/material/dao/MaterialRecordMapper.java @@ -0,0 +1,25 @@ +package com.sqx.modules.material.dao; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.sqx.modules.material.entity.MaterialRecord; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** +* @author Administrator +* @description 针对表【material_record(物料包历史记录表)】的数据库操作Mapper +* @createDate 2024-02-27 14:34:21 +* @Entity generator.domain.MaterialRecord +*/ +@Mapper +public interface MaterialRecordMapper extends BaseMapper { + + + IPage selectMaterialRecordList(IPage page1,@Param("materialRecord") MaterialRecord materialRecord); +} + + + + diff --git a/src/main/java/com/sqx/modules/material/entity/Material.java b/src/main/java/com/sqx/modules/material/entity/Material.java new file mode 100644 index 0000000..c108f67 --- /dev/null +++ b/src/main/java/com/sqx/modules/material/entity/Material.java @@ -0,0 +1,74 @@ +package com.sqx.modules.material.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 物料包表 + */ +@Data +public class Material implements Serializable { + private String id; + /** 物料包名称 */ + private String materialName; + /** 物料包最低数量 */ + private BigDecimal materialMinimum; + /** 物料包类别(1,中医类2,精油类) */ + private Integer status; + /** 备注 */ + private String detail; + /** 假删字段 */ + private Integer isDeleted; + /** 商品id */ + private Integer goodsId; + /** 创建者ID */ + private Long createUser; + /** 创建时间 */ + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date createTime; + /** 创建者ID */ + private Long updateUser; + /** 创建时间 */ + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date updateTime; + //商品名称 + @TableField(exist = false) + private String goodsName; + + + @Override + public boolean equals(Object o) { + if (this == o) { return true; } + if (o == null || getClass() != o.getClass()) {return false;} + Material that = (Material) o; + return id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash(id); + } + + @Override + public String toString() { + return "Material{" + + "id=" + id + + ",materialName='" + materialName + "'" + + ",materialMinimum='" + materialMinimum + "'" + + ",status='" + status + "'" + + ",createUser='" + createUser + "'" + + ",createTime='" + createTime + "'" + + ",updateUser='" + updateUser + "'" + + ",updateTime='" + updateTime + "'" + + '}'; + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/material/entity/MaterialArtificer.java b/src/main/java/com/sqx/modules/material/entity/MaterialArtificer.java new file mode 100644 index 0000000..2642d6c --- /dev/null +++ b/src/main/java/com/sqx/modules/material/entity/MaterialArtificer.java @@ -0,0 +1,82 @@ +package com.sqx.modules.material.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 物料包与技师中间表 + * @TableName material_artificer + */ +@TableName(value ="material_artificer") +@Data +public class MaterialArtificer implements Serializable { + /** + * + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + /** + * 技师id + */ + @TableField(value = "artificer_id") + private Integer artificerId; + + /** + * 物料包id + */ + @TableField(value = "material_id") + private Integer materialId; + + /** 物料包类别(1,中医类2,精油类) */ + @TableField(exist = false) + private Integer status; + /** 物料包名称 */ + @TableField(exist = false) + private String materialName; + /** 修改类型 1.新增 2减少 */ + @TableField(exist = false) + private Integer type; + /** 修改余额 */ + @TableField(exist = false) + private BigDecimal balance; + /** + * 剩余数量 + */ + @TableField(value = "residue") + private BigDecimal residue; + + /** + * 创建者ID + */ + @TableField(value = "create_user") + private Long createUser; + + /** + * 创建时间 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 修改者ID + */ + @TableField(value = "update_user") + private Long updateUser; + + /** + * 修改时间 + */ + @TableField(value = "update_time") + private Date updateTime; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/material/entity/MaterialArtificerResult.java b/src/main/java/com/sqx/modules/material/entity/MaterialArtificerResult.java new file mode 100644 index 0000000..182405b --- /dev/null +++ b/src/main/java/com/sqx/modules/material/entity/MaterialArtificerResult.java @@ -0,0 +1,42 @@ +package com.sqx.modules.material.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 物料包与技师中间表 + * @TableName material_artificer + */ +@Data +public class MaterialArtificerResult implements Serializable { + /** + * + */ + private Integer id; + + /** + * 技师id + */ + private Integer artificerId; + + /** 物料包名称 */ + private String materialName; + /** 物料包最低数量 */ + private String materialMinimum; + /** + * 物料包id + */ + private Integer materialId; + /** + * 剩余数量 + */ + private BigDecimal residue; + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/material/entity/MaterialMassage.java b/src/main/java/com/sqx/modules/material/entity/MaterialMassage.java new file mode 100644 index 0000000..379633a --- /dev/null +++ b/src/main/java/com/sqx/modules/material/entity/MaterialMassage.java @@ -0,0 +1,77 @@ +package com.sqx.modules.material.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 物料包与服务表中间表 + * @TableName material_massage + */ +@TableName(value ="material_massage") +@Data +public class MaterialMassage implements Serializable { + /** + * + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + /** + * 物料包id + */ + @TableField(value = "material_id") + private Integer materialId; + + /** + * 服务表id + */ + @TableField(value = "massage_type_id") + private Integer massageTypeId; + + /** 物料包类别(1,中医类2,精油类) */ + @TableField(exist = false) + private Integer status; + + /** 物料包名称 */ + @TableField(exist = false) + private String materialName; + /** + * 消耗 + */ + @TableField(value = "consume") + private BigDecimal consume; + + /** + * 创建者ID + */ + @TableField(value = "create_user") + private Long createUser; + + /** + * 创建时间 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 修改者ID + */ + @TableField(value = "update_user") + private Long updateUser; + + /** + * 修改时间 + */ + @TableField(value = "update_time") + private Date updateTime; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/material/entity/MaterialMassageResult.java b/src/main/java/com/sqx/modules/material/entity/MaterialMassageResult.java new file mode 100644 index 0000000..6e31493 --- /dev/null +++ b/src/main/java/com/sqx/modules/material/entity/MaterialMassageResult.java @@ -0,0 +1,46 @@ +package com.sqx.modules.material.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 物料包与服务表中间表 + * @TableName material_massage + */ +@Data +public class MaterialMassageResult implements Serializable { + /** + * + */ + private Integer id; + + /** + * 物料包id + */ + private Integer materialId; + + + /** + * 服务表id + */ + private Integer massageTypeId; + + /** 物料包名称 */ + private String materialName; + /** 物料包最低数量 */ + private String materialMinimum; + + /** + * 消耗 + */ + private BigDecimal consume; + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/material/entity/MaterialRecord.java b/src/main/java/com/sqx/modules/material/entity/MaterialRecord.java new file mode 100644 index 0000000..b2c69c4 --- /dev/null +++ b/src/main/java/com/sqx/modules/material/entity/MaterialRecord.java @@ -0,0 +1,58 @@ +package com.sqx.modules.material.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.Date; + +/** + * @TableName material_record + */ +@TableName(value ="material_record") +@Data +public class MaterialRecord implements Serializable { + private Integer id; + //操作数量 + private BigDecimal number; + //总量 + private BigDecimal total; + //技师表id + private Integer materialId; + //类型 1.增加 2.减少 + private Integer type; + //描述 + private String recordDescribe; + /** 技师名称 */ + @TableField(exist = false) + private String artificerName; + @TableField(exist = false) + private String startDate; + @TableField(exist = false) + private String endDate; + @TableField(exist = false) + private String materialName; + /** + * 技师id + */ + @TableField(value = "artificer_id") + private Integer artificerId; + private Long createUser; + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date createTime; + + private Long updateUser; + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date updateTime; + + private static final long serialVersionUID = 1L; + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/material/service/MaterialArtificerService.java b/src/main/java/com/sqx/modules/material/service/MaterialArtificerService.java new file mode 100644 index 0000000..9b3c3f1 --- /dev/null +++ b/src/main/java/com/sqx/modules/material/service/MaterialArtificerService.java @@ -0,0 +1,23 @@ +package com.sqx.modules.material.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.material.entity.MaterialArtificer; + +/** +* @author Administrator +* @description 针对表【material_artificer(物料包与技师中间表)】的数据库操作Service +* @createDate 2024-02-27 15:30:46 +*/ +public interface MaterialArtificerService extends IService { + + Result insertMaterialArtificer(MaterialArtificer materialArtificer); + + Result materialArtificerDelete(MaterialArtificer materialArtificer); + + Result materialArtificerUpdata(MaterialArtificer materialArtificer); + + String accomplishOrders(Long MessageTypeId, Long artificerId); + + void changePay(Long id, Long userId, Integer number); +} diff --git a/src/main/java/com/sqx/modules/material/service/MaterialMassageService.java b/src/main/java/com/sqx/modules/material/service/MaterialMassageService.java new file mode 100644 index 0000000..31851ac --- /dev/null +++ b/src/main/java/com/sqx/modules/material/service/MaterialMassageService.java @@ -0,0 +1,19 @@ +package com.sqx.modules.material.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.material.entity.MaterialMassage; + +/** +* @author Administrator +* @description 针对表【material_massage(物料包与服务表中间表)】的数据库操作Service +* @createDate 2024-02-27 15:29:44 +*/ +public interface MaterialMassageService extends IService { + + Result insert(MaterialMassage materialMassage); + + Result materialMassageDelete(MaterialMassage materialMassage); + + Result materialMassageUpdata(MaterialMassage materialMassage); +} diff --git a/src/main/java/com/sqx/modules/material/service/MaterialRecordService.java b/src/main/java/com/sqx/modules/material/service/MaterialRecordService.java new file mode 100644 index 0000000..ddedba1 --- /dev/null +++ b/src/main/java/com/sqx/modules/material/service/MaterialRecordService.java @@ -0,0 +1,18 @@ +package com.sqx.modules.material.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.material.entity.Material; +import com.sqx.modules.material.entity.MaterialRecord; + +/** +* @author Administrator +* @description 针对表【material_record(物料包历史记录表)】的数据库操作Service +* @createDate 2024-02-27 14:34:21 +*/ +public interface MaterialRecordService extends IService { + + Result selectPage(Integer page, Integer limit, MaterialRecord materialRecord); + + Result addMaterialRecord(MaterialRecord materialRecord); +} diff --git a/src/main/java/com/sqx/modules/material/service/MaterialService.java b/src/main/java/com/sqx/modules/material/service/MaterialService.java new file mode 100644 index 0000000..0cc2d87 --- /dev/null +++ b/src/main/java/com/sqx/modules/material/service/MaterialService.java @@ -0,0 +1,78 @@ +package com.sqx.modules.material.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.entity.Agency; +import com.sqx.modules.material.entity.Material; +import com.sqx.modules.material.entity.MaterialArtificer; +import com.sqx.modules.material.entity.MaterialMassage; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public interface MaterialService extends IService { + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + public List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + public Material getById(Integer id); + + /** + * 新增,插入所有字段 + * + * @param material 新增的记录 + * @return 返回影响行数 + */ + public int insert(Material material); + + /** + * 新增,忽略null字段 + * + * @param material 新增的记录 + * @return 返回影响行数 + */ + public Result insertIgnoreNull(Material material); + + /** + * 修改,修改所有字段 + * + * @param material 修改的记录 + * @return 返回影响行数 + */ + public int update(Material material); + + /** + * 修改,忽略null字段 + * + * @param material 修改的记录 + * @return 返回影响行数 + */ + public Result updateIgnoreNull(Material material); + /** + * 删除记录 + * + * @param material 待删除的记录 + * @return 返回影响行数 + */ + public Result delete(Material material); + + public Result selectPage(Integer page, Integer limit, Material material); + + Result selectMaterialArtificer(Integer page, Integer limit, MaterialArtificer materialArtificer); + + Result selectMaterialMassage(Integer page, Integer limit, MaterialMassage materialMassage); + + Result materialList(Material material); +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/material/service/impl/MaterialArtificerServiceImpl.java b/src/main/java/com/sqx/modules/material/service/impl/MaterialArtificerServiceImpl.java new file mode 100644 index 0000000..cbdaa4b --- /dev/null +++ b/src/main/java/com/sqx/modules/material/service/impl/MaterialArtificerServiceImpl.java @@ -0,0 +1,171 @@ +package com.sqx.modules.material.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.dao.ArtificerDao; +import com.sqx.modules.artificer.dao.MassageTypeDao; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.entity.MassageType; +import com.sqx.modules.material.dao.MaterialArtificerMapper; +import com.sqx.modules.material.dao.MaterialMapper; +import com.sqx.modules.material.dao.MaterialMassageMapper; +import com.sqx.modules.material.entity.Material; +import com.sqx.modules.material.entity.MaterialArtificer; +import com.sqx.modules.material.entity.MaterialMassage; +import com.sqx.modules.material.entity.MaterialRecord; +import com.sqx.modules.material.service.MaterialArtificerService; +import com.sqx.modules.material.service.MaterialRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** +* @author Administrator +* @description 针对表【material_artificer(物料包与技师中间表)】的数据库操作Service实现 +* @createDate 2024-02-27 15:30:46 +*/ +@Service +public class MaterialArtificerServiceImpl extends ServiceImpl implements MaterialArtificerService { + @Autowired + private MaterialRecordService materialRecordService; + @Autowired + private MaterialMapper materialMapper; + @Autowired + private MaterialMassageMapper materialMassageMapper; + @Autowired + private MassageTypeDao massageTypeDao; + @Autowired + private ArtificerDao artificerDao; + @Override + public Result insertMaterialArtificer(MaterialArtificer materialArtificer) { + materialArtificer.setCreateTime(new Date()); + materialArtificer.setUpdateTime(new Date()); + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("material_id", materialArtificer.getMaterialId()); + List materialArtificerList = baseMapper.selectList(queryWrapper); + if(materialArtificerList.size()>0){ + return Result.error("该物料包已被添加,请重新选择"); + } + int result = baseMapper.insert(materialArtificer); + return Result.success(String.valueOf(result)); + } + + @Override + public Result materialArtificerDelete(MaterialArtificer materialArtificer) { + MaterialArtificer materialArtificer1 = baseMapper.selectById(materialArtificer.getId()); + if(materialArtificer1 == null){ + return Result.error("该技师物料包不存在,请重新选择"); + } + if(materialArtificer1.getResidue().compareTo(BigDecimal.ZERO) == 1){ + return Result.error("该技师物料包未消耗空,请勿删除"); + } + int result = baseMapper.deleteById(materialArtificer.getId()); + return Result.success(result == 1 ?"删除成功":"删除失败"); + } + + @Override + public Result materialArtificerUpdata(MaterialArtificer materialArtificer) { + MaterialArtificer materialArtificerData = baseMapper.selectById(materialArtificer.getId()); + materialArtificer.setUpdateTime(new Date()); + //如果类型为1则执行添加剩余数量 否则执行减少剩余数量 + if(materialArtificer.getType().equals(1)){ + materialArtificer.setResidue(materialArtificerData.getResidue().add(materialArtificer.getBalance())); + }else { + materialArtificer.setResidue(materialArtificerData.getResidue().subtract(materialArtificer.getBalance())); + } + int result = baseMapper.updateById(materialArtificer); + if(!materialArtificer.getBalance().equals(0)){ + //修改过剩余量,执行新增历史记录 + MaterialRecord materialRecord = new MaterialRecord(); + materialRecord.setMaterialId(materialArtificerData.getMaterialId()); + materialRecord.setType(materialArtificer.getType()); + materialRecord.setTotal(materialArtificer.getResidue()); + materialRecord.setNumber(materialArtificer.getBalance()); + materialRecord.setUpdateTime(new Date()); + materialRecord.setCreateTime(new Date()); + materialRecord.setCreateUser(materialArtificer.getUpdateUser()); + materialRecord.setArtificerId(materialArtificerData.getArtificerId()); + materialRecord.setUpdateUser(materialArtificer.getUpdateUser()); + materialRecord.setRecordDescribe(DateUtil.date()+"管理员:"+materialArtificer.getUpdateUser()+(materialArtificer.getType().equals(1)?"新增剩余数量:":"减少剩余数量:")+materialArtificer.getBalance()+"总和:"+materialArtificer.getResidue()); + materialRecordService.addMaterialRecord(materialRecord); + } + return Result.success(result == 1 ?"修改成功":"修改失败"); + } + + @Override + public String accomplishOrders(Long messageTypeId, Long artificerId) { + QueryWrapper materialMassageQueryWrapper = new QueryWrapper(); + QueryWrapper materialArtificerQueryWrapper = new QueryWrapper(); + QueryWrapper massageTypeQueryWrapper = new QueryWrapper(); + //查询所有含有messageTypeId或者parent_id的数据 + massageTypeQueryWrapper.eq("massage_type_id",messageTypeId).or().eq("parent_id",messageTypeId); + List massageTypeList = massageTypeDao.selectList(massageTypeQueryWrapper); + //查询id为messageTypeId或者parent_id为messageTypeId + materialMassageQueryWrapper.in("massage_type_id",massageTypeList.stream().map(MassageType::getMassageTypeId).toArray()); + List materialMassageList = materialMassageMapper.selectList(materialMassageQueryWrapper); + materialMassageQueryWrapper.eq("artificer_id",artificerId); + List materialArtificers = baseMapper.selectList(materialArtificerQueryWrapper); + //循环列表消耗物料包 + for (int i = 0; i < materialMassageList.size(); i++){ + for (int j = 0; j < materialArtificers.size(); j++){ + if(materialMassageList.get(i).getMaterialId().equals(materialArtificers.get(j).getMaterialId())){ + materialArtificers.get(j).setResidue(materialArtificers.get(j).getResidue().subtract(materialMassageList.get(i).getConsume())); + baseMapper.updateById(materialArtificers.get(j)); + //修改剩余量,执行新增历史记录 + MaterialRecord materialRecord = new MaterialRecord(); + materialRecord.setMaterialId(materialMassageList.get(i).getMaterialId()); + materialRecord.setType(2); + materialRecord.setTotal(materialArtificers.get(i).getResidue()); + materialRecord.setNumber(materialMassageList.get(i).getConsume()); + materialRecord.setUpdateTime(new Date()); + materialRecord.setCreateTime(new Date()); + materialRecord.setCreateUser(Long.valueOf(materialArtificers.get(i).getArtificerId())); + materialRecord.setArtificerId(materialArtificers.get(i).getArtificerId()); + materialRecord.setUpdateUser(Long.valueOf(materialArtificers.get(i).getArtificerId())); + materialRecord.setRecordDescribe(DateUtil.date()+(materialRecord.getType().equals(1)?"新增剩余数量:":"减少剩余数量:")+materialMassageList.get(i).getConsume()+"总和:"+materialRecord.getTotal()); + materialRecordService.addMaterialRecord(materialRecord); + } + } + } + return null; + } + + @Override + public void changePay(Long id, Long userId, Integer number) { + //查询技师id + Artificer artificer = artificerDao.selectOne(new QueryWrapper().eq("user_id",userId)); + //查询物料包id + Material material = materialMapper.selectOne(new QueryWrapper().eq("goods_id",id)); + if(ObjectUtil.isEmpty(material)){ + return; + } + //根据物料包id和技师id查询技师对应物料包 + MaterialArtificer materialArtificer = baseMapper.selectOne(new QueryWrapper().eq("artificer_id",artificer.getArtificerId()).eq("material_id",material.getId())); + //修改物料包数量 + materialArtificer.setResidue(materialArtificer.getResidue().add(new BigDecimal(number))); + baseMapper.updateById(materialArtificer); + //修改剩余量,执行新增历史记录 + MaterialRecord materialRecord = new MaterialRecord(); + materialRecord.setMaterialId(materialArtificer.getMaterialId()); + materialRecord.setType(1); + materialRecord.setTotal(materialArtificer.getResidue()); + materialRecord.setNumber(BigDecimal.valueOf(number)); + materialRecord.setUpdateTime(new Date()); + materialRecord.setCreateTime(new Date()); + materialRecord.setCreateUser(Long.valueOf(materialArtificer.getArtificerId())); + materialRecord.setArtificerId(materialArtificer.getArtificerId()); + materialRecord.setUpdateUser(Long.valueOf(materialArtificer.getArtificerId())); + materialRecord.setRecordDescribe(DateUtil.date()+"通过商城购买"+(materialRecord.getType().equals(1)?"新增剩余数量:":"减少剩余数量:")+materialArtificer.getResidue()+"总和:"+materialRecord.getTotal()); + materialRecordService.addMaterialRecord(materialRecord); + } +} + + + + diff --git a/src/main/java/com/sqx/modules/material/service/impl/MaterialMassageServiceImpl.java b/src/main/java/com/sqx/modules/material/service/impl/MaterialMassageServiceImpl.java new file mode 100644 index 0000000..c48e350 --- /dev/null +++ b/src/main/java/com/sqx/modules/material/service/impl/MaterialMassageServiceImpl.java @@ -0,0 +1,53 @@ +package com.sqx.modules.material.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.Result; +import com.sqx.modules.material.dao.MaterialMassageMapper; +import com.sqx.modules.material.entity.Material; +import com.sqx.modules.material.entity.MaterialMassage; +import com.sqx.modules.material.service.MaterialMassageService; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +/** +* @author Administrator +* @description 针对表【material_massage(物料包与服务表中间表)】的数据库操作Service实现 +* @createDate 2024-02-27 15:29:44 +*/ +@Service +public class MaterialMassageServiceImpl extends ServiceImpl implements MaterialMassageService { + + @Override + public Result insert(MaterialMassage materialMassage) { + materialMassage.setCreateTime(new Date()); + materialMassage.setUpdateTime(new Date()); + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("material_id", materialMassage.getMaterialId()); + queryWrapper.eq("massageTypeId", materialMassage.getMassageTypeId()); + List materialMassageList = baseMapper.selectList(queryWrapper); + if(materialMassageList.size()>0){ + return Result.error("该物料包已被添加,请重新选择"); + } + int result = baseMapper.insert(materialMassage); + return Result.success(String.valueOf(result)); + } + + @Override + public Result materialMassageDelete(MaterialMassage materialMassage) { + int result = baseMapper.deleteById(materialMassage.getId()); + return Result.success(String.valueOf(result)); + } + + @Override + public Result materialMassageUpdata(MaterialMassage materialMassage) { + materialMassage.setUpdateTime(new Date()); + return Result.success(String.valueOf(baseMapper.updateById(materialMassage))); + } +} + + + + diff --git a/src/main/java/com/sqx/modules/material/service/impl/MaterialRecordServiceImpl.java b/src/main/java/com/sqx/modules/material/service/impl/MaterialRecordServiceImpl.java new file mode 100644 index 0000000..8aa9143 --- /dev/null +++ b/src/main/java/com/sqx/modules/material/service/impl/MaterialRecordServiceImpl.java @@ -0,0 +1,44 @@ +package com.sqx.modules.material.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.Result; +import com.sqx.modules.material.dao.MaterialRecordMapper; +import com.sqx.modules.material.entity.Material; +import com.sqx.modules.material.entity.MaterialRecord; +import com.sqx.modules.material.service.MaterialRecordService; +import jodd.util.StringUtil; +import org.springframework.stereotype.Service; + +/** +* @author Administrator +* @description 针对表【material_record(物料包历史记录表)】的数据库操作Service实现 +* @createDate 2024-02-27 14:34:21 +*/ +@Service +public class MaterialRecordServiceImpl extends ServiceImpl implements MaterialRecordService { + + + @Override + public Result selectPage(Integer page, Integer limit, MaterialRecord materialRecord) { + IPage page1 = new Page(page, limit); + IPage materialIPage = baseMapper.selectMaterialRecordList(page1,materialRecord); + return Result.success().put("data", materialIPage); + } + + @Override + public Result addMaterialRecord(MaterialRecord materialRecord) { + int i = baseMapper.insert(materialRecord); + if (i > 0){ + return Result.success().put("data", i); + } + return Result.error("添加失败"); + } +} + + + + diff --git a/src/main/java/com/sqx/modules/material/service/impl/MaterialServiceImpl.java b/src/main/java/com/sqx/modules/material/service/impl/MaterialServiceImpl.java new file mode 100644 index 0000000..e2e09e2 --- /dev/null +++ b/src/main/java/com/sqx/modules/material/service/impl/MaterialServiceImpl.java @@ -0,0 +1,201 @@ +package com.sqx.modules.material.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.dao.OrdersDao; +import com.sqx.modules.artificer.entity.Orders; +import com.sqx.modules.material.dao.MaterialArtificerMapper; +import com.sqx.modules.material.dao.MaterialMapper; +import com.sqx.modules.material.dao.MaterialMassageMapper; +import com.sqx.modules.material.entity.*; +import com.sqx.modules.material.service.MaterialService; +import com.sqx.modules.member.dao.MemberDao; +import com.sqx.modules.member.entity.Member; +import com.sqx.modules.member.service.MemberService; +import com.sqx.modules.shopping.dao.GoodsJpaRepository; +import com.sqx.modules.shopping.entity.SelfGoods; +import com.sqx.modules.shopping.service.GoodsService; +import jodd.util.StringUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.*; + +@Service +public class MaterialServiceImpl extends ServiceImpl implements MaterialService { + + @Autowired + private MaterialMapper materialMapper; + @Autowired + private MaterialArtificerMapper materialArtificerMapper; + @Autowired + private MaterialMassageMapper materialMassageMapper; + @Autowired + private GoodsService goodsService; + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + public List listAll() { + return materialMapper.listAll(); + } + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + public Material getById(Integer id) { + return materialMapper.getById(id); + } + + /** + * 新增,插入所有字段 + * + * @param material 新增的记录 + * @return 返回影响行数 + */ + public int insert(Material material) { + return materialMapper.insert(material); + } + + /** + * 新增,忽略null字段 + * + * @param material 新增的记录 + * @return 返回影响行数 + */ + public Result insertIgnoreNull(Material material) { + material.setCreateTime(new Date()); + material.setUpdateTime(new Date()); + // 创建服务查询封装器 + QueryWrapper materialQueryWrapper = new QueryWrapper(); + // 设置查询条件,根据物料ID查询物料按摩信息 + materialQueryWrapper.eq("goods_id", material.getGoodsId()); + // 根据查询封装器查询物料按摩信息 + Material materials = baseMapper.selectOne(materialQueryWrapper); + if(!materials.getId().equals(material.getId()) ){ + return Result.error("当前商品已绑定物料包,请重新选择!"); + } + return Result.success().put("data",materialMapper.insertIgnoreNull(material)); + } + + /** + * 修改,修改所有字段 + * + * @param material 修改的记录 + * @return 返回影响行数 + */ + public int update(Material material) { + return materialMapper.update(material); + } + + /** + * 修改,忽略null字段 + * + * @param material 修改的记录 + * @return 返回影响行数 + */ + public Result updateIgnoreNull(Material material) { + material.setUpdateTime(new Date()); + QueryWrapper materialQueryWrapper = new QueryWrapper(); + // 设置查询条件,根据物料ID查询物料按摩信息 + materialQueryWrapper.eq("goods_id", material.getGoodsId()); + // 根据查询封装器查询物料按摩信息 + Material materials = baseMapper.selectOne(materialQueryWrapper); + if(ObjectUtil.isNotEmpty(materials) && !materials.getId().equals(material.getId()) ){ + return Result.error("当前商品已绑定物料包,请重新选择!"); + } + return Result.success().put("data",materialMapper.updateIgnoreNull(material)); + } + + /** + * 删除记录 + * + * @param material 待删除的记录 + * @return 返回影响行数 + */ + public Result delete(Material material) { + //查询该物料包是否绑定技师或者服务如果绑定了返回错误禁止删除 + // 创建服务查询封装器 + QueryWrapper materialMassageQueryWrapper = new QueryWrapper(); + // 设置查询条件,根据物料ID查询物料按摩信息 + materialMassageQueryWrapper.eq("material_id", material.getId()); + // 根据查询封装器查询物料按摩信息 + List materialMassages = materialMassageMapper.selectList(materialMassageQueryWrapper); + // 创建技师查询封装器 + QueryWrapper materialArtificerQueryWrapper = new QueryWrapper(); + // 设置查询条件,根据物料ID查询技师信息 + materialArtificerQueryWrapper.eq("material_id", material.getId()); + // 根据查询封装器查询物料技师信息 + List materialArtificers = materialArtificerMapper.selectList(materialArtificerQueryWrapper); + // 如果物料按摩信息或技师信息存在,则返回错误信息 + if (materialMassages.size() > 0 || materialArtificers.size() > 0){ + return Result.error("该物料包已被技师或服务绑定,无法删除"); + } + return Result.success().put("data", materialMapper.delete(material)); + } + + @Override + /** + * 查询分页数据 + * @param page 当前页码 + * @param limit 每页显示数量 + * @param material 物料对象 + * @return 结果对象 + */ + public Result selectPage(Integer page, Integer limit, Material material) { + IPage page1 = new Page(page, limit); + IPage materialIPage = materialMapper.selectPages(page1,material); + return Result.success().put("data", materialIPage); + } + + + @Override + public Result selectMaterialArtificer(Integer page, Integer limit, MaterialArtificer materialArtificer) { + if(ObjectUtil.isEmpty(page) || ObjectUtil.isEmpty(limit)){ + List materialIPage = materialMapper.selectMaterialArtificerList(materialArtificer); + return Result.success().put("data", materialIPage); + }else { + IPage page1 = new Page(page, limit); + IPage materialIPage = materialMapper.selectMaterialArtificer(page1,materialArtificer); + return Result.success().put("data", materialIPage); + } + } + + @Override + public Result selectMaterialMassage(Integer page, Integer limit, MaterialMassage materialMassage) { + IPage page1 = new Page(page, limit); + IPage materialIPage = materialMapper.selectMaterialMassage(page1,materialMassage); + return Result.success().put("data", materialIPage); + } + + @Override + public Result materialList(Material material) { + QueryWrapper queryWrapper = new QueryWrapper(); + if(ObjectUtil.isNotEmpty(material.getStatus())) { + queryWrapper.eq("status", material.getStatus()); + } + if(StringUtil.isNotEmpty(material.getMaterialName())) { + queryWrapper.eq("material_name", material.getMaterialName()); + } + if(ObjectUtil.isNotEmpty(material.getGoodsId())) { + queryWrapper.eq("goods_id", material.getGoodsId()); + } + //筛选数据为未被删除 + queryWrapper.eq("is_deleted", "0"); + queryWrapper.orderByDesc( "update_time"); + List materialIPage = materialMapper.selectList(queryWrapper); + return Result.success().put("data", materialIPage); + } + + +} diff --git a/src/main/java/com/sqx/modules/member/controller/MemberController.java b/src/main/java/com/sqx/modules/member/controller/MemberController.java new file mode 100644 index 0000000..370f8b8 --- /dev/null +++ b/src/main/java/com/sqx/modules/member/controller/MemberController.java @@ -0,0 +1,56 @@ +package com.sqx.modules.member.controller; + +import com.sqx.common.utils.Result; +import com.sqx.modules.member.entity.Member; +import com.sqx.modules.member.service.MemberService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value = "会员特权", tags = {"会员特权"}) +@RequestMapping(value = "/member") +public class MemberController { + + + @Autowired + private MemberService memberService; + + @GetMapping("/selectMemberList") + @ApiOperation("查询列表(不带分页)") + public Result selectMemberList(){ + return memberService.selectMemberList(); + } + + + @GetMapping("/selectMemberPage") + @ApiOperation("查询列表(带分页") + public Result selectMemberPage(Integer page,Integer limit){ + return memberService.selectMemberPage(page, limit); + } + + @PostMapping("/updateMember") + @ApiOperation("修改会员特权") + public Result updateMember(@RequestBody Member member){ + return memberService.updateMember(member); + } + + + @PostMapping("/deleteMemberById") + @ApiOperation("删除会员特权") + public Result deleteMemberById(Long memberId){ + return memberService.deleteMemberById(memberId); + } + + @PostMapping("/insertMember") + @ApiOperation("新增会员特权") + public Result insertMember(@RequestBody Member member){ + return memberService.insertMember(member); + } + + + + + +} diff --git a/src/main/java/com/sqx/modules/member/controller/app/AppMemberController.java b/src/main/java/com/sqx/modules/member/controller/app/AppMemberController.java new file mode 100644 index 0000000..eb1dad2 --- /dev/null +++ b/src/main/java/com/sqx/modules/member/controller/app/AppMemberController.java @@ -0,0 +1,27 @@ +package com.sqx.modules.member.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.member.entity.Member; +import com.sqx.modules.member.service.MemberService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value = "会员特权", tags = {"会员特权"}) +@RequestMapping(value = "/app/member") +public class AppMemberController { + + + @Autowired + private MemberService memberService; + + @GetMapping("/selectMemberList") + @ApiOperation("查询列表(不带分页)") + public Result selectMemberList(){ + return memberService.selectMemberList(); + } + + +} diff --git a/src/main/java/com/sqx/modules/member/dao/MemberDao.java b/src/main/java/com/sqx/modules/member/dao/MemberDao.java new file mode 100644 index 0000000..d2ff401 --- /dev/null +++ b/src/main/java/com/sqx/modules/member/dao/MemberDao.java @@ -0,0 +1,12 @@ +package com.sqx.modules.member.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.member.entity.Member; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface MemberDao extends BaseMapper { + + + +} diff --git a/src/main/java/com/sqx/modules/member/entity/Member.java b/src/main/java/com/sqx/modules/member/entity/Member.java new file mode 100644 index 0000000..0eb0c4c --- /dev/null +++ b/src/main/java/com/sqx/modules/member/entity/Member.java @@ -0,0 +1,42 @@ +package com.sqx.modules.member.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description member + * @author fang + * @date 2021-06-19 + */ +@Data +public class Member implements Serializable { + + private static final long serialVersionUID = 1L; + + + /** + * 会员特权id + */ + @TableId(type = IdType.AUTO) + private Integer memberId; + + /** + * 特权图标 + */ + private String memberImg; + + /** + * 特权名称 + */ + private String memberName; + + /** + * 排序 + */ + private String sort; + + public Member() {} +} diff --git a/src/main/java/com/sqx/modules/member/service/MemberService.java b/src/main/java/com/sqx/modules/member/service/MemberService.java new file mode 100644 index 0000000..655e9a2 --- /dev/null +++ b/src/main/java/com/sqx/modules/member/service/MemberService.java @@ -0,0 +1,19 @@ +package com.sqx.modules.member.service; + +import com.sqx.common.utils.Result; +import com.sqx.modules.member.entity.Member; + + +public interface MemberService { + + Result insertMember(Member member); + + Result updateMember(Member member); + + Result deleteMemberById(Long memberId); + + Result selectMemberList(); + + Result selectMemberPage(Integer page,Integer limit); + +} diff --git a/src/main/java/com/sqx/modules/member/service/impl/MemberServiceImpl.java b/src/main/java/com/sqx/modules/member/service/impl/MemberServiceImpl.java new file mode 100644 index 0000000..742e2a0 --- /dev/null +++ b/src/main/java/com/sqx/modules/member/service/impl/MemberServiceImpl.java @@ -0,0 +1,56 @@ +package com.sqx.modules.member.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.member.dao.MemberDao; +import com.sqx.modules.member.entity.Member; +import com.sqx.modules.member.service.MemberService; +import org.springframework.stereotype.Service; + +@Service +public class MemberServiceImpl extends ServiceImpl implements MemberService { + + + @Override + public Result insertMember(Member member){ + baseMapper.insert(member); + return Result.success(); + } + + @Override + public Result updateMember(Member member){ + baseMapper.updateById(member); + return Result.success(); + } + + @Override + public Result deleteMemberById(Long memberId){ + baseMapper.deleteById(memberId); + return Result.success(); + } + + @Override + public Result selectMemberList(){ + return Result.success().put("data",baseMapper.selectList(new QueryWrapper().orderByAsc("sort"))); + } + + @Override + public Result selectMemberPage(Integer page,Integer limit){ + IPage pages=new Page<>(page,limit); + return Result.success().put("data",new PageUtils(baseMapper.selectPage(pages,new QueryWrapper().orderByAsc("sort")))); + } + + + +} + + + + + + + diff --git a/src/main/java/com/sqx/modules/message/controller/ActivityMessageController.java b/src/main/java/com/sqx/modules/message/controller/ActivityMessageController.java new file mode 100644 index 0000000..89bca5a --- /dev/null +++ b/src/main/java/com/sqx/modules/message/controller/ActivityMessageController.java @@ -0,0 +1,84 @@ +package com.sqx.modules.message.controller; + +import com.sqx.common.utils.Result; +import com.sqx.modules.message.entity.ActivityMessageInfo; +import com.sqx.modules.message.service.ActivityMessageService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @author fang + * @date 2020/7/13 + */ +@RestController +@Api(value = "消息管理", tags = {"消息管理"}) +@RequestMapping(value = "/ActivityMessage") +public class ActivityMessageController { + + @Autowired + private ActivityMessageService activityMessageService; + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ApiOperation("管理平台公告详情") + @ResponseBody + public Result getMessage(@PathVariable Integer id) { + return Result.success().put("data",activityMessageService.findOne(Long.valueOf(id))); + } + + @RequestMapping(value = "/add", method = RequestMethod.POST) + @ApiOperation("管理平台和用户端通用接口添加公告") + @ResponseBody + public Result addMessage(@RequestBody ActivityMessageInfo messageInfo) { + activityMessageService.saveBody(messageInfo); + return Result.success(); + } + + @RequestMapping(value = "/update", method = RequestMethod.POST) + @ApiOperation("管理平台修改公告接口") + @ResponseBody + public Result uUpdate(@RequestBody ActivityMessageInfo messageInfo) { + activityMessageService.updateBody(messageInfo); + return Result.success(); + } + + @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET) + @ApiOperation("管理平台删除公告接口") + public Result deleteMessage(@PathVariable int id) { + activityMessageService.delete(id); + return Result.success(); + } + + @RequestMapping(value = "/", method = RequestMethod.GET) + @ApiOperation("管理平台获取全部公告接口") + @ResponseBody + public Result getMessageList() { + List all = activityMessageService.findAll(); + return Result.success().put("data",all); + } + + @RequestMapping(value = "/page/{state}/{page}/{limit}", method = RequestMethod.GET) + @ApiOperation("管理平台分页查询公告接口") + @ResponseBody + public Result getBodyPage(@PathVariable String state, @PathVariable Integer page, @PathVariable int limit) { + return Result.success().put("data",activityMessageService.find(state, page,limit)); + } + + @RequestMapping(value = "/type/{type}/{page}/{limit}", method = RequestMethod.GET) + @ApiOperation("管理平台通过类型获取接口 type1为公告2位用户反馈 3为系统消息 4为订单信息 5为用户消息 6客服消息") + @ResponseBody + public Result findType(@PathVariable Integer type, @PathVariable Integer page, @PathVariable int limit) { + return Result.success().put("data",activityMessageService.findType(type, page,limit)); + } + + @RequestMapping(value = "/findType/{userId}/{type}/{page}/{limit}", method = RequestMethod.GET) + @ApiOperation("用户端获取消息列表 type 4为订单信息 5为用户消息") + @ResponseBody + public Result findType(@PathVariable String userId, @PathVariable String type, @PathVariable Integer page, @PathVariable int limit) { + return Result.success().put("data",activityMessageService.findTypeByUserId(type, userId,page,limit)); + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/message/controller/MessageAudioController.java b/src/main/java/com/sqx/modules/message/controller/MessageAudioController.java new file mode 100644 index 0000000..f202b17 --- /dev/null +++ b/src/main/java/com/sqx/modules/message/controller/MessageAudioController.java @@ -0,0 +1,67 @@ +package com.sqx.modules.message.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.Result; +import com.sqx.modules.message.entity.MessageInfoAudio; +import com.sqx.modules.message.service.MessageAudioService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * @author fang + * @date 2020/7/13 + */ +@RestController +@Api(value = "消息管理", tags = {"消息管理"}) +@RequestMapping(value = "/messageAudio") +public class MessageAudioController { + + @Autowired + private MessageAudioService service; + + @GetMapping("/batchList") + @ApiOperation("按批次获取音频列表") + public Result batchList(Integer page,Integer limit,String batch){ + QueryWrapper qw = new QueryWrapper<>(); + qw.eq(StringUtils.isNotBlank(batch),"batch",batch); + qw.eq(StringUtils.isBlank(batch),"batch","-1"); + qw.orderByAsc("sort"); + IPage pageList = service.page(new Page<>(page,limit),qw); + return Result.success().put("data",pageList); + } + + @PostMapping(value = "/add") + @ApiOperation("新增音频列表") + @ResponseBody + public Result add(@RequestBody MessageInfoAudio messageInfoAudio){ + return Result.success().put("data",service.save(messageInfoAudio)); + } + + @PostMapping(value = "/update") + @ApiOperation("修改音频列表") + @ResponseBody + public Result update(@RequestBody MessageInfoAudio messageInfoAudio){ + return Result.success().put("data",service.updateById(messageInfoAudio)); + } + + @GetMapping(value = "/deleteById") + @ApiOperation("删除音频列表") + @ResponseBody + public Result deleteById(Long id){ + return Result.success().put("data",service.removeById(id)); + } + + @GetMapping(value = "/mergeAllAudio") + @ApiOperation("合并全部音频") + @ResponseBody + public Result mergeAllAudio(String batch){ + return Result.success().put("data",service.mergeAllAudio(batch)); + } + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/message/controller/MessageController.java b/src/main/java/com/sqx/modules/message/controller/MessageController.java new file mode 100644 index 0000000..cc3f239 --- /dev/null +++ b/src/main/java/com/sqx/modules/message/controller/MessageController.java @@ -0,0 +1,193 @@ +package com.sqx.modules.message.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.service.MessageService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author fang + * @date 2020/7/13 + */ +@RestController +@Api(value = "消息管理", tags = {"消息管理"}) +@RequestMapping(value = "/message") +public class MessageController { + + @Autowired + private MessageService messageService; + + @GetMapping("/selectCityList") + @ApiOperation("查询期望开通城市列表") + public Result selectCityList(Integer page,Integer limit,String content){ + return messageService.selectCityList(page, limit, content); + } + + @GetMapping("/selectCityDetailsList") + @ApiOperation("查询期望开通城市详细列表") + public Result selectCityDetailsList(Integer page,Integer limit,String content){ + return Result.success().put("data",new PageUtils(messageService.page(new Page<>(page,limit),new QueryWrapper().eq("state",11).eq("content",content)))); + } + + @PostMapping("/auditMessage") + @ApiOperation("审核投诉") + public Result auditMessage(String ids,Integer status,String auditContent){ + return messageService.auditMessage(ids, status, auditContent); + } + + @GetMapping("/selectMessageCount") + @ApiOperation("查询投诉待审核消息总和") + public Result selectMessageCount(Integer state){ + if(state==9){ + return Result.success().put("data",messageService.count(new QueryWrapper().eq("state",state).isNull("type"))); + } + return Result.success().put("data",messageService.count(new QueryWrapper().eq("state",state).eq("type",0))); + } + + @RequestMapping(value = "/selectMessageByUserId", method = RequestMethod.GET) + @ApiOperation("查询用户消息") + @ResponseBody + public Result selectUserRecharge(int page, int limit, Long userId,Integer state){ + Map map=new HashMap<>(); + map.put("page",page); + map.put("limit",limit); + map.put("userId",userId); + map.put("state",state); + return Result.success().put("data",messageService.selectMessageList(map)); + } + + @RequestMapping(value = "/selectMessageByType", method = RequestMethod.GET) + @ApiOperation("获取消息 type1为公告2位用户反馈 3为系统消息 4为订单信息 5为用户消息 6客服消息 ") + @ResponseBody + public Result selectMessageByType(int page, int limit,Integer state){ + Map map=new HashMap<>(); + map.put("page",page); + map.put("limit",limit); + map.put("userId",null); + map.put("state",state); + PageUtils pageUtils = messageService.selectMessageList(map); + return Result.success().put("data",pageUtils); + } + + @GetMapping("/selectOrdersCount") + @ApiOperation("查询新订单未读条数") + public Result selectOrdersCount(){ + int count = messageService.count(new QueryWrapper().eq("state", 16).eq("is_see", 0)); + messageService.updateSendState(0L,16); + return Result.success().put("data",count); + } + + @RequestMapping(value = "/selectMessageDetails", method = RequestMethod.GET) + @ApiOperation("获取消息详细信息") + @ResponseBody + public Result selectMessageDetails(Long id){ + return Result.success().put("data",messageService.selectMessageById(id)); + } + + @RequestMapping(value = "/updateMessage", method = RequestMethod.POST) + @ApiOperation("修改消息") + @ResponseBody + public Result updateMessage(@RequestBody MessageInfo messageInfo){ + return Result.success().put("data",messageService.update(messageInfo)); + } + + + @RequestMapping(value = "/deleteMessageById", method = RequestMethod.POST) + @ApiOperation("删除消息") + @ResponseBody + public Result deleteMessageById(Long id){ + return Result.success().put("data",messageService.delete(id)); + } + + @RequestMapping(value = "/insertMessage", method = RequestMethod.POST) + @ApiOperation("添加消息") + @ResponseBody + public Result insertMessage(@RequestBody MessageInfo messageInfo){ + return Result.success().put("data",messageService.saveBody(messageInfo)); + } + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ApiOperation("管理平台公告详情") + @ResponseBody + public Result getMessage(@PathVariable Long id) { + return Result.success().put("data",messageService.selectMessageById(id)); + } + + @RequestMapping(value = "/add", method = RequestMethod.POST) + @ApiOperation("管理平台和用户端通用接口添加公告") + @ResponseBody + public Result addMessage(@RequestBody MessageInfo messageInfo) { + messageService.saveBody(messageInfo); + return Result.success(); + } + + @RequestMapping(value = "/update", method = RequestMethod.POST) + @ApiOperation("管理平台修改公告接口") + @ResponseBody + public Result uUpdate(@RequestBody MessageInfo messageInfo) { + messageService.update(messageInfo); + return Result.success(); + } + + @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET) + @ApiOperation("管理平台删除公告接口") + public Result deleteMessage(@PathVariable Long id) { + messageService.delete(id); + return Result.success(); + } + + @RequestMapping(value = "/", method = RequestMethod.GET) + @ApiOperation("管理平台获取全部公告接口") + @ResponseBody + public Result getMessageList(int page,int limit) { + Map map=new HashMap<>(); + map.put("page",page); + map.put("limit",limit); + map.put("userId",null); + map.put("state",null); + map.put("type",null); + return Result.success().put("data",messageService.selectMessageList(map)); + } + + @RequestMapping(value = "/page/{state}/{page}/{limit}", method = RequestMethod.GET) + @ApiOperation("管理平台分页查询公告接口") + @ResponseBody + public Result getBodyPage(@PathVariable Integer state, @PathVariable Integer page, @PathVariable int limit) { + Map map=new HashMap<>(); + map.put("page",page); + map.put("limit",limit); + map.put("state",state); + map.put("type",null); + map.put("userId",null); + return Result.success().put("data",messageService.selectMessageList(map)); + } + + @GetMapping("/selectSignList") + @ApiOperation("查询技师签到记录") + public Result selectSignList(Integer page,Integer limit,Long userId,String phone,String address){ + return messageService.selectSignList(page, limit, address, phone, userId); + } + + @GetMapping("/selectArtificerLocation") + @ApiOperation("查询技师位置更新记录") + public Result selectArtificerLocation(Integer page,Integer limit,Long userId,String phone,String artificerName){ + return messageService.selectArtificerLocation(page, limit, artificerName, phone, userId); + } + + @GetMapping("/selectArtificerScoreList") + @ApiOperation("查询技师信誉分明细") + public Result selectArtificerScoreList(Integer page,Integer limit,Long userId,String phone,String artificerName){ + return messageService.selectArtificerScoreList(page, limit, artificerName, phone, userId); + } + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/message/controller/app/AppMessageController.java b/src/main/java/com/sqx/modules/message/controller/app/AppMessageController.java new file mode 100644 index 0000000..be26a2f --- /dev/null +++ b/src/main/java/com/sqx/modules/message/controller/app/AppMessageController.java @@ -0,0 +1,111 @@ +package com.sqx.modules.message.controller.app; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.service.MessageService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author fang + * @date 2020/7/13 + */ +@RestController +@Api(value = "消息管理", tags = {"消息管理"}) +@RequestMapping(value = "/app/message") +public class AppMessageController { + + @Autowired + private MessageService messageService; + + + @RequestMapping(value = "/selectMessageList", method = RequestMethod.GET) + @ApiOperation("查询用户消息") + @ResponseBody + public Result selectMessageList(int page, int limit,Integer state){ + Map map=new HashMap<>(); + map.put("page",page); + map.put("limit",limit); + map.put("state",state); + PageUtils pageUtils = messageService.selectMessageList(map); + return Result.success().put("data",pageUtils); + } + + @GetMapping("/selectCityCount") + @ApiOperation("查询城市投票总条数") + public Result selectCityCount(String city){ + int count = messageService.count(new QueryWrapper().eq("state", 11).eq("content", city)); + return Result.success().put("data",count); + } + + + @Login + @RequestMapping(value = "/selectMessageByUserId", method = RequestMethod.GET) + @ApiOperation("查询用户消息") + @ResponseBody + public Result selectUserRecharge(int page, int limit,@RequestAttribute("userId") Long userId,Integer state){ + Map map=new HashMap<>(); + map.put("page",page); + map.put("limit",limit); + map.put("userId",userId); + map.put("state",state); + PageUtils pageUtils = messageService.selectMessageList(map); + messageService.updateSendState(userId,state); + return Result.success().put("data",pageUtils); + } + + @Login + @RequestMapping(value = "/selectMessageByUserIds", method = RequestMethod.GET) + @ApiOperation("查询用户消息") + @ResponseBody + public Result selectMessageLists(int page, int limit,@RequestAttribute("userId") Long userId,Integer state){ + Map map=new HashMap<>(); + map.put("page",page); + map.put("limit",limit); + map.put("userId",userId); + map.put("state",state); + PageUtils pageUtils = messageService.selectMessageLists(map); + messageService.updateSendState(userId,state); + return Result.success().put("data",pageUtils); + } + + @Login + @RequestMapping(value = "/selectMessageByUserIdLimit1", method = RequestMethod.GET) + @ApiOperation("查询用户消息") + @ResponseBody + public Result selectMessageByUserIdLimit1(@RequestAttribute("userId") Long userId){ + Map map=new HashMap<>(); + map.put("page",1); + map.put("limit",1); + map.put("userId",userId); + return Result.success().put("data",messageService.selectMessageList(map)); + } + + + @Login + @PostMapping("/insertMessage") + @ApiOperation("添加投诉") + public Result insertMessage(@RequestBody MessageInfo messageInfo){ + messageService.saveBody(messageInfo); + return Result.success(); + } + + @Login + @PostMapping("/insertArtificerLocation") + @ApiOperation("更新经纬度") + public Result insertArtificerLocation(@RequestBody MessageInfo messageInfo){ + return messageService.insertArtificerLocation(messageInfo); + } + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/message/dao/ActivityMessageInfoDao.java b/src/main/java/com/sqx/modules/message/dao/ActivityMessageInfoDao.java new file mode 100644 index 0000000..55204d0 --- /dev/null +++ b/src/main/java/com/sqx/modules/message/dao/ActivityMessageInfoDao.java @@ -0,0 +1,28 @@ +package com.sqx.modules.message.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.message.entity.ActivityMessageInfo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * @author fang + * @date 2020/7/9 + */ +@Mapper +public interface ActivityMessageInfoDao extends BaseMapper { + + IPage find(Page page,@Param("state") String state); + + IPage findType(Page page,@Param("type") Integer type); + + IPage findTypeByUserId(Page page,@Param("type")String type,@Param("userId") String userId); + + Integer updateState(@Param("state") String state, @Param("id") Long id); + + Integer updateSendState(@Param("sendState") String sendState, @Param("id") Long id); + + +} diff --git a/src/main/java/com/sqx/modules/message/dao/MessageInfoAudioDao.java b/src/main/java/com/sqx/modules/message/dao/MessageInfoAudioDao.java new file mode 100644 index 0000000..a20701a --- /dev/null +++ b/src/main/java/com/sqx/modules/message/dao/MessageInfoAudioDao.java @@ -0,0 +1,28 @@ +package com.sqx.modules.message.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.message.entity.MessageInfoAudio; +import com.sqx.modules.message.entity.MessageInfoAudio; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * @author fang + * @date 2020/7/9 + */ +@Mapper +public interface MessageInfoAudioDao extends BaseMapper { + +// IPage find(Page page, @Param("state") String state); +// +// IPage findType(Page page,@Param("type") Integer type); +// +// IPage findTypeByUserId(Page page,@Param("type")String type,@Param("userId") String userId); +// +// Integer updateState(@Param("state") String state, @Param("id") Long id); +// +// Integer updateSendState(@Param("sendState") String sendState, @Param("id") Long id); + +} diff --git a/src/main/java/com/sqx/modules/message/dao/MessageInfoDao.java b/src/main/java/com/sqx/modules/message/dao/MessageInfoDao.java new file mode 100644 index 0000000..ca66f45 --- /dev/null +++ b/src/main/java/com/sqx/modules/message/dao/MessageInfoDao.java @@ -0,0 +1,31 @@ +package com.sqx.modules.message.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.Result; +import com.sqx.modules.message.entity.MessageInfo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Map; + +/** + * @author fang + * @date 2020/7/9 + */ +@Mapper +public interface MessageInfoDao extends BaseMapper { + + int updateSendState(@Param("userId") Long userId,@Param("state") Integer state); + + IPage> selectCityList(Page> page,String content); + + IPage> selectSignList(Page> page,String address,String phone,Long userId); + + IPage> selectArtificerLocation(Page> page,String artificerName,String phone,Long userId); + + IPage> selectArtificerScoreList(Page> page,String artificerName,String phone,Long userId); + + +} diff --git a/src/main/java/com/sqx/modules/message/entity/ActivityMessageInfo.java b/src/main/java/com/sqx/modules/message/entity/ActivityMessageInfo.java new file mode 100644 index 0000000..ec4bbce --- /dev/null +++ b/src/main/java/com/sqx/modules/message/entity/ActivityMessageInfo.java @@ -0,0 +1,49 @@ +package com.sqx.modules.message.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author fang + * @date 2020/7/13 + */ +@Data +@TableName("activity_message_info") +public class ActivityMessageInfo implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.INPUT) + private long id; + + private String createAt; + + private String content; + + private String title; + + private String image; + + private String url; + + private String sendState; + + private String sendTime; + + private String isSee; + + private String state; + + private String type; + + private String userId; + + private String userName; + + private String platform; + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/message/entity/MessageInfo.java b/src/main/java/com/sqx/modules/message/entity/MessageInfo.java new file mode 100644 index 0000000..54b91f0 --- /dev/null +++ b/src/main/java/com/sqx/modules/message/entity/MessageInfo.java @@ -0,0 +1,91 @@ +package com.sqx.modules.message.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author fang + * @date 2020/7/13 + */ +@Data +@TableName("message_info") +public class MessageInfo implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 消息id + */ + private Long id; + + /** + * 内容 + */ + private String content; + + /** + * 创建时间 + */ + private String createAt; + + /** + * 图片 + */ + private String image; + + /** + * is_see + */ + private String isSee; + + + private String typeId; + + private String typeName; + + /** + * 分类 + */ + private String state; + + /** + * 标题 + */ + private String title; + + private String byUserId; + + private String type; + + + private String byUserName; + + /** + * 用户id + */ + private String userId; + + /** + * 用户名 + */ + private String userName; + + /** + * 审核内容 + */ + private String auditContent; + + /** + * 批次号 + */ + private String batch; + + + public MessageInfo() {} + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/message/entity/MessageInfoAudio.java b/src/main/java/com/sqx/modules/message/entity/MessageInfoAudio.java new file mode 100644 index 0000000..e37f01e --- /dev/null +++ b/src/main/java/com/sqx/modules/message/entity/MessageInfoAudio.java @@ -0,0 +1,43 @@ +package com.sqx.modules.message.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author fang + * @date 2020/7/13 + */ +@Data +@TableName("message_info_audio") +public class MessageInfoAudio implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 消息id + */ + private Long id; + + /** + * 音频切片地址 + */ + private String auditContent; + + /** + * 批次号 + */ + private String batch; + + /** + * 排序 + */ + private Integer sort; + + + public MessageInfoAudio() {} + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/message/service/ActivityMessageService.java b/src/main/java/com/sqx/modules/message/service/ActivityMessageService.java new file mode 100644 index 0000000..ca9db21 --- /dev/null +++ b/src/main/java/com/sqx/modules/message/service/ActivityMessageService.java @@ -0,0 +1,34 @@ +package com.sqx.modules.message.service; + + +import com.sqx.common.utils.PageUtils; +import com.sqx.modules.message.entity.ActivityMessageInfo; + +import java.util.List; + +public interface ActivityMessageService { + + int saveBody(ActivityMessageInfo messageInfo); + + List findAll(); + + ActivityMessageInfo findOne(long id); + + ActivityMessageInfo selectById(long id); + + int delete(long id); + + PageUtils find(String state, int page,int limit); + + int updateBody(ActivityMessageInfo userInfo); + + PageUtils findType(Integer type, int page,int limit); + + int updateState(String state, Long id); + + int updateSendState(String state, Long id); + + PageUtils findTypeByUserId( String type,String userId, int page,int limit); + + +} diff --git a/src/main/java/com/sqx/modules/message/service/MessageAudioService.java b/src/main/java/com/sqx/modules/message/service/MessageAudioService.java new file mode 100644 index 0000000..6c4c036 --- /dev/null +++ b/src/main/java/com/sqx/modules/message/service/MessageAudioService.java @@ -0,0 +1,41 @@ +package com.sqx.modules.message.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.message.entity.MessageInfoAudio; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.entity.MessageInfoAudio; + +import java.util.List; +import java.util.Map; + +public interface MessageAudioService extends IService { + String mergeAllAudio(String batch); + + +// int saveBody(MessageInfoAudio e); +// +// List findAll(); +// +// MessageInfoAudio findOne(long id); +// +// MessageInfoAudio selectById(long id); +// +// int delete(long id); +// +// PageUtils find(String state, int page,int limit); +// +// int updateBody(MessageInfoAudio e); +// +// PageUtils findType(Integer type, int page,int limit); +// +// int updateState(String state, Long id); +// +// int updateSendState(String state, Long id); +// +// PageUtils findTypeByUserId( String type,String userId, int page,int limit); + + +} diff --git a/src/main/java/com/sqx/modules/message/service/MessageService.java b/src/main/java/com/sqx/modules/message/service/MessageService.java new file mode 100644 index 0000000..10883b2 --- /dev/null +++ b/src/main/java/com/sqx/modules/message/service/MessageService.java @@ -0,0 +1,44 @@ +package com.sqx.modules.message.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.message.entity.MessageInfo; +import org.apache.ibatis.annotations.Param; +import org.springframework.web.bind.annotation.RequestAttribute; + +import java.util.Map; + +public interface MessageService extends IService { + + Result selectCityList(Integer page,Integer limit,String content); + + Result auditMessage(String ids, Integer status, String auditContent); + + PageUtils selectMessageList(Map params); + + PageUtils selectMessageLists(Map params); + + int saveBody(MessageInfo messageInfo); + + Result insertArtificerLocation(MessageInfo messageInfo); + + int update(MessageInfo messageInfo); + + int delete(Long id); + + MessageInfo selectMessageById(Long id); + + int updateSendState(Long userId,Integer state); + + MessageInfo selectMessageByUserIdAndTime(Long userId,String time); + + Result selectSignList(Integer page,Integer limit,String address,String phone,Long userId); + + Result selectArtificerLocation(Integer page,Integer limit,String artificerName,String phone,Long userId); + + Result selectArtificerScoreList(Integer page,Integer limit,String artificerName,String phone,Long userId); + + +} diff --git a/src/main/java/com/sqx/modules/message/service/impl/ActivityMessageServiceImpl.java b/src/main/java/com/sqx/modules/message/service/impl/ActivityMessageServiceImpl.java new file mode 100644 index 0000000..1a295a7 --- /dev/null +++ b/src/main/java/com/sqx/modules/message/service/impl/ActivityMessageServiceImpl.java @@ -0,0 +1,94 @@ +package com.sqx.modules.message.service.impl; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.modules.message.dao.ActivityMessageInfoDao; +import com.sqx.modules.message.entity.ActivityMessageInfo; +import com.sqx.modules.message.service.ActivityMessageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +/** + * 消息 + */ +@Service +public class ActivityMessageServiceImpl extends ServiceImpl implements ActivityMessageService { + + @Autowired + private ActivityMessageInfoDao activityMessageInfoDao; + + @Override + public List findAll() { + return activityMessageInfoDao.selectList(null); + } + + @Override + public int saveBody(ActivityMessageInfo messageInfo) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + messageInfo.setCreateAt(sdf.format(now)); + return activityMessageInfoDao.insert(messageInfo); + } + + @Override + public ActivityMessageInfo findOne(long id) { + return activityMessageInfoDao.selectById(id); + } + + @Override + public ActivityMessageInfo selectById(long id) { + return activityMessageInfoDao.selectById(id); + } + + @Override + public int delete(long id) { + activityMessageInfoDao.deleteById(id); + return 1; + } + + @Override + public PageUtils find(String state, int page,int limit) { + Page pages = new Page<>(page, limit); + return new PageUtils(activityMessageInfoDao.find(pages,state)); + } + + @Override + @Transactional + public int updateBody(ActivityMessageInfo userInfo) { + activityMessageInfoDao.updateById(userInfo); + return 1; + } + + @Override + public PageUtils findType(Integer type, int page,int limit) { + Page pages = new Page<>(page, limit); + return new PageUtils(activityMessageInfoDao.findType(pages,type)); + } + + @Override + @Transactional + public int updateState(String state, Long id) { + return activityMessageInfoDao.updateState(state,id); + } + + @Override + @Transactional + public int updateSendState(String state, Long id) { + return activityMessageInfoDao.updateSendState(state,id); + } + + @Override + public PageUtils findTypeByUserId( String type,String userId, int page,int limit) { + Page pages = new Page<>(page, limit); + return new PageUtils(activityMessageInfoDao.findTypeByUserId(pages,type,userId)); + } + + + +} diff --git a/src/main/java/com/sqx/modules/message/service/impl/MessageAudioServiceImpl.java b/src/main/java/com/sqx/modules/message/service/impl/MessageAudioServiceImpl.java new file mode 100644 index 0000000..a2c62cc --- /dev/null +++ b/src/main/java/com/sqx/modules/message/service/impl/MessageAudioServiceImpl.java @@ -0,0 +1,175 @@ +package com.sqx.modules.message.service.impl; + +import cn.hutool.core.io.FileUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.common.collect.Lists; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Query; +import com.sqx.common.utils.Result; +import com.sqx.ffmpeg.FFmpeg; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.service.ArtificerService; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.message.dao.MessageInfoAudioDao; +import com.sqx.modules.message.dao.MessageInfoDao; +import com.sqx.modules.message.entity.MessageInfoAudio; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.entity.MessageInfoAudio; +import com.sqx.modules.message.service.MessageAudioService; +import com.sqx.modules.message.service.MessageService; +import com.sqx.modules.risk.entity.Risk; +import com.sqx.modules.risk.service.RiskService; +import com.sqx.modules.utils.HttpClientUtil; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 消息 + */ +@Service +public class MessageAudioServiceImpl extends ServiceImpl implements MessageAudioService { + + @Autowired + private FFmpeg fFmpeg; + + @Autowired + private MessageService messageService; + + @Autowired + private CommonInfoService commonRepository; + + @Override + public String mergeAllAudio(String batch) { + String http = commonRepository.findOne(19).getValue(); + String[] split = http.split("://"); + // 路径 + String baseAudioUploadPath = "/www/wwwroot/"+split[1]+"/file/uploadPath"; + + QueryWrapper iqw = new QueryWrapper<>(); + iqw.eq("batch",batch); + iqw.last("limit 1"); + MessageInfo oldInfo = messageService.getOne(iqw); + if(oldInfo == null){ + return "合并失败,未找到数据!"; + } + String userId = oldInfo.getUserId(); + String dateTime = oldInfo.getCreateAt(); + String date = null; + + String[] dateTime2 = StringUtils.split(dateTime," "); + date = dateTime2[0]; + + String baseFilePath = baseAudioUploadPath + "/" + "audio" + "/" + userId + "/" + date + "/" + batch + "/"; + + String filePath = baseFilePath + "all.mp3"; + FileUtil.touch(filePath); + String url = StringUtils.replace(filePath,"/www/wwwroot/"+split[1],http); + //执行合并 + //查询出已经合并后的文件列表 + QueryWrapper qw = new QueryWrapper<>(); + qw.eq("batch",batch); + List audioList = list(qw); + List mergeList = Lists.newArrayList(); + for (MessageInfoAudio audio: audioList){ + //转换成物理地址 + String fileUrl = audio.getAuditContent(); + String path = StringUtils.replace(fileUrl,http, "/www/wwwroot/"+split[1]); + mergeList.add(path); + } + fFmpeg.mergeAllAudio(mergeList,filePath); + UpdateWrapper uw = new UpdateWrapper<>(); + uw.set("image",url); + uw.eq("batch",batch); + messageService.update(uw); + return "合并成功"; + } + +// @Autowired +// private MessageInfoAudioDao messageInfoAudioDao; +// +// @Override +// public List findAll() { +// return messageInfoAudioDao.selectList(null); +// } +// +// @Override +// public int saveBody(MessageInfoAudio messageInfo) { +// //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// //Date now = new Date(); +// //messageInfo.setCreateAt(sdf.format(now)); +// return messageInfoAudioDao.insert(messageInfo); +// } +// +// @Override +// public MessageInfoAudio findOne(long id) { +// return messageInfoAudioDao.selectById(id); +// } +// +// @Override +// public MessageInfoAudio selectById(long id) { +// return messageInfoAudioDao.selectById(id); +// } +// +// @Override +// public int delete(long id) { +// messageInfoAudioDao.deleteById(id); +// return 1; +// } +// +// @Override +// public PageUtils find(String state, int page,int limit) { +// Page pages = new Page<>(page, limit); +// return new PageUtils(messageInfoAudioDao.find(pages,state)); +// } +// +// @Override +// @Transactional +// public int updateBody(MessageInfoAudio userInfo) { +// messageInfoAudioDao.updateById(userInfo); +// return 1; +// } +// +// @Override +// public PageUtils findType(Integer type, int page,int limit) { +// Page pages = new Page<>(page, limit); +// return new PageUtils(messageInfoAudioDao.findType(pages,type)); +// } +// +// @Override +// @Transactional +// public int updateState(String state, Long id) { +// return messageInfoAudioDao.updateState(state,id); +// } +// +// @Override +// @Transactional +// public int updateSendState(String state, Long id) { +// return messageInfoAudioDao.updateSendState(state,id); +// } +// +// @Override +// public PageUtils findTypeByUserId( String type,String userId, int page,int limit) { +// Page pages = new Page<>(page, limit); +// return new PageUtils(messageInfoAudioDao.findTypeByUserId(pages,type,userId)); +// } + +} diff --git a/src/main/java/com/sqx/modules/message/service/impl/MessageServiceImpl.java b/src/main/java/com/sqx/modules/message/service/impl/MessageServiceImpl.java new file mode 100644 index 0000000..8ca834f --- /dev/null +++ b/src/main/java/com/sqx/modules/message/service/impl/MessageServiceImpl.java @@ -0,0 +1,239 @@ +package com.sqx.modules.message.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Query; +import com.sqx.common.utils.Result; +import com.sqx.map.CommonMapUtils; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.entity.Artificer; +import com.sqx.modules.artificer.service.ArtificerService; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.message.dao.MessageInfoDao; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.service.MessageService; +import com.sqx.modules.risk.entity.Risk; +import com.sqx.modules.risk.service.RiskService; +import com.sqx.modules.utils.AppNotifyUtil; +import com.sqx.modules.utils.HttpClientUtil; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 消息 + */ +@Service +public class MessageServiceImpl extends + ServiceImpl implements MessageService { + + @Autowired + private MessageInfoDao messageInfoDao; + @Autowired + private ArtificerService artificerService; + @Autowired + private RiskService riskService; + @Autowired + private UserService userService; + @Autowired + private CommonInfoService commonInfoService; + + @Override + public Result selectCityList(Integer page,Integer limit,String content){ + IPage> mapIPage = messageInfoDao.selectCityList(new Page<>(page, limit), content); + return Result.success().put("data",new PageUtils(mapIPage)); + } + + @Override + public Result auditMessage(String ids, Integer status, String auditContent){ + for(String id:ids.split(",")){ + MessageInfo messageInfo = baseMapper.selectById(Long.parseLong(id)); + if("0".equals(messageInfo.getType())){ + if(status==1){ + Artificer artificer = artificerService.selectArtificerByUserId(Long.parseLong(messageInfo.getByUserId())); + MessageInfo type = baseMapper.selectById(messageInfo.getTypeId()); + BigDecimal subtract = artificer.getCreditScore().subtract(new BigDecimal(type.getContent())); + artificer.setCreditScore(subtract); + artificerService.updateById(artificer); + MessageInfo messageInfo1=new MessageInfo(); + messageInfo1.setState("8"); + messageInfo1.setTitle(type.getTitle()); + messageInfo1.setContent("扣除信誉分:"+type.getContent()); + messageInfo1.setUserId(messageInfo.getByUserId()); + saveBody(messageInfo1); + UserEntity byId = userService.getById(artificer.getUserId()); + userService.sendMsg(byId.getPhone(),"touSu"); + String value = commonInfoService.findOne(385).getValue(); + BigDecimal minScore = new BigDecimal(value); + if(artificer.getCreditScore().doubleValue() params){ + Long userId = (Long)params.get("userId"); + Integer state = (Integer)params.get("state"); + Integer type = (Integer)params.get("type"); + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + .eq(userId!=null,"user_id", userId) + .eq(state!=null,"state", state) + .eq(type!=null,"type", type).orderByDesc("create_at") + ); + return new PageUtils(page); + } + + @Override + public PageUtils selectMessageLists(Map params){ + Long userId = (Long)params.get("userId"); + Integer state = (Integer)params.get("state"); + Integer type = (Integer)params.get("type"); + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + .eq(userId!=null,"user_id", userId) + .eq(state!=null,"state", state) + .eq("is_see", "0") + .eq(type!=null,"type", type).orderByDesc("create_at") + ); + return new PageUtils(page); + } + + @Override + public int saveBody(MessageInfo messageInfo){ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + messageInfo.setCreateAt(sdf.format(now)); + if(StringUtils.isNotBlank(messageInfo.getState()) && "7".equals(messageInfo.getState())){ + Risk risk=new Risk(); + risk.setUserId(Long.parseLong(messageInfo.getByUserId())); + risk.setContent("用户被举报:"+messageInfo.getContent()); + risk.setRiskType(6); + risk.setCreateTime(DateUtils.format(new Date())); + riskService.save(risk); + } + if(StringUtils.isNotEmpty(messageInfo.getState()) && "9".equals(messageInfo.getState())){ + String address = CommonMapUtils.getLocationToAddress(messageInfo.getTypeId(), messageInfo.getTypeName());//按坐标获取地理位置 + messageInfo.setContent(address); + int returncount = messageInfoDao.insert(messageInfo); + if(returncount == 1) { + //技师电话通知业务 + //accountId + String accountId = commonInfoService.findOne(428).getValue(); + //token + String token = commonInfoService.findOne(429).getValue(); + //templateId 模板id + String templateId = commonInfoService.findOne(431).getValue(); + //呼救手机号 + String calleeNumber = commonInfoService.findOne(432).getValue(); + //呼叫 + AppNotifyUtil.AppNotify(calleeNumber, accountId, token, templateId); + } + return returncount; + } + return messageInfoDao.insert(messageInfo); + } + + @Override + public Result insertArtificerLocation(MessageInfo messageInfo){ + messageInfo.setState("12"); + Artificer artificer = artificerService.selectArtificerByUserId(Long.parseLong(messageInfo.getUserId())); + if(artificer!=null){ + UserEntity userEntity = userService.selectUserById(artificer.getUserId()); + if(userEntity!=null && userEntity.getIsAuthentication()!=null || userEntity.getIsAuthentication()==2){ + if(StringUtils.isNotEmpty(messageInfo.getTypeId()) && StringUtils.isNotEmpty(messageInfo.getTypeName())){ + artificer.setLongitude(messageInfo.getTypeId()); + artificer.setLatitude(messageInfo.getTypeName()); + + JSONObject adInfo = CommonMapUtils.getLocationToAdInfo(messageInfo.getTypeId(), messageInfo.getTypeName());//根据坐标获取行政区划信息 + String address = adInfo.getString("address"); + messageInfo.setContent(address); + artificer.setAddress(address); + String city = adInfo.getString("city"); + artificer.setCity(city); + + artificer.setUpdateTime(DateUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss")); + artificerService.updateById(artificer); + messageInfo.setCreateAt(DateUtils.format(new Date())); + baseMapper.insert(messageInfo); + }else { + return Result.error("请检查定位权限"); + } + } + } + return Result.success(); + } + + + @Override + public int update(MessageInfo messageInfo){ + return messageInfoDao.updateById(messageInfo); + } + + @Override + public int delete(Long id){ + return messageInfoDao.deleteById(id); + } + + @Override + public MessageInfo selectMessageById(Long id){ + return messageInfoDao.selectById(id); + } + + @Override + public int updateSendState(Long userId, Integer state) { + return messageInfoDao.updateSendState(userId, state); + } + + @Override + public MessageInfo selectMessageByUserIdAndTime(Long userId,String time){ + return baseMapper.selectOne(new QueryWrapper().eq("state",10).eq("user_id",userId).like("create_at",time)); + } + + @Override + public Result selectSignList(Integer page,Integer limit,String address,String phone,Long userId){ + return Result.success().put("data",new PageUtils(baseMapper.selectSignList(new Page<>(page,limit),address,phone,userId))); + } + + @Override + public Result selectArtificerLocation(Integer page,Integer limit,String artificerName,String phone,Long userId){ + return Result.success().put("data",new PageUtils(baseMapper.selectArtificerLocation(new Page<>(page,limit),artificerName,phone,userId))); + } + + @Override + public Result selectArtificerScoreList(Integer page,Integer limit,String artificerName,String phone,Long userId){ + return Result.success().put("data",new PageUtils(baseMapper.selectArtificerScoreList(new Page<>(page,limit),artificerName,phone,userId))); + } + +} diff --git a/src/main/java/com/sqx/modules/monitor/MonitorWebSocket.java b/src/main/java/com/sqx/modules/monitor/MonitorWebSocket.java new file mode 100644 index 0000000..ac85372 --- /dev/null +++ b/src/main/java/com/sqx/modules/monitor/MonitorWebSocket.java @@ -0,0 +1,402 @@ +package com.sqx.modules.monitor; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.thread.ExecutorBuilder; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.sqx.common.utils.SpringContextUtils; +import com.sqx.ffmpeg.FFmpeg; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.message.controller.app.AppMessageController; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.entity.MessageInfoAudio; +import com.sqx.modules.message.service.MessageAudioService; +import com.sqx.modules.message.service.MessageService; +import com.sqx.ws.BaseInfoModel; +import com.sqx.ws.BaseModelEncoder; +import com.sqx.ws.HashMapEncoder; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import javax.websocket.*; +import javax.websocket.server.PathParam; +import javax.websocket.server.ServerEndpoint; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; + +/** + * WebSocket聊天实现 + */ +@Component +@Scope("prototype") +@ServerEndpoint(value = "/monitorWebSocket/{businessId}", encoders = { HashMapEncoder.class, BaseModelEncoder.class }) +public class MonitorWebSocket { + private static final Logger log = LoggerFactory.getLogger(MonitorWebSocket.class); + + //通过类似GET请求方式传递参数的方法(服务端采用第二种方法"WebSocketHandler"实现) + //websocket = new WebSocket("ws://127.0.0.1:18080/testWebsocket?id=23&name=Lebron"); + /** + * 在线人数 + */ + public static int onlineNumber = 0; + /** + * 以用户的id为key,WebSocket为对象保存起来 + */ + private static final Map clients = new ConcurrentHashMap<>(); + + private static final Map executorServiceMap = Maps.newHashMap(); + /** + * 会话 + */ + private Session session; + /** + * 用户id + */ + private String businessId; + + //此处不需要 +// //这里使用静态,让 service 属于类 +// private static ChatsContentService chatContentService; +// +// //注入的时候,给类的 service 注入 +// @Autowired +// public void setWxChatContentService(ChatsContentService chatContentService) { +// MapWebSocket.chatContentService = chatContentService; +// } + + private final CommonInfoService commonRepository = SpringContextUtils.getBean(CommonInfoService.class); + + private final FFmpeg fFmpeg = SpringContextUtils.getBean(FFmpeg.class); + + private final AppMessageController appMessageController = SpringContextUtils.getBean(AppMessageController.class); + + private final MessageService messageService = SpringContextUtils.getBean(MessageService.class); + + private final MessageAudioService messageAudioService = SpringContextUtils.getBean(MessageAudioService.class); + + + /** + * 建立连接 + * + * @param session + */ + @OnOpen + public void onOpen(@PathParam("businessId") String businessId, Session session) { + onlineNumber++; + log.info("客户端连接Id: {}", businessId); + this.businessId = businessId; + this.session = session; + log.info("有新连接加入! 当前在线设备: {}", onlineNumber); + try { + //把自己的信息加入到map当中去 + clients.remove(businessId); + clients.put(businessId, this); + /*sendMessageTo("恭喜你连接成功!",wxUserId);*/ + } catch (Exception e) { + log.info("{} 连接发生了错误", businessId); + } + } + + @OnError + public void onError(Session session, Throwable error) { + log.info("服务端发生了错误: {}", error.getMessage()); + } + + /** + * 连接关闭 + */ + @OnClose + public void onClose() { + onlineNumber--; + //webSockets.remove(this); + clients.remove(businessId); + log.info("有连接关闭! 当前在线设备: {}", onlineNumber); + } + + /** + * 接收客户端的消息,并把消息发送给所有连接的会话 + */ + @OnMessage + public void onMessage(String message) { + try { + log.info("客户端发来的消息:{}", message); + //解析聊天内容 + JSONObject jsonObject = JSON.parseObject(message); + String sendType = jsonObject.getString("sendType"); + String userId = jsonObject.getString("userId"); + String date = jsonObject.getString("date"); + String businessId = jsonObject.getString("businessId"); + + String http = commonRepository.findOne(19).getValue(); + String[] split = http.split("://"); + // 上传文件路径 + String baseAudioUploadPath = "/www/wwwroot/"+split[1]+"/file/uploadPath"; + + String baseFilePath = baseAudioUploadPath + "/" + "audio" + "/" + userId + "/" + date + "/" + businessId + "/"; + switch (sendType){ + case "creatFile": { + log.info("creatFile开始!"); + ExecutorService executor = ExecutorBuilder.create()//创建单线程线程池,让其慢慢执行 + .setCorePoolSize(1)//初始线程数为1 + .setMaxPoolSize(1)//最大线程为1 + .setKeepAliveTime(0)//线程存活时间 + .build(); + executorServiceMap.put(businessId,executor); + Callable call = () -> { + log.info("消息保存成功!"); + //String filePath = baseFilePath + "all.mp3"; + //FileUtil.touch(filePath); + //String url = StringUtils.replace(filePath,"/www/wwwroot/"+split[1],http); + String userName = jsonObject.getString("userName"); + String typeId = jsonObject.getString("typeId"); + String typeName = jsonObject.getString("typeName"); + + // + MessageInfo messageInfo = new MessageInfo(); + //messageInfo.setImage(url); + messageInfo.setState("9"); + messageInfo.setTypeId(typeId); + messageInfo.setTypeName(typeName); + messageInfo.setUserId(userId); + messageInfo.setUserName(userName); + messageInfo.setBatch(businessId); + appMessageController.insertMessage(messageInfo); + log.info("消息保存成功!"); + return true; + }; + executor.submit(call); + + + + //01,,不执行了 + //String fileName = jsonObject.getString("fileName"); + //String basePath = FileUploadUtils.getDefaultBaseDir(); + //log.info("基础地址:", basePath); + + //https://wx.sjajk.com/file/uploadPath\audios\333\2023-12-08\\3454e2c9-fc9f-4134-8c18-f50855e99ab2\ +// baseAudioUploadPath.replace(,); +// String url = http +fileName; + + + //创建地址 + //String userId = jsonObject.getString("userId"); + + sendMessageObject(session, BaseInfoModel.success("creatFile","加入队列成功!"));//回执,告知已记录 + break; + } +// case "startUpload": { +// //01 开始上传 +// //创建基本文件夹(临时存这里) +// FileUtil.mkdir("D:\\opt\\upload2" + businessId + File.separator + userId + File.separator); +// //创建文件列表index文件 +// //index = ` +// // 文件原名 2023年11月20日09:25:113 +// // 0001:xmsxmsdasdmsa +// // 0002:adadasdadasdd +// // 0003:adadasdadasd1 +// // ... +// // ` +// sendMessageObject(session, BaseInfoModel.success("startUpload","ok"));//准备工作做完可以开始上传了 +// //前端接到ok,开始02上传文件 +// break; +// } + case "uploadFileData": { + //02~文件上传(N次上传) + //将其扔进线程池里。 + ExecutorService executor = executorServiceMap.get(businessId); + Callable call = () -> { + //写入磁盘 + String currentUploadFragment = jsonObject.getString("currentUploadFragment");//序号 + String fileData = jsonObject.getString("fileData"); + if(StringUtils.isNotBlank(fileData)){ + byte[] fileByte = Base64.decode(fileData);//传过来的是base64,解析成字节码 + //创建文件 + String filePath = baseFilePath + currentUploadFragment + ".mp3"; + FileUtil.touch(filePath); + FileUtil.writeBytes(fileByte,filePath);//按字节码甩今文件里 + log.info("创建文件【{}】成功!",filePath); + } + //分批合并 + int currentUploadFragmentI = Integer.parseInt(currentUploadFragment); + int i = currentUploadFragmentI-1; + int cycle = i % 15; + int mergeFileName = (i / 15) + 1; + if(cycle == 0){ + log.info("分段创建:第{}段,创建的文件名为:{},合并后文件名为:{},", cycle,currentUploadFragmentI, mergeFileName); + //第一个,创建文件并保存 + //第一个文件,复制到all.mp3 + String filePath = baseFilePath + currentUploadFragment + ".mp3"; + String allFilePath = baseFilePath + "merge" + mergeFileName +".mp3"; + String url = StringUtils.replace(allFilePath,"/www/wwwroot/"+split[1],http); + FileUtil.copy(filePath, allFilePath, true);//拷贝 + //删除头一个文件 + FileUtil.del(filePath); + + //保存进子表里 + MessageInfoAudio messageInfoAudio = new MessageInfoAudio(); + messageInfoAudio.setBatch(businessId); + messageInfoAudio.setAuditContent(url); + messageInfoAudio.setSort(mergeFileName); + messageAudioService.save(messageInfoAudio); + + sendMessageObject(session, BaseInfoModel.success("uploadFileData","01创建:ok"));//上传文件的md5以代表上传成功 + return true; + }else{ + log.info("分段合并:第{}段,创建的文件名为:{},合并后文件名为:{},", cycle,currentUploadFragmentI, mergeFileName); + //中间的正常合并 + //合并all + String filePath = baseFilePath + currentUploadFragment + ".mp3"; + String allFilePath = baseFilePath + "merge" + mergeFileName +".mp3"; + String outallFilePath = baseFilePath + "merge" + mergeFileName +"_temp.mp3"; + //判断是不是有ALL,没有就做一个 + if(!FileUtil.exist(allFilePath)){ + //复制一个当前音频,跳到下一个周期 + FileUtil.copy(filePath,allFilePath,true); + FileUtil.del(filePath); + return true; + } + fFmpeg.montageAudio(allFilePath, filePath, outallFilePath); + + //合并完了之后 + //改名,删除合并完成的文件 + FileUtil.copy(outallFilePath,allFilePath,true); + FileUtil.del(filePath); + FileUtil.del(outallFilePath); + } + + //合并 +// if(StringUtils.equals(currentUploadFragment,"1")){ +// //第一个文件,复制到all.mp3 +// String filePath = baseFilePath + currentUploadFragment + ".mp3"; +// String allFilePath = baseFilePath + "all.mp3"; +// FileUtil.copy(filePath, allFilePath, true);//拷贝 +// //删除头一个文件 +// FileUtil.del(filePath); +// sendMessageObject(session, BaseInfoModel.success("uploadFileData","01创建:ok"));//上传文件的md5以代表上传成功 +// return true; +// }else{ +// //合并all +// String filePath = baseFilePath + currentUploadFragment + ".mp3"; +// String allFilePath = baseFilePath + "all.mp3"; +// String outallFilePath = baseFilePath + "all_temp.mp3"; +// //判断是不是有ALL,没有就做一个 +// if(!FileUtil.exist(allFilePath)){ +// //复制一个当前音频,跳到下一个周期 +// FileUtil.copy(filePath,allFilePath,true); +// FileUtil.del(filePath); +// return true; +// } +// fFmpeg.montageAudio(allFilePath, filePath, outallFilePath); +// +// //合并完了之后 +// //改名,删除合并完成的文件 +// FileUtil.copy(outallFilePath,allFilePath,true); +// FileUtil.del(filePath); +// FileUtil.del(outallFilePath); +// } + return true; + }; + executor.submit(call); + sendMessageObject(session, BaseInfoModel.success("uploadFileData","ok"));//上传文件的md5以代表上传成功 + break; + } + case "endUpload": { + ExecutorService executor = executorServiceMap.get(businessId); + Callable call = () -> { + log.info("执行完成!,队列的最末尾"); + String filePath = baseFilePath + "all.mp3"; + FileUtil.touch(filePath); + String url = StringUtils.replace(filePath,"/www/wwwroot/"+split[1],http); + //执行合并 + //查询出已经合并后的文件列表 + QueryWrapper qw = new QueryWrapper<>(); + qw.eq("batch",businessId); + List audioList = messageAudioService.list(qw); + List mergeList = Lists.newArrayList(); + for (MessageInfoAudio audio: audioList){ + //转换成物理地址 + String fileUrl = audio.getAuditContent(); + String path = StringUtils.replace(fileUrl,http, "/www/wwwroot/"+split[1]); + mergeList.add(path); + } + fFmpeg.mergeAllAudio(mergeList,filePath); + UpdateWrapper uw = new UpdateWrapper<>(); + uw.set("image",url); + uw.eq("batch",businessId); + messageService.update(uw); + return true; + }; + executor.submit(call); + //03手动结束上传 + //暂时还不知道干点啥,,空着吧 + //立刻合并剩下的内容 + sendMessageObject(session, BaseInfoModel.success("endUpload","ok"));//准备工作做完可以开始上传了 + break; + } + default: { + log.info("意外的解析数据:{}", message); + } + } + } catch (Exception e) { + log.info("发生了错误了",e); + } + } + + /** + * 发送消息,实践表明,每次浏览器刷新,session会发生变化。 + * @param session + * @param message + */ + public static void sendMessage(Session session, String message) throws IOException { + try { +// session.getBasicRemote().sendText(String.format("%s (From Server,Session ID=%s)",message,session.getId())); + session.getBasicRemote().sendText(message); + log.info("ws发生回执: {}",message); + } catch (IOException e) { + log.error("发送消息出错:{}", e.getMessage()); + log.error(e.getMessage(),e); + } + } + + public static void sendMessageObject(Session session, Object message) throws IOException { + try { + session.getBasicRemote().sendObject(message); + log.info("ws发生回执: {}",message); + } catch (IOException | EncodeException e) { + log.error("发送消息出错:{}", e.getMessage()); + log.error(e.getMessage(),e); + } + } + + + public static synchronized int getOnlineCount() { + return onlineNumber; + } + + public static void main(String[] args) { + for (int currentUploadFragment = 1; currentUploadFragment <= 1000; currentUploadFragment++) { + int i = currentUploadFragment-1; + int cycle = i % 15; + int mergeFileName = (i / 15) + 1; + if(cycle == 0){ + System.out.println("创建文件:" + i + ",合并后文件名为:" + mergeFileName + ",合并生命周期:" + cycle); + }else{ + System.out.println("合并文件:" + i + ",合并后文件名为:" + mergeFileName + ",合并生命周期:" + cycle); + } + } + } + + +} diff --git a/src/main/java/com/sqx/modules/pay/config/AliPayConstants.java b/src/main/java/com/sqx/modules/pay/config/AliPayConstants.java new file mode 100644 index 0000000..0d074cb --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/config/AliPayConstants.java @@ -0,0 +1,44 @@ +package com.sqx.modules.pay.config; + +/** + * @author WALKMAN + * @Description: 支付宝支付参数 + **/ +public class AliPayConstants { + + /** + * 支付宝环境 + */ + public static final String REQUEST_URL = "https://openapi.alipay.com/gateway.do"; + + /** + * 编码格式 + */ + public static String CHARSET = "UTF-8"; + + /** + * 参数格式 + */ + public static String FORMAT = "json"; + + /** + * 加密方式 + */ + public static String SIGNTYPE = "RSA2"; + + /** + * 支付类型-提现(固定) + */ + public static String PAY_TYPE = "ALIPAY_LOGONID"; + + /** + * 平台和支付宝签约属性-固定值 + */ + public static String PRODUCT_CODE = "QUICK_WAP_WAY"; + + /** + * 支付宝提现成功状态 + */ + public static String SUCCESS_CODE = "10000"; + +} diff --git a/src/main/java/com/sqx/modules/pay/config/WXConfig.java b/src/main/java/com/sqx/modules/pay/config/WXConfig.java new file mode 100644 index 0000000..1d4fd85 --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/config/WXConfig.java @@ -0,0 +1,89 @@ +package com.sqx.modules.pay.config; + +import com.github.wxpay.sdk.WXPayConfig; +import lombok.Data; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +/** + * @author fang + * @date 2020/2/26 + */ +@Data +public class WXConfig implements WXPayConfig { + private byte[] certData; + + public String appId; + public String key; + public String mchId; + + /*public WXConfigUtil() throws Exception { + String certPath = ClassUtils.getDefaultClassLoader().getResource("").getPath()+"/weixin/apiclient_cert.p12";//从微信商户平台下载的安全证书存放的路径 + File file = new File(certPath); + InputStream certStream = new FileInputStream(file); + this.certData = new byte[(int) file.length()]; + certStream.read(this.certData); + certStream.close(); + }*/ + + public byte[] getCertData() { + return certData; + } + + public void setCertData(byte[] certData) { + this.certData = certData; + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public void setKey(String key) { + this.key = key; + } + + public String getMchId() { + return mchId; + } + + public void setMchId(String mchId) { + this.mchId = mchId; + } + + @Override + public String getAppID() { + return this.appId; + } + + //parnerid,商户号 + @Override + public String getMchID() { + return this.mchId; + } + + @Override + public String getKey() { + return this.key; + } + + @Override + public InputStream getCertStream() { + ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData); + return certBis; + } + + @Override + public int getHttpConnectTimeoutMs() { + return 8000; + } + + @Override + public int getHttpReadTimeoutMs() { + return 10000; + } +} diff --git a/src/main/java/com/sqx/modules/pay/controller/CashController.java b/src/main/java/com/sqx/modules/pay/controller/CashController.java new file mode 100644 index 0000000..61b6185 --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/controller/CashController.java @@ -0,0 +1,520 @@ +package com.sqx.modules.pay.controller; + + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.alipay.api.AlipayApiException; +import com.alipay.api.AlipayClient; +import com.alipay.api.CertAlipayRequest; +import com.alipay.api.DefaultAlipayClient; +import com.alipay.api.request.AlipayFundTransToaccountTransferRequest; +import com.alipay.api.request.AlipayFundTransUniTransferRequest; +import com.alipay.api.response.AlipayFundTransToaccountTransferResponse; +import com.alipay.api.response.AlipayFundTransUniTransferResponse; +import com.google.common.base.Charsets; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.entity.UserMoneyDetails; +import com.sqx.modules.app.service.UserMoneyDetailsService; +import com.sqx.modules.app.service.UserMoneyService; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.invite.dao.InviteMoneyDao; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.service.MessageService; +import com.sqx.modules.pay.config.AliPayConstants; +import com.sqx.modules.pay.entity.AliPayWithdrawModel; +import com.sqx.modules.pay.entity.CashOut; +import com.sqx.modules.pay.service.CashOutService; +import com.sqx.modules.pay.service.PayDetailsService; +import com.sqx.modules.utils.AmountCalUtils; +import com.sqx.modules.utils.HttpClientUtil; +import com.sqx.modules.utils.excel.ExcelData; +import com.sqx.modules.utils.excel.ExportExcelUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import lombok.val; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +/** + * @author fang + * @date 2020/5/15 + */ +@Slf4j +@RestController +@Api(value = "管理平台", tags = {"管理平台"}) +@RequestMapping(value = "/cash") +public class CashController { + + /** 充值记录 */ + @Autowired + private PayDetailsService payDetailsService; + /** 提现记录 */ + @Autowired + private CashOutService cashOutService; + /** app用户 */ + @Autowired + private UserService userService; + /** 通用配置 */ + @Autowired + private CommonInfoService commonInfoService; + @Autowired + private UserMoneyDetailsService userMoneyDetailsService; + @Autowired + private MessageService messageService; + @Autowired + private UserMoneyService userMoneyService; + private ReentrantReadWriteLock reentrantReadWriteLock=new ReentrantReadWriteLock(true); + + @RequestMapping(value = "/sendMsgByUserId", method = RequestMethod.GET) + @ApiOperation("管理平台主动推送消息(指定用户)") + @ResponseBody + public Result sendMsgByUserId(String title, String content, Long userId){ + UserEntity user = userService.queryByUserId(userId); + send(user,title,content); + return Result.success(); + } + + + @RequestMapping(value = "/sendMsg", method = RequestMethod.GET) + @ApiOperation("管理平台主动推送消息") + @ResponseBody + public Result sendMsg(String title, String content, String phone, Integer flag){ + if(flag==1){ + //根据手机号推送 + UserEntity userByPhone = userService.queryByPhone(phone); + if(null==userByPhone){ + return Result.error(-100,"手机号不存在!"); + } + send(userByPhone,title,content); + }else{ + //所有人推送 + List userInfos = userService.list(); + //用户数量较大 使用多线程推送 根据用户数量进行拆分 同时按照3个线程进行推送 + int count = userInfos.size() / 3; + new Thread(() -> { + for(int i=0 ;i { + for(int i=count ;i { + for(int i=count*2 ;i map=new HashMap<>(); + map.put("page",page); + map.put("limit",limit); + map.put("zhifubaoName",zhifubaoName); + map.put("zhifubao",zhifubao); + map.put("userId",userId); + map.put("userType",userType); + PageUtils pageUtils = cashOutService.selectCashOutList(map); + return Result.success().put("data",pageUtils); + }*/ + + @RequestMapping(value = "/selectPayDetails", method = RequestMethod.GET) + @ApiOperation("查询提现记录列表") + @ResponseBody + public Result selectHelpProfit(Integer page, Integer limit,String userName, String zhifubaoName, String zhifubao, String userId, Integer state, Integer userType, String startTime, String endTime,String phone) { + PageUtils pageUtils = cashOutService.selectCashOutList(page, limit,userName, zhifubaoName, zhifubao, userId, state, userType,startTime,endTime,phone); + return Result.success().put("data", pageUtils); + } + + @RequestMapping(value = "/excelPayDetails", method = RequestMethod.GET) + @ApiOperation("查询提现记录列表") + @ResponseBody + public void excelPayDetails(String userName ,String zhifubaoName, String zhifubao, String userId, Integer state, Integer userType, String startTime, String endTime,String phone, HttpServletResponse response)throws Exception { + ExcelData data = cashOutService.excelPayDetails(userName,zhifubaoName, zhifubao, userId, state, userType,startTime,endTime,phone); + ExportExcelUtils.exportExcel(response,"财务列表.xlsx",data); + } + + + @ApiOperation("财务提现统计") + @GetMapping("/statisticsCashMoney") + public Result statisticsMoney(String time, Integer flag){ + Map map=new HashMap<>(); + map.put("sumCount",cashOutService.selectCashCountByClassify(time, flag, null,null)); + map.put("yzzCount",cashOutService.selectCashCountByClassify(time, flag, null,1)); + map.put("dzzCount",cashOutService.selectCashCountByClassify(time, flag, null,0)); + map.put("ysbCount",cashOutService.selectCashCountByClassify(time, flag, null,-1)); + + map.put("zfbSumCount",cashOutService.selectCashCountByClassify(time, flag, 1,null)); + map.put("zfbYzzCount",cashOutService.selectCashCountByClassify(time, flag, 1,1)); + map.put("zfbDzzCount",cashOutService.selectCashCountByClassify(time, flag, 1,0)); + map.put("zfbYsbCount",cashOutService.selectCashCountByClassify(time, flag, 1,-1)); + + map.put("yhkSumCount",cashOutService.selectCashCountByClassify(time, flag, 2,null)); + map.put("yhkYzzCount",cashOutService.selectCashCountByClassify(time, flag, 2,1)); + map.put("yhkDzzCount",cashOutService.selectCashCountByClassify(time, flag, 2,0)); + map.put("yhkYsbCount",cashOutService.selectCashCountByClassify(time, flag, 2,-1)); + + map.put("sumMoney",cashOutService.selectCashMoneyByClassify(time, flag, null,null)); + map.put("yzzMoney",cashOutService.selectCashMoneyByClassify(time, flag, null,1)); + map.put("dzzMoney",cashOutService.selectCashMoneyByClassify(time, flag, null,0)); + map.put("ysbMoney",cashOutService.selectCashMoneyByClassify(time, flag, null,-1)); + + map.put("zfbSumMoney",cashOutService.selectCashMoneyByClassify(time, flag, 1,null)); + map.put("zfbYzzMoney",cashOutService.selectCashMoneyByClassify(time, flag, 1,1)); + map.put("zfbDzzMoney",cashOutService.selectCashMoneyByClassify(time, flag, 1,0)); + map.put("zfbYsbMoney",cashOutService.selectCashMoneyByClassify(time, flag, 1,-1)); + + map.put("yhkSumMoney",cashOutService.selectCashMoneyByClassify(time, flag, 2,null)); + map.put("yhkYzzMoney",cashOutService.selectCashMoneyByClassify(time, flag, 2,1)); + map.put("yhkDzzMoney",cashOutService.selectCashMoneyByClassify(time, flag, 2,0)); + map.put("yhkYsbMoney",cashOutService.selectCashMoneyByClassify(time, flag, 2,-1)); + + + return Result.success().put("data",map); + } + + + @ApiOperation("充值统计") + @GetMapping("/payMember") + public Result payMember(String time, Integer flag, Integer payClassify){ + //1app微信 2微信公众号 3微信小程序 4支付宝 + Double sumMoney = payDetailsService.selectSumPayByClassify(time, flag, null,null); + Double weiXinGZHMoney = payDetailsService.selectSumPayByClassify(time, flag, 2, null); + Double weiXinXCXMoney = payDetailsService.selectSumPayByClassify(time, flag, 3, null); + Double weiXinAppMoney = payDetailsService.selectSumPayByClassify(time, flag, 1, null); + Double zhiFuBaoMoney = payDetailsService.selectSumPayByClassify(time, flag, 4, null); + Double xiTongMoney = payDetailsService.selectSumPayByClassify(time, flag, 5, null); + Map map = new HashMap<>(); + map.put("sumMoney", sumMoney); + map.put("xiTongMoney",xiTongMoney); + map.put("weiXinGZHMoney",weiXinGZHMoney); + map.put("weiXinXCXMoney",weiXinXCXMoney); + map.put("zhiFuBaoMoney",zhiFuBaoMoney); + map.put("weiXinMoney",BigDecimal.valueOf(weiXinAppMoney)); + + return Result.success().put("data", map); + } + + +/* + @ApiOperation("收入统计") + @GetMapping("/statisticsIncomeMoney") + public Result statisticsIncomeMoney(String time, Integer flag){ + Double sumMoney = ordersService.statisticsIncomeMoney(time, flag, null); + Double courseMoney = ordersService.statisticsIncomeMoney(time, flag, 1); + Double vipMoney = ordersService.statisticsIncomeMoney(time, flag, 2); + Map map=new HashMap<>(); + map.put("sumMoney",sumMoney==null?0.00:sumMoney); + map.put("courseMoney",courseMoney==null?0.00:courseMoney); + map.put("vipMoney",vipMoney==null?0.00:vipMoney); + return Result.success().put("data",map); + } +*/ + + + @RequestMapping(value = "/alipay/{cashId}", method = RequestMethod.POST) + @ApiOperation("管理平台确认提现") + @ResponseBody + public Result alipayPay(@PathVariable Long cashId) { + reentrantReadWriteLock.writeLock().lock(); + try { + //提现订单 + CashOut one = cashOutService.selectById(cashId); + log.error("进来了!!!"); + //订单记录不为空 + if (one == null) { + return Result.error("提现记录不存在!"); + } + //订单状态不是待转帐 + if (one.getState()!=0) { + return Result.error(9999, one.getZhifubaoName() + "转账失败!原因是用户已转账"); + } + //订单编号为空 + if(StringUtils.isEmpty(one.getOrderNumber())){ + one.setOrderNumber(String.valueOf(System.currentTimeMillis())); + } + //配置文件对象 + CommonInfo commonInfo = commonInfoService.findOne(98); + + CommonInfo name = commonInfoService.findOne(12); + if (commonInfo.getValue() != null && commonInfo.getValue().equals("1")) { + + try { + CertAlipayRequest certAlipayRequest = new CertAlipayRequest(); + certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); //gateway:支付宝网关(固定)https://openapi.alipay.com/gateway.do + certAlipayRequest.setAppId(commonInfoService.findOne(63).getValue()); //APPID 即创建应用后生成,详情见创建应用并获取 APPID + certAlipayRequest.setPrivateKey(commonInfoService.findOne(65).getValue()); //开发者应用私钥,由开发者自己生成 + certAlipayRequest.setFormat("json"); //参数返回格式,只支持 json 格式 + certAlipayRequest.setCharset(AliPayConstants.CHARSET); //请求和签名使用的字符编码格式,支持 GBK和 UTF-8 + certAlipayRequest.setSignType(AliPayConstants.SIGNTYPE); //商户生成签名字符串所使用的签名算法类型,目前支持 RSA2 和 RSA,推荐商家使用 RSA2。 + CommonInfo url = commonInfoService.findOne(200); + certAlipayRequest.setCertPath(url.getValue()+"/appCertPublicKey.crt"); //应用公钥证书路径(app_cert_path 文件绝对路径) + certAlipayRequest.setAlipayPublicCertPath(url.getValue()+"/alipayCertPublicKey_RSA2.crt"); //支付宝公钥证书文件路径(alipay_cert_path 文件绝对路径) + certAlipayRequest.setRootCertPath(url.getValue()+"/alipayRootCert.crt"); //支付宝CA根证书文件路径(alipay_root_cert_path 文件绝对路径) + AlipayClient alipayClient = new DefaultAlipayClient(certAlipayRequest); + AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest(); + request.setBizContent("{" + + "\"out_biz_no\":\""+one.getOrderNumber()+"\"," + //订单编号 + "\"trans_amount\":"+new BigDecimal(one.getMoney())+"," + //转账金额 + "\"product_code\":\"TRANS_ACCOUNT_NO_PWD\"," + + "\"biz_scene\":\"DIRECT_TRANSFER\"," + + "\"order_title\":\""+name.getValue() + "佣金结算"+"\"," + + "\"payee_info\":{" + + "\"identity\":\""+one.getZhifubao()+"\"," + //支付宝账号 + "\"identity_type\":\"ALIPAY_LOGON_ID\"," + + "\"name\":\""+one.getZhifubaoName()+"\"," + //支付宝名称 + "}," + + "\"remark\":\""+name.getValue() + "佣金结算"+"\"" + + "}"); + AlipayFundTransUniTransferResponse response = null; + response = alipayClient.certificateExecute(request); + log.error("支付宝转账返回值:"+response.getBody()); + //如果转账成功 + if (AliPayConstants.SUCCESS_CODE.equalsIgnoreCase(response.getCode())) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + //修改状态为转账成功 + one.setState(1); + //设置转账时间 + one.setOutAt(sdf.format(new Date())); + //更新转账订单 + cashOutService.update(one); + //查询用户 + UserEntity userInfo=userService.queryByUserId(one.getUserId()); + cashOutService.cashOutSuccess(userInfo, one.getOutAt(), one.getMoney(), one.getZhifubao(), commonInfoService.findOne(19).getValue()); + + return Result.success(one.getZhifubaoName() + "转账成功"); + } else { + return Result.error(9999, one.getZhifubaoName() + "转账失败!" + response.getSubMsg()); + } + } catch (AlipayApiException e) { + log.error("零钱提现异常原因:" + e.getMessage()); + e.printStackTrace(); + return Result.error(9999, one.getZhifubaoName() + "转账失败!" + e.getMessage()); + } + }else if (commonInfo.getValue() != null && commonInfo.getValue().equals("2")) { + AlipayClient alipayClient = new DefaultAlipayClient(AliPayConstants.REQUEST_URL, + commonInfoService.findOne(63).getValue(), commonInfoService.findOne(65).getValue(), AliPayConstants.FORMAT, + AliPayConstants.CHARSET, commonInfoService.findOne(64).getValue(), AliPayConstants.SIGNTYPE); + val aliPayWithdrawModel = AliPayWithdrawModel.builder() + .out_biz_no(one.getOrderNumber()) + .amount(new BigDecimal(one.getMoney())) + .payee_account(one.getZhifubao()) + .payee_real_name(one.getZhifubaoName()) + .payee_type(AliPayConstants.PAY_TYPE) + .remark(name.getValue()) + .build(); + String json = JSON.toJSONString(aliPayWithdrawModel); + //实例化连接对象 + AlipayFundTransToaccountTransferRequest withdrawRequest = new AlipayFundTransToaccountTransferRequest(); + withdrawRequest.setBizContent(json); + try { + AlipayFundTransToaccountTransferResponse response = alipayClient.execute(withdrawRequest); + if (AliPayConstants.SUCCESS_CODE.equalsIgnoreCase(response.getCode())) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + //修改状态为转账成功 + one.setState(1); + //设置转账时间 + one.setOutAt(sdf.format(new Date())); + //更新转账订单 + cashOutService.update(one); + //查询用户 + UserEntity userInfo=userService.queryByUserId(one.getUserId()); + cashOutService.cashOutSuccess(userInfo, one.getOutAt(), one.getMoney(), one.getZhifubao(), commonInfoService.findOne(19).getValue()); + return Result.success(one.getZhifubaoName() + "转账成功"); + } else { + return Result.error(9999, one.getZhifubaoName() + "转账失败!" + response.getSubMsg()); + } + } catch (AlipayApiException e) { + log.error("零钱提现异常原因:" + e.getMessage()); + e.printStackTrace(); + return Result.error(9999, one.getZhifubaoName() + "转账失败!" + e.getMessage()); + + } + }else{ + //人工转账后改变状态的 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + one.setState(1); + one.setOutAt(sdf.format(now)); + cashOutService.update(one); + UserEntity userInfo=userService.queryByUserId(one.getUserId()); + cashOutService.cashOutSuccess(userInfo, one.getOutAt(), one.getMoney(), one.getZhifubao(),commonInfoService.findOne(19).getValue()); + return Result.success(one.getZhifubaoName() + "转账成功"); + } + }catch (Exception e){ + e.printStackTrace(); + log.error("转账异常"+e.getMessage()); + }finally { + reentrantReadWriteLock.writeLock().unlock(); + } + return Result.error("系统繁忙,请稍后再试!"); + } + + @PostMapping("/offlineCash") + @ApiOperation("线下转账") + public Result offlineCash(String cashIds){ + for(String cashIdStr:cashIds.split(",")){ + Long cashId=Long.parseLong(cashIdStr); + //提现订单 + CashOut one = cashOutService.selectById(cashId); + log.error("进来了!!!"); + //订单记录不为空 + if (one == null) { + continue; + } + //订单状态不是待转帐 + if (one.getState()!=0) { + continue; + } + //订单编号为空 + if(StringUtils.isEmpty(one.getOrderNumber())){ + one.setOrderNumber(String.valueOf(System.currentTimeMillis())); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + one.setState(1); + one.setOutAt(sdf.format(now)); + cashOutService.update(one); + UserEntity userInfo=userService.queryByUserId(one.getUserId()); + cashOutService.cashOutSuccess(userInfo, one.getOutAt(), one.getMoney(), one.getZhifubao(),commonInfoService.findOne(19).getValue()); + } + + return Result.success(); + } + + + @RequestMapping(value = "/refund/{cashId}", method = RequestMethod.POST) + @ApiOperation("管理平台退款") + @ResponseBody + public Result refund(@PathVariable("cashId") Long cashId,String content) { + CashOut one = cashOutService.selectById(cashId); + if (one == null) { + return Result.error("提现信息不存在"); + } + //将状态为待提现的退款 + if(one.getState()!=0){ + return Result.error(-100,"状态错误,已经转账或退款!"); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + //修改提现订单状态 + one.setState(-1); + one.setRefund(content); + one.setOutAt(sdf.format(now)); + cashOutService.update(one); + Long userId = one.getUserId(); + UserEntity userInfo = userService.queryByUserId(userId); + if(userInfo!=null){ + //将金额退还 + userMoneyService.updateMoney(1,userId,one.getRate()); + UserMoneyDetails userMoneyDetails=new UserMoneyDetails(); + userMoneyDetails.setUserId(userInfo.getUserId()); + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(userInfo.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setTitle("[退款提醒]退款:"+one.getRate()); + userMoneyDetails.setContent("退款原因:"+content); + userMoneyDetails.setType(1); + userMoneyDetails.setMoney(BigDecimal.valueOf(one.getRate())); + userMoneyDetails.setCreateTime(sdf.format(now)); + userMoneyDetailsService.save(userMoneyDetails); + + + cashOutService.refundSuccess(userInfo, one.getOutAt(), one.getMoney(), commonInfoService.findOne(19).getValue(),content); + } + return Result.success(); + } + + @GetMapping(value = "/cashMoney") + @ApiOperation("发起提现") + public Result cashMoney(Long userId, Double money,Integer userType,Integer classify) + { + return cashOutService.cashMoney(userId,money,userType,classify); + } + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/pay/controller/PayClassifyController.java b/src/main/java/com/sqx/modules/pay/controller/PayClassifyController.java new file mode 100644 index 0000000..f3dc51a --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/controller/PayClassifyController.java @@ -0,0 +1,80 @@ +package com.sqx.modules.pay.controller; + + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.coupon.service.CouponService; +import com.sqx.modules.pay.entity.PayClassify; +import com.sqx.modules.pay.service.PayClassifyService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +/** + * @author fang + * @date 2022/4/16 + */ +@Slf4j +@RestController +@Api(value = "充值分类", tags = {"充值分类"}) +@RequestMapping(value = "/payClassify") +public class PayClassifyController { + + @Autowired + private PayClassifyService payClassifyService; + @Autowired + private CouponService couponService; + + + @PostMapping("/insertPayClassify") + @ApiOperation("添加充值分类") + public Result insertPayClassify(@RequestBody PayClassify payClassify){ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + payClassify.setCreateTime(sdf.format(new Date())); + payClassifyService.save(payClassify); + return Result.success(); + } + + @PostMapping("/updatePayClassify") + @ApiOperation("修改充值分类") + public Result updatePayClassify(@RequestBody PayClassify payClassify){ + payClassifyService.updateById(payClassify); + if(payClassify.getCouponId()==null){ + payClassifyService.updatePayClassifyCouponId(payClassify.getPayClassifyId()); + } + return Result.success(); + } + + @PostMapping("/deletePayClassify") + @ApiOperation("删除充值分类") + public Result deletePayClassify(Long payClassifyId){ + payClassifyService.removeById(payClassifyId); + return Result.success(); + } + + @GetMapping("/selectPayClassifyList") + @ApiOperation("查询充值分类") + public Result selectPayClassifyList(Integer page,Integer limit){ + Page pages=new Page<>(page,limit); + IPage page1 = payClassifyService.page(pages); + List records = page1.getRecords(); + for(PayClassify payClassify:records){ + if(payClassify.getCouponId()!=null){ + payClassify.setCoupon(couponService.getById(payClassify.getCouponId())); + } + } + return Result.success().put("data",new PageUtils(page1)); + } + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/pay/controller/app/AliPayController.java b/src/main/java/com/sqx/modules/pay/controller/app/AliPayController.java new file mode 100644 index 0000000..f11b14b --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/controller/app/AliPayController.java @@ -0,0 +1,994 @@ +package com.sqx.modules.pay.controller.app; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alipay.api.AlipayApiException; +import com.alipay.api.AlipayClient; +import com.alipay.api.CertAlipayRequest; +import com.alipay.api.DefaultAlipayClient; +import com.alipay.api.domain.AlipayTradeAppPayModel; +import com.alipay.api.domain.AlipayTradeRefundModel; +import com.alipay.api.internal.util.AlipaySignature; +import com.alipay.api.request.AlipayTradeAppPayRequest; +import com.alipay.api.request.AlipayTradeRefundRequest; +import com.alipay.api.request.AlipayTradeWapPayRequest; +import com.alipay.api.response.AlipayTradeAppPayResponse; +import com.alipay.api.response.AlipayTradeRefundResponse; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.dao.UserMoneyDao; +import com.sqx.modules.app.dao.UserVipDao; +import com.sqx.modules.app.dao.VipDetailsDao; +import com.sqx.modules.app.entity.*; +import com.sqx.modules.app.service.UserCertificationService; +import com.sqx.modules.app.service.UserMoneyArtificerService; +import com.sqx.modules.app.service.UserMoneyDetailsService; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.dao.OrdersDao; +import com.sqx.modules.artificer.entity.*; +import com.sqx.modules.artificer.service.*; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.consortia.entity.Consortia; +import com.sqx.modules.consortia.service.ConsortiaService; +import com.sqx.modules.coupon.entity.Coupon; +import com.sqx.modules.coupon.entity.CouponIssue; +import com.sqx.modules.coupon.entity.CouponUser; +import com.sqx.modules.coupon.service.CouponIssueService; +import com.sqx.modules.coupon.service.CouponService; +import com.sqx.modules.coupon.service.CouponUserService; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.service.MessageService; +import com.sqx.modules.pay.config.AliPayConstants; +import com.sqx.modules.pay.dao.PayDetailsDao; +import com.sqx.modules.pay.entity.PayClassify; +import com.sqx.modules.pay.entity.PayDetails; +import com.sqx.modules.pay.service.PayClassifyService; +import com.sqx.modules.utils.AmountCalUtils; +import com.sqx.modules.utils.SenInfoCheckUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import jodd.util.StringUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 支付宝支付处理--暂不做同步处理、回调方式使用异步 + */ +@Slf4j +@RestController +@Api(value = "支付宝支付", tags = {"支付宝支付"}) +@RequestMapping("/app/aliPay") +public class AliPayController { + + @Autowired + private CommonInfoService commonInfoService; + @Autowired + private UserMoneyDao userMoneyDao; + @Autowired + private PayDetailsDao payDetailsDao; + @Autowired + private UserMoneyDetailsService userMoneyDetailsService; + @Autowired + private UserService userService; + @Autowired + private OrdersService ordersService; + @Autowired + private OrdersDao ordersDao; + @Autowired + private ArtificerService artificerService; + @Autowired + private OrdersMassageService ordersMassageService; + @Autowired + private MassageTypeService massageTypeService; + @Autowired + private PayClassifyService payClassifyService; + @Autowired + private CouponUserService couponUserService; + @Autowired + private CouponService couponService; + @Autowired + private CouponIssueService couponIssueService; + @Autowired + private VipDetailsDao vipDetailsDao; + @Autowired + private UserVipDao userVipDao; + @Autowired + private MessageService messageService; + @Autowired + private ConsortiaService consortiaService; + @Autowired + private UserMoneyArtificerService userMoneyArtificerService; + @Autowired + private ArtificerTimeService artificerTimeService; + private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + + @RequestMapping(value = "/notifyApp", method = RequestMethod.POST) + @Transactional(rollbackFor = Exception.class) + public void notifyApp(HttpServletRequest request, HttpServletResponse response) { + //获取支付宝POST过来反馈信息 + Map params = new HashMap(); + Map requestParams = request.getParameterMap(); + for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext(); ) { + String name = (String) iter.next(); + String[] values = (String[]) requestParams.get(name); + String valueStr = ""; + for (int i = 0; i < values.length; i++) { + valueStr = (i == values.length - 1) ? valueStr + values[i] + : valueStr + values[i] + ","; + } + //乱码解决,这段代码在出现乱码时使用。 + //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8"); + params.put(name, valueStr); + } + try { + log.info("回调成功!!!"); + boolean flag = AlipaySignature.rsaCheckV1(params, commonInfoService.findOne(64).getValue(), AliPayConstants.CHARSET, "RSA2"); + log.info(flag + "回调验证信息"); + if (flag) { + String tradeStatus = params.get("trade_status"); + if ("TRADE_SUCCESS".equals(tradeStatus) || "TRADE_FINISHED".equals(tradeStatus)) { + + //支付宝返回的订单编号 + String outTradeNo = params.get("out_trade_no"); + log.error(outTradeNo); + //支付宝支付单号 + String tradeNo = params.get("trade_no"); + PayDetails payDetails = payDetailsDao.selectByOrderId(outTradeNo); + if (payDetails.getState() == 0) { + payDetailsDao.updateState(payDetails.getId(), 1, sdf.format(new Date()), tradeNo); + if (payDetails.getType() == 1) { + Orders orders = ordersService.selectOrdersByOrderNo(payDetails.getOrderId()); + orders.setStatus(2); + orders.setPayWay(6); + orders.setPayTime(sdf.format(new Date())); + + BigDecimal pingMoney=orders.getPayMoney(); + UserEntity user = userService.selectUserById(orders.getUserId()); + + UserEntity oneUser = userService.queryByInvitationCode(user.getInviterCode()); + + BigDecimal oneUserMoney=BigDecimal.ZERO; + if(oneUser!=null && oneUser.getIsAgency()!=null && oneUser.getIsAgency()==1){ + orders.setOneUserId(oneUser.getUserId()); + orders.setOneUserName(oneUser.getUserName()); + oneUserMoney=pingMoney.multiply(oneUser.getUserRate()); + + } + + Artificer artificer = artificerService.getById(orders.getArtificerId()); + + UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); + + UserEntity oneArtificerUser = userService.queryByInvitationCode(artificerUser.getInviterCode()); + + BigDecimal oneArtificerMoney=BigDecimal.ZERO; + if(oneArtificerUser!=null && oneArtificerUser.getIsAgency()!=null && oneArtificerUser.getIsAgency()==1){ + orders.setOneArtificerUserId(oneArtificerUser.getUserId()); + orders.setOneArtificerUserName(oneArtificerUser.getUserName()); + oneArtificerMoney=pingMoney.multiply(oneArtificerUser.getShopRate()); + + } + + BigDecimal shopMoney=BigDecimal.ZERO; + if(artificerUser.getConsortiaId()!=null){ + Consortia consortia = consortiaService.getById(artificerUser.getConsortiaId()); + if(consortia!=null && consortia.getUserId()!=null){ + UserEntity consortiaUser = userService.getById(consortia.getUserId()); + if(consortiaUser!=null){ + shopMoney = pingMoney.multiply(consortia.getRate()); + orders.setConsortiaId(consortia.getConsortiaId()); + orders.setShopUserId(consortiaUser.getUserId()); + orders.setShopUserName(consortiaUser.getUserName()); + + } + } + } + pingMoney=pingMoney.subtract(orders.getArtificerMoney()); + pingMoney=pingMoney.subtract(oneUserMoney); + pingMoney=pingMoney.subtract(oneArtificerMoney); + pingMoney=pingMoney.subtract(shopMoney); + orders.setShopMoney(shopMoney); + orders.setOneUserMoney(oneUserMoney); + orders.setOneArtificerMoney(oneArtificerMoney); + orders.setPingMoney(pingMoney); + + ordersService.updateById(orders); + if(orders.getParentId()!=null && orders.getParentId()!=0){ + String value1 = commonInfoService.findOne(395).getValue(); + OrdersMassage ordersMassage = ordersMassageService.getOne(new QueryWrapper().eq("orders_id", orders.getOrdersId())); + MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId()); + Integer duration=massageType.getDuration(); + Calendar calendar=Calendar.getInstance(); + if("是".equals(value1)){ + + ArtificerTime artificerTime = artificerTimeService.getOne(new QueryWrapper().eq("orders_id", orders.getParentId()).last(" order by artificer_time_id desc limit 1 ")); + String serveTime = artificerTime.getArtificerDate()+" "+artificerTime.getArtificerTime(); + String value = commonInfoService.findOne(392).getValue(); + int minute = Integer.parseInt(value); + int i=1; + if(duration%minute==0){ + i=duration/minute; + }else{ + i=duration/minute; + i++; + } + + SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date parse = null; + try { + parse = sdf1.parse(serveTime); + } catch (ParseException e) { + e.printStackTrace(); + } + + calendar.setTime(parse); + for(int j=0;j().eq("orders_id", orders1.getOrdersId())); + massageType = massageTypeService.getById(ordersMassage.getMassageId()); + duration=massageType.getDuration(); + String endTime = orders1.getEndTime(); + Date date = DateUtils.stringToDate(endTime, "yyyy-MM-dd HH:mm:ss"); + calendar=Calendar.getInstance(); + if(date.getTime()>System.currentTimeMillis()){ + calendar.setTime(date); + } + calendar.add(Calendar.MINUTE,duration); + orders1.setEndTime(endTime); + } + + ordersDao.updateById(orders1); + }else{ + MessageInfo messageInfo=new MessageInfo(); + messageInfo.setState("16"); + messageInfo.setTitle("新订单通知"); + messageInfo.setUserId("0"); + messageInfo.setIsSee("0"); + messageService.saveBody(messageInfo); + } + + ordersService.sendMsg(orders); + } else if (payDetails.getType() == 2) { + //缴纳保证金 + Double cashDeposit = payDetails.getMoney(); + Long userId = payDetails.getUserId(); + userMoneyDao.updateCashDeposit(1, userId, cashDeposit); + UserEntity userEntity = userService.selectUserById(userId); + userEntity.setIsCashDeposit(2); + userService.updateById(userEntity); + //交保证金的记录 + UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); + userMoneyDetails.setUserId(userId); + userMoneyDetails.setTitle("缴纳保证金"); + userMoneyDetails.setContent("已缴纳保证金:" + cashDeposit + "元"); + userMoneyDetails.setType(1); + userMoneyDetails.setMoney(BigDecimal.valueOf(cashDeposit)); + userMoneyDetails.setState(2); + userMoneyDetails.setClassify(1); + userMoneyDetails.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + } else if (payDetails.getType() == 3) { + PayClassify payClassify = payClassifyService.getById(Long.parseLong(payDetails.getRemark())); + userMoneyDao.updateMayMoney(1, payDetails.getUserId(), payClassify.getPrice().doubleValue()); + UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); + userMoneyDetails.setUserId(payDetails.getUserId()); + userMoneyDetails.setTitle("支付宝充值"); + userMoneyDetails.setContent("支付宝充值:"+payClassify.getPrice()); + userMoneyDetails.setType(1); + userMoneyDetails.setMoney(payClassify.getPrice()); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userMoneyDetails.setCreateTime(sdf.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + + + if(payClassify.getCouponId()!=null && payClassify.getGiveNum()>0){ + for(int i=0;i().eq("id", Long.parseLong(payDetails.getRemark()))); + //查看用户是否是会员 + UserVip userVip = userVipDao.selectOne(new QueryWrapper().eq("user_id", userId)); + Calendar cal = Calendar.getInstance(); + if(userVip!=null){ + Date endDate = null; + try { + endDate = sdf.parse(userVip.getEndTime()); + if (endDate != null && System.currentTimeMillis() < (endDate.getTime())) { + cal.setTime(endDate); + } + } catch (Exception e) { + e.getMessage(); + } + }else{ + userVip=new UserVip(); + //设置会员类型 + userVip.setVipNameType(vipDetails.getVipNameType()); + //设置开通会员的用户id + userVip.setUserId(userId); + //设置会员的购买时间 + userVip.setCreateTime(sdf.format(new Date())); + } + + MessageInfo messageInfo=new MessageInfo(); + UserMoneyDetails userMoneyDetails=new UserMoneyDetails(); + userMoneyDetails.setMoney(money); + userMoneyDetails.setUserId(userId); + + if ((vipDetails.getVipNameType().equals(0))) { + //月 + userMoneyDetails.setContent("支付宝开通月卡会员"); + messageInfo.setContent("支付宝开通月卡会员"); + cal.add(Calendar.MONTH, 1); + } else if ((vipDetails.getVipNameType()).equals(1)) { + //季 + userMoneyDetails.setContent("支付宝开通季卡会员"); + messageInfo.setContent("支付宝开通季卡会员"); + cal.add(Calendar.MONTH, 3); + } else { + //年 + userMoneyDetails.setContent("支付宝开通年费会员"); + messageInfo.setContent("支付宝开通年费会员"); + cal.add(Calendar.YEAR, 1); + } + + userVip.setEndTime(sdf.format(cal.getTime())); + if(userVip.getVipId()!=null){ + userVipDao.updateById(userVip); + }else{ + userVipDao.insert(userVip); + } + userMoneyDetails.setTitle("开通会员"); + userMoneyDetails.setType(2); + userMoneyDetails.setCreateTime(sdf.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + UserEntity userEntity = userService.selectUserById(userId); + messageInfo.setTitle("开通会员"); + messageInfo.setState(String.valueOf(4)); + messageInfo.setUserName(userEntity.getUserName()); + messageInfo.setUserId(String.valueOf(userEntity.getUserId())); + messageInfo.setCreateAt(sdf.format(new Date())); + messageInfo.setIsSee("0"); + messageService.saveBody(messageInfo); + if(StringUtil.isNotBlank(userEntity.getClientid())){ + userService.pushToSingle(messageInfo.getTitle(),messageInfo.getContent(),userEntity.getClientid()); + } + + }else if(payDetails.getType()==6){ + double money=payDetails.getMoney(); + if(StringUtils.isNotBlank(payDetails.getRemark())){ + PayClassify payClassify = payClassifyService.getById(Long.parseLong(payDetails.getRemark())); + if(payClassify.getCouponId()!=null && payClassify.getGiveNum()>0){ + for(int i=0;i().eq("user_id", payDetails.getUserId()).eq("artificer_id", artificerId)); + if(userMoneyArtificer==null){ + userMoneyArtificer=new UserMoneyArtificer(); + userMoneyArtificer.setUserId(payDetails.getUserId()); + userMoneyArtificer.setArtificerId(artificerId); + userMoneyArtificer.setMoney(BigDecimal.valueOf(money)); + userMoneyArtificer.setCreateTime(DateUtils.format(new Date())); + userMoneyArtificerService.save(userMoneyArtificer); + }else{ + userMoneyArtificerService.updateMoney(1, payDetails.getUserId(), artificerId,money); + } + Artificer artificer = artificerService.getById(artificerId); + + UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); + userMoneyDetails.setClassify(8); + userMoneyDetails.setUserId(payDetails.getUserId()); + userMoneyDetails.setTitle("支付宝充值"); + userMoneyDetails.setContent("指定技师“"+artificer.getArtificerName()+"”钱包支付宝充值:"+money); + userMoneyDetails.setType(1); + userMoneyDetails.setMoney(BigDecimal.valueOf(money)); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userMoneyDetails.setCreateTime(sdf.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + + } + } + } + + } + } catch (AlipayApiException e) { + e.printStackTrace(); + log.info("回调验证失败!!!"); + } + } + + @Login + @ApiOperation("支付宝支付订单") + @RequestMapping(value = "/payOrder", method = RequestMethod.POST) + @Transactional(rollbackFor = Exception.class) + public Result payOrder(Long ordersId, Integer type) { + Orders orders = ordersService.getById(ordersId); + if (orders == null) { + return Result.error("订单生成失败,请重新下单!"); + } else if (orders.getStatus() != 1) { + return Result.error("订单状态异常,请刷新页面后重试!"); + } + + if(orders.getParentId()!=null && orders.getParentId()!=0){ + Orders orders1 = ordersDao.selectById(orders.getParentId()); + OrdersMassage ordersMassage = ordersMassageService.getOne(new QueryWrapper().eq("orders_id", orders1.getOrdersId())); + MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId()); + if(massageType.getAddNum()==null || massageType.getAddNum()==0){ + return Result.error("当前项目不允许加钟!"); + }else if(massageType.getAddNum()>0){ + if(orders1.getAddNum()!=null && orders1.getAddNum()>=massageType.getAddNum()){ + return Result.error("当前项目已超过最大加钟次数!"); + } + } + Integer duration=massageType.getDuration(); + String value1 = commonInfoService.findOne(395).getValue(); + if("是".equals(value1)){ + String value = commonInfoService.findOne(392).getValue(); + int minute = Integer.parseInt(value); + int i=1; + if(duration%minute==0){ + i=duration/minute; + }else{ + i=duration/minute; + i++; + } + ArtificerTime artificerTime = artificerTimeService.getOne(new QueryWrapper().eq("orders_id", orders.getParentId()).last(" order by artificer_time_id desc limit 1 ")); + String serveTime = artificerTime.getArtificerDate()+" "+artificerTime.getArtificerTime(); + String date=null; + String time=null; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date parse = null; + try { + parse = sdf.parse(serveTime); + } catch (ParseException e) { + e.printStackTrace(); + } + Calendar calendar=Calendar.getInstance(); + calendar.setTime(parse); + for(int j=0;j() + .eq("artificer_id", orders.getArtificerId()) + .eq("artificer_date", date).eq("artificer_time", time)); + if(artificerTime!=null){ + return Result.error("预约时间正忙,请更换其他时间!"); + } + } + } + + + + } + + //通知页面地址 + CommonInfo one = commonInfoService.findOne(19); + String returnUrl = one.getValue() + "/#/pages/task/recharge"; + CommonInfo one3 = commonInfoService.findOne(12); + String name = one3.getValue(); + PayDetails payDetails1 = payDetailsDao.selectByOrderId(orders.getOrdersNo()); + if(payDetails1==null){ + PayDetails payDetails = new PayDetails(); + payDetails.setState(0); + payDetails.setCreateTime(sdf.format(new Date())); + payDetails.setOrderId(orders.getOrdersNo()); + payDetails.setUserId(orders.getUserId()); + payDetails.setMoney(orders.getPayMoney().doubleValue()); + payDetails.setClassify(6); + payDetails.setType(1); + payDetailsDao.insert(payDetails); + }else{ + payDetails1.setClassify(6); + payDetailsDao.updateById(payDetails1); + } + if (type == 1) { + return payApp(name, orders.getOrdersNo(), orders.getPayMoney().doubleValue()); + } else { + return payH5(name, orders.getOrdersNo(), orders.getPayMoney().doubleValue(), returnUrl); + } + } + + + @Login + @ApiOperation("支付宝支付订单") + @RequestMapping(value = "/payOrderCashDeposit", method = RequestMethod.POST) + @Transactional(rollbackFor = Exception.class) + public Result payOrderCashDeposit(@RequestAttribute Long userId, Integer type) { + //通知页面地址 + CommonInfo one = commonInfoService.findOne(261); + String returnUrl = one.getValue() + "/pages/my/index"; + CommonInfo one3 = commonInfoService.findOne(12); + String name = one3.getValue(); + CommonInfo two = commonInfoService.findOne(241); + double money = Double.parseDouble(two.getValue()); + String generalOrder = getGeneralOrder(); + PayDetails payDetails = new PayDetails(); + payDetails.setState(0); + payDetails.setCreateTime(sdf.format(new Date())); + payDetails.setOrderId(generalOrder); + payDetails.setUserId(userId); + payDetails.setMoney(money); + payDetails.setClassify(6); + payDetails.setType(2); + payDetailsDao.insert(payDetails); + if (type == 1) { + return payApp(name, generalOrder, money); + } else { + return payH5(name, generalOrder, money, returnUrl); + } + } + + + @Login + @ApiOperation("支付宝支付订单") + @RequestMapping(value = "/payOrderMoney", method = RequestMethod.POST) + @Transactional(rollbackFor = Exception.class) + public Result payOrderMoney(@RequestAttribute Long userId, Long payClassifyId, Integer type) { + //通知页面地址 + CommonInfo one = commonInfoService.findOne(19); + String returnUrl = one.getValue() + "/#/pages/my/index"; + CommonInfo one3 = commonInfoService.findOne(12); + String name = one3.getValue(); + String generalOrder = getGeneralOrder(); + PayClassify payClassify = payClassifyService.getById(payClassifyId); + PayDetails payDetails = new PayDetails(); + payDetails.setState(0); + payDetails.setCreateTime(sdf.format(new Date())); + payDetails.setOrderId(generalOrder); + payDetails.setUserId(userId); + payDetails.setMoney(payClassify.getPrice().doubleValue()); + payDetails.setClassify(6); + payDetails.setType(3); + payDetails.setRemark(String.valueOf(payClassifyId)); + payDetailsDao.insert(payDetails); + if (type == 1) { + return payApp(name, generalOrder, payClassify.getPrice().doubleValue()); + } else { + return payH5(name, generalOrder, payClassify.getPrice().doubleValue(), returnUrl); + } + } + + @Login + @ApiOperation("支付宝购买卷包") + @RequestMapping(value = "/payCoupon", method = RequestMethod.POST) + @Transactional(rollbackFor = Exception.class) + public Result payCoupon(@RequestAttribute Long userId, Integer classify,Long couponIssueId) { + //通知页面地址 + CommonInfo one = commonInfoService.findOne(19); + String returnUrl = one.getValue() + "/#/pages/my/index"; + CommonInfo one3 = commonInfoService.findOne(12); + String name =one3.getValue(); + CouponIssue couponIssue = couponIssueService.getById(couponIssueId); + if(couponIssue.getIsLimit()==1){ + //是否限购 + CouponUser couponUser = couponUserService.getOne(new QueryWrapper().eq("coupon_issue_id", couponIssueId)); + if(couponUser!=null){ + return Result.error("当前优惠券为限购,您已经拥有了!"); + } + if(couponIssue.getCouponNum()<=0){ + return Result.error("优惠券已经被抢完了!"); + } + } + double money = couponIssue.getPrice().doubleValue(); + String generalOrder = getGeneralOrder(); + PayDetails payDetails = payDetailsDao.selectByOrderId(generalOrder); + if(payDetails==null){ + payDetails = new PayDetails(); + payDetails.setState(0); + payDetails.setCreateTime(sdf.format(new Date())); + payDetails.setOrderId(generalOrder); + payDetails.setUserId(userId); + payDetails.setMoney(money); + payDetails.setClassify(6); + payDetails.setType(4); + payDetails.setRemark(String.valueOf(couponIssueId)); + payDetailsDao.insert(payDetails); + } + if(classify==1){ + return payApp(name,generalOrder,money); + } + return payH5(name,generalOrder,money,returnUrl); + } + + @Login + @ApiOperation("支付宝开通会员") + @RequestMapping(value = "/payUserVip", method = RequestMethod.POST) + @Transactional(rollbackFor = Exception.class) + public Result payUserVip(@RequestAttribute Long userId, Integer classify,Long vipDetailsId) { + //通知页面地址 + CommonInfo one = commonInfoService.findOne(19); + String returnUrl = one.getValue() + "/#/pages/my/index"; + CommonInfo one3 = commonInfoService.findOne(12); + String name =one3.getValue(); + VipDetails vipDetails = vipDetailsDao.selectOne(new QueryWrapper().eq("id", vipDetailsId)); + BigDecimal money = vipDetails.getMoney(); + String generalOrder = getGeneralOrder(); + PayDetails payDetails = payDetailsDao.selectByOrderId(generalOrder); + if(payDetails==null){ + payDetails = new PayDetails(); + payDetails.setState(0); + payDetails.setCreateTime(sdf.format(new Date())); + payDetails.setOrderId(generalOrder); + payDetails.setUserId(userId); + payDetails.setMoney(money.doubleValue()); + payDetails.setClassify(6); + payDetails.setType(5); + payDetails.setRemark(String.valueOf(vipDetailsId)); + payDetailsDao.insert(payDetails); + } + if(classify==1){ + return payApp(name,generalOrder,money.doubleValue()); + } + return payH5(name,generalOrder,money.doubleValue(),returnUrl); + } + + @Login + @ApiOperation("充值指定师傅钱包") + @RequestMapping(value = "/payUserMoneyArtificer", method = RequestMethod.POST) + @Transactional(rollbackFor = Exception.class) + public Result payUserMoneyArtificer(@RequestAttribute Long userId,Long artificerId, Long payClassifyId, BigDecimal money, Integer classify) { + //通知页面地址 + CommonInfo one = commonInfoService.findOne(19); + String returnUrl = one.getValue() + "/#/pages/my/index"; + CommonInfo one3 = commonInfoService.findOne(12); + String name =one3.getValue(); + PayDetails payDetails = new PayDetails(); + if(payClassifyId!=null){ + PayClassify payClassify = payClassifyService.getById(payClassifyId); + money=payClassify.getPrice(); + payDetails.setRemark(String.valueOf(payClassifyId)); + } + String generalOrder = getGeneralOrder(); + payDetails = new PayDetails(); + payDetails.setState(0); + payDetails.setCreateTime(sdf.format(new Date())); + payDetails.setOrderId(generalOrder); + payDetails.setUserId(userId); + payDetails.setMoney(money.doubleValue()); + payDetails.setClassify(6); + payDetails.setType(6); + payDetails.setRemark(String.valueOf(artificerId)); + payDetailsDao.insert(payDetails); + if(classify==1){ + return payApp(name,generalOrder,money.doubleValue()); + } + return payH5(name,generalOrder,money.doubleValue(),returnUrl); + } + + + + public Result payApp(String name, String generalOrder, Double money) { + CommonInfo one = commonInfoService.findOne(19); + String url = one.getValue() + "/sqx_fast/app/aliPay/notifyApp"; + String result = ""; + CommonInfo payWay = commonInfoService.findOne(201); + try { + if ("1".equals(payWay.getValue())) { + //构造client + CertAlipayRequest certAlipayRequest = new CertAlipayRequest(); + //设置网关地址 + certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); + //设置应用Id + certAlipayRequest.setAppId(commonInfoService.findOne(63).getValue()); + //设置应用私钥 + certAlipayRequest.setPrivateKey(commonInfoService.findOne(65).getValue()); + //设置请求格式,固定值json + certAlipayRequest.setFormat("json"); + //设置字符集 + certAlipayRequest.setCharset(AliPayConstants.CHARSET); + //设置签名类型 + certAlipayRequest.setSignType(AliPayConstants.SIGNTYPE); + CommonInfo urls = commonInfoService.findOne(200); + certAlipayRequest.setCertPath(urls.getValue() + "/appCertPublicKey.crt"); //应用公钥证书路径(app_cert_path 文件绝对路径) + certAlipayRequest.setAlipayPublicCertPath(urls.getValue() + "/alipayCertPublicKey_RSA2.crt"); //支付宝公钥证书文件路径(alipay_cert_path 文件绝对路径) + certAlipayRequest.setRootCertPath(urls.getValue() + "/alipayRootCert.crt"); //支付宝CA根证书文件路径(alipay_root_cert_path 文件绝对路径) + //构造client + AlipayClient alipayClient = new DefaultAlipayClient(certAlipayRequest); + + //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay + AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); + //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。 + AlipayTradeAppPayModel model = new AlipayTradeAppPayModel(); + model.setBody(name); + model.setSubject(name); + model.setOutTradeNo(generalOrder); + model.setTimeoutExpress("30m"); + model.setTotalAmount(money +""); + model.setProductCode("QUICK_MSECURITY_PAY"); + request.setBizModel(model); + request.setNotifyUrl(url); + //这里和普通的接口调用不同,使用的是sdkExecute + AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request); + if (response.isSuccess()) { + result = response.getBody(); + } else { + return Result.error("获取订单失败!"); + } + return Result.success().put("data", result); + } else { + //实例化客户端 + AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", commonInfoService.findOne(63).getValue(), commonInfoService.findOne(65).getValue(), "json", AliPayConstants.CHARSET, commonInfoService.findOne(64).getValue(), "RSA2"); + //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay + AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); + //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。 + AlipayTradeAppPayModel model = new AlipayTradeAppPayModel(); + model.setBody(name); + model.setSubject(name); + model.setOutTradeNo(generalOrder); + model.setTimeoutExpress("30m"); + model.setTotalAmount(String.valueOf(money)); + model.setProductCode("QUICK_MSECURITY_PAY"); + request.setBizModel(model); + request.setNotifyUrl(url); + AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request); + if (response.isSuccess()) { + result = response.getBody(); + } else { + return Result.error("获取订单失败!"); + } + return Result.success().put("data", result); + } + } catch (AlipayApiException e) { + e.printStackTrace(); + } + return Result.error(-100, "获取订单失败!"); + } + + public Result payH5(String name, String generalOrder, Double money, String returnUrl) { + CommonInfo payWay = commonInfoService.findOne(201); + CommonInfo one = commonInfoService.findOne(19); + String url = one.getValue() + "/sqx_fast/app/aliPay/notifyApp"; + try { + if ("1".equals(payWay.getValue())) { + //构造client + CertAlipayRequest certAlipayRequest = new CertAlipayRequest(); + //设置网关地址 + certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); + //设置应用Id + certAlipayRequest.setAppId(commonInfoService.findOne(63).getValue()); + //设置应用私钥 + certAlipayRequest.setPrivateKey(commonInfoService.findOne(65).getValue()); + //设置请求格式,固定值json + certAlipayRequest.setFormat("json"); + //设置字符集 + certAlipayRequest.setCharset(AliPayConstants.CHARSET); + //设置签名类型 + certAlipayRequest.setSignType(AliPayConstants.SIGNTYPE); + CommonInfo urls = commonInfoService.findOne(200); + certAlipayRequest.setCertPath(urls.getValue() + "/appCertPublicKey.crt"); //应用公钥证书路径(app_cert_path 文件绝对路径) + certAlipayRequest.setAlipayPublicCertPath(urls.getValue() + "/alipayCertPublicKey_RSA2.crt"); //支付宝公钥证书文件路径(alipay_cert_path 文件绝对路径) + certAlipayRequest.setRootCertPath(urls.getValue() + "/alipayRootCert.crt"); //支付宝CA根证书文件路径(alipay_root_cert_path 文件绝对路径) + //构造client + AlipayClient alipayClient = new DefaultAlipayClient(certAlipayRequest); + AlipayTradeWapPayRequest alipayRequest = new AlipayTradeWapPayRequest(); + JSONObject order = new JSONObject(); + order.put("out_trade_no", generalOrder); //订单号 + order.put("subject", name); //商品标题 + order.put("product_code", "QUICK_WAP_WAY"); + order.put("body", name);//商品名称 + order.put("total_amount", money + ""); //金额 + alipayRequest.setBizContent(order.toString()); + alipayRequest.setNotifyUrl(url); //在公共参数中设置回跳和通知地址 + alipayRequest.setReturnUrl(returnUrl); //线上通知页面地址 + String result = alipayClient.pageExecute(alipayRequest).getBody(); + return Result.success().put("data", result); + } else { + AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", commonInfoService.findOne(63).getValue(), commonInfoService.findOne(65).getValue(), "json", AliPayConstants.CHARSET, commonInfoService.findOne(64).getValue(), "RSA2"); + AlipayTradeWapPayRequest alipayRequest = new AlipayTradeWapPayRequest(); + JSONObject order = new JSONObject(); + order.put("out_trade_no", generalOrder); //订单号 + order.put("subject", name); //商品标题 + order.put("product_code", "QUICK_WAP_WAY"); + order.put("body", name);//商品名称 + order.put("total_amount", money); //金额 + alipayRequest.setBizContent(order.toString()); + //在公共参数中设置回跳和通知地址 + alipayRequest.setNotifyUrl(url); + //通知页面地址 + alipayRequest.setReturnUrl(returnUrl); + String form = alipayClient.pageExecute(alipayRequest).getBody(); + return Result.success().put("data", form); + } + } catch (AlipayApiException e) { + log.error("CreatPayOrderForH5", e); + } + return Result.error("获取订单信息错误!"); + } + + + public String getGeneralOrder() { + Date date = new Date(); + String newString = String.format("%0" + 4 + "d", (int) ((Math.random() * 9 + 1) * 1000)); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String format = sdf.format(date); + return format + newString; + } + + + public String alipayRefund(String ordersNo,BigDecimal refundMoney) { + PayDetails payDetails = payDetailsDao.selectByOrderId(ordersNo); + AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", commonInfoService.findOne(63).getValue(), commonInfoService.findOne(65).getValue(), "json", AliPayConstants.CHARSET, commonInfoService.findOne(64).getValue(), "RSA2"); + AlipayTradeRefundRequest alipay_request = new AlipayTradeRefundRequest(); + AlipayTradeRefundModel model = new AlipayTradeRefundModel(); + model.setOutTradeNo(payDetails.getOrderId());//订单编号 + model.setTradeNo(payDetails.getTradeNo());//支付宝订单交易号 + model.setRefundAmount(refundMoney.toString());//退款金额 不得大于订单金额 + model.setRefundReason("服务退款");//退款说明 + model.setOutRequestNo(payDetails.getOrderId());//标识一次退款请求,同一笔交易多次退款需要保证唯一,如需部分退款,则此参数必传。 + alipay_request.setBizModel(model); + try { + AlipayTradeRefundResponse alipay_response = alipayClient.execute(alipay_request); + String alipayRefundStr = alipay_response.getBody(); + log.info(alipayRefundStr); + return alipayRefundStr; + } catch (AlipayApiException e) { + e.printStackTrace(); + } + return null; + } + + + +} diff --git a/src/main/java/com/sqx/modules/pay/controller/app/ApiWeiXinPayController.java b/src/main/java/com/sqx/modules/pay/controller/app/ApiWeiXinPayController.java new file mode 100644 index 0000000..09d8949 --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/controller/app/ApiWeiXinPayController.java @@ -0,0 +1,307 @@ +package com.sqx.modules.pay.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.entity.UserCertification; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.artificer.entity.Certification; +import com.sqx.modules.pay.dao.PayDetailsDao; +import com.sqx.modules.pay.entity.PayDetails; +import com.sqx.modules.pay.service.WxService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.math.BigDecimal; + +/** + * @author fang + * @date 2020/2/26 + */ +@RestController +@Api(value = "微信支付", tags = {"微信支付"}) +@RequestMapping("/app/wxPay") +@Slf4j +public class ApiWeiXinPayController { + + @Autowired + private WxService wxService; + + @Login + @ApiOperation("微信充值余额") + @PostMapping("/payMoney") + public Result payMoney(@RequestAttribute("userId") Long userId,Long payClassifyId,Integer type,HttpServletRequest request) throws Exception { + return wxService.payMoney(userId,payClassifyId,type,request); + } + + + @Login + @ApiOperation("微信app支付订单") + @PostMapping("/payOrder") + public Result payAppOrder(Long ordersId,Integer type,HttpServletRequest request) throws Exception { + return wxService.payOrder(ordersId,type,request); + } + + + @Login + @ApiOperation("缴纳保证金") + @PostMapping(value = "submitRealName") + public Result submitRealName(@RequestAttribute Long userId,Integer type,HttpServletRequest request) throws Exception { + //1app微信 2微信公众号 3微信小程序 + return wxService.submitRealName(userId, type,request); + } + + @Login + @ApiOperation("微信支付优惠券") + @PostMapping("/payCoupon") + public Result payCoupon(@RequestAttribute Long userId, Integer classify,Long couponIssueId,HttpServletRequest request) throws Exception { + return wxService.payCoupon(userId,classify,couponIssueId,request); + } + + @Login + @ApiOperation("微信支付优惠券") + @PostMapping("/payUserVip") + public Result payUserVip(@RequestAttribute Long userId, Long vipDetailsId,Integer type,HttpServletRequest request) throws Exception { + return wxService.payUserVip(userId,vipDetailsId,type,request); + } + + @Login + @ApiOperation("微信支付充值指定师傅钱包") + @PostMapping("/payUserMoneyArtificer") + public Result payUserMoneyArtificer(@RequestAttribute Long userId,Long artificerId, Long payClassifyId, BigDecimal money, Integer type, HttpServletRequest request) throws Exception { + return wxService.payUserMoneyArtificer(userId,artificerId,payClassifyId,money,type,request); + } + + + @PostMapping("/notify") + @ApiOperation("微信回调") + public String wxPayNotify(HttpServletRequest request) { + String resXml = ""; + try { + InputStream inputStream = request.getInputStream(); + //将InputStream转换成xmlString + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb = new StringBuilder(); + String line = null; + try { + while ((line = reader.readLine()) != null) { + sb.append(line + "\n"); + } + } catch (IOException e) { + log.info(e.getMessage()); + } finally { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + resXml = sb.toString(); + String result = wxService.payBack(resXml,1); + log.info("成功"); + log.info(result); + + return result; + } catch (Exception e) { + log.info("微信手机支付失败:" + e.getMessage()); + String result = "" + "" + "" + " "; + log.info("失败"); + log.info(result); + return result; + } + } + + @PostMapping("/notifyJsApi") + @ApiOperation("微信回调") + public String notifyJsApi(HttpServletRequest request) { + String resXml = ""; + try { + InputStream inputStream = request.getInputStream(); + //将InputStream转换成xmlString + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb = new StringBuilder(); + String line = null; + try { + while ((line = reader.readLine()) != null) { + sb.append(line + "\n"); + } + } catch (IOException e) { + log.info(e.getMessage()); + } finally { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + resXml = sb.toString(); + String result = wxService.payBack(resXml,3); + log.info("成功"); + log.info(result); + return result; + } catch (Exception e) { + log.info("微信手机支付失败:" + e.getMessage()); + String result = "" + "" + "" + " "; + log.info("失败"); + log.info(result); + return result; + } + } + + @PostMapping("/notifyMp") + @ApiOperation("微信回调") + public String notifyMp(HttpServletRequest request) { + String resXml = ""; + try { + InputStream inputStream = request.getInputStream(); + //将InputStream转换成xmlString + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb = new StringBuilder(); + String line = null; + try { + while ((line = reader.readLine()) != null) { + sb.append(line + "\n"); + } + } catch (IOException e) { + log.info(e.getMessage()); + } finally { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + resXml = sb.toString(); + String result = wxService.payBack(resXml,2); + log.info("成功"); + log.info(result); + return result; + } catch (Exception e) { + log.info("微信手机支付失败:" + e.getMessage()); + String result = "" + "" + "" + " "; + log.info("失败"); + log.info(result); + return result; + } + } + + @PostMapping("/notifys") + @ApiOperation("微信回调") + public String wxPayNotifys(HttpServletRequest request) { + String resXml = ""; + try { + InputStream inputStream = request.getInputStream(); + //将InputStream转换成xmlString + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb = new StringBuilder(); + String line = null; + try { + while ((line = reader.readLine()) != null) { + sb.append(line + "\n"); + } + } catch (IOException e) { + log.info(e.getMessage()); + } finally { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + resXml = sb.toString(); + String result = wxService.payBacks(resXml,1); + log.info("成功"); + log.info(result); + + return result; + } catch (Exception e) { + log.info("微信手机支付失败:" + e.getMessage()); + String result = "" + "" + "" + " "; + log.info("失败"); + log.info(result); + return result; + } + } + + @PostMapping("/notifyJsApis") + @ApiOperation("微信回调") + public String notifyJsApis(HttpServletRequest request) { + String resXml = ""; + try { + InputStream inputStream = request.getInputStream(); + //将InputStream转换成xmlString + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb = new StringBuilder(); + String line = null; + try { + while ((line = reader.readLine()) != null) { + sb.append(line + "\n"); + } + } catch (IOException e) { + log.info(e.getMessage()); + } finally { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + resXml = sb.toString(); + String result = wxService.payBacks(resXml,3); + log.info("成功"); + log.info(result); + return result; + } catch (Exception e) { + log.info("微信手机支付失败:" + e.getMessage()); + String result = "" + "" + "" + " "; + log.info("失败"); + log.info(result); + return result; + } + } + + @PostMapping("/notifyMps") + @ApiOperation("微信回调") + public String notifyMps(HttpServletRequest request) { + String resXml = ""; + try { + InputStream inputStream = request.getInputStream(); + //将InputStream转换成xmlString + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb = new StringBuilder(); + String line = null; + try { + while ((line = reader.readLine()) != null) { + sb.append(line + "\n"); + } + } catch (IOException e) { + log.info(e.getMessage()); + } finally { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + resXml = sb.toString(); + String result = wxService.payBacks(resXml,2); + log.info("成功"); + log.info(result); + return result; + } catch (Exception e) { + log.info("微信手机支付失败:" + e.getMessage()); + String result = "" + "" + "" + " "; + log.info("失败"); + log.info(result); + return result; + } + } + +} diff --git a/src/main/java/com/sqx/modules/pay/controller/app/AppCashController.java b/src/main/java/com/sqx/modules/pay/controller/app/AppCashController.java new file mode 100644 index 0000000..17c4098 --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/controller/app/AppCashController.java @@ -0,0 +1,71 @@ +package com.sqx.modules.pay.controller.app; + + +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.service.UserMoneyDetailsService; +import com.sqx.modules.pay.service.CashOutService; +import com.sqx.modules.pay.service.PayDetailsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author fang + * @date 2020/5/15 + */ +@Slf4j +@RestController +@Api(value = "提现", tags = {"提现"}) +@RequestMapping(value = "/app/cash") +public class AppCashController { + + /** 提现记录 */ + @Autowired + private CashOutService cashOutService; + @Autowired + private PayDetailsService payDetailsService; + @Autowired + private UserMoneyDetailsService userMoneyDetailsService; + + + @Login + @GetMapping(value = "/cashMoney") + @ApiOperation("发起提现") + public Result cashMoney(@RequestAttribute("userId") Long userId, Double money,Integer userType,Integer classify) + { + return cashOutService.cashMoney(userId,money,userType,classify); + } + + @Login + @RequestMapping(value = "/selectUserRechargeByUserId", method = RequestMethod.GET) + @ApiOperation("查询某个用户充值信息列表") + @ResponseBody + public Result selectUserRechargeByUserId(int page, int limit, String startTime, String endTime, @RequestAttribute("userId") Long userId, Integer state){ + return Result.success().put("data",payDetailsService.selectPayDetails(page,limit,startTime,endTime,userId,state)); + } + + @Login + @RequestMapping(value = "/selectPayDetails", method = RequestMethod.GET) + @ApiOperation("查询提现记录列表") + @ResponseBody + public Result selectHelpProfit(Integer page, Integer limit,String userName, String zhifubaoName, String zhifubao, Integer state, Integer userType, String startTime, String endTime, @RequestAttribute("userId") Long userId,String phone){ + PageUtils pageUtils = cashOutService.selectCashOutList(page, limit,userName, zhifubaoName, zhifubao, String.valueOf(userId), state, userType,startTime,endTime,phone); + return Result.success().put("data",pageUtils); + } + + @Login + @ApiOperation("钱包明细") + @GetMapping("/queryUserMoneyDetails") + public Result queryUserMoneyDetails(Integer page, Integer limit, @RequestAttribute("userId") Long userId, Integer classify, Integer type,Long artificerId) { + return userMoneyDetailsService.queryUserMoneyDetails(page, limit, userId,classify,type,artificerId); + } + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/pay/controller/app/AppPayClassifyController.java b/src/main/java/com/sqx/modules/pay/controller/app/AppPayClassifyController.java new file mode 100644 index 0000000..3859e7a --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/controller/app/AppPayClassifyController.java @@ -0,0 +1,49 @@ +package com.sqx.modules.pay.controller.app; + + +import com.sqx.common.utils.Result; +import com.sqx.modules.coupon.service.CouponService; +import com.sqx.modules.pay.entity.PayClassify; +import com.sqx.modules.pay.service.PayClassifyService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author fang + * @date 2022/4/16 + */ +@Slf4j +@RestController +@Api(value = "充值分类", tags = {"充值分类"}) +@RequestMapping(value = "/app/payClassify") +public class AppPayClassifyController { + + @Autowired + private PayClassifyService payClassifyService; + @Autowired + private CouponService couponService; + + + @GetMapping("/selectPayClassifyList") + @ApiOperation("查询充值分类") + public Result selectPayClassifyList(){ + List list = payClassifyService.list(); + for(PayClassify payClassify:list){ + if(payClassify.getCouponId()!=null){ + payClassify.setCoupon(couponService.getById(payClassify.getCouponId())); + } + } + return Result.success().put("data",list); + } + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/pay/dao/CashOutDao.java b/src/main/java/com/sqx/modules/pay/dao/CashOutDao.java new file mode 100644 index 0000000..8c2655a --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/dao/CashOutDao.java @@ -0,0 +1,52 @@ +package com.sqx.modules.pay.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.pay.entity.CashOut; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @author fang + * @date 2020/7/8 + */ +@Mapper +public interface CashOutDao extends BaseMapper { + + List selectCashOutLimit3(); + + Double selectCashOutSum(@Param("userId") Long userId, @Param("startTime") Date startTime, @Param("endTime") Date endTime); + + Double sumMoney(@Param("time") String time, @Param("flag") Integer flag); + + Double sumMoneyMonthByUserId(@Param("time") String time, @Param("userId") Long userId); + + BigDecimal sumMoneyByUserId(@Param("userId") Long userId, @Param("time") String time, @Param("flag") Integer flag); + + Integer countMoney(@Param("time") String time, @Param("flag") Integer flag); + + + Integer stayCount(@Param("time") String time, @Param("flag") Integer flag); + + Double stayMoney(@Param("time") String time, @Param("flag") Integer flag); + + void updateMayMoney(@Param("type") Integer type,@Param("userId")Long userId,@Param("money") Double money); + + Double selectMayMoney(@Param("userId") Long userId); + + IPage selectCashOutPage(Page page,String userName,String zhifubaoName, String zhifubao, String userId, + Integer state, Integer userType, String startTime, String endTime,String phone ); + + List selectCashOutList(String userName ,String zhifubaoName, String zhifubao, String userId, + Integer state, Integer userType, String startTime, String endTime,String phone ); + + Double selectCashMoneyByClassify(@Param("time") String time, @Param("flag") Integer flag,@Param("classify") Integer classify,@Param("state") Integer state); + + Integer selectCashCountByClassify(@Param("time") String time, @Param("flag") Integer flag,@Param("classify") Integer classify,@Param("state") Integer state); + +} diff --git a/src/main/java/com/sqx/modules/pay/dao/PayClassifyDao.java b/src/main/java/com/sqx/modules/pay/dao/PayClassifyDao.java new file mode 100644 index 0000000..0ab782a --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/dao/PayClassifyDao.java @@ -0,0 +1,16 @@ +package com.sqx.modules.pay.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.pay.entity.PayClassify; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author fang + * @date 2020/7/8 + */ +@Mapper +public interface PayClassifyDao extends BaseMapper { + + int updatePayClassifyCouponId(Long payClassifyId); + +} diff --git a/src/main/java/com/sqx/modules/pay/dao/PayDetailsDao.java b/src/main/java/com/sqx/modules/pay/dao/PayDetailsDao.java new file mode 100644 index 0000000..a5e7f34 --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/dao/PayDetailsDao.java @@ -0,0 +1,48 @@ +package com.sqx.modules.pay.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.pay.entity.PayDetails; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Map; + +/** + * @author fang + * @date 2020/7/1 + */ +@Mapper +public interface PayDetailsDao extends BaseMapper { + + PayDetails selectById(@Param("id") Long id); + + PayDetails selectByRemark(@Param("remark") String remark); + + PayDetails selectByOrderId(@Param("orderId") String orderId); + + int updateState(@Param("id") Long id, @Param("state") Integer state, @Param("time") String time, @Param("tradeNo") String tradeNo); + + IPage> selectPayDetails(Page> page, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("userId") Long userId, @Param("state") Integer state); + + Double selectSumPay(@Param("createTime") String createTime, @Param("endTime") String endTime, @Param("userId") Long userId); + + Double selectSumMember(@Param("time") String time, @Param("flag") Integer flag); + + IPage> payMemberAnalysis(Page> page, @Param("time") String time, @Param("flag") Integer flag); + + Double selectSumPayByType(String time,Integer flag,Integer type); + + Double selectSumPayByState(@Param("time") String time, @Param("flag") Integer flag, @Param("state") Integer state); + + Double selectSumPayByClassify(@Param("time") String time, @Param("flag") Integer flag, @Param("classify") Integer classify,@Param("payClassify") Integer payClassify); + + IPage> selectUserMemberList(Page> page, @Param("phone") String phone); + + int selectPayCount(Long userId); + + Double instantselectSumPay(@Param("date") String date, @Param("userId") Long userId); + + +} diff --git a/src/main/java/com/sqx/modules/pay/entity/AliPayParamModel.java b/src/main/java/com/sqx/modules/pay/entity/AliPayParamModel.java new file mode 100644 index 0000000..bd8efae --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/entity/AliPayParamModel.java @@ -0,0 +1,33 @@ +package com.sqx.modules.pay.entity; + +import lombok.Data; + +/** + * @author WALKMAN + * @Description 支付宝订单参数 + **/ +@Data +public class AliPayParamModel { + + /** + * 系统交易订单号 + */ + private String out_trade_no; + + /** + * 订单金额 + */ + private String total_amount; + + /** + * 标题 + */ + private String subject; + + /** + * 商品标签-固定值 + */ + private String product_code; + + +} diff --git a/src/main/java/com/sqx/modules/pay/entity/AliPayWithdrawModel.java b/src/main/java/com/sqx/modules/pay/entity/AliPayWithdrawModel.java new file mode 100644 index 0000000..4a91221 --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/entity/AliPayWithdrawModel.java @@ -0,0 +1,51 @@ +package com.sqx.modules.pay.entity; + +import lombok.Builder; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author WALKMAN + * @Description:支付宝提现表单 + **/ +@Data +@Builder +public class AliPayWithdrawModel { + + /** + * 平台交易订单号 + */ + private String out_biz_no; + + /** + * 交易方式 + */ + private String payee_type = "ALIPAY_LOGONID"; + + /** + * 提现金额 + */ + private BigDecimal amount; + + /** + * 提现账户 + */ + private String payee_account; + + /** + * 支付宝账户昵称 + */ + private String payer_show_name; + + /** + * 支付宝真实名称 + */ + private String payee_real_name; + + /** + * 交易备注 + */ + private String remark; + +} diff --git a/src/main/java/com/sqx/modules/pay/entity/CashOut.java b/src/main/java/com/sqx/modules/pay/entity/CashOut.java new file mode 100644 index 0000000..9ea7169 --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/entity/CashOut.java @@ -0,0 +1,127 @@ +package com.sqx.modules.pay.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 提现申请 + * @author fang + * @date 2020/7/8 + */ +@Data +@TableName("cash_out") +public class CashOut implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 申请提现id + */ + @TableId(type = IdType.INPUT) + private long id; + + /** + * 申请时间 + */ + private String createAt; + + /** + * 是否转账 + */ + private String outAt; + + /** + * 提现金额 + */ + private String money; + + /** + * 转账时间 + */ + private Boolean isOut; + + /** + * 会员编号 + */ + private String relationId; + + /** + * 用户id + */ + private Long userId; + + /** + * 支付宝账号 + */ + private String zhifubao; + + /** + * 支付宝姓名 + */ + private String zhifubaoName; + + /** + * 订单编号 + */ + private String orderNumber; + + /** + * 状态 0待转账 1成功 -1退款 + */ + private Integer state; + + /** + * 原因 + */ + private String refund; + + /** + * 手续费 + */ + private Double rate; + + /** + * 类型 1用户 2技师 + */ + private Integer userType; + + /** + * 提现方式 1支付宝 2银行卡 + */ + private Integer classify; + + /** + * 银行卡号 + */ + private String bankCard; + + /** + * 银行名称 + */ + private String bankCardName; + + /** + * 银行卡用户名 + */ + private String bankCardUserName; + + /** + * 银行卡开户行地址 + */ + private String bankCardAddress; + + @TableField(exist = false) + private String phone; + + @TableField(exist = false) + private String artificerName; + + @TableField(exist = false) + private String userName; + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/pay/entity/PayClassify.java b/src/main/java/com/sqx/modules/pay/entity/PayClassify.java new file mode 100644 index 0000000..5ef0146 --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/entity/PayClassify.java @@ -0,0 +1,56 @@ +package com.sqx.modules.pay.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.sqx.modules.coupon.entity.Coupon; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @description pay_classify + * @author fang + * @date 2022-04-06 + */ +@Data +public class PayClassify implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 充值分类id + */ + private Long payClassifyId; + + /** + * 售价 + */ + private BigDecimal price; + + private BigDecimal money; + + /** + * 优惠券 + */ + private Long couponId; + + @TableField(exist = false) + private Coupon coupon; + + private Integer giveNum; + + /** + * 排序 + */ + private Integer sort; + + /** + * 时间 + */ + private String createTime; + + public PayClassify() {} +} diff --git a/src/main/java/com/sqx/modules/pay/entity/PayDetails.java b/src/main/java/com/sqx/modules/pay/entity/PayDetails.java new file mode 100644 index 0000000..5d364e2 --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/entity/PayDetails.java @@ -0,0 +1,80 @@ +package com.sqx.modules.pay.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 充值记录 + * @author fang 2020-05-14 + */ +@Data +@TableName("pay_details") +public class PayDetails implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 充值记录id + */ + @TableId(type = IdType.INPUT) + private Long id; + + /** + * 分类(1微信 1app微信 2微信公众号 3微信小程序 4微信公众号 外链 5系统修改金额 6支付宝) + */ + private Integer classify; + + /** + * 订单id + */ + private String orderId; + + /** + * 支付宝交易订单号 + */ + private String tradeNo; + + /** + * 充值金额 + */ + private Double money; + + /** + * 用户id + */ + private Long userId; + + /** + * 0待支付 1支付成功 2失败 + */ + private Integer state; + + /** + * 创建时间 + */ + private String createTime; + + /** + * 支付时间 + */ + private String payTime; + + /** + * 支付类型 1订单 2实名认证 3充值 4优惠券 5会员 + */ + private Integer type; + + private String remark; + + @TableField(exist = false) + private String refundContent; + + @TableField(exist = false) + private String outRequestNo; + +} diff --git a/src/main/java/com/sqx/modules/pay/service/CashOutService.java b/src/main/java/com/sqx/modules/pay/service/CashOutService.java new file mode 100644 index 0000000..5393f20 --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/service/CashOutService.java @@ -0,0 +1,52 @@ +package com.sqx.modules.pay.service; + + +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.pay.entity.CashOut; +import com.sqx.modules.utils.excel.ExcelData; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +public interface CashOutService { + + PageUtils selectCashOutList(Integer page, Integer limit,String userName, String zhifubaoName, String zhifubao, String userId, Integer state, Integer userType, String startTime, String endTime,String phone); + + ExcelData excelPayDetails(String userName ,String zhifubaoName, String zhifubao, String userId, Integer state, Integer userType, String startTime, String endTime,String phone); + + int saveBody(CashOut cashOut); + + int update(CashOut cashOut); + + CashOut selectById(Long id); + + void cashOutSuccess(UserEntity userByWxId, String date, String money, String payWay, String url); + + List selectCashOutLimit3(); + + void refundSuccess(UserEntity userByWxId, String date, String money, String url, String content); + + Double selectCashOutSum(Long userId, Date startTime, Date endTime); + + Double sumMoney(String time, Integer flag); + + Double sumMoneyMonthByUserId(String time, Long userId); + + Integer countMoney(String time, Integer flag); + + Integer stayCount(String time, Integer flag); + + Double stayMoney(String time, Integer flag); + + Integer selectCashCountByClassify(String time, Integer flag,Integer classify,Integer state); + + Double selectCashMoneyByClassify(String time, Integer flag,Integer classify,Integer state); + + void updateMayMoney(int i, Long userId, Double money); + + Result cashMoney(Long userId, Double money,Integer userType,Integer classify); + +} diff --git a/src/main/java/com/sqx/modules/pay/service/PayClassifyService.java b/src/main/java/com/sqx/modules/pay/service/PayClassifyService.java new file mode 100644 index 0000000..c78221f --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/service/PayClassifyService.java @@ -0,0 +1,11 @@ +package com.sqx.modules.pay.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.modules.pay.entity.PayClassify; + +public interface PayClassifyService extends IService { + + int updatePayClassifyCouponId(Long payClassifyId); + +} diff --git a/src/main/java/com/sqx/modules/pay/service/PayDetailsService.java b/src/main/java/com/sqx/modules/pay/service/PayDetailsService.java new file mode 100644 index 0000000..0e053c1 --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/service/PayDetailsService.java @@ -0,0 +1,27 @@ +package com.sqx.modules.pay.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.PageUtils; +import com.sqx.modules.pay.entity.PayDetails; + +public interface PayDetailsService extends IService { + + PageUtils selectPayDetails(int page, int limit, String startTime, String endTime, Long userId, Integer state); + + Double selectSumPay(String createTime, String endTime, Long userId); + + PageUtils payMemberAnalysis(int page, int limit, String time, Integer flag); + + PageUtils selectUserMemberList(int page, int limit, String phone); + + Double selectSumMember(String time, Integer flag); + + Double selectSumPayByState(String time, Integer flag, Integer state); + + Double selectSumPayByClassify(String time, Integer flag, Integer classify,Integer payClassify); + + Double instantselectSumPay(String date, Long userId); + + Double selectSumPayByType(String time,Integer flag,Integer type); + +} diff --git a/src/main/java/com/sqx/modules/pay/service/WxService.java b/src/main/java/com/sqx/modules/pay/service/WxService.java new file mode 100644 index 0000000..782044d --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/service/WxService.java @@ -0,0 +1,35 @@ +package com.sqx.modules.pay.service; + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserCertification; +import com.sqx.modules.artificer.entity.Certification; + +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; + + +/** + * @author fang + * @date 2020/2/26 + */ +public interface WxService { + + Result payMoney(Long userId, Long payClassifyId, Integer classify, HttpServletRequest request) throws Exception; + + Result payOrder(Long id, Integer type,HttpServletRequest request) throws Exception; + + Result payCoupon(Long userId, Integer type, Long couponIssueId,HttpServletRequest request) throws Exception; + + String payBack(String resXml,Integer type); + + String payBacks(String resXml, Integer type); + + Result submitRealName(Long userId, Integer type,HttpServletRequest request) throws Exception; + + Result payUserVip( Long userId, Long vipDetailsId,Integer type,HttpServletRequest request) throws Exception; + + Result payUserMoneyArtificer(Long userId,Long artificerId,Long payClassifyId,BigDecimal money,Integer classify,HttpServletRequest request) throws Exception; + + boolean refund(String ordersNo, BigDecimal payMoney, BigDecimal refundMoney, Integer payWay); + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/pay/service/impl/CashOutServiceImpl.java b/src/main/java/com/sqx/modules/pay/service/impl/CashOutServiceImpl.java new file mode 100644 index 0000000..a22734f --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/service/impl/CashOutServiceImpl.java @@ -0,0 +1,393 @@ +package com.sqx.modules.pay.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Query; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.entity.UserMoneyDetails; +import com.sqx.modules.app.service.UserMoneyDetailsService; +import com.sqx.modules.app.service.UserMoneyService; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.invite.dao.InviteMoneyDao; +import com.sqx.modules.invite.entity.Invite; +import com.sqx.modules.invite.entity.InviteMoney; +import com.sqx.modules.message.dao.MessageInfoDao; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.pay.dao.CashOutDao; +import com.sqx.modules.pay.entity.CashOut; +import com.sqx.modules.pay.service.CashOutService; +import com.sqx.modules.utils.AmountCalUtils; +import com.sqx.modules.utils.excel.ExcelData; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import weixin.popular.api.MessageAPI; +import weixin.popular.bean.message.templatemessage.TemplateMessage; +import weixin.popular.bean.message.templatemessage.TemplateMessageItem; +import weixin.popular.bean.message.templatemessage.TemplateMessageResult; +import weixin.popular.support.TokenManager; + +import javax.websocket.SendResult; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 提现申请记录 + */ +@Service +public class CashOutServiceImpl extends ServiceImpl implements CashOutService { + + /** + * 提现申请记录 + */ + @Autowired + private CashOutDao cashOutDao; + /** + * 通用配置 + */ + @Autowired + private CommonInfoService commonInfoService; + /** + * app用户 + */ + @Autowired + private UserService userService; + @Autowired + private MessageInfoDao messageInfoDao; + @Autowired + private UserMoneyService userMoneyService; + @Autowired + private UserMoneyDetailsService userMoneyDetailsService; + @Autowired + private InviteMoneyDao inviteMoneyDao; + + @Override + public PageUtils selectCashOutList(Integer page, Integer limit,String userName ,String zhifubaoName, String zhifubao, String userId, Integer state, Integer userType, String startTime, String endTime,String phone) { + IPage cashOutIPage = baseMapper.selectCashOutPage(new Page<>(page, limit),userName,zhifubaoName, zhifubao, userId, state, userType, startTime, endTime, phone); + return new PageUtils(cashOutIPage); + } + + @Override + public ExcelData excelPayDetails(String userName ,String zhifubaoName, String zhifubao, String userId, Integer state, Integer userType, + String startTime, String endTime,String phone) { + List cashOutIPage = baseMapper.selectCashOutList( userName,zhifubaoName, zhifubao, userId, state, userType, startTime, endTime, phone); + ExcelData data = new ExcelData(); + data.setName("提现列表"); + List titles = new ArrayList(); + titles.add("编号");titles.add("用户类型");titles.add("手机号");titles.add("提现类型");titles.add("支付宝账号");titles.add("支付宝名称"); + titles.add("绑定银行卡姓名");titles.add("银行名称");titles.add("银行卡账号");titles.add("开户行地址"); + titles.add("提现金额");titles.add("状态"); + titles.add("拒绝原因");titles.add("申请时间");titles.add("转账/拒绝时间");titles.add("转账订单号"); + data.setTitles(titles); + List> rows = new ArrayList(); + for(CashOut cashOut:cashOutIPage){ + List row = new ArrayList(); + row.add(cashOut.getId()); + if(cashOut.getUserType()==null || cashOut.getUserType()==1){ + row.add("用户"); + }else{ + row.add("技师"); + } + row.add(cashOut.getPhone()); + if(cashOut.getClassify()==null || cashOut.getClassify()==1){ + row.add("支付宝"); + }else{ + row.add("银行卡"); + } + row.add(cashOut.getZhifubao());row.add(cashOut.getZhifubaoName()); + row.add(cashOut.getBankCardUserName());row.add(cashOut.getBankCardName()); + row.add(cashOut.getBankCard());row.add(cashOut.getBankCardAddress()); + row.add(cashOut.getMoney()); + if(cashOut.getState()==-1){ + row.add("退款"); + }else if(cashOut.getState()==0){ + row.add("待转账"); + }else{ + row.add("成功"); + } + row.add(cashOut.getRefund()==null?"":cashOut.getRefund()); + row.add(cashOut.getCreateAt()); + row.add(StringUtils.isEmpty(cashOut.getOutAt())?"":cashOut.getOutAt()); + row.add(cashOut.getOrderNumber()); + rows.add(row); + } + data.setRows(rows); + return data; + } + + + @Override + public CashOut selectById(Long id) { + return cashOutDao.selectById(id); + } + + @Override + public int saveBody(CashOut cashOut) { + return cashOutDao.insert(cashOut); + } + + + @Override + public int update(CashOut cashOut) { + return cashOutDao.updateById(cashOut); + } + + + @Override + public void cashOutSuccess(UserEntity userByWxId, String date, String money, String payWay, String url) { + if(userByWxId!=null){ + MessageInfo messageInfo = new MessageInfo(); + messageInfo.setState(String.valueOf(5)); + messageInfo.setContent("您好,您的提现转账成功,请注意查收!提现金额【" + money + "元】!支付宝收款账号 " + payWay + "感谢您的使用!如有疑问请在公众号中发送您的问题联系客服"); + messageInfo.setTitle("提现成功通知"); + messageInfo.setUserName(userByWxId.getUserName()); + messageInfo.setUserId(String.valueOf(userByWxId.getUserId())); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + messageInfo.setCreateAt(sdf.format(now)); + messageInfo.setIsSee("0"); + messageInfoDao.insert(messageInfo); + if (userByWxId.getClientid() != null) { + userService.pushToSingle("提现成功通知", "您好,您的提现转账成功,请注意查收!提现金额【" + money + "元】!支付宝收款账号 " + payWay + "感谢您的使用!如有疑问请在公众号中发送您的问题联系客服", userByWxId.getClientid()); + } + /*CommonInfo three = commonInfoService.findOne(39); + String apkey = ""; + if (three != null) { + apkey = three.getValue(); + } + if(StringUtils.isNotBlank(userByWxId.getOpenId())){ + LinkedHashMap data = new LinkedHashMap<>(); + data.put("first", new TemplateMessageItem("您好,您的提现转账成功,请注意查收", "#d71345")); + data.put("keyword1", new TemplateMessageItem(money + " 元", "#d71345")); + data.put("keyword2", new TemplateMessageItem(date, "#d71345")); + data.put("remark", new TemplateMessageItem("支付宝收款账号 " + payWay + "感谢您的使用!如有疑问请在公众号中发送您的问题联系客服", null)); + sendWxMessage(apkey, data, userByWxId.getOpenId(), url); + }*/ + } + + } + + /** + * 退款成功通知 + * + * @param + * @param date + * @param money + * @param url + */ + @Override + public void refundSuccess(UserEntity userByWxId, String date, String money, String url, String content) { + MessageInfo messageInfo = new MessageInfo(); + messageInfo.setState(String.valueOf(5)); + messageInfo.setContent(content); + messageInfo.setTitle("提现失败提醒"); + messageInfo.setUserName(userByWxId.getUserName()); + messageInfo.setUserId(String.valueOf(userByWxId.getUserId())); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + messageInfo.setCreateAt(sdf.format(now)); + messageInfo.setIsSee("0"); + messageInfoDao.insert(messageInfo); + if (userByWxId.getClientid() != null) { + userService.pushToSingle("提现失败提醒", content, userByWxId.getClientid()); + } + /*CommonInfo three = commonInfoService.findOne(77); + String apkey = ""; + if (three != null) { + apkey = three.getValue(); + } + if(StringUtils.isNotBlank(userByWxId.getOpenId())){ + LinkedHashMap data = new LinkedHashMap<>(); + data.put("first", new TemplateMessageItem("您好,您发起的提现失败了", "#d71345")); + data.put("keyword1", new TemplateMessageItem(money + " 元", "#d71345")); + data.put("keyword2", new TemplateMessageItem(date, "#d71345")); + data.put("keyword3", new TemplateMessageItem(content, "#d71345")); + data.put("remark", new TemplateMessageItem("请您按照失败原因修改相关信息后,重新提现!", null)); + sendWxMessage(apkey, data, userByWxId.getOpenId(), url); + }*/ + + } + + @Override + public Double selectCashOutSum(Long userId, Date startTime, Date endTime) { + return cashOutDao.selectCashOutSum(userId, startTime, endTime); + } + + @Override + public Double sumMoney(String time, Integer flag) { + return cashOutDao.sumMoney(time, flag); + } + + @Override + public Double sumMoneyMonthByUserId(String time, Long userId) { + return cashOutDao.sumMoneyMonthByUserId(time, userId); + } + + @Override + public Integer countMoney(String time, Integer flag) { + return cashOutDao.countMoney(time, flag); + } + + @Override + public Integer stayCount(String time, Integer flag) { + return cashOutDao.stayCount(time, flag); + } + + @Override + public Double stayMoney(String time, Integer flag) { + return cashOutDao.stayMoney(time, flag); + } + + @Override + public Integer selectCashCountByClassify(String time, Integer flag,Integer classify,Integer state) { + return cashOutDao.selectCashCountByClassify(time, flag,classify,state); + } + + @Override + public Double selectCashMoneyByClassify(String time, Integer flag,Integer classify,Integer state) { + return cashOutDao.selectCashMoneyByClassify(time, flag,classify,state); + } + + @Override + public void updateMayMoney(int i, Long userId, Double money) { + cashOutDao.updateMayMoney(i, userId, money); + } + + + @Override + public List selectCashOutLimit3() { + return cashOutDao.selectCashOutLimit3(); + } + + + @Override + @Transactional + public Result cashMoney(Long userId, Double money,Integer userType,Integer classify) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd"); + String nowDay = simpleDateFormat.format(new Date()); + String value = commonInfoService.findOne(334).getValue(); + if(StringUtils.isNotBlank(value)){ + boolean flag=true; + for(String day:value.split(",")){ + if(nowDay.equals(day)){ + flag=false; + break; + } + } + if(flag){ + return Result.error("请在"+value+"号进行提现!"); + } + } + + if (money == null || money <= 0.00) { + return Result.error("请不要输入小于0的数字,请输入正确的提现金额!"); + } + //最低提现金额 + CommonInfo one = commonInfoService.findOne(112); + if (one != null && money < Double.parseDouble(one.getValue())) { + return Result.error("输入金额不满足最低提现金额,请重新输入!"); + } + //最高提现金额 + CommonInfo one2 = commonInfoService.findOne(153); + if (one2 != null && money > Double.parseDouble(one2.getValue())) { + return Result.error(-100, "输入金额过大,不能大于" + one2.getValue() + ",请重新输入!"); + } + //手续费 + CommonInfo one1 = commonInfoService.findOne(152); + + //计算提现金额所需要的手续费 小于0.01 的按0.01来算 + Double mul = AmountCalUtils.mul(money, Double.parseDouble(one1.getValue())); + if (mul < 0.01) { + mul = 0.01; + } + //查询账户的余额 + UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(userId); + if(money>userMoney.getMoney().doubleValue()){ + return Result.error("金额不足,请输入正确的金额!"); + } + UserEntity userEntity = userService.selectUserById(userId); + CashOut cashOut = new CashOut(); + cashOut.setClassify(classify); + if(classify==1){ + cashOut.setZhifubao(userEntity.getZhiFuBao()); + cashOut.setZhifubaoName(userEntity.getZhiFuBaoName()); + }else{ + cashOut.setBankCard(userEntity.getBankCard()); + cashOut.setBankCardName(userEntity.getBankCardName()); + cashOut.setBankCardUserName(userEntity.getBankCardUserName()); + cashOut.setBankCardAddress(userEntity.getBankCardAddress()); + } + + //提现判断金额是否足够 + Double moneySum = AmountCalUtils.add(new BigDecimal(money), new BigDecimal(mul)).doubleValue(); //金额=提现金额+手续费 + Double moneySub = AmountCalUtils.sub(new BigDecimal(money), new BigDecimal(mul)).doubleValue(); //金额=提现金额+手续费 + if ((userMoney.getMoney()).compareTo(BigDecimal.valueOf(moneySum)) > -1) { //用户金额足够 + //扣除可提现金额直接在数据库进行操作 + //增加金额操作记录 + userMoneyService.updateMoney(2,userId,moneySum); + UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(userId); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setUserId(userId); + userMoneyDetails.setTitle("提现:" + money); + userMoneyDetails.setContent("支付宝提现:" + money + ",手续费:" + mul ); + userMoneyDetails.setType(2); + userMoneyDetails.setMoney(new BigDecimal(moneySum)); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userMoneyDetails.setCreateTime(sdf.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + cashOut.setState(0); + cashOut.setMoney(money.toString()); + cashOut.setCreateAt(sdf.format(new Date())); + cashOut.setUserId(userEntity.getUserId()); + cashOut.setRate(moneySum); + cashOut.setOrderNumber(String.valueOf(System.currentTimeMillis())); + cashOut.setUserType(userType); + baseMapper.insert(cashOut); + //扣除金额直接在数据库进行操作 + return Result.success("提现成功,将在三个工作日内到账,请耐心等待!"); + }else{ + //扣除可提现金额直接在数据库进行操作 + //增加金额操作记录 + userMoneyService.updateMoney(2,userId,money); + UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(userId); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setUserId(userId); + userMoneyDetails.setTitle("提现:" + moneySub); + userMoneyDetails.setContent("支付宝提现:" + moneySub + ",手续费:" + mul ); + userMoneyDetails.setType(2); + userMoneyDetails.setMoney(new BigDecimal(money)); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userMoneyDetails.setCreateTime(sdf.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + cashOut.setState(0); + cashOut.setMoney(moneySub.toString()); + cashOut.setCreateAt(sdf.format(new Date())); + cashOut.setUserId(userEntity.getUserId()); + cashOut.setRate(money); + cashOut.setOrderNumber(String.valueOf(System.currentTimeMillis())); + cashOut.setUserType(userType); + baseMapper.insert(cashOut); + return Result.success("提现成功,将在三个工作日内到账,请耐心等待!"); + } + } + +} diff --git a/src/main/java/com/sqx/modules/pay/service/impl/PayClassifyServiceImpl.java b/src/main/java/com/sqx/modules/pay/service/impl/PayClassifyServiceImpl.java new file mode 100644 index 0000000..15fcd05 --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/service/impl/PayClassifyServiceImpl.java @@ -0,0 +1,23 @@ +package com.sqx.modules.pay.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.modules.pay.dao.PayClassifyDao; +import com.sqx.modules.pay.entity.PayClassify; +import com.sqx.modules.pay.service.PayClassifyService; +import org.springframework.stereotype.Service; + +/** + * 充值分类 + */ +@Service +public class PayClassifyServiceImpl extends ServiceImpl implements PayClassifyService { + + + @Override + public int updatePayClassifyCouponId(Long payClassifyId){ + return baseMapper.updatePayClassifyCouponId(payClassifyId); + } + + + +} diff --git a/src/main/java/com/sqx/modules/pay/service/impl/PayDetailsServiceImpl.java b/src/main/java/com/sqx/modules/pay/service/impl/PayDetailsServiceImpl.java new file mode 100644 index 0000000..390daa5 --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/service/impl/PayDetailsServiceImpl.java @@ -0,0 +1,82 @@ +package com.sqx.modules.pay.service.impl; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.modules.pay.dao.PayDetailsDao; +import com.sqx.modules.pay.entity.PayDetails; +import com.sqx.modules.pay.service.PayDetailsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 充值记录 + */ +@Service +public class PayDetailsServiceImpl extends ServiceImpl implements PayDetailsService { + + /** + * 充值记录 + */ + @Autowired + private PayDetailsDao payDetailsDao; + + + @Override + public PageUtils selectPayDetails(int page, int limit, String startTime, String endTime, Long userId, Integer state) { + Page> pages = new Page<>(page, limit); + if (state != null && state == -1) { + state = null; + } + return new PageUtils(payDetailsDao.selectPayDetails(pages, startTime, endTime, userId, state)); + } + + @Override + public Double selectSumPay(String createTime, String endTime, Long userId) { + if (userId == null || userId == -1) { + return payDetailsDao.selectSumPay(createTime, endTime, null); + } + return payDetailsDao.selectSumPay(createTime, endTime, userId); + } + + @Override + public PageUtils payMemberAnalysis(int page, int limit, String time, Integer flag) { + Page> pages = new Page<>(page, limit); + return new PageUtils(payDetailsDao.payMemberAnalysis(pages, time, flag)); + } + + @Override + public PageUtils selectUserMemberList(int page, int limit, String phone) { + Page> pages = new Page<>(page, limit); + return new PageUtils(payDetailsDao.selectUserMemberList(pages, phone)); + } + + @Override + public Double selectSumMember(String time, Integer flag) { + return payDetailsDao.selectSumMember(time, flag); + } + + @Override + public Double selectSumPayByState(String time, Integer flag, Integer state) { + return payDetailsDao.selectSumPayByState(time, flag, state); + } + + @Override + public Double selectSumPayByClassify(String time, Integer flag, Integer classify,Integer payClassify) { + return payDetailsDao.selectSumPayByClassify(time, flag, classify,payClassify); + } + + @Override + public Double instantselectSumPay(String date, Long userId) { + return payDetailsDao.instantselectSumPay(date, userId); + } + + @Override + public Double selectSumPayByType(String time,Integer flag,Integer type) { + return payDetailsDao.selectSumPayByType(time, flag, type); + } + + +} diff --git a/src/main/java/com/sqx/modules/pay/service/impl/WxServiceImpl.java b/src/main/java/com/sqx/modules/pay/service/impl/WxServiceImpl.java new file mode 100644 index 0000000..89a86ed --- /dev/null +++ b/src/main/java/com/sqx/modules/pay/service/impl/WxServiceImpl.java @@ -0,0 +1,1197 @@ +package com.sqx.modules.pay.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.wxpay.sdk.WXPay; +import com.github.wxpay.sdk.WXPayConstants; +import com.github.wxpay.sdk.WXPayUtil; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.dao.UserMoneyDao; +import com.sqx.modules.app.dao.UserVipDao; +import com.sqx.modules.app.dao.VipDetailsDao; +import com.sqx.modules.app.entity.*; +import com.sqx.modules.app.service.UserCertificationService; +import com.sqx.modules.app.service.UserMoneyArtificerService; +import com.sqx.modules.app.service.UserMoneyDetailsService; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.dao.OrdersDao; +import com.sqx.modules.artificer.dao.RealNameDao; +import com.sqx.modules.artificer.dao.UserRechargeDao; +import com.sqx.modules.artificer.entity.*; +import com.sqx.modules.artificer.service.*; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.consortia.entity.Consortia; +import com.sqx.modules.consortia.service.ConsortiaService; +import com.sqx.modules.coupon.entity.Coupon; +import com.sqx.modules.coupon.entity.CouponIssue; +import com.sqx.modules.coupon.entity.CouponUser; +import com.sqx.modules.coupon.service.CouponIssueService; +import com.sqx.modules.coupon.service.CouponService; +import com.sqx.modules.coupon.service.CouponUserService; +import com.sqx.modules.message.entity.MessageInfo; +import com.sqx.modules.message.service.MessageService; +import com.sqx.modules.pay.config.WXConfig; +import com.sqx.modules.pay.dao.PayDetailsDao; +import com.sqx.modules.pay.entity.PayClassify; +import com.sqx.modules.pay.entity.PayDetails; +import com.sqx.modules.pay.service.PayClassifyService; +import com.sqx.modules.pay.service.WxService; +import com.sqx.modules.utils.*; +import jodd.util.StringUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.util.*; + +/** + * @author fang + * @date 2020/2/26 + */ +@Service +@Slf4j +public class WxServiceImpl implements WxService { + private static final String SPBILL_CREATE_IP = "127.0.0.1"; + private static final String TRADE_TYPE_APP = "APP"; + private static final String TRADE_TYPE_NATIVE = "NATIVE"; + private static final String TRADE_TYPE_JSAPI = "JSAPI"; + private static final String Wap = "MWEB"; + + @Autowired + private CommonInfoService commonInfoService; + @Autowired + private UserService userService; + @Autowired + private PayDetailsDao payDetailsDao; + @Autowired + private UserMoneyDao userMoneyDao; + @Autowired + private UserMoneyDetailsService userMoneyDetailsService; + @Autowired + private OrdersService ordersService; + @Autowired + private RealNameDao realNameDao; + @Autowired + private ArtificerService artificerService; + @Autowired + private OrdersMassageService ordersMassageService; + @Autowired + private MassageTypeService massageTypeService; + @Autowired + private OrdersDao ordersDao; + @Autowired + private PayClassifyService payClassifyService; + @Autowired + private CouponUserService couponUserService; + @Autowired + private CouponService couponService; + @Autowired + private CouponIssueService couponIssueService; + @Autowired + private VipDetailsDao vipDetailsDao; + @Autowired + private UserVipDao userVipDao; + @Autowired + private MessageService messageService; + @Autowired + private ConsortiaService consortiaService; + @Autowired + private UserMoneyArtificerService userMoneyArtificerService; + @Autowired + private ArtificerTimeService artificerTimeService; + @Autowired + private UserRechargeDao userRechargeDao; + + private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + @Override + public Result payMoney(Long userId,Long payClassifyId,Integer classify,HttpServletRequest request) throws Exception { + PayClassify payClassify = payClassifyService.getById(payClassifyId); + String generalOrder = getGeneralOrder(); + PayDetails payDetails = new PayDetails(); + payDetails.setState(0); + payDetails.setCreateTime(sdf.format(new Date())); + payDetails.setOrderId(generalOrder); + payDetails.setUserId(userId); + payDetails.setMoney(payClassify.getPrice().doubleValue()); + payDetails.setClassify(classify); + payDetails.setType(3); + payDetails.setRemark(String.valueOf(payClassifyId)); + payDetailsDao.insert(payDetails); + //用户在服务中充值余额,算技师业绩增加userRecharge表 + //查询用户在服务中的技师的订单id + List orders = ordersDao.selectList(Wrappers.lambdaQuery().eq(Orders::getUserId, userId).eq(Orders::getStatus, 6).orderByDesc(Orders::getCreateTime)); + if(orders.size() > 0){ + Long ordersId = orders.get(0).getOrdersId(); + Long artificerId = orders.get(0).getArtificerId(); + BigDecimal b = new BigDecimal(payClassify.getPrice().toString()); + BigDecimal sum = b; + UserRecharge o = new UserRecharge(); + o.setOrdersId(ordersId.intValue()); + o.setUserRecharge(sum); + o.setType("2"); + o.setUserId(userId.intValue()); + o.setCreateTime(LocalDateTime.now().toString()); + o.setArtificerId(artificerId.intValue()); + userRechargeDao.insert(o); + } + return pay(payClassify.getPrice().doubleValue(), classify, userId, generalOrder,request); + } + + + @Override + public Result payOrder(Long id, Integer classify,HttpServletRequest request) throws Exception { + Orders orders = ordersService.getById(id); + if (orders == null) { + return Result.error("订单生成失败,请重新下单!"); + }else if(orders.getStatus()!=1){ + return Result.error("订单状态异常,请刷新页面后重试!"); + } + + if(orders.getParentId()!=null && orders.getParentId()!=0){ + Orders orders1 = ordersDao.selectById(orders.getParentId()); + OrdersMassage ordersMassage = ordersMassageService.getOne(new QueryWrapper().eq("orders_id", orders1.getOrdersId())); + MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId()); + if(massageType.getAddNum()==null || massageType.getAddNum()==0){ + return Result.error("当前项目不允许加钟!"); + }else if(massageType.getAddNum()>0){ + if(orders1.getAddNum()!=null && orders1.getAddNum()>=massageType.getAddNum()){ + return Result.error("当前项目已超过最大加钟次数!"); + } + } + Integer duration=massageType.getDuration(); + String value1 = commonInfoService.findOne(395).getValue(); + if("是".equals(value1)){ + String value = commonInfoService.findOne(392).getValue(); + int minute = Integer.parseInt(value); + int i=1; + if(duration%minute==0){ + i=duration/minute; + }else{ + i=duration/minute; + i++; + } + ArtificerTime artificerTime = artificerTimeService.getOne(new QueryWrapper().eq("orders_id", orders.getParentId()).last(" order by artificer_time_id desc limit 1 ")); + String serveTime = artificerTime.getArtificerDate()+" "+artificerTime.getArtificerTime(); + String date=null; + String time=null; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date parse = sdf.parse(serveTime); + Calendar calendar=Calendar.getInstance(); + calendar.setTime(parse); + for(int j=0;j() + .eq("artificer_id", orders.getArtificerId()) + .eq("artificer_date", date).eq("artificer_time", time)); + if(artificerTime!=null){ + return Result.error("预约时间正忙,请更换其他时间!"); + } + } + } + + + } + PayDetails payDetails1 = payDetailsDao.selectByOrderId(orders.getOrdersNo()); + if(payDetails1==null){ + PayDetails payDetails = new PayDetails(); + payDetails.setState(0); + payDetails.setCreateTime(sdf.format(new Date())); + payDetails.setOrderId(orders.getOrdersNo()); + payDetails.setUserId(orders.getUserId()); + payDetails.setMoney(orders.getPayMoney().doubleValue()); + payDetails.setClassify(classify); + payDetails.setType(1); + payDetailsDao.insert(payDetails); + }else{ + payDetails1.setClassify(classify); + payDetailsDao.updateById(payDetails1); + } + + return pay(orders.getPayMoney().doubleValue(), classify, orders.getUserId(), orders.getOrdersNo(),request); + } + + @Override + public Result submitRealName( Long userId,Integer type,HttpServletRequest request) throws Exception { + CommonInfo two = commonInfoService.findOne(241); + double money = Double.parseDouble(two.getValue()); + String generalOrder = getGeneralOrder(); + PayDetails payDetails = new PayDetails(); + payDetails.setState(0); + payDetails.setCreateTime(sdf.format(new Date())); + payDetails.setOrderId(generalOrder); + payDetails.setUserId(userId); + payDetails.setMoney(money); + payDetails.setClassify(type); + payDetails.setType(2); + payDetailsDao.insert(payDetails); + return pays(money, type,userId, generalOrder,request); + } + + @Override + public Result payCoupon(Long userId, Integer type, Long couponIssueId,HttpServletRequest request) throws Exception { + CouponIssue couponIssue = couponIssueService.getById(couponIssueId); + if(couponIssue.getIsLimit()==1){ + //是否限购 + CouponUser couponUser = couponUserService.getOne(new QueryWrapper().eq("coupon_issue_id", couponIssueId)); + if(couponUser!=null){ + return Result.error("当前优惠券为限购,您已经拥有了!"); + } + if(couponIssue.getCouponNum()<=0){ + return Result.error("优惠券已经被抢完了!"); + } + } + double money = couponIssue.getPrice().doubleValue(); + String generalOrder = getGeneralOrder(); + PayDetails payDetails = payDetailsDao.selectByOrderId(generalOrder); + if(payDetails==null){ + payDetails = new PayDetails(); + payDetails.setState(0); + payDetails.setCreateTime(sdf.format(new Date())); + payDetails.setOrderId(generalOrder); + payDetails.setUserId(userId); + payDetails.setMoney(money); + payDetails.setClassify(type); + payDetails.setType(4); + payDetails.setRemark(String.valueOf(couponIssueId)); + payDetailsDao.insert(payDetails); + }else{ + payDetails.setClassify(type); + payDetailsDao.updateById(payDetails); + } + return pay(money, type, userId, generalOrder,request); + } + + @Override + public Result payUserVip(Long userId, Long vipDetailsId, Integer type, HttpServletRequest request) throws Exception { + VipDetails vipDetails = vipDetailsDao.selectOne(new QueryWrapper().eq("id", vipDetailsId)); + BigDecimal money = vipDetails.getMoney(); + String generalOrder = getGeneralOrder(); + PayDetails payDetails = new PayDetails(); + payDetails.setState(0); + payDetails.setCreateTime(sdf.format(new Date())); + payDetails.setOrderId(generalOrder); + payDetails.setUserId(userId); + payDetails.setMoney(money.doubleValue()); + payDetails.setClassify(type); + payDetails.setType(5); + payDetails.setRemark(String.valueOf(vipDetailsId)); + payDetailsDao.insert(payDetails); + return pay(money.doubleValue(), type,userId, generalOrder,request); + } + + @Override + public Result payUserMoneyArtificer(Long userId,Long artificerId,Long payClassifyId,BigDecimal money,Integer classify,HttpServletRequest request) throws Exception { + PayDetails payDetails = new PayDetails(); + if(payClassifyId!=null){ + PayClassify payClassify = payClassifyService.getById(payClassifyId); + money=payClassify.getPrice(); + payDetails.setRemark(String.valueOf(payClassifyId)); + } + String generalOrder = getGeneralOrder(); + payDetails.setState(0); + payDetails.setCreateTime(sdf.format(new Date())); + payDetails.setOrderId(generalOrder); + payDetails.setUserId(userId); + payDetails.setMoney(money.doubleValue()); + payDetails.setClassify(classify); + payDetails.setType(6); + payDetails.setRemark(String.valueOf(artificerId)); + payDetailsDao.insert(payDetails); + return pay(money.doubleValue(), classify, userId, generalOrder,request); + } + + + /** + * 微信支付订单生成 + * + * @param moneys 支付金额 带小数点 + * @param type 类型 1app 2 二维码支付 3小程序 公众号支付 + * @param userId 用户id + * @param outTradeNo 单号 + * @return + * @throws Exception + */ + private Result pay(Double moneys, Integer type, Long userId, String outTradeNo,HttpServletRequest request) throws Exception { + //h5服务域名配置 + CommonInfo oneu = commonInfoService.findOne(19); + String url; + if (type == 3) { + url = oneu.getValue() + "/sqx_fast/app/wxPay/notifyJsApi"; + } else if (type == 2 || type == 4) { + url = oneu.getValue() + "/sqx_fast/app/wxPay/notifyMp"; + } else { + url = oneu.getValue() + "/sqx_fast/app/wxPay/notify"; + } + String currentTimeMillis=(System.currentTimeMillis() / 1000)+""; + //后台服务名称 + CommonInfo one = commonInfoService.findOne(12); + log.info("回调地址:" + url); + Double mul = AmountCalUtils.mul(moneys, 100); + String money = String.valueOf(mul.intValue()); + String generateNonceStr = WXPayUtil.generateNonceStr(); + WXConfig config = new WXConfig(); + //微信小程序APPID 微信公众号APPID + if(type==1){ + config.setAppId(commonInfoService.findOne(74).getValue()); + }else if(type == 2 || type == 4){ + config.setAppId(commonInfoService.findOne(5).getValue()); + }else{ + config.setAppId(commonInfoService.findOne(45).getValue()); + } + //微信商户key + config.setKey(commonInfoService.findOne(75).getValue()); + //微信商户号mchId + config.setMchId(commonInfoService.findOne(76).getValue()); + WXPay wxpay = new WXPay(config); + Map data = new HashMap<>(); + data.put("appid", config.getAppID()); + data.put("mch_id", config.getMchID()); + data.put("nonce_str", generateNonceStr); + String body = one.getValue(); + data.put("body", body); + //生成商户订单号,不可重复 + data.put("out_trade_no", outTradeNo); + data.put("total_fee", money); + //自己的服务器IP地址 + data.put("spbill_create_ip", SPBILL_CREATE_IP); + //异步通知地址(请注意必须是外网) + data.put("notify_url", url); + //交易类型 + if (type == 1) { + data.put("trade_type", TRADE_TYPE_APP); + } else if (type == 2) { + data.put("trade_type", TRADE_TYPE_JSAPI); + } else if (type == 3) { + data.put("trade_type", TRADE_TYPE_JSAPI); + } else { + data.put("trade_type", Wap); + data.put("spbill_create_ip", HttpClientUtil.getIpAddress(request)); + } + //附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据 + data.put("attach", ""); + data.put("sign", WXPayUtil.generateSignature(data, config.getKey(), + WXPayConstants.SignType.MD5)); + if(type==3 || type==2){ + UserEntity userEntity = userService.queryByUserId(userId); + if(type==3){ + if(StringUtils.isNotBlank(userEntity.getOpenId())){ + data.put("openid", userEntity.getOpenId()); + } + }else{ + data.put("openid", userEntity.getWxOpenId()); + } + } + //使用官方API请求预付订单 + Map response = wxpay.unifiedOrder(data); + for (String key : response.keySet()) { + log.info("微信支付订单微信返回参数:keys:" + key + " value:" + response.get(key).toString()); + } + if ("SUCCESS".equals(response.get("return_code"))) {//主要返回以下5个参数 + + if (type == 1) { + Map param = new HashMap<>(); + param.put("appid", config.getAppID()); + param.put("partnerid", response.get("mch_id")); + param.put("prepayid", response.get("prepay_id")); + param.put("package", "Sign=WXPay"); + param.put("noncestr", generateNonceStr); + param.put("timestamp", currentTimeMillis); + param.put("sign", WXPayUtil.generateSignature(param, config.getKey(), + WXPayConstants.SignType.MD5)); + param.put("outtradeno", outTradeNo); + return Result.success().put("data", param); + } else { + Map param = new HashMap<>(); + param.put("appid", config.getAppID()); + param.put("partnerid", response.get("mch_id")); + param.put("prepayid", response.get("prepay_id")); + param.put("noncestr", generateNonceStr); + param.put("timestamp", currentTimeMillis); + /*param.put("sign", WXPayUtil.generateSignature(param, config.getKey(), + WXPayConstants.SignType.MD5));*/ + String stringSignTemp = "appId=" + config.getAppID() + "&nonceStr=" + generateNonceStr + "&package=prepay_id=" + response.get("prepay_id") + "&signType=MD5&timeStamp=" + currentTimeMillis + "" + "&key=" + config.getKey(); + String sign = MD5Util.md5Encrypt32Upper(stringSignTemp).toUpperCase(); + param.put("sign", sign); + param.put("outtradeno", outTradeNo); + param.put("package", "prepay_id=" + response.get("prepay_id"));//给前端返回的值 + param.put("mweb_url", response.get("mweb_url")); + param.put("trade_type", response.get("trade_type")); + param.put("return_msg", response.get("return_msg")); + param.put("result_code", response.get("result_code")); + param.put("signType", "MD5"); + return Result.success().put("data", param); + } + } + return Result.error("获取订单失败"); + } + + private Result pays(Double moneys, Integer type, Long userId, String outTradeNo,HttpServletRequest request) throws Exception { + //h5服务域名配置 + CommonInfo oneu = commonInfoService.findOne(19); + String url; + if (type == 3) { + url = oneu.getValue() + "/sqx_fast/app/wxPay/notifyJsApis"; + } else if (type == 2 || type == 4) { + url = oneu.getValue() + "/sqx_fast/app/wxPay/notifyMps"; + } else { + url = oneu.getValue() + "/sqx_fast/app/wxPay/notifys"; + } + String currentTimeMillis=(System.currentTimeMillis() / 1000)+""; + //后台服务名称 + CommonInfo one = commonInfoService.findOne(12); + log.info("回调地址:" + url); + Double mul = AmountCalUtils.mul(moneys, 100); + String money = String.valueOf(mul.intValue()); + String generateNonceStr = WXPayUtil.generateNonceStr(); + WXConfig config = new WXConfig(); + //微信小程序APPID 微信公众号APPID + if(type==1){ + config.setAppId(commonInfoService.findOne(260).getValue());//微信商户key + config.setKey(commonInfoService.findOne(245).getValue()); + //微信商户号mchId + config.setMchId(commonInfoService.findOne(246).getValue()); + }else if(type==2 || type == 4){ + config.setAppId(commonInfoService.findOne(5).getValue()); + //微信商户key + config.setKey(commonInfoService.findOne(75).getValue()); + //微信商户号mchId + config.setMchId(commonInfoService.findOne(76).getValue()); + }else{ + config.setAppId(commonInfoService.findOne(243).getValue()); + //微信商户key + config.setKey(commonInfoService.findOne(245).getValue()); + //微信商户号mchId + config.setMchId(commonInfoService.findOne(246).getValue()); + } + + WXPay wxpay = new WXPay(config); + Map data = new HashMap<>(); + data.put("appid", config.getAppID()); + data.put("mch_id", config.getMchID()); + data.put("nonce_str", generateNonceStr); + String body = one.getValue(); + data.put("body", body); + //生成商户订单号,不可重复 + data.put("out_trade_no", outTradeNo); + data.put("total_fee", money); + //自己的服务器IP地址 + data.put("spbill_create_ip", SPBILL_CREATE_IP); + //异步通知地址(请注意必须是外网) + data.put("notify_url", url); + //交易类型 + if (type == 1) { + data.put("trade_type", TRADE_TYPE_APP); + } else if (type == 2) { + data.put("trade_type", TRADE_TYPE_JSAPI); + } else if (type == 3) { + data.put("trade_type", TRADE_TYPE_JSAPI); + } else { + data.put("trade_type", Wap); + data.put("spbill_create_ip", HttpClientUtil.getIpAddress(request)); + } + //附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据 + data.put("attach", ""); + data.put("sign", WXPayUtil.generateSignature(data, config.getKey(), + WXPayConstants.SignType.MD5)); + if(type==3 || type==2){ + UserEntity userEntity = userService.queryByUserId(userId); + if(type==3){ + if(StringUtils.isNotBlank(userEntity.getArtificerOpenId())){ + data.put("openid", userEntity.getArtificerOpenId()); + } + }else{ + data.put("openid", userEntity.getWxOpenId()); + } + } + //使用官方API请求预付订单 + Map response = wxpay.unifiedOrder(data); + for (String key : response.keySet()) { + log.info("微信支付订单微信返回参数:keys:" + key + " value:" + response.get(key).toString()); + } + if ("SUCCESS".equals(response.get("return_code"))) {//主要返回以下5个参数 + + if (type == 1) { + Map param = new HashMap<>(); + param.put("appid", config.getAppID()); + param.put("partnerid", response.get("mch_id")); + param.put("prepayid", response.get("prepay_id")); + param.put("package", "Sign=WXPay"); + param.put("noncestr", generateNonceStr); + param.put("timestamp", currentTimeMillis); + param.put("sign", WXPayUtil.generateSignature(param, config.getKey(), + WXPayConstants.SignType.MD5)); + param.put("outtradeno", outTradeNo); + return Result.success().put("data", param); + } else { + Map param = new HashMap<>(); + param.put("appid", config.getAppID()); + param.put("partnerid", response.get("mch_id")); + param.put("prepayid", response.get("prepay_id")); + param.put("noncestr", generateNonceStr); + param.put("timestamp", currentTimeMillis); + /*param.put("sign", WXPayUtil.generateSignature(param, config.getKey(), + WXPayConstants.SignType.MD5));*/ + String stringSignTemp = "appId=" + config.getAppID() + "&nonceStr=" + generateNonceStr + "&package=prepay_id=" + response.get("prepay_id") + "&signType=MD5&timeStamp=" + currentTimeMillis + "" + "&key=" + config.getKey(); + String sign = MD5Util.md5Encrypt32Upper(stringSignTemp).toUpperCase(); + param.put("sign", sign); + param.put("outtradeno", outTradeNo); + param.put("package", "prepay_id=" + response.get("prepay_id"));//给前端返回的值 + param.put("mweb_url", response.get("mweb_url")); + param.put("trade_type", response.get("trade_type")); + param.put("return_msg", response.get("return_msg")); + param.put("result_code", response.get("result_code")); + param.put("signType", "MD5"); + return Result.success().put("data", param); + } + } + return Result.error("获取订单失败"); + } + + @Override + public String payBack(String resXml, Integer type) { + WXConfig config = null; + try { + config = new WXConfig(); + } catch (Exception e) { + e.printStackTrace(); + } + log.error("进入回调了!!!"); + if(type==1){ + config.setAppId(commonInfoService.findOne(74).getValue()); + }else if(type==2){ + config.setAppId(commonInfoService.findOne(5).getValue()); + }else{ + config.setAppId(commonInfoService.findOne(45).getValue()); + } + config.setKey(commonInfoService.findOne(75).getValue()); + config.setMchId(commonInfoService.findOne(76).getValue()); + WXPay wxpay = new WXPay(config); + String xmlBack = ""; + Map notifyMap = null; + try { + notifyMap = WXPayUtil.xmlToMap(resXml); // 调用官方SDK转换成map类型数据 + if (wxpay.isPayResultNotifySignatureValid(notifyMap)) {//验证签名是否有效,有效则进一步处理 + log.error("验证成功!!!"); + String return_code = notifyMap.get("return_code");//状态 + String out_trade_no = notifyMap.get("out_trade_no");//商户订单号 + if (return_code.equals("SUCCESS")) { + log.error("验证成功222!!!"); + if (out_trade_no != null) { + // 注意特殊情况:订单已经退款,但收到了支付结果成功的通知,不应把商户的订单状态从退款改成支付成功 + // 注意特殊情况:微信服务端同样的通知可能会多次发送给商户系统,所以数据持久化之前需要检查是否已经处理过了,处理了直接返回成功标志 + //业务数据持久化 + log.error("订单号!!!" + out_trade_no); + PayDetails payDetails = payDetailsDao.selectByOrderId(out_trade_no); + if (payDetails.getState() == 0) { + payDetailsDao.updateState(payDetails.getId(), 1, sdf.format(new Date()), ""); + if(payDetails.getType()==1){ + Orders orders = ordersService.selectOrdersByOrderNo(payDetails.getOrderId()); + orders.setStatus(2); + orders.setPayWay(payDetails.getClassify()); + orders.setPayTime(sdf.format(new Date())); + + + BigDecimal pingMoney=orders.getPayMoney(); + UserEntity user = userService.selectUserById(orders.getUserId()); + + UserEntity oneUser = userService.queryByInvitationCode(user.getInviterCode()); + + BigDecimal oneUserMoney=BigDecimal.ZERO; + if(oneUser!=null && oneUser.getIsAgency()!=null && oneUser.getIsAgency()==1){ + orders.setOneUserId(oneUser.getUserId()); + orders.setOneUserName(oneUser.getUserName()); + oneUserMoney=pingMoney.multiply(oneUser.getUserRate()); + + } + + Artificer artificer = artificerService.getById(orders.getArtificerId()); + + UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); + + UserEntity oneArtificerUser = userService.queryByInvitationCode(artificerUser.getInviterCode()); + + BigDecimal oneArtificerMoney=BigDecimal.ZERO; + if(oneArtificerUser!=null && oneArtificerUser.getIsAgency()!=null && oneArtificerUser.getIsAgency()==1){ + orders.setOneArtificerUserId(oneArtificerUser.getUserId()); + orders.setOneArtificerUserName(oneArtificerUser.getUserName()); + oneArtificerMoney=pingMoney.multiply(oneArtificerUser.getShopRate()); + + } + BigDecimal shopMoney=BigDecimal.ZERO; + if(artificerUser.getConsortiaId()!=null){ + Consortia consortia = consortiaService.getById(artificerUser.getConsortiaId()); + if(consortia!=null && consortia.getUserId()!=null){ + UserEntity consortiaUser = userService.getById(consortia.getUserId()); + if(consortiaUser!=null){ + shopMoney = pingMoney.multiply(consortia.getRate()); + orders.setConsortiaId(consortia.getConsortiaId()); + orders.setShopUserId(consortiaUser.getUserId()); + orders.setShopUserName(consortiaUser.getUserName()); + + } + } + } + pingMoney=pingMoney.subtract(orders.getArtificerMoney()); + pingMoney=pingMoney.subtract(oneUserMoney); + pingMoney=pingMoney.subtract(oneArtificerMoney); + pingMoney=pingMoney.subtract(shopMoney); + orders.setShopMoney(shopMoney); + orders.setOneUserMoney(oneUserMoney); + orders.setOneArtificerMoney(oneArtificerMoney); + orders.setPingMoney(pingMoney); + ordersService.updateById(orders); + + if(orders.getParentId()!=null && orders.getParentId()!=0){ + String value1 = commonInfoService.findOne(395).getValue(); + OrdersMassage ordersMassage = ordersMassageService.getOne(new QueryWrapper().eq("orders_id", orders.getOrdersId())); + MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId()); + Integer duration=massageType.getDuration(); + Calendar calendar=Calendar.getInstance(); + if("是".equals(value1)){ + ArtificerTime artificerTime = artificerTimeService.getOne(new QueryWrapper().eq("orders_id", orders.getParentId()).last(" order by artificer_time_id desc limit 1 ")); + String serveTime = artificerTime.getArtificerDate()+" "+artificerTime.getArtificerTime(); + String value = commonInfoService.findOne(392).getValue(); + int minute = Integer.parseInt(value); + int i=1; + if(duration%minute==0){ + i=duration/minute; + }else{ + i=duration/minute; + i++; + } + + SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date parse = sdf1.parse(serveTime); + + calendar.setTime(parse); + for(int j=0;j().eq("orders_id", orders1.getOrdersId())); + massageType = massageTypeService.getById(ordersMassage.getMassageId()); + duration=massageType.getDuration(); + String endTime = orders1.getEndTime(); + Date date = DateUtils.stringToDate(endTime, "yyyy-MM-dd HH:mm:ss"); + calendar=Calendar.getInstance(); + if(date.getTime()>System.currentTimeMillis()){ + calendar.setTime(date); + } + calendar.add(Calendar.MINUTE,duration); + orders1.setEndTime(endTime); + } + + + ordersDao.updateById(orders1); + }else{ + MessageInfo messageInfo=new MessageInfo(); + messageInfo.setState("16"); + messageInfo.setTitle("新订单通知"); + messageInfo.setUserId("0"); + messageInfo.setIsSee("0"); + messageService.saveBody(messageInfo); + } + + ordersService.sendMsg(orders); + }else if(payDetails.getType()==2){ + //缴纳保证金 + Double cashDeposit = payDetails.getMoney(); + Long userId = payDetails.getUserId(); + userMoneyDao.updateCashDeposit(1, userId, cashDeposit); + UserEntity userEntity = userService.selectUserById(userId); + userEntity.setIsCashDeposit(2); + userService.updateById(userEntity); + //交保证金的记录 + UserMoneyDetails userMoneyDetails=new UserMoneyDetails(); + userMoneyDetails.setUserId(userId); + userMoneyDetails.setTitle("缴纳保证金"); + userMoneyDetails.setContent("已缴纳保证金:"+cashDeposit+"元"); + userMoneyDetails.setType(1); + userMoneyDetails.setMoney(BigDecimal.valueOf(cashDeposit)); + userMoneyDetails.setState(2); + userMoneyDetails.setClassify(1); + userMoneyDetails.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + }else if(payDetails.getType()==3){ + PayClassify payClassify = payClassifyService.getById(Long.parseLong(payDetails.getRemark())); + userMoneyDao.updateMayMoney(1, payDetails.getUserId(), payClassify.getPrice().doubleValue()); + UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); + userMoneyDetails.setUserId(payDetails.getUserId()); + userMoneyDetails.setTitle("微信充值"); + userMoneyDetails.setContent("微信充值:"+payClassify.getPrice()); + userMoneyDetails.setType(1); + userMoneyDetails.setMoney(payClassify.getPrice()); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userMoneyDetails.setCreateTime(sdf.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + + if(payClassify.getCouponId()!=null && payClassify.getGiveNum()>0){ + for(int i=0;i().eq("id", Long.parseLong(payDetails.getRemark()))); + //查看用户是否是会员 + UserVip userVip = userVipDao.selectOne(new QueryWrapper().eq("user_id", userId)); + Calendar cal = Calendar.getInstance(); + if(userVip!=null){ + Date endDate = null; + try { + endDate = sdf.parse(userVip.getEndTime()); + if (endDate != null && System.currentTimeMillis() < (endDate.getTime())) { + cal.setTime(endDate); + } + } catch (Exception e) { + e.getMessage(); + } + }else{ + userVip=new UserVip(); + //设置会员类型 + userVip.setVipNameType(vipDetails.getVipNameType()); + //设置开通会员的用户id + userVip.setUserId(userId); + //设置会员的购买时间 + userVip.setCreateTime(sdf.format(new Date())); + } + + MessageInfo messageInfo=new MessageInfo(); + UserMoneyDetails userMoneyDetails=new UserMoneyDetails(); + userMoneyDetails.setMoney(money); + userMoneyDetails.setUserId(userId); + + if ((vipDetails.getVipNameType().equals(0))) { + //月 + userMoneyDetails.setContent("微信开通月卡会员"); + messageInfo.setContent("微信开通月卡会员"); + cal.add(Calendar.MONTH, 1); + } else if ((vipDetails.getVipNameType()).equals(1)) { + //季 + userMoneyDetails.setContent("微信开通季卡会员"); + messageInfo.setContent("微信开通季卡会员"); + cal.add(Calendar.MONTH, 3); + } else { + //年 + userMoneyDetails.setContent("微信开通年费会员"); + messageInfo.setContent("微信开通年费会员"); + cal.add(Calendar.YEAR, 1); + } + + userVip.setEndTime(sdf.format(cal.getTime())); + if(userVip.getVipId()!=null){ + userVipDao.updateById(userVip); + }else{ + userVipDao.insert(userVip); + } + userMoneyDetails.setTitle("开通会员"); + userMoneyDetails.setType(2); + userMoneyDetails.setCreateTime(sdf.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + UserEntity userEntity = userService.selectUserById(userId); + messageInfo.setTitle("开通会员"); + messageInfo.setState(String.valueOf(4)); + messageInfo.setUserName(userEntity.getUserName()); + messageInfo.setUserId(String.valueOf(userEntity.getUserId())); + messageInfo.setCreateAt(sdf.format(new Date())); + messageInfo.setIsSee("0"); + messageService.saveBody(messageInfo); + if(StringUtil.isNotBlank(userEntity.getClientid())){ + userService.pushToSingle(messageInfo.getTitle(),messageInfo.getContent(),userEntity.getClientid()); + } + + }else if(payDetails.getType()==6){ + double money=payDetails.getMoney(); + if(StringUtils.isNotBlank(payDetails.getRemark())){ + PayClassify payClassify = payClassifyService.getById(Long.parseLong(payDetails.getRemark())); + if(payClassify.getCouponId()!=null && payClassify.getGiveNum()>0){ + for(int i=0;i().eq("user_id", payDetails.getUserId()).eq("artificer_id", artificerId)); + if(userMoneyArtificer==null){ + userMoneyArtificer=new UserMoneyArtificer(); + userMoneyArtificer.setUserId(payDetails.getUserId()); + userMoneyArtificer.setArtificerId(artificerId); + userMoneyArtificer.setMoney(BigDecimal.valueOf(money)); + userMoneyArtificer.setCreateTime(DateUtils.format(new Date())); + userMoneyArtificerService.save(userMoneyArtificer); + }else{ + userMoneyArtificerService.updateMoney(1, payDetails.getUserId(),artificerId, money); + } + Artificer artificer = artificerService.getById(artificerId); + + UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); + userMoneyDetails.setClassify(8); + userMoneyDetails.setUserId(payDetails.getUserId()); + userMoneyDetails.setTitle("微信充值"); + userMoneyDetails.setContent("指定技师“"+artificer.getArtificerName()+"”钱包微信充值:"+money); + userMoneyDetails.setType(1); + userMoneyDetails.setMoney(BigDecimal.valueOf(money)); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userMoneyDetails.setCreateTime(sdf.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + + } + } + System.err.println("微信手机支付回调成功订单号:" + out_trade_no + ""); + xmlBack = "" + "" + "" + " "; + } else { + System.err.println("微信手机支付回调成功订单号:" + out_trade_no + ""); + xmlBack = "" + "" + "" + " "; + } + } else { + } + return xmlBack; + } else { + // 签名错误,如果数据里没有sign字段,也认为是签名错误 + System.err.println("手机支付回调通知签名错误"); + xmlBack = "" + "" + "" + " "; + return xmlBack; + } + } catch (Exception e) { + System.err.println("手机支付回调通知失败" + e); + xmlBack = "" + "" + "" + " "; + } + return xmlBack; + } + + @Override + public String payBacks(String resXml, Integer type) { + WXConfig config = null; + try { + config = new WXConfig(); + } catch (Exception e) { + e.printStackTrace(); + } + log.error("进入回调了!!!"); + if(type==1){ + config.setAppId(commonInfoService.findOne(260).getValue()); + config.setKey(commonInfoService.findOne(245).getValue()); + config.setMchId(commonInfoService.findOne(246).getValue()); + }else if(type==2){ + config.setAppId(commonInfoService.findOne(5).getValue()); + config.setKey(commonInfoService.findOne(75).getValue()); + config.setMchId(commonInfoService.findOne(76).getValue()); + }else{ + config.setAppId(commonInfoService.findOne(243).getValue()); + config.setKey(commonInfoService.findOne(245).getValue()); + config.setMchId(commonInfoService.findOne(246).getValue()); + } + + WXPay wxpay = new WXPay(config); + String xmlBack = ""; + Map notifyMap = null; + try { + notifyMap = WXPayUtil.xmlToMap(resXml); // 调用官方SDK转换成map类型数据 + if (wxpay.isPayResultNotifySignatureValid(notifyMap)) {//验证签名是否有效,有效则进一步处理 + log.error("验证成功!!!"); + String return_code = notifyMap.get("return_code");//状态 + String out_trade_no = notifyMap.get("out_trade_no");//商户订单号 + if (return_code.equals("SUCCESS")) { + log.error("验证成功222!!!"); + if (out_trade_no != null) { + // 注意特殊情况:订单已经退款,但收到了支付结果成功的通知,不应把商户的订单状态从退款改成支付成功 + // 注意特殊情况:微信服务端同样的通知可能会多次发送给商户系统,所以数据持久化之前需要检查是否已经处理过了,处理了直接返回成功标志 + //业务数据持久化 + log.error("订单号!!!" + out_trade_no); + PayDetails payDetails = payDetailsDao.selectByOrderId(out_trade_no); + if (payDetails.getState() == 0) { + payDetailsDao.updateState(payDetails.getId(), 1, sdf.format(new Date()), ""); + if(payDetails.getType()==1){ + Orders orders = ordersService.selectOrdersByOrderNo(payDetails.getOrderId()); + orders.setStatus(2); + orders.setPayTime(sdf.format(new Date())); + ordersService.updateById(orders); + ordersService.sendMsg(orders); + }else if(payDetails.getType()==2){ + //缴纳保证金 + Double cashDeposit = payDetails.getMoney(); + Long userId = payDetails.getUserId(); + userMoneyDao.updateCashDeposit(1, userId, cashDeposit); + UserEntity userEntity = userService.selectUserById(userId); + userEntity.setIsCashDeposit(2); + userService.updateById(userEntity); + //交保证金的记录 + UserMoneyDetails userMoneyDetails=new UserMoneyDetails(); + userMoneyDetails.setUserId(userId); + userMoneyDetails.setTitle("缴纳保证金"); + userMoneyDetails.setContent("已缴纳保证金:"+cashDeposit+"元"); + userMoneyDetails.setType(1); + userMoneyDetails.setMoney(BigDecimal.valueOf(cashDeposit)); + userMoneyDetails.setState(2); + userMoneyDetails.setClassify(1); + userMoneyDetails.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + }else if(payDetails.getType()==3){ + userMoneyDao.updateMayMoney(1, payDetails.getUserId(), payDetails.getMoney()); + UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); + userMoneyDetails.setUserId(payDetails.getUserId()); + userMoneyDetails.setTitle("微信充值"); + userMoneyDetails.setContent("微信充值:"+payDetails.getMoney()); + userMoneyDetails.setType(1); + userMoneyDetails.setMoney(BigDecimal.valueOf(payDetails.getMoney())); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userMoneyDetails.setCreateTime(sdf.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + } + } + System.err.println("微信手机支付回调成功订单号:" + out_trade_no + ""); + xmlBack = "" + "" + "" + " "; + } else { + System.err.println("微信手机支付回调成功订单号:" + out_trade_no + ""); + xmlBack = "" + "" + "" + " "; + } + } else { + } + return xmlBack; + } else { + // 签名错误,如果数据里没有sign字段,也认为是签名错误 + System.err.println("手机支付回调通知签名错误"); + xmlBack = "" + "" + "" + " "; + return xmlBack; + } + } catch (Exception e) { + System.err.println("手机支付回调通知失败" + e); + xmlBack = "" + "" + "" + " "; + } + return xmlBack; + } + + + public String getGeneralOrder() { + Date date = new Date(); + String newString = String.format("%0" + 4 + "d", (int) ((Math.random() * 9 + 1) * 1000)); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String format = sdf.format(date); + return format + newString; + } + + + @Override + public boolean refund(String ordersNo,BigDecimal payMoney,BigDecimal refundMoney,Integer payWay) { + WXConfigUtil config = null; + try { + config = new WXConfigUtil(); + } catch (Exception e) { + e.printStackTrace(); + } + int commInfoId = 0; +// Integer payWay = null; + //orders.getPayWay(); //支付方式 1app微信 2微信公众号 3微信小程序 4微信公众号 外链支付 6支付宝 5零钱 + switch (payWay) { + case 1: + commInfoId = 74; + break; //appId + case 2: + commInfoId = 5; + break; //公众号id + case 3: + commInfoId = 45; + break; //小程序id + case 4: + commInfoId = 5; + break; //小程序id + } + if(config==null){ + return false; + } + config.setAppId(commonInfoService.findOne(commInfoId).getValue()); + config.setKey(commonInfoService.findOne(75).getValue()); + config.setMchId(commonInfoService.findOne(76).getValue()); + WXPay wxpay = new WXPay(config); + Map data = new HashMap<>(); + data.put("appid", config.getAppID()); + data.put("mch_id", config.getMchID()); + data.put("nonce_str", WXPayUtil.generateNonceStr()); + try { + data.put("sign", WXPayUtil.generateSignature(data, config.getKey(), WXPayConstants.SignType.MD5)); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + data.put("out_trade_no", ordersNo); //订单号,支付单号一致 + data.put("out_refund_no", ordersNo); //退款单号,同一笔用不同的退款单号 + double total_fee = 0.00; + data.put("total_fee", new Double(payMoney.doubleValue() * 100).intValue() + ""); //1块等于微信支付传入100); + data.put("refund_fee", new Double(refundMoney.doubleValue() * 100).intValue() + ""); //1块等于微信支付传入100); + //使用官方API退款 + try { + Map response = wxpay.refund(data); + if ("SUCCESS".equals(response.get("return_code"))) {//主要返回以下5个参数 + log.error("退款成功!"); + return true; + } else { + log.error("退款失败!订单号:"+ordersNo); + for (String key : response.keySet()) { + log.info("微信退款失败返回参数:keys:" + key + " value:" + response.get(key).toString()); + } + return false; + } + } catch (Exception e) { + log.info("退款异常:订单号"+ordersNo,e); + e.printStackTrace(); + return false; + } + } + + + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/risk/controller/RiskController.java b/src/main/java/com/sqx/modules/risk/controller/RiskController.java new file mode 100644 index 0000000..5dc8c8c --- /dev/null +++ b/src/main/java/com/sqx/modules/risk/controller/RiskController.java @@ -0,0 +1,54 @@ +package com.sqx.modules.risk.controller; + + +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.risk.service.RiskService; +import com.sqx.modules.app.service.UserService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +@RequestMapping("/risk") +@Api(value = "风险管理", tags = {"风险管理"}) +public class RiskController { + + @Autowired + private RiskService riskService; + @Autowired + private UserService userService; + + + @GetMapping("/selectRiskList") + @ApiOperation("查询风险列表") + public Result selectRiskList(Integer page,Integer limit,String userName,String phone,Integer riskType){ + return riskService.selectRiskList(page, limit, userName, phone, riskType); + } + + @GetMapping("/selectRiskGroupList") + @ApiOperation("查询风险列表分组") + public Result selectRiskGroupList(Integer page,Integer limit, String userName, String phone, Integer riskSort){ + return riskService.selectRiskGroupList(page, limit, userName, phone, riskSort); + } + + @PostMapping("/updateRiskUser") + @ApiOperation("标记为风险用户或取消标记") + public Result updateRiskUser(Long userId){ + UserEntity user = userService.getById(userId); + if(user.getRisk()!=null && user.getRisk()==1){ + user.setRisk(2); + }else{ + user.setRisk(1); + } + userService.updateById(user); + return Result.success(); + } + + +} diff --git a/src/main/java/com/sqx/modules/risk/controller/app/AppRiskController.java b/src/main/java/com/sqx/modules/risk/controller/app/AppRiskController.java new file mode 100644 index 0000000..8b657be --- /dev/null +++ b/src/main/java/com/sqx/modules/risk/controller/app/AppRiskController.java @@ -0,0 +1,56 @@ +package com.sqx.modules.risk.controller.app; + + +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.risk.entity.Risk; +import com.sqx.modules.risk.service.RiskService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Date; + + +@RestController +@RequestMapping("/app/risk") +@Api(value = "风险管理", tags = {"风险管理"}) +public class AppRiskController { + + @Autowired + private RiskService riskService; + + @Login + @PostMapping("/insertRisk") + @ApiOperation("触发风险") + public Result insertRisk(@RequestAttribute Long userId,Integer riskType, String content,Long byUserId){ + Risk risk=new Risk(); + if(byUserId!=null){ + risk.setUserId(byUserId); + }else{ + risk.setUserId(userId); + } + if(riskType==6){ + risk.setContent("用户被举报:"+content); + }else{ + risk.setContent("系统检测触发关键词:"+content); + } + risk.setRiskType(riskType); + risk.setCreateTime(DateUtils.format(new Date())); + riskService.save(risk); + return Result.success(); + } + + + + + + + + +} diff --git a/src/main/java/com/sqx/modules/risk/dao/RiskDao.java b/src/main/java/com/sqx/modules/risk/dao/RiskDao.java new file mode 100644 index 0000000..560550e --- /dev/null +++ b/src/main/java/com/sqx/modules/risk/dao/RiskDao.java @@ -0,0 +1,19 @@ +package com.sqx.modules.risk.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.risk.entity.Risk; +import org.apache.ibatis.annotations.Mapper; + +import java.util.Map; + + +@Mapper +public interface RiskDao extends BaseMapper { + + IPage selectRiskList(Page page,String userName,String phone,Integer riskType); + + IPage> selectRiskGroupList(Page> page, String userName, String phone,Integer riskSort); + +} diff --git a/src/main/java/com/sqx/modules/risk/entity/Risk.java b/src/main/java/com/sqx/modules/risk/entity/Risk.java new file mode 100644 index 0000000..65aa9ad --- /dev/null +++ b/src/main/java/com/sqx/modules/risk/entity/Risk.java @@ -0,0 +1,56 @@ +package com.sqx.modules.risk.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.sqx.modules.app.entity.UserEntity; +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description risk + * @author fang + * @date 2022-10-31 + */ +@Data +@ApiModel("风险记录") +@TableName("risk") +public class Risk implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 风险记录 + */ + private Long riskId; + + /** + * 风险类型(1ip属地风险 2动态 3动态评论 4服务评论 5聊天 6举报) + */ + private Integer riskType; + + /** + * 用户id + */ + private Long userId; + + @TableField(exist = false) + private UserEntity user; + + + /** + * 触发内容 + */ + private String content; + + /** + * 时间 + */ + private String createTime; + + public Risk() {} +} diff --git a/src/main/java/com/sqx/modules/risk/service/RiskService.java b/src/main/java/com/sqx/modules/risk/service/RiskService.java new file mode 100644 index 0000000..f65d2d7 --- /dev/null +++ b/src/main/java/com/sqx/modules/risk/service/RiskService.java @@ -0,0 +1,15 @@ +package com.sqx.modules.risk.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.risk.entity.Risk; + + +public interface RiskService extends IService { + + Result selectRiskList(Integer page,Integer limit, String userName, String phone, Integer riskType); + + Result selectRiskGroupList(Integer page,Integer limit, String userName, String phone, Integer riskSort); + +} diff --git a/src/main/java/com/sqx/modules/risk/service/impl/RiskServiceImpl.java b/src/main/java/com/sqx/modules/risk/service/impl/RiskServiceImpl.java new file mode 100644 index 0000000..071c59e --- /dev/null +++ b/src/main/java/com/sqx/modules/risk/service/impl/RiskServiceImpl.java @@ -0,0 +1,52 @@ +package com.sqx.modules.risk.service.impl; + + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.risk.dao.RiskDao; +import com.sqx.modules.risk.entity.Risk; +import com.sqx.modules.risk.service.RiskService; +import com.sqx.modules.app.service.UserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + + +@Service("RiskService") +public class RiskServiceImpl extends ServiceImpl implements RiskService { + + @Autowired + private UserService userService; + + @Override + public Result selectRiskList(Integer page,Integer limit, String userName, String phone, Integer riskType){ + IPage riskIPage = baseMapper.selectRiskList(new Page<>(page, limit), userName, phone, riskType); + List records = riskIPage.getRecords(); + for(Risk risk:records){ + risk.setUser(userService.getById(risk.getUserId())); + } + return Result.success().put("data",new PageUtils(riskIPage)); + } + + + @Override + public Result selectRiskGroupList(Integer page,Integer limit, String userName, String phone, Integer riskSort){ + IPage> mapIPage = baseMapper.selectRiskGroupList(new Page<>(page, limit), userName, phone, riskSort); + List> records = mapIPage.getRecords(); + for(Map risk:records){ + risk.put("user",userService.getById(Long.parseLong(String.valueOf(risk.get("userId"))))); + } + return Result.success().put("data",new PageUtils(mapIPage)); + } + + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/search/Response/SearchResponse.java b/src/main/java/com/sqx/modules/search/Response/SearchResponse.java new file mode 100644 index 0000000..da91e63 --- /dev/null +++ b/src/main/java/com/sqx/modules/search/Response/SearchResponse.java @@ -0,0 +1,22 @@ +package com.sqx.modules.search.Response; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SearchResponse implements Serializable { + + //用户的搜索记录 + List userSearchName = new ArrayList<>(); + //所有搜索记录前几名 + List AllSerchName = new ArrayList<>(); + + +} diff --git a/src/main/java/com/sqx/modules/search/controller/SearchController.java b/src/main/java/com/sqx/modules/search/controller/SearchController.java new file mode 100644 index 0000000..88d02d3 --- /dev/null +++ b/src/main/java/com/sqx/modules/search/controller/SearchController.java @@ -0,0 +1,46 @@ +package com.sqx.modules.search.controller; + +import com.sqx.common.utils.Result; +import com.sqx.modules.search.entity.Search; +import com.sqx.modules.search.service.SearchService; +import com.sqx.modules.sys.controller.AbstractController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value = "搜索记录", tags = {"搜索记录"}) +@RequestMapping(value = "/search") +public class SearchController extends AbstractController { + @Autowired + private SearchService searchService; + @PostMapping("/insertSearch") + @ApiOperation("记录搜索信息") + public Result insertSearch(@RequestBody Search search){ + return searchService.insertSearch(search); + } + @GetMapping("/selectByUserId") + @ApiOperation("查看搜索信息") + public Result selectByUserId(Long userId){ + return searchService.selectByUserId(userId); + } + + @GetMapping("/deleteById") + @ApiOperation("删除搜索信息") + public Result deleteById(Long id){ + return searchService.deleteById(id); + } + + + + + + + + + + + + +} diff --git a/src/main/java/com/sqx/modules/search/controller/app/AppSearchController.java b/src/main/java/com/sqx/modules/search/controller/app/AppSearchController.java new file mode 100644 index 0000000..e3b4f66 --- /dev/null +++ b/src/main/java/com/sqx/modules/search/controller/app/AppSearchController.java @@ -0,0 +1,46 @@ +package com.sqx.modules.search.controller.app; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.app.entity.App; +import com.sqx.modules.search.entity.Search; +import com.sqx.modules.search.service.AppSearchService; +import com.sqx.modules.search.service.SearchService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; + +/** + * 搜索记录 + * + * @author liyuan + * @since 2021-07-17 + */ +@RestController +@RequestMapping("app/Search") +@AllArgsConstructor +@Slf4j +public class AppSearchController { + + private AppSearchService appSearchService; + /** + * 查询搜索记录 + */ + @CrossOrigin + @Login + @RequestMapping(value = "/selectAppSearchNum", method = RequestMethod.GET) + public Result selectAppSearchNum(@RequestAttribute Long userId) { + return appSearchService.selectAppSearchNum(userId); + } + + /** + * 删除用户的搜索记录 + */ + @Login + @RequestMapping(value = "/deleteAppSearch", method = RequestMethod.GET) + public Result deleteAppSearch(@RequestAttribute Long userId) { + return appSearchService.deleteAppSearch(userId); + } +} diff --git a/src/main/java/com/sqx/modules/search/dao/AppSearchDao.java b/src/main/java/com/sqx/modules/search/dao/AppSearchDao.java new file mode 100644 index 0000000..db4444a --- /dev/null +++ b/src/main/java/com/sqx/modules/search/dao/AppSearchDao.java @@ -0,0 +1,26 @@ +package com.sqx.modules.search.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.common.utils.Result; +import com.sqx.modules.search.entity.Search; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Mapper +public interface AppSearchDao extends BaseMapper { + + /** + * 经常搜索的名称 + * + * @return + */ + List selectAppSearchNum(); + + /** + * 删除用户的搜索记录 + */ + int deleteAppSearch(Long userId); +} diff --git a/src/main/java/com/sqx/modules/search/dao/SearchDao.java b/src/main/java/com/sqx/modules/search/dao/SearchDao.java new file mode 100644 index 0000000..060cee4 --- /dev/null +++ b/src/main/java/com/sqx/modules/search/dao/SearchDao.java @@ -0,0 +1,9 @@ +package com.sqx.modules.search.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.search.entity.Search; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface SearchDao extends BaseMapper { +} diff --git a/src/main/java/com/sqx/modules/search/entity/Search.java b/src/main/java/com/sqx/modules/search/entity/Search.java new file mode 100644 index 0000000..f3348e0 --- /dev/null +++ b/src/main/java/com/sqx/modules/search/entity/Search.java @@ -0,0 +1,35 @@ +package com.sqx.modules.search.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +@Data +@TableName("search") +public class Search implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 搜索id + */ + @TableId(type = IdType.AUTO) + private Long searchId; + /** + * 搜索名称 + */ + private String searchName; + /** + * 用户 + */ + private Long userId; + + /** + * 更新时间 + */ + @TableField("update_time") + private String updateTime; + + public Search() {} +} diff --git a/src/main/java/com/sqx/modules/search/service/AppSearchService.java b/src/main/java/com/sqx/modules/search/service/AppSearchService.java new file mode 100644 index 0000000..38af0e3 --- /dev/null +++ b/src/main/java/com/sqx/modules/search/service/AppSearchService.java @@ -0,0 +1,17 @@ +package com.sqx.modules.search.service; + +import com.sqx.common.utils.Result; +import com.sqx.modules.search.entity.Search; +import org.springframework.web.bind.annotation.RequestAttribute; + +/** + * app搜索 + */ +public interface AppSearchService { + + Result insetAppSearch(String searchName, Long userId); + + Result selectAppSearchNum(Long userId); + + Result deleteAppSearch( Long userId); +} diff --git a/src/main/java/com/sqx/modules/search/service/SearchService.java b/src/main/java/com/sqx/modules/search/service/SearchService.java new file mode 100644 index 0000000..9e27453 --- /dev/null +++ b/src/main/java/com/sqx/modules/search/service/SearchService.java @@ -0,0 +1,11 @@ +package com.sqx.modules.search.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.search.entity.Search; + +public interface SearchService extends IService { + Result insertSearch(Search search); + Result selectByUserId(Long userId); + Result deleteById(Long id); +} diff --git a/src/main/java/com/sqx/modules/search/service/impl/AppSearchServiceImpl.java b/src/main/java/com/sqx/modules/search/service/impl/AppSearchServiceImpl.java new file mode 100644 index 0000000..84110bc --- /dev/null +++ b/src/main/java/com/sqx/modules/search/service/impl/AppSearchServiceImpl.java @@ -0,0 +1,106 @@ +package com.sqx.modules.search.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.Result; +import com.sqx.modules.search.Response.SearchResponse; +import com.sqx.modules.search.dao.AppSearchDao; +import com.sqx.modules.search.entity.Search; +import com.sqx.modules.search.service.AppSearchService; +import com.sqx.modules.search.service.SearchService; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.Map; + + +@Service +@AllArgsConstructor +public class AppSearchServiceImpl extends ServiceImpl implements AppSearchService { + private AppSearchDao appSearchDao; + private SearchService searchService; + + /** + * 记录用户搜索的内容 + * + * + * @param userId + * @return + */ + @Override + public Result insetAppSearch(String searchName, Long userId) { + //判断传过来的搜索信息不为空 + if (searchName != null) { + //去查询用户搜索内容是否有重复 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("search_name", searchName); + queryWrapper.eq("user_id", userId); + Search search1 = baseMapper.selectOne(queryWrapper); + //有重复则更新改变时间 + if (search1 != null) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + search1.setUpdateTime(simpleDateFormat.format(new Date())); + int i = baseMapper.updateById(search1); + if (i > 0) { + return Result.success("更新成功!"); + } else { + return Result.error("更新失败!"); + } + } else { + //没有则记录 + Search search=new Search(); + search.setUserId(userId); + search.setSearchName(searchName); + int count = baseMapper.insert(search); + if (count > 0) { + return Result.success("记录成功!"); + } else { + return Result.error("记录失败!"); + } + } + + } else { + return Result.error("搜索信息为空!"); + } + } + + /** + * 经常搜索的名称 + * + * @return + */ + @Override + public Result selectAppSearchNum(Long userId) { + //经常搜索的名称 + List list = appSearchDao.selectAppSearchNum(); + //用户经常搜索的名称 + Result result = searchService.selectByUserId(userId); + //创建返回对象 + SearchResponse searchResponse = new SearchResponse(); + searchResponse.setAllSerchName(list); + List searches = (List) result.get("data"); + for (Search search : searches) { + searchResponse.getUserSearchName().add(search.getSearchName()); + } + + return Result.success().put("data", searchResponse); + } + + /** + * 删除用户的搜索记录 + * + * @param userId + * @return + */ + @Override + public Result deleteAppSearch(Long userId) { + appSearchDao.deleteAppSearch(userId); + return Result.success(); + } +} diff --git a/src/main/java/com/sqx/modules/search/service/impl/SearchServiceImpl.java b/src/main/java/com/sqx/modules/search/service/impl/SearchServiceImpl.java new file mode 100644 index 0000000..4f15b56 --- /dev/null +++ b/src/main/java/com/sqx/modules/search/service/impl/SearchServiceImpl.java @@ -0,0 +1,31 @@ +package com.sqx.modules.search.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.Result; +import com.sqx.modules.search.dao.SearchDao; +import com.sqx.modules.search.entity.Search; +import com.sqx.modules.search.service.SearchService; +import org.springframework.stereotype.Service; + +@Service +public class SearchServiceImpl extends ServiceImpl implements SearchService { + @Override + public Result insertSearch(Search search) { + baseMapper.insert(search); + return Result.success(); + } + + @Override + public Result selectByUserId(Long userId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("user_id",userId); + return Result.success().put("data",baseMapper.selectList(queryWrapper)); + } + + @Override + public Result deleteById(Long id) { + baseMapper.deleteById(id); + return Result.success(); + } +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/AdvertController.java b/src/main/java/com/sqx/modules/shopping/controller/AdvertController.java new file mode 100644 index 0000000..dea8a39 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/AdvertController.java @@ -0,0 +1,52 @@ +package com.sqx.modules.shopping.controller; + + +import com.sqx.modules.shopping.entity.Adverti; +import com.sqx.modules.shopping.service.AdvertService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城广告位",tags={"自营商城广告位管理"}) +@RequestMapping(value = "/advert") +public class AdvertController { + @Autowired + private AdvertService service; + + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll() { + return service.findAll(); + } + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @PostMapping("/save") + @ApiOperation("添加") + public Result saveBody(@RequestBody Adverti entity) { + return service.saveBody(entity); + } + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody Adverti entity) { + return service.updateBody(entity); + } + + + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/CouponsController.java b/src/main/java/com/sqx/modules/shopping/controller/CouponsController.java new file mode 100644 index 0000000..1403b2f --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/CouponsController.java @@ -0,0 +1,64 @@ +package com.sqx.modules.shopping.controller; + + +import com.sqx.modules.shopping.entity.Coupons; +import com.sqx.modules.shopping.service.CouponsService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城优惠券",tags={"自营商城优惠券"}) +@RequestMapping(value = "/coupons") +public class CouponsController { + @Autowired + private CouponsService service; + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll(Integer page, Integer size) { + return service.findAll(page, size); + } + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @PostMapping("/save") + @ApiOperation("添加") + public Result saveBody(@RequestBody Coupons entity) { + return service.saveBody(entity); + } + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody Coupons entity) { + return service.updateBody(entity); + } + + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + + + @GetMapping("/userGet") + @ApiOperation("用户端领取优惠券") + public Result userGetCoupons(Long userId, Long couponsId) { + return service.userGetCoupons(userId, couponsId); + } + + + @GetMapping("/userCoupons") + @ApiOperation("用户端优惠券列表") + public Result userCoupons(Long userId) { + return service.userCoupons(userId); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/GoodsController.java b/src/main/java/com/sqx/modules/shopping/controller/GoodsController.java new file mode 100644 index 0000000..f626031 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/GoodsController.java @@ -0,0 +1,205 @@ +package com.sqx.modules.shopping.controller; + + +import com.sqx.modules.shopping.entity.SelfGoods; +import com.sqx.modules.shopping.entity.SelfGoodsAttr; +import com.sqx.modules.shopping.service.GoodsService; +import com.sqx.modules.shopping.service.SelfGoodsRuleService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城商品",tags={"自营商城商品管理"}) +@RequestMapping(value = "/goods") +public class GoodsController { + @Autowired + private GoodsService service; + @Autowired + private SelfGoodsRuleService ruleService; + + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll(Integer page, Integer size, + @ApiParam("商品标题:可搜索")@RequestParam(required = false) String title, + @ApiParam("商品类型:类型名称")@RequestParam(required = false) String type, + @ApiParam("商品状态:0全部 1上架 2下架")@RequestParam(required = false) Integer status, + @ApiParam("是否积分商品:1积分商城商品")@RequestParam(required = false) Integer isJiFenGoods) { + return service.findAll(page, size, title, type, status, isJiFenGoods); + } + + @GetMapping("/selectListByType") + @ApiOperation("按照类型查询物料包列表") + public Result selectListByType( + @ApiParam("商品标题:可搜索")@RequestParam(required = false) String title, + @ApiParam("商品类型:类型名称")@RequestParam(required = false) String type, + @ApiParam("商品状态:0全部 1上架 2下架")@RequestParam(required = false) Integer status, + @ApiParam("是否积分商品:1积分商城商品")@RequestParam(required = false) Integer isJiFenGoods) { + return service.selectListByType(title, type, status, isJiFenGoods); + } + @GetMapping("/goodsList") + @ApiOperation("其他商品列表") + public Result goodsVirtualList(Integer page, Integer size, + @ApiParam("商品标题:可搜索")@RequestParam(required = false) String title, + @ApiParam("商品类型:类型名称")@RequestParam(required = false) String type, + @ApiParam("商品状态:0全部 1上架 2下架")@RequestParam(required = false) Integer status, + @ApiParam("虚拟类型:0全部 1普通商品 2虚拟商品 3核销商品")@RequestParam(required = false) Integer isExpress, + @ApiParam("是否积分商品:1积分商城商品")@RequestParam(required = false) Integer isJiFenGoods) { + return service.goodsVirtualList(page, size, title, type, status, isExpress, isJiFenGoods); + } + + + @GetMapping("/userList") + @ApiOperation("用户端商品列表") + public Result userList(Integer page, Integer size, + @ApiParam("商品类型:类型名称")@RequestParam(required = false) String type, + @ApiParam("品牌id")@RequestParam(required = false) String brandId, + @ApiParam("商品标题:可搜索")@RequestParam(required = false) String title, + @ApiParam("排序字段 综合createAt 销量sales 佣金比例commissionPrice 超低价price")@RequestParam(required = false) String sort, + @ApiParam("是否积分商品:0虚拟商品列表固定传0 1积分商城商品")@RequestParam(required = false) Integer isJiFenGoods) { + return service.findAllByUser(page, size, type,brandId, title, sort, isJiFenGoods); + } + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @PostMapping("/save") + @ApiOperation("添加") + public Result saveBody(@RequestBody SelfGoods entity) { + return service.saveBody(entity); + } + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody SelfGoods entity) { + return service.updateBody(entity); + } + + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + + @GetMapping("/brandList") + @ApiOperation("用户端品牌列表") + public Result brandList(@ApiParam("搜索内容")@RequestParam(required = false) String title) { + return service.searchBrandList(title); + } + + @GetMapping("/selectGoods") + @ApiOperation("精选好物") + public Result selectGoods(Integer page, Integer size, + @ApiParam("排序字段 综合createAt 销量sales 佣金比例commissionPrice 超低价price")@RequestParam(required = false) String sort) { + return service.selectGoods(page, size, sort); + } + + + @GetMapping("/selling") + @ApiOperation("热卖榜单") + public Result selling(Integer page, Integer size, + @ApiParam("排序字段 综合createAt 销量sales 佣金比例commissionPrice 超低价price")@RequestParam(required = false) String sort) { + return service.selling(page, size, sort); + } + + + @GetMapping("/homeGoods") + @ApiOperation("首页商品") + public Result homeGoods(Integer page, Integer size) { + return service.homeGoods(page, size); + } + + + @GetMapping("/news") + @ApiOperation("每日上新") + public Result news(Integer page, Integer size, + @ApiParam("排序字段 综合createAt 销量sales 佣金比例commissionPrice 超低价price")@RequestParam(required = false) String sort) { + return service.news(page, size, sort); + } + + + @GetMapping("/recommend") + @ApiOperation("每日推荐商品") + public Result recommend(Integer page, Integer size, + @ApiParam("排序字段 综合createAt 销量sales 佣金比例commissionPrice 超低价price")@RequestParam(required = false) String sort) { + return service.recommend(page, size, sort); + } + + @GetMapping("/addRecommend") + @ApiOperation("后台管理添加每日推荐") + public Result addRecommend(Long id) { + return service.addRecommend(id); + } + + @GetMapping("/deleteRecommend") + @ApiOperation("后台管理删除每日推荐") + public Result deleteRecommend(String ids) { + return service.deleteRecommend(ids); + } + + @GetMapping("/addSelectGoods") + @ApiOperation("后台管理添加精选好物") + public Result addSelectGoods(Long id) { + return service.addSelectGoods(id); + } + + @GetMapping("/deleteSelectGoods") + @ApiOperation("后台管理删除精选好物") + public Result addSelectGoods(String ids) { + return service.deleteSelectGoods(ids); + } + + + @GetMapping("/info") + @ApiOperation("商品规格选项") + public Result info() { + return ruleService.info(); + } + + @ApiOperation(value = "多规格生成sku") + @PostMapping(value = "/isFormatAttr") + public Result isFormatSku(@RequestBody SelfGoodsAttr attr, + @ApiParam("商品图片")@RequestParam(required = false) String coverImg, + @ApiParam("原价")@RequestParam(required = false) String originalPrice, + @ApiParam("售价")@RequestParam(required = false) String price, + @ApiParam("会员价")@RequestParam(required = false) String memberPrice){ + return service.isFormatAttr(attr, coverImg, originalPrice, price, memberPrice); + } + + @ApiOperation(value = "单规格生成sku") + @GetMapping(value = "/onlyFormatAttr") + public Result onlyFormatSku(@ApiParam("商品图片")@RequestParam(required = false) String coverImg, + @ApiParam("原价")@RequestParam(required = false) String originalPrice, + @ApiParam("售价")@RequestParam(required = false) String price, + @ApiParam("会员价")@RequestParam(required = false) String memberPrice){ + return service.onlyFormatAttr(coverImg, originalPrice, price, memberPrice); + } + + @ApiOperation(value = "回显属性") + @GetMapping(value = "/formatAttr") + public Result formatAttr(Long goodsId){ + return service.formatAttr(goodsId); + } + + @ApiOperation(value = "回显规格") + @GetMapping(value = "/findAttrValue") + public Result findAttrValue(Long goodsId){ + return service.findAttrValue(goodsId); + } + + + @ApiOperation(value = "商品上下架") + @GetMapping(value = "/updateStatus") + public Result updateStatus(Long goodsId){ + return service.updateStatus(goodsId); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/GoodsTypeController.java b/src/main/java/com/sqx/modules/shopping/controller/GoodsTypeController.java new file mode 100644 index 0000000..2ef30ae --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/GoodsTypeController.java @@ -0,0 +1,67 @@ +package com.sqx.modules.shopping.controller; + + +import com.sqx.modules.shopping.entity.GoodsType; +import com.sqx.modules.shopping.service.GoodsTypeService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城分类",tags={"自营商城分类管理"}) +@RequestMapping(value = "/goodsType") +public class GoodsTypeController { + @Autowired + private GoodsTypeService service; + + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll() { + return service.findAll(); + } + + + @GetMapping("/result") + @ApiOperation("商品分类数据封装") + public Result findAllResult() { + return service.findAllResult(); + } + + + @GetMapping("/result1") + @ApiOperation("一级分类数据封装") + public Result findAllResult1() { + return service.findAllResult1(); + } + + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @PostMapping("/save") + @ApiOperation("添加") + public Result saveBody(@RequestBody GoodsType entity) { + return service.saveBody(entity); + } + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody GoodsType entity) { + return service.updateBody(entity); + } + + + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/OrdersController.java b/src/main/java/com/sqx/modules/shopping/controller/OrdersController.java new file mode 100644 index 0000000..72b854a --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/OrdersController.java @@ -0,0 +1,195 @@ +package com.sqx.modules.shopping.controller; + + +import com.sqx.modules.shopping.entity.SelfOrders; +import com.sqx.modules.shopping.service.OrdersService; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.excel.ExcelData; +import com.sqx.modules.shopping.utils.excel.ExportExcelUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; + +@RestController +@Api(value="自营商城订单",tags={"自营商城订单管理"}) +@RequestMapping(value = "/orders") +public class OrdersController { + @Autowired + private OrdersService service; + + @GetMapping("/list") + @ApiOperation("后台管理列表") + public Result findAll(Integer page, Integer size, + @ApiParam("订单号")@RequestParam(required = false) String orderNum, + @ApiParam("订单状态:1待付款 2已付款 3已发货 4已收货 5已取消 6退款中 7已退款 8拒绝退款")@RequestParam String status, + @ApiParam("商品名称")@RequestParam(required = false) String title, + String startTime, String endTime, + @ApiParam("手机号")@RequestParam(required = false) String mobile, + String sendWay) { + return service.findAll(page, size, orderNum, status, title, mobile,startTime,endTime,sendWay); + } + + + @GetMapping("/listExcel") + @ApiOperation("后台管理列表") + public void listExcel( + @ApiParam("订单号")@RequestParam(required = false) String orderNum, + @ApiParam("订单状态:1待付款 2已付款 3已发货 4已收货 5已取消 6退款中 7已退款 8拒绝退款")@RequestParam String status, + @ApiParam("商品名称")@RequestParam(required = false) String title, + String startTime, String endTime, + @ApiParam("手机号")@RequestParam(required = false) String mobile, + String sendWay, + HttpServletResponse response) throws Exception { + ExcelData data = service.listExcel(orderNum, status, title, mobile,startTime,endTime,sendWay); + ExportExcelUtils.exportExcel(response,"订单列表.xlsx",data); + } + + + + @GetMapping("/findMyList") + @ApiOperation("我的订单列表") + public Result findMyList(Integer page, Integer size, + @ApiParam("用户id")@RequestParam String userId, + @ApiParam("订单状态:1待付款 2已付款 3已发货 4已收货 5已取消 6退款中 7已退款 8拒绝退款")@RequestParam String status) { + return service.findMyList(page, size, userId, status); + } + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @PostMapping("/save") + @ApiOperation("保存订单") + public Result saveBody(@RequestBody SelfOrders entity) { + return service.saveBody(entity); + } + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody SelfOrders entity) { + return service.updateBody(entity); + } + + + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + + + @ApiOperation(value="取消订单,orderStatus=1时可取消") + @GetMapping("/cancel") + public Result orderCancel(@ApiParam("id") @RequestParam Long id){ + return service.orderCancel(id); + } + + @ApiOperation("后台管理去发货") + @GetMapping("/express") + public Result express(Long id, String expressName, String expressNumber){ + return service.express(id, expressName, expressNumber); + } + + @ApiOperation("后台管理虚拟去发货") + @GetMapping("/expressVirtual") + public Result expressVirtual(Long id){ + return service.expressVirtual(id); + } + + + @ApiOperation(value="确认收货,orderStatus=3时收货") + @GetMapping("/confirm") + public Result orderConfirm(@ApiParam("id") @RequestParam Long id){ + return service.orderConfirm(id); + } + + + + @ApiOperation(value="收入金额统计") + @GetMapping("/income") + public Result income(@ApiParam("data") @RequestParam String data, @ApiParam("way: 1年 2月 3日") @RequestParam int way){ + return service.income(data, way); + } + + + @ApiOperation(value="订单成交量统计") + @GetMapping("/statistical") + public Result statistical(@ApiParam("data") @RequestParam String data){ + return service.statistical(data); + } + + @ApiOperation("零钱支付") + @GetMapping("/changePay") + public Result changePay(String ordersId){ + return service.changePay(ordersId); + } + + @ApiOperation("检测是否完成支付") + @GetMapping("/wxPay") + public Result wxPayWeb(Long ordersId){ + return service.checkPay(ordersId); + } + + + @ApiOperation("申请退款") + @GetMapping("/refund") + public Result refund(Long ordersId, String refund){ + return service.refund(ordersId, refund); + } + + + @ApiOperation("后台管理确认退款") + @GetMapping("/refundMoney") + public Result refundMoney(Long ordersId){ + return service.refundMoney(ordersId); + } + + + @ApiOperation("后台管理拒绝退款") + @GetMapping("/refusedRefund") + public Result refusedRefund(Long ordersId, String refusedRefund){ + return service.refusedRefund(ordersId, refusedRefund); + } + + + @ApiOperation("后台管理待处理订单") + @GetMapping("/pendingOrder") + public Result pendingOrder(){ + return service.pendingOrder(); + } + + + @ApiOperation("用户端提醒发货") + @GetMapping("/remind") + public Result remind(Long ordersId){ + return service.remind(ordersId); + } + + + @ApiOperation("后台管理被提醒发货") + @GetMapping("/remindOrder") + public Result remindOrder(){ + return service.remindOrder(); + } + + + @ApiOperation("用户端 订单统计") + @GetMapping("/count") + public Result count(Long userId){ + return service.count(userId); + } + + + @ApiOperation("查快递") + @GetMapping("/findExpress") + public Result findExpress(String expressNumber){ + return service.findExpress(expressNumber); + } +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/OrdersRelationController.java b/src/main/java/com/sqx/modules/shopping/controller/OrdersRelationController.java new file mode 100644 index 0000000..960d977 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/OrdersRelationController.java @@ -0,0 +1,60 @@ +package com.sqx.modules.shopping.controller; + + +import com.sqx.modules.shopping.service.OrdersRelationService; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Api(value="自营商城订单分销",tags={"自营商城订单分销管理"}) +@RequestMapping(value = "/ordersRelation") +public class OrdersRelationController { + @Autowired + private OrdersRelationService service; + + @GetMapping("/list") + @ApiOperation("订单分销列表") + public Result findAll(Integer page, Integer size, + @ApiParam("用户id") @RequestParam(required = false) Long userId, + @ApiParam("用户手机号") @RequestParam(required = false) String phone, + @ApiParam("分销 0全部 1未到账 2已到账") @RequestParam(required = false) Integer status, + @ApiParam("佣金来源 0全部 1团队 2自己)") @RequestParam(required = false) Integer moneyFrom) { + return service.findAll(page, size, userId, phone, status, moneyFrom); + } + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @GetMapping("/statistaical") + @ApiOperation("我的佣金统计") + public Result statistaical(Long userId) { + return service.statistaical(userId); + } + + @GetMapping("/tuanStatistaical") + @ApiOperation("团队佣金统计") + public Result tuanStatistaical(Long userId) { + return service.tuanStatistaical(userId); + } + + + @GetMapping(value = "/tuanSum") + @ApiOperation("获取团队总收益") + public Result tuanSum(Long userId) { + return ResultUtil.success(service.tuanSum(userId)); + } + + + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/OrdersTask.java b/src/main/java/com/sqx/modules/shopping/controller/OrdersTask.java new file mode 100644 index 0000000..4c67488 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/OrdersTask.java @@ -0,0 +1,57 @@ +package com.sqx.modules.shopping.controller; + +import com.sqx.modules.shopping.dao.OrdersRepository; +import com.sqx.modules.shopping.entity.SelfOrderRelation; +import com.sqx.modules.shopping.service.OrdersRelationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +@Component +public class OrdersTask { + @Autowired + private OrdersRelationService service; + @Autowired + private OrdersRepository ordersRepository; + /** + * 每天凌晨执行一次 + */ + /*@Scheduled(cron = "0 0 0 * * ?") + public void scheduledTask(){ + List list = service.findAllByStatus(); + for (SelfOrderRelation s : list) { + String finishTime = s.getFinishTime(); + boolean timeOut = isTimeOut(finishTime, 7); + if (timeOut){ + service.addMoney(s); + } + } + }*/ + + /** + * 判断传入时间是否超时 + * @param finishTime 完成时间 + * @param days 天数 + * @return 是否超时 true没有过期 + */ + public boolean isTimeOut(String finishTime, int days){ + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try{ + Date finish = sf.parse(finishTime); + Calendar c = Calendar.getInstance(); + c.setTime(finish); + c.add(Calendar.DATE, + days); + finish = c.getTime(); //完成时间七天后的时间,得到过期时间 + //过期时间和现在时间比 + return finish.after(new Date()); + }catch (Exception e){ + e.printStackTrace(); + } + return false; + } +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/SelfActivityController.java b/src/main/java/com/sqx/modules/shopping/controller/SelfActivityController.java new file mode 100644 index 0000000..a47baaa --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/SelfActivityController.java @@ -0,0 +1,78 @@ +package com.sqx.modules.shopping.controller; + + +import com.sqx.modules.shopping.dao.SelfActivityJpaRepository; +import com.sqx.modules.shopping.dao.SelfActivityRepository; +import com.sqx.modules.shopping.entity.SelfActivity; +import com.sqx.modules.shopping.utils.DateUtil; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.text.SimpleDateFormat; +import java.util.Date; + +@RestController +@Api(value="自营商城首页菜单和活动管理",tags={"自营商城首页菜单和活动管理"}) +@RequestMapping(value = "/selfActivity") +public class SelfActivityController { + @Autowired + private SelfActivityJpaRepository activityJpaRepository; + + @Autowired + private SelfActivityRepository activityRepository; + + + @GetMapping(value = "/id") + @ApiOperation("管理平台详情") + public Result getBanner(Integer id) { + return ResultUtil.success(activityJpaRepository.findById(Long.valueOf(id)).orElse(null)); + } + + @GetMapping(value = "/state") + @ApiOperation("根据状态查询菜单列表") + + public Result getBannerState(String state) { + return ResultUtil.success(activityRepository.findOne(state)); + } + + @PostMapping(value = "/update") + @ApiOperation("管理平台修改") + public Result addBanner(@RequestBody SelfActivity info) { + SelfActivity activity = new SelfActivity(); + activity.setId(Long.valueOf(info.getId())); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + activity.setImage_url(info.getImage_url()); + activity.setTitle(info.getTitle()); + activity.setCreateAt(sdf.format(now)); + activity.setState(info.getState()); + activity.setUrl(info.getUrl()); + return ResultUtil.success(activityJpaRepository.save(activity)); + } + + @PostMapping(value = "/save") + @ApiOperation("管理平台添加") + public Result saveBanner(@RequestBody SelfActivity info) { + info.setCreateAt(DateUtil.createTime()); + return ResultUtil.success(activityJpaRepository.save(info)); + } + + @GetMapping(value = "/delete") + @ApiOperation("管理平台删除") + public Result deleteBanner(@RequestParam Long id) { + activityJpaRepository.deleteById(id); + return ResultUtil.success(); + } + + @GetMapping(value = "/list") + @ApiOperation("管理平台获取全部广告位") + public Result getBannerList() { + return ResultUtil.success(activityJpaRepository.findAll()); + } + + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/SelfBannerController.java b/src/main/java/com/sqx/modules/shopping/controller/SelfBannerController.java new file mode 100644 index 0000000..9ae5bc2 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/SelfBannerController.java @@ -0,0 +1,52 @@ +package com.sqx.modules.shopping.controller; + + +import com.sqx.modules.shopping.entity.SelfBanner; +import com.sqx.modules.shopping.service.SlefBannerService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城Banner位",tags={"自营商城Banner位"}) +@RequestMapping(value = "/selfBanner") +public class SelfBannerController { + @Autowired + private SlefBannerService service; + + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll() { + return service.findAll(); + } + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @PostMapping("/save") + @ApiOperation("添加") + public Result saveBody(@RequestBody SelfBanner entity) { + return service.saveBody(entity); + } + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody SelfBanner entity) { + return service.updateBody(entity); + } + + + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/SelfGoodsBrandController.java b/src/main/java/com/sqx/modules/shopping/controller/SelfGoodsBrandController.java new file mode 100644 index 0000000..7ca572e --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/SelfGoodsBrandController.java @@ -0,0 +1,56 @@ +package com.sqx.modules.shopping.controller; + + +import com.sqx.modules.shopping.entity.SelfGoodsBrand; +import com.sqx.modules.shopping.service.SelfGoodsBrandService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城商品品牌",tags={"自营商城商品品牌"}) +@RequestMapping(value = "/selfGoodsBrand") +public class SelfGoodsBrandController { + @Autowired + private SelfGoodsBrandService service; + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll(Integer page, Integer size) { + return service.findAll(page, size); + } + + @GetMapping("/result") + @ApiOperation("品牌封装列表") + public Result result() { + return service.result(); + } + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @PostMapping("/save") + @ApiOperation("添加") + public Result saveBody(@RequestBody SelfGoodsBrand entity) { + return service.saveBody(entity); + } + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody SelfGoodsBrand entity) { + return service.updateBody(entity); + } + + + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/SelfGoodsCommentController.java b/src/main/java/com/sqx/modules/shopping/controller/SelfGoodsCommentController.java new file mode 100644 index 0000000..44f3efb --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/SelfGoodsCommentController.java @@ -0,0 +1,76 @@ +package com.sqx.modules.shopping.controller; + + +import com.sqx.modules.shopping.entity.SelfGoodsComment; +import com.sqx.modules.shopping.service.SelfGoodsCommentService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城商品评论",tags={"自营商城商品评论"}) +@RequestMapping(value = "/selfGoodsComment") +public class SelfGoodsCommentController { + @Autowired + private SelfGoodsCommentService service; + + @GetMapping("/list") + @ApiOperation("商品评价列表") + public Result findAll(Integer page, Integer size, Long goodsId, @ApiParam("0全部 1好评 2中评 3差评")@RequestParam Integer scoreType) { + return service.findAll(page, size, goodsId,scoreType); + } + + @GetMapping("/count") + @ApiOperation("商品评价统计") + public Result count(Long goodsId) { + return service.count(goodsId); + } + + + @GetMapping("/findByOrderId") + @ApiOperation("订单评价") + public Result findByOrderId(Long orderId) { + return service.findByOrderId(orderId); + } + + @GetMapping("/userList") + @ApiOperation("用户评论列表") + public Result userList(Integer page, Integer size, Long userId) { + return service.userList(page, size, userId); + } + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @PostMapping("/save") + @ApiOperation("添加") + public Result saveBody(@RequestBody SelfGoodsComment entity) { + return service.saveBody(entity); + } + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody SelfGoodsComment entity) { + return service.updateBody(entity); + } + + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + + @GetMapping("/reply") + @ApiOperation("回复评论") + public Result reply(Long commentId, String reply) { + return service.reply(commentId, reply); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/SelfGoodsRuleController.java b/src/main/java/com/sqx/modules/shopping/controller/SelfGoodsRuleController.java new file mode 100644 index 0000000..3c95862 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/SelfGoodsRuleController.java @@ -0,0 +1,49 @@ +package com.sqx.modules.shopping.controller; + +import com.sqx.modules.shopping.entity.SelfGoodsRule; +import com.sqx.modules.shopping.service.SelfGoodsRuleService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城商品规格",tags={"自营商城商品规格"}) +@RequestMapping(value = "/selfGoodsRule") +public class SelfGoodsRuleController { + @Autowired + private SelfGoodsRuleService service; + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll(Integer page, Integer size) { + return service.findAll(page, size); + } + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @PostMapping("/save") + @ApiOperation("添加") + public Result saveBody(@RequestBody SelfGoodsRule entity) { + return service.saveBody(entity); + } + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody SelfGoodsRule entity) { + return service.updateBody(entity); + } + + + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/SelfGoodsVirtualController.java b/src/main/java/com/sqx/modules/shopping/controller/SelfGoodsVirtualController.java new file mode 100644 index 0000000..d1db301 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/SelfGoodsVirtualController.java @@ -0,0 +1,57 @@ +package com.sqx.modules.shopping.controller; + + +import com.sqx.modules.shopping.entity.SelfGoodsVirtual; +import com.sqx.modules.shopping.service.SelfGoodsVirtualService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城虚拟商品",tags={"自营商城虚拟商品"}) +@RequestMapping(value = "/selfGoodsVirtual") +public class SelfGoodsVirtualController { + @Autowired + private SelfGoodsVirtualService service; + + + @GetMapping("/list") + @ApiOperation("兑换码列表") + public Result findAll(Integer page, Integer size, + @ApiParam("虚拟商品id")@RequestParam(required = false) Long goodsId, + @ApiParam("卡密内容")@RequestParam(required = false) String content) { + return service.findAll(page, size, goodsId, content); + } + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + + @PostMapping("/save") + @ApiOperation("添加") + public Result saveBody(@RequestBody SelfGoodsVirtual entity) { + return service.saveBody(entity); + } + + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody SelfGoodsVirtual entity) { + return service.updateBody(entity); + } + + + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/SelfMerchantApplyController.java b/src/main/java/com/sqx/modules/shopping/controller/SelfMerchantApplyController.java new file mode 100644 index 0000000..6882375 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/SelfMerchantApplyController.java @@ -0,0 +1,71 @@ +package com.sqx.modules.shopping.controller; + + +import com.sqx.modules.shopping.entity.SelfMerchantApply; +import com.sqx.modules.shopping.service.SelfMerchantApplyService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城多商户商户入驻申请信息",tags={"自营商城多商户商户入驻申请信息"}) +@RequestMapping(value = "/self/merchantApply") +public class SelfMerchantApplyController { + @Autowired + private SelfMerchantApplyService service; + + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll(Integer page, Integer size, + @ApiParam("商家名称") @RequestParam(required = false) String companyName, + @ApiParam("注册手机号") @RequestParam(required = false) String legalPhone, + @ApiParam("店铺类型") @RequestParam Integer storeType, + @ApiParam("审核状态(1待处理 2通过 3拒绝)") @RequestParam Integer status, + @ApiParam("申请时间开始区间") @RequestParam(required = false) String createTimeStart, + @ApiParam("申请时间结束区间") @RequestParam(required = false) String createTimeEnd) { + return service.findAll(page, size, companyName, legalPhone, storeType, status, createTimeStart, createTimeEnd); + } + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + + @PostMapping("/save") + @ApiOperation("添加") + public Result saveBody(@RequestBody SelfMerchantApply entity) { + return service.saveBody(entity); + } + + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody SelfMerchantApply entity) { + return service.updateBody(entity); + } + + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + + + @PostMapping("/deal") + @ApiOperation("处理审核") + public Result deal(@ApiParam("申请id") @RequestParam Long id, + @ApiParam("审核状态(1待处理 2通过 3拒绝)") @RequestParam Integer status, + @ApiParam("生效日期") @RequestParam(required = false) String auditTime, + @ApiParam("生效年限") @RequestParam String auditYears, + @ApiParam("拒绝原因") @RequestParam(required = false) String refundReason) { + return service.deal(id, status, auditTime, auditYears, refundReason); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/SelfUserCollectController.java b/src/main/java/com/sqx/modules/shopping/controller/SelfUserCollectController.java new file mode 100644 index 0000000..0898942 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/SelfUserCollectController.java @@ -0,0 +1,54 @@ +package com.sqx.modules.shopping.controller; + +import com.sqx.modules.shopping.entity.SelfUserCollect; +import com.sqx.modules.shopping.service.SelfUserCollectService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城用户收藏",tags={"自营商城用户收藏"}) +@RequestMapping(value = "/selfUserCollect") +public class SelfUserCollectController { + @Autowired + private SelfUserCollectService service; + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll(Integer page, Integer size, Long userId) { + return service.findAll(page, size, userId); + } + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @PostMapping("/save") + @ApiOperation("添加") + public Result saveBody(@RequestBody SelfUserCollect entity) { + return service.saveBody(entity); + } + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody SelfUserCollect entity) { + return service.updateBody(entity); + } + + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + + @GetMapping("/check") + @ApiOperation("判断是否收藏") + public Result check(Long goodsId, Long userId) { + return service.check(goodsId, userId); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/SkuUtil.java b/src/main/java/com/sqx/modules/shopping/controller/SkuUtil.java new file mode 100644 index 0000000..54b71d1 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/SkuUtil.java @@ -0,0 +1,48 @@ +package com.sqx.modules.shopping.controller; + +import java.util.ArrayList; +import java.util.List; + +public class SkuUtil { + + /** + * @param inputList 所有数组的列表 + * */ + public static List> skuSort(List> inputList) { + List> result = new ArrayList<>(); + List combination = new ArrayList(); + int n=inputList.size(); + for (int i = 0; i < n; i++) { + combination.add(0); + } + int i=0; + boolean isContinue=false; + do{ + List temp = new ArrayList<>(); + //打印一次循环生成的组合 + for (int j = 0; j < n; j++) { + temp.add(inputList.get(j).get(combination.get(j))); + } + result.add(temp); + i++; + combination.set(n-1, i); + for (int j = n-1; j >= 0; j--) { + if (combination.get(j)>=inputList.get(j).size()) { + combination.set(j, 0); + i=0; + if (j-1>=0) { + combination.set(j-1, combination.get(j-1)+1); + } + } + } + isContinue=false; + for (Integer integer : combination) { + if (integer != 0) { + isContinue=true; + } + } + }while (isContinue); + return result; + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/app/AppAdvertController.java b/src/main/java/com/sqx/modules/shopping/controller/app/AppAdvertController.java new file mode 100644 index 0000000..2a09dc3 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/app/AppAdvertController.java @@ -0,0 +1,34 @@ +package com.sqx.modules.shopping.controller.app; + + +import com.sqx.modules.shopping.entity.Adverti; +import com.sqx.modules.shopping.service.AdvertService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城广告位",tags={"自营商城广告位管理"}) +@RequestMapping(value = "/app/advert") +public class AppAdvertController { + @Autowired + private AdvertService service; + + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll() { + return service.findAll(); + } + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/app/AppCouponsController.java b/src/main/java/com/sqx/modules/shopping/controller/app/AppCouponsController.java new file mode 100644 index 0000000..1b5e3c8 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/app/AppCouponsController.java @@ -0,0 +1,47 @@ +package com.sqx.modules.shopping.controller.app; + + +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.shopping.entity.Coupons; +import com.sqx.modules.shopping.service.CouponsService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城优惠券",tags={"自营商城优惠券"}) +@RequestMapping(value = "/app/coupons") +public class AppCouponsController { + @Autowired + private CouponsService service; + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll(Integer page, Integer size) { + return service.findAll(page, size); + } + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @Login + @GetMapping("/userGet") + @ApiOperation("用户端领取优惠券") + public Result userGetCoupons(@RequestAttribute Long userId, Long couponsId) { + return service.userGetCoupons(userId, couponsId); + } + + @Login + @GetMapping("/userCoupons") + @ApiOperation("用户端优惠券列表") + public Result userCoupons(@RequestAttribute Long userId) { + return service.userCoupons(userId); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/app/AppGoodsController.java b/src/main/java/com/sqx/modules/shopping/controller/app/AppGoodsController.java new file mode 100644 index 0000000..25d4e61 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/app/AppGoodsController.java @@ -0,0 +1,148 @@ +package com.sqx.modules.shopping.controller.app; + + +import com.sqx.modules.shopping.entity.SelfGoods; +import com.sqx.modules.shopping.entity.SelfGoodsAttr; +import com.sqx.modules.shopping.service.GoodsService; +import com.sqx.modules.shopping.service.SelfGoodsRuleService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城商品",tags={"自营商城商品管理"}) +@RequestMapping(value = "/app/goods") +public class AppGoodsController { + @Autowired + private GoodsService service; + @Autowired + private SelfGoodsRuleService ruleService; + + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll(Integer page, Integer size, + @ApiParam("商品标题:可搜索")@RequestParam(required = false) String title, + @ApiParam("商品类型:类型名称")@RequestParam(required = false) String type, + @ApiParam("商品状态:0全部 1上架 2下架")@RequestParam(required = false) Integer status, + @ApiParam("是否积分商品:1积分商城商品")@RequestParam(required = false) Integer isJiFenGoods) { + return service.findAll(page, size, title, type, status, isJiFenGoods); + } + + + @GetMapping("/goodsList") + @ApiOperation("其他商品列表") + public Result goodsVirtualList(Integer page, Integer size, + @ApiParam("商品标题:可搜索")@RequestParam(required = false) String title, + @ApiParam("商品类型:类型名称")@RequestParam(required = false) String type, + @ApiParam("商品状态:0全部 1上架 2下架")@RequestParam(required = false) Integer status, + @ApiParam("虚拟类型:0全部 1普通商品 2虚拟商品 3核销商品")@RequestParam(required = false) Integer isExpress, + @ApiParam("是否积分商品:1积分商城商品")@RequestParam(required = false) Integer isJiFenGoods) { + return service.goodsVirtualList(page, size, title, type, status, isExpress, isJiFenGoods); + } + + + @GetMapping("/userList") + @ApiOperation("用户端商品列表") + public Result userList(Integer page, Integer size, + @ApiParam("商品类型:类型名称")@RequestParam(required = false) String type, + @ApiParam("品牌id")@RequestParam(required = false) String brandId, + @ApiParam("商品标题:可搜索")@RequestParam(required = false) String title, + @ApiParam("排序字段 综合createAt 销量sales 佣金比例commissionPrice 超低价price")@RequestParam(required = false) String sort, + @ApiParam("是否积分商品:0虚拟商品列表固定传0 1积分商城商品")@RequestParam(required = false) Integer isJiFenGoods) { + return service.findAllByUser(page, size, type,brandId, title, sort, isJiFenGoods); + } + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @GetMapping("/brandList") + @ApiOperation("用户端品牌列表") + public Result brandList(@ApiParam("搜索内容")@RequestParam(required = false) String title) { + return service.searchBrandList(title); + } + + @GetMapping("/selectGoods") + @ApiOperation("精选好物") + public Result selectGoods(Integer page, Integer size, + @ApiParam("排序字段 综合createAt 销量sales 佣金比例commissionPrice 超低价price")@RequestParam(required = false) String sort) { + return service.selectGoods(page, size, sort); + } + + + @GetMapping("/selling") + @ApiOperation("热卖榜单") + public Result selling(Integer page, Integer size, + @ApiParam("排序字段 综合createAt 销量sales 佣金比例commissionPrice 超低价price")@RequestParam(required = false) String sort) { + return service.selling(page, size, sort); + } + + + @GetMapping("/homeGoods") + @ApiOperation("首页商品") + public Result homeGoods(Integer page, Integer size) { + return service.homeGoods(page, size); + } + + + @GetMapping("/news") + @ApiOperation("每日上新") + public Result news(Integer page, Integer size, + @ApiParam("排序字段 综合createAt 销量sales 佣金比例commissionPrice 超低价price")@RequestParam(required = false) String sort) { + return service.news(page, size, sort); + } + + + @GetMapping("/recommend") + @ApiOperation("每日推荐商品") + public Result recommend(Integer page, Integer size, + @ApiParam("排序字段 综合createAt 销量sales 佣金比例commissionPrice 超低价price")@RequestParam(required = false) String sort) { + return service.recommend(page, size, sort); + } + + @GetMapping("/info") + @ApiOperation("商品规格选项") + public Result info() { + return ruleService.info(); + } + + @ApiOperation(value = "多规格生成sku") + @PostMapping(value = "/isFormatAttr") + public Result isFormatSku(@RequestBody SelfGoodsAttr attr, + @ApiParam("商品图片")@RequestParam(required = false) String coverImg, + @ApiParam("原价")@RequestParam(required = false) String originalPrice, + @ApiParam("售价")@RequestParam(required = false) String price, + @ApiParam("会员价")@RequestParam(required = false) String memberPrice){ + return service.isFormatAttr(attr, coverImg, originalPrice, price, memberPrice); + } + + @ApiOperation(value = "单规格生成sku") + @GetMapping(value = "/onlyFormatAttr") + public Result onlyFormatSku(@ApiParam("商品图片")@RequestParam(required = false) String coverImg, + @ApiParam("原价")@RequestParam(required = false) String originalPrice, + @ApiParam("售价")@RequestParam(required = false) String price, + @ApiParam("会员价")@RequestParam(required = false) String memberPrice){ + return service.onlyFormatAttr(coverImg, originalPrice, price, memberPrice); + } + + @ApiOperation(value = "回显属性") + @GetMapping(value = "/formatAttr") + public Result formatAttr(Long goodsId){ + return service.formatAttr(goodsId); + } + + @ApiOperation(value = "回显规格") + @GetMapping(value = "/findAttrValue") + public Result findAttrValue(Long goodsId){ + return service.findAttrValue(goodsId); + } + + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/app/AppGoodsTypeController.java b/src/main/java/com/sqx/modules/shopping/controller/app/AppGoodsTypeController.java new file mode 100644 index 0000000..742db66 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/app/AppGoodsTypeController.java @@ -0,0 +1,49 @@ +package com.sqx.modules.shopping.controller.app; + + +import com.sqx.modules.shopping.entity.GoodsType; +import com.sqx.modules.shopping.service.GoodsTypeService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城分类",tags={"自营商城分类管理"}) +@RequestMapping(value = "/app/goodsType") +public class AppGoodsTypeController { + @Autowired + private GoodsTypeService service; + + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll() { + return service.findAll(); + } + + + @GetMapping("/result") + @ApiOperation("商品分类数据封装") + public Result findAllResult() { + return service.findAllResult(); + } + + + @GetMapping("/result1") + @ApiOperation("一级分类数据封装") + public Result findAllResult1() { + return service.findAllResult1(); + } + + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/app/AppOrdersController.java b/src/main/java/com/sqx/modules/shopping/controller/app/AppOrdersController.java new file mode 100644 index 0000000..ec3ba18 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/app/AppOrdersController.java @@ -0,0 +1,130 @@ +package com.sqx.modules.shopping.controller.app; + + +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.shopping.entity.SelfOrders; +import com.sqx.modules.shopping.service.OrdersService; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.excel.ExcelData; +import com.sqx.modules.shopping.utils.excel.ExportExcelUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; + +@RestController +@Api(value="自营商城订单",tags={"自营商城订单管理"}) +@RequestMapping(value = "/app/orders") +public class AppOrdersController { + @Autowired + private OrdersService service; + + @Login + @GetMapping("/list") + @ApiOperation("后台管理列表") + public Result findAll(Integer page, Integer size, + @ApiParam("订单号")@RequestParam(required = false) String orderNum, + @ApiParam("订单状态:1待付款 2已付款 3已发货 4已收货 5已取消 6退款中 7已退款 8拒绝退款")@RequestParam String status, + @ApiParam("商品名称")@RequestParam(required = false) String title, + String startTime, String endTime, + @ApiParam("手机号")@RequestParam(required = false) String mobile,String sendWay) { + return service.findAll(page, size, orderNum, status, title, mobile,startTime,endTime,sendWay); + } + + + @Login + @GetMapping("/findMyList") + @ApiOperation("我的订单列表") + public Result findMyList(Integer page, Integer size, + @ApiParam("用户id")@RequestParam String userId, + @ApiParam("订单状态:1待付款 2已付款 3已发货 4已收货 5已取消 6退款中 7已退款 8拒绝退款")@RequestParam String status) { + return service.findMyList(page, size, userId, status); + } + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @Login + @PostMapping("/save") + @ApiOperation("保存订单") + public Result saveBody(@RequestBody SelfOrders entity) { + return service.saveBody(entity); + } + + @Login + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody SelfOrders entity) { + return service.updateBody(entity); + } + + + @Login + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + + @Login + @ApiOperation(value="取消订单,orderStatus=1时可取消") + @GetMapping("/cancel") + public Result orderCancel(@ApiParam("id") @RequestParam Long id){ + return service.orderCancel(id); + } + + @Login + @ApiOperation(value="确认收货,orderStatus=3时收货") + @GetMapping("/confirm") + public Result orderConfirm(@ApiParam("id") @RequestParam Long id){ + return service.orderConfirm(id); + } + + @Login + @ApiOperation("零钱支付") + @GetMapping("/changePay") + public Result changePay(String ordersId){ + return service.changePay(ordersId); + } + + @ApiOperation("检测是否完成支付") + @GetMapping("/wxPay") + public Result wxPayWeb(Long ordersId){ + return service.checkPay(ordersId); + } + + @Login + @ApiOperation("申请退款") + @GetMapping("/refund") + public Result refund(Long ordersId, String refund){ + return service.refund(ordersId, refund); + } + + @Login + @ApiOperation("用户端提醒发货") + @GetMapping("/remind") + public Result remind(Long ordersId){ + return service.remind(ordersId); + } + + @Login + @ApiOperation("用户端 订单统计") + @GetMapping("/count") + public Result count(@RequestAttribute Long userId){ + return service.count(userId); + } + + @Login + @ApiOperation("查快递") + @GetMapping("/findExpress") + public Result findExpress(String expressNumber){ + return service.findExpress(expressNumber); + } +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/app/AppOrdersRelationController.java b/src/main/java/com/sqx/modules/shopping/controller/app/AppOrdersRelationController.java new file mode 100644 index 0000000..704016c --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/app/AppOrdersRelationController.java @@ -0,0 +1,61 @@ +package com.sqx.modules.shopping.controller.app; + + +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.shopping.service.OrdersRelationService; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城订单分销",tags={"自营商城订单分销管理"}) +@RequestMapping(value = "/app/ordersRelation") +public class AppOrdersRelationController { + @Autowired + private OrdersRelationService service; + + @Login + @GetMapping("/list") + @ApiOperation("订单分销列表") + public Result findAll(Integer page, Integer size, + @ApiParam("用户id") @RequestParam(required = false) Long userId, + @ApiParam("用户手机号") @RequestParam(required = false) String phone, + @ApiParam("分销 0全部 1未到账 2已到账") @RequestParam(required = false) Integer status, + @ApiParam("佣金来源 0全部 1团队 2自己)") @RequestParam(required = false) Integer moneyFrom) { + return service.findAll(page, size, userId, phone, status, moneyFrom); + } + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @Login + @GetMapping("/statistaical") + @ApiOperation("我的佣金统计") + public Result statistaical(@RequestAttribute Long userId) { + return service.statistaical(userId); + } + + @Login + @GetMapping("/tuanStatistaical") + @ApiOperation("团队佣金统计") + public Result tuanStatistaical(@RequestAttribute Long userId) { + return service.tuanStatistaical(userId); + } + + @Login + @GetMapping(value = "/tuanSum") + @ApiOperation("获取团队总收益") + public Result tuanSum(@RequestAttribute Long userId) { + return ResultUtil.success(service.tuanSum(userId)); + } + + + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfActivityController.java b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfActivityController.java new file mode 100644 index 0000000..15865d1 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfActivityController.java @@ -0,0 +1,49 @@ +package com.sqx.modules.shopping.controller.app; + + +import com.sqx.modules.shopping.dao.SelfActivityJpaRepository; +import com.sqx.modules.shopping.dao.SelfActivityRepository; +import com.sqx.modules.shopping.entity.SelfActivity; +import com.sqx.modules.shopping.utils.DateUtil; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.text.SimpleDateFormat; +import java.util.Date; + +@RestController +@Api(value="自营商城首页菜单和活动管理",tags={"自营商城首页菜单和活动管理"}) +@RequestMapping(value = "/app/selfActivity") +public class AppSelfActivityController { + @Autowired + private SelfActivityJpaRepository activityJpaRepository; + + @Autowired + private SelfActivityRepository activityRepository; + + + @GetMapping(value = "/id") + @ApiOperation("管理平台详情") + public Result getBanner(Integer id) { + return ResultUtil.success(activityJpaRepository.findById(Long.valueOf(id)).orElse(null)); + } + + @GetMapping(value = "/state") + @ApiOperation("根据状态查询菜单列表") + public Result getBannerState(String state) { + return ResultUtil.success(activityRepository.findOne(state)); + } + + + @GetMapping(value = "/list") + @ApiOperation("管理平台获取全部广告位") + public Result getBannerList() { + return ResultUtil.success(activityJpaRepository.findAll()); + } + + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfAliPayController.java b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfAliPayController.java new file mode 100644 index 0000000..b21ab05 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfAliPayController.java @@ -0,0 +1,378 @@ +package com.sqx.modules.shopping.controller.app; + +import com.alibaba.fastjson.JSONObject; +import com.alipay.api.AlipayApiException; +import com.alipay.api.AlipayClient; +import com.alipay.api.CertAlipayRequest; +import com.alipay.api.DefaultAlipayClient; +import com.alipay.api.domain.AlipayTradeAppPayModel; +import com.alipay.api.internal.util.AlipaySignature; +import com.alipay.api.request.AlipayTradeAppPayRequest; +import com.alipay.api.request.AlipayTradeWapPayRequest; +import com.alipay.api.response.AlipayTradeAppPayResponse; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.pay.config.AliPayConstants; +import com.sqx.modules.shopping.dao.OrdersJpaRepository; +import com.sqx.modules.shopping.entity.SelfGoods; +import com.sqx.modules.shopping.entity.SelfGoodsVirtual; +import com.sqx.modules.shopping.entity.SelfOrders; +import com.sqx.modules.shopping.service.GoodsService; +import com.sqx.modules.shopping.service.OrdersService; +import com.sqx.modules.shopping.service.SelfGoodsVirtualService; +import com.sqx.modules.shopping.utils.AmountCalUtil; +import com.sqx.modules.shopping.utils.DateUtil; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +@Api(value="自营商城支付宝支付",tags={"自营商城支付宝支付"}) +@Slf4j +@RestController +@RequestMapping("/aliPay") +public class AppSelfAliPayController { + + @Autowired + private CommonInfoService commonRepository; + @Autowired + private OrdersService ordersService; + @Autowired + private OrdersJpaRepository ordersJpaRepository; + @Autowired + private SelfGoodsVirtualService selfGoodsVirtualService; + @Autowired + private UserService userService; + @Autowired + private GoodsService goodsService; + + + @RequestMapping("/notifyApp") + @Transactional(rollbackFor = Exception.class) + public void notifyApp(HttpServletRequest request, HttpServletResponse response){ + //获取支付宝POST过来反馈信息 + Map params = new HashMap(); + Map requestParams = request.getParameterMap(); + for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) { + String name = (String) iter.next(); + String[] values = (String[]) requestParams.get(name); + String valueStr = ""; + for (int i = 0; i < values.length; i++) { + valueStr = (i == values.length - 1) ? valueStr + values[i] + : valueStr + values[i] + ","; + } + //乱码解决,这段代码在出现乱码时使用。 + //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8"); + params.put(name, valueStr); + } + //切记alipaypublickey是支付宝的公钥,请去open.alipay.com对应应用下查看。 + //boolean AlipaySignature.rsaCheckV1(Map params, String publicKey, String charset, String sign_type) + try { + log.info("回调成功!!!"); + boolean flag = AlipaySignature.rsaCheckV1(params, commonRepository.findOne(64).getValue(), AliPayConstants.CHARSET,"RSA2"); + log.info(flag+"回调验证信息"); + if(flag){ + String outTradeNo = params.get("out_trade_no"); + //支付成功,处理业务 + SelfOrders orders = ordersService.findByOrderNum(outTradeNo); + if (orders.getStatus() != 1){ + log.info("订单回调重复:"+orders.toString()); + return; + } + orders.setPayWay(2); //支付方式为2支付宝 + orders.setStatus(2); //已付款 + orders.setPayTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); //设置支付时间 + //5.虚拟商品处理 + if (orders.getIsExpress() == 2){ //是否需要发货(1需要发货 2无需发货) + //虚拟商品发货,发货成功为确认收货,否则不做变化 + SelfGoodsVirtual v = selfGoodsVirtualService.sendGoods(orders.getGoodsId()); + if (v != null){ + orders.setVirtualId(v.getId()); //虚拟商品id + orders.setExpressTime(DateUtil.createTime()); //发货时间 + orders.setFinishTime(DateUtil.createTime()); //收货时间 + orders.setStatus(4); //确认收货 + log.info("虚拟商品发货成功,单号:"+outTradeNo); + System.err.println("虚拟商品发货成功,单号:"+outTradeNo); + } + } + ordersService.updateBody(orders); + } + } catch (AlipayApiException e) { + e.printStackTrace(); + log.info("回调验证失败!!!"); + } + } + + + @ApiOperation("支付宝回调") + @RequestMapping("/notifyAppZS") + @Transactional(rollbackFor = Exception.class) + public void notifyAppZS(HttpServletRequest request, HttpServletResponse response){ + //获取支付宝POST过来反馈信息 + Map params = new HashMap(); + Map requestParams = request.getParameterMap(); + for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) { + String name = (String) iter.next(); + String[] values = (String[]) requestParams.get(name); + String valueStr = ""; + for (int i = 0; i < values.length; i++) { + valueStr = (i == values.length - 1) ? valueStr + values[i] + : valueStr + values[i] + ","; + } + //乱码解决,这段代码在出现乱码时使用。 + //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8"); + params.put(name, valueStr); + } + try { + log.info("回调成功!!!"); + CommonInfo urls = commonRepository.findOne(246); + boolean flag = AlipaySignature.rsaCertCheckV1(params,urls.getValue()+"/alipayCertPublicKey_RSA2.crt", AliPayConstants.CHARSET, "RSA2"); + log.info(flag+"回调验证信息"); + if(flag){ + String tradeStatus = params.get("trade_status"); + if("TRADE_SUCCESS".equals(tradeStatus) || "TRADE_FINISHED".equals(tradeStatus)){ + String outTradeNo = params.get("out_trade_no"); + //支付成功,处理业务 + SelfOrders orders = ordersService.findByOrderNum(outTradeNo); + if (orders.getStatus() != 1){ + log.info("订单回调重复:"+orders.toString()); + return; + } + orders.setPayWay(2); //支付方式为2支付宝 + orders.setStatus(2); //已付款 + orders.setPayTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); //设置支付时间 + //5.虚拟商品处理 + if (orders.getIsExpress() == 2){ //是否需要发货(1需要发货 2无需发货) + //虚拟商品发货,发货成功为确认收货,否则不做变化 + SelfGoodsVirtual v = selfGoodsVirtualService.sendGoods(orders.getGoodsId()); + if (v != null){ + orders.setVirtualId(v.getId()); //虚拟商品id + orders.setExpressTime(DateUtil.createTime()); //发货时间 + orders.setFinishTime(DateUtil.createTime()); //收货时间 + orders.setStatus(4); //确认收货 + log.info("虚拟商品发货成功,单号:"+outTradeNo); + System.err.println("虚拟商品发货成功,单号:"+outTradeNo); + } + } + ordersService.updateBody(orders); + } + } + } catch (AlipayApiException e) { + e.printStackTrace(); + log.info("回调验证失败!!!"); + } + } + + + + + @ApiOperation("app支付") + @GetMapping("/payApp") + @Transactional(rollbackFor = Exception.class) + public Result payApp(Long ordersId){ + log.info("开始下单了!!"); + SelfOrders orders = ordersJpaRepository.getOne(ordersId); + String outTradeNo=orders.getOrderNum(); + //校验金额是否一致 + SelfGoods byId = goodsService.findById(orders.getGoodsId()); + UserEntity userById = userService.selectUserById(orders.getUserId()); + Double aDouble=0.00; + if(userById.getMember()==null || userById.getMember()!=1){ + aDouble = AmountCalUtil.moneyMul(byId.getPrice(), orders.getNumber()); + }else{ + aDouble = AmountCalUtil.moneyMul(byId.getMemberPrice(), orders.getNumber()); + } + aDouble= AmountCalUtil.add(aDouble,byId.getPostagePrice()); + if(!orders.getPayMoney().equals(aDouble)){ + ordersJpaRepository.deleteById(ordersId); + return ResultUtil.error(-100,"订单信息错误,请重新下单!"); + } + String name = commonRepository.findOne(12).getValue(); + return payApp(name,outTradeNo,orders.getPayMoney()); + } + + + @ApiOperation("h5支付") + @GetMapping(value = "/payH5") + @Transactional(rollbackFor = Exception.class) + public Result payH5(Long ordersId) { + SelfOrders orders = ordersJpaRepository.getOne(ordersId); + SelfGoods byId = goodsService.findById(orders.getGoodsId()); + UserEntity userById = userService.selectUserById(orders.getUserId()); + Double aDouble=0.00; + if(userById.getMember()==null || userById.getMember()!=1){ + aDouble = AmountCalUtil.moneyMul(byId.getPrice(), orders.getNumber()); + }else{ + aDouble = AmountCalUtil.moneyMul(byId.getMemberPrice(), orders.getNumber()); + } + aDouble= AmountCalUtil.add(aDouble,byId.getPostagePrice()); + if(!orders.getPayMoney().equals(aDouble)){ + ordersJpaRepository.deleteById(ordersId); + return ResultUtil.error(-100,"订单信息错误,请重新下单!"); + } + String name = commonRepository.findOne(12).getValue(); + CommonInfo one = commonRepository.findOne(19); + String returnUrl = one.getValue()+"/pages/zysc/my/payment?id="+ordersId; + return payH5(name,orders.getOrderNum(),orders.getPayMoney(),returnUrl); + } + + + public Result payApp(String name, String generalOrder, Double money) { + CommonInfo one = commonRepository.findOne(19); + String url = one.getValue() + "/sqx_fast/aliPay/notifyApp"; + String result = ""; + CommonInfo payWay = commonRepository.findOne(201); + try { + if ("1".equals(payWay.getValue())) { + //构造client + CertAlipayRequest certAlipayRequest = new CertAlipayRequest(); + //设置网关地址 + certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); + //设置应用Id + certAlipayRequest.setAppId(commonRepository.findOne(63).getValue()); + //设置应用私钥 + certAlipayRequest.setPrivateKey(commonRepository.findOne(65).getValue()); + //设置请求格式,固定值json + certAlipayRequest.setFormat("json"); + //设置字符集 + certAlipayRequest.setCharset(AliPayConstants.CHARSET); + //设置签名类型 + certAlipayRequest.setSignType(AliPayConstants.SIGNTYPE); + CommonInfo urls = commonRepository.findOne(200); + certAlipayRequest.setCertPath(urls.getValue() + "/appCertPublicKey.crt"); //应用公钥证书路径(app_cert_path 文件绝对路径) + certAlipayRequest.setAlipayPublicCertPath(urls.getValue() + "/alipayCertPublicKey_RSA2.crt"); //支付宝公钥证书文件路径(alipay_cert_path 文件绝对路径) + certAlipayRequest.setRootCertPath(urls.getValue() + "/alipayRootCert.crt"); //支付宝CA根证书文件路径(alipay_root_cert_path 文件绝对路径) + //构造client + AlipayClient alipayClient = new DefaultAlipayClient(certAlipayRequest); + + //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay + AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); + //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。 + AlipayTradeAppPayModel model = new AlipayTradeAppPayModel(); + model.setBody(name); + model.setSubject(name); + model.setOutTradeNo(generalOrder); + model.setTimeoutExpress("30m"); + model.setTotalAmount(money +""); + model.setProductCode("QUICK_MSECURITY_PAY"); + request.setBizModel(model); + request.setNotifyUrl(url); + //这里和普通的接口调用不同,使用的是sdkExecute + AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request); + if (response.isSuccess()) { + result = response.getBody(); + } else { + return ResultUtil.error(500,"获取订单失败!"); + } + return ResultUtil.success(result); + } else { + //实例化客户端 + AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", commonRepository.findOne(63).getValue(), commonRepository.findOne(65).getValue(), "json", AliPayConstants.CHARSET, commonRepository.findOne(64).getValue(), "RSA2"); + //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay + AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); + //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。 + AlipayTradeAppPayModel model = new AlipayTradeAppPayModel(); + model.setBody(name); + model.setSubject(name); + model.setOutTradeNo(generalOrder); + model.setTimeoutExpress("30m"); + model.setTotalAmount(String.valueOf(money)); + model.setProductCode("QUICK_MSECURITY_PAY"); + request.setBizModel(model); + request.setNotifyUrl(url); + AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request); + if (response.isSuccess()) { + result = response.getBody(); + } else { + return ResultUtil.error(500,"获取订单失败!"); + } + return ResultUtil.success(result); + } + } catch (AlipayApiException e) { + e.printStackTrace(); + } + return ResultUtil.error(-100, "获取订单失败!"); + } + + public Result payH5(String name, String generalOrder, Double money, String returnUrl) { + CommonInfo payWay = commonRepository.findOne(201); + CommonInfo one = commonRepository.findOne(19); + String url = one.getValue() + "/sqx_fast/aliPay/notifyApp"; + try { + if ("1".equals(payWay.getValue())) { + //构造client + CertAlipayRequest certAlipayRequest = new CertAlipayRequest(); + //设置网关地址 + certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); + //设置应用Id + certAlipayRequest.setAppId(commonRepository.findOne(63).getValue()); + //设置应用私钥 + certAlipayRequest.setPrivateKey(commonRepository.findOne(65).getValue()); + //设置请求格式,固定值json + certAlipayRequest.setFormat("json"); + //设置字符集 + certAlipayRequest.setCharset(AliPayConstants.CHARSET); + //设置签名类型 + certAlipayRequest.setSignType(AliPayConstants.SIGNTYPE); + CommonInfo urls = commonRepository.findOne(200); + certAlipayRequest.setCertPath(urls.getValue() + "/appCertPublicKey.crt"); //应用公钥证书路径(app_cert_path 文件绝对路径) + certAlipayRequest.setAlipayPublicCertPath(urls.getValue() + "/alipayCertPublicKey_RSA2.crt"); //支付宝公钥证书文件路径(alipay_cert_path 文件绝对路径) + certAlipayRequest.setRootCertPath(urls.getValue() + "/alipayRootCert.crt"); //支付宝CA根证书文件路径(alipay_root_cert_path 文件绝对路径) + //构造client + AlipayClient alipayClient = new DefaultAlipayClient(certAlipayRequest); + AlipayTradeWapPayRequest alipayRequest = new AlipayTradeWapPayRequest(); + JSONObject order = new JSONObject(); + order.put("out_trade_no", generalOrder); //订单号 + order.put("subject", name); //商品标题 + order.put("product_code", "QUICK_WAP_WAY"); + order.put("body", name);//商品名称 + order.put("total_amount", money + ""); //金额 + alipayRequest.setBizContent(order.toString()); + alipayRequest.setNotifyUrl(url); //在公共参数中设置回跳和通知地址 + alipayRequest.setReturnUrl(returnUrl); //线上通知页面地址 + String result = alipayClient.pageExecute(alipayRequest).getBody(); + return ResultUtil.success(result); + } else { + AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", commonRepository.findOne(63).getValue(), commonRepository.findOne(65).getValue(), "json", AliPayConstants.CHARSET, commonRepository.findOne(64).getValue(), "RSA2"); + AlipayTradeWapPayRequest alipayRequest = new AlipayTradeWapPayRequest(); + JSONObject order = new JSONObject(); + order.put("out_trade_no", generalOrder); //订单号 + order.put("subject", name); //商品标题 + order.put("product_code", "QUICK_WAP_WAY"); + order.put("body", name);//商品名称 + order.put("total_amount", money); //金额 + alipayRequest.setBizContent(order.toString()); + //在公共参数中设置回跳和通知地址 + alipayRequest.setNotifyUrl(url); + //通知页面地址 + alipayRequest.setReturnUrl(returnUrl); + String form = alipayClient.pageExecute(alipayRequest).getBody(); + return ResultUtil.success(form); + } + } catch (AlipayApiException e) { + log.error("CreatPayOrderForH5", e); + } + return ResultUtil.error(500,"获取订单信息错误!"); + } + + + + + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfBannerController.java b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfBannerController.java new file mode 100644 index 0000000..76e15f7 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfBannerController.java @@ -0,0 +1,33 @@ +package com.sqx.modules.shopping.controller.app; + + +import com.sqx.modules.shopping.entity.SelfBanner; +import com.sqx.modules.shopping.service.SlefBannerService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城Banner位",tags={"自营商城Banner位"}) +@RequestMapping(value = "/app/selfBanner") +public class AppSelfBannerController { + @Autowired + private SlefBannerService service; + + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll() { + return service.findAll(); + } + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfGoodsBrandController.java b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfGoodsBrandController.java new file mode 100644 index 0000000..8bba858 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfGoodsBrandController.java @@ -0,0 +1,37 @@ +package com.sqx.modules.shopping.controller.app; + + +import com.sqx.modules.shopping.entity.SelfGoodsBrand; +import com.sqx.modules.shopping.service.SelfGoodsBrandService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城商品品牌",tags={"自营商城商品品牌"}) +@RequestMapping(value = "/app/selfGoodsBrand") +public class AppSelfGoodsBrandController { + @Autowired + private SelfGoodsBrandService service; + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll(Integer page, Integer size) { + return service.findAll(page, size); + } + + @GetMapping("/result") + @ApiOperation("品牌封装列表") + public Result result() { + return service.result(); + } + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfGoodsCommentController.java b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfGoodsCommentController.java new file mode 100644 index 0000000..e10341a --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfGoodsCommentController.java @@ -0,0 +1,62 @@ +package com.sqx.modules.shopping.controller.app; + + +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.shopping.entity.SelfGoodsComment; +import com.sqx.modules.shopping.service.SelfGoodsCommentService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城商品评论",tags={"自营商城商品评论"}) +@RequestMapping(value = "/app/selfGoodsComment") +public class AppSelfGoodsCommentController { + @Autowired + private SelfGoodsCommentService service; + + @GetMapping("/list") + @ApiOperation("商品评价列表") + public Result findAll(Integer page, Integer size, Long goodsId, @ApiParam("0全部 1好评 2中评 3差评")@RequestParam Integer scoreType) { + return service.findAll(page, size, goodsId,scoreType); + } + + @GetMapping("/count") + @ApiOperation("商品评价统计") + public Result count(Long goodsId) { + return service.count(goodsId); + } + + + @GetMapping("/findByOrderId") + @ApiOperation("订单评价") + public Result findByOrderId(Long orderId) { + return service.findByOrderId(orderId); + } + + @Login + @GetMapping("/userList") + @ApiOperation("用户评论列表") + public Result userList(Integer page, Integer size,@RequestAttribute Long userId) { + return service.userList(page, size, userId); + } + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @Login + @PostMapping("/save") + @ApiOperation("添加") + public Result saveBody(@RequestBody SelfGoodsComment entity) { + return service.saveBody(entity); + } + + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfGoodsRuleController.java b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfGoodsRuleController.java new file mode 100644 index 0000000..763937e --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfGoodsRuleController.java @@ -0,0 +1,49 @@ +package com.sqx.modules.shopping.controller.app; + +import com.sqx.modules.shopping.entity.SelfGoodsRule; +import com.sqx.modules.shopping.service.SelfGoodsRuleService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城商品规格",tags={"自营商城商品规格"}) +@RequestMapping(value = "/app/selfGoodsRule") +public class AppSelfGoodsRuleController { + @Autowired + private SelfGoodsRuleService service; + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll(Integer page, Integer size) { + return service.findAll(page, size); + } + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @PostMapping("/save") + @ApiOperation("添加") + public Result saveBody(@RequestBody SelfGoodsRule entity) { + return service.saveBody(entity); + } + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody SelfGoodsRule entity) { + return service.updateBody(entity); + } + + + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfGoodsVirtualController.java b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfGoodsVirtualController.java new file mode 100644 index 0000000..70477d7 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfGoodsVirtualController.java @@ -0,0 +1,57 @@ +package com.sqx.modules.shopping.controller.app; + + +import com.sqx.modules.shopping.entity.SelfGoodsVirtual; +import com.sqx.modules.shopping.service.SelfGoodsVirtualService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城虚拟商品",tags={"自营商城虚拟商品"}) +@RequestMapping(value = "/app/selfGoodsVirtual") +public class AppSelfGoodsVirtualController { + @Autowired + private SelfGoodsVirtualService service; + + + @GetMapping("/list") + @ApiOperation("兑换码列表") + public Result findAll(Integer page, Integer size, + @ApiParam("虚拟商品id")@RequestParam(required = false) Long goodsId, + @ApiParam("卡密内容")@RequestParam(required = false) String content) { + return service.findAll(page, size, goodsId, content); + } + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + + @PostMapping("/save") + @ApiOperation("添加") + public Result saveBody(@RequestBody SelfGoodsVirtual entity) { + return service.saveBody(entity); + } + + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody SelfGoodsVirtual entity) { + return service.updateBody(entity); + } + + + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfMerchantApplyController.java b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfMerchantApplyController.java new file mode 100644 index 0000000..9333681 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfMerchantApplyController.java @@ -0,0 +1,71 @@ +package com.sqx.modules.shopping.controller.app; + + +import com.sqx.modules.shopping.entity.SelfMerchantApply; +import com.sqx.modules.shopping.service.SelfMerchantApplyService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城多商户商户入驻申请信息",tags={"自营商城多商户商户入驻申请信息"}) +@RequestMapping(value = "/app/self/merchantApply") +public class AppSelfMerchantApplyController { + @Autowired + private SelfMerchantApplyService service; + + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll(Integer page, Integer size, + @ApiParam("商家名称") @RequestParam(required = false) String companyName, + @ApiParam("注册手机号") @RequestParam(required = false) String legalPhone, + @ApiParam("店铺类型") @RequestParam Integer storeType, + @ApiParam("审核状态(1待处理 2通过 3拒绝)") @RequestParam Integer status, + @ApiParam("申请时间开始区间") @RequestParam(required = false) String createTimeStart, + @ApiParam("申请时间结束区间") @RequestParam(required = false) String createTimeEnd) { + return service.findAll(page, size, companyName, legalPhone, storeType, status, createTimeStart, createTimeEnd); + } + + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + + @PostMapping("/save") + @ApiOperation("添加") + public Result saveBody(@RequestBody SelfMerchantApply entity) { + return service.saveBody(entity); + } + + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody SelfMerchantApply entity) { + return service.updateBody(entity); + } + + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + + + @PostMapping("/deal") + @ApiOperation("处理审核") + public Result deal(@ApiParam("申请id") @RequestParam Long id, + @ApiParam("审核状态(1待处理 2通过 3拒绝)") @RequestParam Integer status, + @ApiParam("生效日期") @RequestParam(required = false) String auditTime, + @ApiParam("生效年限") @RequestParam String auditYears, + @ApiParam("拒绝原因") @RequestParam(required = false) String refundReason) { + return service.deal(id, status, auditTime, auditYears, refundReason); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfUserCollectController.java b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfUserCollectController.java new file mode 100644 index 0000000..5c7bc46 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfUserCollectController.java @@ -0,0 +1,54 @@ +package com.sqx.modules.shopping.controller.app; + +import com.sqx.modules.shopping.entity.SelfUserCollect; +import com.sqx.modules.shopping.service.SelfUserCollectService; +import com.sqx.modules.shopping.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(value="自营商城用户收藏",tags={"自营商城用户收藏"}) +@RequestMapping(value = "/app/selfUserCollect") +public class AppSelfUserCollectController { + @Autowired + private SelfUserCollectService service; + + @GetMapping("/list") + @ApiOperation("列表") + public Result findAll(Integer page, Integer size, Long userId) { + return service.findAll(page, size, userId); + } + + @GetMapping("/find") + @ApiOperation("查询") + public Result findOne(Long id) { + return service.findOne(id); + } + + @PostMapping("/save") + @ApiOperation("添加") + public Result saveBody(@RequestBody SelfUserCollect entity) { + return service.saveBody(entity); + } + + @PostMapping("/update") + @ApiOperation("修改") + public Result updateBody(@RequestBody SelfUserCollect entity) { + return service.updateBody(entity); + } + + @GetMapping("/delete") + @ApiOperation("删除") + public Result delete(Long id) { + return service.delete(id); + } + + @GetMapping("/check") + @ApiOperation("判断是否收藏") + public Result check(Long goodsId, Long userId) { + return service.check(goodsId, userId); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfWXPayController.java b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfWXPayController.java new file mode 100644 index 0000000..446dfd8 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/controller/app/AppSelfWXPayController.java @@ -0,0 +1,115 @@ +package com.sqx.modules.shopping.controller.app; + + +import com.sqx.modules.shopping.service.SelfWXService; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Map; + +@Api(value="自营商城微信支付",tags={"自营商城微信支付"}) +@RestController +@RequestMapping("/pay") +public class AppSelfWXPayController { + private final Logger log = LoggerFactory.getLogger(AppSelfWXPayController.class); + @Autowired + private SelfWXService service; + + + @ApiOperation("app支付") + @PostMapping("/wxPayApp") + public Map wxPayApp(Long ordersId, HttpServletRequest request) throws Exception { + return service.doUnifiedOrder(ordersId,1, request); + } + + + @ApiOperation("公众号JSAPI支付") + @PostMapping("/wxPayWeb") + public Map wxPayWeb(Long ordersId, HttpServletRequest request) throws Exception { + return service.doUnifiedOrder(ordersId,2, request); + } + + @ApiOperation("小程序JSAPI支付") + @PostMapping("/wxPayJS") + public Map wxPayJS(Long ordersId, HttpServletRequest request) throws Exception { + return service.doUnifiedOrder(ordersId,3, request); + } + + @ApiOperation("H5支付") + @PostMapping("/wxPayH5") + public Map wxPayH5(Long ordersId, HttpServletRequest request) throws Exception { + return service.doUnifiedOrder(ordersId,4, request); + } + + + @PostMapping("/notify") + public String notify(HttpServletRequest request) { + return notify(request,1); + } + + @PostMapping("/notifyjs") + public String notifyjs(HttpServletRequest request) { + return notify(request,2); + } + + @PostMapping("/notifys") + public String notifys(HttpServletRequest request) { + return notify(request,3); + } + + public String notify(HttpServletRequest request,Integer type) { + String resXml = ""; + try { + InputStream inputStream = request.getInputStream(); + //将InputStream转换成xmlString + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb = new StringBuilder(); + String line = null; + try { + while ((line = reader.readLine()) != null) { + sb.append(line + "\n"); + } + } catch (IOException e) { + log.info(e.getMessage()); + } finally { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + resXml = sb.toString(); + String result = service.payBack(resXml,type); + log.info("成功"); + log.info(result); + return result; + } catch (Exception e) { + log.info("微信手机支付失败:" + e.getMessage()); + String result = "" + "" + "" + " "; + log.info("失败"); + log.info(result); + return result; + } + } + + + @ApiOperation("微信退款") + @PostMapping("/refund") + public Result refund(Long ordersId){ + return ResultUtil.success(service.refund(ordersId)); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/AdvertJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/AdvertJpaRepository.java new file mode 100644 index 0000000..d4e3d6b --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/AdvertJpaRepository.java @@ -0,0 +1,11 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.Adverti; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface AdvertJpaRepository extends JpaRepository { + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/AdvertRepository.java b/src/main/java/com/sqx/modules/shopping/dao/AdvertRepository.java new file mode 100644 index 0000000..ba38f49 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/AdvertRepository.java @@ -0,0 +1,9 @@ +package com.sqx.modules.shopping.dao; + +import com.sqx.modules.shopping.entity.Adverti; +import org.springframework.data.repository.Repository; + + +public interface AdvertRepository extends Repository { + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/CouponsJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/CouponsJpaRepository.java new file mode 100644 index 0000000..2bd6fb3 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/CouponsJpaRepository.java @@ -0,0 +1,20 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.Coupons; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface CouponsJpaRepository extends JpaRepository { + + /** + * 查询所有优惠券,状态为0正常 + */ + @Query(value = "from Coupons s where s.status = 0 and s.remainingNumber > 0") + List findAllByStatus(); + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/CouponsRepository.java b/src/main/java/com/sqx/modules/shopping/dao/CouponsRepository.java new file mode 100644 index 0000000..3054f06 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/CouponsRepository.java @@ -0,0 +1,9 @@ +package com.sqx.modules.shopping.dao; + +import com.sqx.modules.shopping.entity.Coupons; +import org.springframework.data.repository.Repository; + + +public interface CouponsRepository extends Repository { + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/CouponsUserJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/CouponsUserJpaRepository.java new file mode 100644 index 0000000..6f2b497 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/CouponsUserJpaRepository.java @@ -0,0 +1,20 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.CouponsUser; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +@Repository +public interface CouponsUserJpaRepository extends JpaRepository { + + /** + * 查询用户领取的优惠券的数量 + */ + @Query(value = "select count(s.id) from CouponsUser s where s.couponsId =: couponsId and s.userId =: userId") + int findByCouponsId(@Param("couponsId") Long couponsId, @Param("userId") Long userId); + + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/CouponsUserRepository.java b/src/main/java/com/sqx/modules/shopping/dao/CouponsUserRepository.java new file mode 100644 index 0000000..a162f3b --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/CouponsUserRepository.java @@ -0,0 +1,9 @@ +package com.sqx.modules.shopping.dao; + +import com.sqx.modules.shopping.entity.CouponsUser; +import org.springframework.data.repository.Repository; + + +public interface CouponsUserRepository extends Repository { + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/GoodsJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/GoodsJpaRepository.java new file mode 100644 index 0000000..297339f --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/GoodsJpaRepository.java @@ -0,0 +1,21 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoods; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface GoodsJpaRepository extends JpaRepository { + + //条件查询带分页 + Page findAll(Specification specification, Pageable pageable); + + List findAll(Specification specification); + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/GoodsRepository.java b/src/main/java/com/sqx/modules/shopping/dao/GoodsRepository.java new file mode 100644 index 0000000..6304e50 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/GoodsRepository.java @@ -0,0 +1,9 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoods; +import org.springframework.data.repository.Repository; + +public interface GoodsRepository extends Repository { + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/GoodsTypeJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/GoodsTypeJpaRepository.java new file mode 100644 index 0000000..45877f2 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/GoodsTypeJpaRepository.java @@ -0,0 +1,15 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.GoodsType; +import com.sqx.modules.shopping.entity.SelfGoods; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface GoodsTypeJpaRepository extends JpaRepository { + List findAll(Specification specification); +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/GoodsTypeRepository.java b/src/main/java/com/sqx/modules/shopping/dao/GoodsTypeRepository.java new file mode 100644 index 0000000..fba8db0 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/GoodsTypeRepository.java @@ -0,0 +1,24 @@ +package com.sqx.modules.shopping.dao; + +import com.sqx.modules.shopping.entity.GoodsType; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.Repository; + +import java.util.List; + + +public interface GoodsTypeRepository extends Repository { + + /** + * 查询所有一级分类 + */ + @Query(value = "from GoodsType s where s.parentId=0 order by s.sort asc") + List findAllStatus0(); + + /** + * 查询所有非一级分类 + */ + @Query(value = "from GoodsType s where s.parentId <> 0 order by s.sort asc") + List findAllStatus(); + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/OrdersJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/OrdersJpaRepository.java new file mode 100644 index 0000000..6d2c9ee --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/OrdersJpaRepository.java @@ -0,0 +1,31 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfOrders; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface OrdersJpaRepository extends JpaRepository { + + //条件查询带分页 + Page findAll(Specification specification, Pageable pageable); + + //条件查询 + List findAll(Specification specification); + + //根据订单号查询 + SelfOrders findByOrderNum(String orderNum); + + //根据订单号查询 + List findByPayNum(String payNum); + + //根据虚拟id查询 + SelfOrders findByVirtualId(Long virtualId); + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/OrdersRelationJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/OrdersRelationJpaRepository.java new file mode 100644 index 0000000..aa55147 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/OrdersRelationJpaRepository.java @@ -0,0 +1,22 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfOrderRelation; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface OrdersRelationJpaRepository extends JpaRepository { + + //条件查询带分页 + Page findAll(Specification specification, Pageable pageable); + + //条件查询 + List findAll(Specification specification); + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/OrdersRelationRepository.java b/src/main/java/com/sqx/modules/shopping/dao/OrdersRelationRepository.java new file mode 100644 index 0000000..7683ac2 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/OrdersRelationRepository.java @@ -0,0 +1,46 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfOrderRelation; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.Repository; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +public interface OrdersRelationRepository extends Repository { + + /** + * 查询所有未入账的 + */ + @Query(value = "from SelfOrderRelation where status = 1") + List findAllByStatus(); + + //用户自己本月未到账 + @Query(value = "select sum(s.commissionPrice) from SelfOrderRelation s where s.status = 1 and s.moneyFrom = 2 and s.userId=:userId and s.createAt like concat('%',:month,'%')") + String sumByUserIdStatus1(@Param("userId") Long userId, @Param("month") String month); + + //用户自己本月已到账 + @Query(value = "select sum(s.commissionPrice) from SelfOrderRelation s where s.status = 2 and s.moneyFrom = 2 and s.userId=:userId and s.createAt like concat('%',:month,'%')") + String sumByUserIdStatus2(@Param("userId") Long userId, @Param("month") String month); + + //用户团队本月未到账 + @Query(value = "select sum(s.commissionPrice) from SelfOrderRelation s where s.status = 1 and s.moneyFrom = 1 and s.userId=:userId and s.createAt like concat('%',:month,'%')") + String sumByUserIdStatus1Tuan(@Param("userId") Long userId, @Param("month") String month); + + //用户团队本月已到账 + @Query(value = "select sum(s.commissionPrice) from SelfOrderRelation s where s.status = 2 and s.moneyFrom = 1 and s.userId=:userId and s.createAt like concat('%',:month,'%')") + String sumByUserIdStatus2Tuan(@Param("userId") Long userId, @Param("month") String month); + + //团队总收益 + @Query(value = "select sum(s.commissionPrice) from SelfOrderRelation s where s.status = 2 and s.moneyFrom in(1,3) and s.userId=:userId") + String tuanSum(@Param("userId") Long userId); + + //直属团队累计金额 + @Query(value = "select sum(s.commissionPrice) from SelfOrderRelation s where s.status = 2 and s.moneyFrom = 1 and s.userId=:userId") + String sumByLowerUserId(@Param("userId") Long userId); + + //非直属团队累计金额 + @Query(value = "select sum(s.commissionPrice) from SelfOrderRelation s where s.status = 2 and s.moneyFrom = 3 and s.userId=:userId") + String sumByLowerUserIds(@Param("userId") Long userId); +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/OrdersRepository.java b/src/main/java/com/sqx/modules/shopping/dao/OrdersRepository.java new file mode 100644 index 0000000..f6b7b0b --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/OrdersRepository.java @@ -0,0 +1,29 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfOrders; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.Repository; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +public interface OrdersRepository extends Repository { + + /** + * 查询待处理订单个数(1待付款 2已付款 3已发货 4已收货 5已取消 6退款中 7已退款) + */ + @Query(value = "select count(id) from SelfOrders where status in(2,6)") + int pendingOrder(); + + //查询用户订单 + @Query(value = "from SelfOrders o where o.userId =:userId") + List findByUserId(@Param("userId") Long userId); + + @Query(value = "from SelfOrders o where o.status in(2,3,4,6,8,9,10) and o.orderType in(1,2,3)") + List findByStatus(); + +// @Query(value = "select * from self_orders where status=3 and ") + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfActivityJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfActivityJpaRepository.java new file mode 100644 index 0000000..a871ec5 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfActivityJpaRepository.java @@ -0,0 +1,13 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfActivity; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface SelfActivityJpaRepository extends JpaRepository { + + + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfActivityRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfActivityRepository.java new file mode 100644 index 0000000..0a6ea85 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfActivityRepository.java @@ -0,0 +1,14 @@ +package com.sqx.modules.shopping.dao; + +import com.sqx.modules.shopping.entity.SelfActivity; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.Repository; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +public interface SelfActivityRepository extends Repository { + @Query(value = "from SelfActivity s where s.state=:state") + List findOne(@Param("state") String state); + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfBannerJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfBannerJpaRepository.java new file mode 100644 index 0000000..8c6eb13 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfBannerJpaRepository.java @@ -0,0 +1,11 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfBanner; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface SelfBannerJpaRepository extends JpaRepository { + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfBannerRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfBannerRepository.java new file mode 100644 index 0000000..2982333 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfBannerRepository.java @@ -0,0 +1,9 @@ +package com.sqx.modules.shopping.dao; + +import com.sqx.modules.shopping.entity.SelfBanner; +import org.springframework.data.repository.Repository; + + +public interface SelfBannerRepository extends Repository { + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsAttrJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsAttrJpaRepository.java new file mode 100644 index 0000000..8366237 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsAttrJpaRepository.java @@ -0,0 +1,24 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoodsAttr; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface SelfGoodsAttrJpaRepository extends JpaRepository { + + List findAll(Specification specification); + + /** + * 根据商品id查询 + */ + @Query(value = "from SelfGoodsAttr s where s.goodsId=:goodsId") + List findAllByGoodsId(@Param("goodsId") Long goodsId); + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsAttrRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsAttrRepository.java new file mode 100644 index 0000000..6aedb51 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsAttrRepository.java @@ -0,0 +1,18 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoodsAttr; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.Repository; +import org.springframework.transaction.annotation.Transactional; + +public interface SelfGoodsAttrRepository extends Repository { + + @Transactional + @Modifying + @Query(value = "delete from self_goods_attr where goods_id=:goodsId",nativeQuery = true) + int deleteSelfGoodsAttrByGoodsId(Long goodsId); + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsAttrValueJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsAttrValueJpaRepository.java new file mode 100644 index 0000000..735c7bd --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsAttrValueJpaRepository.java @@ -0,0 +1,28 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoodsAttrValue; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface SelfGoodsAttrValueJpaRepository extends JpaRepository { + + List findAll(Specification specification); + + /** + * 根据规格id查询 + */ + @Query(value = "from SelfGoodsAttrValue s where s.attrId=:attrId") + List findAllByAttrId(@Param("attrId") Long attrId); + /** + * 根据商品id查询 + */ + @Query(value = "from SelfGoodsAttrValue s where s.goodsId=:goodsId") + List findAllByGoodsId(@Param("goodsId") Long goodsId); +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsAttrValueRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsAttrValueRepository.java new file mode 100644 index 0000000..7b0f021 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsAttrValueRepository.java @@ -0,0 +1,18 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoodsAttrValue; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.Repository; +import org.springframework.transaction.annotation.Transactional; + +public interface SelfGoodsAttrValueRepository extends Repository { + + @Transactional + @Modifying + @Query(value = "delete from self_goods_attr_value where goods_id=:goodsId",nativeQuery = true) + int deleteSelfGoodsAttrValueByGoodsId(Long goodsId); + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsBrandJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsBrandJpaRepository.java new file mode 100644 index 0000000..d0bbcdd --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsBrandJpaRepository.java @@ -0,0 +1,22 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoodsBrand; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface SelfGoodsBrandJpaRepository extends JpaRepository { + + //分页查询 + Page findAll(Pageable pageable); + + //条件查询 + List findAll(Specification specification); + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsBrandRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsBrandRepository.java new file mode 100644 index 0000000..9c69d08 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsBrandRepository.java @@ -0,0 +1,9 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoodsBrand; +import org.springframework.data.repository.Repository; + +public interface SelfGoodsBrandRepository extends Repository { + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsCommentJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsCommentJpaRepository.java new file mode 100644 index 0000000..982e6e9 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsCommentJpaRepository.java @@ -0,0 +1,28 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoodsComment; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface SelfGoodsCommentJpaRepository extends JpaRepository { + + //分页查询 + Page findAll(Specification specification, Pageable pageable); + + //条件查询 + List findAll(Specification specification); + + //根据订单查询评论 + SelfGoodsComment findByOrderId(Long orderId); + + //根据商品id + List findAllByGoodsId(Long goodsId); + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsCommentRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsCommentRepository.java new file mode 100644 index 0000000..5a717db --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsCommentRepository.java @@ -0,0 +1,9 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoodsComment; +import org.springframework.data.repository.Repository; + +public interface SelfGoodsCommentRepository extends Repository { + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsRuleJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsRuleJpaRepository.java new file mode 100644 index 0000000..e17899d --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsRuleJpaRepository.java @@ -0,0 +1,16 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoodsRule; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface SelfGoodsRuleJpaRepository extends JpaRepository { + + //分页查询 + Page findAll(Pageable pageable); + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsRuleRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsRuleRepository.java new file mode 100644 index 0000000..e9bff99 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsRuleRepository.java @@ -0,0 +1,9 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoodsRule; +import org.springframework.data.repository.Repository; + +public interface SelfGoodsRuleRepository extends Repository { + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsRuleValueJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsRuleValueJpaRepository.java new file mode 100644 index 0000000..d273a77 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsRuleValueJpaRepository.java @@ -0,0 +1,20 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoodsRuleValue; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface SelfGoodsRuleValueJpaRepository extends JpaRepository { + + /** + * 根据规格id查询所有规格明细 + */ + @Query(value = "from SelfGoodsRuleValue s where s.ruleId=:ruleId") + List findAllByRuleId(@Param("ruleId") Long ruleId); +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsRuleValueRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsRuleValueRepository.java new file mode 100644 index 0000000..ef468e6 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsRuleValueRepository.java @@ -0,0 +1,9 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoodsRuleValue; +import org.springframework.data.repository.Repository; + +public interface SelfGoodsRuleValueRepository extends Repository { + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsSkuJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsSkuJpaRepository.java new file mode 100644 index 0000000..486b736 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsSkuJpaRepository.java @@ -0,0 +1,45 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoodsSku; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Repository +public interface SelfGoodsSkuJpaRepository extends JpaRepository { + + List findAll(Specification specification); + + /** + * 根据商品id查询 + */ + @Query(value = "from SelfGoodsSku s where s.goodsId=:goodsId") + List findAllByGoodsId(@Param("goodsId") Long goodsId); + + + //sku库存减少 + @Modifying + @Transactional + @Query(value = "update SelfGoodsSku s set s.stock=s.stock-:number where s.id=:id") + Integer lessStock(@Param("id") Long id, @Param("number") Integer number); + + //sku库存增加 + @Modifying + @Transactional + @Query(value = "update SelfGoodsSku s set s.stock=s.stock+:number where s.id=:id") + Integer addStock(@Param("id") Long id, @Param("number") Integer number); + + //sku销量添加 + @Modifying + @Transactional + @Query(value = "update SelfGoodsSku s set s.sales=s.sales+:number where s.id=:id") + Integer addSales(@Param("id") Long id, @Param("number") Integer number); + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsSkuRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsSkuRepository.java new file mode 100644 index 0000000..ed06e3f --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsSkuRepository.java @@ -0,0 +1,9 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoodsSku; +import org.springframework.data.repository.Repository; + +public interface SelfGoodsSkuRepository extends Repository { + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsVirtualJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsVirtualJpaRepository.java new file mode 100644 index 0000000..c60d547 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsVirtualJpaRepository.java @@ -0,0 +1,55 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoodsVirtual; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Map; + +@Repository +public interface SelfGoodsVirtualJpaRepository extends JpaRepository { + + //分页查询 + Page findAll(Pageable pageable); + + //条件查询 + Page findAll(Specification specification, Pageable pageable); + + List findAll(Specification specification); + + //查询可用的虚拟商品 + @Query(value = "select v.id,v.content,v.cover_img as coverImg,v.create_time as createTime,v.goods_id as goodsId,v.link_url as linkUrl,v.status,v.title,o.id as orderId,o.order_num as orderNum,o.pay_money as payMoney,o.pay_way as payWay,o.express_time as expressTime,u.nick_name as nickName,u.phone from self_goods_virtual v left join self_orders o on o.virtual_id = v.id left join tb_user u on u.user_id = o.user_id where v.goods_id=:goodsId and v.content like concat('%',:content,'%') order by o.express_time desc", + countQuery = "select count(*) from self_goods_virtual v left join self_orders o on o.virtual_id = v.id left join tb_user u on u.user_id = o.user_id where v.goods_id=:goodsId and v.content like concat('%',:content,'%') order by o.express_time desc", + nativeQuery=true) + Page> findAllContent(Pageable pageable, @Param("goodsId") Long goodsId, @Param("content") String content); + + //查询可用的虚拟商品 + @Query(value = "select v.id,v.content,v.cover_img as coverImg,v.create_time as createTime,v.goods_id as goodsId,v.link_url as linkUrl,v.status,v.title,o.id as orderId,o.order_num as orderNum,o.pay_money as payMoney,o.pay_way as payWay,o.express_time as expressTime,u.nick_name as nickName,u.phone from self_goods_virtual v left join self_orders o on o.virtual_id = v.id left join tb_user u on u.user_id = o.user_id where v.goods_id=:goodsId order by o.express_time desc", + countQuery = "select count(*) from self_goods_virtual v left join self_orders o on o.virtual_id = v.id left join tb_user u on u.user_id = o.user_id where v.goods_id=:goodsId order by o.express_time desc", + nativeQuery=true) + Page> findAll(Pageable pageable, @Param("goodsId") Long goodsId); + + //查询可用的虚拟商品 + @Query(value = "from SelfGoodsVirtual s where s.status=1 and s.goodsId=:goodsId") + List findByGoodsId(@Param("goodsId") Long goodsId); + + //查询重复的卡密 + @Query(value = "from SelfGoodsVirtual s where s.content=:content and s.goodsId=:goodsId") + List checkContent(@Param("content") String content, @Param("goodsId") Long goodsId); + + //被使用 + @Modifying + @Transactional + @Query(value = "update SelfGoodsVirtual s set s.status=3 where s.id=:id") + Integer used(@Param("id") Long id); + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsVirtualRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsVirtualRepository.java new file mode 100644 index 0000000..1f96164 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfGoodsVirtualRepository.java @@ -0,0 +1,9 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfGoodsVirtual; +import org.springframework.data.repository.Repository; + +public interface SelfGoodsVirtualRepository extends Repository { + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfMerchantApplyJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfMerchantApplyJpaRepository.java new file mode 100644 index 0000000..79d5cc8 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfMerchantApplyJpaRepository.java @@ -0,0 +1,22 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfMerchantApply; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface SelfMerchantApplyJpaRepository extends JpaRepository { + + //条件查询带分页 + Page findAll(Specification specification, Pageable pageable); + + //条件查询 + List findAll(Specification specification); + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfMerchantApplyRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfMerchantApplyRepository.java new file mode 100644 index 0000000..170b2ea --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfMerchantApplyRepository.java @@ -0,0 +1,8 @@ +package com.sqx.modules.shopping.dao; + +import com.sqx.modules.shopping.entity.SelfMerchantApply; +import org.springframework.data.repository.Repository; + +public interface SelfMerchantApplyRepository extends Repository { + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfOrdersRemindJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfOrdersRemindJpaRepository.java new file mode 100644 index 0000000..70e5100 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfOrdersRemindJpaRepository.java @@ -0,0 +1,25 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfOrderRemind; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface SelfOrdersRemindJpaRepository extends JpaRepository { + + //条件查询带分页 + Page findAll(Specification specification, Pageable pageable); + + //条件查询 + List findAll(Specification specification); + + //根据订单id查询 + SelfOrderRemind findByOrdersId(Long ordersId); + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfOrdersRemindRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfOrdersRemindRepository.java new file mode 100644 index 0000000..361ed79 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfOrdersRemindRepository.java @@ -0,0 +1,11 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfOrderRemind; +import org.springframework.data.repository.Repository; + +public interface SelfOrdersRemindRepository extends Repository { + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfUserCollectJpaRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfUserCollectJpaRepository.java new file mode 100644 index 0000000..217c032 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfUserCollectJpaRepository.java @@ -0,0 +1,26 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfUserCollect; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +@Repository +public interface SelfUserCollectJpaRepository extends JpaRepository { + + //分页查询 + Page findAll(Pageable pageable); + + //条件查询 + Page findAll(Specification specification, Pageable pageable); + + //根据商品id和用户id查询 + @Query(value = "from SelfUserCollect s where s.goodsId=:goodsId and s.userId=:userId") + SelfUserCollect findByGoodsIdAndUserId(@Param("goodsId") Long goodsId, @Param("userId") Long userId); + +} diff --git a/src/main/java/com/sqx/modules/shopping/dao/SelfUserCollectRepository.java b/src/main/java/com/sqx/modules/shopping/dao/SelfUserCollectRepository.java new file mode 100644 index 0000000..a08e6e1 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/dao/SelfUserCollectRepository.java @@ -0,0 +1,9 @@ +package com.sqx.modules.shopping.dao; + + +import com.sqx.modules.shopping.entity.SelfUserCollect; +import org.springframework.data.repository.Repository; + +public interface SelfUserCollectRepository extends Repository { + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/entity/Adverti.java b/src/main/java/com/sqx/modules/shopping/entity/Adverti.java new file mode 100644 index 0000000..8f73cd2 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/Adverti.java @@ -0,0 +1,51 @@ +package com.sqx.modules.shopping.entity; + +import javax.persistence.*; + +/** + * 自营商城广告位 + */ +@Entity +public class Adverti { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //id + @Column + private String imgUrl; //图片地址 + @Column + private String linkUrl; //跳转地址 + @Column + private String createAt; //创建时间 + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getImgUrl() { + return imgUrl; + } + + public void setImgUrl(String imgUrl) { + this.imgUrl = imgUrl; + } + + public String getLinkUrl() { + return linkUrl; + } + + public void setLinkUrl(String linkUrl) { + this.linkUrl = linkUrl; + } + + public String getCreateAt() { + return createAt; + } + + public void setCreateAt(String createAt) { + this.createAt = createAt; + } +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/Coupons.java b/src/main/java/com/sqx/modules/shopping/entity/Coupons.java new file mode 100644 index 0000000..42b071b --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/Coupons.java @@ -0,0 +1,112 @@ +package com.sqx.modules.shopping.entity; + +import javax.persistence.*; + +/** + * 自营商城优惠券 + */ +@Entity +public class Coupons { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //id + @Column + private String createAt; //创建时间 + @Column + private Integer status; //状态(0正常、1已过期) + @Column + private String title; //优惠券标题 + @Column + private String instructions; //使用说明 + @Column + private String endDay; //优惠券过期日期 + @Column + private Integer putNumber; //发放数量 + @Column + private Integer getNumber; //限领数量 + @Column + private Integer remainingNumber; //剩余数量 + @Column + private Integer couponsType; //优惠券类型(1立减) + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getCreateAt() { + return createAt; + } + + public void setCreateAt(String createAt) { + this.createAt = createAt; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getInstructions() { + return instructions; + } + + public void setInstructions(String instructions) { + this.instructions = instructions; + } + + public Integer getPutNumber() { + return putNumber; + } + + public void setPutNumber(Integer putNumber) { + this.putNumber = putNumber; + } + + public Integer getGetNumber() { + return getNumber; + } + + public void setGetNumber(Integer getNumber) { + this.getNumber = getNumber; + } + + public Integer getRemainingNumber() { + return remainingNumber; + } + + public void setRemainingNumber(Integer remainingNumber) { + this.remainingNumber = remainingNumber; + } + + public String getEndDay() { + return endDay; + } + + public void setEndDay(String endDay) { + this.endDay = endDay; + } + + public Integer getCouponsType() { + return couponsType; + } + + public void setCouponsType(Integer couponsType) { + this.couponsType = couponsType; + } +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/CouponsUser.java b/src/main/java/com/sqx/modules/shopping/entity/CouponsUser.java new file mode 100644 index 0000000..269bbe6 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/CouponsUser.java @@ -0,0 +1,91 @@ +package com.sqx.modules.shopping.entity; + +import javax.persistence.*; + +/** + * 自营商城优惠券用户 + */ +@Entity +public class CouponsUser { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //id + @Column + private String createAt; //创建时间 + @Column + private Integer status; //状态(0正常、1已过期) + @Column + private String title; //优惠券标题 + @Column + private String instructions; //使用说明 + @Column + private String endDay; //优惠券过期时间 + @Column + private Long couponsId; //优惠券id + @Column + private Long userId; //用户id + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getCreateAt() { + return createAt; + } + + public void setCreateAt(String createAt) { + this.createAt = createAt; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getInstructions() { + return instructions; + } + + public void setInstructions(String instructions) { + this.instructions = instructions; + } + + public String getEndDay() { + return endDay; + } + + public void setEndDay(String endDay) { + this.endDay = endDay; + } + + public Long getCouponsId() { + return couponsId; + } + + public void setCouponsId(Long couponsId) { + this.couponsId = couponsId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/GoodsType.java b/src/main/java/com/sqx/modules/shopping/entity/GoodsType.java new file mode 100644 index 0000000..58faa1e --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/GoodsType.java @@ -0,0 +1,29 @@ +package com.sqx.modules.shopping.entity; + +import lombok.Data; + +import javax.persistence.*; +import java.util.List; + +/** + * 自营商城商品分类 + */ +@Data +@Entity +public class GoodsType { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //id + @Column + private Long parentId; //父级id,父级为0时为一级 + @Column + private String name; //分类名称 + @Column + private String img; //图片 + @Column + private String createAt; //创建时间 + @Column + private Integer sort; //排序 + @Transient + private List children; //下级分类 +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/GoodsTypeResult.java b/src/main/java/com/sqx/modules/shopping/entity/GoodsTypeResult.java new file mode 100644 index 0000000..7d9b80e --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/GoodsTypeResult.java @@ -0,0 +1,16 @@ +package com.sqx.modules.shopping.entity; + +import lombok.Data; + +import java.util.List; + + +/** + * 自营商城商品分类数据封装 + */ +@Data +public class GoodsTypeResult { + private Long value; + private String label; + private List children; //下级分类 +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/SelfActivity.java b/src/main/java/com/sqx/modules/shopping/entity/SelfActivity.java new file mode 100644 index 0000000..b3f52de --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/SelfActivity.java @@ -0,0 +1,73 @@ +package com.sqx.modules.shopping.entity; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * 自营商城首页图标 + */ +@Entity +public class SelfActivity implements Serializable { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private long id; + @Column + private String createAt; + @Column + private String image_url; + @Column + private String url; + @Column + private String title; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + @Column + private String state; + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getCreateAt() { + return createAt; + } + + public void setCreateAt(String createAt) { + this.createAt = createAt; + } + + public String getImage_url() { + return image_url; + } + + public void setImage_url(String image_url) { + this.image_url = image_url; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/SelfBanner.java b/src/main/java/com/sqx/modules/shopping/entity/SelfBanner.java new file mode 100644 index 0000000..8daed80 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/SelfBanner.java @@ -0,0 +1,61 @@ +package com.sqx.modules.shopping.entity; + +import javax.persistence.*; + +/** + * 自营商城Banner + */ +@Entity +public class SelfBanner { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //id + @Column + private String imgUrl; //图片地址 + @Column + private String linkUrl; //跳转地址 + @Column + private String createAt; //创建时间 + @Column + private String sort; //排序 + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getImgUrl() { + return imgUrl; + } + + public void setImgUrl(String imgUrl) { + this.imgUrl = imgUrl; + } + + public String getLinkUrl() { + return linkUrl; + } + + public void setLinkUrl(String linkUrl) { + this.linkUrl = linkUrl; + } + + public String getCreateAt() { + return createAt; + } + + public void setCreateAt(String createAt) { + this.createAt = createAt; + } + + public String getSort() { + return sort; + } + + public void setSort(String sort) { + this.sort = sort; + } +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/SelfGoods.java b/src/main/java/com/sqx/modules/shopping/entity/SelfGoods.java new file mode 100644 index 0000000..3d5ac1d --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/SelfGoods.java @@ -0,0 +1,77 @@ +package com.sqx.modules.shopping.entity; + +import lombok.Data; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * 自营商城商品分类 + */ +@Data +@Entity +public class SelfGoods implements Serializable { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //id + @Column + private String merchants; //商户号 + @Column + private String typeId; //商品类型id + @Transient + private GoodsType type; //商品类型id + @Column + private String createAt; //创建时间 + @Column + private String title; //商品标题 + @Column + private String buyReason; //必买理由 + @Column + private String coverImg; //商品封面图片 + @Column + private String img; //商品图片 + @Column + private String descrition; //商品描述 + @Column + private Double originalPrice; //商品原价 + @Column + private Double price; //商品价格 + @Column + private Double memberPrice; //会员价格 + @Column + private Double commissionPrice; //商品佣金 + @Column + private Integer sales; //商品销量 + @Column + private Integer status; //商品状态(默认1正常 2下架) + @Column + private Integer isSelect; //精选好物(0默认 1精选好物) + @Column + private Integer homeGoods; //首页商品(0默认 1是首页商品) + @Column + private Integer isRecommend; //每日推荐(0默认 1推荐商品) + @Column + private Integer isExpress; //是否需要发货(1普通商品需要发货 2虚拟商品无需发货) + @Column + private Double postagePrice; //邮费 + + @Transient + private List attr; //规格 + @Transient + private List sku; //sku + + /**虚拟商品*/ + @Transient + private Integer virtualSum; //虚拟商品总数 + @Transient + private Integer virtualCount; //虚拟商品库存 + @Column + private Integer isJiFenGoods; + @Column + private Long brandId; //品牌id + @Transient + private SelfGoodsBrand brand; //品牌实体 + + +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsAttr.java b/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsAttr.java new file mode 100644 index 0000000..25fca9e --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsAttr.java @@ -0,0 +1,25 @@ +package com.sqx.modules.shopping.entity; + +import lombok.Data; + +import javax.persistence.*; +import java.util.List; + +/** + * 自营商城商品属性 + */ +@Data +@Entity +public class SelfGoodsAttr { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //id + @Column + private Long goodsId; //商品id + @Column + private Long ruleId; //规格模板id + @Column + private String attrName; //属性名称 + @Transient + private List attrValue; //规格值 +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsAttrValue.java b/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsAttrValue.java new file mode 100644 index 0000000..03bfeb1 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsAttrValue.java @@ -0,0 +1,25 @@ +package com.sqx.modules.shopping.entity; + +import lombok.Data; + +import javax.persistence.*; + +/** + * 自营商城商品属性值 + */ +@Data +@Entity +public class SelfGoodsAttrValue { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //id + @Column + private Long goodsId; //商品id + @Column + private Long attrId; //商品规格id + @Column + private String detail; //属性值组合:{尺寸: "7寸", 颜色: "红底"} + @Column + private String value; //规格属性名称 + +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsBrand.java b/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsBrand.java new file mode 100644 index 0000000..92012ca --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsBrand.java @@ -0,0 +1,22 @@ +package com.sqx.modules.shopping.entity; + +import lombok.Data; + +import javax.persistence.*; + +/** + * 自营商城商品品牌 + */ +@Data +@Entity +public class SelfGoodsBrand { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long brandId; //品牌id + @Column + private String brandName; //品牌名称 + @Column + private String names; //品牌别名 + @Column + private String createTime; //创建时间 +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsComment.java b/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsComment.java new file mode 100644 index 0000000..412ad46 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsComment.java @@ -0,0 +1,47 @@ +package com.sqx.modules.shopping.entity; + +import lombok.Data; + +import javax.persistence.*; + +/** + * 自营商城商品评论 + */ +@Data +@Entity +public class SelfGoodsComment { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long commentId; //评论id + @Column + private String content; //评论内容 + @Column + private String img; //评论图片(逗号拼接) + @Column + private String createTime; //创建时间 + /**分数*/ + @Column + private Integer score; //分数 + @Column + private Integer scoreType; //分数类型(1好评 2中评 3差评) + /**商品*/ + @Column + private Long goodsId; //商品id + @Column + private String skuId; //商品skuId + @Column + private String sku; //商品规格名称 + /**订单id*/ + @Column + private Long orderId; //订单id + /**用户*/ + @Column + private Long userId; //用户id + @Column + private String userName; //用户昵称 + @Column + private String userHeader; //用户头像 + /**回复*/ + @Column + private String reply; //回复 +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsRule.java b/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsRule.java new file mode 100644 index 0000000..c2878bc --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsRule.java @@ -0,0 +1,23 @@ +package com.sqx.modules.shopping.entity; + +import lombok.Data; + +import javax.persistence.*; +import java.util.List; + +/** + * 自营商城商品规格 + */ +@Data +@Entity +public class SelfGoodsRule { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //id + @Column + private String ruleName; //规格名称 + @Column + private String createTime; //创建时间 + @Transient + private List ruleValue; //规格值 +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsRuleValue.java b/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsRuleValue.java new file mode 100644 index 0000000..3deaf7a --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsRuleValue.java @@ -0,0 +1,22 @@ +package com.sqx.modules.shopping.entity; + +import lombok.Data; + +import javax.persistence.*; + +/** + * 自营商城商品规格属性 + */ +@Entity +@Data +public class SelfGoodsRuleValue { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //id + @Column + private Long ruleId; //规格id + @Column + private String value; //规格属性名称 + @Column + private String detail; //规格属性值 +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsSku.java b/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsSku.java new file mode 100644 index 0000000..6d7d108 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsSku.java @@ -0,0 +1,32 @@ +package com.sqx.modules.shopping.entity; + +import lombok.Data; + +import javax.persistence.*; + +/** + * 自营商城商品SKU + */ +@Data +@Entity +public class SelfGoodsSku { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //id + @Column + private Long goodsId; //商品id + @Column + private String skuImg; //sku图片 + @Column + private Double skuOriginalPrice; //sku原价 + @Column + private Double skuPrice; //sku商品售价 + @Column + private Double memberPrice; //会员价格 + @Column + private Integer stock; //库存 + @Column + private Integer sales; //销量 + @Column + private String detailJson; //sku信息,json封装 +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsVirtual.java b/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsVirtual.java new file mode 100644 index 0000000..cc28531 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/SelfGoodsVirtual.java @@ -0,0 +1,52 @@ +package com.sqx.modules.shopping.entity; + +import com.sqx.modules.app.entity.UserEntity; +import lombok.Data; + +import javax.persistence.*; + +/** + * 自营商城虚拟商品 + */ +@Data +@Entity +public class SelfGoodsVirtual { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //虚拟商品id + @Column + private String linkUrl; //访问链接 + @Column + private String content; //卡密内容 + @Column + private Integer status; //状态(1正常 2关闭 3已使用) + @Column + private String createTime; //创建时间 + /**商品信息*/ + @Column + private Long goodsId; //商品id + @Column + private String title; //商品标题 + @Column + private String coverImg; //商品封面图片 + /**订单信息*/ + @Transient + private SelfOrders orders; //订单 + @Transient + private String orderId; //订单id + @Transient + private String orderNum; //订单号 + @Transient + private String payMoney; //支付金额 + @Transient + private String payWay; //支付方式 + @Transient + private String expressTime; //发货时间 + /**用户信息*/ + @Transient + private UserEntity userInfo; //用户 + @Transient + private String nickName; //昵称 + @Transient + private String phone; //手机号 +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/SelfMerchantApply.java b/src/main/java/com/sqx/modules/shopping/entity/SelfMerchantApply.java new file mode 100644 index 0000000..6c7825a --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/SelfMerchantApply.java @@ -0,0 +1,77 @@ +package com.sqx.modules.shopping.entity; + +import lombok.Data; + +import javax.persistence.*; + +/** + * 自营商城商家入驻申请 + */ +@Data +@Entity +public class SelfMerchantApply { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //id + //店铺信息 + @Column + private String storeName; //店铺名称 + @Column + private Integer storeType; //店铺类型(1个人 2个体工商户 3企业 4其他组织) + @Column + private String serverPhone; //客服电话 + @Column + private String legal; //店铺负责人 + @Column + private String legalPhone; //负责人电话 + @Column + private String storeAddressProvince; //店铺地址省市 + @Column + private String storeAddressDetail; //店铺地址详细 + //公司信息 + @Column + private String companyName; //商户名称 + @Column + private String companyCode; //营业执照编号 + @Column + private String companyAddressProvince; //公司注册地址省 + @Column + private String companyAddressCity; //公司注册地址市 + @Column + private String companyAddressDistrict; //公司注册地址区 + @Column + private String companyAddressDetail; //公司注册地址 + @Column + private String companyTerm; //营业期限 + @Column + private String companyLicenseImg; //营业执照照片 + //经营者个人信息 + @Column + private String storeHead; //负责人姓名 + @Column + private String idCardType; //证件类型(1中国大陆居民身份证 2中国香港居民来往内地通行证 3中国澳门居民来往内地通行证 4中国台湾居民来往内地通行证 5其他国家或地区居民护照) + @Column + private String idCardNumber; //身份证号码 + @Column + private String idCardValidTimeStart; //身份证有效期起始时间 + @Column + private String idCardValidTimeEnd; //身份证有效期截止时间 + @Column + private String idCardImg1; //证件照片正面 + @Column + private String idCardImg2; //证件照片国徽面 + @Column + private String idCardImg3; //手持证件照片 + //授权信息 + @Column + private String auditTime; //生效日期 + @Column + private String auditYears; //生效年限 + //审核 + @Column + private String createTime; //申请时间 + @Column + private Integer status; //审核状态(1待处理 2通过 3拒绝) + @Column + private String refundReason; //拒绝原因 +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/SelfOrderRelation.java b/src/main/java/com/sqx/modules/shopping/entity/SelfOrderRelation.java new file mode 100644 index 0000000..1ca5206 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/SelfOrderRelation.java @@ -0,0 +1,51 @@ +package com.sqx.modules.shopping.entity; + +import lombok.Data; + +import javax.persistence.*; + +/** + * 自营商城订单分销 + */ +@Data +@Entity +public class SelfOrderRelation { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //id + @Column + private Long orderId; //订单id + /**收益人的信息*/ + @Column + private Long userId; //用户id + @Column + private String userName; //用户姓名 + @Column + private String phone; //用户手机号 + @Column + private Double commissionPrice; //订单佣金 + @Column + private String createAt; //创建时间 + @Column + private String detail; //分销明细 + @Column + private Integer status; //1未到账 2已到账 + @Column + private Double payMoney; //订单实付金额 + @Column + private Long goodsId; //商品id + @Column + private String goodsImg; //商品照片 + @Column + private String goodsTitle; //商品标题 + @Column + private Integer moneyFrom; //佣金来源(1直属 2自己 3非直属) + @Column + private Double commissionMoney; //代理佣金/团长佣金 + @Column + private Long lowerUserId; //下级用户id + @Column + private String lowerUserName; //下级用户名称 + @Column + private String finishTime; //收货时间 +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/SelfOrderRemind.java b/src/main/java/com/sqx/modules/shopping/entity/SelfOrderRemind.java new file mode 100644 index 0000000..5c5aaaf --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/SelfOrderRemind.java @@ -0,0 +1,23 @@ +package com.sqx.modules.shopping.entity; + +import lombok.Data; + +import javax.persistence.*; + +/** + * 自营商城发货提醒 + */ +@Data +@Entity +public class SelfOrderRemind { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //id + @Column + private Long ordersId; //订单id + @Column + private String createTime; //创建时间 + @Column + private Integer status; //状态(1提醒 2收到) + +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/SelfOrders.java b/src/main/java/com/sqx/modules/shopping/entity/SelfOrders.java new file mode 100644 index 0000000..37b81a2 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/SelfOrders.java @@ -0,0 +1,118 @@ +package com.sqx.modules.shopping.entity; + +import lombok.Data; + +import javax.persistence.*; +import java.math.BigDecimal; +import java.util.List; + +/** + * 自营商城订单 + */ +@Data +@Entity +public class SelfOrders { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //id + @Column + private String orderNum; //订单号 + @Column + private String payNum; //支付单号 + @Column + private String descrition; //订单备注 + @Column + private Integer number; //商品个数 + @Column + private Double payMoney; //支付金额 + @Column + private Integer status; //订单状态(1待付款 2已付款 3已发货 4已收货 5已取消 6退款中 7已退款 8拒绝退款 9拼团中 10已评价) + @Column + private Integer oldStatus; + @Column + private Integer payWay; //支付方式(1app微信 2微信公众号 3微信小程序 4app支付宝 5H5支付宝 6零钱) + @Column + private String createAt; //创建时间 + @Column + private String payTime; //支付时间 + @Column + private String finishTime; //完成时间 + /**收货信息*/ + @Column + private String consignee; //收货人 + @Column + private String mobile; //手机号 + @Column + private String provinces; //省市区 + @Column + private String detail; //详细地址 + /**用户信息*/ + @Column + private Long userId; //用户id + @Column + private String relationId; //分销id(拿到返利的人) + /**物流发货信息*/ + @Column + private Integer isExpress; //是否需要发货(1需要发货 2无需发货) + @Column + private Integer sendWay;//1快递 2自提 + @Column + private Double postagePrice; //邮费 + @Column + private String expressName; //快递名称 + @Column + private String expressNumber; //快递单号 + @Column + private String expressTime; //发货时间 + @Column + private Long virtualId; //虚拟商品id + /**退款*/ + @Column + private Integer isRefund; //是否可以退款(2不可退款) + @Column + private String refund; //退款理由 + @Column + private String refusedRefund; //拒绝退款理由 + /**商品*/ + @Column + private Long goodsId; //商品id + @Column + private Long skuId; //商品skuId + @Column + private String detailJson; //商品sku信息 + @Column + private BigDecimal commissionPrice; //订单佣金 + @Column + private Long type; //商品类型id + @Transient + private GoodsType goodsType; + @Column + private String title; //商品标题 + @Column + private String img; //商品图片 + @Column + private Double price; //商品价格 + @Column + private Double memberPrice; + /**拼团*/ + @Column + private Integer orderType; //订单类型(1普通订单 2拼团 3秒杀) + @Column + private Long groupId; //拼团商品Id + @Column + private Long groupPinkId; //加入拼团团体id + /**秒杀*/ + @Column + private Long secKillId; //秒杀商品id + /**多商户*/ + @Column + private Long merchantId; //商户id + /**优惠券*/ + @Column + private Long userCouponsId; //用户优惠券id + @Column + private Double couponMoney; //优惠券优惠金额 + /**分销*/ + @Transient + private List relationList; //订单分销列表 +} diff --git a/src/main/java/com/sqx/modules/shopping/entity/SelfUserCollect.java b/src/main/java/com/sqx/modules/shopping/entity/SelfUserCollect.java new file mode 100644 index 0000000..c439d8a --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/entity/SelfUserCollect.java @@ -0,0 +1,32 @@ +package com.sqx.modules.shopping.entity; + +import lombok.Data; + +import javax.persistence.*; + +/** + * 自营商城用户收藏 + */ +@Data +@Entity +public class SelfUserCollect { + @Id() + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; //id + @Column + private String createTime; //创建时间 + /**商品*/ + @Column + private Long goodsId; //商品id + @Column + private String title; //商品标题 + @Column + private String coverImg; //商品封面图片 + @Column + private Double price; //商品价格 + @Transient + private SelfGoods goods; //商品实体 + /**用户*/ + @Column + private Long userId; //用户id +} diff --git a/src/main/java/com/sqx/modules/shopping/service/AdvertService.java b/src/main/java/com/sqx/modules/shopping/service/AdvertService.java new file mode 100644 index 0000000..ec1d470 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/AdvertService.java @@ -0,0 +1,22 @@ +package com.sqx.modules.shopping.service; + +import com.sqx.modules.shopping.entity.Adverti; +import com.sqx.modules.shopping.utils.Result; + +public interface AdvertService { + //列表 + Result findAll(); + + //查询 + Result findOne(Long id); + + //删除 + Result delete(Long id); + + //添加 + Result saveBody(Adverti entity); + + //修改 + Result updateBody(Adverti entity); + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/CouponsService.java b/src/main/java/com/sqx/modules/shopping/service/CouponsService.java new file mode 100644 index 0000000..09a3f3e --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/CouponsService.java @@ -0,0 +1,36 @@ +package com.sqx.modules.shopping.service; + +import com.sqx.modules.shopping.entity.Coupons; +import com.sqx.modules.shopping.utils.Result; + +public interface CouponsService { + //列表 + Result findAll(Integer page, Integer size); + + //查询 + Result findOne(Long id); + + //删除 + Result delete(Long id); + + //添加 + Result saveBody(Coupons entity); + + //修改 + Result updateBody(Coupons entity); + + /** + * 用户领取优惠券 + * @param userId 用户id + * @return + */ + Result userGetCoupons(Long userId, Long couponsId); + + /** + * 用户优惠券列表 + * @param userId id + * @return + */ + Result userCoupons(Long userId); + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/CouponsUserService.java b/src/main/java/com/sqx/modules/shopping/service/CouponsUserService.java new file mode 100644 index 0000000..20589dc --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/CouponsUserService.java @@ -0,0 +1,22 @@ +package com.sqx.modules.shopping.service; + +import com.sqx.modules.shopping.entity.CouponsUser; +import com.sqx.modules.shopping.utils.Result; + +public interface CouponsUserService { + //列表 + Result findAll(Integer page, Integer size); + + //查询 + Result findOne(Long id); + + //删除 + Result delete(Long id); + + //添加 + Result saveBody(CouponsUser entity); + + //修改 + Result updateBody(CouponsUser entity); + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/GoodsService.java b/src/main/java/com/sqx/modules/shopping/service/GoodsService.java new file mode 100644 index 0000000..9ca0b32 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/GoodsService.java @@ -0,0 +1,80 @@ +package com.sqx.modules.shopping.service; + +import com.sqx.modules.shopping.entity.SelfGoods; +import com.sqx.modules.shopping.entity.SelfGoodsAttr; +import com.sqx.modules.shopping.utils.Result; + +public interface GoodsService { + //后台管理商品列表 + Result findAll(Integer page, Integer size, String title, String type, Integer status, Integer isJiFenGoods); + + //虚拟商品列表 + Result goodsVirtualList(Integer page, Integer size, String title, String type, Integer status, Integer isExpress, Integer isJiFenGoods); + + //用户端商品列表 + Result findAllByUser(Integer page, Integer size, String type,String brandId ,String title, String sort, Integer isJiFenGoods); + + //查询 + Result findOne(Long id); + + SelfGoods findById(Long goodsId); + + //删除 + Result delete(Long id); + + Result searchBrandList(String title); + + //添加 + Result saveBody(SelfGoods entity); + + //修改 + Result updateBody(SelfGoods entity); + + //精选商品 + Result selectGoods(Integer page, Integer size, String sort); + + //热卖榜单 + Result selling(Integer page, Integer size, String sort); + + //每日上新 + Result news(Integer page, Integer size, String sort); + + //每日推荐 + Result recommend(Integer page, Integer size, String sort); + + //首页商品 + Result homeGoods(Integer page, Integer size); + + //添加精选好物 + Result addSelectGoods(Long id); + + //删除精选好物 + Result deleteSelectGoods(String ids); + + //后台管理添加每日推荐 + Result addRecommend(Long id); + + //后台管理删除每日推荐 + Result deleteRecommend(String ids); + + //商品销量+1 + void salesAddOne(Long id); + + //生成属性 + Result isFormatAttr(SelfGoodsAttr attr, String coverImg, String originalPrice, String price, String memberPrice); + + //单规格生成属性 + Result onlyFormatAttr(String coverImg, String originalPrice, String price, String memberPrice); + + //回显属性 + Result formatAttr(Long goodsId); + + //回显属性值 + Result findAttrValue(Long goodsId); + + //商品上下架 + Result updateStatus(Long goodsId); + + + Result selectListByType(String title, String type, Integer status, Integer isJiFenGoods); +} diff --git a/src/main/java/com/sqx/modules/shopping/service/GoodsTypeService.java b/src/main/java/com/sqx/modules/shopping/service/GoodsTypeService.java new file mode 100644 index 0000000..059ce30 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/GoodsTypeService.java @@ -0,0 +1,28 @@ +package com.sqx.modules.shopping.service; + +import com.sqx.modules.shopping.entity.GoodsType; +import com.sqx.modules.shopping.utils.Result; + +public interface GoodsTypeService { + //列表 + Result findAll(); + + //数据封装 + Result findAllResult(); + + //一级目录数据封装 + Result findAllResult1(); + + //查询 + Result findOne(Long id); + + //删除 + Result delete(Long id); + + //添加 + Result saveBody(GoodsType entity); + + //修改 + Result updateBody(GoodsType entity); + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/OrdersRelationService.java b/src/main/java/com/sqx/modules/shopping/service/OrdersRelationService.java new file mode 100644 index 0000000..fcb61a1 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/OrdersRelationService.java @@ -0,0 +1,43 @@ +package com.sqx.modules.shopping.service; + +import com.sqx.modules.shopping.entity.SelfOrderRelation; +import com.sqx.modules.shopping.utils.Result; + +import java.util.List; + +public interface OrdersRelationService { + //列表 + Result findAll(Integer page, Integer size, Long userId, String phone, Integer status, Integer moneyFrom); + + //查询 + Result findOne(Long id); + + //删除 + Result delete(Long id); + + //添加 + Result saveBody(SelfOrderRelation entity); + + //修改 + Result updateBody(SelfOrderRelation entity); + + //根据订单id查询分销记录 + List findByOrdersId(Long OrdersId); + + //查询所有未结账的记录 + List findAllByStatus(); + + //执行零钱入账 + void addMoney(SelfOrderRelation entity); + + //我的佣金统计 + Result statistaical(Long userId); + + //团队佣金统计 + Result tuanStatistaical(Long userId); + + //团队总收益 + Result tuanSum(Long userId); + + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/OrdersService.java b/src/main/java/com/sqx/modules/shopping/service/OrdersService.java new file mode 100644 index 0000000..0989a09 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/OrdersService.java @@ -0,0 +1,88 @@ +package com.sqx.modules.shopping.service; + +import com.sqx.modules.shopping.entity.SelfGoodsVirtual; +import com.sqx.modules.shopping.entity.SelfOrders; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.excel.ExcelData; + +import java.util.List; + +public interface OrdersService { + //列表 + Result findAll(Integer page, Integer size, String orderNum, String status, String title,String mobile, String startTime, String endTime,String sendWay); + + ExcelData listExcel(String orderNum, String status, String title, String mobile, String startTime, String endTime,String sendWay); + + //我的订单 + Result findMyList(Integer page, Integer size, String userId, String status); + + //查询 + Result findOne(Long id); + + //删除 + Result delete(Long id); + + //添加 + Result saveBody(SelfOrders entity); + + //修改 + Result updateBody(SelfOrders entity); + + //收入 + Result income(String data, int way); + + //订单数统计 + Result statistical(String data); + + //取消订单 + Result orderCancel(Long id); + + //后台管理去发货 + Result express(Long id, String expressName, String expressNumber); + //后台管理发货虚拟商品 + Result expressVirtual(Long id); + + //确认收货 + Result orderConfirm(Long id); + + Result changePay(String id); + + void fenXiao(SelfOrders o); + + //检测完成支付 + Result checkPay(Long id); + + //根据订单查询订单 + SelfOrders findByOrderNum(String orderNum); + + //用户申请退款 + Result refund(Long id, String refund); + + //退款到余额 + Result refundMoney(Long id); + + //后台管理拒绝退款 + Result refusedRefund(Long ordersId, String refusedRefund); + + //后台管理待处理订单 + Result pendingOrder(); + + //提醒发货 + Result remind(Long ordersId); + + //后台管理被提醒发货 + Result remindOrder(); + + //处理虚拟商品 + SelfGoodsVirtual sendExpress(SelfOrders orders); + + //根据支付单号查询多个订单 + List findByPayNum(String payNum); + + //用户端订单统计 + Result count(Long userId); + + //查快递 + Result findExpress(String expressNumber); + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/SelfAliPayService.java b/src/main/java/com/sqx/modules/shopping/service/SelfAliPayService.java new file mode 100644 index 0000000..259e38e --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/SelfAliPayService.java @@ -0,0 +1,7 @@ +package com.sqx.modules.shopping.service; + +public interface SelfAliPayService { + + //退款 + boolean refund(Long ordersId); +} diff --git a/src/main/java/com/sqx/modules/shopping/service/SelfGoodsAttrService.java b/src/main/java/com/sqx/modules/shopping/service/SelfGoodsAttrService.java new file mode 100644 index 0000000..26c2075 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/SelfGoodsAttrService.java @@ -0,0 +1,21 @@ +package com.sqx.modules.shopping.service; + +import com.sqx.modules.shopping.entity.SelfGoodsAttr; +import com.sqx.modules.shopping.utils.Result; + +import java.util.List; + +public interface SelfGoodsAttrService { + //添加 + Result saveBody(SelfGoodsAttr entity); + + //修改 + Result updateBody(SelfGoodsAttr entity); + + //根据商品id查询 + List findByGoodsId(Long goodsId); + + void deleteAttrAndValue(Long goodsId); + + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/SelfGoodsBrandService.java b/src/main/java/com/sqx/modules/shopping/service/SelfGoodsBrandService.java new file mode 100644 index 0000000..eff3f42 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/SelfGoodsBrandService.java @@ -0,0 +1,26 @@ +package com.sqx.modules.shopping.service; + + +import com.sqx.modules.shopping.entity.SelfGoodsBrand; +import com.sqx.modules.shopping.utils.Result; + +public interface SelfGoodsBrandService { + //后台管理商品列表 + Result findAll(Integer page, Integer size); + + //查询 + Result findOne(Long id); + + //删除 + Result delete(Long id); + + //添加 + Result saveBody(SelfGoodsBrand entity); + + //修改 + Result updateBody(SelfGoodsBrand entity); + + //所有商品规格模板 + Result result(); + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/SelfGoodsCommentService.java b/src/main/java/com/sqx/modules/shopping/service/SelfGoodsCommentService.java new file mode 100644 index 0000000..7fe313f --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/SelfGoodsCommentService.java @@ -0,0 +1,35 @@ +package com.sqx.modules.shopping.service; + + +import com.sqx.modules.shopping.entity.SelfGoodsComment; +import com.sqx.modules.shopping.utils.Result; + +public interface SelfGoodsCommentService { + //列表 + Result findAll(Integer page, Integer size, Long goodsId, Integer scoreType); + + //统计 + Result count(Long goodsId); + + //用户端我的评论 + Result userList(Integer page, Integer size, Long userId); + + //查询订单评价 + Result findByOrderId(Long orderId); + + //查询 + Result findOne(Long id); + + //删除 + Result delete(Long id); + + //添加 + Result saveBody(SelfGoodsComment entity); + + //修改 + Result updateBody(SelfGoodsComment entity); + + //回复评论 + Result reply(Long commentId, String reply); + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/SelfGoodsRuleService.java b/src/main/java/com/sqx/modules/shopping/service/SelfGoodsRuleService.java new file mode 100644 index 0000000..61628fb --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/SelfGoodsRuleService.java @@ -0,0 +1,25 @@ +package com.sqx.modules.shopping.service; + +import com.sqx.modules.shopping.entity.SelfGoodsRule; +import com.sqx.modules.shopping.utils.Result; + +public interface SelfGoodsRuleService { + //后台管理商品列表 + Result findAll(Integer page, Integer size); + + //查询 + Result findOne(Long id); + + //删除 + Result delete(Long id); + + //添加 + Result saveBody(SelfGoodsRule entity); + + //修改 + Result updateBody(SelfGoodsRule entity); + + //所有商品规格模板 + Result info(); + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/SelfGoodsSkuService.java b/src/main/java/com/sqx/modules/shopping/service/SelfGoodsSkuService.java new file mode 100644 index 0000000..0e37b65 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/SelfGoodsSkuService.java @@ -0,0 +1,17 @@ +package com.sqx.modules.shopping.service; + +public interface SelfGoodsSkuService { + + //判断库存是否大于购买数量 + boolean checkStock(Long skuId, Integer paNumber); + + //sku库存减少 + void lessStock(Long skuId, Integer number); + + //sku库存+1 + void addStock(Long skuId, Integer number); + + //sku销量添加 + void addSales(Long skuId, Integer number); + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/SelfGoodsVirtualService.java b/src/main/java/com/sqx/modules/shopping/service/SelfGoodsVirtualService.java new file mode 100644 index 0000000..3199bff --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/SelfGoodsVirtualService.java @@ -0,0 +1,29 @@ +package com.sqx.modules.shopping.service; + +import com.sqx.modules.shopping.entity.SelfGoodsVirtual; +import com.sqx.modules.shopping.utils.Result; + +public interface SelfGoodsVirtualService { + //列表 + Result findAll(Integer page, Integer size, Long goodsId, String content); + + //查询 + Result findOne(Long id); + + //删除 + Result delete(Long id); + + //添加 + Result saveBody(SelfGoodsVirtual entity); + + //修改 + Result updateBody(SelfGoodsVirtual entity); + + /** + * 发送虚拟商品 + * @param goodsId + * @return + */ + SelfGoodsVirtual sendGoods(Long goodsId); + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/SelfMerchantApplyService.java b/src/main/java/com/sqx/modules/shopping/service/SelfMerchantApplyService.java new file mode 100644 index 0000000..d36ab23 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/SelfMerchantApplyService.java @@ -0,0 +1,45 @@ +package com.sqx.modules.shopping.service; + +import com.sqx.modules.shopping.entity.SelfMerchantApply; +import com.sqx.modules.shopping.utils.Result; + +public interface SelfMerchantApplyService { + /** + * 商家入驻申请列表 + * @param page 页数 + * @param size 条数 + * @param companyName 商家名称 + * @param legalPhone 注册手机号 + * @param storeType 店铺类型 + * @param status 审核状态(1待处理 2通过 3拒绝) + * @param createTimeStart 申请时间开始区间 + * @param createTimeEnd 申请时间结束区间 + * @return + */ + Result findAll(Integer page, Integer size, String companyName,String legalPhone, Integer storeType, Integer status, String createTimeStart, String createTimeEnd); + + //查询 + Result findOne(Long id); + + //删除 + Result delete(Long id); + + //添加 + Result saveBody(SelfMerchantApply entity); + + //修改 + Result updateBody(SelfMerchantApply entity); + + /** + * 处理审核 + * @param id + * @param status 审核状态(1待处理 2通过 3拒绝) + * @param auditTime 生效日期 + * @param auditYears 生效年限 + * @param refundReason 拒绝原因 + * @return + */ + Result deal(Long id, Integer status, String auditTime, String auditYears, String refundReason); + + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/SelfUserCollectService.java b/src/main/java/com/sqx/modules/shopping/service/SelfUserCollectService.java new file mode 100644 index 0000000..c87de66 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/SelfUserCollectService.java @@ -0,0 +1,26 @@ +package com.sqx.modules.shopping.service; + + +import com.sqx.modules.shopping.entity.SelfUserCollect; +import com.sqx.modules.shopping.utils.Result; + +public interface SelfUserCollectService { + //列表 + Result findAll(Integer page, Integer size, Long userId); + + //查询 + Result findOne(Long id); + + //删除 + Result delete(Long id); + + //添加 + Result saveBody(SelfUserCollect entity); + + //修改 + Result updateBody(SelfUserCollect entity); + + //判断是否收藏 + Result check(Long goodsId, Long userId); + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/SelfWXService.java b/src/main/java/com/sqx/modules/shopping/service/SelfWXService.java new file mode 100644 index 0000000..9d8ba3c --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/SelfWXService.java @@ -0,0 +1,27 @@ +package com.sqx.modules.shopping.service; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +public interface SelfWXService { + + /** + * 微信支付 + * @param ordersId + * @param type + * @return + * @throws Exception + */ + Map doUnifiedOrder(Long ordersId, Integer type, HttpServletRequest request) throws Exception; + + /** + * 支付回调 + * @param resXml + * @return + */ + String payBack(String resXml,Integer type); + + //退款 + boolean refund(Long ordersId); + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/service/SlefBannerService.java b/src/main/java/com/sqx/modules/shopping/service/SlefBannerService.java new file mode 100644 index 0000000..6ad3fb6 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/SlefBannerService.java @@ -0,0 +1,22 @@ +package com.sqx.modules.shopping.service; + +import com.sqx.modules.shopping.entity.SelfBanner; +import com.sqx.modules.shopping.utils.Result; + +public interface SlefBannerService { + //列表 + Result findAll(); + + //查询 + Result findOne(Long id); + + //删除 + Result delete(Long id); + + //添加 + Result saveBody(SelfBanner entity); + + //修改 + Result updateBody(SelfBanner entity); + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/AdvertServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/AdvertServiceImpl.java new file mode 100644 index 0000000..1a2c4f5 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/AdvertServiceImpl.java @@ -0,0 +1,48 @@ +package com.sqx.modules.shopping.service.impl; + +import com.sqx.modules.shopping.dao.AdvertJpaRepository; +import com.sqx.modules.shopping.entity.Adverti; +import com.sqx.modules.shopping.service.AdvertService; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Date; + +@Service +public class AdvertServiceImpl implements AdvertService { + @Autowired + private AdvertJpaRepository jpaRepository; + + @Override + public Result findAll() { + return ResultUtil.success(jpaRepository.findAll()); + } + + @Override + public Result saveBody(Adverti entity) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + entity.setCreateAt(sdf.format(now)); + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result updateBody(Adverti entity) { + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result findOne(Long id) { + return ResultUtil.success(jpaRepository.findById(id).orElse(null)); + } + + @Override + public Result delete(Long id) { + jpaRepository.deleteById(id); + return ResultUtil.success(); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/CouponsServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/CouponsServiceImpl.java new file mode 100644 index 0000000..1d816dc --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/CouponsServiceImpl.java @@ -0,0 +1,158 @@ +package com.sqx.modules.shopping.service.impl; + + +import com.sqx.modules.shopping.dao.CouponsJpaRepository; +import com.sqx.modules.shopping.dao.CouponsUserJpaRepository; +import com.sqx.modules.shopping.entity.Coupons; +import com.sqx.modules.shopping.entity.CouponsUser; +import com.sqx.modules.shopping.service.CouponsService; +import com.sqx.modules.shopping.service.CouponsUserService; +import com.sqx.modules.shopping.utils.ExceptionEnum; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +@Service +public class CouponsServiceImpl implements CouponsService { + @Autowired + private CouponsJpaRepository jpaRepository; + @Autowired + private CouponsUserService couponsUserService; + @Autowired + private CouponsUserJpaRepository couponsUserJpaRepository; + + @Override + public Result findAll(Integer page, Integer size) { + Pageable pageable = PageRequest.of(page, size); + Page all = jpaRepository.findAll(pageable); + List list = all.getContent(); + //判断是否有库存且未过期 + for (int i = 0; i < list.size(); i++) { + Coupons c = list.get(i); + Integer remainingNumber = c.getRemainingNumber(); //优惠券库存 + String endDay = c.getEndDay(); //过期时间 + if (remainingNumber == 0 || !isTimeOut(endDay)){ + c.setStatus(1); + Coupons newCoupons = jpaRepository.save(c); + list.set(i, newCoupons); + } + } + return ResultUtil.success(all); + } + + @Override + public Result saveBody(Coupons entity) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + entity.setCreateAt(sdf.format(now)); + entity.setStatus(0); + entity.setCouponsType(1); + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result updateBody(Coupons entity) { + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result findOne(Long id) { + return ResultUtil.success(jpaRepository.findById(id).orElse(null)); + } + + @Override + public Result delete(Long id) { + jpaRepository.deleteById(id); + return ResultUtil.success(); + } + + /** + * 用户点击领取优惠券 + * @param userId 用户id + * @return + */ + @Override + public Result userGetCoupons(Long userId, Long couponsId) { + Coupons c = jpaRepository.findById(couponsId).orElse(null); + Integer remainingNumber = c.getRemainingNumber(); //优惠券库存 + String endDay = c.getEndDay(); //过期时间 + if (remainingNumber == 0){ + return ResultUtil.error(ExceptionEnum.COUPONS_ZERO); + } + if (!isTimeOut(endDay)){ + return ResultUtil.error(ExceptionEnum.COUPONS_TIME_OUT); + } + //获取用户对应当前优惠券的领取次数 + int userCouponsCount = couponsUserJpaRepository.findByCouponsId(couponsId, userId); + //优惠券限领次数 + int count = c.getGetNumber().intValue(); + if (userCouponsCount >= count){ + return ResultUtil.error(ExceptionEnum.COUPONS_GET_OUT); + } + //保存用户领券信息 + CouponsUser s = new CouponsUser(); + s.setCouponsId(c.getId()); + s.setTitle(c.getTitle()); + s.setInstructions(c.getInstructions()); + s.setEndDay(c.getEndDay()); + s.setUserId(userId); + couponsUserService.saveBody(s); + //优惠券库存减1 + int number = c.getRemainingNumber().intValue()-1; + c.setRemainingNumber(number); + this.updateBody(c); + return ResultUtil.success(); + } + + + /** + * 用户优惠券列表 + * @param userId 用户id + * @return + */ + @Override + public Result userCoupons(Long userId) { + List list = couponsUserJpaRepository.findAll(); + //判断是否过期 + for (int i = 0; i < list.size(); i++) { + CouponsUser c = list.get(i); + String endDay = c.getEndDay(); //过期时间 + if (!isTimeOut(endDay)){ + c.setStatus(1); + } + } + return ResultUtil.success(list); + } + + + /** + * 判断优惠券是否过期 + * @param endDay 过期时间 + * @return 是否超时 true没有过期 false过期 + */ + public static boolean isTimeOut(String endDay){ + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try{ + Date finish = sf.parse(endDay); + Calendar c = Calendar.getInstance(); + c.setTime(finish); + finish = c.getTime(); + System.out.println(sf.format(finish)); + //过期时间和现在时间比 + return finish.after(new Date()); + }catch (Exception e){ + e.printStackTrace(); + } + return false; + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/CouponsUserServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/CouponsUserServiceImpl.java new file mode 100644 index 0000000..44a2234 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/CouponsUserServiceImpl.java @@ -0,0 +1,52 @@ +package com.sqx.modules.shopping.service.impl; + +import com.sqx.modules.shopping.dao.CouponsUserJpaRepository; +import com.sqx.modules.shopping.entity.CouponsUser; +import com.sqx.modules.shopping.service.CouponsUserService; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Date; + +@Service +public class CouponsUserServiceImpl implements CouponsUserService { + @Autowired + private CouponsUserJpaRepository jpaRepository; + + @Override + public Result findAll(Integer page, Integer size) { + Pageable pageable = PageRequest.of(page, size); + return ResultUtil.success(jpaRepository.findAll(pageable)); + } + + @Override + public Result saveBody(CouponsUser entity) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + entity.setCreateAt(sdf.format(now)); + entity.setStatus(0); + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result updateBody(CouponsUser entity) { + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result findOne(Long id) { + return ResultUtil.success(jpaRepository.findById(id).orElse(null)); + } + + @Override + public Result delete(Long id) { + jpaRepository.deleteById(id); + return ResultUtil.success(); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/GoodsTypeServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/GoodsTypeServiceImpl.java new file mode 100644 index 0000000..516efd0 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/GoodsTypeServiceImpl.java @@ -0,0 +1,117 @@ +package com.sqx.modules.shopping.service.impl; + +import com.sqx.modules.shopping.dao.GoodsTypeJpaRepository; +import com.sqx.modules.shopping.dao.GoodsTypeRepository; +import com.sqx.modules.shopping.entity.GoodsType; +import com.sqx.modules.shopping.entity.GoodsTypeResult; +import com.sqx.modules.shopping.service.GoodsTypeService; +import com.sqx.modules.shopping.utils.DateUtil; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class GoodsTypeServiceImpl implements GoodsTypeService { + @Autowired + private GoodsTypeJpaRepository jpaRepository; + @Autowired + private GoodsTypeRepository repository; + + @Override + public Result findAll() { + List type1 = repository.findAllStatus0(); + List type2 = repository.findAllStatus(); + List resultList = new ArrayList<>(); + for (GoodsType g : type1) { + GoodsType result = new GoodsType(); + result.setId(g.getId()); + result.setParentId(g.getParentId()); + result.setName(g.getName()); + result.setImg(g.getImg()); + result.setSort(g.getSort()); + result.setCreateAt(g.getCreateAt()); + List children = new ArrayList<>(); + for (GoodsType c : type2) { + GoodsType r1 = new GoodsType(); + if (g.getId().equals(c.getParentId())){ + r1.setId(c.getId()); + r1.setParentId(c.getParentId()); + r1.setName(c.getName()); + r1.setImg(c.getImg()); + r1.setSort(c.getSort()); + r1.setCreateAt(c.getCreateAt()); + children.add(r1); + } + result.setChildren(children); + } + resultList.add(result); + } + return ResultUtil.success(resultList); + } + + @Override + public Result findAllResult() { + List type1 = repository.findAllStatus0(); + List type2 = repository.findAllStatus(); + List resultList = new ArrayList<>(); + for (GoodsType g : type1) { + GoodsTypeResult result = new GoodsTypeResult(); + result.setValue(g.getId()); + result.setLabel(g.getName()); + List children = new ArrayList<>(); + for (GoodsType c : type2) { + GoodsTypeResult r1 = new GoodsTypeResult(); + if (g.getId().equals(c.getParentId())){ + r1.setValue(c.getId()); + r1.setLabel(c.getName()); + children.add(r1); + } + result.setChildren(children); + } + resultList.add(result); + } + return ResultUtil.success(resultList); + } + + @Override + public Result findAllResult1() { + List type1 = repository.findAllStatus0(); + List resultList = new ArrayList<>(); + for (GoodsType g : type1) { + GoodsTypeResult result = new GoodsTypeResult(); + if (g.getParentId().toString().equals("0")){ + result.setValue(g.getId()); + result.setLabel(g.getName()); + } + resultList.add(result); + } + return ResultUtil.success(resultList); + } + + @Override + public Result saveBody(GoodsType entity) { + entity.setCreateAt(DateUtil.createTime()); + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result updateBody(GoodsType entity) { + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result findOne(Long id) { + return ResultUtil.success(jpaRepository.findById(id).orElse(null)); + } + + @Override + public Result delete(Long id) { + jpaRepository.deleteById(id); + return ResultUtil.success(); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/OrdersRelationServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/OrdersRelationServiceImpl.java new file mode 100644 index 0000000..dd01127 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/OrdersRelationServiceImpl.java @@ -0,0 +1,208 @@ +package com.sqx.modules.shopping.service.impl; + +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.entity.UserMoneyDetails; +import com.sqx.modules.app.service.UserMoneyDetailsService; +import com.sqx.modules.app.service.UserMoneyService; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.shopping.dao.OrdersJpaRepository; +import com.sqx.modules.shopping.dao.OrdersRelationJpaRepository; +import com.sqx.modules.shopping.dao.OrdersRelationRepository; +import com.sqx.modules.shopping.entity.SelfOrderRelation; +import com.sqx.modules.shopping.entity.SelfOrders; +import com.sqx.modules.shopping.service.OrdersRelationService; +import com.sqx.modules.shopping.utils.AmountCalUtil; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.*; + +@Service +public class OrdersRelationServiceImpl implements OrdersRelationService { + @Autowired + private OrdersRelationJpaRepository jpaRepository; + @Autowired + private OrdersRelationRepository repository; + @Autowired + private UserService userService; + @Autowired + private UserMoneyDetailsService userMoneyDetailsService; + @Autowired + private OrdersJpaRepository ordersJpaRepository; + @Autowired + private UserMoneyService userMoneyService; + + @Override + public Result findAll(Integer page, Integer size, Long userId, String phone, Integer status, Integer moneyFrom) { + //根据时间排序 + Pageable pageable = PageRequest.of(page, size, Sort.by(new Sort.Order(Sort.Direction.DESC, "createAt"))); + // 构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + if (userId != null) { + predicateList.add(criteriaBuilder.equal(root.get("userId"), userId)); + } + if (StringUtils.isNotEmpty(phone)) { + predicateList.add(criteriaBuilder.equal(root.get("phone"), phone)); + } + if (status != 0) { + predicateList.add(criteriaBuilder.equal(root.get("status"), status)); + } + if (moneyFrom != 0) { + predicateList.add(criteriaBuilder.equal(root.get("moneyFrom"), moneyFrom)); + } + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + return ResultUtil.success(jpaRepository.findAll(queryCondition, pageable)); + } + + /** + * 保存订单 + * @param entity + * @return + */ + @Override + public Result saveBody(SelfOrderRelation entity) { + entity.setCreateAt(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); //创建时间 + SelfOrderRelation save = jpaRepository.save(entity); + //虚拟商品分销立即到账 + SelfOrders o = ordersJpaRepository.findById(save.getOrderId()).orElse(null); + if (o.getIsExpress() == 2){ + this.addMoney(save); + } + return ResultUtil.success(save); + } + + @Override + public Result updateBody(SelfOrderRelation entity) { + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result findOne(Long id) { + return ResultUtil.success(jpaRepository.findById(id).orElse(null)); + } + + @Override + public Result delete(Long id) { + jpaRepository.deleteById(id); + return ResultUtil.success(); + } + + @Override + public List findByOrdersId(Long ordersId) { + // 构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + if (ordersId != null) { + predicateList.add(criteriaBuilder.equal(root.get("orderId"), ordersId)); + } + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + return jpaRepository.findAll(queryCondition); + } + + @Override + public List findAllByStatus() { + return repository.findAllByStatus(); + } + + /** + * 佣金零钱到账 + * @param s + */ + @Override + public void addMoney(SelfOrderRelation s) { + //1.用户零钱增加 + userMoneyService.updateMoney(1,s.getUserId(),s.getCommissionPrice()); + //2.用户零钱明细增加 + UserMoneyDetails userMoneyDetails=new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(s.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setMoney(BigDecimal.valueOf(s.getCommissionPrice())); + userMoneyDetails.setUserId(s.getUserId()); + if(s.getMoneyFrom().equals(1)){ + userMoneyDetails.setTitle("【直属佣金】商品分佣"); + }else if(s.getMoneyFrom().equals(2)){ + userMoneyDetails.setTitle("【商城佣金】商品分佣"); + }else{ + userMoneyDetails.setTitle("【非直属佣金】商品分佣"); + } + userMoneyDetails.setContent("佣金到账金额:"+s.getCommissionPrice()); + userMoneyDetails.setType(1); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date())); + userMoneyDetailsService.save(userMoneyDetails); + //3.修改分销记录为已到账 + s.setStatus(2); //已到账 + this.updateBody(s); + //4.订单设置未不可退款状态 + Long orderId = s.getOrderId(); + SelfOrders order = ordersJpaRepository.getOne(orderId); + order.setIsRefund(2); //不可退款 + ordersJpaRepository.save(order); + } + + /** + * 我的佣金统计:已到账佣金、未到账佣金、本月佣金 + * @param userId + * @return + */ + @Override + public Result statistaical(Long userId) { + String month = new SimpleDateFormat("yyyy-MM").format(new Date()); + String sum1 = repository.sumByUserIdStatus1(userId, month); + String sum2 = repository.sumByUserIdStatus2(userId, month); + Map map = new HashMap<>(); + map.put("sum1", AmountCalUtil.moneySum(sum1)); //本月未到账 + map.put("sum2", AmountCalUtil.moneySum(sum2)); //本月已到账 + return ResultUtil.success(map); + } + + /** + * 团队佣金统计 + * @param userId + * @return + */ + @Override + public Result tuanStatistaical(Long userId) { + String month = new SimpleDateFormat("yyyy-MM").format(new Date()); + String sum1 = repository.sumByUserIdStatus1Tuan(userId, month); + String sum2 = repository.sumByUserIdStatus2Tuan(userId, month); + Map map = new HashMap<>(); + map.put("sum1", AmountCalUtil.moneySum(sum1)); //本月未到账 + map.put("sum2", AmountCalUtil.moneySum(sum2)); //本月已到账 + return ResultUtil.success(map); + } + + @Override + public Result tuanSum(Long userId) { + return ResultUtil.success(AmountCalUtil.moneySum(repository.tuanSum(userId))); + } + + + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/SelUserCollectServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/SelUserCollectServiceImpl.java new file mode 100644 index 0000000..ba16e4a --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/SelUserCollectServiceImpl.java @@ -0,0 +1,93 @@ +package com.sqx.modules.shopping.service.impl; + +import com.sqx.modules.shopping.dao.GoodsJpaRepository; +import com.sqx.modules.shopping.dao.SelfUserCollectJpaRepository; +import com.sqx.modules.shopping.entity.SelfGoods; +import com.sqx.modules.shopping.entity.SelfUserCollect; +import com.sqx.modules.shopping.service.SelfUserCollectService; +import com.sqx.modules.shopping.utils.DateUtil; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import java.util.ArrayList; +import java.util.List; + +@Service +public class SelUserCollectServiceImpl implements SelfUserCollectService { + @Autowired + private SelfUserCollectJpaRepository jpaRepository; + @Autowired + private GoodsJpaRepository goodsJpaRepository; + + + @Override + public Result findAll(Integer page, Integer size, Long userId) { + Pageable pageable = PageRequest.of(page, size); + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + if (userId != null) { + predicateList.add(criteriaBuilder.equal(root.get("userId"), userId)); + } + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + Page all = jpaRepository.findAll(queryCondition, pageable); + List goodsList = goodsJpaRepository.findAll(); + for (SelfUserCollect s : all.getContent()) { + for (SelfGoods goods : goodsList) { + if (s.getGoodsId().equals(goods.getId())){ + s.setGoods(goods); + break; + } + } + } + return ResultUtil.success(all); + } + + @Override + public Result saveBody(SelfUserCollect entity) { + entity.setCreateTime(DateUtil.createTime()); //创建时间 + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result updateBody(SelfUserCollect entity) { + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result findOne(Long id) { + return ResultUtil.success(jpaRepository.findById(id).orElse(null)); + } + + @Override + public Result delete(Long id) { + jpaRepository.deleteById(id); + return ResultUtil.success(); + } + + @Override + public Result check(Long goodsId, Long userId) { + SelfUserCollect s = jpaRepository.findByGoodsIdAndUserId(goodsId, userId); + if (s != null && s.getId() != null){ + Result result = new Result(); + result.setData(false); + result.setMsg(s.getId().toString()); + result.setStatus(0); + return result; + } + return ResultUtil.success(true); + } +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/SelfAliPayServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/SelfAliPayServiceImpl.java new file mode 100644 index 0000000..eca2d43 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/SelfAliPayServiceImpl.java @@ -0,0 +1,45 @@ +package com.sqx.modules.shopping.service.impl; + +import com.alipay.api.AlipayApiException; +import com.alipay.api.AlipayClient; +import com.alipay.api.DefaultAlipayClient; +import com.alipay.api.domain.AlipayTradeRefundModel; +import com.alipay.api.request.AlipayTradeRefundRequest; +import com.alipay.api.response.AlipayTradeRefundResponse; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.pay.config.AliPayConstants; +import com.sqx.modules.shopping.dao.OrdersJpaRepository; +import com.sqx.modules.shopping.entity.SelfOrders; +import com.sqx.modules.shopping.service.SelfAliPayService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class SelfAliPayServiceImpl implements SelfAliPayService { + @Autowired + private OrdersJpaRepository ordersJpaRepository; + @Autowired + private CommonInfoService commonRepository; + + @Override + public boolean refund(Long ordersId) { + try { + SelfOrders orders = ordersJpaRepository.getOne(ordersId); + AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", commonRepository.findOne(63).getValue(), commonRepository.findOne(65).getValue(), "json", AliPayConstants.CHARSET, commonRepository.findOne(64).getValue(), "RSA2"); + AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); + AlipayTradeRefundModel model = new AlipayTradeRefundModel(); + model.setOutTradeNo(orders.getOrderNum()); //订单号 + model.setRefundAmount(orders.getPayMoney()+""); //退款金额 + request.setBizModel(model); + AlipayTradeRefundResponse response = alipayClient.execute(request); + if(response.isSuccess()){ + return true; + } else { + return false; + } + }catch (AlipayApiException e) { + e.printStackTrace(); + } + return false; + } +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/SelfBannerServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/SelfBannerServiceImpl.java new file mode 100644 index 0000000..92c2483 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/SelfBannerServiceImpl.java @@ -0,0 +1,48 @@ +package com.sqx.modules.shopping.service.impl; + +import com.sqx.modules.shopping.dao.SelfBannerJpaRepository; +import com.sqx.modules.shopping.entity.SelfBanner; +import com.sqx.modules.shopping.service.SlefBannerService; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Date; + +@Service +public class SelfBannerServiceImpl implements SlefBannerService { + @Autowired + private SelfBannerJpaRepository jpaRepository; + + @Override + public Result findAll() { + Sort sort = Sort.by(new Sort.Order(Sort.Direction.ASC, "sort")); //排序升序 + return ResultUtil.success(jpaRepository.findAll(sort)); + } + + @Override + public Result saveBody(SelfBanner entity) { + entity.setCreateAt(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result updateBody(SelfBanner entity) { + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result findOne(Long id) { + return ResultUtil.success(jpaRepository.findById(id).orElse(null)); + } + + @Override + public Result delete(Long id) { + jpaRepository.deleteById(id); + return ResultUtil.success(); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsAttrServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsAttrServiceImpl.java new file mode 100644 index 0000000..fb24d7b --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsAttrServiceImpl.java @@ -0,0 +1,69 @@ +package com.sqx.modules.shopping.service.impl; + +import com.sqx.modules.shopping.dao.SelfGoodsAttrJpaRepository; +import com.sqx.modules.shopping.dao.SelfGoodsAttrValueJpaRepository; +import com.sqx.modules.shopping.entity.SelfGoodsAttr; +import com.sqx.modules.shopping.entity.SelfGoodsAttrValue; +import com.sqx.modules.shopping.service.SelfGoodsAttrService; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class SelfGoodsAttrServiceImpl implements SelfGoodsAttrService { + @Autowired + private SelfGoodsAttrJpaRepository attrJpaRepository; + @Autowired + private SelfGoodsAttrValueJpaRepository attrValueJpaRepository; + + @Override + public Result saveBody(SelfGoodsAttr e) { + SelfGoodsAttr save = attrJpaRepository.save(e); + List list = e.getAttrValue(); + for (SelfGoodsAttrValue v : list) { + v.setGoodsId(e.getGoodsId()); + v.setAttrId(save.getId()); + attrValueJpaRepository.save(v); + } + return ResultUtil.success(save); + } + + @Override + public Result updateBody(SelfGoodsAttr e) { + //查询所有值删掉 + List allRuleValue = attrValueJpaRepository.findAllByAttrId(e.getId()); + attrValueJpaRepository.deleteAll(allRuleValue); + //放入新值 + List list = e.getAttrValue(); + for (SelfGoodsAttrValue v : list) { + v.setGoodsId(e.getGoodsId()); + v.setAttrId(e.getId()); + attrValueJpaRepository.save(v); + } + return ResultUtil.success(attrJpaRepository.save(e)); + } + + @Override + public List findByGoodsId(Long goodsId) { + List list = attrJpaRepository.findAllByGoodsId(goodsId); + for (SelfGoodsAttr s : list) { + List valueList = attrValueJpaRepository.findAllByAttrId(s.getId()); + s.setAttrValue(valueList); + } + return list; + } + + @Override + public void deleteAttrAndValue(Long goodsId) { + //删掉所有attr + List list = attrJpaRepository.findAllByGoodsId(goodsId); + attrJpaRepository.deleteAll(list); + //删掉所有value + List allRuleValue = attrValueJpaRepository.findAllByGoodsId(goodsId); + attrValueJpaRepository.deleteAll(allRuleValue); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsBrandServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsBrandServiceImpl.java new file mode 100644 index 0000000..d498e4e --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsBrandServiceImpl.java @@ -0,0 +1,67 @@ +package com.sqx.modules.shopping.service.impl; + +import com.sqx.modules.shopping.dao.SelfGoodsBrandJpaRepository; +import com.sqx.modules.shopping.entity.GoodsTypeResult; +import com.sqx.modules.shopping.entity.SelfGoodsBrand; +import com.sqx.modules.shopping.service.SelfGoodsBrandService; +import com.sqx.modules.shopping.utils.DateUtil; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class SelfGoodsBrandServiceImpl implements SelfGoodsBrandService { + @Autowired + private SelfGoodsBrandJpaRepository jpaRepository; + + @Override + public Result findAll(Integer page, Integer size) { + Pageable pageable = PageRequest.of(page, size); + Page pageList = jpaRepository.findAll(pageable); + return ResultUtil.success(pageList); + } + + @Override + public Result result() { + List type1 = jpaRepository.findAll(); + List resultList = new ArrayList<>(); + for (SelfGoodsBrand g : type1) { + GoodsTypeResult result = new GoodsTypeResult(); + result.setValue(g.getBrandId()); + result.setLabel(g.getBrandName()); + resultList.add(result); + } + return ResultUtil.success(resultList); + } + + @Override + public Result saveBody(SelfGoodsBrand entity) { + entity.setCreateTime(DateUtil.createTime()); //创建时间 + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result updateBody(SelfGoodsBrand entity) { + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result findOne(Long id) { + SelfGoodsBrand s = jpaRepository.findById(id).orElse(null); + return ResultUtil.success(s); + } + + @Override + public Result delete(Long id) { + jpaRepository.deleteById(id); + return ResultUtil.success(); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsCommentServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsCommentServiceImpl.java new file mode 100644 index 0000000..a97e8c1 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsCommentServiceImpl.java @@ -0,0 +1,144 @@ +package com.sqx.modules.shopping.service.impl; + +import com.sqx.modules.shopping.dao.OrdersJpaRepository; +import com.sqx.modules.shopping.dao.SelfGoodsCommentJpaRepository; +import com.sqx.modules.shopping.entity.SelfGoodsComment; +import com.sqx.modules.shopping.entity.SelfOrders; +import com.sqx.modules.shopping.service.SelfGoodsCommentService; +import com.sqx.modules.shopping.utils.DateUtil; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class SelfGoodsCommentServiceImpl implements SelfGoodsCommentService { + @Autowired + private SelfGoodsCommentJpaRepository jpaRepository; + @Autowired + private OrdersJpaRepository ordersJpaRepository; + + @Override + public Result findAll(Integer page, Integer size, Long goodsId, Integer scoreType) { + Pageable pageable = PageRequest.of(page, size, Sort.by(new Sort.Order(Sort.Direction.DESC, "createTime"))); + //构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + if(goodsId!=null){ + predicateList.add(criteriaBuilder.equal(root.get("goodsId"), goodsId)); + } + if (scoreType != 0){ + predicateList.add(criteriaBuilder.equal(root.get("scoreType"), scoreType)); + } + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + Page pageList = jpaRepository.findAll(queryCondition, pageable); + return ResultUtil.success(pageList); + } + + @Override + public Result count(Long goodsId) { + List list = jpaRepository.findAllByGoodsId(goodsId); + Map map = new HashMap<>(); + int count = list.size(); //个数 + int sum = 0; //总分数 + String count1 = ""; //平均分 + int count2 = 0; + int count3 = 0; + int count4 = 0; + for (SelfGoodsComment s : list) { + Integer score = s.getScoreType(); + sum += s.getScore(); //总分数 + switch (score){ + case 1 : count2++; break; + case 2 : count3++; break; + case 3 : count4++; break; + } + } + DecimalFormat dF = new DecimalFormat("0.0"); + count1 = dF.format((float)sum/count); //计算平均分 + map.put("count", count); //总条数 + map.put("count1", count1); //平均分 + map.put("count2", count2); //好评个数 + map.put("count3", count3); //中评个数 + map.put("count4", count4); //差评个数 + return ResultUtil.success(map); + } + + @Override + public Result userList(Integer page, Integer size, Long userId) { + Pageable pageable = PageRequest.of(page, size, Sort.by(new Sort.Order(Sort.Direction.DESC, "createTime"))); + //构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + predicateList.add(criteriaBuilder.equal(root.get("userId"), userId)); + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + Page pageList = jpaRepository.findAll(queryCondition, pageable); + return ResultUtil.success(pageList); + } + + @Override + public Result findByOrderId(Long orderId) { + return ResultUtil.success(jpaRepository.findByOrderId(orderId)); + } + + @Override + public Result saveBody(SelfGoodsComment entity) { + SelfGoodsComment c = jpaRepository.findByOrderId(entity.getOrderId()); + if (c != null && c.getCommentId()!=null){ + ResultUtil.error(-1, "已经评价了"); + } + //更新订单状态 + SelfOrders o = ordersJpaRepository.findById(entity.getOrderId()).orElse(null); + o.setStatus(10); //10已评价 + ordersJpaRepository.save(o); + //保存评论 + entity.setCreateTime(DateUtil.createTime()); //创建时间 + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result updateBody(SelfGoodsComment entity) { + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result findOne(Long id) { + return ResultUtil.success(jpaRepository.findById(id).orElse(null)); + } + + @Override + public Result delete(Long id) { + jpaRepository.deleteById(id); + return ResultUtil.success(); + } + + @Override + public Result reply(Long commentId, String reply) { + SelfGoodsComment s = jpaRepository.findById(commentId).orElse(null); + s.setReply(reply); + return ResultUtil.success(jpaRepository.save(s)); + } +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsRuleServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsRuleServiceImpl.java new file mode 100644 index 0000000..9904f99 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsRuleServiceImpl.java @@ -0,0 +1,85 @@ +package com.sqx.modules.shopping.service.impl; + +import com.sqx.modules.shopping.dao.SelfGoodsRuleJpaRepository; +import com.sqx.modules.shopping.dao.SelfGoodsRuleValueJpaRepository; +import com.sqx.modules.shopping.entity.SelfGoodsRule; +import com.sqx.modules.shopping.entity.SelfGoodsRuleValue; +import com.sqx.modules.shopping.service.SelfGoodsRuleService; +import com.sqx.modules.shopping.utils.DateUtil; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class SelfGoodsRuleServiceImpl implements SelfGoodsRuleService { + @Autowired + private SelfGoodsRuleJpaRepository jpaRepository; + @Autowired + private SelfGoodsRuleValueJpaRepository ruleValueJpaRepository; + + @Override + public Result findAll(Integer page, Integer size) { + Pageable pageable = PageRequest.of(page, size); + Page pageList = jpaRepository.findAll(pageable); + List all = pageList.getContent(); + for (SelfGoodsRule r : all) { + r.setRuleValue(ruleValueJpaRepository.findAllByRuleId(r.getId())); + } + return ResultUtil.success(pageList); + } + + @Override + public Result info() { + List all = jpaRepository.findAll(); + for (SelfGoodsRule r : all) { + r.setRuleValue(ruleValueJpaRepository.findAllByRuleId(r.getId())); + } + return ResultUtil.success(all); + } + + @Override + public Result saveBody(SelfGoodsRule entity) { + entity.setCreateTime(DateUtil.createTime()); //创建时间 + SelfGoodsRule save = jpaRepository.save(entity); + List list = entity.getRuleValue(); + for (SelfGoodsRuleValue v : list) { + v.setRuleId(save.getId()); + ruleValueJpaRepository.save(v); + } + return ResultUtil.success(save); + } + + @Override + public Result updateBody(SelfGoodsRule entity) { + //查询所有值删掉 + List allRuleValue = ruleValueJpaRepository.findAllByRuleId(entity.getId()); + ruleValueJpaRepository.deleteAll(allRuleValue); + //放入新值 + List list = entity.getRuleValue(); + for (SelfGoodsRuleValue v : list) { + v.setRuleId(entity.getId()); + ruleValueJpaRepository.save(v); + } + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result findOne(Long id) { + SelfGoodsRule s = jpaRepository.findById(id).orElse(null); + s.setRuleValue(ruleValueJpaRepository.findAllByRuleId(id)); + return ResultUtil.success(s); + } + + @Override + public Result delete(Long id) { + jpaRepository.deleteById(id); + return ResultUtil.success(); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsServiceImpl.java new file mode 100644 index 0000000..7ff653a --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsServiceImpl.java @@ -0,0 +1,705 @@ +package com.sqx.modules.shopping.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.sqx.modules.shopping.controller.SkuUtil; +import com.sqx.modules.shopping.dao.*; +import com.sqx.modules.shopping.entity.*; +import com.sqx.modules.shopping.service.GoodsService; +import com.sqx.modules.shopping.service.SelfGoodsAttrService; +import com.sqx.modules.shopping.utils.DateUtil; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import java.util.*; +import java.util.stream.Collectors; + +@Service +public class SelfGoodsServiceImpl implements GoodsService { + @Autowired + private GoodsJpaRepository jpaRepository; + @Autowired + private GoodsTypeJpaRepository goodsJpaTypeRepository; + @Autowired + private SelfGoodsAttrValueJpaRepository attrValueJpaRepository; + @Autowired + private SelfGoodsAttrValueRepository selfGoodsAttrValueRepository; + @Autowired + private SelfGoodsAttrJpaRepository attrJpaRepository; + @Autowired + private SelfGoodsAttrRepository selfGoodsAttrRepository; + @Autowired + private SelfGoodsAttrService goodsAttrService; + @Autowired + private SelfGoodsSkuJpaRepository skuJpaRepository; + @Autowired + private SelfGoodsVirtualJpaRepository goodsVirtualJpaRepository; + @Autowired + private SelfGoodsBrandJpaRepository selfGoodsBrandJpaRepository; + + + /** + * 后台管理商品列表、创建时间排序 + * @param page 页数 + * @param size 条数 + * @param title 标题:模糊查询 + * @param type 类型 + * @param status 状态 + * @return + */ + @Override + public Result findAll(Integer page, Integer size, String title, String type, Integer status, Integer isJiFenGoods) { + //按照时间排序 + Pageable pageable = PageRequest.of(page, size, Sort.by(new Sort.Order(Sort.Direction.DESC, "createAt"))); + //构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + if (StringUtils.isNotEmpty(title)) { + predicateList.add(criteriaBuilder.like(root.get("title"), "%"+title+"%")); + } + if (StringUtils.isNotEmpty(type)) { + predicateList.add(criteriaBuilder.equal(root.get("typeId"), type)); + } + if (status != 0) { + predicateList.add(criteriaBuilder.equal(root.get("status"), status)); + } + if (isJiFenGoods != null) { + predicateList.add(criteriaBuilder.equal(root.get("isJiFenGoods"), isJiFenGoods)); + }else { + predicateList.add(criteriaBuilder.isNull(root.get("isJiFenGoods"))); + } + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + //处理数据:商品分类 + Page all = jpaRepository.findAll(queryCondition, pageable); + List list = all.getContent(); + List allType = goodsJpaTypeRepository.findAll(); + for (SelfGoods g : list) { + for (GoodsType goodsType : allType) { + String typeId = g.getTypeId(); + if (StringUtils.isNotEmpty(typeId) && typeId.equals(goodsType.getId().toString())){ + g.setType(goodsType); + break; + } + } + } + return ResultUtil.success(all); + } + @Override + public Result selectListByType(String title, String type, Integer status, Integer isJiFenGoods) { + //构造自定义查询条件 + Specification queryCondition1 = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + predicateList.add(criteriaBuilder.or(criteriaBuilder.equal(root.get("parentId"), "56"),criteriaBuilder.equal(root.get("id"), "56"))); + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + List materialTypes = goodsJpaTypeRepository.findAll(queryCondition1); + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + if (StringUtils.isNotEmpty(title)) { + predicateList.add(criteriaBuilder.like(root.get("title"), "%"+title+"%")); + } + CriteriaBuilder.In in = criteriaBuilder.in(root.get("typeId")); + for(GoodsType goodsType:materialTypes) { + in.value(goodsType.getId()); + } + predicateList.add(in); + if (ObjectUtil.isNotEmpty(status)) { + predicateList.add(criteriaBuilder.equal(root.get("status"), status)); + } + if (ObjectUtil.isNotEmpty(isJiFenGoods)) { + predicateList.add(criteriaBuilder.equal(root.get("isJiFenGoods"), isJiFenGoods)); + }else { + predicateList.add(criteriaBuilder.isNull(root.get("isJiFenGoods"))); + } + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + //处理数据:商品分类 + List all = jpaRepository.findAll(queryCondition); + for (SelfGoods g : all) { + for (GoodsType goodsType : materialTypes) { + String typeId = g.getTypeId(); + if (StringUtils.isNotEmpty(typeId) && typeId.equals(goodsType.getId().toString())){ + g.setType(goodsType); + break; + } + } + } + return ResultUtil.success(all); + } + //虚拟商品列表 + @Override + public Result goodsVirtualList(Integer page, Integer size, String title, String type, Integer status, Integer isExpress, Integer isJiFenGoods) { + //按照时间排序 + Pageable pageable = PageRequest.of(page, size, Sort.by(new Sort.Order(Sort.Direction.DESC, "createAt"))); + //构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + if (StringUtils.isNotEmpty(title)) { + predicateList.add(criteriaBuilder.like(root.get("title"), "%"+title+"%")); + } + if (StringUtils.isNotEmpty(type)) { + predicateList.add(criteriaBuilder.equal(root.get("typeId"), type)); + } + if (status != 0) { + predicateList.add(criteriaBuilder.equal(root.get("status"), status)); + } + if (isExpress != 0) { + predicateList.add(criteriaBuilder.equal(root.get("isExpress"), isExpress)); + } + if (isJiFenGoods != null) { + if (isJiFenGoods != 0){ //虚拟商品列表包含积分虚拟商品 + predicateList.add(criteriaBuilder.equal(root.get("isJiFenGoods"), isJiFenGoods)); + } + }else { + predicateList.add(criteriaBuilder.isNull(root.get("isJiFenGoods"))); + } + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + //处理数据:商品分类 + Page all = jpaRepository.findAll(queryCondition, pageable); + List virtualList = goodsVirtualJpaRepository.findAll(); + List list = all.getContent(); + for (SelfGoods g : list) { + int sum = 0; + int count = 0; + for (SelfGoodsVirtual v : virtualList) { + if (g.getId().equals(v.getGoodsId())){ //虚拟商品总数库存 + sum++; + if (v.getStatus() == 1){ //未使用的库存 + count++; + } + } + } + g.setVirtualSum(sum); + g.setVirtualCount(count); + } + return ResultUtil.success(all); + } + + /** + * 用户端商品列表、销量排序 + * @param page 页数 + * @param size 条数 + * @param title 标题:模糊查询 + * @return + */ + @Override + public Result findAllByUser(Integer page, Integer size, String type, String brandId, String title, String sort, Integer isJiFenGoods) { + Sort.Order order = new Sort.Order(Sort.Direction.DESC, sort); + if (sort.equals("price")){ + order = new Sort.Order(Sort.Direction.ASC, sort); + } + Pageable pageable = PageRequest.of(page, size, Sort.by(order)); + //构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + if (StringUtils.isNotEmpty(type)) { + predicateList.add(criteriaBuilder.equal(root.get("typeId"), type)); + } + if (StringUtils.isNotEmpty(brandId)) { + predicateList.add(criteriaBuilder.equal(root.get("brandId"), brandId)); + } + if (StringUtils.isNotEmpty(title)) { + predicateList.add(criteriaBuilder.like(root.get("title"), "%"+title+"%")); + } + if (isJiFenGoods != null) { + predicateList.add(criteriaBuilder.equal(root.get("isJiFenGoods"), isJiFenGoods)); + }else { + predicateList.add(criteriaBuilder.isNull(root.get("isJiFenGoods"))); + } + predicateList.add(criteriaBuilder.equal(root.get("status"), 1)); + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + //处理数据:商品分类 + Page all = jpaRepository.findAll(queryCondition, pageable); + List list = all.getContent(); + for (SelfGoods g : list) { + Long id=g.getId(); + /*if (g.getTypeId() != null){ + g.setType(goodsJpaTypeRepository.findById(Long.valueOf(g.getTypeId())).orElse(null)); + }*/ + g.setAttr(goodsAttrService.findByGoodsId(id)); + g.setSku(skuJpaRepository.findAllByGoodsId(id)); + /*if (g.getBrandId() != null){ + g.setBrand(brandJpaRepository.findById(g.getBrandId()).orElse(null)); + }*/ + if (g.getIsExpress() == 2){ //虚拟商品库存 + g.setVirtualCount(goodsVirtualJpaRepository.findByGoodsId(g.getId()).size()); + } + } + return ResultUtil.success(all); + } + + + @Override + public Result saveBody(SelfGoods entity) { + entity.setCreateAt(DateUtil.createTime()); //创建时间 + entity.setStatus(1); //状态为默认1上架 + SelfGoods g = jpaRepository.save(entity); + //处理规格 + List attr = entity.getAttr(); + for (SelfGoodsAttr a : attr) { + a.setGoodsId(g.getId()); + goodsAttrService.saveBody(a); + } + List sku = entity.getSku(); + for (SelfGoodsSku v : sku) { + v.setGoodsId(g.getId()); + skuJpaRepository.save(v); + } + return ResultUtil.success(g); + } + + @Override + public Result updateBody(SelfGoods entity) { + //1.修改attr + if (entity.getAttr() != null && entity.getAttr().size()>0){ + SelfGoodsAttr selfGoodsAttr = entity.getAttr().get(0); + if(selfGoodsAttr.getId()==null){ + goodsAttrService.deleteAttrAndValue(entity.getId()); + for(SelfGoodsAttr attr:entity.getAttr()){ + attr.setGoodsId(entity.getId()); + goodsAttrService.saveBody(attr); + } + }else{ + for(SelfGoodsAttr attr:entity.getAttr()){ + attr.setGoodsId(entity.getId()); + goodsAttrService.updateBody(attr); + } + } + }else { //修改为单规格,删除所有attr + goodsAttrService.deleteAttrAndValue(entity.getId()); + } + //2.修改所有sku + List allSku = skuJpaRepository.findAllByGoodsId(entity.getId()); + skuJpaRepository.deleteAll(allSku); + List sku = entity.getSku(); + for (SelfGoodsSku v : sku) { + v.setGoodsId(entity.getId()); + skuJpaRepository.save(v); + } + //3.修改商品信息 + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result findOne(Long id) { + SelfGoods g = jpaRepository.findById(id).orElse(null); + if (g.getTypeId() != null){ + g.setType(goodsJpaTypeRepository.findById(Long.valueOf(g.getTypeId())).orElse(null)); + } + g.setAttr(goodsAttrService.findByGoodsId(id)); + g.setSku(skuJpaRepository.findAllByGoodsId(id)); + if (g.getIsExpress() == 2){ //虚拟商品库存 + g.setVirtualCount(goodsVirtualJpaRepository.findByGoodsId(g.getId()).size()); + } + if (g.getBrandId() != null){ + g.setBrand(selfGoodsBrandJpaRepository.findById(g.getBrandId()).orElse(null)); + } + return ResultUtil.success(g); + } + + + @Override + public SelfGoods findById(Long goodsId){ + return jpaRepository.findById(goodsId).orElse(null); + } + + + @Override + public Result delete(Long id) { + jpaRepository.deleteById(id); + return ResultUtil.success(); + } + + + @Override + public Result searchBrandList(String title) { + //构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + if (StringUtils.isNotEmpty(title)) { + predicateList.add(criteriaBuilder.like(root.get("title"), "%"+title+"%")); + } + predicateList.add(criteriaBuilder.equal(root.get("status"), 1)); + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + List goodsList = jpaRepository.findAll(queryCondition); + List brandList = selfGoodsBrandJpaRepository.findAll(); + List result = new ArrayList<>(); + for (SelfGoods g : goodsList) { + if (g.getBrandId() != null){ + Long brandId = g.getBrandId(); + for (SelfGoodsBrand b : brandList) { + if (brandId.equals(b.getBrandId())){ + result.add(b); + break; + } + } + } + } + //利用list中的元素创建HashSet集合,此时set中进行了去重操作 + HashSet set = new HashSet(result); + result.clear(); + result.addAll(set); + return ResultUtil.success(result); + } + + + + @Override + public Result selectGoods(Integer page, Integer size, String sort) { + Sort.Order order = new Sort.Order(Sort.Direction.DESC, sort); + if (sort.equals("price")){ + order = new Sort.Order(Sort.Direction.ASC, sort); + } + Pageable pageable = PageRequest.of(page, size, Sort.by(order)); + //构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + predicateList.add(criteriaBuilder.equal(root.get("isSelect"), 1)); + predicateList.add(criteriaBuilder.equal(root.get("status"), 1)); //上架 + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + return ResultUtil.success(jpaRepository.findAll(queryCondition, pageable)); + } + + @Override + public Result selling(Integer page, Integer size, String sort) { + Sort.Order order = new Sort.Order(Sort.Direction.DESC, sort); + if (sort.equals("price")){ + order = new Sort.Order(Sort.Direction.ASC, sort); + } + Pageable pageable = PageRequest.of(page, size, Sort.by(order)); + //构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + predicateList.add(criteriaBuilder.isNull(root.get("isJiFenGoods"))); + predicateList.add(criteriaBuilder.equal(root.get("status"), 1)); //上架 + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + return ResultUtil.success(jpaRepository.findAll(queryCondition, pageable)); + } + + @Override + public Result news(Integer page, Integer size, String sort) { + Sort.Order order = new Sort.Order(Sort.Direction.DESC, sort); + if (sort.equals("price")){ + order = new Sort.Order(Sort.Direction.ASC, sort); + } + Pageable pageable = PageRequest.of(page, size, Sort.by(order)); + //构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + predicateList.add(criteriaBuilder.equal(root.get("status"), 1)); //上架 + predicateList.add(criteriaBuilder.isNull(root.get("isJiFenGoods"))); //非积分商品 + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + return ResultUtil.success(jpaRepository.findAll(queryCondition, pageable)); + } + + @Override + public Result recommend(Integer page, Integer size, String sort) { + Sort.Order order = new Sort.Order(Sort.Direction.DESC, sort); + if (sort.equals("price")){ + order = new Sort.Order(Sort.Direction.ASC, sort); + } + Pageable pageable = PageRequest.of(page, size, Sort.by(order)); + //构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + predicateList.add(criteriaBuilder.equal(root.get("isRecommend"), 1)); //每日推荐 + predicateList.add(criteriaBuilder.equal(root.get("status"), 1)); //上架 + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + return ResultUtil.success(jpaRepository.findAll(queryCondition, pageable)); + } + + @Override + public Result homeGoods(Integer page, Integer size) { + //按照时间排序 + Pageable pageable = PageRequest.of(page, size, Sort.by(new Sort.Order(Sort.Direction.DESC, "sales"))); + //构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + predicateList.add(criteriaBuilder.equal(root.get("homeGoods"), 1)); + predicateList.add(criteriaBuilder.equal(root.get("status"), 1)); //上架 + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + return ResultUtil.success(jpaRepository.findAll(queryCondition, pageable)); + } + + @Override + public Result addSelectGoods(Long id) { + SelfGoods one = jpaRepository.getOne(id); + one.setIsSelect(1); //设置为精选好物 + return ResultUtil.success(this.updateBody(one)); + } + + @Override + public Result deleteSelectGoods(String ids) { + String[] split = ids.split(","); + for (String id : split) { + SelfGoods one = jpaRepository.getOne(Long.valueOf(id)); + one.setIsSelect(0); //设置为否 + this.updateBody(one); + } + return ResultUtil.success(); + } + + @Override + public Result addRecommend(Long id) { + SelfGoods one = jpaRepository.getOne(id); + one.setIsRecommend(1); //设置为每日推荐 + return ResultUtil.success(this.updateBody(one)); + } + + @Override + public Result deleteRecommend(String ids) { + String[] split = ids.split(","); + for (String id : split) { + SelfGoods one = jpaRepository.getOne(Long.valueOf(id)); + one.setIsRecommend(0); //设置为否 + this.updateBody(one); + } + return ResultUtil.success(); + } + + @Override + public void salesAddOne(Long id) { + SelfGoods one = jpaRepository.getOne(id); + one.setSales(one.getSales()+1); + jpaRepository.save(one); + } + + @Override + public Result isFormatAttr(SelfGoodsAttr goodsAttr, String coverImg, String originalPrice, String price, String memberPrice) { + //1.获取商品规格值 + List attr = goodsAttr.getAttrValue(); + int attrSize = attr.size(); + //2.准备返回值 + Map map = new HashMap<>(); + List header = new ArrayList<>(); //表头 + List> value = new ArrayList<>(); //规格排列组合 + //3.sku规格处理集合 + List> skuInputList = new ArrayList<>(); + //4.循环规格值 + for (int i = 0; i < attrSize; i++) { + //5.放入表头数据 + header.add(attr.get(i).getValue()); + //6.sku规格计算 + String detail = attr.get(i).getDetail(); + String[] split = detail.split(","); + List skuList = new ArrayList<>(); + for (int j = 0; j < split.length; j++) { + skuList.add(split[j]); + } + skuInputList.add(skuList); + } + //8.sku规格种类 + List> skuList = SkuUtil.skuSort(skuInputList); //计算规格种类 + for (int i = 0; i < skuList.size(); i++) { + Map sku = new HashMap<>(); + List strings = skuList.get(i); + String[] arr = strings.toArray(new String[strings.size()]); + String json = ""; + for (int j = 0; j < attrSize; j++) { + String arrString = arr[j]; + sku.put("value"+j, arrString); + json += arrString+","; + } + json = json.substring(0, json.length()-1); + sku.put("json", json); + sku.put("detailJson", json); + sku.put("skuImg", coverImg); + sku.put("skuOriginalPrice", originalPrice); + sku.put("skuPrice", price); + sku.put("stock", 999); + sku.put("sales", 0); + value.add(sku); + } + //表头 + header.add("图片"); + if (StringUtils.isNotEmpty(originalPrice)){ + header.add("原价"); + } + header.add("售价"); + header.add("库存"); + header.add("销量"); + header.add("操作"); + //数据放入返回map + map.put("header", header); + map.put("value", value); + return ResultUtil.success(map); + } + + @Override + public Result onlyFormatAttr(String coverImg, String originalPrice, String price, String memberPrice) { + Map map = new HashMap<>(); + List header = new ArrayList<>(); //表头 + //表头 + header.add("图片"); + if (StringUtils.isNotEmpty(originalPrice)){ + header.add("原价"); + } + header.add("售价"); + header.add("库存"); + header.add("销量"); + List> value = new ArrayList<>(); //规格排列组合 + Map sku = new HashMap<>(); + sku.put("json", null); + sku.put("detailJson", null); + sku.put("skuImg", coverImg); + sku.put("skuOriginalPrice", originalPrice); + sku.put("skuPrice", price); + sku.put("stock", 999); + sku.put("sales", 0); + value.add(sku); + //数据放入返回map + map.put("header", header); + map.put("value", value); + return ResultUtil.success(map); + } + + /** + * 回显sku + * @param goodsId + * @return + */ + @Override + public Result formatAttr(Long goodsId) { + //1.获取商品规格值 + List attr = attrValueJpaRepository.findAllByGoodsId(goodsId); + //sku集合 + List goodsSkuList = skuJpaRepository.findAllByGoodsId(goodsId); + int attrSize = attr.size(); + //2.准备返回值 + Map map = new HashMap<>(); + List header = new ArrayList<>(); //表头 + List> value = new ArrayList<>(); //规格排列组合 + if (attrSize > 0){ + //4.循环规格值 + for (int i = 0; i < attrSize; i++) { + //5.放入表头数据 + header.add(attr.get(i).getValue()); + } + } + SelfGoods goods = jpaRepository.findById(goodsId).orElse(null); + if (goods.getIsJiFenGoods() == null){ //普通商品回显表头 + //表头 + header.add("图片"); + header.add("原价"); + header.add("售价"); + header.add("库存"); + header.add("销量"); + header.add("操作"); + }else { //积分商品回显表头 + //表头 + header.add("图片"); + header.add("售价"); + header.add("库存"); + header.add("销量"); + header.add("操作"); + } + //5.sku数据放入 + for (SelfGoodsSku s : goodsSkuList) { + Map sku = new HashMap<>(); + String detailJson = s.getDetailJson(); + if (detailJson != null){ + String[] split = detailJson.split(","); + for (int i = 0; i < split.length; i++) { + sku.put("value"+i, split[i]); + } + } + if (goods.getIsJiFenGoods() == null){ + sku.put("detailJson", detailJson); + sku.put("skuOriginalPrice", s.getSkuOriginalPrice()); + sku.put("skuPrice", s.getSkuPrice()); + sku.put("stock", s.getStock()); + sku.put("sales", s.getSales()); + sku.put("skuImg", s.getSkuImg()); + }else { + sku.put("detailJson", detailJson); + sku.put("skuPrice", s.getSkuPrice()); + sku.put("stock", s.getStock()); + sku.put("sales", s.getSales()); + sku.put("skuImg", s.getSkuImg()); + } + value.add(sku); + } + //数据放入返回map + map.put("header", header); + map.put("value", value); + return ResultUtil.success(map); + } + + @Override + public Result findAttrValue(Long goodsId) { + List attrList = attrJpaRepository.findAllByGoodsId(goodsId); + SelfGoodsAttr s = new SelfGoodsAttr(); + if (attrList.size() > 0 && attrList != null){ + s = attrList.get(0); + s.setAttrValue(attrValueJpaRepository.findAllByGoodsId(goodsId)); + } + return ResultUtil.success(s); + } + + @Override + public Result updateStatus(Long goodsId) { + SelfGoods g = jpaRepository.findById(goodsId).orElse(null); + if (g.getStatus() == 1){ + g.setStatus(2); + }else { + g.setStatus(1); + } + return ResultUtil.success(jpaRepository.save(g)); + } + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsSkuServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsSkuServiceImpl.java new file mode 100644 index 0000000..9c07907 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsSkuServiceImpl.java @@ -0,0 +1,39 @@ +package com.sqx.modules.shopping.service.impl; + + +import com.sqx.modules.shopping.dao.SelfGoodsSkuJpaRepository; +import com.sqx.modules.shopping.entity.SelfGoodsSku; +import com.sqx.modules.shopping.service.SelfGoodsSkuService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class SelfGoodsSkuServiceImpl implements SelfGoodsSkuService { + @Autowired + private SelfGoodsSkuJpaRepository jpaRepository; + + @Override + public boolean checkStock(Long skuId, Integer paNumber) { + boolean flag = true; + SelfGoodsSku sku = jpaRepository.findById(skuId).orElse(null); + if (sku.getStock() < paNumber){ + flag = false; + } + return flag; + } + + @Override + public void lessStock(Long skuId, Integer number) { + jpaRepository.lessStock(skuId, number); + } + + @Override + public void addStock(Long skuId, Integer number) { + jpaRepository.addStock(skuId, number); + } + + @Override + public void addSales(Long skuId, Integer number) { + jpaRepository.addSales(skuId, number); + } +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsVirtualServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsVirtualServiceImpl.java new file mode 100644 index 0000000..f699233 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsVirtualServiceImpl.java @@ -0,0 +1,106 @@ +package com.sqx.modules.shopping.service.impl; + +import com.sqx.modules.shopping.dao.OrdersJpaRepository; +import com.sqx.modules.shopping.dao.SelfGoodsVirtualJpaRepository; +import com.sqx.modules.shopping.entity.SelfGoodsVirtual; +import com.sqx.modules.shopping.service.SelfGoodsVirtualService; +import com.sqx.modules.shopping.utils.DateUtil; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Service +public class SelfGoodsVirtualServiceImpl implements SelfGoodsVirtualService { + @Autowired + private SelfGoodsVirtualJpaRepository jpaRepository; + @Autowired + private OrdersJpaRepository ordersJpaRepository; + + @Override + public Result findAll(Integer page, Integer size, Long goodsId, String content) { + Pageable pageable = PageRequest.of(page, size); + if (StringUtils.isNotEmpty(content)){ + Page> all1 = jpaRepository.findAllContent(pageable, goodsId, content); + return ResultUtil.success(all1); + }else { + Page> all1 = jpaRepository.findAll(pageable, goodsId); + return ResultUtil.success(all1); + } + } + + + /** + * 批量添加 + * @return + */ + @Override + public Result saveBody(SelfGoodsVirtual e) { + List all = jpaRepository.findAll(); + String msg = ""; + int success = 0; + int failure = 0; + //获取多个卡密,切割循环 + String[] list = e.getContent().split(","); + List saveList = new ArrayList<>(); + for (int i = 0; i < list.length; i++) { + String content = list[i]; + //卡密查重 + List checkList = jpaRepository.checkContent(content, e.getGoodsId()); + if (checkList.size() > 0){ + failure++; + msg += "/"+content; + }else { + SelfGoodsVirtual s = new SelfGoodsVirtual(); + s.setStatus(1); //基础信息 + s.setCreateTime(DateUtil.createTime()); + s.setGoodsId(e.getGoodsId()); //商品信息 + s.setTitle(e.getTitle()); + s.setCoverImg(e.getCoverImg()); + s.setGoodsId(e.getGoodsId()); + s.setLinkUrl(e.getLinkUrl()); //链接 + s.setContent(content); //卡密 + saveList.add(s); + success++; //添加成功计数 + } + } + jpaRepository.saveAll(saveList); + return ResultUtil.success("本次补货"+list.length+"条,成功"+success+"条,失败"+failure+"条,重复数据为"+msg); + } + + @Override + public Result updateBody(SelfGoodsVirtual entity) { + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result findOne(Long id) { + return ResultUtil.success(jpaRepository.findById(id).orElse(null)); + } + + @Override + public Result delete(Long id) { + jpaRepository.deleteById(id); + return ResultUtil.success(); + } + + @Override + public SelfGoodsVirtual sendGoods(Long goodsId) { + List goodsList = jpaRepository.findByGoodsId(goodsId); + if (goodsList.size() > 0){ + SelfGoodsVirtual g = goodsList.get(0); + g.setStatus(3); //已使用 + jpaRepository.save(g); + return g; + } + return null; + } +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/SelfMerchantApplyServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/SelfMerchantApplyServiceImpl.java new file mode 100644 index 0000000..0c55804 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/SelfMerchantApplyServiceImpl.java @@ -0,0 +1,131 @@ +package com.sqx.modules.shopping.service.impl; + +import com.sqx.modules.shopping.dao.SelfMerchantApplyJpaRepository; +import com.sqx.modules.shopping.dao.SelfMerchantApplyRepository; +import com.sqx.modules.shopping.entity.SelfMerchantApply; +import com.sqx.modules.shopping.service.SelfMerchantApplyService; +import com.sqx.modules.shopping.utils.DateUtil; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import java.util.ArrayList; +import java.util.List; + +@Service +public class SelfMerchantApplyServiceImpl implements SelfMerchantApplyService { + @Autowired + private SelfMerchantApplyJpaRepository jpaRepository; + @Autowired + private SelfMerchantApplyRepository repository; + + /** + * 商家入驻申请列表 + * @param page 页数 + * @param size 条数 + * @param companyName 商家名称 + * @param legalPhone 注册手机号 + * @param storeType 店铺类型 + * @param status 状态 + * @param createTimeStart 申请时间开始区间 + * @param createTimeEnd 申请时间结束区间 + * @return + */ + @Override + public Result findAll(Integer page, Integer size, String companyName, String legalPhone, Integer storeType, Integer status, String createTimeStart, String createTimeEnd) { + //按照时间排序 + Pageable pageable = PageRequest.of(page, size, Sort.by(new Sort.Order(Sort.Direction.DESC, "createTime"))); + //构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + if (StringUtils.isNotEmpty(companyName)) { + predicateList.add(criteriaBuilder.equal(root.get("companyName"), companyName)); + } + if (StringUtils.isNotEmpty(legalPhone)) { + predicateList.add(criteriaBuilder.equal(root.get("legalPhone"), legalPhone)); + } + if (storeType != 0) { + predicateList.add(criteriaBuilder.equal(root.get("storeType"), storeType)); + } + if (status != 0) { + predicateList.add(criteriaBuilder.equal(root.get("status"), status)); + } + if (StringUtils.isNotEmpty(createTimeStart)) { + predicateList.add(criteriaBuilder.greaterThanOrEqualTo(root.get("createTime"), status)); + } + if (StringUtils.isNotEmpty(createTimeEnd)) { + predicateList.add(criteriaBuilder.lessThan(root.get("createTime"), status)); + } + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + return ResultUtil.success(jpaRepository.findAll(queryCondition, pageable)); + } + + /** + * 商户入驻申请 + * @param entity + * @return + */ + @Override + public Result saveBody(SelfMerchantApply entity) { + entity.setCreateTime(DateUtil.createTime()); + entity.setStatus(1); //审核状态(1待处理 2通过 3拒绝) + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result updateBody(SelfMerchantApply entity) { + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result findOne(Long id) { + return ResultUtil.success(jpaRepository.getOne(id)); + } + + @Override + public Result delete(Long id) { + jpaRepository.deleteById(id); + return ResultUtil.success(); + } + + /** + * 处理审核 + * @param id + * @param status 审核状态(1待处理 2通过 3拒绝) + * @param auditTime 生效日期 + * @param auditYears 生效年限 + * @param refundReason 拒绝原因 + * @return + */ + @Override + public Result deal(Long id, Integer status, String auditTime, String auditYears, String refundReason) { + SelfMerchantApply one = jpaRepository.getOne(id); + one.setStatus(status); + one.setAuditTime(auditTime); + one.setAuditYears(auditYears); + one.setRefundReason(refundReason); + SelfMerchantApply update = jpaRepository.save(one); + if (update.getStatus() == 2){ + //通过审核 + + }else if(update.getStatus() == 3){ + //拒绝 + + } + return ResultUtil.success(update); + } +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/SelfOrdersServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/SelfOrdersServiceImpl.java new file mode 100644 index 0000000..7ccfc08 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/SelfOrdersServiceImpl.java @@ -0,0 +1,968 @@ +package com.sqx.modules.shopping.service.impl; + +import com.alibaba.fastjson.JSON; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.entity.UserMoney; +import com.sqx.modules.app.entity.UserMoneyDetails; +import com.sqx.modules.app.entity.UserVip; +import com.sqx.modules.app.service.UserMoneyDetailsService; +import com.sqx.modules.app.service.UserMoneyService; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.app.service.UserVipService; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.material.service.MaterialArtificerService; +import com.sqx.modules.shopping.dao.*; +import com.sqx.modules.shopping.entity.*; +import com.sqx.modules.shopping.service.*; +import com.sqx.modules.shopping.utils.AmountCalUtil; +import com.sqx.modules.shopping.utils.DateUtil; +import com.sqx.modules.shopping.utils.Result; +import com.sqx.modules.shopping.utils.ResultUtil; +import com.sqx.modules.shopping.utils.excel.ExcelData; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.math.BigDecimal; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.UnknownHostException; +import java.text.SimpleDateFormat; +import java.util.*; + +@Service +public class SelfOrdersServiceImpl implements OrdersService { + @Autowired + private OrdersRepository ordersRepository; + @Autowired + private OrdersJpaRepository jpaRepository; + @Autowired + private OrdersRelationService ordersRelationService; + @Autowired + private GoodsService goodsService; + @Autowired + private SelfAliPayService selfAliPayService; + @Autowired + private SelfWXService selfWXService; + @Autowired + private CommonInfoService commonRepository; + @Autowired + private SelfOrdersRemindJpaRepository selfOrdersRemindJpaRepository; + @Autowired + private SelfGoodsVirtualService selfGoodsVirtualService; + @Autowired + private OrdersRelationJpaRepository ordersRelationJpaRepository; + @Autowired + private UserService userService; + @Autowired + private GoodsTypeJpaRepository goodsJpaTypeRepository; + @Autowired + private SelfGoodsSkuService skuService; + @Autowired + private UserMoneyService userMoneyService; + @Autowired + private UserMoneyDetailsService userMoneyDetailsService; + @Autowired + private UserVipService userVipService; + @Autowired + private MaterialArtificerService materialArtificerService; + + + + /** + * 订单列表 + * @param page + * @param size + * @param orderNum + * @param status + * @return + */ + @Override + public Result findAll(Integer page, Integer size, String orderNum, String status, String title,String mobile, String startTime, String endTime,String sendWay) { + //根据时间排序 + Pageable pageable = PageRequest.of(page, size, Sort.by(new Sort.Order(Sort.Direction.DESC, "createAt"))); + // 构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + if (StringUtils.isNotEmpty(orderNum)) { + predicateList.add(criteriaBuilder.equal(root.get("orderNum"), orderNum)); + } + if (!"0".equals(status)) { + predicateList.add(criteriaBuilder.equal(root.get("status"), status)); + } + if (StringUtils.isNotEmpty(title)) { + predicateList.add(criteriaBuilder.like(root.get("title"), "%"+title+"%")); + } + if (StringUtils.isNotEmpty(mobile)) { + predicateList.add(criteriaBuilder.equal(root.get("mobile"), mobile)); + } + if (StringUtils.isNotEmpty(startTime)){ + predicateList.add(criteriaBuilder.greaterThanOrEqualTo(root.get("createAt"), startTime)); + } + if (StringUtils.isNotEmpty(endTime)){ + predicateList.add(criteriaBuilder.lessThanOrEqualTo(root.get("createAt"), endTime)); + } + if (StringUtils.isNotEmpty(sendWay)){ + predicateList.add(criteriaBuilder.lessThanOrEqualTo(root.get("sendWay"), sendWay)); + } + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + Page all = jpaRepository.findAll(queryCondition, pageable); + List list = all.getContent(); + List allType = goodsJpaTypeRepository.findAll(); + for (SelfOrders g : list) { + for (GoodsType goodsType : allType) { + Long typeId = g.getType(); + if (typeId!=null && typeId.equals(goodsType.getId())){ + g.setGoodsType(goodsType); + } + } + } + return ResultUtil.success(all); + } + + + @Override + public ExcelData listExcel( String orderNum, String status, String title,String mobile, String startTime, String endTime,String sendWay) { + // 构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + if (StringUtils.isNotEmpty(orderNum)) { + predicateList.add(criteriaBuilder.equal(root.get("orderNum"), orderNum)); + } + if (!"0".equals(status)) { + predicateList.add(criteriaBuilder.equal(root.get("status"), status)); + } + if (StringUtils.isNotEmpty(title)) { + predicateList.add(criteriaBuilder.like(root.get("title"), "%"+title+"%")); + } + if (StringUtils.isNotEmpty(mobile)) { + predicateList.add(criteriaBuilder.equal(root.get("mobile"), mobile)); + } + if (StringUtils.isNotEmpty(startTime)){ + predicateList.add(criteriaBuilder.greaterThanOrEqualTo(root.get("createAt"), startTime)); + } + if (StringUtils.isNotEmpty(endTime)){ + predicateList.add(criteriaBuilder.lessThanOrEqualTo(root.get("createAt"), endTime)); + } + if (StringUtils.isNotEmpty(sendWay)){ + predicateList.add(criteriaBuilder.lessThanOrEqualTo(root.get("sendWay"), sendWay)); + } + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + List all = jpaRepository.findAll(queryCondition); + ExcelData data = new ExcelData(); + data.setName("订单列表"); + List titles = new ArrayList(); + titles.add("商品图片");titles.add("商品标题");titles.add("商品规格");titles.add("商品个数"); + //titles.add("订单备注"); + titles.add("订单类型");titles.add("订单号");titles.add("收货人"); + titles.add("手机号");titles.add("详细地址");titles.add("商品价格");titles.add("支付金额"); + titles.add("佣金");titles.add("退款原因");titles.add("驳回原因");titles.add("支付方式");titles.add("创建时间"); + titles.add("付款时间");titles.add("收货时间");titles.add("订单状态"); + data.setTitles(titles); + List> rows = new ArrayList(); + for(SelfOrders orders:all){ + List row = new ArrayList(); + row.add(orders.getImg());row.add(orders.getTitle());row.add(StringUtils.isEmpty(orders.getDetailJson())?"无":orders.getDetailJson());row.add(orders.getNumber()); + row.add(StringUtils.isEmpty(orders.getDescrition())?"未填写":orders.getDescrition()); + row.add(orders.getOrderNum());row.add(StringUtils.isEmpty(orders.getConsignee())?"":orders.getConsignee()); + row.add(StringUtils.isEmpty(orders.getMobile())?"":orders.getMobile());row.add(StringUtils.isEmpty(orders.getDetail())?"":orders.getDetail());row.add(orders.getPrice());row.add(orders.getPayMoney()); + row.add(orders.getCommissionPrice());row.add(StringUtils.isEmpty(orders.getRefund())?"":orders.getRefund());row.add(StringUtils.isEmpty(orders.getRefusedRefund())?"":orders.getRefusedRefund()); + //1app微信 2微信公众号 3微信小程序 4app支付宝 5H5支付宝 6零钱 7积分 + if(orders.getPayWay()==null) { + row.add("未支付"); + }else if(orders.getPayWay()==1){ + row.add("app微信"); + }else if(orders.getPayWay()==2){ + row.add("微信公众号"); + }else if(orders.getPayWay()==3){ + row.add("微信小程序"); + }else if(orders.getPayWay()==4){ + row.add("app支付宝"); + }else if(orders.getPayWay()==5){ + row.add("H5支付宝"); + }else if(orders.getPayWay()==6){ + row.add("零钱"); + }else if(orders.getPayWay()==7){ + row.add("积分"); + }else{ + row.add("未知"); + } + row.add(orders.getCreateAt()); + row.add(StringUtils.isEmpty(orders.getPayTime())?"":orders.getPayTime()); + row.add(StringUtils.isEmpty(orders.getFinishTime())?"":orders.getFinishTime()); + //1待付款 2已付款 3已发货 4已收货 5已取消 6退款中 7已退款 8拒绝退款 9拼团中 10已评价 + if(orders.getStatus()==1){ + row.add("待付款"); + }else if(orders.getStatus()==2){ + row.add("已付款"); + }else if(orders.getStatus()==3){ + row.add("已发货"); + }else if(orders.getStatus()==4){ + row.add("已收货"); + }else if(orders.getStatus()==5){ + row.add("已取消"); + }else if(orders.getStatus()==6){ + row.add("退款中"); + }else if(orders.getStatus()==7){ + row.add("已退款"); + }else if(orders.getStatus()==8){ + row.add("拒绝退款"); + }else if(orders.getStatus()==9){ + row.add("拼团中"); + }else if(orders.getStatus()==10){ + row.add("已评价"); + }else{ + row.add("未知"); + } + rows.add(row); + } + data.setRows(rows); + return data; + } + + + + + /** + * 用户端订单列表 + * @param page + * @param size + * @param userId + * @param status + * @return + */ + @Override + public Result findMyList(Integer page, Integer size, String userId, String status) { + //根据时间排序 + Pageable pageable = PageRequest.of(page, size, Sort.by(new Sort.Order(Sort.Direction.DESC, "createAt"))); + // 构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + if (StringUtils.isNotEmpty(userId)) { + predicateList.add(criteriaBuilder.equal(root.get("userId"), userId)); + } + if (!"0".equals(status)) { + predicateList.add(criteriaBuilder.equal(root.get("status"), status)); + } + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + Page all = jpaRepository.findAll(queryCondition, pageable); + //处理订单分销 + List all1 = ordersRelationJpaRepository.findAll(); + List allType = goodsJpaTypeRepository.findAll(); + for (SelfOrders o : all.getContent()) { + List relationList = new ArrayList<>(); + for (SelfOrderRelation r : all1) { + if (o.getId().toString().equals(r.getOrderId().toString())){ + relationList.add(r); + } + } + for (GoodsType goodsType : allType) { + Long typeId = o.getType(); + if (typeId!=null && typeId.equals(goodsType.getId())){ + o.setGoodsType(goodsType); + } + } + o.setRelationList(relationList); + } + return ResultUtil.success(all); + } + + /** + * 生成订单编号 + * @return + */ + private String getGeneralOrder() { + Date date=new Date(); + String newString = String.format("%0"+4+"d", (int)((Math.random()*9+1)*1000)); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String format = sdf.format(date); + return format+newString; + } + + /** + * 保存订单 + * @param entity + * @return + */ + @Override + public Result saveBody(SelfOrders entity) { + /* + 前端传入:用户id、收货人、手机号、详细地址、商品类型、商品标题、商品图片、商品描述、商品价格、商品个数、支付金额、 + 后台生成:创建时间、订单号、订单状态 + */ + entity.setCreateAt(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); //创建时间 + entity.setOrderNum(this.getGeneralOrder()); //订单号 + entity.setStatus(1); //订单状态待支付 + /* + * 支付金额 需要后端去验证金额 + */ + UserEntity userById = userService.selectUserById(entity.getUserId()); + Long goodsId = entity.getGoodsId(); + SelfGoods byId = goodsService.findById(goodsId); + if(byId.getStatus().equals(2)){ + return ResultUtil.error(-200,"商品已经下架了!"); + } + + if (!skuService.checkStock(entity.getSkuId(), entity.getNumber())){ + return ResultUtil.error(-1,entity.getTitle()+"库存不足"); + } + skuService.lessStock(entity.getSkuId(), entity.getNumber()); //sku库存减少对应数量 + + entity.setPrice(byId.getPrice()); + entity.setMemberPrice(byId.getMemberPrice()); + UserVip userVip = userVipService.selectUserVipByUserId(userById.getUserId()); + if(userVip==null || userVip.getIsVip()!=1){ + Double aDouble = AmountCalUtil.moneyMul(byId.getPrice(), entity.getNumber()); + entity.setPayMoney(aDouble); + }else{ + Double aDouble = AmountCalUtil.moneyMul(byId.getMemberPrice(), entity.getNumber()); + entity.setPayMoney(aDouble); + } + if(entity.getSendWay()==1 && byId.getPostagePrice()!=null){ + entity.setPayMoney(AmountCalUtil.add(entity.getPayMoney(),byId.getPostagePrice())); + } + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result updateBody(SelfOrders entity) { + Long goodsId = entity.getGoodsId(); + SelfGoods byId = goodsService.findById(goodsId); + UserEntity userById = userService.selectUserById(entity.getUserId()); + UserVip userVip = userVipService.selectUserVipByUserId(userById.getUserId()); + if(userVip==null || userVip.getIsVip()!=1){ + Double aDouble = AmountCalUtil.moneyMul(byId.getPrice(), entity.getNumber()); + entity.setPayMoney(aDouble); + }else{ + + Double aDouble = AmountCalUtil.moneyMul(byId.getMemberPrice(), entity.getNumber()); + entity.setPayMoney(aDouble); + } + entity.setPayMoney(AmountCalUtil.add(entity.getPayMoney(),byId.getPostagePrice())); + return ResultUtil.success(jpaRepository.save(entity)); + } + + @Override + public Result findOne(Long id) { + return ResultUtil.success(jpaRepository.findById(id).orElse(null)); + } + + @Override + public Result delete(Long id) { + jpaRepository.deleteById(id); + return ResultUtil.success(); + } + + /** + * 收入统计 + * @param data + * @param way + * @return + */ + @Override + public Result income(String data, int way) { + List list = ordersRepository.findByStatus(); + switch (way){ + case 1: data = data.substring(0,4); break; //年,截取前四个 + case 2: data = data.substring(0,7); break; //月,前6 + default: break; //日,或者其他不做处理 + } + BigDecimal sum0 = new BigDecimal("0.00"); //总收入 + BigDecimal sum1 = new BigDecimal("0.00"); //收入 + BigDecimal pay1 = new BigDecimal("0.00"); //微信 + BigDecimal pay2 = new BigDecimal("0.00"); //支付宝 + BigDecimal pay3 = new BigDecimal("0.00"); //余额 + int refundNum=0; + BigDecimal refundMoney = new BigDecimal("0.00"); //退款金额 + for (SelfOrders o : list) { + BigDecimal money = o.getPayMoney()== null?new BigDecimal("0.00"):BigDecimal.valueOf(o.getPayMoney()); //订单金额 + sum0 = sum0.add(money); + if (StringUtils.isNotEmpty(o.getPayTime()) && o.getPayTime().contains(data)){ + sum1 = sum1.add(money); + switch (o.getPayWay()){ //根据支付方式细分:支付方式(1app微信 2微信公众号 3微信小程序 4app支付宝 5H5支付宝 6零钱) + case 1 : pay1 = pay1.add(money); break; + case 2 : pay1 = pay1.add(money); break; + case 3 : pay1 = pay1.add(money); break; + case 4 : pay2 = pay2.add(money); break; + case 5 : pay2 = pay2.add(money); break; + case 6 : pay3 = pay3.add(money); break; + default: break; + } + } + if(o.getStatus().equals(7)){ + refundNum++; + refundMoney=refundMoney.add(money); + } + } + BigDecimal refundIncome = sum1.subtract(refundMoney); + Map map = new HashMap<>(); + map.put("sum0", sum0); + map.put("sum1", sum1); + map.put("pay1", pay1); + map.put("pay2", pay2); + map.put("pay3", pay3); + map.put("refundMoney", refundMoney); + map.put("refundIncome", refundIncome); + map.put("refundNum", refundNum); + return ResultUtil.success(map); + } + + /** + * 订单成交量统计 + * @param data + * @return + */ + @Override + public Result statistical(String data) { + // 构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + predicateList.add(criteriaBuilder.equal(root.get("status"), 4)); //统计已收货 + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + List list = jpaRepository.findAll(queryCondition); + int sum0 = 0; //年 + int sum1 = 0; //月 + int sum2 = 0; //日 + for (SelfOrders o : list) { + if (StringUtils.isEmpty(o.getFinishTime())){ + continue; + } + if (o.getFinishTime().contains(data.substring(0, 4))){ + String orderTime = o.getFinishTime(); + if (orderTime.contains(data.substring(0, 4))){ + sum0 ++; + } + if (orderTime.contains(data.substring(0, 7))){ + sum1 ++; + } + if (orderTime.contains(data)){ + sum2 ++; + } + } + } + Map map = new HashMap<>(); + map.put("sum0", sum0); + map.put("sum1", sum1); + map.put("sum2", sum2); + return ResultUtil.success(map); + } + + /** + * 取消订单 + * @param id + * @return + */ + @Override + public Result orderCancel(Long id) { + SelfOrders orders = jpaRepository.findById(id).orElse(null); + if (orders.getStatus() == 1){ + skuService.addStock(orders.getSkuId(), orders.getNumber()); + orders.setStatus(5); //设置为已取消 + orders = jpaRepository.save(orders); + return ResultUtil.success(orders); + }else { + return ResultUtil.error(-1, "当前订单不可取消"); + } + } + + /** + * 发货 + * @param id + * @param expressName + * @param expressNumber + * @return + */ + @Override + public Result express(Long id, String expressName, String expressNumber) { + SelfOrders orders = jpaRepository.findById(id).orElse(null); + orders.setExpressName(expressName); + orders.setExpressNumber(expressNumber); + orders.setStatus(3); //设置为已发货 + orders.setExpressTime(DateUtil.createTime()); + return ResultUtil.success(jpaRepository.save(orders)); + } + /** + * 虚拟商品发货 + * @param id + * @return + */ + @Override + public Result expressVirtual(Long id) { + SelfOrders orders = jpaRepository.findById(id).orElse(null); + if (orders.getIsExpress() != 2){ //是否需要发货(1需要发货 2无需发货) + return ResultUtil.error(-1, "非虚拟商品,发货失败"); + } + //虚拟商品发货,发货成功为确认收货,否则不做变化 + SelfGoodsVirtual v = this.sendExpress(orders); + if (v != null){ + orders.setVirtualId(v.getId()); //虚拟商品id + orders.setExpressTime(DateUtil.createTime()); //发货时间 + orders.setStatus(4); //确认收货 + SelfOrders save = jpaRepository.save(orders); + return ResultUtil.success(save); + }else { + return ResultUtil.error(-1, "虚拟商品库存不足:"+orders.getTitle()); + } + } + + /** + * 确认收货 + * @param id + * @return + */ + @Override + public Result orderConfirm(Long id) { + //1.订单设置已收货 + SelfOrders orders = jpaRepository.findById(id).orElse(null); + orders.setStatus(4); //4已收货 + orders.setFinishTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); //设置完成时间 + //2.订单分销 + List list = ordersRelationService.findByOrdersId(id); //订单关联的分销列表 + for (SelfOrderRelation s : list) { + //立刻到账 + s.setFinishTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + ordersRelationService.addMoney(s); + } + Long userId = orders.getUserId(); + //8.商品销量+1 + goodsService.salesAddOne(orders.getGoodsId()); + return ResultUtil.success(jpaRepository.save(orders)); + } + + + /** + * 零钱支付 + * @param id 订单id + * @return + */ + @Override + public Result changePay(String id) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String date=sdf.format(new Date()); + String[] ids = id.split(","); + for (String s : ids) { + //1.获取订单、用户信息 + SelfOrders orders = jpaRepository.findById(Long.valueOf(s)).orElse(null); + if(orders==null){ + continue; + } + double payMoney = orders.getPayMoney(); + UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(orders.getUserId()); + double money = userMoney.getMoney().doubleValue(); + if (payMoney > money){ + return ResultUtil.error(500,"钱包余额不足!"); + } + userMoneyService.updateMoney(2,orders.getUserId(),payMoney); + UserMoneyDetails userMoneyDetails=new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(orders.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setUserId(orders.getUserId()); + userMoneyDetails.setTitle("[购买商品]标题:"+orders.getTitle()); + userMoneyDetails.setContent("钱包支付:"+payMoney); + userMoneyDetails.setType(2); + userMoneyDetails.setMoney(BigDecimal.valueOf(payMoney)); + userMoneyDetails.setCreateTime(date); + userMoneyDetailsService.save(userMoneyDetails); + //订单分销 + this.fenXiao(orders); + //4.支付成功处理订单 + orders.setPayWay(6); //支付方式(1app微信 2微信公众号 3微信小程序 4app支付宝 5H5支付宝 6零钱) + orders.setPayTime(DateUtil.createTime()); //设置支付时间 + orders.setStatus(2); //订单状态(1待付款 2已付款 3已发货 4已收货 5已取消 6退款中 7已退款 8拒绝退款 9拼团中) + //虚拟商品处理 + if (orders.getOrderType() == 1) { //普通订单 + if (orders.getIsExpress() == 2){ //是否需要发货(1需要发货 2无需发货) + //虚拟商品发货,发货成功为确认收货,否则不做变化 + SelfGoodsVirtual v = this.sendExpress(orders); + if (v != null){ + orders.setVirtualId(v.getId()); //虚拟商品id + orders.setExpressTime(DateUtil.createTime()); //发货时间 + orders.setStatus(4); //确认收货 + } + }else if (orders.getIsExpress() == 3){ //核销订单 + orders.setStatus(3); //待收货、待使用 + } + } + jpaRepository.save(orders); + //执行物料包添加操作 + materialArtificerService.changePay(orders.getGoodsId(),orders.getUserId(),orders.getNumber()); + //公众号消息通知 + //userService.orderPay(orders.getUserId(), orders.getOrderNum(),orders.getPayMoney().toString(),orders.getCreateAt()); + } + return ResultUtil.success(); + } + + + /** + * 订单分销处理 + */ + @Override + public void fenXiao(SelfOrders o) { + //1.查询订单 + BigDecimal commissionPrice = o.getCommissionPrice(); //订单的佣金 + //2.查询订单用户 + UserEntity u = userService.selectUserById(o.getUserId()); + BigDecimal sum = commissionPrice; //计算可以分配佣金 + //分销金额不能0 + if (sum.doubleValue() < 0.01){ + return; + } + //4.判断有无上级 + String invitation = u.getInviterCode(); + UserEntity shangJiUser = userService.queryByInvitationCode(invitation); + if(shangJiUser!=null) { + BigDecimal rate=shangJiUser.getShopRate(); + BigDecimal myCommission = commissionPrice.multiply(rate); + SelfOrderRelation s = new SelfOrderRelation(); + s.setOrderId(o.getId()); + s.setStatus(1); + s.setPayMoney(o.getPayMoney()); + s.setGoodsId(o.getGoodsId()); + s.setGoodsImg(o.getImg()); + s.setGoodsTitle(o.getTitle()); + //不同部分:佣金不同、代理佣金、团队 + s.setUserId(shangJiUser.getUserId()); //团长id + s.setUserName(shangJiUser.getUserName()); //团长姓名 + s.setPhone(shangJiUser.getPhone()); //团长手机号 + s.setCommissionPrice(myCommission.doubleValue()); //佣金不同 + s.setCommissionMoney(commissionPrice.doubleValue()); //代理佣金 + s.setDetail("【直属购买】"+o.getTitle()); + s.setMoneyFrom(1); //直属 + s.setLowerUserId(u.getUserId()); + s.setLowerUserName(u.getUserName()); + ordersRelationService.saveBody(s); + /*invitation = shangJiUser.getInviterCode(); + UserEntity feiUser = userService.queryByInvitationCode(invitation); + if(feiUser!=null) { + rate=feiUser.getShopRate(); + myCommission = commissionPrice.multiply(rate); + SelfOrderRelation s2 = new SelfOrderRelation(); + s2.setOrderId(o.getId()); + s2.setStatus(1); + s2.setPayMoney(o.getPayMoney()); + s2.setGoodsId(o.getGoodsId()); + s2.setGoodsImg(o.getImg()); + s2.setGoodsTitle(o.getTitle()); + s2.setUserId(feiUser.getUserId()); //团长id + s2.setUserName(feiUser.getUserName()); //团长姓名 + s2.setPhone(feiUser.getPhone()); //团长手机号 + s2.setCommissionPrice(myCommission.doubleValue()); //佣金不同 + s2.setCommissionMoney(commissionPrice.doubleValue()); //代理佣金 + s2.setDetail("【非直属购买】"+o.getTitle()); + s2.setMoneyFrom(3); //非直属 + s2.setLowerUserId(u.getUserId()); + s2.setLowerUserName(u.getUserName()); + ordersRelationService.saveBody(s2); + }*/ + } + } + + + /** + * 检测支付 + * @param id + * @return + */ + @Override + public Result checkPay(Long id) { + SelfOrders one = jpaRepository.getOne(id); + if (one.getStatus() == 2){ + return ResultUtil.success(one); + } + return ResultUtil.error(-1, "未支付"); + } + + @Override + public SelfOrders findByOrderNum(String orderNum) { + return jpaRepository.findByOrderNum(orderNum); + } + + + //处理虚拟商品 + @Override + public SelfGoodsVirtual sendExpress(SelfOrders orders){ + //发送虚拟商品 + SelfGoodsVirtual v = selfGoodsVirtualService.sendGoods(orders.getGoodsId()); + if (v != null) { //有商品 + return v; + }else { //无商品时,后台管理发送发货提醒 + SelfOrderRemind r = new SelfOrderRemind(); + r.setOrdersId(orders.getId()); + r.setCreateTime(DateUtil.createTime()); + r.setStatus(1); + selfOrdersRemindJpaRepository.save(r); + return null; + } + } + + /** + * 发起退款 + * @param id + * @param refund + * @return + */ + @Override + public Result refund(Long id, String refund) { + SelfOrders orders = jpaRepository.findById(id).orElse(null); + if (orders.getIsExpress() == 2){ + return ResultUtil.error(-1, "虚拟商品不支持退款"); + } + orders.setRefund(refund); + orders.setOldStatus(orders.getStatus()); + orders.setStatus(6); //6退款中 + return ResultUtil.success(jpaRepository.save(orders)); + } + + /** + * 确认退款 + * @param id + * @return + */ + @Override + public Result refundMoney(Long id) { + boolean refund = true; + //1.获取订单 + SelfOrders orders = jpaRepository.findById(id).orElse(null); + Integer payWay = orders.getPayWay(); + //2.零钱支付退款 + if (payWay == 6){ //支付方式(1app微信 2微信公众号 3微信小程序 4app支付宝 5H5支付宝 6零钱) + //2.1用户信息 + //2.2用户零钱增加 + userMoneyService.updateMoney(1,orders.getUserId(),orders.getPayMoney()); + //2.3零钱增加明细 + UserMoneyDetails userMoneyDetails=new UserMoneyDetails(); + //查询用户当前余额 + UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(orders.getUserId()); + //插入余额 + userMoneyDetails.setBalance(userNowMoney.getMoney()); + //插入操作类型为已操作用户余额 + userMoneyDetails.setManipulateType(2); + userMoneyDetails.setUserId(orders.getUserId()); + userMoneyDetails.setTitle("[商品退款]标题:"+orders.getTitle()); + userMoneyDetails.setContent("自营商城退款,订单号:"+orders.getOrderNum()); + userMoneyDetails.setType(1); + userMoneyDetails.setMoney(BigDecimal.valueOf(orders.getPayMoney())); + userMoneyDetails.setCreateTime(DateUtil.createTime()); + userMoneyDetailsService.save(userMoneyDetails); + + }else if (payWay == 4 || payWay == 5){ + //3.支付宝退款 + refund = selfAliPayService.refund(id); + }else if (payWay == 1 || payWay == 2 || payWay == 3){ + //4.微信退款 + refund = selfWXService.refund(id); + } + //5.删除分销订单 + List list = ordersRelationService.findByOrdersId(id); //订单关联的分销列表 + for (SelfOrderRelation s : list) { + ordersRelationService.delete(s.getId()); + } + //6.处理订单已退款 + if (refund){ + orders.setStatus(7); //已退款 + jpaRepository.save(orders); + return ResultUtil.success(); + }else { + return ResultUtil.error(-1,"退款失败"); + } + } + + /** + * 拒绝退款 + * @param ordersId + * @param refusedRefund + * @return + */ + @Override + public Result refusedRefund(Long ordersId, String refusedRefund) { + SelfOrders order = jpaRepository.getOne(ordersId); + order.setStatus(order.getOldStatus()); + order.setRefusedRefund(refusedRefund); + order = jpaRepository.save(order); + return ResultUtil.success(order); + } + + @Override + public Result pendingOrder() { + return ResultUtil.success(ordersRepository.pendingOrder()); + } + + @Override + public Result remind(Long ordersId) { + SelfOrderRemind remind = selfOrdersRemindJpaRepository.findByOrdersId(ordersId); + if (remind != null){ + if (remind.getStatus() == 1){ + return ResultUtil.error(0, "已经提醒发货"); + }else { + remind.setStatus(1); + selfOrdersRemindJpaRepository.save(remind); + } + }else{ + SelfOrderRemind r = new SelfOrderRemind(); + r.setOrdersId(ordersId); + r.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + r.setStatus(1); + selfOrdersRemindJpaRepository.save(r); + } + return ResultUtil.success(); + } + + @Override + public Result remindOrder() { + // 构造自定义查询条件 + Specification queryCondition = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicateList = new ArrayList<>(); + predicateList.add(criteriaBuilder.equal(root.get("status"), 1)); + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + } + }; + List all = selfOrdersRemindJpaRepository.findAll(queryCondition); + for (SelfOrderRemind r : all) { + r.setStatus(2); + selfOrdersRemindJpaRepository.save(r); + } + return ResultUtil.success(all.size()); + } + + @Override + public List findByPayNum(String payNum) { + return jpaRepository.findByPayNum(payNum); + } + + /** + * 订单数量统计 + * @param userId + * @return + */ + @Override + public Result count(Long userId) { + Map map = new HashMap<>(); + int count1 = 0; + int count2 = 0; + int count3 = 0; + int count4 = 0; + int count5 = 0; + int count6 = 0; + int count7 = 0; + int count8 = 0; + //订单状态(1待付款 2已付款 3已发货 4已收货 5已取消 6退款中 7已退款 8拒绝退款 9拼团中 10已评价) + List list = ordersRepository.findByUserId(userId); + for (SelfOrders o : list) { + switch (o.getStatus()){ + case 1: count1++; break; + case 2: count2++; break; + case 3: count3++; break; + case 4: count4++; break; + case 5: count5++; break; + case 6: count6++; break; + case 7: count7++; break; + case 8: count8++; break; + } + } + map.put("count1", count1); //待付款 + map.put("count2", count2); //代发货 + map.put("count3", count3); //待收货 + map.put("count4", count4); //待评价 + map.put("count5", count5); //已取消 + map.put("count6", count6); //6退款中 + map.put("count7", count7); //7已退款 + map.put("count8", count8); //8拒绝退款 + return ResultUtil.success(map); + } + + @Override + public Result findExpress(String expressNumber) { + String appCode = commonRepository.findOne(103).getValue(); + String host = "https://wuliu.market.alicloudapi.com";// 【1】请求地址 支持http 和 https 及 WEBSOCKET + String path = "/kdi"; // 【2】后缀 + String appcode = appCode; // 【3】开通服务后 买家中心-查看AppCode + String no = expressNumber;// 【4】请求参数,详见文档描述 + String type = ""; // 【4】请求参数,不知道可不填 95%能自动识别 + String urlSend = host + path + "?no=" + no +"&type="+type; // 【5】拼接请求链接 + try { + URL url = new URL(urlSend); + HttpURLConnection httpURLCon = (HttpURLConnection) url.openConnection(); + httpURLCon .setRequestProperty("Authorization", "APPCODE " + appcode);// 格式Authorization:APPCODE (中间是英文空格) + int httpCode = httpURLCon.getResponseCode(); + if (httpCode == 200) { + String json = read(httpURLCon.getInputStream()); + return ResultUtil.success(JSON.parseObject(json)); + } else { + Map> map = httpURLCon.getHeaderFields(); + String error = map.get("X-Ca-Error-Message").get(0); + if (httpCode == 400 && error.equals("Invalid AppCode `not exists`")) { + System.out.println("AppCode错误 "); + } else if (httpCode == 400 && error.equals("Invalid Url")) { + System.out.println("请求的 Method、Path 或者环境错误"); + } else if (httpCode == 400 && error.equals("Invalid Param Location")) { + System.out.println("参数错误"); + } else if (httpCode == 403 && error.equals("Unauthorized")) { + System.out.println("服务未被授权(或URL和Path不正确)"); + } else if (httpCode == 403 && error.equals("Quota Exhausted")) { + System.out.println("套餐包次数用完 "); + } else { + System.out.println("参数名错误 或 其他错误"); + System.out.println(error); + } + } + } catch (MalformedURLException e) { + System.out.println("URL格式错误"); + } catch (UnknownHostException e) { + System.out.println("URL地址错误"); + } catch (Exception e) { + e.printStackTrace(); + } + return ResultUtil.error(-1, "查询失败"); + } + + /* + * 读取返回结果 + */ + private static String read(InputStream is) throws IOException { + StringBuffer sb = new StringBuffer(); + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + String line = null; + while ((line = br.readLine()) != null) { + line = new String(line.getBytes(), "utf-8"); + sb.append(line); + } + br.close(); + return sb.toString(); + } +} diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/SelfWXServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/SelfWXServiceImpl.java new file mode 100644 index 0000000..89ac6e3 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/service/impl/SelfWXServiceImpl.java @@ -0,0 +1,341 @@ +package com.sqx.modules.shopping.service.impl; + +import com.github.wxpay.sdk.WXPay; +import com.github.wxpay.sdk.WXPayConstants; +import com.github.wxpay.sdk.WXPayUtil; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.common.entity.CommonInfo; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.pay.config.WXConfig; +import com.sqx.modules.shopping.dao.OrdersJpaRepository; +import com.sqx.modules.shopping.entity.SelfGoods; +import com.sqx.modules.shopping.entity.SelfGoodsVirtual; +import com.sqx.modules.shopping.entity.SelfOrders; +import com.sqx.modules.shopping.service.GoodsService; +import com.sqx.modules.shopping.service.OrdersService; +import com.sqx.modules.shopping.service.SelfGoodsVirtualService; +import com.sqx.modules.shopping.service.SelfWXService; +import com.sqx.modules.shopping.utils.AmountCalUtil; +import com.sqx.modules.shopping.utils.DateUtil; +import com.sqx.modules.shopping.utils.WXConfigUtil; +import com.sqx.modules.utils.HttpClientUtil; +import com.sqx.modules.utils.MD5Util; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletRequest; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@Service +public class SelfWXServiceImpl implements SelfWXService { + private static final String TRADE_TYPE_APP = "APP"; + private static final String TRADE_TYPE_NATIVE = "NATIVE"; + private static final String TRADE_TYPE_JSAPI = "JSAPI"; + private static final String Wap = "MWEB"; + + private final Logger log = LoggerFactory.getLogger(SelfWXServiceImpl.class); + + @Autowired + private CommonInfoService commonRepository; + @Autowired + private OrdersService ordersService; + @Autowired + private OrdersJpaRepository ordersJpaRepository; + @Autowired + private GoodsService goodsService; + @Autowired + private UserService userService; + + /** + * 微信支付 + * @param ordersId 订单id + * @param type 类型 1App支付 2Web支付 + * @return + * @throws Exception + */ + @Override + @Transactional + public Map doUnifiedOrder(Long ordersId, Integer type,HttpServletRequest request) throws Exception { + String url; + CommonInfo one2 = commonRepository.findOne(19); + if(type==1){ + url=one2.getValue()+"/sqx_fast/pay/notify"; + }else if(type == 2 || type == 4){ + url=one2.getValue()+"/sqx_fast/pay/notifyjs"; + }else{ + url=one2.getValue()+"/sqx_fast/pay/notifys"; + } + log.info("回调地址:"+url); + //获取订单 + SelfOrders orders = ordersJpaRepository.findById(ordersId).orElse(null); + //校验金额是否一致 + SelfGoods byId = goodsService.findById(orders.getGoodsId()); + if(!byId.getStatus().equals(1)){ + ordersJpaRepository.deleteById(ordersId); + throw new Exception("订单信息错误,请重新下单!"); + } + UserEntity userById = userService.selectUserById(orders.getUserId()); + Double aDouble=0.00; + if(userById.getMember()==null || userById.getMember()!=1){ + aDouble = AmountCalUtil.moneyMul(byId.getPrice(), orders.getNumber()); + }else{ + aDouble = AmountCalUtil.moneyMul(byId.getMemberPrice(), orders.getNumber()); + } + aDouble= AmountCalUtil.add(aDouble,byId.getPostagePrice()); + if(!orders.getPayMoney().equals(aDouble)){ + ordersJpaRepository.deleteById(ordersId); + throw new Exception("订单信息错误,请重新下单!"); + } + String outTradeNo = orders.getOrderNum(); + WXConfig config = new WXConfig(); + if(type==1){ + config.setAppId(commonRepository.findOne(260).getValue());//微信商户key + config.setKey(commonRepository.findOne(245).getValue()); + //微信商户号mchId + config.setMchId(commonRepository.findOne(246).getValue()); + }else if(type==2 || type == 4){ + config.setAppId(commonRepository.findOne(5).getValue()); + //微信商户key + config.setKey(commonRepository.findOne(75).getValue()); + //微信商户号mchId + config.setMchId(commonRepository.findOne(76).getValue()); + }else{ + config.setAppId(commonRepository.findOne(243).getValue()); + //微信商户key + config.setKey(commonRepository.findOne(245).getValue()); + //微信商户号mchId + config.setMchId(commonRepository.findOne(246).getValue()); + } + config.setKey(commonRepository.findOne(75).getValue()); + config.setMchId(commonRepository.findOne(76).getValue()); + String generateNonceStr = WXPayUtil.generateNonceStr(); + WXPay wxpay = new WXPay(config); + Map data = new HashMap<>(); + data.put("appid", config.getAppID()); + data.put("mch_id", config.getMchID()); + data.put("nonce_str",generateNonceStr ); + data.put("body", orders.getTitle()); + //生成商户订单号,不可重复 + data.put("out_trade_no", outTradeNo); + data.put("total_fee", new Double(orders.getPayMoney()*100).intValue()+""); //1块等于微信支付传入100); + //自己的服务器IP地址 + //异步通知地址(请注意必须是外网) + data.put("notify_url", url); + //交易类型 + if (type ==2){ + data.put("openid",userById.getWxOpenId()); + }else if(type ==3){ + data.put("openid",userById.getArtificerOpenId()); + } + if (type == 1) { + data.put("trade_type", TRADE_TYPE_APP); + } else if (type == 2) { + data.put("trade_type", TRADE_TYPE_JSAPI); + } else if (type == 3) { + data.put("trade_type", TRADE_TYPE_JSAPI); + } else { + data.put("trade_type", Wap); + data.put("spbill_create_ip", HttpClientUtil.getIpAddress(request)); + } + //附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据 + data.put("attach", ""); + data.put("sign", WXPayUtil.generateSignature(data, config.getKey(), WXPayConstants.SignType.MD5)); + //使用官方API请求预付订单 + Map response = wxpay.unifiedOrder(data); + for (String key : response.keySet()) { + log.error("key= "+ key + " and value= " + response.get(key)); + } + if ("SUCCESS".equals(response.get("return_code"))) {//主要返回以下5个参数 + if(type==1){ + Map param = new HashMap<>(); + param.put("appid", config.getAppID()); + param.put("partnerid", response.get("mch_id")); + param.put("prepayid", response.get("prepay_id")); + param.put("package", "Sign=WXPay"); + param.put("noncestr", WXPayUtil.generateNonceStr()); + param.put("timestamp", System.currentTimeMillis() / 1000 + ""); + param.put("sign", WXPayUtil.generateSignature(param, config.getKey(), + WXPayConstants.SignType.MD5)); + param.put("outtradeno", outTradeNo); + param.put("signType", "MD5"); + return param; + }else{ + Map param = new HashMap<>(); + param.put("appid", config.getAppID()); + param.put("partnerid", response.get("mch_id")); + param.put("prepayid", response.get("prepay_id")); + param.put("noncestr", generateNonceStr); + String timestamp = System.currentTimeMillis() / 1000 + ""; + param.put("timestamp",timestamp); + /*param.put("sign", WXPayUtil.generateSignature(param, config.getKey(), + WXPayConstants.SignType.MD5));*/ + String stringSignTemp = "appId=" + config.getAppID() + "&nonceStr=" + generateNonceStr + "&package=prepay_id=" + response.get("prepay_id") + "&signType=MD5&timeStamp=" + timestamp+ ""+"&key="+config.getKey(); + String sign = MD5Util.md5Encrypt32Upper(stringSignTemp).toUpperCase(); + param.put("sign",sign); + param.put("outtradeno", outTradeNo); + param.put("package", "prepay_id="+response.get("prepay_id"));//给前端返回的值 + param.put("mweb_url", response.get("mweb_url")); + param.put("trade_type", response.get("trade_type")); + param.put("return_msg", response.get("return_msg")); + param.put("result_code", response.get("result_code")); + param.put("signType", "MD5"); + return param; + } + } + throw new Exception("下单失败"); + } + + @Override + public String payBack(String resXml,Integer type) { + WXConfigUtil config = null; + try { + config = new WXConfigUtil(); + } catch (Exception e) { + e.printStackTrace(); + } + if(type==1){ + config.setAppId(commonRepository.findOne(260).getValue());//微信商户key + config.setKey(commonRepository.findOne(245).getValue()); + //微信商户号mchId + config.setMchId(commonRepository.findOne(246).getValue()); + }else if(type==2 || type == 4){ + config.setAppId(commonRepository.findOne(5).getValue()); + //微信商户key + config.setKey(commonRepository.findOne(75).getValue()); + //微信商户号mchId + config.setMchId(commonRepository.findOne(76).getValue()); + }else{ + config.setAppId(commonRepository.findOne(243).getValue()); + //微信商户key + config.setKey(commonRepository.findOne(245).getValue()); + //微信商户号mchId + config.setMchId(commonRepository.findOne(246).getValue()); + } + WXPay wxpay = new WXPay(config); + String xmlBack = ""; + Map notifyMap = null; + try { + notifyMap = WXPayUtil.xmlToMap(resXml); // 调用官方SDK转换成map类型数据 + if (wxpay.isPayResultNotifySignatureValid(notifyMap)) {//验证签名是否有效,有效则进一步处理 + + String return_code = notifyMap.get("return_code");//状态 + String out_trade_no = notifyMap.get("out_trade_no");//商户订单号 + if ("SUCCESS".equals(return_code)) { + if (out_trade_no != null) { + //支付回调 + this.wxPayBack(out_trade_no); + System.err.println("微信手机支付回调成功订单号:" + out_trade_no + ""); + xmlBack = "" + "" + "" + " "; + } else { +// System.err.println("微信手机支付回调成功订单号:" + out_trade_no + ""); + xmlBack = "" + "" + "" + " "; + } + }else{ + } + return xmlBack; + } else { + // 签名错误,如果数据里没有sign字段,也认为是签名错误 + System.err.println("手机支付回调通知签名错误"); + xmlBack = "" + "" + "" + " "; + return xmlBack; + } + } catch (Exception e) { + System.err.println("手机支付回调通知失败" + e); + xmlBack = "" + "" + "" + " "; + } + return xmlBack; + } + + + + @Override + public boolean refund(Long ordersId){ + + SelfOrders orders = ordersJpaRepository.getOne(ordersId); + WXConfigUtil config = null; + log.info("证书"); + try { + config = new WXConfigUtil(); + } catch (Exception e) { + e.printStackTrace(); + } + config.setAppId(commonRepository.findOne(74).getValue()); + config.setKey(commonRepository.findOne(75).getValue()); + config.setMchId(commonRepository.findOne(76).getValue()); + WXPay wxpay = new WXPay(config); + Map data = new HashMap<>(); + data.put("appid", config.getAppID()); + data.put("mch_id", config.getMchID()); + data.put("nonce_str", WXPayUtil.generateNonceStr()); + log.info("签名"); + try{ + data.put("sign", WXPayUtil.generateSignature(data, config.getKey(), WXPayConstants.SignType.MD5)); + }catch (Exception e){ + e.printStackTrace(); + return false; + } + data.put("out_trade_no", orders.getOrderNum()); //订单号 + data.put("out_refund_no", orders.getOrderNum()); //退款单号 + data.put("total_fee", new Double(orders.getPayMoney()*100).intValue()+""); //1块等于微信支付传入100); + data.put("refund_fee", new Double(orders.getPayMoney()*100).intValue()+""); //1块等于微信支付传入100); + //使用官方API退款 + try{ + Map response = wxpay.refund(data); + if ("SUCCESS".equals(response.get("return_code"))) {//主要返回以下5个参数 + return true; + }else { + return false; + } + }catch (Exception e){ + log.info("返回"); + e.printStackTrace(); + return false; + } + } + + @Autowired + private SelfGoodsVirtualService selfGoodsVirtualService; + + /** + * 支付成功业务 + */ + public void wxPayBack(String out_trade_no){ + log.info("支付回调,单号:"+out_trade_no); + //支付成功,处理业务:处理多个订单 + SelfOrders orders = ordersService.findByOrderNum(out_trade_no); + if (orders.getStatus() != 1){ + log.info("订单回调重复:"+orders.toString()); + return; + } + //1.订单业务 + orders.setPayWay(1); //支付方式(1微信 2支付宝 3零钱) + orders.setPayTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); //设置支付时间 + orders.setStatus(2); //2已付款 +// if (orders.getIsExpress() == 2){ +// orders.setStatus(9); +// } + //5.虚拟商品处理 + if (orders.getIsExpress() == 2){ //是否需要发货(1需要发货 2无需发货) + //虚拟商品发货,发货成功为确认收货,否则不做变化 + SelfGoodsVirtual v = selfGoodsVirtualService.sendGoods(orders.getGoodsId()); + if (v != null){ + orders.setVirtualId(v.getId()); //虚拟商品id + orders.setExpressTime(DateUtil.createTime()); //发货时间 + orders.setFinishTime(DateUtil.createTime()); //收货时间 + orders.setStatus(4); //确认收货 +// System.err.println("虚拟商品发货成功:" + out_trade_no + ""); + log.info("虚拟商品发货成功,单号:"+out_trade_no); + } + } + ordersJpaRepository.save(orders); + + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/utils/AmountCalUtil.java b/src/main/java/com/sqx/modules/shopping/utils/AmountCalUtil.java new file mode 100644 index 0000000..f427f65 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/utils/AmountCalUtil.java @@ -0,0 +1,62 @@ +package com.sqx.modules.shopping.utils; + + +import org.apache.commons.lang3.StringUtils; + +import java.math.BigDecimal; +import java.text.DecimalFormat; + +/** + * 金额计算工具类 + * @author fang + * @date 2020-04-17 + */ +public class AmountCalUtil { + + + //金额计算 加法 + public static double add(double value1,double value2){ + BigDecimal b1 = new BigDecimal(Double.valueOf(value1)); + BigDecimal b2 = new BigDecimal(Double.valueOf(value2)); + return b1.add(b2).doubleValue(); + } + + //金额计算 减法 + public static Double sub(double v1, double v2) { + BigDecimal n1 = new BigDecimal(Double.toString(v1)); + BigDecimal n2 = new BigDecimal(Double.toString(v2)); + return n1.subtract(n2).doubleValue(); + } + + //金额计算 乘法 + public static Double mul(double v1, double v2) { + BigDecimal n1 = new BigDecimal(Double.toString(v1)); + BigDecimal n2 = new BigDecimal(Double.toString(v2)); + return n1.multiply(n2).doubleValue(); + } + + //金额计算 除法 + public static Double divide(double v1, double v2) { + BigDecimal n1 = new BigDecimal(Double.toString(v1)); + BigDecimal n2 = new BigDecimal(Double.toString(v2)); + return n1.divide(n2, 10, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + + private final static DecimalFormat df = new DecimalFormat("######0.00"); + //金额计算乘法,保留小数点后两位 + public static Double moneyMul(double v1, double v2){ + BigDecimal n1 = new BigDecimal(Double.toString(v1)); + BigDecimal n2 = new BigDecimal(Double.toString(v2)); + double v = n1.multiply(n2).doubleValue(); + return Double.parseDouble(df.format(v)); + } + //金额计算乘法,保留小数点后两位 + public static Double moneySum(String sum){ + if (StringUtils.isEmpty(sum)){ + sum = "0"; + } + double v = Double.parseDouble(sum); + return Double.parseDouble(df.format(v)); + } + +} diff --git a/src/main/java/com/sqx/modules/shopping/utils/DateUtil.java b/src/main/java/com/sqx/modules/shopping/utils/DateUtil.java new file mode 100644 index 0000000..8b0259d --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/utils/DateUtil.java @@ -0,0 +1,439 @@ +package com.sqx.modules.shopping.utils; + +import org.apache.commons.lang3.StringUtils; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +public class DateUtil { + /** + * 判断是否是购物节日期 + * @param date + * @return true 是 + */ + public static boolean isShoppingFestival(Date date){ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + int month = calendar.get(Calendar.MONTH)+1; + int day = calendar.get(Calendar.DAY_OF_MONTH); + + //判断是否是双十一 + if(month==11 && day==11){ + return true; + } + + //判断是否是双十二 + if(month==12 && day==12){ + return true; + } + + return false; + } + + /** + * 获取两个日期之间左右年月 + * @param minDate + * @param maxDate + * @return + * @throws ParseException + */ + public static List getMonthBetween(Date minDate, Date maxDate) throws ParseException { + ArrayList result = new ArrayList(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");//格式化为年月 + + Calendar min = Calendar.getInstance(); + Calendar max = Calendar.getInstance(); + + min.setTime(minDate); + min.set(min.get(Calendar.YEAR), min.get(Calendar.MONTH), 1); + + max.setTime(maxDate); + max.set(max.get(Calendar.YEAR), max.get(Calendar.MONTH), 2); + + Calendar curr = min; + while (curr.before(max)) { + result.add(sdf.format(curr.getTime())); + curr.add(Calendar.MONTH, 1); + } + + return result; + } + + /** + * 获取指定月份天数 + * @param year 年份(四位数) + * @param month 月份(从1开始) + * @return + */ + public static int getMonthDays(int year, int month) { + if (month == 2) { + if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) { + return 29; + } else { + return 28; + } + } else if (month == 4 || month == 6 || month == 9 || month == 11) { + return 30; + } else { + return 31; + } + } + + /** + * 判断时间是否在时间段内 + * + * @param date + * 当前时间 yyyy-MM-dd HH:mm:ss + * @param strDateBegin + * 开始时间 00:00 + * @param strDateEnd + * 结束时间 00:05 + * @return 在时间段内返回true + */ + public static boolean isInDate(Date date, String strDateBegin, String strDateEnd) { + + if(date==null || StringUtils.isBlank(strDateBegin) || StringUtils.isBlank(strDateEnd)){ + return false; + } + + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); + String strDate = sdf.format(date); + // 截取当前时间时分秒 + int strDateH = Integer.parseInt(strDate.substring(0, 2)); + int strDateM = Integer.parseInt(strDate.substring(3, 5)); + // 截取开始时间时分秒 + int strDateBeginH = Integer.parseInt(strDateBegin.substring(0, 2)); + int strDateBeginM = Integer.parseInt(strDateBegin.substring(3, 5)); + // 截取结束时间时分秒 + int strDateEndH = Integer.parseInt(strDateEnd.substring(0, 2)); + int strDateEndM = Integer.parseInt(strDateEnd.substring(3, 5)); + + if(strDateH >= strDateBeginH && strDateH <= strDateEndH){ + + //判断开始时间和结束时间的小时是否一样 + if(strDateBeginH == strDateEndH){ //是 + + // + if(strDateH == strDateBeginH){ + if(strDateM >= strDateBeginM && strDateM <= strDateEndM){ + return true; + } + }else{ + return false; + } + + }else{ //否 + + if(strDateH == strDateBeginH){ + + if(strDateM >= strDateBeginM){ + return true; + }else{ + return false; + } + + }else if(strDateH == strDateEndH){ + + if(strDateM <= strDateEndM){ + return true; + }else{ + return false; + } + + }else{ + return true; + } + + } + }else{ + return false; + } + + return false; + } + /** + * + * @param pattern,字符串的format格式,例如:yyyy-MM-dd HH:mm:ss + * @param date,需要转换为指定格式的日期对象 + * @return + */ + public static String getFormatStrByPatternAndDate(String pattern,Date date){ + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); + return simpleDateFormat.format(date); + } + public static Date getDataByFormatString(String pattern,String dateFormatStr){ + try { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); + return simpleDateFormat.parse(dateFormatStr); + } catch (ParseException e) { + e.printStackTrace(); + return null; + } + } + + /** + * 将日期的时分秒转为 00:00:00 + * @param date + * @return + * @throws + */ + public static Date lowDate(Date date){ + String lowDate = getFormatStrByPatternAndDate("yyyy-MM-dd",date) + " 00:00:00"; + return getDataByFormatString("yyyy-MM-dd HH:mm:ss",lowDate); + } + + /** + * 将日期的时分秒转为 23:59:59 + * @param date + * @return + * @throws ParseException + */ + public static Date hightDate(Date date){ + String lowDate = getFormatStrByPatternAndDate("yyyy-MM-dd",date) + " 23:59:59"; + return getDataByFormatString("yyyy-MM-dd HH:mm:ss",lowDate); + } + + /** + * 计算d1 到 d2 相差多少时间 + * @param d1 未来的时间 + * @param d2 现在的时间 + * @return 数组下标 0 天 1 时 2 分 3 秒 + */ + public static long[] dateDiff(Date d1, Date d2) throws ParseException { + long nd = 1000*24*60*60;//一天的毫秒数 + long nh = 1000*60*60;//一小时的毫秒数 + long nm = 1000*60;//一分钟的毫秒数 + long ns = 1000;//一秒钟的毫秒数 + //获得两个时间的毫秒时间差异 + long diff = d1.getTime() - d2.getTime(); + long day = diff/nd;//计算差多少天 + long hour = diff%nd/nh;//计算差多少小时 + long min = diff%nd%nh/nm;//计算差多少分钟 + long sec = diff%nd%nh%nm/ns;//计算差多少秒 + return new long[]{day,hour,min,sec}; + } + + /** + * 判断 start 是否大于 end + * @param start + * @param end + * @return + * @throws ParseException + */ + public static boolean startThanEnd(Date start, Date end) throws ParseException{ + long[] result = dateDiff(start, end); + if(result[0]>=0 && result[1]>=0 && result[2]>=0 && result[3]>=0){ + return true; + } + return false; + } + + /** + * 获取指定日期指定分钟后的日期 + * @param date + * @param minute + * @return + */ + public static Date getLaterMinute(Date date, Long minute) { + minute = minute == null ? 0 : minute; + long curren = date.getTime(); + curren += minute * 60 * 1000; + return new Date(curren); + } + + /** + * 获取指定日期指定分钟前的日期 + * @param date + * @param minute + * @return + */ + public static Date getPreviouslyMinute(Date date, Long minute) { + minute = minute == null ? 0 : minute; + long curren = date.getTime(); + curren -= minute * 60 * 1000; + return new Date(curren); + } + + /** + * 获取指定日期指定天数后的日期 + * @param date 指定的时间 + * @param later 指定的天数 + * @return + */ + public static Date getLaterDay(Date date, Long later){ + later = later == null ? 0 : later; + long current = date.getTime(); + return new Date(current + later * 24 * 60 * 60 * 1000); + } + + + /** + * 获取指定日期指定天数前的日期 + * @param date 指定的时间 + * @param later 指定的天数 + * @return + */ + public static Date getPreviouslyDay(Date date, Long later){ + later = later == null ? 0 : later; + long current = date.getTime(); + return new Date(current - later * 24 * 60 * 60 * 1000); + } + + /** + * 获取指定日期指定小时后的日期 + * @param date 指定的时间 + * @param later 指定的小时 + * @return + */ + public static Date getLaterHour(Date date, Long later){ + later = later == null ? 0 : later; + long current = date.getTime(); + return new Date(current + later * 60 * 60 * 1000); + } + + /** + * 获取指定日期指定小时前的日期 + * @param date 指定的时间 + * @param later 指定的小时 + * @return + */ + public static Date getPreviouslyHour(Date date, Long later){ + later = later == null ? 0 : later; + long current = date.getTime(); + return new Date(current - later * 60 * 60 * 1000); + } + + /** + * 得到本周周一 + * @return + */ + public static Date getMondayOfWeek() { + Calendar c = Calendar.getInstance(); + int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1; + if (day_of_week == 0){ + day_of_week = 7; + } + c.add(Calendar.DATE, -day_of_week + 1); + return c.getTime(); + } + + /** + * 得到本周周日 + * @return + */ + public static Date getSundayOfWeek() { + Calendar c = Calendar.getInstance(); + int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1; + if (day_of_week == 0){ + day_of_week = 7; + } + c.add(Calendar.DATE, -day_of_week + 7); + return c.getTime(); + } + + /** + * 获取当前月的第一天 + * @return + */ + public static Date getFirstDayOfMonth(){ + Calendar c = Calendar.getInstance(); + c.add(Calendar.MONTH, 0); + c.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天 + return c.getTime(); + } + + /** + * 获取当前月的最后一天 + * @return + */ + public static Date getLastDayOfMonth(){ + Calendar ca = Calendar.getInstance(); + ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH)); + return ca.getTime(); + } + + /** + * 获取上一个月的第一天 + * @return + */ + public static Date getFirstDayOfPreviouslyMonth(){ + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, -1); + calendar.set(Calendar.DAY_OF_MONTH,1); + return calendar.getTime(); + } + + /** + * 获取上一个月的最后一天 + * @return + */ + public static Date getLastDayOfPreviouslyMonth(){ + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.DAY_OF_MONTH, 0); + return calendar.getTime(); + } + + /** + * 获取上上一个月的第一天 + * @return + */ + public static Date getFirstDayOfPPreviouslyMonth(){ + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, -2); + calendar.set(Calendar.DAY_OF_MONTH,1); + return calendar.getTime(); + } + + /** + * 获取上上一个月的最后一天 + * @return + */ + public static Date getLastDayOfPPreviouslyMonth(){ + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, -1); + calendar.set(Calendar.DAY_OF_MONTH, 0); + return calendar.getTime(); + } + + /** + * 获取指定日期是星期几 + * @param date + * @return + */ + public static int getDayOfWeek(Date date) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + //一周第一天是否为星期天 + boolean isFirstSunday = (cal.getFirstDayOfWeek() == Calendar.SUNDAY); + //获取周几 + int weekDay = cal.get(Calendar.DAY_OF_WEEK); + //若一周第一天为星期天,则-1 + if (isFirstSunday) { + weekDay = weekDay - 1; + if (weekDay == 0) { + weekDay = 7; + } + } + return weekDay; + } + + /** + * 获取创建时间 + * @return + */ + public static String createTime() { + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + } + + /** + * 获取创建时间 + * @return + */ + public static String createDate() { + return new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + } +} diff --git a/src/main/java/com/sqx/modules/shopping/utils/ExceptionEnum.java b/src/main/java/com/sqx/modules/shopping/utils/ExceptionEnum.java new file mode 100644 index 0000000..54d27fd --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/utils/ExceptionEnum.java @@ -0,0 +1,49 @@ +package com.sqx.modules.shopping.utils; + +public enum ExceptionEnum { + UNKNOW_ERROR(-1, "未知错误"), + LIMIT_USER(-100, "账号已经禁用,请联系管理员!"), + USER_NOT_FIND(-101, "用户未注册"), + USER_IS_BIND_FOR_ANTHER_OPENID(-99, "当前手机号已经被其他微信绑定"), + WRONT_TOKEN(-102, "用户信息失效,请重新登录"), + USER_PWD_EMPTY(-103, "用户名密码不能为空"), + USER_PWD_ERROR(-104, "用户名或密码错误"), + USER_IS_EXITS(-105, "手机号已经注册!"), + ERROR(-106, "服务器内部错误"), + UPDATE_PWD_ERROR(-107, "密码修改失败"), + STATE_PWD_ERROR(-108, "状态修改失败"), + DATA_EMPTY(-109, "添加数据不能为空"), + Return_ATA_EMPTY(-110, "暂无数据"), + ADD_ERROR(-111, "提现失败"), + CODE_ERROR(-112, "验证码不正确"), + BIND_ERROR(-113, "手机号已经被其他账号绑定"), + SEND_ERROR(-114, "验证码发送失败"), + USER_PHONE_ERROR(-115, "用户名不能为空"), + OLD_PWD_ERROR(-116, "原始密码错误"), + IS_REGISTER(-117, "当前手机号已经绑定其他微信账号"), + IS_BIND(-118, "当前淘宝账号已经绑定其他手机号"), + IS_BIND_RELATION(-119, "当前账号已经绑定其他淘宝账号"), + OLD_NOT_SAME_NEW_PWD_ERROR(-120, "新密码不能等于和原始密码一致"), + USER_IS_REGISTER(-121, "用户已经注册请前往登录"), + RELATIONID_IS_REGISTER(-122, "淘宝账号已经授权绑定其他手机号"), + CODE_NOT_FOUND(-123, "邀请码不存在"), + COMMON_IS_EXITS(-124, "已经存在"), + COUPONS_ZERO(-125, "优惠券被领完了"), + COUPONS_GET_OUT(-126, "优惠券超过领取次数"), + COUPONS_TIME_OUT(-127, "优惠券已过期"); + private Integer code; + private String msg; + ExceptionEnum(Integer code, String msg) { + this.code = code; + this.msg = msg; + } + + public Integer getCode() { + return code; + } + + public String getMsg() { + return msg; + } +} + diff --git a/src/main/java/com/sqx/modules/shopping/utils/Result.java b/src/main/java/com/sqx/modules/shopping/utils/Result.java new file mode 100644 index 0000000..3278073 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/utils/Result.java @@ -0,0 +1,51 @@ +package com.sqx.modules.shopping.utils; + +public class Result { + + // error_code 状态值:0 极为成功,其他数值代表失败 + private Integer status; + + // error_msg 错误信息,若status为0时,为success + private String msg; + + // content 返回体报文的出参,使用泛型兼容不同的类型 + private T data; + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer code) { + this.status = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public T getData(Object object) { + return data; + } + + public void setData(T data) { + this.data = data; + } + + public T getData() { + return data; + } + + @Override + public String toString() { + return "Result{" + + "status=" + status + + ", msg='" + msg + '\'' + + ", data=" + data + + '}'; + + } +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/shopping/utils/ResultUtil.java b/src/main/java/com/sqx/modules/shopping/utils/ResultUtil.java new file mode 100644 index 0000000..0c6144e --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/utils/ResultUtil.java @@ -0,0 +1,64 @@ +package com.sqx.modules.shopping.utils; + +public class ResultUtil { + + /** + * 返回成功,传入返回体具体出參 + * + * @param object + * @return + */ + public static Result success(Object object) { + Result result = new Result(); + result.setStatus(0); + result.setMsg("success"); + result.setData(object); + return result; + } + + + public static Result successMsg(String msg) { + Result result = new Result(); + result.setStatus(0); + result.setMsg(msg); + return result; + } + + /** + * 提供给部分不需要出參的接口 + * + * @return + */ + public static Result success() { + return success(null); + } + + /** + * 自定义错误信息 + * + * @param code + * @param msg + * @return + */ + public static Result error(Integer code, String msg) { + Result result = new Result(); + result.setStatus(code); + result.setMsg(msg); + result.setData(null); + return result; + } + + /** + * 返回异常信息,在已知的范围内 + * + * @param exceptionEnum + * @return + */ + public static Result error(ExceptionEnum exceptionEnum) { + Result result = new Result(); + result.setStatus(exceptionEnum.getCode()); + result.setMsg(exceptionEnum.getMsg()); + result.setData(null); + return result; + } +} diff --git a/src/main/java/com/sqx/modules/shopping/utils/WXConfigUtil.java b/src/main/java/com/sqx/modules/shopping/utils/WXConfigUtil.java new file mode 100644 index 0000000..6201f5d --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/utils/WXConfigUtil.java @@ -0,0 +1,78 @@ +package com.sqx.modules.shopping.utils; + +import com.github.wxpay.sdk.WXPayConfig; +import lombok.Data; +import org.apache.commons.io.IOUtils; +import org.springframework.core.io.ClassPathResource; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +/** + * @author fang + * @date 2020/2/26 + */ +@Data +public class WXConfigUtil implements WXPayConfig { + private byte[] certData; + private String appId = ""; + private String key = ""; + private String mchId = ""; + + + //初始化加载证书 + public WXConfigUtil() throws Exception { + /*int byteread = 0; + int bytesum = 0; + URL url = new URL("windine.blogdriver.com/logo.gif"); + *//*String certPath = ClassUtils.getDefaultClassLoader().getResource("").getPath()+"/weixin/apiclient_cert.p12";//从微信商户平台下载的安全证书存放的路径*//* + URLConnection conn = url.openConnection(); + InputStream inStream = conn.getInputStream(); + FileOutputStream fs = new FileOutputStream(" /www/wwwroot/"+profileHttpUrl+"/file/uploadPath"); + byte[] buffer = new byte[1204]; + int length; + while ((byteread = inStream.read(buffer)) != -1) { + bytesum += byteread; + fs.write(buffer, 0, byteread); + }*/ + ClassPathResource classPathResource = new ClassPathResource("weixin/apiclient_cert.p12"); + InputStream certStream = classPathResource.getInputStream(); + this.certData = IOUtils.toByteArray(certStream); + certStream.read(this.certData); + certStream.close(); +// File file = new File(" "); + /*InputStream certStream = new FileInputStream(file); + this.certData = new byte[(int) file.length()]; + certStream.read(this.certData); + certStream.close();*/ + } + + + @Override + public String getAppID() { + return this.appId; + } + + @Override + public String getMchID() { + return this.mchId; + } + + @Override + public InputStream getCertStream() { + ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData); + return certBis; + } + + @Override + public int getHttpConnectTimeoutMs() { + return 8000; + } + + @Override + public int getHttpReadTimeoutMs() { + return 10000; + } + + +} diff --git a/src/main/java/com/sqx/modules/shopping/utils/excel/ExcelData.java b/src/main/java/com/sqx/modules/shopping/utils/excel/ExcelData.java new file mode 100644 index 0000000..aa75ee5 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/utils/excel/ExcelData.java @@ -0,0 +1,34 @@ +package com.sqx.modules.shopping.utils.excel; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author fang + * @date 2020/9/24 + */ + +@Data +public class ExcelData implements Serializable { + + private static final long serialVersionUID = 4454016249210520899L; + + /** + * 表头 + */ + private List titles; + + /** + * 数据 + */ + private List> rows; + + /** + * 页签名称 + */ + private String name; + + +} diff --git a/src/main/java/com/sqx/modules/shopping/utils/excel/ExcelUtils.java b/src/main/java/com/sqx/modules/shopping/utils/excel/ExcelUtils.java new file mode 100644 index 0000000..8a904b8 --- /dev/null +++ b/src/main/java/com/sqx/modules/shopping/utils/excel/ExcelUtils.java @@ -0,0 +1,171 @@ +package com.sqx.modules.shopping.utils.excel; + +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.http.entity.ContentType; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.commons.CommonsMultipartFile; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; + +/** + * @author fang + * @date 2021/1/27 + */ +@Slf4j +public class ExcelUtils { + + /*public static List get(String fileUrl){ + MultipartFile fileItem = createFileItem(fileUrl, null); + String substring = fileUrl.substring(fileUrl.lastIndexOf(".")); + List list=new ArrayList<>(); + try { +// String fileName = fileItem.getOriginalFilename(); + String xls=".xlsx"; + InputStream inputStream = fileItem.getInputStream(); + log.info("文件名:{}", substring); + int serviceStationNo=0; + int serviceStationName=0; + int oilName=0; + int activity=0; + int downPrice=0; + //区分两种excel表格 + if(substring.indexOf(xls)!=-1){ + XSSFWorkbook workbook=new XSSFWorkbook(inputStream); + //获取第一个工作表 + org.apache.poi.xssf.usermodel.XSSFSheet hs=workbook.getSheetAt(0); + //获取Sheet的第一个行号和最后一个行号 + int last=hs.getLastRowNum(); + int first=hs.getFirstRowNum(); + //遍历获取单元格里的信息 + for (int i = first; i <=last; i++) { + XSSFRow row=hs.getRow(i); + int firstCellNum=row.getFirstCellNum();//获取所在行的第一个行号 + int lastCellNum=row.getLastCellNum();//获取所在行的最后一个行号 + OilStation oilStation=new OilStation(); + for (int j = firstCellNum; j titles) { + int rowIndex = 0; + int colIndex = 0; + Font titleFont = wb.createFont();//获取字体 + titleFont.setFontName("simsun");//设置字体名称(宋体) + titleFont.setBold(true);//设置字体加粗 + titleFont.setColor(IndexedColors.BLACK.index);//设置字体颜色 黑色 + XSSFCellStyle titleStyle = wb.createCellStyle();//获取单元格样式 + titleStyle.setAlignment(HorizontalAlignment.CENTER);//设置单元格的水平对齐类型(这里是水平居中) + titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);//设置单元格的垂直对齐类型(这里是居中) + titleStyle.setFillForegroundColor(createXssfColor("#FFFFFF"));//设置单元格前景色(白色) + titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);//指定图案和纯色单元格填充的单元格填充信息(实心前景) + titleStyle.setFont(titleFont);//设置字体样式 + setBorder(titleStyle, BorderStyle.THIN, createXssfColor("#000000"));//设置边框样式(细线、黑色) + Row titleRow = sheet.createRow(rowIndex);//在该工作簿中创建第一行. + colIndex = 0; + for (String field : titles) {//循环创建列 + Cell cell = titleRow.createCell(colIndex); + cell.setCellValue(field); + cell.setCellStyle(titleStyle); + colIndex++; + } + rowIndex++;//将行数++ 返回用于下面添加数据 + return rowIndex; + } + + /** + * 将数据写入 + * @param wb + * @param sheet + * @param rows + * @param rowIndex + * @return + */ + private static int writeRowsToExcel(XSSFWorkbook wb, Sheet sheet, List> rows, int rowIndex) { + int colIndex = 0; + Font dataFont = wb.createFont();//获取字体 + dataFont.setFontName("simsun");//设置字体名称(宋体) + dataFont.setColor(IndexedColors.BLACK.index);//设置字体颜色 黑色 + XSSFCellStyle dataStyle = wb.createCellStyle();//获取单元格样式 + dataStyle.setAlignment(HorizontalAlignment.CENTER);//设置单元格的水平对齐类型(这里是水平居中) + dataStyle.setVerticalAlignment(VerticalAlignment.CENTER);//设置单元格的垂直对齐类型(这里是居中) + dataStyle.setFont(dataFont);//设置字体样式 + setBorder(dataStyle, BorderStyle.THIN, createXssfColor("#000000"));//设置边框样式(细线、黑色) + for (List rowData : rows) {//循环写入数据 + Row dataRow = sheet.createRow(rowIndex); + colIndex = 0; + for (Object cellData : rowData) { + Cell cell = dataRow.createCell(colIndex); + if (cellData != null) { + cell.setCellValue(cellData.toString()); + } else { + cell.setCellValue(""); + } + + cell.setCellStyle(dataStyle); + colIndex++; + } + rowIndex++; + } + return rowIndex; + } + + /** + * 自动调整大小 + * @param sheet + * @param columnNumber + */ + private static void autoSizeColumns(Sheet sheet, int columnNumber) { + for (int i = 0; i < columnNumber; i++) { + int orgWidth = sheet.getColumnWidth(i); + sheet.autoSizeColumn(i, true); + int newWidth = (int) (sheet.getColumnWidth(i) + 100); + if (newWidth > orgWidth) { + sheet.setColumnWidth(i, newWidth); + } else { + sheet.setColumnWidth(i, orgWidth); + } + } + } + + /** + * 设置表格样式 + * @param style + * @param border + * @param color + */ + private static void setBorder(XSSFCellStyle style, BorderStyle border, XSSFColor color) { + style.setBorderTop(border); + style.setBorderLeft(border); + style.setBorderRight(border); + style.setBorderBottom(border); + style.setBorderColor(XSSFCellBorder.BorderSide.TOP, color); + style.setBorderColor(XSSFCellBorder.BorderSide.LEFT, color); + style.setBorderColor(XSSFCellBorder.BorderSide.RIGHT, color); + style.setBorderColor(XSSFCellBorder.BorderSide.BOTTOM, color); + } + + /** + * 将rgb颜色码 转换为 XSSFColor + * @param color + * @return + */ + private static XSSFColor createXssfColor(String color) { + int[] rgbColor = hexToRgb(color); + XSSFColor xssfColor = new XSSFColor(new java.awt.Color(rgbColor[0], rgbColor[1], rgbColor[2]), new DefaultIndexedColorMap()); + return xssfColor; + } + + /** + * 将颜色码 转换为 r g b + * @param hex + * @return + */ + public static int[] hexToRgb(String hex) { + String colorStr = hex; + if (hex.startsWith("#")) { + colorStr = hex.substring(1); + } + if (StringUtils.length(colorStr) == 8) { + colorStr = hex.substring(2); + } + int r= Integer.valueOf( colorStr.substring( 0, 2 ), 16 ); + int g= Integer.valueOf( colorStr.substring( 2, 4 ), 16 ); + int b= Integer.valueOf( colorStr.substring( 4, 6 ), 16 ); + + return new int[] { r, g, b }; + } + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/sys/controller/AbstractController.java b/src/main/java/com/sqx/modules/sys/controller/AbstractController.java new file mode 100644 index 0000000..b403433 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/controller/AbstractController.java @@ -0,0 +1,22 @@ +package com.sqx.modules.sys.controller; + +import com.sqx.modules.sys.entity.SysUserEntity; +import org.apache.shiro.SecurityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Controller公共组件 + * + */ +public abstract class AbstractController { + protected Logger logger = LoggerFactory.getLogger(getClass()); + + protected SysUserEntity getUser() { + return (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); + } + + protected Long getUserId() { + return getUser().getUserId(); + } +} diff --git a/src/main/java/com/sqx/modules/sys/controller/SysConfigController.java b/src/main/java/com/sqx/modules/sys/controller/SysConfigController.java new file mode 100644 index 0000000..5fe42ad --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/controller/SysConfigController.java @@ -0,0 +1,89 @@ +package com.sqx.modules.sys.controller; + + +import com.sqx.common.annotation.SysLog; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.common.validator.ValidatorUtils; +import com.sqx.modules.sys.entity.SysConfigEntity; +import com.sqx.modules.sys.service.SysConfigService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * 系统配置信息 + * + */ +@RestController +@RequestMapping("/sys/config") +public class SysConfigController extends AbstractController { + @Autowired + private SysConfigService sysConfigService; + + /** + * 所有配置列表 + */ + @GetMapping("/list") + @RequiresPermissions("sys:config:list") + public Result list(@RequestParam Map params){ + PageUtils page = sysConfigService.queryPage(params); + + return Result.success().put("page", page); + } + + + /** + * 配置信息 + */ + @GetMapping("/info/{id}") + @RequiresPermissions("sys:config:info") + public Result info(@PathVariable("id") Long id){ + SysConfigEntity config = sysConfigService.getById(id); + + return Result.success().put("config", config); + } + + /** + * 保存配置 + */ + @SysLog("保存配置") + @PostMapping("/save") + @RequiresPermissions("sys:config:save") + public Result save(@RequestBody SysConfigEntity config){ + ValidatorUtils.validateEntity(config); + + sysConfigService.saveConfig(config); + + return Result.success(); + } + + /** + * 修改配置 + */ + @SysLog("修改配置") + @PostMapping("/update") + @RequiresPermissions("sys:config:update") + public Result update(@RequestBody SysConfigEntity config){ + ValidatorUtils.validateEntity(config); + + sysConfigService.update(config); + + return Result.success(); + } + + /** + * 删除配置 + */ + @SysLog("删除配置") + @PostMapping("/delete") + @RequiresPermissions("sys:config:delete") + public Result delete(@RequestBody Long[] ids){ + sysConfigService.deleteBatch(ids); + + return Result.success(); + } + +} diff --git a/src/main/java/com/sqx/modules/sys/controller/SysDictController.java b/src/main/java/com/sqx/modules/sys/controller/SysDictController.java new file mode 100644 index 0000000..c0966b7 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/controller/SysDictController.java @@ -0,0 +1,90 @@ +package com.sqx.modules.sys.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.sys.entity.SysDictEntity; +import com.sqx.modules.sys.service.SysDictService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Arrays; +import java.util.List; + +/** + * 数据字典 + * + */ +@RestController +@RequestMapping("sys/dict") +public class SysDictController { + @Autowired + private SysDictService sysDictService; + + + @RequestMapping("/selectDictList") + public Result selectDictList(String type,Integer status){ + SysDictEntity sysDictEntity = sysDictService.getOne(new QueryWrapper().eq("type", type)); + if(sysDictEntity!=null){ + List sysDictEntityList = sysDictService.list(new QueryWrapper().eq(status!=null && status!=0,"status",status).eq( "parent_id", sysDictEntity.getId()).orderByDesc("order_num")); + return Result.success().put("data", sysDictEntityList); + } + return Result.success(); + } + + /** + * 列表 + */ + @RequestMapping("/list") + public Result list(Integer page,Integer limit,String name,String parentId,String type,Integer status){ + PageUtils pages = sysDictService.queryPage(page, limit, name, parentId, type,status); + + return Result.success().put("page", pages); + } + + + /** + * 信息 + */ + @RequestMapping("/info/{id}") + public Result info(@PathVariable("id") Long id){ + SysDictEntity dict = sysDictService.getById(id); + + return Result.success().put("dict", dict); + } + + /** + * 保存 + */ + @RequestMapping("/save") + public Result save(@RequestBody SysDictEntity dict){ + + sysDictService.save(dict); + + return Result.success(); + } + + /** + * 修改 + */ + @RequestMapping("/update") + public Result update(@RequestBody SysDictEntity dict){ + sysDictService.updateById(dict); + + return Result.success(); + } + + /** + * 删除 + */ + @RequestMapping("/delete") + public Result delete(@RequestBody Long[] ids){ + sysDictService.removeByIds(Arrays.asList(ids)); + + return Result.success(); + } + +} diff --git a/src/main/java/com/sqx/modules/sys/controller/SysLogController.java b/src/main/java/com/sqx/modules/sys/controller/SysLogController.java new file mode 100644 index 0000000..d7a08df --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/controller/SysLogController.java @@ -0,0 +1,39 @@ +package com.sqx.modules.sys.controller; + +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.sys.service.SysLogService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.util.Map; + + +/** + * 系统日志 + * + */ +@Controller +@RequestMapping("/sys/log") +public class SysLogController { + @Autowired + private SysLogService sysLogService; + + /** + * 列表 + */ + @ResponseBody + @GetMapping("/list") + @RequiresPermissions("sys:log:list") + public Result list(@RequestParam Map params){ + PageUtils page = sysLogService.queryPage(params); + + return Result.success().put("page", page); + } + +} diff --git a/src/main/java/com/sqx/modules/sys/controller/SysLoginController.java b/src/main/java/com/sqx/modules/sys/controller/SysLoginController.java new file mode 100644 index 0000000..930ea58 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/controller/SysLoginController.java @@ -0,0 +1,91 @@ +package com.sqx.modules.sys.controller; + +import com.sqx.common.utils.Result; +import com.sqx.modules.sys.entity.SysUserEntity; +import com.sqx.modules.sys.form.SysLoginForm; +import com.sqx.modules.sys.service.SysCaptchaService; +import com.sqx.modules.sys.service.SysUserService; +import com.sqx.modules.sys.service.SysUserTokenService; +import org.apache.commons.io.IOUtils; +import org.apache.shiro.crypto.hash.Sha256Hash; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.imageio.ImageIO; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.Map; + +/** + * 登录相关 + * + */ +@RestController +public class SysLoginController extends AbstractController { + @Autowired + private SysUserService sysUserService; + @Autowired + private SysUserTokenService sysUserTokenService; + @Autowired + private SysCaptchaService sysCaptchaService; + + /** + * 验证码 + */ + @GetMapping("captcha.jpg") + public void captcha(HttpServletResponse response, String uuid)throws IOException { + response.setHeader("Cache-Control", "no-store, no-cache"); + response.setContentType("image/jpeg"); + + //获取图片验证码 + BufferedImage image = sysCaptchaService.getCaptcha(uuid); + + ServletOutputStream out = response.getOutputStream(); + ImageIO.write(image, "jpg", out); + IOUtils.closeQuietly(out); + } + + /** + * 登录 + */ + @PostMapping("/sys/login") + public Map login(@RequestBody SysLoginForm form)throws IOException { + boolean captcha = sysCaptchaService.validate(form.getUuid(), form.getCaptcha()); + if(!captcha){ + return Result.error("验证码不正确"); + } + + //用户信息 + SysUserEntity user = sysUserService.queryByUserName(form.getUsername()); + + //账号不存在、密码错误 + if(user == null || !user.getPassword().equals(new Sha256Hash(form.getPassword(), user.getSalt()).toHex())) { + return Result.error("账号或密码不正确"); + } + + //账号锁定 + if(user.getStatus() == 0){ + return Result.error("账号已被锁定,请联系管理员"); + } + + //生成token,并保存到数据库 + Result r = sysUserTokenService.createToken(user.getUserId()); + return r; + } + + + /** + * 退出 + */ + @PostMapping("/sys/logout") + public Result logout() { + sysUserTokenService.logout(getUserId()); + return Result.success(); + } + +} diff --git a/src/main/java/com/sqx/modules/sys/controller/SysMenuController.java b/src/main/java/com/sqx/modules/sys/controller/SysMenuController.java new file mode 100644 index 0000000..3f876eb --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/controller/SysMenuController.java @@ -0,0 +1,183 @@ +package com.sqx.modules.sys.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.sqx.common.annotation.SysLog; +import com.sqx.common.exception.SqxException; +import com.sqx.common.utils.Constant; +import com.sqx.common.utils.Result; +import com.sqx.modules.sys.entity.SysMenuEntity; +import com.sqx.modules.sys.service.ShiroService; +import com.sqx.modules.sys.service.SysMenuService; +import org.apache.commons.lang.StringUtils; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Set; + +/** + * 系统菜单 + * + */ +@RestController +@RequestMapping("/sys/menu") +public class SysMenuController extends AbstractController { + @Autowired + private SysMenuService sysMenuService; + @Autowired + private ShiroService shiroService; + + /** + * 导航菜单 + */ + @GetMapping("/nav") + public Result nav(){ + List menuList = sysMenuService.getUserMenuList(getUserId()); + Set permissions = shiroService.getUserPermissions(getUserId()); + return Result.success().put("menuList", menuList).put("permissions", permissions); + } + + /** + * 所有菜单列表 + */ + @GetMapping("/list") + @RequiresPermissions("sys:menu:list") + public List list(){ + List menuList = sysMenuService.list(new QueryWrapper().orderByAsc("order_num")); + for(SysMenuEntity sysMenuEntity : menuList){ + SysMenuEntity parentMenuEntity = sysMenuService.getById(sysMenuEntity.getParentId()); + if(parentMenuEntity != null){ + sysMenuEntity.setParentName(parentMenuEntity.getName()); + } + } + + return menuList; + } + + /** + * 选择菜单(添加、修改菜单) + */ + @GetMapping("/select") + @RequiresPermissions("sys:menu:select") + public Result select(){ + //查询列表数据 + List menuList = sysMenuService.queryNotButtonList(); + + //添加顶级菜单 + SysMenuEntity root = new SysMenuEntity(); + root.setMenuId(0L); + root.setName("一级菜单"); + root.setParentId(-1L); + root.setOpen(true); + menuList.add(root); + + return Result.success().put("menuList", menuList); + } + + /** + * 菜单信息 + */ + @GetMapping("/info/{menuId}") + @RequiresPermissions("sys:menu:info") + public Result info(@PathVariable("menuId") Long menuId){ + SysMenuEntity menu = sysMenuService.getById(menuId); + return Result.success().put("menu", menu); + } + + /** + * 保存 + */ + @SysLog("保存菜单") + @PostMapping("/save") + @RequiresPermissions("sys:menu:save") + public Result save(@RequestBody SysMenuEntity menu){ + //数据校验 + verifyForm(menu); + + sysMenuService.save(menu); + + return Result.success(); + } + + /** + * 修改 + */ + @SysLog("修改菜单") + @PostMapping("/update") + @RequiresPermissions("sys:menu:update") + public Result update(@RequestBody SysMenuEntity menu){ + //数据校验 + verifyForm(menu); + + sysMenuService.updateById(menu); + + return Result.success(); + } + + /** + * 删除 + */ + @SysLog("删除菜单") + @PostMapping("/delete/{menuId}") + @RequiresPermissions("sys:menu:delete") + public Result delete(@PathVariable("menuId") long menuId){ + if(menuId <= 31){ + return Result.error("系统菜单,不能删除"); + } + + //判断是否有子菜单或按钮 + List menuList = sysMenuService.queryListParentId(menuId); + if(menuList.size() > 0){ + return Result.error("请先删除子菜单或按钮"); + } + + sysMenuService.delete(menuId); + + return Result.success(); + } + + /** + * 验证参数是否正确 + */ + private void verifyForm(SysMenuEntity menu){ + if(StringUtils.isBlank(menu.getName())){ + throw new SqxException("菜单名称不能为空"); + } + + if(menu.getParentId() == null){ + throw new SqxException("上级菜单不能为空"); + } + + //菜单 + if(menu.getType() == Constant.MenuType.MENU.getValue()){ + if(StringUtils.isBlank(menu.getUrl())){ + throw new SqxException("菜单URL不能为空"); + } + } + + //上级菜单类型 + int parentType = Constant.MenuType.CATALOG.getValue(); + if(menu.getParentId() != 0){ + SysMenuEntity parentMenu = sysMenuService.getById(menu.getParentId()); + parentType = parentMenu.getType(); + } + + //目录、菜单 + if(menu.getType() == Constant.MenuType.CATALOG.getValue() || + menu.getType() == Constant.MenuType.MENU.getValue()){ + if(parentType != Constant.MenuType.CATALOG.getValue()){ + throw new SqxException("上级菜单只能为目录类型"); + } + return ; + } + + //按钮 + if(menu.getType() == Constant.MenuType.BUTTON.getValue()){ + if(parentType != Constant.MenuType.MENU.getValue()){ + throw new SqxException("上级菜单只能为菜单类型"); + } + return ; + } + } +} diff --git a/src/main/java/com/sqx/modules/sys/controller/SysRoleController.java b/src/main/java/com/sqx/modules/sys/controller/SysRoleController.java new file mode 100644 index 0000000..88db465 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/controller/SysRoleController.java @@ -0,0 +1,117 @@ +package com.sqx.modules.sys.controller; + +import com.sqx.common.annotation.SysLog; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.common.validator.ValidatorUtils; +import com.sqx.modules.sys.entity.SysRoleEntity; +import com.sqx.modules.sys.service.SysRoleMenuService; +import com.sqx.modules.sys.service.SysRoleService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 角色管理 + * + */ +@RestController +@RequestMapping("/sys/role") +public class SysRoleController extends AbstractController { + @Autowired + private SysRoleService sysRoleService; + @Autowired + private SysRoleMenuService sysRoleMenuService; + + /** + * 角色列表 + */ + @GetMapping("/list") + @RequiresPermissions("sys:role:list") + public Result list(@RequestParam Map params){ + //如果不是超级管理员,则只查询自己创建的角色列表 + /*if(getUserId() != Constant.SUPER_ADMIN){ + params.put("createUserId", getUserId()); + }*/ + PageUtils page = sysRoleService.queryPage(params); + return Result.success().put("page", page); + } + + /** + * 角色列表 + */ + @GetMapping("/select") + @RequiresPermissions("sys:role:select") + public Result select(){ + Map map = new HashMap<>(); + + //如果不是超级管理员,则只查询自己所拥有的角色列表 + /*if(getUserId() != Constant.SUPER_ADMIN){ + map.put("create_user_id", getUserId()); + }*/ + List list = (List) sysRoleService.listByMap(map); + + return Result.success().put("list", list); + } + + /** + * 角色信息 + */ + @GetMapping("/info/{roleId}") + @RequiresPermissions("sys:role:info") + public Result info(@PathVariable("roleId") Long roleId){ + SysRoleEntity role = sysRoleService.getById(roleId); + + //查询角色对应的菜单 + List menuIdList = sysRoleMenuService.queryMenuIdList(roleId); + role.setMenuIdList(menuIdList); + + return Result.success().put("role", role); + } + + /** + * 保存角色 + */ + @SysLog("保存角色") + @PostMapping("/save") + @RequiresPermissions("sys:role:save") + public Result save(@RequestBody SysRoleEntity role){ + ValidatorUtils.validateEntity(role); + + role.setCreateUserId(getUserId()); + sysRoleService.saveRole(role); + + return Result.success(); + } + + /** + * 修改角色 + */ + @SysLog("修改角色") + @PostMapping("/update") + @RequiresPermissions("sys:role:update") + public Result update(@RequestBody SysRoleEntity role){ + ValidatorUtils.validateEntity(role); + + role.setCreateUserId(getUserId()); + sysRoleService.update(role); + + return Result.success(); + } + + /** + * 删除角色 + */ + @SysLog("删除角色") + @PostMapping("/delete") + @RequiresPermissions("sys:role:delete") + public Result delete(@RequestBody Long[] roleIds){ + sysRoleService.deleteBatch(roleIds); + + return Result.success(); + } +} diff --git a/src/main/java/com/sqx/modules/sys/controller/SysUserController.java b/src/main/java/com/sqx/modules/sys/controller/SysUserController.java new file mode 100644 index 0000000..4783e37 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/controller/SysUserController.java @@ -0,0 +1,145 @@ +package com.sqx.modules.sys.controller; + +import com.sqx.common.annotation.SysLog; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.common.validator.Assert; +import com.sqx.common.validator.ValidatorUtils; +import com.sqx.common.validator.group.AddGroup; +import com.sqx.common.validator.group.UpdateGroup; +import com.sqx.modules.sys.entity.SysUserEntity; +import com.sqx.modules.sys.form.PasswordForm; +import com.sqx.modules.sys.service.SysUserRoleService; +import com.sqx.modules.sys.service.SysUserService; +import org.apache.commons.lang.ArrayUtils; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.apache.shiro.crypto.hash.Sha256Hash; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * 系统用户 + * + */ +@RestController +@RequestMapping("/sys/user") +public class SysUserController extends AbstractController { + @Autowired + private SysUserService sysUserService; + @Autowired + private SysUserRoleService sysUserRoleService; + + + /** + * 所有用户列表 + */ + @GetMapping("/list") + @RequiresPermissions("sys:user:list") + public Result list(@RequestParam Map params){ + //只有超级管理员,才能查看所有管理员列表 + /*if(getUserId() != Constant.SUPER_ADMIN){ + params.put("createUserId", getUserId()); + }*/ + PageUtils page = sysUserService.queryPage(params); + + return Result.success().put("page", page); + } + + /** + * 获取登录的用户信息 + */ + @GetMapping("/info") + public Result info(){ + return Result.success().put("user", getUser()); + } + + /** + * 修改登录用户密码 + */ + @SysLog("修改密码") + @PostMapping("/password") + public Result password(@RequestBody PasswordForm form){ + Assert.isBlank(form.getNewPassword(), "新密码不为能空"); + + //sha256加密 + String password = new Sha256Hash(form.getPassword(), getUser().getSalt()).toHex(); + //sha256加密 + String newPassword = new Sha256Hash(form.getNewPassword(), getUser().getSalt()).toHex(); + + //更新密码 + boolean flag = sysUserService.updatePassword(getUserId(), password, newPassword); + if(!flag){ + return Result.error("原密码不正确"); + } + + return Result.success(); + } + + /** + * 用户信息 + */ + @GetMapping("/info/{userId}") + @RequiresPermissions("sys:user:info") + public Result info(@PathVariable("userId") Long userId){ + SysUserEntity user = sysUserService.getById(userId); + + //获取用户所属的角色列表 + List roleIdList = sysUserRoleService.queryRoleIdList(userId); + user.setRoleIdList(roleIdList); + + return Result.success().put("user", user); + } + + /** + * 保存用户 + */ + @SysLog("保存用户") + @PostMapping("/save") + @RequiresPermissions("sys:user:save") + public Result save(@RequestBody SysUserEntity user){ + ValidatorUtils.validateEntity(user, AddGroup.class); + + user.setCreateUserId(getUserId()); + sysUserService.saveUser(user); + + return Result.success(); + } + + /** + * 修改用户 + */ + @SysLog("修改用户") + @PostMapping("/update") + @RequiresPermissions("sys:user:update") + public Result update(@RequestBody SysUserEntity user){ + ValidatorUtils.validateEntity(user, UpdateGroup.class); + + user.setCreateUserId(getUserId()); + sysUserService.update(user); + + return Result.success(); + } + + /** + * 删除用户 + */ + @SysLog("删除用户") + @PostMapping("/delete") + @RequiresPermissions("sys:user:delete") + public Result delete(@RequestBody Long[] userIds){ + if(ArrayUtils.contains(userIds, 1L)){ + return Result.error("系统管理员不能删除"); + } + + if(ArrayUtils.contains(userIds, getUserId())){ + return Result.error("当前用户不能删除"); + } + + sysUserService.deleteBatch(userIds); + + return Result.success(); + } +} diff --git a/src/main/java/com/sqx/modules/sys/controller/app/AppDictController.java b/src/main/java/com/sqx/modules/sys/controller/app/AppDictController.java new file mode 100644 index 0000000..ad78145 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/controller/app/AppDictController.java @@ -0,0 +1,35 @@ +package com.sqx.modules.sys.controller.app; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.sqx.common.utils.Result; +import com.sqx.modules.sys.entity.SysDictEntity; +import com.sqx.modules.sys.service.SysDictService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 数据字典 + * + */ +@RestController +@RequestMapping("app/dict") +public class AppDictController { + @Autowired + private SysDictService sysDictService; + + /** + * 列表 + */ + @RequestMapping("/list") + public Result list(String type){ + SysDictEntity sysDictEntity = sysDictService.getOne(new QueryWrapper().eq("type", type)); + List sysDictEntityList = sysDictService.list(new QueryWrapper().eq("status",1).eq( "parent_id", sysDictEntity.getId()).orderByDesc("order_num")); + return Result.success().put("data", sysDictEntityList); + } + + + +} diff --git a/src/main/java/com/sqx/modules/sys/dao/SysCaptchaDao.java b/src/main/java/com/sqx/modules/sys/dao/SysCaptchaDao.java new file mode 100644 index 0000000..402e1a2 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/dao/SysCaptchaDao.java @@ -0,0 +1,14 @@ +package com.sqx.modules.sys.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.sys.entity.SysCaptchaEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 验证码 + * + */ +@Mapper +public interface SysCaptchaDao extends BaseMapper { + +} diff --git a/src/main/java/com/sqx/modules/sys/dao/SysConfigDao.java b/src/main/java/com/sqx/modules/sys/dao/SysConfigDao.java new file mode 100644 index 0000000..2ed6515 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/dao/SysConfigDao.java @@ -0,0 +1,26 @@ +package com.sqx.modules.sys.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.sys.entity.SysConfigEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 系统配置信息 + * + */ +@Mapper +public interface SysConfigDao extends BaseMapper { + + /** + * 根据key,查询value + */ + SysConfigEntity queryByKey(String paramKey); + + /** + * 根据key,更新value + */ + int updateValueByKey(@Param("paramKey") String paramKey, @Param("paramValue") String paramValue); + +} diff --git a/src/main/java/com/sqx/modules/sys/dao/SysDictDao.java b/src/main/java/com/sqx/modules/sys/dao/SysDictDao.java new file mode 100644 index 0000000..47d22ba --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/dao/SysDictDao.java @@ -0,0 +1,14 @@ +package com.sqx.modules.sys.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.sys.entity.SysDictEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 数据字典 + * + */ +@Mapper +public interface SysDictDao extends BaseMapper { + +} diff --git a/src/main/java/com/sqx/modules/sys/dao/SysLogDao.java b/src/main/java/com/sqx/modules/sys/dao/SysLogDao.java new file mode 100644 index 0000000..2e78f97 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/dao/SysLogDao.java @@ -0,0 +1,15 @@ +package com.sqx.modules.sys.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.sys.entity.SysLogEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 系统日志 + * + */ +@Mapper +public interface SysLogDao extends BaseMapper { + +} diff --git a/src/main/java/com/sqx/modules/sys/dao/SysMenuDao.java b/src/main/java/com/sqx/modules/sys/dao/SysMenuDao.java new file mode 100644 index 0000000..0510df4 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/dao/SysMenuDao.java @@ -0,0 +1,27 @@ +package com.sqx.modules.sys.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.sys.entity.SysMenuEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 菜单管理 + * + */ +@Mapper +public interface SysMenuDao extends BaseMapper { + + /** + * 根据父菜单,查询子菜单 + * @param parentId 父菜单ID + */ + List queryListParentId(Long parentId); + + /** + * 获取不包含按钮的菜单列表 + */ + List queryNotButtonList(); + +} diff --git a/src/main/java/com/sqx/modules/sys/dao/SysRoleDao.java b/src/main/java/com/sqx/modules/sys/dao/SysRoleDao.java new file mode 100644 index 0000000..e8b4576 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/dao/SysRoleDao.java @@ -0,0 +1,20 @@ +package com.sqx.modules.sys.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.sys.entity.SysRoleEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 角色管理 + * + */ +@Mapper +public interface SysRoleDao extends BaseMapper { + + /** + * 查询用户创建的角色ID列表 + */ + List queryRoleIdList(Long createUserId); +} diff --git a/src/main/java/com/sqx/modules/sys/dao/SysRoleMenuDao.java b/src/main/java/com/sqx/modules/sys/dao/SysRoleMenuDao.java new file mode 100644 index 0000000..2716b21 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/dao/SysRoleMenuDao.java @@ -0,0 +1,25 @@ +package com.sqx.modules.sys.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.sys.entity.SysRoleMenuEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 角色与菜单对应关系 + * + */ +@Mapper +public interface SysRoleMenuDao extends BaseMapper { + + /** + * 根据角色ID,获取菜单ID列表 + */ + List queryMenuIdList(Long roleId); + + /** + * 根据角色ID数组,批量删除 + */ + int deleteBatch(Long[] roleIds); +} diff --git a/src/main/java/com/sqx/modules/sys/dao/SysUserDao.java b/src/main/java/com/sqx/modules/sys/dao/SysUserDao.java new file mode 100644 index 0000000..b21c796 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/dao/SysUserDao.java @@ -0,0 +1,32 @@ +package com.sqx.modules.sys.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.sys.entity.SysUserEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 系统用户 + * + */ +@Mapper +public interface SysUserDao extends BaseMapper { + + /** + * 查询用户的所有权限 + * @param userId 用户ID + */ + List queryAllPerms(Long userId); + + /** + * 查询用户的所有菜单ID + */ + List queryAllMenuId(Long userId); + + /** + * 根据用户名,查询系统用户 + */ + SysUserEntity queryByUserName(String username); + +} diff --git a/src/main/java/com/sqx/modules/sys/dao/SysUserRoleDao.java b/src/main/java/com/sqx/modules/sys/dao/SysUserRoleDao.java new file mode 100644 index 0000000..b0d82b7 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/dao/SysUserRoleDao.java @@ -0,0 +1,26 @@ +package com.sqx.modules.sys.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.sys.entity.SysUserRoleEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 用户与角色对应关系 + * + */ +@Mapper +public interface SysUserRoleDao extends BaseMapper { + + /** + * 根据用户ID,获取角色ID列表 + */ + List queryRoleIdList(Long userId); + + + /** + * 根据角色ID数组,批量删除 + */ + int deleteBatch(Long[] roleIds); +} diff --git a/src/main/java/com/sqx/modules/sys/dao/SysUserTokenDao.java b/src/main/java/com/sqx/modules/sys/dao/SysUserTokenDao.java new file mode 100644 index 0000000..6df7ec8 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/dao/SysUserTokenDao.java @@ -0,0 +1,16 @@ +package com.sqx.modules.sys.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.sys.entity.SysUserTokenEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 系统用户Token + * + */ +@Mapper +public interface SysUserTokenDao extends BaseMapper { + + SysUserTokenEntity queryByToken(String token); + +} diff --git a/src/main/java/com/sqx/modules/sys/entity/SysCaptchaEntity.java b/src/main/java/com/sqx/modules/sys/entity/SysCaptchaEntity.java new file mode 100644 index 0000000..4b8de05 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/entity/SysCaptchaEntity.java @@ -0,0 +1,28 @@ +package com.sqx.modules.sys.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.util.Date; + +/** + * 系统验证码 + * + */ +@Data +@TableName("sys_captcha") +public class SysCaptchaEntity { + @TableId(type = IdType.INPUT) + private String uuid; + /** + * 验证码 + */ + private String code; + /** + * 过期时间 + */ + private Date expireTime; + +} diff --git a/src/main/java/com/sqx/modules/sys/entity/SysConfigEntity.java b/src/main/java/com/sqx/modules/sys/entity/SysConfigEntity.java new file mode 100644 index 0000000..3fe2ee6 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/entity/SysConfigEntity.java @@ -0,0 +1,21 @@ +package com.sqx.modules.sys.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + + +/** + * 系统配置信息 + * + */ +@Data +@TableName("sys_config") +public class SysConfigEntity { + @TableId + private Long id; + private String paramKey; + private String paramValue; + private String remark; + +} diff --git a/src/main/java/com/sqx/modules/sys/entity/SysDictEntity.java b/src/main/java/com/sqx/modules/sys/entity/SysDictEntity.java new file mode 100644 index 0000000..7f5ae2d --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/entity/SysDictEntity.java @@ -0,0 +1,58 @@ +package com.sqx.modules.sys.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 数据字典 + * + */ +@Data +@TableName("sys_dict") +public class SysDictEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId + private Long id; + /** + * 字典名称 + */ + + private String name; + /** + * 字典类型 + */ + + private String type; + + /** + * 上级id 0是顶级 + */ + private Long parentId; + + /** + * 字典码 + */ + + private String code; + /** + * 字典值 + */ + + private String value; + /** + * 排序 + */ + private Integer orderNum; + /** + * 备注 + */ + private String remark; + + private Integer status; + + +} diff --git a/src/main/java/com/sqx/modules/sys/entity/SysLogEntity.java b/src/main/java/com/sqx/modules/sys/entity/SysLogEntity.java new file mode 100644 index 0000000..1239aff --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/entity/SysLogEntity.java @@ -0,0 +1,36 @@ +package com.sqx.modules.sys.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 系统日志 + * + */ +@Data +@TableName("sys_log") +public class SysLogEntity implements Serializable { + private static final long serialVersionUID = 1L; + @TableId + private Long id; + //用户名 + private String username; + //用户操作 + private String operation; + //请求方法 + private String method; + //请求参数 + private String params; + //执行时长(毫秒) + private Long time; + //IP地址 + private String ip; + //创建时间 + private Date createDate; + +} diff --git a/src/main/java/com/sqx/modules/sys/entity/SysMenuEntity.java b/src/main/java/com/sqx/modules/sys/entity/SysMenuEntity.java new file mode 100644 index 0000000..410cbdb --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/entity/SysMenuEntity.java @@ -0,0 +1,76 @@ +package com.sqx.modules.sys.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 菜单管理 + * + */ +@Data +@TableName("sys_menu") +public class SysMenuEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 菜单ID + */ + @TableId + private Long menuId; + + /** + * 父菜单ID,一级菜单为0 + */ + private Long parentId; + + /** + * 父菜单名称 + */ + @TableField(exist=false) + private String parentName; + + /** + * 菜单名称 + */ + private String name; + + /** + * 菜单URL + */ + private String url; + + /** + * 授权(多个用逗号分隔,如:user:list,user:create) + */ + private String perms; + + /** + * 类型 0:目录 1:菜单 2:按钮 + */ + private Integer type; + + /** + * 菜单图标 + */ + private String icon; + + /** + * 排序 + */ + private Integer orderNum; + + /** + * ztree属性 + */ + @TableField(exist=false) + private Boolean open; + + @TableField(exist=false) + private List list; + +} diff --git a/src/main/java/com/sqx/modules/sys/entity/SysRoleEntity.java b/src/main/java/com/sqx/modules/sys/entity/SysRoleEntity.java new file mode 100644 index 0000000..da2548d --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/entity/SysRoleEntity.java @@ -0,0 +1,51 @@ +package com.sqx.modules.sys.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * 角色 + * + */ +@Data +@TableName("sys_role") +public class SysRoleEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 角色ID + */ + @TableId + private Long roleId; + + /** + * 角色名称 + */ + private String roleName; + + /** + * 备注 + */ + private String remark; + + /** + * 创建者ID + */ + private Long createUserId; + + @TableField(exist=false) + private List menuIdList; + + /** + * 创建时间 + */ + private Date createTime; + + +} diff --git a/src/main/java/com/sqx/modules/sys/entity/SysRoleMenuEntity.java b/src/main/java/com/sqx/modules/sys/entity/SysRoleMenuEntity.java new file mode 100644 index 0000000..dcdce80 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/entity/SysRoleMenuEntity.java @@ -0,0 +1,31 @@ +package com.sqx.modules.sys.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 角色与菜单对应关系 + * + */ +@Data +@TableName("sys_role_menu") +public class SysRoleMenuEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId + private Long id; + + /** + * 角色ID + */ + private Long roleId; + + /** + * 菜单ID + */ + private Long menuId; + +} diff --git a/src/main/java/com/sqx/modules/sys/entity/SysUserEntity.java b/src/main/java/com/sqx/modules/sys/entity/SysUserEntity.java new file mode 100644 index 0000000..d1f95f8 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/entity/SysUserEntity.java @@ -0,0 +1,75 @@ +package com.sqx.modules.sys.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.sqx.common.validator.group.AddGroup; +import com.sqx.common.validator.group.UpdateGroup; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * 系统用户 + * + */ +@Data +@TableName("sys_user") +public class SysUserEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 用户ID + */ + @TableId + private Long userId; + + /** + * 用户名 + */ + private String username; + + /** + * 密码 + */ + private String password; + + /** + * 盐 + */ + private String salt; + + /** + * 邮箱 + */ + private String email; + + /** + * 手机号 + */ + private String mobile; + + /** + * 状态 0:禁用 1:正常 + */ + private Integer status; + + /** + * 角色ID列表 + */ + @TableField(exist=false) + private List roleIdList; + + /** + * 创建者ID + */ + private Long createUserId; + + /** + * 创建时间 + */ + private Date createTime; + +} diff --git a/src/main/java/com/sqx/modules/sys/entity/SysUserRoleEntity.java b/src/main/java/com/sqx/modules/sys/entity/SysUserRoleEntity.java new file mode 100644 index 0000000..ba913a6 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/entity/SysUserRoleEntity.java @@ -0,0 +1,31 @@ +package com.sqx.modules.sys.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 用户与角色对应关系 + * + */ +@Data +@TableName("sys_user_role") +public class SysUserRoleEntity implements Serializable { + private static final long serialVersionUID = 1L; + @TableId + private Long id; + + /** + * 用户ID + */ + private Long userId; + + /** + * 角色ID + */ + private Long roleId; + + +} diff --git a/src/main/java/com/sqx/modules/sys/entity/SysUserTokenEntity.java b/src/main/java/com/sqx/modules/sys/entity/SysUserTokenEntity.java new file mode 100644 index 0000000..d5e9ffd --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/entity/SysUserTokenEntity.java @@ -0,0 +1,31 @@ +package com.sqx.modules.sys.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 系统用户Token + * + */ +@Data +@TableName("sys_user_token") +public class SysUserTokenEntity implements Serializable { + private static final long serialVersionUID = 1L; + + //用户ID + @TableId(type = IdType.INPUT) + private Long userId; + //token + private String token; + //过期时间 + private Date expireTime; + //更新时间 + private Date updateTime; + +} diff --git a/src/main/java/com/sqx/modules/sys/form/PasswordForm.java b/src/main/java/com/sqx/modules/sys/form/PasswordForm.java new file mode 100644 index 0000000..e10a377 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/form/PasswordForm.java @@ -0,0 +1,20 @@ +package com.sqx.modules.sys.form; + +import lombok.Data; + +/** + * 密码表单 + * + */ +@Data +public class PasswordForm { + /** + * 原密码 + */ + private String password; + /** + * 新密码 + */ + private String newPassword; + +} diff --git a/src/main/java/com/sqx/modules/sys/form/SysLoginForm.java b/src/main/java/com/sqx/modules/sys/form/SysLoginForm.java new file mode 100644 index 0000000..46efd2d --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/form/SysLoginForm.java @@ -0,0 +1,17 @@ +package com.sqx.modules.sys.form; + +import lombok.Data; + +/** + * 登录表单 + * + */ +@Data +public class SysLoginForm { + private String username; + private String password; + private String captcha; + private String uuid; + + +} diff --git a/src/main/java/com/sqx/modules/sys/oauth2/OAuth2Filter.java b/src/main/java/com/sqx/modules/sys/oauth2/OAuth2Filter.java new file mode 100644 index 0000000..43e9437 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/oauth2/OAuth2Filter.java @@ -0,0 +1,101 @@ +package com.sqx.modules.sys.oauth2; + +import com.google.gson.Gson; +import com.sqx.common.utils.HttpContextUtils; +import com.sqx.common.utils.Result; +import org.apache.commons.lang.StringUtils; +import org.apache.http.HttpStatus; +import org.apache.shiro.authc.AuthenticationException; +import org.apache.shiro.authc.AuthenticationToken; +import org.apache.shiro.web.filter.authc.AuthenticatingFilter; +import org.springframework.web.bind.annotation.RequestMethod; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * oauth2过滤器 + * + */ +public class OAuth2Filter extends AuthenticatingFilter { + + @Override + protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) throws Exception { + //获取请求token + String token = getRequestToken((HttpServletRequest) request); + + if(StringUtils.isBlank(token)){ + return null; + } + + return new OAuth2Token(token); + } + + @Override + protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) { + if(((HttpServletRequest) request).getMethod().equals(RequestMethod.OPTIONS.name())){ + return true; + } + + return false; + } + + @Override + protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception { + //获取请求token,如果token不存在,直接返回401 + String token = getRequestToken((HttpServletRequest) request); + if(StringUtils.isBlank(token)){ + HttpServletResponse httpResponse = (HttpServletResponse) response; + httpResponse.setHeader("Access-Control-Allow-Credentials", "true"); + httpResponse.setHeader("Access-Control-Allow-Origin", HttpContextUtils.getOrigin()); + + String json = new Gson().toJson(Result.error(HttpStatus.SC_UNAUTHORIZED, "invalid token")); + + httpResponse.getWriter().print(json); + + return false; + } + + return executeLogin(request, response); + } + + @Override + protected boolean onLoginFailure(AuthenticationToken token, AuthenticationException e, ServletRequest request, ServletResponse response) { + HttpServletResponse httpResponse = (HttpServletResponse) response; + httpResponse.setContentType("application/json;charset=utf-8"); + httpResponse.setHeader("Access-Control-Allow-Credentials", "true"); + httpResponse.setHeader("Access-Control-Allow-Origin", HttpContextUtils.getOrigin()); + try { + //处理登录失败的异常 + Throwable throwable = e.getCause() == null ? e : e.getCause(); + Result r = Result.error(HttpStatus.SC_UNAUTHORIZED, throwable.getMessage()); + + String json = new Gson().toJson(r); + httpResponse.getWriter().print(json); + } catch (IOException e1) { + + } + + return false; + } + + /** + * 获取请求的token + */ + private String getRequestToken(HttpServletRequest httpRequest){ + //从header中获取token + String token = httpRequest.getHeader("token"); + + //如果header中不存在token,则从参数中获取token + if(StringUtils.isBlank(token)){ + token = httpRequest.getParameter("token"); + } + + return token; + } + + +} diff --git a/src/main/java/com/sqx/modules/sys/oauth2/OAuth2Realm.java b/src/main/java/com/sqx/modules/sys/oauth2/OAuth2Realm.java new file mode 100644 index 0000000..4f1adee --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/oauth2/OAuth2Realm.java @@ -0,0 +1,70 @@ +package com.sqx.modules.sys.oauth2; + +import com.sqx.modules.sys.entity.SysUserEntity; +import com.sqx.modules.sys.entity.SysUserTokenEntity; +import com.sqx.modules.sys.service.ShiroService; +import org.apache.shiro.authc.*; +import org.apache.shiro.authz.AuthorizationInfo; +import org.apache.shiro.authz.SimpleAuthorizationInfo; +import org.apache.shiro.realm.AuthorizingRealm; +import org.apache.shiro.subject.PrincipalCollection; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Set; + +/** + * 认证 + * + */ +@Component +public class OAuth2Realm extends AuthorizingRealm { + @Autowired + private ShiroService shiroService; + + @Override + public boolean supports(AuthenticationToken token) { + return token instanceof OAuth2Token; + } + + /** + * 授权(验证权限时调用) + */ + @Override + protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { + SysUserEntity user = (SysUserEntity)principals.getPrimaryPrincipal(); + Long userId = user.getUserId(); + + //用户权限列表 + Set permsSet = shiroService.getUserPermissions(userId); + + SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); + info.setStringPermissions(permsSet); + return info; + } + + /** + * 认证(登录时调用) + */ + @Override + protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { + String accessToken = (String) token.getPrincipal(); + + //根据accessToken,查询用户信息 + SysUserTokenEntity tokenEntity = shiroService.queryByToken(accessToken); + //token失效 + if(tokenEntity == null || tokenEntity.getExpireTime().getTime() < System.currentTimeMillis()){ + throw new IncorrectCredentialsException("token失效,请重新登录"); + } + + //查询用户信息 + SysUserEntity user = shiroService.queryUser(tokenEntity.getUserId()); + //账号锁定 + if(user.getStatus() == 0){ + throw new LockedAccountException("账号已被锁定,请联系管理员"); + } + + SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, accessToken, getName()); + return info; + } +} diff --git a/src/main/java/com/sqx/modules/sys/oauth2/OAuth2Token.java b/src/main/java/com/sqx/modules/sys/oauth2/OAuth2Token.java new file mode 100644 index 0000000..67fac8c --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/oauth2/OAuth2Token.java @@ -0,0 +1,26 @@ +package com.sqx.modules.sys.oauth2; + + +import org.apache.shiro.authc.AuthenticationToken; + +/** + * token + * + */ +public class OAuth2Token implements AuthenticationToken { + private String token; + + public OAuth2Token(String token){ + this.token = token; + } + + @Override + public String getPrincipal() { + return token; + } + + @Override + public Object getCredentials() { + return token; + } +} diff --git a/src/main/java/com/sqx/modules/sys/oauth2/TokenGenerator.java b/src/main/java/com/sqx/modules/sys/oauth2/TokenGenerator.java new file mode 100644 index 0000000..527154b --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/oauth2/TokenGenerator.java @@ -0,0 +1,43 @@ +package com.sqx.modules.sys.oauth2; + +import com.sqx.common.exception.SqxException; + +import java.security.MessageDigest; +import java.util.UUID; + +/** + * 生成token + * + */ +public class TokenGenerator { + + public static String generateValue() { + return generateValue(UUID.randomUUID().toString()); + } + + private static final char[] HexCode = "0123456789abcdef".toCharArray(); + + public static String toHexString(byte[] data) { + if(data == null) { + return null; + } + StringBuilder r = new StringBuilder(data.length*2); + for ( byte b : data) { + r.append(HexCode[(b >> 4) & 0xF]); + r.append(HexCode[(b & 0xF)]); + } + return r.toString(); + } + + public static String generateValue(String param) { + try { + MessageDigest algorithm = MessageDigest.getInstance("MD5"); + algorithm.reset(); + algorithm.update(param.getBytes()); + byte[] messageDigest = algorithm.digest(); + return toHexString(messageDigest); + } catch (Exception e) { + throw new SqxException("生成Token失败", e); + } + } +} diff --git a/src/main/java/com/sqx/modules/sys/redis/SysConfigRedis.java b/src/main/java/com/sqx/modules/sys/redis/SysConfigRedis.java new file mode 100644 index 0000000..6336a4c --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/redis/SysConfigRedis.java @@ -0,0 +1,36 @@ +package com.sqx.modules.sys.redis; + + +import com.sqx.common.utils.RedisKeys; +import com.sqx.common.utils.RedisUtils; +import com.sqx.modules.sys.entity.SysConfigEntity; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 系统配置Redis + * + */ +@Component +public class SysConfigRedis { + @Autowired + private RedisUtils redisUtils; + + public void saveOrUpdate(SysConfigEntity config) { + if(config == null){ + return ; + } + String key = RedisKeys.getSysConfigKey(config.getParamKey()); + redisUtils.set(key, config); + } + + public void delete(String configKey) { + String key = RedisKeys.getSysConfigKey(configKey); + redisUtils.delete(key); + } + + public SysConfigEntity get(String configKey){ + String key = RedisKeys.getSysConfigKey(configKey); + return redisUtils.get(key, SysConfigEntity.class); + } +} diff --git a/src/main/java/com/sqx/modules/sys/service/ShiroService.java b/src/main/java/com/sqx/modules/sys/service/ShiroService.java new file mode 100644 index 0000000..1eb275f --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/ShiroService.java @@ -0,0 +1,25 @@ +package com.sqx.modules.sys.service; + +import com.sqx.modules.sys.entity.SysUserEntity; +import com.sqx.modules.sys.entity.SysUserTokenEntity; + +import java.util.Set; + +/** + * shiro相关接口 + * + */ +public interface ShiroService { + /** + * 获取用户权限列表 + */ + Set getUserPermissions(long userId); + + SysUserTokenEntity queryByToken(String token); + + /** + * 根据用户ID,查询用户 + * @param userId + */ + SysUserEntity queryUser(Long userId); +} diff --git a/src/main/java/com/sqx/modules/sys/service/SysCaptchaService.java b/src/main/java/com/sqx/modules/sys/service/SysCaptchaService.java new file mode 100644 index 0000000..3a47f89 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/SysCaptchaService.java @@ -0,0 +1,26 @@ +package com.sqx.modules.sys.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.modules.sys.entity.SysCaptchaEntity; + +import java.awt.image.BufferedImage; + +/** + * 验证码 + * + */ +public interface SysCaptchaService extends IService { + + /** + * 获取图片验证码 + */ + BufferedImage getCaptcha(String uuid); + + /** + * 验证码效验 + * @param uuid uuid + * @param code 验证码 + * @return true:成功 false:失败 + */ + boolean validate(String uuid, String code); +} diff --git a/src/main/java/com/sqx/modules/sys/service/SysConfigService.java b/src/main/java/com/sqx/modules/sys/service/SysConfigService.java new file mode 100644 index 0000000..5becf42 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/SysConfigService.java @@ -0,0 +1,51 @@ +package com.sqx.modules.sys.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.PageUtils; +import com.sqx.modules.sys.entity.SysConfigEntity; + +import java.util.Map; + +/** + * 系统配置信息 + * + */ +public interface SysConfigService extends IService { + + PageUtils queryPage(Map params); + + /** + * 保存配置信息 + */ + public void saveConfig(SysConfigEntity config); + + /** + * 更新配置信息 + */ + public void update(SysConfigEntity config); + + /** + * 根据key,更新value + */ + public void updateValueByKey(String key, String value); + + /** + * 删除配置信息 + */ + public void deleteBatch(Long[] ids); + + /** + * 根据key,获取配置的value值 + * + * @param key key + */ + public String getValue(String key); + + /** + * 根据key,获取value的Object对象 + * @param key key + * @param clazz Object对象 + */ + public T getConfigObject(String key, Class clazz); + +} diff --git a/src/main/java/com/sqx/modules/sys/service/SysDictService.java b/src/main/java/com/sqx/modules/sys/service/SysDictService.java new file mode 100644 index 0000000..8d4f4ae --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/SysDictService.java @@ -0,0 +1,15 @@ +package com.sqx.modules.sys.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.PageUtils; +import com.sqx.modules.sys.entity.SysDictEntity; + +/** + * 数据字典 + * + */ +public interface SysDictService extends IService { + + PageUtils queryPage(Integer page,Integer limit,String name,String parentId,String type,Integer status); +} + diff --git a/src/main/java/com/sqx/modules/sys/service/SysLogService.java b/src/main/java/com/sqx/modules/sys/service/SysLogService.java new file mode 100644 index 0000000..f24f42c --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/SysLogService.java @@ -0,0 +1,19 @@ +package com.sqx.modules.sys.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.PageUtils; +import com.sqx.modules.sys.entity.SysLogEntity; + +import java.util.Map; + + +/** + * 系统日志 + * + */ +public interface SysLogService extends IService { + + PageUtils queryPage(Map params); + +} diff --git a/src/main/java/com/sqx/modules/sys/service/SysMenuService.java b/src/main/java/com/sqx/modules/sys/service/SysMenuService.java new file mode 100644 index 0000000..bda1f3d --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/SysMenuService.java @@ -0,0 +1,43 @@ +package com.sqx.modules.sys.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.modules.sys.entity.SysMenuEntity; + +import java.util.List; + + +/** + * 菜单管理 + * + */ +public interface SysMenuService extends IService { + + /** + * 根据父菜单,查询子菜单 + * @param parentId 父菜单ID + * @param menuIdList 用户菜单ID + */ + List queryListParentId(Long parentId, List menuIdList); + + /** + * 根据父菜单,查询子菜单 + * @param parentId 父菜单ID + */ + List queryListParentId(Long parentId); + + /** + * 获取不包含按钮的菜单列表 + */ + List queryNotButtonList(); + + /** + * 获取用户菜单列表 + */ + List getUserMenuList(Long userId); + + /** + * 删除 + */ + void delete(Long menuId); +} diff --git a/src/main/java/com/sqx/modules/sys/service/SysRoleMenuService.java b/src/main/java/com/sqx/modules/sys/service/SysRoleMenuService.java new file mode 100644 index 0000000..6ccb8ba --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/SysRoleMenuService.java @@ -0,0 +1,28 @@ +package com.sqx.modules.sys.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.modules.sys.entity.SysRoleMenuEntity; + +import java.util.List; + + + +/** + * 角色与菜单对应关系 + * + */ +public interface SysRoleMenuService extends IService { + + void saveOrUpdate(Long roleId, List menuIdList); + + /** + * 根据角色ID,获取菜单ID列表 + */ + List queryMenuIdList(Long roleId); + + /** + * 根据角色ID数组,批量删除 + */ + int deleteBatch(Long[] roleIds); + +} diff --git a/src/main/java/com/sqx/modules/sys/service/SysRoleService.java b/src/main/java/com/sqx/modules/sys/service/SysRoleService.java new file mode 100644 index 0000000..d2e5d08 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/SysRoleService.java @@ -0,0 +1,30 @@ +package com.sqx.modules.sys.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.PageUtils; +import com.sqx.modules.sys.entity.SysRoleEntity; + +import java.util.List; +import java.util.Map; + + +/** + * 角色 + * + */ +public interface SysRoleService extends IService { + + PageUtils queryPage(Map params); + + void saveRole(SysRoleEntity role); + + void update(SysRoleEntity role); + + void deleteBatch(Long[] roleIds); + + + /** + * 查询用户创建的角色ID列表 + */ + List queryRoleIdList(Long createUserId); +} diff --git a/src/main/java/com/sqx/modules/sys/service/SysUserRoleService.java b/src/main/java/com/sqx/modules/sys/service/SysUserRoleService.java new file mode 100644 index 0000000..66abf8c --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/SysUserRoleService.java @@ -0,0 +1,27 @@ +package com.sqx.modules.sys.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.modules.sys.entity.SysUserRoleEntity; + +import java.util.List; + + + +/** + * 用户与角色对应关系 + * + */ +public interface SysUserRoleService extends IService { + + void saveOrUpdate(Long userId, List roleIdList); + + /** + * 根据用户ID,获取角色ID列表 + */ + List queryRoleIdList(Long userId); + + /** + * 根据角色ID数组,批量删除 + */ + int deleteBatch(Long[] roleIds); +} diff --git a/src/main/java/com/sqx/modules/sys/service/SysUserService.java b/src/main/java/com/sqx/modules/sys/service/SysUserService.java new file mode 100644 index 0000000..1ed0289 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/SysUserService.java @@ -0,0 +1,57 @@ +package com.sqx.modules.sys.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.PageUtils; +import com.sqx.modules.sys.entity.SysUserEntity; + +import java.util.List; +import java.util.Map; + + +/** + * 系统用户 + * + */ +public interface SysUserService extends IService { + + PageUtils queryPage(Map params); + + /** + * 查询用户的所有权限 + * @param userId 用户ID + */ + List queryAllPerms(Long userId); + + /** + * 查询用户的所有菜单ID + */ + List queryAllMenuId(Long userId); + + /** + * 根据用户名,查询系统用户 + */ + SysUserEntity queryByUserName(String username); + + /** + * 保存用户 + */ + void saveUser(SysUserEntity user); + + /** + * 修改用户 + */ + void update(SysUserEntity user); + + /** + * 删除用户 + */ + void deleteBatch(Long[] userIds); + + /** + * 修改密码 + * @param userId 用户ID + * @param password 原密码 + * @param newPassword 新密码 + */ + boolean updatePassword(Long userId, String password, String newPassword); +} diff --git a/src/main/java/com/sqx/modules/sys/service/SysUserTokenService.java b/src/main/java/com/sqx/modules/sys/service/SysUserTokenService.java new file mode 100644 index 0000000..2cec7a4 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/SysUserTokenService.java @@ -0,0 +1,25 @@ +package com.sqx.modules.sys.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.sys.entity.SysUserTokenEntity; + +/** + * 用户Token + * + */ +public interface SysUserTokenService extends IService { + + /** + * 生成token + * @param userId 用户ID + */ + Result createToken(long userId); + + /** + * 退出,修改token值 + * @param userId 用户ID + */ + void logout(long userId); + +} diff --git a/src/main/java/com/sqx/modules/sys/service/impl/ShiroServiceImpl.java b/src/main/java/com/sqx/modules/sys/service/impl/ShiroServiceImpl.java new file mode 100644 index 0000000..4a600b7 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/impl/ShiroServiceImpl.java @@ -0,0 +1,60 @@ +package com.sqx.modules.sys.service.impl; + +import com.sqx.common.utils.Constant; +import com.sqx.modules.sys.dao.SysMenuDao; +import com.sqx.modules.sys.dao.SysUserDao; +import com.sqx.modules.sys.dao.SysUserTokenDao; +import com.sqx.modules.sys.entity.SysMenuEntity; +import com.sqx.modules.sys.entity.SysUserEntity; +import com.sqx.modules.sys.entity.SysUserTokenEntity; +import com.sqx.modules.sys.service.ShiroService; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +@Service +public class ShiroServiceImpl implements ShiroService { + @Autowired + private SysMenuDao sysMenuDao; + @Autowired + private SysUserDao sysUserDao; + @Autowired + private SysUserTokenDao sysUserTokenDao; + + @Override + public Set getUserPermissions(long userId) { + List permsList; + + //系统管理员,拥有最高权限 + if(userId == Constant.SUPER_ADMIN){ + List menuList = sysMenuDao.selectList(null); + permsList = new ArrayList<>(menuList.size()); + for(SysMenuEntity menu : menuList){ + permsList.add(menu.getPerms()); + } + }else{ + permsList = sysUserDao.queryAllPerms(userId); + } + //用户权限列表 + Set permsSet = new HashSet<>(); + for(String perms : permsList){ + if(StringUtils.isBlank(perms)){ + continue; + } + permsSet.addAll(Arrays.asList(perms.trim().split(","))); + } + return permsSet; + } + + @Override + public SysUserTokenEntity queryByToken(String token) { + return sysUserTokenDao.queryByToken(token); + } + + @Override + public SysUserEntity queryUser(Long userId) { + return sysUserDao.selectById(userId); + } +} diff --git a/src/main/java/com/sqx/modules/sys/service/impl/SysCaptchaServiceImpl.java b/src/main/java/com/sqx/modules/sys/service/impl/SysCaptchaServiceImpl.java new file mode 100644 index 0000000..ad23106 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/impl/SysCaptchaServiceImpl.java @@ -0,0 +1,62 @@ +package com.sqx.modules.sys.service.impl; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.code.kaptcha.Producer; +import com.sqx.common.exception.SqxException; +import com.sqx.common.utils.DateUtils; +import com.sqx.modules.sys.dao.SysCaptchaDao; +import com.sqx.modules.sys.entity.SysCaptchaEntity; +import com.sqx.modules.sys.service.SysCaptchaService; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.awt.image.BufferedImage; +import java.util.Date; + +/** + * 验证码 + * + */ +@Service("sysCaptchaService") +public class SysCaptchaServiceImpl extends ServiceImpl implements SysCaptchaService { + @Autowired + private Producer producer; + + @Override + public BufferedImage getCaptcha(String uuid) { + if(StringUtils.isBlank(uuid)){ + throw new SqxException("uuid不能为空"); + } + //生成文字验证码 + String code = producer.createText(); + + SysCaptchaEntity captchaEntity = new SysCaptchaEntity(); + captchaEntity.setUuid(uuid); + captchaEntity.setCode(code); + //5分钟后过期 + captchaEntity.setExpireTime(DateUtils.addDateMinutes(new Date(), 5)); + this.save(captchaEntity); + + return producer.createImage(code); + } + + @Override + public boolean validate(String uuid, String code) { + SysCaptchaEntity captchaEntity = this.getOne(new QueryWrapper().eq("uuid", uuid)); + if(captchaEntity == null){ + return false; + } + + //删除验证码 + this.removeById(uuid); + + if(captchaEntity.getCode().equalsIgnoreCase(code) && captchaEntity.getExpireTime().getTime() >= System.currentTimeMillis()){ + return true; + } + + return false; + } +} diff --git a/src/main/java/com/sqx/modules/sys/service/impl/SysConfigServiceImpl.java b/src/main/java/com/sqx/modules/sys/service/impl/SysConfigServiceImpl.java new file mode 100644 index 0000000..4a694ea --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/impl/SysConfigServiceImpl.java @@ -0,0 +1,96 @@ +package com.sqx.modules.sys.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.gson.Gson; +import com.sqx.common.exception.SqxException; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Query; +import com.sqx.modules.sys.dao.SysConfigDao; +import com.sqx.modules.sys.entity.SysConfigEntity; +import com.sqx.modules.sys.redis.SysConfigRedis; +import com.sqx.modules.sys.service.SysConfigService; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.Map; + +@Service("sysConfigService") +public class SysConfigServiceImpl extends ServiceImpl implements SysConfigService { + @Autowired + private SysConfigRedis sysConfigRedis; + + @Override + public PageUtils queryPage(Map params) { + String paramKey = (String)params.get("paramKey"); + + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + .like(StringUtils.isNotBlank(paramKey),"param_key", paramKey) + .eq("status", 1) + ); + + return new PageUtils(page); + } + + @Override + public void saveConfig(SysConfigEntity config) { + this.save(config); + sysConfigRedis.saveOrUpdate(config); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(SysConfigEntity config) { + this.updateById(config); + sysConfigRedis.saveOrUpdate(config); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateValueByKey(String key, String value) { + baseMapper.updateValueByKey(key, value); + sysConfigRedis.delete(key); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteBatch(Long[] ids) { + for(Long id : ids){ + SysConfigEntity config = this.getById(id); + sysConfigRedis.delete(config.getParamKey()); + } + + this.removeByIds(Arrays.asList(ids)); + } + + @Override + public String getValue(String key) { + SysConfigEntity config = sysConfigRedis.get(key); + if(config == null){ + config = baseMapper.queryByKey(key); + sysConfigRedis.saveOrUpdate(config); + } + + return config == null ? null : config.getParamValue(); + } + + @Override + public T getConfigObject(String key, Class clazz) { + String value = getValue(key); + if(StringUtils.isNotBlank(value)){ + return new Gson().fromJson(value, clazz); + } + + try { + return clazz.newInstance(); + } catch (Exception e) { + throw new SqxException("获取参数失败"); + } + } +} diff --git a/src/main/java/com/sqx/modules/sys/service/impl/SysDictServiceImpl.java b/src/main/java/com/sqx/modules/sys/service/impl/SysDictServiceImpl.java new file mode 100644 index 0000000..1910467 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/impl/SysDictServiceImpl.java @@ -0,0 +1,30 @@ +package com.sqx.modules.sys.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.modules.sys.dao.SysDictDao; +import com.sqx.modules.sys.entity.SysDictEntity; +import com.sqx.modules.sys.service.SysDictService; +import org.apache.commons.lang.StringUtils; +import org.springframework.stereotype.Service; + + +@Service("sysDictService") +public class SysDictServiceImpl extends ServiceImpl implements SysDictService { + + @Override + public PageUtils queryPage(Integer page,Integer limit,String name,String parentId,String type,Integer status) { + IPage pages = baseMapper.selectPage(new Page<>(page,limit), + new QueryWrapper() + .like(StringUtils.isNotBlank(name),"name", name) + .eq(StringUtils.isNotBlank(parentId),"parent_id",parentId) + .eq(status!=null && status!=0,"status",status) + .eq(StringUtils.isNotBlank(type),"type",type).orderByDesc("order_num")); + + return new PageUtils(pages); + } + +} diff --git a/src/main/java/com/sqx/modules/sys/service/impl/SysLogServiceImpl.java b/src/main/java/com/sqx/modules/sys/service/impl/SysLogServiceImpl.java new file mode 100644 index 0000000..fe77587 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/impl/SysLogServiceImpl.java @@ -0,0 +1,31 @@ +package com.sqx.modules.sys.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Query; +import com.sqx.modules.sys.dao.SysLogDao; +import com.sqx.modules.sys.entity.SysLogEntity; +import com.sqx.modules.sys.service.SysLogService; +import org.apache.commons.lang.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.Map; + + +@Service("sysLogService") +public class SysLogServiceImpl extends ServiceImpl implements SysLogService { + + @Override + public PageUtils queryPage(Map params) { + String key = (String)params.get("key"); + + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper().like(StringUtils.isNotBlank(key),"username", key) + ); + + return new PageUtils(page); + } +} diff --git a/src/main/java/com/sqx/modules/sys/service/impl/SysMenuServiceImpl.java b/src/main/java/com/sqx/modules/sys/service/impl/SysMenuServiceImpl.java new file mode 100644 index 0000000..2f2c197 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/impl/SysMenuServiceImpl.java @@ -0,0 +1,99 @@ +package com.sqx.modules.sys.service.impl; + + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.Constant; +import com.sqx.common.utils.MapUtils; +import com.sqx.modules.sys.dao.SysMenuDao; +import com.sqx.modules.sys.entity.SysMenuEntity; +import com.sqx.modules.sys.service.SysMenuService; +import com.sqx.modules.sys.service.SysRoleMenuService; +import com.sqx.modules.sys.service.SysUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + + +@Service("sysMenuService") +public class SysMenuServiceImpl extends ServiceImpl implements SysMenuService { + @Autowired + private SysUserService sysUserService; + @Autowired + private SysRoleMenuService sysRoleMenuService; + + @Override + public List queryListParentId(Long parentId, List menuIdList) { + List menuList = queryListParentId(parentId); + if(menuIdList == null){ + return menuList; + } + + List userMenuList = new ArrayList<>(); + for(SysMenuEntity menu : menuList){ + if(menuIdList.contains(menu.getMenuId())){ + userMenuList.add(menu); + } + } + return userMenuList; + } + + @Override + public List queryListParentId(Long parentId) { + return baseMapper.queryListParentId(parentId); + } + + @Override + public List queryNotButtonList() { + return baseMapper.queryNotButtonList(); + } + + @Override + public List getUserMenuList(Long userId) { + //系统管理员,拥有最高权限 + if(userId == Constant.SUPER_ADMIN){ + return getAllMenuList(null); + } + //用户菜单列表 + List menuIdList = sysUserService.queryAllMenuId(userId); + return getAllMenuList(menuIdList); + } + + @Override + public void delete(Long menuId){ + //删除菜单 + this.removeById(menuId); + //删除菜单与角色关联 + sysRoleMenuService.removeByMap(new MapUtils().put("menu_id", menuId)); + } + + /** + * 获取所有菜单列表 + */ + private List getAllMenuList(List menuIdList){ + //查询根菜单列表 + List menuList = queryListParentId(0L, menuIdList); + //递归获取子菜单 + getMenuTreeList(menuList, menuIdList); + + return menuList; + } + + /** + * 递归 + */ + private List getMenuTreeList(List menuList, List menuIdList){ + List subMenuList = new ArrayList(); + + for(SysMenuEntity entity : menuList){ + //目录 + if(entity.getType() == Constant.MenuType.CATALOG.getValue()){ + entity.setList(getMenuTreeList(queryListParentId(entity.getMenuId(), menuIdList), menuIdList)); + } + subMenuList.add(entity); + } + + return subMenuList; + } +} diff --git a/src/main/java/com/sqx/modules/sys/service/impl/SysRoleMenuServiceImpl.java b/src/main/java/com/sqx/modules/sys/service/impl/SysRoleMenuServiceImpl.java new file mode 100644 index 0000000..c68928e --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/impl/SysRoleMenuServiceImpl.java @@ -0,0 +1,51 @@ +package com.sqx.modules.sys.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.modules.sys.dao.SysRoleMenuDao; +import com.sqx.modules.sys.entity.SysRoleMenuEntity; +import com.sqx.modules.sys.service.SysRoleMenuService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + + + +/** + * 角色与菜单对应关系 + * + */ +@Service("sysRoleMenuService") +public class SysRoleMenuServiceImpl extends ServiceImpl implements SysRoleMenuService { + + @Override + @Transactional(rollbackFor = Exception.class) + public void saveOrUpdate(Long roleId, List menuIdList) { + //先删除角色与菜单关系 + deleteBatch(new Long[]{roleId}); + + if(menuIdList.size() == 0){ + return ; + } + + //保存角色与菜单关系 + for(Long menuId : menuIdList){ + SysRoleMenuEntity sysRoleMenuEntity = new SysRoleMenuEntity(); + sysRoleMenuEntity.setMenuId(menuId); + sysRoleMenuEntity.setRoleId(roleId); + + this.save(sysRoleMenuEntity); + } + } + + @Override + public List queryMenuIdList(Long roleId) { + return baseMapper.queryMenuIdList(roleId); + } + + @Override + public int deleteBatch(Long[] roleIds){ + return baseMapper.deleteBatch(roleIds); + } + +} diff --git a/src/main/java/com/sqx/modules/sys/service/impl/SysRoleServiceImpl.java b/src/main/java/com/sqx/modules/sys/service/impl/SysRoleServiceImpl.java new file mode 100644 index 0000000..7416971 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/impl/SysRoleServiceImpl.java @@ -0,0 +1,113 @@ +package com.sqx.modules.sys.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Query; +import com.sqx.modules.sys.dao.SysRoleDao; +import com.sqx.modules.sys.entity.SysRoleEntity; +import com.sqx.modules.sys.service.SysRoleMenuService; +import com.sqx.modules.sys.service.SysRoleService; +import com.sqx.modules.sys.service.SysUserRoleService; +import com.sqx.modules.sys.service.SysUserService; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 角色 + * + */ +@Service("sysRoleService") +public class SysRoleServiceImpl extends ServiceImpl implements SysRoleService { + @Autowired + private SysRoleMenuService sysRoleMenuService; + @Autowired + private SysUserService sysUserService; + @Autowired + private SysUserRoleService sysUserRoleService; + + @Override + public PageUtils queryPage(Map params) { + String roleName = (String)params.get("roleName"); + Long createUserId = (Long)params.get("createUserId"); + + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + .like(StringUtils.isNotBlank(roleName),"role_name", roleName) + .eq(createUserId != null,"create_user_id", createUserId) + ); + + return new PageUtils(page); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void saveRole(SysRoleEntity role) { + role.setCreateTime(new Date()); + this.save(role); + + //检查权限是否越权 + checkPrems(role); + + //保存角色与菜单关系 + sysRoleMenuService.saveOrUpdate(role.getRoleId(), role.getMenuIdList()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(SysRoleEntity role) { + this.updateById(role); + + //检查权限是否越权 + checkPrems(role); + + //更新角色与菜单关系 + sysRoleMenuService.saveOrUpdate(role.getRoleId(), role.getMenuIdList()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteBatch(Long[] roleIds) { + //删除角色 + this.removeByIds(Arrays.asList(roleIds)); + + //删除角色与菜单关联 + sysRoleMenuService.deleteBatch(roleIds); + + //删除角色与用户关联 + sysUserRoleService.deleteBatch(roleIds); + } + + + @Override + public List queryRoleIdList(Long createUserId) { + return baseMapper.queryRoleIdList(createUserId); + } + + /** + * 检查权限是否越权 + */ + private void checkPrems(SysRoleEntity role){ + /*//如果不是超级管理员,则需要判断角色的权限是否超过自己的权限 + if(role.getCreateUserId() == Constant.SUPER_ADMIN){ + return ; + } + + //查询用户所拥有的菜单列表 + List menuIdList = sysUserService.queryAllMenuId(role.getCreateUserId()); + + //判断是否越权 + if(!menuIdList.containsAll(role.getMenuIdList())){ + throw new SqxException("新增角色的权限,已超出你的权限范围"); + }*/ + } +} diff --git a/src/main/java/com/sqx/modules/sys/service/impl/SysUserRoleServiceImpl.java b/src/main/java/com/sqx/modules/sys/service/impl/SysUserRoleServiceImpl.java new file mode 100644 index 0000000..786102a --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/impl/SysUserRoleServiceImpl.java @@ -0,0 +1,49 @@ +package com.sqx.modules.sys.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.MapUtils; +import com.sqx.modules.sys.dao.SysUserRoleDao; +import com.sqx.modules.sys.entity.SysUserRoleEntity; +import com.sqx.modules.sys.service.SysUserRoleService; +import org.springframework.stereotype.Service; + +import java.util.List; + + + +/** + * 用户与角色对应关系 + * + */ +@Service("sysUserRoleService") +public class SysUserRoleServiceImpl extends ServiceImpl implements SysUserRoleService { + + @Override + public void saveOrUpdate(Long userId, List roleIdList) { + //先删除用户与角色关系 + this.removeByMap(new MapUtils().put("user_id", userId)); + + if(roleIdList == null || roleIdList.size() == 0){ + return ; + } + + //保存用户与角色关系 + for(Long roleId : roleIdList){ + SysUserRoleEntity sysUserRoleEntity = new SysUserRoleEntity(); + sysUserRoleEntity.setUserId(userId); + sysUserRoleEntity.setRoleId(roleId); + + this.save(sysUserRoleEntity); + } + } + + @Override + public List queryRoleIdList(Long userId) { + return baseMapper.queryRoleIdList(userId); + } + + @Override + public int deleteBatch(Long[] roleIds){ + return baseMapper.deleteBatch(roleIds); + } +} diff --git a/src/main/java/com/sqx/modules/sys/service/impl/SysUserServiceImpl.java b/src/main/java/com/sqx/modules/sys/service/impl/SysUserServiceImpl.java new file mode 100644 index 0000000..1a84382 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/impl/SysUserServiceImpl.java @@ -0,0 +1,136 @@ +package com.sqx.modules.sys.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Query; +import com.sqx.modules.sys.dao.SysUserDao; +import com.sqx.modules.sys.entity.SysUserEntity; +import com.sqx.modules.sys.service.SysRoleService; +import com.sqx.modules.sys.service.SysUserRoleService; +import com.sqx.modules.sys.service.SysUserService; +import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.shiro.crypto.hash.Sha256Hash; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; + + +/** + * 系统用户 + * + */ +@SuppressWarnings("ALL") +@Service("sysUserService") +public class SysUserServiceImpl extends ServiceImpl implements SysUserService { + @Autowired + private SysUserRoleService sysUserRoleService; + @Autowired + private SysRoleService sysRoleService; + + @Override + public PageUtils queryPage(Map params) { + String username = (String)params.get("username"); + Long createUserId = (Long)params.get("createUserId"); + + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + .like(StringUtils.isNotBlank(username),"username", username) + .eq(createUserId != null,"create_user_id", createUserId) + ); + + return new PageUtils(page); + } + + @Override + public List queryAllPerms(Long userId) { + return baseMapper.queryAllPerms(userId); + } + + @Override + public List queryAllMenuId(Long userId) { + return baseMapper.queryAllMenuId(userId); + } + + @Override + public SysUserEntity queryByUserName(String username) { + return baseMapper.queryByUserName(username); + } + + @SuppressWarnings("AlibabaTransactionMustHaveRollback") + @Override + @Transactional + public void saveUser(SysUserEntity user) { + user.setCreateTime(new Date()); + //sha256加密 + String salt = RandomStringUtils.randomAlphanumeric(20); + user.setPassword(new Sha256Hash(user.getPassword(), salt).toHex()); + user.setSalt(salt); + this.save(user); + + //检查角色是否越权 + checkRole(user); + + //保存用户与角色关系 + sysUserRoleService.saveOrUpdate(user.getUserId(), user.getRoleIdList()); + } + + @Override + @Transactional + public void update(SysUserEntity user) { + if(StringUtils.isBlank(user.getPassword())){ + user.setPassword(null); + }else{ + user.setPassword(new Sha256Hash(user.getPassword(), user.getSalt()).toHex()); + } + this.updateById(user); + + //检查角色是否越权 + checkRole(user); + + //保存用户与角色关系 + sysUserRoleService.saveOrUpdate(user.getUserId(), user.getRoleIdList()); + } + + @Override + public void deleteBatch(Long[] userId) { + this.removeByIds(Arrays.asList(userId)); + } + + @Override + public boolean updatePassword(Long userId, String password, String newPassword) { + SysUserEntity userEntity = new SysUserEntity(); + userEntity.setPassword(newPassword); + return this.update(userEntity, + new QueryWrapper().eq("user_id", userId).eq("password", password)); + } + + /** + * 检查角色是否越权 + */ + private void checkRole(SysUserEntity user){ + /*if(user.getRoleIdList() == null || user.getRoleIdList().size() == 0){ + return; + } + //如果不是超级管理员,则需要判断用户的角色是否自己创建 + if(user.getCreateUserId() == Constant.SUPER_ADMIN){ + return ; + } + + //查询用户创建的角色列表 + List roleIdList = sysRoleService.queryRoleIdList(user.getCreateUserId()); + + //判断是否越权 + if(!roleIdList.containsAll(user.getRoleIdList())){ + throw new SqxException("新增用户所选角色,不是本人创建"); + }*/ + } +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/sys/service/impl/SysUserTokenServiceImpl.java b/src/main/java/com/sqx/modules/sys/service/impl/SysUserTokenServiceImpl.java new file mode 100644 index 0000000..1e40e84 --- /dev/null +++ b/src/main/java/com/sqx/modules/sys/service/impl/SysUserTokenServiceImpl.java @@ -0,0 +1,66 @@ +package com.sqx.modules.sys.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.Result; +import com.sqx.modules.sys.dao.SysUserTokenDao; +import com.sqx.modules.sys.entity.SysUserTokenEntity; +import com.sqx.modules.sys.oauth2.TokenGenerator; +import com.sqx.modules.sys.service.SysUserTokenService; +import org.springframework.stereotype.Service; + +import java.util.Date; + + +@Service("sysUserTokenService") +public class SysUserTokenServiceImpl extends ServiceImpl implements SysUserTokenService { + //12小时后过期 + private final static int EXPIRE = 3600 * 12; + + + @Override + public Result createToken(long userId) { + //生成一个token + String token = TokenGenerator.generateValue(); + + //当前时间 + Date now = new Date(); + //过期时间 + Date expireTime = new Date(now.getTime() + EXPIRE * 1000); + + //判断是否生成过token + SysUserTokenEntity tokenEntity = this.getById(userId); + if(tokenEntity == null){ + tokenEntity = new SysUserTokenEntity(); + tokenEntity.setUserId(userId); + tokenEntity.setToken(token); + tokenEntity.setUpdateTime(now); + tokenEntity.setExpireTime(expireTime); + + //保存token + this.save(tokenEntity); + }else{ + tokenEntity.setToken(token); + tokenEntity.setUpdateTime(now); + tokenEntity.setExpireTime(expireTime); + + //更新token + this.updateById(tokenEntity); + } + + Result r = Result.success().put("token", token).put("expire", EXPIRE); + + return r; + } + + @Override + public void logout(long userId) { + //生成一个token + String token = TokenGenerator.generateValue(); + + //修改token + SysUserTokenEntity tokenEntity = new SysUserTokenEntity(); + tokenEntity.setUserId(userId); + tokenEntity.setToken(token); + this.updateById(tokenEntity); + } +} diff --git a/src/main/java/com/sqx/modules/taking/controller/GameController.java b/src/main/java/com/sqx/modules/taking/controller/GameController.java new file mode 100644 index 0000000..ab74dfc --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/controller/GameController.java @@ -0,0 +1,77 @@ +package com.sqx.modules.taking.controller; +import com.sqx.common.utils.Result; +import com.sqx.modules.taking.service.GameService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@AllArgsConstructor +@RequestMapping("/game") +@Api("游戏分类") +public class GameController { + private GameService gameService; + + /** + * 查看游戏分类 + */ + @GetMapping("/queryGameName") + @ApiOperation("查看游戏分类") + public Result queryAllGameName(Long page, Long limit) { + return gameService.queryAllGameName(page, limit); + } + + /** + * 添加游戏分类 + */ + @GetMapping("/addGameName") + @ApiOperation("添加游戏分类") + public Result addGameName(String gameName,String gameImg) { + return gameService.addGameName(gameName,gameImg); + } + + /** + * 修改游戏分类 + */ + @GetMapping("/updateGameName") + @ApiOperation("修改游戏分类") + public Result updateGameName(Long id, String gameName,String gameImg, Long status) { + return gameService.updateGameName(id, gameName,gameImg, status); + } + + /** + * 删除游戏分类 + */ + @GetMapping("/deleteGameName") + @ApiOperation("删除游戏分类") + public Result deleteGameName(Long id) { + return gameService.deleteGameName(id); + } + + /** + * 查看启用的游戏分类 + */ + @GetMapping("/queryGame") + @ApiOperation("查看启用的游戏分类") + public Result queryGameName() { + return gameService.queryGameName(); + } + + /** + * 是否启用游戏分类 + */ + @GetMapping("/enableGameName") + @ApiOperation("是否启用游戏分类") + public Result enableGameName(Long status, Long id) { + if (status == null || id == null) { + return Result.error("启用分类的条件为空"); + } else { + return gameService.enableGameName(status, id); + } + } + + +} diff --git a/src/main/java/com/sqx/modules/taking/controller/OrderTakingCommentController.java b/src/main/java/com/sqx/modules/taking/controller/OrderTakingCommentController.java new file mode 100644 index 0000000..20333fe --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/controller/OrderTakingCommentController.java @@ -0,0 +1,50 @@ +package com.sqx.modules.taking.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.sqx.common.utils.Result; +import com.sqx.modules.taking.entity.TakingCommnt; +import com.sqx.modules.taking.service.OrderTakingCommentService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/takingComment") +@Api(value = "评论", tags = {"评论"}) +public class OrderTakingCommentController { + + @Autowired + private OrderTakingCommentService orderTakingCommentService; + + /** + * 查看我的评论 + */ + @GetMapping("/queryMyComment") + public Result queryMyComment(Integer page,Integer limit,Long userId){ + return orderTakingCommentService.selectOrderTakingCommentByUserId(page,limit,userId); + } + + @GetMapping("/selectOrderTakingComment") + @ApiOperation("查看评论") + public Result selectOrderTakingComment(Integer page, Integer limit, Long id,Long massageTypeId) { + return orderTakingCommentService.selectOrderTakingComment(page, limit, id,massageTypeId); + } + + @PostMapping("/deleteOrderTakingComment/{id}") + @ApiOperation("删除评论") + public Result deleteOrderTakingComment(@PathVariable Long id){ + orderTakingCommentService.removeById(id); + return Result.success(); + } + + @GetMapping("/selectOrderTakingCommentByOrdersId") + @ApiOperation("根据订单查看评论") + public Result selectOrderTakingCommentByOrdersId(Long ordersId){ + return Result.success().put("data",orderTakingCommentService.getOne(new QueryWrapper().eq("order_id",ordersId))); + } + + + +} diff --git a/src/main/java/com/sqx/modules/taking/controller/app/AppGameController.java b/src/main/java/com/sqx/modules/taking/controller/app/AppGameController.java new file mode 100644 index 0000000..e565ff9 --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/controller/app/AppGameController.java @@ -0,0 +1,25 @@ +package com.sqx.modules.taking.controller.app; + +import com.sqx.common.utils.Result; +import com.sqx.modules.taking.service.GameService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@AllArgsConstructor +@RequestMapping("app/appGame") +@Api("app游戏分类") +public class AppGameController { + + private GameService gameService; + + @GetMapping("/queryGameName") + @ApiOperation("查询首页游戏分类") + public Result queryGameName() { + return gameService.queryGameName(); + } +} diff --git a/src/main/java/com/sqx/modules/taking/controller/app/AppOrderTakingCommentController.java b/src/main/java/com/sqx/modules/taking/controller/app/AppOrderTakingCommentController.java new file mode 100644 index 0000000..bb4a023 --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/controller/app/AppOrderTakingCommentController.java @@ -0,0 +1,87 @@ +package com.sqx.modules.taking.controller.app; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.annotation.Login; +import com.sqx.modules.taking.entity.TakingCommnt; +import com.sqx.modules.taking.service.OrderTakingCommentService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +@RestController +@AllArgsConstructor +@RequestMapping("/app/takingComment") +@Api(value = "APP评论|点赞", tags = {"APP评论|点赞"}) +public class AppOrderTakingCommentController { + + private OrderTakingCommentService orderTakingCommentService; + + /** + * 查看接单下的所有评论内容 时间 评论人 评论人图像 评论点赞次数 + * + * @param page + * @param limit + * @param + */ + @CrossOrigin + @GetMapping("/selectOrderTakingComment") + @ApiOperation("查看评论") + public Result selectOrderTakingComment(Integer page, Integer limit, Long artificerId,Long massageTypeId) { + return orderTakingCommentService.selectOrderTakingComment(page, limit, artificerId,massageTypeId); + } + /** + * 查看技师评论 + * + * @param page + * @param limit + * @param + */ + @CrossOrigin + @GetMapping("/selectTakingCommentByArtificerId") + @ApiOperation("查看评论") + public Result selectTakingCommentByArtificerId(Integer page, Integer limit, Long artificerId) { + return orderTakingCommentService.selectTakingCommentByArtificerId(page, limit, artificerId); + } + @GetMapping("/selectOrderTakingCommentByOrdersId") + @ApiOperation("根据订单查看评论") + public Result selectOrderTakingCommentByOrdersId(Long ordersId){ + return Result.success().put("data",orderTakingCommentService.getOne(new QueryWrapper().eq("orders_id",ordersId))); + } + + + + /** + * 有赞时取消点赞 没赞时点赞 + * + * @param commentId + * @param userId + * @return + */ + @Login + @GetMapping("/updateGoodsNum") + @ApiOperation("点赞评论") + public Result updateGoodsNum(Long commentId, @RequestAttribute("userId") Long userId) { + return orderTakingCommentService.updateGoodsNum(commentId, userId); + } + + /** + * 添加评论 + */ + @Login + @PostMapping("/addGoodsNum") + @ApiOperation("添加评论") + public Result addGoodsNum(Long orderId, @RequestAttribute("userId") Long userId, String content, Integer score,Long artificerId) { + return orderTakingCommentService.addGoodsNum(orderId, userId, content, score,artificerId); + } + + @Login + @GetMapping("/selectTakingCommentCount") + @ApiOperation("查询评论次数") + public Result selectTakingCommentCount(Long ordersId, @RequestAttribute("userId") Long userId) { + return Result.success().put("data",orderTakingCommentService.selectTakingCommentCount(ordersId, userId)); + } + + +} diff --git a/src/main/java/com/sqx/modules/taking/dao/GameDao.java b/src/main/java/com/sqx/modules/taking/dao/GameDao.java new file mode 100644 index 0000000..1780d9f --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/dao/GameDao.java @@ -0,0 +1,9 @@ +package com.sqx.modules.taking.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.taking.entity.Game; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface GameDao extends BaseMapper { +} diff --git a/src/main/java/com/sqx/modules/taking/dao/OrderTakingCommentDao.java b/src/main/java/com/sqx/modules/taking/dao/OrderTakingCommentDao.java new file mode 100644 index 0000000..d42605d --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/dao/OrderTakingCommentDao.java @@ -0,0 +1,34 @@ +package com.sqx.modules.taking.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.modules.taking.entity.CommentFabulous; +import com.sqx.modules.taking.entity.TakingCommnt; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Map; + +@Mapper +public interface OrderTakingCommentDao extends BaseMapper { + IPage> selectOrderTakingComment(IPage page, @Param("artificerId") Long artificerId,@Param("massageTypeId") Long massageTypeId); + + int selectCommentNumber(@Param("id") Long id); + + CommentFabulous selectGoodsNum(@Param("commentId") Long commentId, @Param("userId") Long userId); + + int deleteGoodsNum(@Param("id") Long id); + + int insertGoodsNum(@Param("commentId") Long commentId, @Param("userId") Long userId); + + Double selectAvgScore(@Param("artificerId") Long artificerId); + + IPage> selectOrderTakingCommentByUserId(Page> page, @Param("userId") Long userId); + + Double selectCountTakingByUserId(Long userId,@Param("startTime") String startTime,@Param("endTime") String endTime); + + Integer selectCommentCount(Long userId,Integer type,@Param("startTime") String startTime,@Param("endTime") String endTime); + + IPage selectTakingCommentByArtificerId(IPage page1, @Param("artificerId")Long artificerId); +} diff --git a/src/main/java/com/sqx/modules/taking/entity/CommentFabulous.java b/src/main/java/com/sqx/modules/taking/entity/CommentFabulous.java new file mode 100644 index 0000000..170d295 --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/entity/CommentFabulous.java @@ -0,0 +1,41 @@ +package com.sqx.modules.taking.entity; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description comment_fabulous + * @author liyuan + * @date 2021-08-12 + */ +@Data +@ApiModel("comment_fabulous") +public class CommentFabulous implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 点赞id + */ + @ApiModelProperty("点赞id") + private Long id; + + /** + * 接单评论id + */ + @ApiModelProperty("接单评论id") + private Long takingCommentId; + + /** + * 用户id + */ + @ApiModelProperty("用户id") + private Long userId; + + public CommentFabulous() {} +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/taking/entity/Game.java b/src/main/java/com/sqx/modules/taking/entity/Game.java new file mode 100644 index 0000000..a2b5eb8 --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/entity/Game.java @@ -0,0 +1,41 @@ +package com.sqx.modules.taking.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +import java.io.Serializable; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@ToString +@ApiModel("游戏分类") +public class Game implements Serializable { + @ApiModelProperty("id") + @TableId(type = IdType.AUTO) + private Long id; + @ApiModelProperty("游戏名称") + @TableField("game_name") + private String gameName; + @ApiModelProperty("0启用1删除") + @TableField("status") + private Long status; + @ApiModelProperty("创建时间") + @TableField("create_time") + private String createTime; + @ApiModelProperty("修改时间") + @TableField("update_time") + private String updateTime; + @ApiModelProperty("游戏图片") + @TableField("game_img") + private String gameImg; + + +} diff --git a/src/main/java/com/sqx/modules/taking/entity/TakingCommnt.java b/src/main/java/com/sqx/modules/taking/entity/TakingCommnt.java new file mode 100644 index 0000000..e807367 --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/entity/TakingCommnt.java @@ -0,0 +1,68 @@ +package com.sqx.modules.taking.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +import java.io.Serializable; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@ToString +@ApiModel("接单评论") +public class TakingCommnt implements Serializable { + @TableId(type = IdType.AUTO) + private Long id; + /** + * 订单id + */ + private Long orderId; + /** + * 用户id + */ + private Long userId; + /** + * 评论内容 + */ + private String content; + /** + * 创建时间 + */ + private String createTime; + /** + * 点赞次数 + */ + @TableField(exist = false) + private Long count; + /** + * 邮件 + */ + private String mail; + + private Integer score; + + private Long artificerId; + + private Long massageTypeId; + + //技师名称 + @TableField(exist = false) + private String artificerName; + //服务名称 + @TableField(exist = false) + private String title; + //服务时间 + @TableField(exist = false) + private String serserveTime; + //客户名称 + @TableField(exist = false) + private String userName; + + +} diff --git a/src/main/java/com/sqx/modules/taking/response/MyReleaseResponse.java b/src/main/java/com/sqx/modules/taking/response/MyReleaseResponse.java new file mode 100644 index 0000000..fefbbdc --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/response/MyReleaseResponse.java @@ -0,0 +1,57 @@ +package com.sqx.modules.taking.response; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +public class MyReleaseResponse implements Serializable { + /** + * 接单id + */ + private Long id; + /** + * 发布状态 + */ + private String status; + /** + * 更新时间 + */ + private String updateTime; + /** + * 游戏名称 + */ + private String gameName; + /** + * 价格 + */ + private Double money; + private String orderLevel; + /** + * 接单时间 + */ + private String orderTakingTime; + private BigDecimal oldMoney; + private BigDecimal memberMoney; + private String gameImg; + private String content; + private String city; + private Integer sec; + private String createTime; + private Integer classify; + private String unit; + private String myLevel; + private String homepageImg; + private Integer salesNum; + private Integer authentication; + + private String describes; + private String headImg; + private String certificateImg; + private String workImg; + private String name; + private Integer sex; + private String region; + private String birthdate; +} diff --git a/src/main/java/com/sqx/modules/taking/response/OrderTakingResponse.java b/src/main/java/com/sqx/modules/taking/response/OrderTakingResponse.java new file mode 100644 index 0000000..edd4335 --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/response/OrderTakingResponse.java @@ -0,0 +1,79 @@ +package com.sqx.modules.taking.response; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +public class OrderTakingResponse implements Serializable { + /** + * 接单id + */ + private Long id; + /** + * 发布人id + */ + private Long userId; + + /** + * 发布人姓名 + */ + private String userName; + + /** + * 性别 + */ + private Integer sex; + + /** + * 年龄 + */ + private Integer age; + /** + * 发布城市 + */ + private String city; + /** + * 发布人图像 + */ + private String avatar; + /** + * 接单游戏 + */ + private String gameName; + /** + * 我的段位 + */ + private String myLevel; + /** + * 订单评分 + */ + private Double orderScore; + /** + * 价钱 + */ + private BigDecimal money; + /** + * 服务人数 + */ + private int count; + private BigDecimal oldMoney; + private BigDecimal memberMoney; + private String gameImg; + private Integer sec; + private Integer classify; + private String unit; + private String homepageImg; + private Integer salesNum; + private Integer authentication; + + private String describes; + private String headImg; + private String certificateImg; + private String workImg; + private String name; + private String region; + private String birthdate; + private String orderLevel; +} diff --git a/src/main/java/com/sqx/modules/taking/response/TakingCommentResponse.java b/src/main/java/com/sqx/modules/taking/response/TakingCommentResponse.java new file mode 100644 index 0000000..23bf245 --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/response/TakingCommentResponse.java @@ -0,0 +1,59 @@ +package com.sqx.modules.taking.response; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class TakingCommentResponse implements Serializable { + + /** + * 评论id + */ + private Long id; + /** + * 用户名 + */ + @ApiModelProperty("用户名") + @TableField("user_name") + private String userName; + + /** + * 头像 + */ + @ApiModelProperty("头像") + private String avatar; + /** + * 评论内容 + */ + private String content; + /** + * 点赞量 + */ + private int count; + /** + * 等级 + */ + private String grade; + + private Integer score; + + private String createTime; + + private Long userId; + + @TableField(exist = false) + private String artificerName; + + @TableField(exist = false) + private String title; + + @TableField(exist = false) + private Long artificerUserId; + + +} diff --git a/src/main/java/com/sqx/modules/taking/response/TakingDetailsResponse.java b/src/main/java/com/sqx/modules/taking/response/TakingDetailsResponse.java new file mode 100644 index 0000000..8413ab0 --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/response/TakingDetailsResponse.java @@ -0,0 +1,99 @@ +package com.sqx.modules.taking.response; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 接单详情返回字段 + */ +@Data +public class TakingDetailsResponse implements Serializable { + + + private Long id; + /** + *发布用户id + */ + private Long userId; + /** + * 主页显示图片 + */ + private String homepageImg; + + private String detailsImg; + /** + * 用户图像 + */ + private String avatar; + /** + * 用户名 + */ + private String userName; + /** + * 城市 + */ + private String city; + /** + * 游戏名称 + */ + private String gameName; + /** + * 性别 1男 2女 + */ + private Integer sex; + /** + * 年龄 + */ + private Integer age; + /** + * 价格 + */ + private Double money; + /** + * 单位 + */ + private String unitType; + /** + * 评分 + */ + private Double orderScore; + /** + * 下单 + */ + private int count; + /** + * 语音介绍 + */ + private String voiceIntroduce; + /** + * 接单大区 + */ + private String orderTakingArea; + /** + * 接单时间 + */ + private String orderTakingTime; + private BigDecimal oldMoney; + private BigDecimal memberMoney; + private String gameImg; + private Integer sec; + private String createTime; + private String myLevel; + private Integer classify; + private String unit; + private Integer salesNum; + private Integer authentication; + + private String describes; + private String headImg; + private String certificateImg; + private String workImg; + private String name; + private String region; + private String birthdate; + private String orderTakingUserName; + private String orderLevel; + +} diff --git a/src/main/java/com/sqx/modules/taking/response/TakingResponse.java b/src/main/java/com/sqx/modules/taking/response/TakingResponse.java new file mode 100644 index 0000000..d2523ef --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/response/TakingResponse.java @@ -0,0 +1,96 @@ +package com.sqx.modules.taking.response; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.sqx.modules.taking.entity.Game; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 接单返回字段 + */ +@Data +public class TakingResponse implements Serializable { + @ApiModelProperty("接单id") + private Long id; + @ApiModelProperty("游戏id类型") + @TableField("game_id") + private String gameId; + @TableField(exist = false) + private String gameName; + @ApiModelProperty("我的段位") + @TableField("my_level") + private String myLevel; + @ApiModelProperty("接单段位") + @TableField("order_level") + private String orderLevel; + @ApiModelProperty("接单时间") + @TableField("order_taking_time") + private String orderTakingTime; + @ApiModelProperty("接单大区") + @TableField("order_taking_area") + private String orderTakingArea; + @ApiModelProperty("价格") + @TableField("money") + private BigDecimal money; + @ApiModelProperty("语音介绍") + @TableField("voice_introduce") + private String voiceIntroduce; + @ApiModelProperty("主页图片") + @TableField("homepage_img") + private String homepageImg; + @ApiModelProperty("详情图") + @TableField("details_img") + private String detailsImg; + @ApiModelProperty("创建时间") + @TableField("create_time") + private String createTime; + @ApiModelProperty("接单状态0进行中1待审核2已取消3完成") + @TableField("status") + private int status; + @ApiModelProperty("是否是推荐接单0是1不是") + @TableField("is_recommend") + private String isRecommend; + @ApiModelProperty("发布人") + @TableField("user_id") + private Long userId; + @TableField(exist = false) + private String userName; + @TableField(exist = false) + private String avatar; + @ApiModelProperty("城市") + private String city; + @ApiModelProperty("人数") + private int count; + @ApiModelProperty("评分") + @TableField("order_score") + private Double orderScore; + @ApiModelProperty("精度") + private String longitude; + @ApiModelProperty("维度") + private String latitude; + private BigDecimal oldMoney; + private BigDecimal memberMoney; + private String content; + private String gameImg; + private Integer sec; + private Integer sex; + private Integer age; + private Integer classify; + private String unit; + private Integer salesNum; + private Integer authentication; + + private String describes; + private String headImg; + private String certificateImg; + private String workImg; + private String name; + private String region; + private String birthdate; +// private String createTime; +} diff --git a/src/main/java/com/sqx/modules/taking/service/GameService.java b/src/main/java/com/sqx/modules/taking/service/GameService.java new file mode 100644 index 0000000..dedf258 --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/service/GameService.java @@ -0,0 +1,55 @@ +package com.sqx.modules.taking.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.sqx.common.utils.Result; +import com.sqx.modules.taking.entity.Game; +import io.swagger.annotations.ApiParam; + +public interface GameService { + + /** + * 查询首页游戏分类 + * + * @return + */ + Result queryGameName(); + + + /** + * 添加游戏分类 + * + * @param + * @return + */ + Result addGameName(String gameName,String gameImg); + + /** + * 修改游戏分类 + * + * @param + * @return + */ + Result updateGameName(Long id, String gameName,String gameImg, Long status); + + /** + * 删除游戏分类 + * + * @param id + * @return + */ + Result deleteGameName(Long id); + + /** + * 查看所有游戏分类信息 + * + * @param page + * @param limit + * @return + */ + Result queryAllGameName(Long page, Long limit); + + /** + * 是否启用游戏分类 + */ + Result enableGameName(Long status, Long id); +} diff --git a/src/main/java/com/sqx/modules/taking/service/OrderTakingCommentService.java b/src/main/java/com/sqx/modules/taking/service/OrderTakingCommentService.java new file mode 100644 index 0000000..f697ca9 --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/service/OrderTakingCommentService.java @@ -0,0 +1,39 @@ +package com.sqx.modules.taking.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.App; +import com.sqx.modules.taking.entity.TakingCommnt; +import org.springframework.web.bind.annotation.RequestAttribute; + +public interface OrderTakingCommentService extends IService { + /** + * 查看接单的评论 + */ + Result selectOrderTakingComment(Integer page, Integer limit, Long id,Long massageTypeId); + + Result selectOrderTakingCommentByUserId(Integer page, Integer limit, Long userId); + + /** + * 点赞 + * + * @param commentId + * @param userId + * @return + */ + Result updateGoodsNum(Long commentId, Long userId); + + /** + * 添加评论 + * + * @param orderId + * @param userId + * @param content + */ + Result addGoodsNum(Long orderId, Long userId, String content, Integer score,Long artificerId); + + + int selectTakingCommentCount(Long orderTakingId,Long userId); + + Result selectTakingCommentByArtificerId(Integer page, Integer limit, Long artificerId); +} diff --git a/src/main/java/com/sqx/modules/taking/service/impl/GameServiceImpl.java b/src/main/java/com/sqx/modules/taking/service/impl/GameServiceImpl.java new file mode 100644 index 0000000..e830566 --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/service/impl/GameServiceImpl.java @@ -0,0 +1,112 @@ +package com.sqx.modules.taking.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.Result; +import com.sqx.modules.taking.dao.GameDao; +import com.sqx.modules.taking.entity.Game; +import com.sqx.modules.taking.service.GameService; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +@Service +@AllArgsConstructor +public class GameServiceImpl extends ServiceImpl implements GameService { + + + @Override + public Result queryGameName() { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("status", 0); + List games = baseMapper.selectList(queryWrapper); + return Result.success().put("data", games); + } + + + + @Override + public Result addGameName(String gameName,String gameImg) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (gameName == null) { + return Result.error("游戏分类信息为null"); + } else { + Game game = new Game(); + game.setCreateTime(simpleDateFormat.format(new Date())); + game.setUpdateTime(simpleDateFormat.format(new Date())); + game.setGameName(gameName); + game.setGameImg(gameImg); + game.setStatus((long) 0); + int i = baseMapper.insert(game); + if (i > 0) { + return Result.success(); + } else { + return Result.error(); + } + } + + } + + @Override + public Result updateGameName(Long id, String gameName, String gameImg,Long status) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Game game = baseMapper.selectById(id); + if (game == null) { + return Result.error("游戏分类信息为null"); + } else { + game.setUpdateTime(simpleDateFormat.format(new Date())); + game.setGameName(gameName); + game.setStatus(status); + game.setGameImg(gameImg); + int i = baseMapper.updateById(game); + if (i > 0) { + return Result.success(); + } else { + return Result.error(); + } + } + } + + @Override + public Result deleteGameName(Long id) { + + Game game = baseMapper.selectById(id); + if (game != null) { + baseMapper.deleteById(id); + return Result.success(); + } else { + return Result.error("游戏信息不存在!"); + + } + } + + @Override + public Result queryAllGameName(Long page, Long limit) { + if (page == null || limit == null) { + return Result.error("分页条件为空!"); + } else { + Page page1 = new Page<>(page, limit); + return Result.success().put("data", baseMapper.selectPage(page1, null)); + } + } + + @Override + public Result enableGameName(Long status, Long id) { + Game game = baseMapper.selectById(id); + if (game == null) { + return Result.error("游戏分类信息不存在"); + } else { + game.setStatus(status); + game.setUpdateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + baseMapper.updateById(game); + return Result.success(); + } + + } + + +} diff --git a/src/main/java/com/sqx/modules/taking/service/impl/OrderTakingCommentServiceImpl.java b/src/main/java/com/sqx/modules/taking/service/impl/OrderTakingCommentServiceImpl.java new file mode 100644 index 0000000..1969399 --- /dev/null +++ b/src/main/java/com/sqx/modules/taking/service/impl/OrderTakingCommentServiceImpl.java @@ -0,0 +1,163 @@ +package com.sqx.modules.taking.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.entity.MassageType; +import com.sqx.modules.artificer.entity.Orders; +import com.sqx.modules.artificer.service.MassageTypeService; +import com.sqx.modules.artificer.service.OrdersService; +import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.material.entity.MaterialArtificerResult; +import com.sqx.modules.risk.entity.Risk; +import com.sqx.modules.risk.service.RiskService; +import com.sqx.modules.taking.dao.OrderTakingCommentDao; +import com.sqx.modules.taking.entity.CommentFabulous; +import com.sqx.modules.taking.entity.TakingCommnt; +import com.sqx.modules.taking.response.TakingDetailsResponse; +import com.sqx.modules.taking.service.OrderTakingCommentService; +import com.sqx.modules.utils.SenInfoCheckUtil; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; + +@Service +public class OrderTakingCommentServiceImpl extends ServiceImpl implements OrderTakingCommentService { + + @Autowired + private OrderTakingCommentDao orderTakingCommentDao; + @Autowired + private OrdersService ordersService; + @Autowired + private MassageTypeService massageTypeService; + @Autowired + private RiskService riskService; + @Autowired + private CommonInfoService commonInfoService; + + @Override + public Result selectOrderTakingComment(Integer page, Integer limit, Long artificerId,Long massageTypeId) { + Page page1 = new Page<>(page, limit); + IPage iPage = orderTakingCommentDao.selectOrderTakingComment(page1, artificerId,massageTypeId); + return Result.success().put("data", new PageUtils(iPage)); + } + + @Override + public Result selectOrderTakingCommentByUserId(Integer page, Integer limit, Long userId) { + Page> page1 = new Page<>(page, limit); + IPage> iPage = orderTakingCommentDao.selectOrderTakingCommentByUserId(page1, userId); + return Result.success().put("data", new PageUtils(iPage)); + } + + @Override + public Result updateGoodsNum(Long commentId, Long userId) { + //判断自己是否点过赞 + CommentFabulous commentFabulous = orderTakingCommentDao.selectGoodsNum(commentId, userId); + if (commentFabulous != null) { + //有赞则取消点赞 + int i = orderTakingCommentDao.deleteGoodsNum(commentFabulous.getId()); + if (i > 0) { + return Result.success("取消点赞成功!"); + } else { + return Result.error("取消点赞失败!"); + } + } else { + //无赞 点赞 + int i = orderTakingCommentDao.insertGoodsNum(commentId, userId); + if (i > 0) { + return Result.success("点赞成功!"); + } else { + return Result.error("点赞失败!"); + } + } + } + + @Override + public Result addGoodsNum(Long orderId, Long userId, String content, Integer score,Long artificerId) { + int i = selectTakingCommentCount(orderId, userId); + if(i>0){ + return Result.error("您已经评价过了!"); + } + Orders orders = ordersService.getById(orderId); + if(!orders.getStatus().equals(3)){ + return Result.success("当前订单未完成或已经评价过了!"); + } + String value = commonInfoService.findOne(323).getValue(); + if(value.contains(content)){ + Risk risk=new Risk(); + risk.setUserId(userId); + risk.setContent("系统检测触发关键词:"+content); + risk.setRiskType(4); + risk.setCreateTime(DateUtils.format(new Date())); + riskService.save(risk); + return Result.error(-200,"内容存在违规信息,请检查后重新提交!"); + } + if(!SenInfoCheckUtil.contentFilter(content)){ + Risk risk=new Risk(); + risk.setUserId(userId); + risk.setContent("系统检测触发关键词:"+content); + risk.setRiskType(4); + risk.setCreateTime(DateUtils.format(new Date())); + riskService.save(risk); + return Result.error(-200,"内容存在违规信息,请检查后重新提交!"); + } + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + //创建 + TakingCommnt takingCommnt = new TakingCommnt(); + takingCommnt.setContent(content); + takingCommnt.setOrderId(orderId); + takingCommnt.setUserId(userId); + takingCommnt.setCreateTime(simpleDateFormat.format(new Date())); + takingCommnt.setScore(score); + takingCommnt.setArtificerId(artificerId); + takingCommnt.setMassageTypeId(orders.getMassageTypeId()); + baseMapper.insert(takingCommnt); + orders.setStatus(5); + ordersService.updateById(orders); + //修改订单下所有加钟的状态为已完成 + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("parent_id", orders.getOrdersId()); + Orders orders2 = new Orders(); + orders2.setStatus(5); + //修改为订单已完成 + ordersService.update(orders2,updateWrapper); + if(orders.getMassageTypeId()!=null){ + MassageType massageType = massageTypeService.getById(orders.getMassageTypeId()); + if(massageType!=null){ + if(StringUtils.isEmpty(massageType.getScore())){ + massageType.setScore(String.valueOf(score)); + }else{ + BigDecimal add = new BigDecimal(massageType.getScore()).add(BigDecimal.valueOf(score)); + massageType.setScore(add.toString()); + } + massageTypeService.updateById(massageType); + } + } + + + return Result.success(); + } + + @Override + public int selectTakingCommentCount(Long ordersId,Long userId){ + return baseMapper.selectCount(new QueryWrapper().eq("order_id",ordersId).eq("user_id",userId)); + } + + @Override + public Result selectTakingCommentByArtificerId(Integer page, Integer limit, Long artificerId) { + IPage page1 = new Page<>(page, limit); + return Result.success().put("data", baseMapper.selectTakingCommentByArtificerId(page1,artificerId)); + } + + +} diff --git a/src/main/java/com/sqx/modules/trip/controller/TripController.java b/src/main/java/com/sqx/modules/trip/controller/TripController.java new file mode 100644 index 0000000..af862e2 --- /dev/null +++ b/src/main/java/com/sqx/modules/trip/controller/TripController.java @@ -0,0 +1,72 @@ +package com.sqx.modules.trip.controller; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.dao.UserMoneyDao; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.entity.*; +import com.sqx.modules.artificer.service.*; +import com.sqx.modules.trip.entity.Trip; +import com.sqx.modules.trip.service.TripService; +import com.sqx.modules.utils.excel.ExcelData; +import com.sqx.modules.utils.excel.ExportExcelUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +@RestController +@RequestMapping("/trip") +@Api(value = "出行方式", tags = {"出行方式"}) +public class TripController { + + @Autowired + private TripService tripService; + + @GetMapping("/selectTripList") + @ApiOperation("查询出行方式列表") + public Result selectTripList(Integer page,Integer limit,String city){ + return Result.success().put("data",new PageUtils(tripService.page(new Page<>(page,limit),new QueryWrapper().like(StringUtils.isNotBlank(city),"city",city)))); + } + + @PostMapping("/insertTrip") + @ApiOperation("添加出行方式") + public Result insertTrip(@RequestBody Trip trip){ + trip.setCreateTime(DateUtils.format(new Date())); + tripService.save(trip); + return Result.success(); + } + + @PostMapping("/updateTrip") + @ApiOperation("修改出行方式") + public Result updateTrip(@RequestBody Trip trip){ + tripService.updateById(trip); + return Result.success(); + } + + @PostMapping("/deleteTripById") + @ApiOperation("删除出行方式") + public Result deleteTripById(Long tripId){ + tripService.removeById(tripId); + return Result.success(); + } + + + + + + +} diff --git a/src/main/java/com/sqx/modules/trip/controller/app/AppTripController.java b/src/main/java/com/sqx/modules/trip/controller/app/AppTripController.java new file mode 100644 index 0000000..51d05f5 --- /dev/null +++ b/src/main/java/com/sqx/modules/trip/controller/app/AppTripController.java @@ -0,0 +1,35 @@ +package com.sqx.modules.trip.controller.app; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sqx.common.utils.DateUtils; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.trip.entity.Trip; +import com.sqx.modules.trip.service.TripService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Date; + +@RestController +@RequestMapping("/app/trip") +@Api(value = "出行方式", tags = {"出行方式"}) +public class AppTripController { + + @Autowired + private TripService tripService; + + @GetMapping("/selectTripList") + @ApiOperation("查询出行方式列表") + public Result selectTripList(String city){ + return Result.success().put("data",tripService.list(new QueryWrapper().like(StringUtils.isNotBlank(city),"city",city))); + } + + + +} diff --git a/src/main/java/com/sqx/modules/trip/dao/TripDao.java b/src/main/java/com/sqx/modules/trip/dao/TripDao.java new file mode 100644 index 0000000..fbfdd53 --- /dev/null +++ b/src/main/java/com/sqx/modules/trip/dao/TripDao.java @@ -0,0 +1,14 @@ +package com.sqx.modules.trip.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sqx.modules.artificer.entity.Agency; +import com.sqx.modules.trip.entity.Trip; +import org.apache.ibatis.annotations.Mapper; + + +@Mapper +public interface TripDao extends BaseMapper { + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/trip/entity/Trip.java b/src/main/java/com/sqx/modules/trip/entity/Trip.java new file mode 100644 index 0000000..014b494 --- /dev/null +++ b/src/main/java/com/sqx/modules/trip/entity/Trip.java @@ -0,0 +1,66 @@ +package com.sqx.modules.trip.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description trip + * @author fang + * @date 2023-01-14 + */ +@Data +public class Trip implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + /** + * 出行方式 + */ + private Long tripId; + + /** + * 出租起步价 + */ + private String taxiStartingFare; + + /** + * 出租起步公里 + */ + private String taxiStartingKm; + + /** + * 出租每公里价格 + */ + private String taxiKmMoney; + + /** + * 公交起步价 + */ + private String busStartingFare; + + /** + * 公交起步公里 + */ + private String busStartingKm; + + /** + * 公交每公里价格 + */ + private String busKmMoney; + + /** + * 城市 + */ + private String city; + + /** + * 创建时间 + */ + private String createTime; + + public Trip() {} +} diff --git a/src/main/java/com/sqx/modules/trip/service/TripService.java b/src/main/java/com/sqx/modules/trip/service/TripService.java new file mode 100644 index 0000000..5bc2ed2 --- /dev/null +++ b/src/main/java/com/sqx/modules/trip/service/TripService.java @@ -0,0 +1,12 @@ +package com.sqx.modules.trip.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sqx.common.utils.Result; +import com.sqx.modules.artificer.entity.Agency; +import com.sqx.modules.trip.entity.Trip; + +public interface TripService extends IService { + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/trip/service/impl/TripServiceImpl.java b/src/main/java/com/sqx/modules/trip/service/impl/TripServiceImpl.java new file mode 100644 index 0000000..e85e577 --- /dev/null +++ b/src/main/java/com/sqx/modules/trip/service/impl/TripServiceImpl.java @@ -0,0 +1,27 @@ +package com.sqx.modules.trip.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.utils.Result; +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import com.sqx.modules.artificer.dao.AgencyDao; +import com.sqx.modules.artificer.entity.Agency; +import com.sqx.modules.artificer.service.AgencyService; +import com.sqx.modules.trip.dao.TripDao; +import com.sqx.modules.trip.entity.Trip; +import com.sqx.modules.trip.service.TripService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.concurrent.locks.ReentrantReadWriteLock; + + +@Service +public class TripServiceImpl extends ServiceImpl implements TripService { + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/utils/AliPayOrderUtil.java b/src/main/java/com/sqx/modules/utils/AliPayOrderUtil.java new file mode 100644 index 0000000..b912695 --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/AliPayOrderUtil.java @@ -0,0 +1,133 @@ +package com.sqx.modules.utils; + +import javax.servlet.http.HttpServletRequest; +import java.text.SimpleDateFormat; +import java.util.*; + +public class AliPayOrderUtil { + + /** + * 将request中的参数转换成Map + * + * @param request + * @return + */ + public static Map convertRequestParamsToMap(HttpServletRequest request) { + Map retMap = new HashMap<>(); + Set> entrySet = request.getParameterMap().entrySet(); + for (Map.Entry entry : entrySet) { + String name = entry.getKey(); + String[] values = entry.getValue(); + int valLen = values.length; + if (valLen == 1) { + retMap.put(name, values[0]); + } else if (valLen > 1) { + StringBuilder sb = new StringBuilder(); + for (String val : values) { + sb.append(",").append(val); + } + retMap.put(name, sb.toString().substring(1)); + } else { + retMap.put(name, ""); + } + } + return retMap; + } + + + + /** + * 计算两个经纬度之间的距离 + * @param lat1 + * @param lng1 + * @param lat2 + * @param lng2 + * @return + */ + + + private static double EARTH_RADIUS = 6371.393; + private static double rad(double d) + { + return d * Math.PI / 180.0; + } + + + /** + * 生成随机订单编号 + * @return + */ + public static String createOrderId() { + int machineId = 1;//最大支持1-9个集群机器部署 + int hashCodeV = UUID.randomUUID().toString().hashCode(); + if(hashCodeV < 0) {//有可能是负数 + hashCodeV = - hashCodeV; + } + // 0 代表前面补充0 + // 4 代表长度为4 + // d 代表参数为正数型 + return machineId+String.format("%015d", hashCodeV); + } + + + + /** + * 获取当前日期是星期几
+ * + * @param date + * @return 当前日期是星期几 + */ + public static String getWeekOfDate(Date date) { + String[] weekDays = { "日", "一", "二", "三", "四", "五", "六" }; + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + int w = cal.get(Calendar.DAY_OF_WEEK) - 1; + if (w < 0) + w = 0; + return weekDays[w]; + } + + /** + * 获取当前日期是星期几
+ * + * @param date + * @return 当前日期是星期几 + */ + public static String getWeekOfDates(Date date) { + String[] weekDays = { "周日", "周一", "周二", "周三", "周四", "周五", "周六" }; + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + int w = cal.get(Calendar.DAY_OF_WEEK) - 1; + if (w < 0) + w = 0; + return weekDays[w]; + } + + + /** + * 获取最近一周的时间 + * + * @param date + * @return 返回起始时间 + */ + public static String getStartTime(Date date) { + String weekOfDate = getWeekOfDate(date); + Integer day=0; + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + switch (weekOfDate){ + case "日": day=6;break; + case "一": day=0;break; + case "二": day=1;break; + case "三": day=2;break; + case "四": day=3;break; + case "五": day=4;break; + case "六": day=5;break; + } + Calendar cal=Calendar.getInstance(); + if(!day.equals(0)){ + cal.add(Calendar.DATE,-day); + } + return sdf.format(cal.getTime()); + } + +} diff --git a/src/main/java/com/sqx/modules/utils/AmountCalUtils.java b/src/main/java/com/sqx/modules/utils/AmountCalUtils.java new file mode 100644 index 0000000..e6ec16c --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/AmountCalUtils.java @@ -0,0 +1,76 @@ +package com.sqx.modules.utils; + + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.DecimalFormat; + +/** + * 金额计算工具类 + * @author fang + * @date 2020-04-17 + */ +public class AmountCalUtils { + + + //金额计算 加法 + public static BigDecimal add(BigDecimal b1,BigDecimal b2){ + return b1.add(b2); + } + + //金额计算 减法 + public static BigDecimal sub(BigDecimal n1, BigDecimal n2) { + formater.setMaximumFractionDigits(2); + formater.setGroupingSize(0); + formater.setRoundingMode(RoundingMode.FLOOR); + double v = n1.subtract(n2).doubleValue(); + return new BigDecimal(formater.format(v)); + } + + //金额计算 乘法 + public static Double mul(double v1, double v2) { + BigDecimal n1 = new BigDecimal(Double.toString(v1)); + BigDecimal n2 = new BigDecimal(Double.toString(v2)); + return n1.multiply(n2).doubleValue(); + } + + //金额计算 乘法 + public static BigDecimal mulMoney(BigDecimal n1, BigDecimal n2) { + formater.setMaximumFractionDigits(2); + formater.setGroupingSize(0); + formater.setRoundingMode(RoundingMode.FLOOR); + BigDecimal multiply = n1.multiply(n2); + return new BigDecimal(formater.format(multiply)); + } + + //金额计算 除法 + public static Double divide(double v1, double v2) { + BigDecimal n1 = new BigDecimal(Double.toString(v1)); + BigDecimal n2 = new BigDecimal(Double.toString(v2)); + return n1.divide(n2, 10, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + + private final static DecimalFormat formater = new DecimalFormat(); + + //金额计算除法,保留小数点后两位 + public static Double moneyDivide(BigDecimal n1, BigDecimal n2){ + BigDecimal v = n1.divide(n2, 10, BigDecimal.ROUND_HALF_UP); + System.out.println(v); + formater.setMaximumFractionDigits(2); + formater.setGroupingSize(0); + formater.setRoundingMode(RoundingMode.FLOOR); + return Double.parseDouble(formater.format(v)); + } + + public static Double moneyDivides(BigDecimal n1, BigDecimal n2){ + BigDecimal v = n1.divide(n2, 10, BigDecimal.ROUND_HALF_UP); + System.out.println(v); + formater.setMaximumFractionDigits(2); + formater.setGroupingSize(0); + formater.setRoundingMode(RoundingMode.FLOOR); + return Double.parseDouble(formater.format(v)); + } + + + +} diff --git a/src/main/java/com/sqx/modules/utils/AppNotifyUtil.java b/src/main/java/com/sqx/modules/utils/AppNotifyUtil.java new file mode 100644 index 0000000..0e6f106 --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/AppNotifyUtil.java @@ -0,0 +1,34 @@ +package com.sqx.modules.utils; + +import com.sqx.common.utils.Result; +import com.sqx.modules.common.service.CommonInfoService; +import com.winnerlook.model.VoiceNotifyBody; +import com.winnerlook.model.VoiceResponseResult; +import com.winnerlook.service.VoiceSender; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.LinkedHashMap; + +public class AppNotifyUtil { + + public static Result AppNotify(String calleeNumber, String accountId, String token, String templateId) { + VoiceNotifyBody message = new VoiceNotifyBody(); + /*用户接收回执的服务器地址*/ + message.setCallbackUrl(""); + message.setCalleeNumber(calleeNumber); + message.setReplayTimes(1); + /*设置平台分配的模板ID*/ + message.setTemplateId(templateId); + LinkedHashMap params = new LinkedHashMap(); + message.setTemplateArgs(params); + try { + VoiceResponseResult result1 = VoiceSender.httpsSendVoiceNotify(message, accountId, token); + System.out.println("result = " + result1); + return Result.success().put("data",result1); + }catch (Exception e) { + //Log.e(this.getClass(), " e = " + e); + e.printStackTrace(); + } + return Result.error("系统错误,请联系管理员。"); + } +} diff --git a/src/main/java/com/sqx/modules/utils/Base64Utils.java b/src/main/java/com/sqx/modules/utils/Base64Utils.java new file mode 100644 index 0000000..db5cd80 --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/Base64Utils.java @@ -0,0 +1,313 @@ +package com.sqx.modules.utils; + + +import java.io.*; + +public class Base64Utils { + public Base64Utils() { + } + + /** + * 功能:编码字符串 + * + * @author jiangshuai + * @date 2016年10月03日 + * @param data + * 源字符串 + * @return String + */ + public static String encode(String data) { + return encode(data.getBytes()); + } + + /** + * 功能:解码字符串 + * + * @author jiangshuai + * @date 2016年10月03日 + * @param data + * 源字符串 + * @return String + */ + public static String decode(String data) { + return new String(decode(data.toCharArray())); + } + + + + /** + * 功能:编码byte[] + * + * @author jiangshuai + * @date 2016年10月03日 + * @param data + * 源 + * @return char[] + */ + public static String encode(byte[] data) { + char[] out = new char[((data.length + 2) / 3) * 4]; + for (int i = 0, index = 0; i < data.length; i += 3, index += 4) { + boolean quad = false; + boolean trip = false; + + int val = (0xFF & (int) data[i]); + val <<= 8; + if ((i + 1) < data.length) { + val |= (0xFF & (int) data[i + 1]); + trip = true; + } + val <<= 8; + if ((i + 2) < data.length) { + val |= (0xFF & (int) data[i + 2]); + quad = true; + } + out[index + 3] = alphabet[(quad ? (val & 0x3F) : 64)]; + val >>= 6; + out[index + 2] = alphabet[(trip ? (val & 0x3F) : 64)]; + val >>= 6; + out[index + 1] = alphabet[val & 0x3F]; + val >>= 6; + out[index + 0] = alphabet[val & 0x3F]; + } + return new String(out); + } + + /** + * 功能:解码 + * + * @author jiangshuai + * @date 2016年10月03日 + * @param data + * 编码后的字符数组 + * @return byte[] + */ + public static byte[] decode(char[] data) { + + int tempLen = data.length; + for (int ix = 0; ix < data.length; ix++) { + if ((data[ix] > 255) || codes[data[ix]] < 0) { + --tempLen; // ignore non-valid chars and padding + } + } + // calculate required length: + // -- 3 bytes for every 4 valid base64 chars + // -- plus 2 bytes if there are 3 extra base64 chars, + // or plus 1 byte if there are 2 extra. + + int len = (tempLen / 4) * 3; + if ((tempLen % 4) == 3) { + len += 2; + } + if ((tempLen % 4) == 2) { + len += 1; + + } + byte[] out = new byte[len]; + + int shift = 0; // # of excess bits stored in accum + int accum = 0; // excess bits + int index = 0; + + // we now go through the entire array (NOT using the 'tempLen' value) + for (int ix = 0; ix < data.length; ix++) { + int value = (data[ix] > 255) ? -1 : codes[data[ix]]; + + if (value >= 0) { // skip over non-code + accum <<= 6; // bits shift up by 6 each time thru + shift += 6; // loop, with new bits being put in + accum |= value; // at the bottom. + if (shift >= 8) { // whenever there are 8 or more shifted in, + shift -= 8; // write them out (from the top, leaving any + out[index++] = // excess at the bottom for next iteration. + (byte) ((accum >> shift) & 0xff); + } + } + } + + // if there is STILL something wrong we just have to throw up now! + if (index != out.length) { + throw new Error("Miscalculated data length (wrote " + index + + " instead of " + out.length + ")"); + } + + return out; + } + + /** + * 功能:编码文件 + * + * @author jiangshuai + * @date 2016年10月03日 + * @param file + * 源文件 + */ + public static void encode(File file) throws IOException { + if (!file.exists()) { + System.exit(0); + } + + else { + byte[] decoded = readBytes(file); + String encoded = encode(decoded); + writeChars(file, encoded.toCharArray()); + } + file = null; + } + + /** + * 功能:解码文件。 + * + * @author jiangshuai + * @date 2016年10月03日 + * @param file + * 源文件 + * @throws IOException + */ + public static void decode(File file) throws IOException { + if (!file.exists()) { + System.exit(0); + } else { + char[] encoded = readChars(file); + byte[] decoded = decode(encoded); + writeBytes(file, decoded); + } + file = null; + } + + // + // code characters for values 0..63 + // + private static char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" + .toCharArray(); + + // + // lookup table for converting base64 characters to value in range 0..63 + // + private static byte[] codes = new byte[256]; + static { + for (int i = 0; i < 256; i++) { + codes[i] = -1; + // LoggerUtil.debug(i + "&" + codes[i] + " "); + } + for (int i = 'A'; i <= 'Z'; i++) { + codes[i] = (byte) (i - 'A'); + // LoggerUtil.debug(i + "&" + codes[i] + " "); + } + + for (int i = 'a'; i <= 'z'; i++) { + codes[i] = (byte) (26 + i - 'a'); + // LoggerUtil.debug(i + "&" + codes[i] + " "); + } + for (int i = '0'; i <= '9'; i++) { + codes[i] = (byte) (52 + i - '0'); + // LoggerUtil.debug(i + "&" + codes[i] + " "); + } + codes['+'] = 62; + codes['/'] = 63; + } + + private static byte[] readBytes(File file) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] b = null; + InputStream fis = null; + InputStream is = null; + try { + fis = new FileInputStream(file); + is = new BufferedInputStream(fis); + int count = 0; + byte[] buf = new byte[16384]; + while ((count = is.read(buf)) != -1) { + if (count > 0) { + baos.write(buf, 0, count); + } + } + b = baos.toByteArray(); + + } finally { + try { + if (fis != null) + fis.close(); + if (is != null) + is.close(); + if (baos != null) + baos.close(); + } catch (Exception e) { + System.out.println(e); + } + } + + return b; + } + + private static char[] readChars(File file) throws IOException { + CharArrayWriter caw = new CharArrayWriter(); + Reader fr = null; + Reader in = null; + try { + fr = new FileReader(file); + in = new BufferedReader(fr); + int count = 0; + char[] buf = new char[16384]; + while ((count = in.read(buf)) != -1) { + if (count > 0) { + caw.write(buf, 0, count); + } + } + + } finally { + try { + if (caw != null) + caw.close(); + if (in != null) + in.close(); + if (fr != null) + fr.close(); + } catch (Exception e) { + System.out.println(e); + } + } + + return caw.toCharArray(); + } + + private static void writeBytes(File file, byte[] data) throws IOException { + OutputStream fos = null; + OutputStream os = null; + try { + fos = new FileOutputStream(file); + os = new BufferedOutputStream(fos); + os.write(data); + + } finally { + try { + if (os != null) + os.close(); + if (fos != null) + fos.close(); + } catch (Exception e) { + System.out.println(e); + } + } + } + + private static void writeChars(File file, char[] data) throws IOException { + Writer fos = null; + Writer os = null; + try { + fos = new FileWriter(file); + os = new BufferedWriter(fos); + os.write(data); + + } finally { + try { + if (os != null) + os.close(); + if (fos != null) + fos.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + +} diff --git a/src/main/java/com/sqx/modules/utils/CertificateUtils.java b/src/main/java/com/sqx/modules/utils/CertificateUtils.java new file mode 100644 index 0000000..48474e3 --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/CertificateUtils.java @@ -0,0 +1,892 @@ +package com.sqx.modules.utils; + +import org.springframework.core.io.ClassPathResource; + +import javax.crypto.Cipher; +import java.io.*; +import java.nio.MappedByteBuffer; +import java.nio.channels.FileChannel; +import java.security.KeyStore; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.Signature; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.util.Base64; +import java.util.Date; + +/** + *

+ * 数字签名/加密解密工具包 + *

+ */ +public class CertificateUtils { + + /** + * Java密钥库(Java 密钥库,JKS)KEY_STORE + */ + public static final String KEY_STORE = "JKS"; + + public static final String X509 = "X.509"; + + /** + * 文件读取缓冲区大小 + */ + private static final int CACHE_SIZE = 2048; + + /** + * 最大文件加密块 + */ + private static final int MAX_ENCRYPT_BLOCK = 117; + + /** + * 最大文件解密块 + */ + private static final int MAX_DECRYPT_BLOCK = 128; + + /** + *

+ * 根据密钥库获得私钥 + *

+ * + * @param keyStorePath 密钥库存储路径 + * @param alias 密钥库别名 + * @param password 密钥库密码 + * @return + * @throws Exception + */ + static PrivateKey getPrivateKey(String keyStorePath, String alias, String password) + throws Exception { + KeyStore keyStore = getKeyStore(keyStorePath, password); + PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, password.toCharArray()); + return privateKey; + } + + /** + *

+ * 获得密钥库 + *

+ * + * @param keyStorePath 密钥库存储路径 + * @param password 密钥库密码 + * @return + * @throws Exception + */ + private static KeyStore getKeyStore(String keyStorePath, String password) + throws Exception { + //FileInputStream in = new FileInputStream(keyStorePath); + ClassPathResource classPathResource = new ClassPathResource("keystore/PTTEST17.keystore"); + InputStream certStream = classPathResource.getInputStream(); + KeyStore keyStore = KeyStore.getInstance(KEY_STORE); + keyStore.load(certStream, password.toCharArray()); + certStream.close(); + return keyStore; + } + + /** + *

+ * 根据证书获得公钥 + *

+ * + * @param certificatePath 证书存储路径 + * @return + * @throws Exception + */ + static PublicKey getPublicKey(String certificatePath) throws CertificateException, IOException { + Certificate certificate = getCertificate(certificatePath); + PublicKey publicKey = certificate.getPublicKey(); + return publicKey; + } + + /** + *

+ * 根据证书获得公钥 + *

+ * + * @param certificateInStream 证书输入流 + * @return + * @throws Exception + */ + static PublicKey getPublicKey(InputStream certificateInStream) throws CertificateException, IOException { + Certificate certificate = getCertificate(certificateInStream); + PublicKey publicKey = certificate.getPublicKey(); + return publicKey; + } + + /** + *

+ * 获得证书 + *

+ * + * @param certificatePath 证书存储路径 + * @return + * @throws Exception + */ + private static Certificate getCertificate(String certificatePath) throws CertificateException, IOException { + CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); + FileInputStream in = new FileInputStream(certificatePath); + Certificate certificate = certificateFactory.generateCertificate(in); + in.close(); + return certificate; + } + + /** + *

+ * 获得证书 + *

+ * + * @param certificateInStream 证书输入流 + * @return + * @throws Exception + */ + private static Certificate getCertificate(InputStream certificateInStream) throws CertificateException, IOException { + CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); + Certificate certificate = certificateFactory.generateCertificate(certificateInStream); + certificateInStream.close(); + return certificate; + } + + /** + *

+ * 根据密钥库获得证书 + *

+ * + * @param keyStorePath 密钥库存储路径 + * @param alias 密钥库别名 + * @param password 密钥库密码 + * @return + * @throws Exception + */ + private static Certificate getCertificate(String keyStorePath, String alias, String password) + throws Exception { + KeyStore keyStore = getKeyStore(keyStorePath, password); + Certificate certificate = keyStore.getCertificate(alias); + return certificate; + } + + /** + *

+ * 私钥加密 + *

+ * + * @param data 源数据 + * @param keyStorePath 密钥库存储路径 + * @param alias 密钥库别名 + * @param password 密钥库密码 + * @return + * @throws Exception + */ + public static byte[] encryptByPrivateKey(byte[] data, String keyStorePath, String alias, String password) + throws Exception { + // 取得私钥 + PrivateKey privateKey = getPrivateKey(keyStorePath, alias, password); + Cipher cipher = Cipher.getInstance(privateKey.getAlgorithm()); + System.out.print("\n=========="+privateKey.getAlgorithm()+"\n=========="); + cipher.init(Cipher.ENCRYPT_MODE, privateKey); + int inputLen = data.length; + ByteArrayOutputStream out = new ByteArrayOutputStream(); + int offSet = 0; + byte[] cache; + int i = 0; + // 对数据分段加密 + while (inputLen - offSet > 0) { + if (inputLen - offSet > MAX_ENCRYPT_BLOCK) { + cache = cipher.doFinal(data, offSet, MAX_ENCRYPT_BLOCK); + } else { + cache = cipher.doFinal(data, offSet, inputLen - offSet); + } + out.write(cache, 0, cache.length); + i++; + offSet = i * MAX_ENCRYPT_BLOCK; + } + byte[] encryptedData = out.toByteArray(); + out.close(); + return encryptedData; + } + + /** + *

+ * 文件私钥加密 + *

+ *

+ * 过大的文件可能会导致内存溢出 + * + * + * @param filePath 文件路径 + * @param keyStorePath 密钥库存储路径 + * @param alias 密钥库别名 + * @param password 密钥库密码 + * @return + * @throws Exception + */ + public static byte[] encryptFileByPrivateKey(String filePath, String keyStorePath, String alias, String password) + throws Exception { + byte[] data = fileToByte(filePath); + return encryptByPrivateKey(data, keyStorePath, alias, password); + } + + /** + *

+ * 文件加密 + *

+ * + * @param srcFilePath 源文件 + * @param destFilePath 加密后文件 + * @param keyStorePath 密钥库存储路径 + * @param alias 密钥库别名 + * @param password 密钥库密码 + * @throws Exception + */ + public static void encryptFileByPrivateKey(String srcFilePath, String destFilePath, String keyStorePath, String alias, String password) + throws Exception { + // 取得私钥 + PrivateKey privateKey = getPrivateKey(keyStorePath, alias, password); + Cipher cipher = Cipher.getInstance(privateKey.getAlgorithm()); + cipher.init(Cipher.ENCRYPT_MODE, privateKey); + File srcFile = new File(srcFilePath); + FileInputStream in = new FileInputStream(srcFile); + File destFile = new File(destFilePath); + if (!destFile.getParentFile().exists()) { + destFile.getParentFile().mkdirs(); + } + destFile.createNewFile(); + OutputStream out = new FileOutputStream(destFile); + byte[] data = new byte[MAX_ENCRYPT_BLOCK]; + byte[] encryptedData; // 加密块 + while (in.read(data) != -1) { + encryptedData = cipher.doFinal(data); + out.write(encryptedData, 0, encryptedData.length); + out.flush(); + } + out.close(); + in.close(); + } + + /** + *

+ * 文件加密成BASE64编码的字符串 + *

+ * + * @param filePath 文件路径 + * @param keyStorePath 密钥库存储路径 + * @param alias 密钥库别名 + * @param password 密钥库密码 + * @return + * @throws Exception + */ +// public static String encryptFileToBase64ByPrivateKey(String filePath, String keyStorePath, String alias, String password) +// throws Exception { +// byte[] encryptedData = encryptFileByPrivateKey(filePath, keyStorePath, alias, password); +// return Base64Utils.encode(encryptedData); +// } + + /** + *

+ * 私钥解密 + *

+ * + * @param encryptedData 已加密数据 + * @param keyStorePath 密钥库存储路径 + * @param alias 密钥库别名 + * @param password 密钥库密码 + * @return + * @throws Exception + */ + public static byte[] decryptByPrivateKey(byte[] encryptedData, String keyStorePath, String alias, String password) + throws Exception { + // 取得私钥 + PrivateKey privateKey = getPrivateKey(keyStorePath, alias, password); + Cipher cipher = Cipher.getInstance(privateKey.getAlgorithm()); + cipher.init(Cipher.DECRYPT_MODE, privateKey); + // 解密byte数组最大长度限制: 128 + int inputLen = encryptedData.length; + ByteArrayOutputStream out = new ByteArrayOutputStream(); + int offSet = 0; + byte[] cache; + int i = 0; + // 对数据分段解密 + while (inputLen - offSet > 0) { + if (inputLen - offSet > MAX_DECRYPT_BLOCK) { + cache = cipher.doFinal(encryptedData, offSet, MAX_DECRYPT_BLOCK); + } else { + cache = cipher.doFinal(encryptedData, offSet, inputLen - offSet); + } + out.write(cache, 0, cache.length); + i++; + offSet = i * MAX_DECRYPT_BLOCK; + } + byte[] decryptedData = out.toByteArray(); + out.close(); + return decryptedData; + } + + /** + *

+ * 公钥加密 + *

+ * + * @param data 源数据 + * @param certificatePath 证书存储路径 + * @return + * @throws Exception + */ + public static byte[] encryptByPublicKey(byte[] data, String certificatePath) + throws Exception { + // 取得公钥 + PublicKey publicKey = getPublicKey(certificatePath); + Cipher cipher = Cipher.getInstance(publicKey.getAlgorithm()); + cipher.init(Cipher.ENCRYPT_MODE, publicKey); + int inputLen = data.length; + ByteArrayOutputStream out = new ByteArrayOutputStream(); + int offSet = 0; + byte[] cache; + int i = 0; + // 对数据分段加密 + while (inputLen - offSet > 0) { + if (inputLen - offSet > MAX_ENCRYPT_BLOCK) { + cache = cipher.doFinal(data, offSet, MAX_ENCRYPT_BLOCK); + } else { + cache = cipher.doFinal(data, offSet, inputLen - offSet); + } + out.write(cache, 0, cache.length); + i++; + offSet = i * MAX_ENCRYPT_BLOCK; + } + byte[] encryptedData = out.toByteArray(); + out.close(); + return encryptedData; + } + + /** + *

+ * 公钥解密 + *

+ * + * @param encryptedData 已加密数据 + * @param certificatePath 证书存储路径 + * @return + * @throws Exception + */ + public static byte[] decryptByPublicKey(byte[] encryptedData, String certificatePath) + throws Exception { + PublicKey publicKey = getPublicKey(certificatePath); + Cipher cipher = Cipher.getInstance(publicKey.getAlgorithm()); + cipher.init(Cipher.DECRYPT_MODE, publicKey); + int inputLen = encryptedData.length; + ByteArrayOutputStream out = new ByteArrayOutputStream(); + int offSet = 0; + byte[] cache; + int i = 0; + // 对数据分段解密 + while (inputLen - offSet > 0) { + if (inputLen - offSet > MAX_DECRYPT_BLOCK) { + cache = cipher.doFinal(encryptedData, offSet, MAX_DECRYPT_BLOCK); + } else { + cache = cipher.doFinal(encryptedData, offSet, inputLen - offSet); + } + out.write(cache, 0, cache.length); + i++; + offSet = i * MAX_DECRYPT_BLOCK; + } + byte[] decryptedData = out.toByteArray(); + out.close(); + return decryptedData; + } + + /** + *

+ * 文件解密 + *

+ * + * @param srcFilePath 源文件 + * @param destFilePath 目标文件 + * @param certificatePath 证书存储路径 + * @throws Exception + */ + public static void decryptFileByPublicKey(String srcFilePath, String destFilePath, String certificatePath) + throws Exception { + PublicKey publicKey = getPublicKey(certificatePath); + Cipher cipher = Cipher.getInstance(publicKey.getAlgorithm()); + cipher.init(Cipher.DECRYPT_MODE, publicKey); + File srcFile = new File(srcFilePath); + FileInputStream in = new FileInputStream(srcFile); + File destFile = new File(destFilePath); + if (!destFile.getParentFile().exists()) { + destFile.getParentFile().mkdirs(); + } + destFile.createNewFile(); + OutputStream out = new FileOutputStream(destFile); + byte[] data = new byte[MAX_DECRYPT_BLOCK]; + byte[] decryptedData; // 解密块 + while (in.read(data) != -1) { + decryptedData = cipher.doFinal(data); + out.write(decryptedData, 0, decryptedData.length); + out.flush(); + } + out.close(); + in.close(); + } + + /** + *

+ * 生成数据签名 + *

+ * + * @param data 源数据 + * @param keyStorePath 密钥库存储路径 + * @param alias 密钥库别名 + * @param password 密钥库密码 + * @return + * @throws Exception + */ + public static byte[] sign(byte[] data, String keyStorePath, String alias, String password) + throws Exception { + // 获得证书 + X509Certificate x509Certificate = (X509Certificate) getCertificate(keyStorePath, alias, password); + // 获取私钥 + KeyStore keyStore = getKeyStore(keyStorePath, password); + // 取得私钥 + PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, password.toCharArray()); + // 构建签名 + Signature signature = Signature.getInstance(x509Certificate.getSigAlgName()); + signature.initSign(privateKey); + signature.update(data); + return signature.sign(); + } + + /** + *

+ * 生成数据签名并以BASE64编码 + *

+ * + * @param data 源数据 + * @param keyStorePath 密钥库存储路径 + * @param alias 密钥库别名 + * @param password 密钥库密码 + * @return + * @throws Exception + */ + public static String signToBase64(byte[] data, String keyStorePath, String alias, String password) + throws Exception { + return Base64.getEncoder().encodeToString(sign(data, keyStorePath, alias, password)); + } + + /** + *

+ * 生成文件数据签名(BASE64) + *

+ *

+ * 需要先将文件私钥加密,再根据加密后的数据生成签名(BASE64),适用于小文件 + *

+ * + * @param filePath 源文件 + * @param keyStorePath 密钥库存储路径 + * @param alias 密钥库别名 + * @param password 密钥库密码 + * @return + * @throws Exception + */ + public static String signFileToBase64WithEncrypt(String filePath, String keyStorePath, String alias, String password) + throws Exception { + byte[] encryptedData = encryptFileByPrivateKey(filePath, keyStorePath, alias, password); + return signToBase64(encryptedData, keyStorePath, alias, password); + } + + /** + *

+ * 生成文件签名 + *

+ *

+ * 注意:
+ * 方法中使用了FileChannel,其巨大Bug就是不会释放文件句柄,导致签名的文件无法操作(移动或删除等)
+ * 该方法已被generateFileSign取代 + *

+ * + * @param filePath 文件路径 + * @param keyStorePath 密钥库存储路径 + * @param alias 密钥库别名 + * @param password 密钥库密码 + * @return + * @throws Exception + */ + @Deprecated + public static byte[] signFile(String filePath, String keyStorePath, String alias, String password) + throws Exception { + byte[] sign = new byte[0]; + // 获得证书 + X509Certificate x509Certificate = (X509Certificate) getCertificate(keyStorePath, alias, password); + // 获取私钥 + KeyStore keyStore = getKeyStore(keyStorePath, password); + // 取得私钥 + PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, password.toCharArray()); + // 构建签名 + Signature signature = Signature.getInstance(x509Certificate.getSigAlgName()); + signature.initSign(privateKey); + File file = new File(filePath); + if (file.exists()) { + FileInputStream in = new FileInputStream(file); + FileChannel fileChannel = in.getChannel(); + MappedByteBuffer byteBuffer = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, file.length()); + signature.update(byteBuffer); + fileChannel.close(); + in.close(); + sign = signature.sign(); + } + return sign; + } + + /** + *

+ * 生成文件数字签名 + *

+ * + * @param filePath + * @param keyStorePath + * @param alias + * @param password + * @return + * @throws Exception + */ + public static byte[] generateFileSign(String filePath, String keyStorePath, String alias, String password) + throws Exception { + byte[] sign = new byte[0]; + // 获得证书 + X509Certificate x509Certificate = (X509Certificate) getCertificate(keyStorePath, alias, password); + // 获取私钥 + KeyStore keyStore = getKeyStore(keyStorePath, password); + // 取得私钥 + PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, password.toCharArray()); + // 构建签名 + Signature signature = Signature.getInstance(x509Certificate.getSigAlgName()); + signature.initSign(privateKey); + File file = new File(filePath); + if (file.exists()) { + FileInputStream in = new FileInputStream(file); + byte[] cache = new byte[CACHE_SIZE]; + int nRead = 0; + while ((nRead = in.read(cache)) != -1) { + signature.update(cache, 0, nRead); + } + in.close(); + sign = signature.sign(); + } + return sign; + + } + + /** + *

+ * 文件签名成BASE64编码字符串 + *

+ * + * @param filePath + * @param keyStorePath + * @param alias + * @param password + * @return + * @throws Exception + */ + public static String signFileToBase64(String filePath, String keyStorePath, String alias, String password) + throws Exception { + return Base64.getEncoder().encodeToString(generateFileSign(filePath, keyStorePath, alias, password)); + } + + /** + *

+ * 验证签名 + *

+ * + * @param data 已加密数据 + * @param sign 数据签名[BASE64] + * @param certificatePath 证书存储路径 + * @return + * @throws Exception + */ + public static boolean verifySign(byte[] data, String sign, String certificatePath) + throws Exception { + // 获得证书 + X509Certificate x509Certificate = (X509Certificate) getCertificate(certificatePath); + // 获得公钥 + PublicKey publicKey = x509Certificate.getPublicKey(); + // 构建签名 + Signature signature = Signature.getInstance(x509Certificate.getSigAlgName()); + signature.initVerify(publicKey); + signature.update(data); + return signature.verify(Base64.getDecoder().decode(sign)); + } + + /** + *

+ * 验证签名 + *

+ * + * @param data 已加密数据 + * @param sign 数据签名[BASE64] + * @param certificate 证书 + * @return + * @throws Exception + */ + public static boolean verifySign(byte[] data, String sign, byte[] certificate) + throws Exception { + // 获得证书 + X509Certificate x509Certificate = (X509Certificate) getCertificate(new ByteArrayInputStream(certificate)); + // 获得公钥 + PublicKey publicKey = x509Certificate.getPublicKey(); + // 构建签名 + Signature signature = Signature.getInstance(x509Certificate.getSigAlgName()); + signature.initVerify(publicKey); + signature.update(data); + return signature.verify(Base64.getDecoder().decode(sign)); + } + + /** + *

+ * 校验文件签名 + *

+ * + * @param filePath + * @param sign + * @param certificatePath + * @return + * @throws Exception + */ +// public static boolean validateFileSign(String filePath, String sign, String certificatePath) +// throws Exception { +// boolean result = false; +// // 获得证书 +// X509Certificate x509Certificate = (X509Certificate) getCertificate(certificatePath); +// // 获得公钥 +// PublicKey publicKey = x509Certificate.getPublicKey(); +//// System.out.print("测试私钥"); +//// System.out.print(publicKey); +//// System.out.print("测试私钥"); +//// System.out.print("\n"); +// +// // 构建签名 +// Signature signature = Signature.getInstance(x509Certificate.getSigAlgName()); +// signature.initVerify(publicKey); +// File file = new File(filePath); +// if (file.exists()) { +// byte[] decodedSign = Base64Utils.decode(sign); +// FileInputStream in = new FileInputStream(file); +// byte[] cache = new byte[CACHE_SIZE]; +// int nRead = 0; +// while ((nRead = in.read(cache)) != -1) { +// signature.update(cache, 0, nRead); +// } +// in.close(); +// result = signature.verify(decodedSign); +// } +// return result; +// } + + /** + *

+ * BASE64解码->签名校验 + *

+ * + * @param base64String BASE64编码字符串 + * @param sign 数据签名[BASE64] + * @param certificatePath 证书存储路径 + * @return + * @throws Exception + */ +// public static boolean verifyBase64Sign(String base64String, String sign, String certificatePath) +// throws Exception { +// byte[] data = Base64Utils.decode(base64String); +// return verifySign(data, sign, certificatePath); +// } + + /** + *

+ * BASE64解码->公钥解密-签名校验 + *

+ * + * + * @param base64String BASE64编码字符串 + * @param sign 数据签名[BASE64] + * @param certificatePath 证书存储路径 + * @return + * @throws Exception + */ +// public static boolean verifyBase64SignWithDecrypt(String base64String, String sign, String certificatePath) +// throws Exception { +// byte[] encryptedData = Base64Utils.decode(base64String); +// byte[] data = decryptByPublicKey(encryptedData, certificatePath); +// return verifySign(data, sign, certificatePath); +// } + + /** + *

+ * 文件公钥解密->签名校验 + *

+ * + * @param encryptedFilePath 加密文件路径 + * @param sign 数字证书[BASE64] + * @param certificatePath + * @return + * @throws Exception + */ +// public static boolean verifyFileSignWithDecrypt(String encryptedFilePath, String sign, String certificatePath) +// throws Exception { +// byte[] encryptedData = fileToByte(encryptedFilePath); +// byte[] data = decryptByPublicKey(encryptedData, certificatePath); +// return verifySign(data, sign, certificatePath); +// } + + /** + *

+ * 校验证书当前是否有效 + *

+ * + * @param certificate 证书 + * @return + */ + public static boolean verifyCertificate(Certificate certificate) { + return verifyCertificate(new Date(), certificate); + } + + /** + *

+ * 验证证书是否过期或无效 + *

+ * + * @param date 日期 + * @param certificate 证书 + * @return + */ + public static boolean verifyCertificate(Date date, Certificate certificate) { + boolean isValid = true; + try { + X509Certificate x509Certificate = (X509Certificate) certificate; + x509Certificate.checkValidity(date); + } catch (Exception e) { + isValid = false; + } + return isValid; + } + + /** + *

+ * 验证数字证书是在给定的日期是否有效 + *

+ * + * @param date 日期 + * @param certificatePath 证书存储路径 + * @return + */ + public static boolean verifyCertificate(Date date, String certificatePath) { + Certificate certificate; + try { + certificate = getCertificate(certificatePath); + return verifyCertificate(certificate); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + *

+ * 验证数字证书是在给定的日期是否有效 + *

+ * + * @param keyStorePath 密钥库存储路径 + * @param alias 密钥库别名 + * @param password 密钥库密码 + * @return + */ + public static boolean verifyCertificate(Date date, String keyStorePath, String alias, String password) { + Certificate certificate; + try { + certificate = getCertificate(keyStorePath, alias, password); + return verifyCertificate(certificate); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + *

+ * 验证数字证书当前是否有效 + *

+ * + * @param keyStorePath 密钥库存储路径 + * @param alias 密钥库别名 + * @param password 密钥库密码 + * @return + */ + public static boolean verifyCertificate(String keyStorePath, String alias, String password) { + return verifyCertificate(new Date(), keyStorePath, alias, password); + } + + /** + *

+ * 验证数字证书当前是否有效 + *

+ * + * @param certificatePath 证书存储路径 + * @return + */ + public static boolean verifyCertificate(String certificatePath) { + return verifyCertificate(new Date(), certificatePath); + } + + /** + *

+ * 文件转换为byte数组 + *

+ * + * @param filePath 文件路径 + * @return + * @throws Exception + */ + public static byte[] fileToByte(String filePath) throws Exception { + byte[] data = new byte[0]; + File file = new File(filePath); + if (file.exists()) { + FileInputStream in = new FileInputStream(file); + ByteArrayOutputStream out = new ByteArrayOutputStream(2048); + byte[] cache = new byte[CACHE_SIZE]; + int nRead = 0; + while ((nRead = in.read(cache)) != -1) { + out.write(cache, 0, nRead); + out.flush(); + } + out.close(); + in.close(); + data = out.toByteArray(); + } + return data; + } + + /** + *

+ * 二进制数据写文件 + *

+ * + * @param bytes 二进制数据 + * @param filePath 文件生成目录 + */ + public static void byteArrayToFile(byte[] bytes, String filePath) throws Exception { + InputStream in = new ByteArrayInputStream(bytes); + File destFile = new File(filePath); + if (!destFile.getParentFile().exists()) { + destFile.getParentFile().mkdirs(); + } + destFile.createNewFile(); + OutputStream out = new FileOutputStream(destFile); + byte[] cache = new byte[CACHE_SIZE]; + int nRead = 0; + while ((nRead = in.read(cache)) != -1) { + out.write(cache, 0, nRead); + out.flush(); + } + out.close(); + in.close(); + } + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/utils/CusAccessObjectUtil.java b/src/main/java/com/sqx/modules/utils/CusAccessObjectUtil.java new file mode 100644 index 0000000..b0bcb55 --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/CusAccessObjectUtil.java @@ -0,0 +1,88 @@ +package com.sqx.modules.utils; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import org.apache.commons.lang3.StringUtils; + +import javax.servlet.http.HttpServletRequest; + +/** + * 获取对象的IP地址等信息 + * @author fang + * @date 2020/9/23 + */ +public class CusAccessObjectUtil { + + /** + * 获取用户真实IP地址,不使用request.getRemoteAddr();的原因是有可能用户使用了代理软件方式避免真实IP地址, + * + * 可是,如果通过了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP值,究竟哪个才是真正的用户端的真实IP呢? + * 答案是取X-Forwarded-For中第一个非unknown的有效IP字符串。 + * + * 如:X-Forwarded-For:192.168.1.110, 192.168.1.120, 192.168.1.130, + * 192.168.1.100 + * + * 用户真实IP为: 192.168.1.110 + * + * @param request + * @return + */ + public static String getIpAddrs( HttpServletRequest request) + throws Exception { + if (request == null) { + throw (new Exception("getIpAddr method HttpServletRequest Object is null")); + } + String ipString = request.getHeader("x-forwarded-for"); + if (StringUtils.isBlank(ipString) || "unknown".equalsIgnoreCase(ipString)) { + ipString = request.getHeader("Proxy-Client-IP"); + } + if (StringUtils.isBlank(ipString) || "unknown".equalsIgnoreCase(ipString)) { + ipString = request.getHeader("WL-Proxy-Client-IP"); + } + if (StringUtils.isBlank(ipString) || "unknown".equalsIgnoreCase(ipString)) { + ipString = request.getRemoteAddr(); + } + + // 多个路由时,取第一个非unknown的ip + String[] arr = ipString.split(","); + for (String str : arr) { + if (!"unknown".equalsIgnoreCase(str)) { + ipString = str; + break; + } + } + + return ipString; + } + + public static String getAddress(String ip) { + String url = "http://ip.ws.126.net/ipquery?ip=" + ip; + String str = HttpClientUtil.doGet(url); + if(!StrUtil.hasBlank(str)){ + String substring = str.substring(str.indexOf("{"), str.indexOf("}")+1); + System.out.println(substring); + JSONObject jsonObject = JSONUtil.parseObj(substring); + String province = jsonObject.getStr("province"); + String city = jsonObject.getStr("city"); + return province+city; + } + return "未知"; + } + + + + +// // 测试 + public static void main(String[] args) { + String ip = "111.121.72.101"; + String address = getAddress(ip); + System.out.println(address); + } + + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/utils/FileUtils.java b/src/main/java/com/sqx/modules/utils/FileUtils.java new file mode 100644 index 0000000..0e5ea41 --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/FileUtils.java @@ -0,0 +1,63 @@ +package com.sqx.modules.utils; + +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.http.entity.ContentType; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.commons.CommonsMultipartFile; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; + + +/** + * 文件工具类 + * @author fang + * @date 2021-03-4 + */ +public class FileUtils { + + /** + * 根据文件地址下载文件 + * @param url 文件地址 + * @param fileName 文件名 + * @return + */ + public static MultipartFile createFileItem(String url, String fileName) { + FileItem item = null; + try { + HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); + conn.setReadTimeout(30000); + conn.setConnectTimeout(30000); + //设置应用程序要从网络连接读取数据 + conn.setDoInput(true); + conn.setRequestMethod("GET"); + if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { + InputStream is = conn.getInputStream(); + + FileItemFactory factory = new DiskFileItemFactory(16, null); + String textFieldName = "uploadfile"; + item = factory.createItem(textFieldName, ContentType.APPLICATION_OCTET_STREAM.toString(), false, fileName); + OutputStream os = item.getOutputStream(); + + int bytesRead = 0; + byte[] buffer = new byte[8192]; + while ((bytesRead = is.read(buffer, 0, 8192)) != -1) { + os.write(buffer, 0, bytesRead); + } + os.close(); + is.close(); + } + } catch (IOException e) { + throw new RuntimeException("文件下载失败", e); + } + + return new CommonsMultipartFile(item); + } + + +} diff --git a/src/main/java/com/sqx/modules/utils/HttpClientUtil.java b/src/main/java/com/sqx/modules/utils/HttpClientUtil.java new file mode 100644 index 0000000..6b2b65b --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/HttpClientUtil.java @@ -0,0 +1,266 @@ +package com.sqx.modules.utils; + +import lombok.extern.slf4j.Slf4j; +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; + +import javax.servlet.http.HttpServletRequest; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.nio.Buffer; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Slf4j +public class HttpClientUtil { + + public static String doGet(String url, Map param) { + + // 创建Httpclient对象 + CloseableHttpClient httpclient = HttpClients.createDefault(); + + String resultString = ""; + CloseableHttpResponse response = null; + try { + // 创建uri + URIBuilder builder = new URIBuilder(url); + if (param != null) { + for (String key : param.keySet()) { + builder.addParameter(key, param.get(key)); + } + } + URI uri = builder.build(); + + // 创建http GET请求 + HttpGet httpGet = new HttpGet(uri); + // 执行请求 + response = httpclient.execute(httpGet); + // 判断返回状态是否为200 + if (response.getStatusLine().getStatusCode() == 200) { + resultString = EntityUtils.toString(response.getEntity(), "UTF-8"); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (response != null) { + response.close(); + } + httpclient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return resultString; + } + + public static String doGet(String url) { + return doGet(url, null); + } + + public static String doPost(String url, Map param) { + // 创建Httpclient对象 + CloseableHttpClient httpClient = HttpClients.createDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + try { + // 创建Http Post请求 + HttpPost httpPost = new HttpPost(url); + // 创建参数列表 + if (param != null) { + List paramList = new ArrayList<>(); + for (String key : param.keySet()) { + paramList.add(new BasicNameValuePair(key, param.get(key))); + } + // 模拟表单 + UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList); + httpPost.setEntity(entity); + } + // 执行http请求 + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + return resultString; + } + + public static String doPost(String url) { + return doPost(url, null); + } + + public static String doPostJson(String url, String json) { + // 创建Httpclient对象 + CloseableHttpClient httpClient = HttpClients.createDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + try { + // 创建Http Post请求 + HttpPost httpPost = new HttpPost(url); + // 创建请求内容 + StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); + httpPost.setEntity(entity); + // 执行http请求 + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + return resultString; + } + + /* 发送 post请求 用HTTPclient 发送请求*/ + public static byte[] post(String URL, String json) { + String obj = null; + InputStream inputStream = null; + Buffer reader = null; + byte[] data = null; + // 创建默认的httpClient实例. + CloseableHttpClient httpclient = HttpClients.createDefault(); + // 创建httppost + HttpPost httppost = new HttpPost(URL); + httppost.addHeader("Content-type", "application/json; charset=utf-8"); + httppost.setHeader("Accept", "application/json"); + try { + StringEntity s = new StringEntity(json, Charset.forName("UTF-8")); + s.setContentEncoding("UTF-8"); + httppost.setEntity(s); + CloseableHttpResponse response = httpclient.execute(httppost); + try { + // 获取相应实体 + HttpEntity entity = response.getEntity(); + if (entity != null) { + inputStream = entity.getContent(); + data = readInputStream(inputStream); + } + return data; + } finally { + response.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + // 关闭连接,释放资源 + try { + httpclient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return data; + } + + + /** 将流 保存为数据数组 + * @param inStream + * @return + * @throws Exception + */ + public static byte[] readInputStream(InputStream inStream) throws Exception { + ByteArrayOutputStream outStream = new ByteArrayOutputStream(); + // 创建一个Buffer字符串 + byte[] buffer = new byte[1024]; + // 每次读取的字符串长度,如果为-1,代表全部读取完毕 + int len = 0; + // 使用一个输入流从buffer里把数据读取出来 + while ((len = inStream.read(buffer)) != -1) { + // 用输出流往buffer里写入数据,中间参数代表从哪个位置开始读,len代表读取的长度 + outStream.write(buffer, 0, len); + } + // 关闭输入流 + inStream.close(); + // 把outStream里的数据写入内存 + return outStream.toByteArray(); + } + + /** + * 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址; + * + * @param request + * @return + * @throws IOException + */ + public static String getIpAddress(HttpServletRequest request) throws IOException { + // 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址 + String ip = request.getHeader("X-Forwarded-For"); + if (log.isInfoEnabled()) { + log.info("getIpAddress(HttpServletRequest) - X-Forwarded-For - String ip=" + ip); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + if (log.isInfoEnabled()) { + log.info("getIpAddress(HttpServletRequest) - Proxy-Client-IP - String ip=" + ip); + } + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + if (log.isInfoEnabled()) { + log.info("getIpAddress(HttpServletRequest) - WL-Proxy-Client-IP - String ip=" + ip); + } + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + if (log.isInfoEnabled()) { + log.info("getIpAddress(HttpServletRequest) - HTTP_CLIENT_IP - String ip=" + ip); + } + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + if (log.isInfoEnabled()) { + log.info("getIpAddress(HttpServletRequest) - HTTP_X_FORWARDED_FOR - String ip=" + ip); + } + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + if (log.isInfoEnabled()) { + log.info("getIpAddress(HttpServletRequest) - getRemoteAddr - String ip=" + ip); + } + } + } else if (ip.length() > 15) { + String[] ips = ip.split(","); + for (int index = 0; index < ips.length; index++) { + String strIp = (String) ips[index]; + if (!("unknown".equalsIgnoreCase(strIp))) { + ip = strIp; + break; + } + } + } + return ip; + } + + + + + +} diff --git a/src/main/java/com/sqx/modules/utils/HttpUtil.java b/src/main/java/com/sqx/modules/utils/HttpUtil.java new file mode 100644 index 0000000..88d41fa --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/HttpUtil.java @@ -0,0 +1,223 @@ +package com.sqx.modules.utils; + +import javax.net.ssl.*; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLEncoder; +import java.security.SecureRandom; +import java.security.cert.X509Certificate; +import java.util.Map; +import java.util.Map.Entry; + +/** + * 进行http访问的基本类 + */ +public class HttpUtil { + + private static final String DEFAULT_CHARSET = "UTF-8"; + + private static final String METHOD_POST = "POST"; + + private static final String METHOD_GET = "GET"; + + private static final int CONNECTTIMEOUT = 5000; + + private static final int READTIMEOUT = 5000; + + private static class DefaultTrustManager implements X509TrustManager { + + public X509Certificate[] getAcceptedIssuers() { + return null; + } + + public void checkClientTrusted(X509Certificate[] cert, String oauthType) + throws java.security.cert.CertificateException { + } + + public void checkServerTrusted(X509Certificate[] cert, String oauthType) + throws java.security.cert.CertificateException { + } + } + + private static HttpURLConnection getConnection(URL url, String method) + throws IOException { + + HttpURLConnection conn; + if ("https".equals(url.getProtocol())) { + SSLContext ctx; + try { + ctx = SSLContext.getInstance("TLS"); + ctx.init(new KeyManager[0], new TrustManager[] { new DefaultTrustManager() }, + new SecureRandom()); + } catch (Exception e) { + throw new IOException(e); + } + HttpsURLConnection connHttps = (HttpsURLConnection) url.openConnection(); + connHttps.setSSLSocketFactory(ctx.getSocketFactory()); + connHttps.setHostnameVerifier(new HostnameVerifier() { + + public boolean verify(String hostname, SSLSession session) { + return true;// 默认都认证通过 + } + }); + conn = connHttps; + } else { + conn = (HttpURLConnection) url.openConnection(); + } + conn.setRequestMethod(method); + conn.setDoInput(true); + conn.setDoOutput(true); + conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); + conn.setRequestProperty("Connection", "Keep-Alive"); + return conn; + + } + + /** + * 通过get方法访问 + * + * @param url 访问的url地址 + * @param urlParams 请求需要的参数 + * @return 返回请求响应的数据 + * @throws IOException + */ + public static String doGet(String url, Map urlParams) + throws IOException { + if (isEmpty(url)) { + throw new IllegalArgumentException("The parameter 'url' can not be null or blank."); + } + url += buildQuery(urlParams, DEFAULT_CHARSET); + HttpURLConnection conn = getConnection(new URL(url), METHOD_GET); + String s = getResponseAsString(conn); + return s; + } + + /** + * + * @param url api请求的权路径url地址 + * @param urlParams 请求的参数 + * @param requestJson 请求报文 + * @return 请求响应 + * @throws IOException + */ + public static String doPost(String url, Map urlParams, String requestJson) throws IOException { + return doPost(url, urlParams, requestJson, CONNECTTIMEOUT, READTIMEOUT); + } + + /** + * + * 通过post方法请求数据 + * + * @param url 请求的url地址 + * @param urlParams 请求的参数 + * @param requestJson 请求报文 + * @param connectTimeOut 请求连接过期时间 + * @param readTimeOut 请求读取过期时间 + * @return 请求响应 + * @throws IOException + */ + public static String doPost(String url, Map urlParams, String requestJson, + int connectTimeOut, int readTimeOut) throws IOException { + if (isEmpty(url)) { + throw new IllegalArgumentException("The parameter 'url' can not be null or blank."); + } + url += buildQuery(urlParams, DEFAULT_CHARSET); + HttpURLConnection conn = getConnection(new URL(url), METHOD_POST); + conn.setConnectTimeout(connectTimeOut); + conn.setReadTimeout(readTimeOut); + conn.getOutputStream().write(requestJson.getBytes(DEFAULT_CHARSET)); + String s = getResponseAsString(conn); + return s; + } + + /** + * + * @param params 请求参数 + * @return 构建query + */ + public static String buildQuery(Map params, String charset) throws UnsupportedEncodingException { + if (params == null || params.isEmpty()) { + return ""; + } + StringBuilder sb = new StringBuilder(); + boolean first = true; + for (Entry entry : params.entrySet()) { + if (first) { + sb.append("?"); + first = false; + } else { + sb.append("&"); + } + String key = entry.getKey(); + String value = entry.getValue(); + if (areNotEmpty(key, value)) { + sb.append(key).append("=").append(URLEncoder.encode(value, charset)); + } + } + return sb.toString(); + + } + + private static String getResponseAsString(HttpURLConnection conn) throws IOException { + InputStream es = conn.getErrorStream(); + if (es == null) { + return getStreamAsString(conn.getInputStream(), DEFAULT_CHARSET); + } else { + String msg = getStreamAsString(es, DEFAULT_CHARSET); + if (isEmpty(msg)) { + throw new IOException(conn.getResponseCode() + " : " + conn.getResponseMessage()); + } else { + throw new IOException(msg); + } + } + + } + + private static String getStreamAsString(InputStream input, String charset) throws IOException { + StringBuilder sb = new StringBuilder(); + BufferedReader bf = null; + try { + bf = new BufferedReader(new InputStreamReader(input, charset)); + String str; + while ((str = bf.readLine()) != null) { + sb.append(str); + } + return sb.toString(); + } finally { + if (bf != null) { + bf.close(); + } + } + + } + + /** + * 判断字符串为空 + * + * @param str 字符串信息 + * @return true or false + */ + private static boolean isEmpty(String str) { + return str == null || str.trim().length() == 0; + } + + /** + * 判断字符数组,不为空 + * + * @param values 字符数组 + * @return true or false + */ + public static boolean areNotEmpty(String... values) { + if (values == null || values.length == 0) { + return false; + } + + for (String value : values) { + if (isEmpty(value)) { + return false; + } + } + return true; + } +} diff --git a/src/main/java/com/sqx/modules/utils/InvitationCodeUtil.java b/src/main/java/com/sqx/modules/utils/InvitationCodeUtil.java new file mode 100644 index 0000000..367ed3d --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/InvitationCodeUtil.java @@ -0,0 +1,55 @@ +package com.sqx.modules.utils; + +import com.sqx.modules.app.entity.UserEntity; +import com.sqx.modules.app.service.UserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 邀请码生成解密工具类 + * @author fang + * @date 2020/7/8 + */ +@Component +public class InvitationCodeUtil { + + + private static UserService userService; + + @Autowired + public void setUserService(UserService userService) { + InvitationCodeUtil.userService = userService; + } + + /** + * 根据ID生成六位随机码 + * @param id ID + * @return 随机码 + */ + public static String toSerialCode(long id) { + while (true){ + int t = (int) ((Math.random() * 9 + 1) * 100000); + String s = String.valueOf(t); + UserEntity userEntity = userService.queryByInvitationCode(s); + if(userEntity==null){ + return s; + } + } + } + + /** + * 根据随机码生成ID + * @param code 随机码 + * @return ID + */ + public static long codeToId(String code) { + UserEntity userEntity = userService.queryByInvitationCode(code); + return userEntity.getUserId(); + } + + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/utils/LonLatUtil.java b/src/main/java/com/sqx/modules/utils/LonLatUtil.java new file mode 100644 index 0000000..549d780 --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/LonLatUtil.java @@ -0,0 +1,25 @@ +package com.sqx.modules.utils; + +import org.gavaghan.geodesy.Ellipsoid; +import org.gavaghan.geodesy.GeodeticCalculator; +import org.gavaghan.geodesy.GeodeticCurve; +import org.gavaghan.geodesy.GlobalCoordinates; + +/** + * @description: 经纬度计算工具类 + */ +public class LonLatUtil { + + /** + * 创建GeodeticCalculator,调用计算方法,传入坐标系、经纬度用于计算距离 + * @param gpsFrom 当前位置 + * @param gpsTo 目标位置 + * @param ellipsoid 坐标系 + * @return + */ + public static double getDistanceMeter(GlobalCoordinates gpsFrom, GlobalCoordinates gpsTo, + Ellipsoid ellipsoid){ + GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(ellipsoid, gpsFrom, gpsTo); + return geoCurve.getEllipsoidalDistance(); + } +} diff --git a/src/main/java/com/sqx/modules/utils/MD5Util.java b/src/main/java/com/sqx/modules/utils/MD5Util.java new file mode 100644 index 0000000..ea314d7 --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/MD5Util.java @@ -0,0 +1,162 @@ +package com.sqx.modules.utils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class MD5Util { + private static final Logger logger = LoggerFactory.getLogger(MD5Util.class); + static MessageDigest messageDigest = null; + + /** + * 判断新密码和旧密码是否正确 返回true 和 false + * + * @param newStr + * @param oldMD5Str + * @return + */ + public final static boolean checkMD5(String newStr, String oldMD5Str) { + String temp = encoderByMd5(newStr); + return (temp != null && temp.equals(oldMD5Str)) ? true : false; + } + + /** + * 对给定的字符串进行加密 + * + * @param source + * @return 加密后的16进制的字符串 + */ + public final static String encoderByMd5(String source) { + String tmp = source.substring(0, 1) + + source.subSequence(source.length() - 1, source.length()); + tmp = md5(tmp); + return md5(source + tmp); + } + + private static String md5(String source) { + + char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', + 'e', 'f'}; + try { + + byte[] strTemp = source.getBytes(); + // 使用MD5创建MessageDigest对象 + MessageDigest mdTemp = MessageDigest.getInstance("MD5"); + mdTemp.update(strTemp); + byte[] md = mdTemp.digest(); + int j = md.length; + char str[] = new char[j * 2]; + int k = 0; + for (byte b : md) { + str[k++] = hexDigits[b >> 4 & 0xf]; + str[k++] = hexDigits[b & 0xf]; + } + + if (logger.isDebugEnabled()) { + logger.debug("加密后的字符串:" + new String(str)); + } + return new String(str); + } catch (Exception e) { + logger.error("md5加密出错:" + source, e); + return null; + } + + } + + + public static String encodeByMD5(String str) { + try { + if (messageDigest == null) { + messageDigest = MessageDigest.getInstance("MD5"); + } + messageDigest.reset(); + messageDigest.update(str.getBytes("UTF-8")); + } catch (NoSuchAlgorithmException e) { + logger.error("NoSuchAlgorithmException caught!", e); + + } catch (UnsupportedEncodingException e) { + logger.error("UnsupportedEncodingException error!", e); + } + if (messageDigest == null) { + return ""; + } + byte[] byteArray = messageDigest.digest(); + + StringBuffer md5StrBuff = new StringBuffer(); + + for (int i = 0; i < byteArray.length; i++) { + if (Integer.toHexString(0xFF & byteArray[i]).length() == 1) { + md5StrBuff.append("0").append(Integer.toHexString(0xFF & byteArray[i])); + } else { + md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i])); + } + } + + return md5StrBuff.toString(); + } + + /** + * MD5加密字符串(32位大写) + * + * @param string 需要进行MD5加密的字符串 + * @return 加密后的字符串(大写) + */ + public static String md5Encrypt32Upper(String string) { + byte[] hash; + try { + //创建一个MD5算法对象,并获得MD5字节数组,16*8=128位 + hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8")); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException("Huh, MD5 should be supported?", e); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("Huh, UTF-8 should be supported?", e); + } + //转换为十六进制字符串 + StringBuilder hex = new StringBuilder(hash.length * 2); + for (byte b : hash) { + if ((b & 0xFF) < 0x10) { + hex.append("0"); + } + hex.append(Integer.toHexString(b & 0xFF)); + } + return hex.toString().toUpperCase(); + } + + + public static String encryption(String plain) { + String re_md5 = new String(); + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(plain.getBytes("utf-8")); + byte b[] = md.digest(); + + int i; + + StringBuffer buf = new StringBuffer(""); + for (int offset = 0; offset < b.length; offset++) { + i = b[offset]; + if (i < 0) { + i += 256; + } + if (i < 16) { + buf.append("0"); + } + buf.append(Integer.toHexString(i)); + } + + re_md5 = buf.toString(); + + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return re_md5; + } + + + +} diff --git a/src/main/java/com/sqx/modules/utils/PeriodUtil.java b/src/main/java/com/sqx/modules/utils/PeriodUtil.java new file mode 100644 index 0000000..a0f0882 --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/PeriodUtil.java @@ -0,0 +1,127 @@ +package com.sqx.modules.utils; + +import cn.hutool.core.date.DateUtil; +import com.sqx.modules.artificer.entity.Period; + +import java.util.Calendar; +import java.util.Date; + +public class PeriodUtil { + //获取传入日期的周期的开始时间以及结束时间 + public static Period obtainCycle(Date date) { + Period period = new Period(); + final Calendar c = Calendar.getInstance(); + c.setTime(date); + //如果日期为1号到10号 返回当月1日与10日 + if(c.get(Calendar.DAY_OF_MONTH) >=1 && c.get(Calendar.DAY_OF_MONTH)<=10){ + c.set(Calendar.DATE,1); + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE, 0); + c.set(Calendar.SECOND, 0); + c.set(Calendar.MILLISECOND, 0); + period.setStartFundData(DateUtil.parse(DateUtil.format(c.getTime(),"yyyy-MM-dd HH:mm:ss"))); + c.set(Calendar.DATE,10); + c.set(Calendar.HOUR_OF_DAY, 23); + c.set(Calendar.MINUTE, 59); + c.set(Calendar.SECOND, 59); + c.set(Calendar.MILLISECOND, 999); + period.setEndFundData(DateUtil.parse(DateUtil.format(c.getTime(),"yyyy-MM-dd HH:mm:ss"))); + } else if (c.get(Calendar.DAY_OF_MONTH)>=11 && c.get(Calendar.DAY_OF_MONTH)<=20) { + //如果日期为11号到20号 返回当月11日与20日 + c.set(Calendar.DATE,11); + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE, 0); + c.set(Calendar.SECOND, 0); + c.set(Calendar.MILLISECOND, 0); + period.setStartFundData(DateUtil.parse(DateUtil.format(c.getTime(),"yyyy-MM-dd HH:mm:ss"))); + c.set(Calendar.DATE,20); + c.set(Calendar.HOUR_OF_DAY, 23); + c.set(Calendar.MINUTE, 59); + c.set(Calendar.SECOND, 59); + c.set(Calendar.MILLISECOND, 999); + period.setEndFundData(DateUtil.parse(DateUtil.format(c.getTime(),"yyyy-MM-dd HH:mm:ss"))); + }else if (c.get(Calendar.DAY_OF_MONTH)>=21 && c.get(Calendar.DAY_OF_MONTH)<=31) { + //如果日期为21号到31号 返回当月21日与当月最后一天 + c.set(Calendar.DATE,21); + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE, 0); + c.set(Calendar.SECOND, 0); + c.set(Calendar.MILLISECOND, 0); + period.setStartFundData(DateUtil.parse(DateUtil.format(c.getTime(),"yyyy-MM-dd HH:mm:ss"))); + //获取月底的最后一天 + c.set(Calendar.DATE,DateUtil.endOfMonth(c).get(Calendar.DATE)); + c.set(Calendar.HOUR_OF_DAY, 23); + c.set(Calendar.MINUTE, 59); + c.set(Calendar.SECOND, 59); + c.set(Calendar.MILLISECOND, 999); + period.setEndFundData(DateUtil.parse(DateUtil.format(c.getTime(),"yyyy-MM-dd HH:mm:ss"))); + } + return period; + } + //传入时间计算上一期时间 + public static Period previousIssue(Date date) { + //取当前时间的上一个周期 + Date previousDate = DateUtil.offsetDay(date,-10); + //获取上一个周期的开始以及结束时间 + Period period = obtainCycle(previousDate); + return period; + } + //传入时间计算周期 + public static Period calculationPeriod(Period period) { + Period selectPeriod; + switch (period.getFundType()){ + case 1: + //本期 根据传入的时间获取周期开始时间以及结束时间 + selectPeriod = obtainCycle(period.getFundData()); + period.setStartFundData(selectPeriod.getStartFundData()); + period.setEndFundData(selectPeriod.getEndFundData()); + break; + case 2: + //上期 + selectPeriod = obtainCycle(period.getFundData()); + selectPeriod = previousIssue(selectPeriod.getStartFundData()); + period.setStartFundData(selectPeriod.getStartFundData()); + period.setEndFundData(selectPeriod.getEndFundData()); + break; + case 3: + //本月 + Date beginOfMonth = DateUtil.parse(DateUtil.format(DateUtil.beginOfMonth(period.getFundData()), "yyyy/MM/dd")); + Date endOfMonth = DateUtil.parse(DateUtil.format(DateUtil.endOfMonth(period.getFundData()), "yyyy/MM/dd")); + final Calendar beginOfMonthc = Calendar.getInstance(); + beginOfMonthc.setTime(beginOfMonth); + beginOfMonthc.set(Calendar.HOUR_OF_DAY, 0); + beginOfMonthc.set(Calendar.MINUTE, 0); + beginOfMonthc.set(Calendar.SECOND, 0); + beginOfMonthc.set(Calendar.MILLISECOND, 0); + final Calendar endOfMonthc = Calendar.getInstance(); + endOfMonthc.setTime(endOfMonth); + endOfMonthc.set(Calendar.HOUR_OF_DAY, 23); + endOfMonthc.set(Calendar.MINUTE, 59); + endOfMonthc.set(Calendar.SECOND, 59); + endOfMonthc.set(Calendar.MILLISECOND, 999); + period.setStartFundData(DateUtil.parse(DateUtil.format(beginOfMonthc.getTime(),"yyyy-MM-dd HH:mm:ss"))); + period.setEndFundData(DateUtil.parse(DateUtil.format(endOfMonthc.getTime(),"yyyy-MM-dd HH:mm:ss"))); + break; + case 4: + //上月 + Date beginOfMonth2 = DateUtil.parse(DateUtil.format(DateUtil.beginOfMonth(DateUtil.offsetMonth(period.getFundData(),-1)), "yyyy/MM/dd")); + Date endOfMonth2 = DateUtil.parse(DateUtil.format(DateUtil.endOfMonth(DateUtil.offsetMonth(period.getFundData(),-1)), "yyyy/MM/dd")); + final Calendar beginOfMonthc2 = Calendar.getInstance(); + beginOfMonthc2.setTime(beginOfMonth2); + beginOfMonthc2.set(Calendar.HOUR_OF_DAY, 0); + beginOfMonthc2.set(Calendar.MINUTE, 0); + beginOfMonthc2.set(Calendar.SECOND, 0); + beginOfMonthc2.set(Calendar.MILLISECOND, 0); + final Calendar endOfMonthc2 = Calendar.getInstance(); + endOfMonthc2.setTime(endOfMonth2); + endOfMonthc2.set(Calendar.HOUR_OF_DAY, 23); + endOfMonthc2.set(Calendar.MINUTE, 59); + endOfMonthc2.set(Calendar.SECOND, 59); + endOfMonthc2.set(Calendar.MILLISECOND, 999); + period.setStartFundData(DateUtil.parse(DateUtil.format(beginOfMonthc2.getTime(),"yyyy-MM-dd HH:mm:ss"))); + period.setEndFundData(DateUtil.parse(DateUtil.format(endOfMonthc2.getTime(),"yyyy-MM-dd HH:mm:ss"))); + break; + } + return period; + } +} diff --git a/src/main/java/com/sqx/modules/utils/SenInfoCheckUtil.java b/src/main/java/com/sqx/modules/utils/SenInfoCheckUtil.java new file mode 100644 index 0000000..30586d5 --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/SenInfoCheckUtil.java @@ -0,0 +1,392 @@ +package com.sqx.modules.utils; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.common.collect.Maps; +import com.sqx.modules.common.service.CommonInfoService; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.commons.CommonsMultipartFile; + +import javax.imageio.ImageIO; +import javax.servlet.http.HttpServletResponse; +import java.awt.image.BufferedImage; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLConnection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +@Component +public class SenInfoCheckUtil { + + private static Logger logger = LoggerFactory.getLogger(SenInfoCheckUtil.class); + + private static String MpAccessToken; + + // 这里使用静态,让 service 属于类 + private static CommonInfoService commonInfoService; + + // 注入的时候,给类的 service 注入 + @Autowired + public void setWxChatContentService(CommonInfoService commonInfoService) { + SenInfoCheckUtil.commonInfoService = commonInfoService; + } + + + /** + * 获取Token 小程序 + * @param + * @param + * @return AccessToken + */ + public static String getMpToken(){ + return getMpAccessToken(); + } + + public static String getJiMpToken(){ + return getJiAccessToken(); + } + + + public static void getImg(String relation,String goodsId,String type, String page,HttpServletResponse response){ + String mpToken = getMpToken(); + //获取二维码数据 + String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+mpToken; + Map map = Maps.newHashMap(); + map.put("scene",relation+"&"+goodsId+"&"+type); + String value = commonInfoService.findOne(105).getValue(); + if("是".equals(value)){ + map.put("page",page); + } + map.put("width", 280); + String jsonString = JSON.toJSONString(map); + InputStream inputStream = sendPostBackStream(url, jsonString); + //生成二维码图片 + response.setContentType("image/png"); + try{ + BufferedImage bi = ImageIO.read(inputStream); + ImageIO.write(bi, "JPG", response.getOutputStream()); + inputStream.close(); + }catch (Exception e){ + e.printStackTrace(); + } + } + + + /** + * 获取二维码图片 + */ + public static void getPoster(String invitationCode, HttpServletResponse response){ + String mpToken = getMpToken(); + //获取二维码数据 + String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+mpToken; + Map map = Maps.newHashMap(); + map.put("scene",invitationCode); + map.put("width", 280); + String jsonString = JSON.toJSONString(map); + InputStream inputStream = sendPostBackStream(url, jsonString); + //生成二维码图片 + response.setContentType("image/png"); + try{ + BufferedImage bi = ImageIO.read(inputStream); + ImageIO.write(bi, "JPG", response.getOutputStream()); + inputStream.close(); + }catch (Exception e){ + logger.error(e.getMessage()); + } + } + + + public static void jiMpCreateQr(String invitationCode, HttpServletResponse response){ + String mpToken = getJiMpToken(); + //获取二维码数据 + String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+mpToken; + Map map = Maps.newHashMap(); + map.put("scene",invitationCode); + map.put("width", 280); + String jsonString = JSON.toJSONString(map); + InputStream inputStream = sendPostBackStream(url, jsonString); + //生成二维码图片 + response.setContentType("image/png"); + try{ + BufferedImage bi = ImageIO.read(inputStream); + ImageIO.write(bi, "JPG", response.getOutputStream()); + inputStream.close(); + }catch (Exception e){ + logger.error(e.getMessage()); + } + } + + private static InputStream sendPostBackStream(String url, String param) { + PrintWriter out = null; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + conn.setDoOutput(true); + conn.setDoInput(true); + //解决乱码问题 + OutputStreamWriter outWriter =new OutputStreamWriter(conn.getOutputStream(), "utf-8"); + out =new PrintWriter(outWriter); + // 发送请求参数 + if(StringUtils.isNotBlank(param)) { + out.print(param); + } + // flush输出流的缓冲 + out.flush(); + return conn.getInputStream(); + } catch (Exception e) { + logger.error("发送 POST 请求出现异常!"+e); + } finally{ + IOUtils.closeQuietly(out); + } + return null; + } + + + /** + * 获取access_token + * 每个两个小时自动刷新AcessTocken + */ + public static String getMpAccessToken(){ + String appid = commonInfoService.findOne(45).getValue(); + String secret = commonInfoService.findOne(46).getValue(); + String jsonResult = HttpClientUtil.doPost("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret); + JSONObject parseObject = JSON.parseObject(jsonResult); + logger.info("=========accessTokenOut========="+parseObject.toJSONString()); + + String errcode = parseObject.getString("errcode"); + String accessToken = parseObject.getString("access_token"); + String expiresIn = parseObject.getString("expires_in"); + return accessToken; + } + + public static String getJiAccessToken(){ + String appid = commonInfoService.findOne(243).getValue(); + String secret = commonInfoService.findOne(244).getValue(); + String jsonResult = HttpClientUtil.doPost("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret); + JSONObject parseObject = JSON.parseObject(jsonResult); + logger.info("=========accessTokenOut========="+parseObject.toJSONString()); + + String errcode = parseObject.getString("errcode"); + String accessToken = parseObject.getString("access_token"); + String expiresIn = parseObject.getString("expires_in"); + return accessToken; + } + + + public static void sendMsg(String wxId, String templateId,List msgList, Integer type){ + String mpToken; + if(type==4 || type==1 || type==5){ + mpToken=getJiMpToken(); + }else{ + mpToken = getMpToken(); + } + RestTemplate restTemplate = new RestTemplate(); + String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" +mpToken; + //拼接推送的模版 + WxMssVo wxMssVo = new WxMssVo(); + wxMssVo.setTouser(wxId);//用户的openid(要发送给那个用户,通常这里应该动态传进来的) + wxMssVo.setTemplate_id(templateId);//订阅消息模板id + wxMssVo.setData(getParam(type,msgList)); + ResponseEntity responseEntity = + restTemplate.postForEntity(url, wxMssVo, String.class); + String body = responseEntity.getBody(); + System.err.println(body); + + } + + + + public static Map getParam(Integer type, List msgList){ + if(type==1){ + Map paras = new HashMap<>(3); + paras.put("character_string3",new TemplateParam( msgList.get(0))); + paras.put("thing1",new TemplateParam( msgList.get(1))); + paras.put("time2",new TemplateParam( msgList.get(2))); + paras.put("thing4",new TemplateParam( msgList.get(3))); + return paras; + }else if(type==2){ + Map paras = new HashMap<>(3); + paras.put("number5",new TemplateParam( msgList.get(0))); + paras.put("thing7",new TemplateParam( msgList.get(1))); + paras.put("thing6",new TemplateParam( msgList.get(2))); + return paras; + }else if(type==3 || type==4){ + Map paras = new HashMap<>(3); + paras.put("character_string6",new TemplateParam( msgList.get(0))); + paras.put("thing1",new TemplateParam( msgList.get(1))); + paras.put("time3",new TemplateParam( msgList.get(2))); + return paras; + }else{ + Map paras = new HashMap<>(3); + paras.put("character_string2",new TemplateParam( msgList.get(0))); + paras.put("thing1",new TemplateParam( msgList.get(1))); + paras.put("phrase5",new TemplateParam( msgList.get(2))); + paras.put("time3",new TemplateParam( msgList.get(3))); + return paras; + } + } + + + + /** + * 图片违规检测 + * @param + * @param file + * @return + */ + public static Boolean imgFilter( MultipartFile file){ + String contentType = file.getContentType(); + return checkPic(file, getMpAccessToken(),contentType); + } + + /** + * 文本违规检测 + * @param + * @param content + * @return + */ + public static Boolean contentFilter( String content){ + return checkContent(getMpAccessToken(),content); + } + + /** + * 恶意图片过滤 + * @param multipartFile + * @return + */ + private static Boolean checkPic(MultipartFile multipartFile, String accessToken,String contentType) { + try { + + CloseableHttpClient httpclient = HttpClients.createDefault(); + + CloseableHttpResponse response = null; + + HttpPost request = new HttpPost("https://api.weixin.qq.com/wxa/img_sec_check?access_token=" + accessToken); + request.addHeader("Content-Type", "application/octet-stream"); + + InputStream inputStream = multipartFile.getInputStream(); + + byte[] byt = new byte[inputStream.available()]; + inputStream.read(byt); + request.setEntity(new ByteArrayEntity(byt, ContentType.create(contentType))); + + response = httpclient.execute(request); + HttpEntity httpEntity = response.getEntity(); + String result = EntityUtils.toString(httpEntity, "UTF-8");// 转成string + JSONObject jso = JSONObject.parseObject(result); + return getResult(jso); + } catch (Exception e) { + e.printStackTrace(); + System.err.println("----------------调用腾讯内容过滤系统出错------------------"); + return true; + } + } + + private static Boolean checkContent(String accessToken,String content) { + try { + System.err.println(accessToken); + System.err.println(content); + CloseableHttpClient httpclient = HttpClients.createDefault(); + + CloseableHttpResponse response = null; + + HttpPost request = new HttpPost("https://api.weixin.qq.com/wxa/msg_sec_check?access_token=" + accessToken); + request.addHeader("Content-Type", "application/json"); + Map map = new HashMap<>(); + map.put("content",content); + String body = JSONObject.toJSONString(map); + request.setEntity(new StringEntity(body,ContentType.create("text/json", "UTF-8"))); + response = httpclient.execute(request); + HttpEntity httpEntity = response.getEntity(); + String result = EntityUtils.toString(httpEntity, "UTF-8");// 转成string + JSONObject jso = JSONObject.parseObject(result); + System.err.println(jso); + return getResult(jso); + } catch (Exception e) { + e.printStackTrace(); + System.err.println("----------------调用腾讯内容过滤系统出错------------------"); + return true; + } + } + + private static Boolean getResult(JSONObject jso){ + Object errcode = jso.get("errcode"); + int errCode = (int) errcode; + if (errCode == 0) { + return true; + } else if (errCode == 87014) { + System.err.println("图片内容违规-----------"); + return false; + } + return true; + } + + public static MultipartFile createFileItem(String url, String fileName) { + FileItem item = null; + try { + HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); + conn.setReadTimeout(30000); + conn.setConnectTimeout(30000); + //设置应用程序要从网络连接读取数据 + conn.setDoInput(true); + conn.setRequestMethod("GET"); + if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { + InputStream is = conn.getInputStream(); + + FileItemFactory factory = new DiskFileItemFactory(16, null); + String textFieldName = "uploadfile"; + item = factory.createItem(textFieldName, ContentType.APPLICATION_OCTET_STREAM.toString(), false, fileName); + OutputStream os = item.getOutputStream(); + + int bytesRead = 0; + byte[] buffer = new byte[8192]; + while ((bytesRead = is.read(buffer, 0, 8192)) != -1) { + os.write(buffer, 0, bytesRead); + } + os.close(); + is.close(); + } + } catch (IOException e) { + throw new RuntimeException("文件下载失败", e); + } + + return new CommonsMultipartFile(item); + } + + + + + + +} diff --git a/src/main/java/com/sqx/modules/utils/Template.java b/src/main/java/com/sqx/modules/utils/Template.java new file mode 100644 index 0000000..b0cc289 --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/Template.java @@ -0,0 +1,20 @@ +package com.sqx.modules.utils; + +import lombok.Data; + +import java.util.List; + +@Data +public class Template { + + private String template_id; + + private String touser; + + private String page; + + private String data; + + private List templateParamList; + +} diff --git a/src/main/java/com/sqx/modules/utils/TemplateParam.java b/src/main/java/com/sqx/modules/utils/TemplateParam.java new file mode 100644 index 0000000..51f0628 --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/TemplateParam.java @@ -0,0 +1,21 @@ +package com.sqx.modules.utils; + +public class TemplateParam { + + + private String value; + + public TemplateParam( String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/utils/TreeUtils.java b/src/main/java/com/sqx/modules/utils/TreeUtils.java new file mode 100644 index 0000000..5f9ce31 --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/TreeUtils.java @@ -0,0 +1,76 @@ +package com.sqx.modules.utils; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; + +public class TreeUtils { + + /** + * 将 List 集合转为树状结构 + * @param nodes 待转换的 List 集合,其中对象必须包含指定的父级字段和节点ID字段 + * @param parentIdField 父级字段名称 + * @param idField 节点ID字段名称 + * @param 对象类型 + * @return 转换后的树状结构 + */ + public static List listToTree(List nodes, String parentIdField, String idField) throws NoSuchFieldException, IllegalAccessException { + List treeNodes = new ArrayList<>(); + for (T node : nodes) { + Object parentIdValue = getFieldValue(node, parentIdField); + int parentId = Integer.parseInt(parentIdValue.toString()); + if (parentId == 0) { + //父ID为0为根节点, 直接加入列表中 + treeNodes.add(node); + continue; + } + // 将节点加入对应的父节点中 + for (T parent : nodes) { + Object idValue = getFieldValue(parent, idField); + int id = Integer.parseInt(idValue.toString()); + if (id == parentId) { + Object children = getFieldValue(parent, "children"); + if (children == null){ + setFieldValue(parent,"children",new ArrayList()); + } + ((List)getFieldValue(parent, "children")).add(node); + } + } + } + return treeNodes; + } + + /** + * 反射获取对象的属性值 + * @param obj 目标对象 + * @param fieldName 属性名 + * @return 属性值 + * @throws NoSuchFieldException + * @throws IllegalAccessException + */ + private static Object getFieldValue(Object obj, String fieldName) throws NoSuchFieldException, IllegalAccessException { + Class clazz = obj.getClass(); + Field field = clazz.getDeclaredField(fieldName); + field.setAccessible(true); + return field.get(obj); + } + + /** + * 反射设置对象的属性值 + * @param obj 目标对象 + * @param fieldName 属性名 + * @param value 属性值 + * @throws NoSuchFieldException + * @throws IllegalAccessException + */ + private static void setFieldValue(Object obj, String fieldName, Object value) { + try { + Class clazz = obj.getClass(); + java.lang.reflect.Field field = clazz.getDeclaredField(fieldName); + field.setAccessible(true); + field.set(obj, value); + } catch (Exception e) { + e.printStackTrace(); + } + } +} + diff --git a/src/main/java/com/sqx/modules/utils/VerifyIdCardUtils.java b/src/main/java/com/sqx/modules/utils/VerifyIdCardUtils.java new file mode 100644 index 0000000..ee5108b --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/VerifyIdCardUtils.java @@ -0,0 +1,180 @@ +package com.sqx.modules.utils; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.sqx.modules.common.service.CommonInfoService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLEncoder; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.NoSuchAlgorithmException; +import java.text.SimpleDateFormat; +import java.util.*; + +@Component +@Slf4j +public class VerifyIdCardUtils { + // 这里使用静态,让 service 属于类 + private static CommonInfoService commonInfoService; + + // 注入的时候,给类的 service 注入 + @Autowired + public void setWxChatContentService(CommonInfoService commonInfoService) { + VerifyIdCardUtils.commonInfoService = commonInfoService; + } + + + /** + * 验证身份信息 + * @param cardNo 身份证号 + * @param realName 姓名 + * @return + */ + public static String verifyIdCard(String cardNo,String realName) { + try{ + //云市场分配的密钥Id + String secretId = commonInfoService.findOne(257).getValue(); + //云市场分配的密钥Key + String secretKey = commonInfoService.findOne(258).getValue(); + String source = commonInfoService.findOne(259).getValue(); + + Calendar cd = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US); + sdf.setTimeZone(TimeZone.getTimeZone("GMT")); + String datetime = sdf.format(cd.getTime()); + // 签名 + String auth = calcAuthorization(source, secretId, secretKey, datetime); + // 请求方法 + String method = "GET"; + // 请求头 + Map headers = new HashMap(); + headers.put("X-Source", source); + headers.put("X-Date", datetime); + headers.put("Authorization", auth); + + // 查询参数 + Map queryParams = new HashMap(); + queryParams.put("cardNo",cardNo); + queryParams.put("realName",realName); + // body参数 + Map bodyParams = new HashMap(); + + // url参数拼接 + String url = "https://service-hcgajsa5-1253495967.ap-beijing.apigateway.myqcloud.com/release/idcard/VerifyIdcardv2"; + if (!queryParams.isEmpty()) { + url += "?" + urlencode(queryParams); + } + + BufferedReader in = null; + try { + URL realUrl = new URL(url); + HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection(); + conn.setConnectTimeout(5000); + conn.setReadTimeout(5000); + conn.setRequestMethod(method); + + // request headers + for (Map.Entry entry : headers.entrySet()) { + conn.setRequestProperty(entry.getKey(), entry.getValue()); + } + + // request body + Map methods = new HashMap<>(); + methods.put("POST", true); + methods.put("PUT", true); + methods.put("PATCH", true); + Boolean hasBody = methods.get(method); + if (hasBody != null) { + conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + + conn.setDoOutput(true); + DataOutputStream out = new DataOutputStream(conn.getOutputStream()); + out.writeBytes(urlencode(bodyParams)); + out.flush(); + out.close(); + } + + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader(conn.getInputStream())); + String line; + String result = ""; + while ((line = in.readLine()) != null) { + result += line; + } + JSONObject res = JSON.parseObject(result); + String errorCode = res.getString("error_code"); + if("0".equals(errorCode)){ + JSONObject result1 = res.getJSONObject("result"); + String isok = result1.getString("isok"); + if("true".equals(isok)){ + return "ok"; + } + } + log.error("身份验证失败:"+res.getString("reason")); + } catch (Exception e) { + e.printStackTrace(); + log.error("身份验证网络请求失败!"+e.getMessage(),e); + } finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + log.error("身份验证io流关闭失败!"+e2.getMessage(),e2); + } + } + }catch (Exception e){ + e.printStackTrace(); + log.error("身份验证失败!"+e.getMessage(),e); + } + return "身份验证失败,请检查后重试!"; + } + + + + + + + public static String calcAuthorization(String source, String secretId, String secretKey, String datetime) + throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException { + String signStr = "x-date: " + datetime + "\n" + "x-source: " + source; + Mac mac = Mac.getInstance("HmacSHA1"); + Key sKey = new SecretKeySpec(secretKey.getBytes("UTF-8"), mac.getAlgorithm()); + mac.init(sKey); + byte[] hash = mac.doFinal(signStr.getBytes("UTF-8")); + String sig = Base64.getEncoder().encodeToString(hash); + + String auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"" + sig + "\""; + return auth; + } + + public static String urlencode(Map map) throws UnsupportedEncodingException { + StringBuilder sb = new StringBuilder(); + for (Map.Entry entry : map.entrySet()) { + if (sb.length() > 0) { + sb.append("&"); + } + sb.append(String.format("%s=%s", + URLEncoder.encode(entry.getKey().toString(), "UTF-8"), + URLEncoder.encode(entry.getValue().toString(), "UTF-8") + )); + } + return sb.toString(); + } + + + + +} diff --git a/src/main/java/com/sqx/modules/utils/WXConfigUtil.java b/src/main/java/com/sqx/modules/utils/WXConfigUtil.java new file mode 100644 index 0000000..497d1ee --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/WXConfigUtil.java @@ -0,0 +1,78 @@ +package com.sqx.modules.utils; + +import com.github.wxpay.sdk.WXPayConfig; +import lombok.Data; +import org.apache.commons.io.IOUtils; +import org.springframework.core.io.ClassPathResource; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +/** + * @author fang + * @date 2020/2/26 + */ +@Data +public class WXConfigUtil implements WXPayConfig { + private byte[] certData; + private String appId = ""; + private String key = ""; + private String mchId = ""; + + + //初始化加载证书 + public WXConfigUtil() throws Exception { + /*int byteread = 0; + int bytesum = 0; + URL url = new URL("windine.blogdriver.com/logo.gif"); + *//*String certPath = ClassUtils.getDefaultClassLoader().getResource("").getPath()+"/weixin/apiclient_cert.p12";//从微信商户平台下载的安全证书存放的路径*//* + URLConnection conn = url.openConnection(); + InputStream inStream = conn.getInputStream(); + FileOutputStream fs = new FileOutputStream(" /www/wwwroot/"+profileHttpUrl+"/file/uploadPath"); + byte[] buffer = new byte[1204]; + int length; + while ((byteread = inStream.read(buffer)) != -1) { + bytesum += byteread; + fs.write(buffer, 0, byteread); + }*/ + ClassPathResource classPathResource = new ClassPathResource("weixin/apiclient_cert.p12"); + InputStream certStream = classPathResource.getInputStream(); + this.certData = IOUtils.toByteArray(certStream); + certStream.read(this.certData); + certStream.close(); +// File file = new File(" "); + /*InputStream certStream = new FileInputStream(file); + this.certData = new byte[(int) file.length()]; + certStream.read(this.certData); + certStream.close();*/ + } + + + @Override + public String getAppID() { + return this.appId; + } + + @Override + public String getMchID() { + return this.mchId; + } + + @Override + public InputStream getCertStream() { + ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData); + return certBis; + } + + @Override + public int getHttpConnectTimeoutMs() { + return 8000; + } + + @Override + public int getHttpReadTimeoutMs() { + return 10000; + } + + +} diff --git a/src/main/java/com/sqx/modules/utils/WxMssVo.java b/src/main/java/com/sqx/modules/utils/WxMssVo.java new file mode 100644 index 0000000..78d85a6 --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/WxMssVo.java @@ -0,0 +1,42 @@ +package com.sqx.modules.utils; + +import java.util.Map; + +public class WxMssVo { + private String touser;//用户openid + private String template_id;//订阅消息模版id + private String page = "/pages/index/index";//默认跳到小程序首页 + private Map data;//推送文字 + + public String getTouser() { + return touser; + } + + public void setTouser(String touser) { + this.touser = touser; + } + + public String getTemplate_id() { + return template_id; + } + + public void setTemplate_id(String template_id) { + this.template_id = template_id; + } + + public String getPage() { + return page; + } + + public void setPage(String page) { + this.page = page; + } + + public Map getData() { + return data; + } + + public void setData(Map data) { + this.data = data; + } +} diff --git a/src/main/java/com/sqx/modules/utils/address/AddressUtil.java b/src/main/java/com/sqx/modules/utils/address/AddressUtil.java new file mode 100644 index 0000000..36f886f --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/address/AddressUtil.java @@ -0,0 +1,57 @@ +package com.sqx.modules.utils.address; + +import com.thoughtworks.xstream.core.BaseException; + +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class AddressUtil { + + private AddressUtil() {} + + /** + * 从地址串中解析提取出省市区等信息 + * @param address 地址信息 + * @return 解析后的地址Map + */ + private static Map addressResolution(String address){ + //1.地址的正则表达式 + String regex = "(?[^省]+省|.+自治区|[^澳门]+澳门|[^香港]+香港|[^市]+市)?(?[^自治州]+自治州|[^特别行政区]+特别行政区|[^市]+市|.*?地区|.*?行政单位|.+盟|市辖区|[^县]+县)(?[^县]+县|[^市]+市|[^镇]+镇|[^区]+区|[^乡]+乡|.+场|.+旗|.+海域|.+岛)?(?
.*)"; + //2、创建匹配规则 + Matcher m = Pattern.compile(regex).matcher(address); + String province; + String city; + String county; + String detailAddress; + Map map = new HashMap<>(16); + + while (m.find()){ + //加入省 + province = m.group("province"); + map.put("province", province == null ? "" : province.trim()); + //加入市 + city = m.group("city"); + map.put("city", city == null ? "" : city.trim()); + //加入区 + county = m.group("county"); + map.put("county", county == null ? "" : county.trim()); + //详细地址 + detailAddress = m.group("address"); + map.put("address", detailAddress == null ? "" : detailAddress.trim()); + } + return map; + } + + /** + * 根据地址获取解析后的地址对象 + * @param address 解析前地址Str + * @return 解析后地址对象 + */ + public static WSSsdrAddress resolveAddress(String address) { + Map addressMap = addressResolution(address); + return new WSSsdrAddress(addressMap.get("province"), addressMap.get("city"), addressMap.get("county"), addressMap.get("address")); + } + +} diff --git a/src/main/java/com/sqx/modules/utils/address/WSSsdrAddress.java b/src/main/java/com/sqx/modules/utils/address/WSSsdrAddress.java new file mode 100644 index 0000000..a354d9f --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/address/WSSsdrAddress.java @@ -0,0 +1,34 @@ +package com.sqx.modules.utils.address; + + +import com.thoughtworks.xstream.core.BaseException; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; + +@Data +@NoArgsConstructor +public class WSSsdrAddress implements Serializable { + + private String province; + + private String city; + + private String county; + + private String address; + + public WSSsdrAddress(String province, String city, String county, String address) { + if (StringUtils.isBlank(province) || + StringUtils.isBlank(city) || + StringUtils.isBlank(county) || + StringUtils.isBlank(address)) { + } + this.province = province; + this.city = city; + this.county = county; + this.address = address; + } +} diff --git a/src/main/java/com/sqx/modules/utils/excel/ExcelData.java b/src/main/java/com/sqx/modules/utils/excel/ExcelData.java new file mode 100644 index 0000000..692e79d --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/excel/ExcelData.java @@ -0,0 +1,34 @@ +package com.sqx.modules.utils.excel; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author fang + * @date 2020/9/24 + */ + +@Data +public class ExcelData implements Serializable { + + private static final long serialVersionUID = 4454016249210520899L; + + /** + * 表头 + */ + private List titles; + + /** + * 数据 + */ + private List> rows; + + /** + * 页签名称 + */ + private String name; + + +} diff --git a/src/main/java/com/sqx/modules/utils/excel/ExcelUtils.java b/src/main/java/com/sqx/modules/utils/excel/ExcelUtils.java new file mode 100644 index 0000000..6ce7174 --- /dev/null +++ b/src/main/java/com/sqx/modules/utils/excel/ExcelUtils.java @@ -0,0 +1,171 @@ +package com.sqx.modules.utils.excel; + +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.http.entity.ContentType; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.commons.CommonsMultipartFile; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; + +/** + * @author fang + * @date 2021/1/27 + */ +@Slf4j +public class ExcelUtils { + + /*public static List get(String fileUrl){ + MultipartFile fileItem = createFileItem(fileUrl, null); + String substring = fileUrl.substring(fileUrl.lastIndexOf(".")); + List list=new ArrayList<>(); + try { +// String fileName = fileItem.getOriginalFilename(); + String xls=".xlsx"; + InputStream inputStream = fileItem.getInputStream(); + log.info("文件名:{}", substring); + int serviceStationNo=0; + int serviceStationName=0; + int oilName=0; + int activity=0; + int downPrice=0; + //区分两种excel表格 + if(substring.indexOf(xls)!=-1){ + XSSFWorkbook workbook=new XSSFWorkbook(inputStream); + //获取第一个工作表 + org.apache.poi.xssf.usermodel.XSSFSheet hs=workbook.getSheetAt(0); + //获取Sheet的第一个行号和最后一个行号 + int last=hs.getLastRowNum(); + int first=hs.getFirstRowNum(); + //遍历获取单元格里的信息 + for (int i = first; i <=last; i++) { + XSSFRow row=hs.getRow(i); + int firstCellNum=row.getFirstCellNum();//获取所在行的第一个行号 + int lastCellNum=row.getLastCellNum();//获取所在行的最后一个行号 + OilStation oilStation=new OilStation(); + for (int j = firstCellNum; j titles) { + int rowIndex = 0; + int colIndex = 0; + Font titleFont = wb.createFont();//获取字体 + titleFont.setFontName("simsun");//设置字体名称(宋体) + titleFont.setBold(true);//设置字体加粗 + titleFont.setColor(IndexedColors.BLACK.index);//设置字体颜色 黑色 + XSSFCellStyle titleStyle = wb.createCellStyle();//获取单元格样式 + titleStyle.setAlignment(HorizontalAlignment.CENTER);//设置单元格的水平对齐类型(这里是水平居中) + titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);//设置单元格的垂直对齐类型(这里是居中) + titleStyle.setFillForegroundColor(createXssfColor("#FFFFFF"));//设置单元格前景色(白色) + titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);//指定图案和纯色单元格填充的单元格填充信息(实心前景) + titleStyle.setFont(titleFont);//设置字体样式 + setBorder(titleStyle, BorderStyle.THIN, createXssfColor("#000000"));//设置边框样式(细线、黑色) + Row titleRow = sheet.createRow(rowIndex);//在该工作簿中创建第一行. + colIndex = 0; + for (String field : titles) {//循环创建列 + Cell cell = titleRow.createCell(colIndex); + cell.setCellValue(field); + cell.setCellStyle(titleStyle); + colIndex++; + } + rowIndex++;//将行数++ 返回用于下面添加数据 + return rowIndex; + } + + /** + * 将数据写入 + * @param wb + * @param sheet + * @param rows + * @param rowIndex + * @return + */ + private static int writeRowsToExcel(XSSFWorkbook wb, Sheet sheet, List> rows, int rowIndex) { + int colIndex = 0; + Font dataFont = wb.createFont();//获取字体 + dataFont.setFontName("simsun");//设置字体名称(宋体) + dataFont.setColor(IndexedColors.BLACK.index);//设置字体颜色 黑色 + XSSFCellStyle dataStyle = wb.createCellStyle();//获取单元格样式 + dataStyle.setAlignment(HorizontalAlignment.CENTER);//设置单元格的水平对齐类型(这里是水平居中) + dataStyle.setVerticalAlignment(VerticalAlignment.CENTER);//设置单元格的垂直对齐类型(这里是居中) + dataStyle.setFont(dataFont);//设置字体样式 + setBorder(dataStyle, BorderStyle.THIN, createXssfColor("#000000"));//设置边框样式(细线、黑色) + for (List rowData : rows) {//循环写入数据 + Row dataRow = sheet.createRow(rowIndex); + colIndex = 0; + for (Object cellData : rowData) { + Cell cell = dataRow.createCell(colIndex); + if (cellData != null) { + cell.setCellValue(cellData.toString()); + } else { + cell.setCellValue(""); + } + + cell.setCellStyle(dataStyle); + colIndex++; + } + rowIndex++; + } + return rowIndex; + } + + /** + * 自动调整大小 + * @param sheet + * @param columnNumber + */ + private static void autoSizeColumns(Sheet sheet, int columnNumber) { + for (int i = 0; i < columnNumber; i++) { + int orgWidth = sheet.getColumnWidth(i); + sheet.autoSizeColumn(i, true); + int newWidth = (int) (sheet.getColumnWidth(i) + 100); + if (newWidth > orgWidth) { + sheet.setColumnWidth(i, newWidth); + } else { + sheet.setColumnWidth(i, orgWidth); + } + } + } + + /** + * 设置表格样式 + * @param style + * @param border + * @param color + */ + private static void setBorder(XSSFCellStyle style, BorderStyle border, XSSFColor color) { + style.setBorderTop(border); + style.setBorderLeft(border); + style.setBorderRight(border); + style.setBorderBottom(border); + style.setBorderColor(XSSFCellBorder.BorderSide.TOP, color); + style.setBorderColor(XSSFCellBorder.BorderSide.LEFT, color); + style.setBorderColor(XSSFCellBorder.BorderSide.RIGHT, color); + style.setBorderColor(XSSFCellBorder.BorderSide.BOTTOM, color); + } + + /** + * 将rgb颜色码 转换为 XSSFColor + * @param color + * @return + */ + private static XSSFColor createXssfColor(String color) { + int[] rgbColor = hexToRgb(color); + XSSFColor xssfColor = new XSSFColor(new java.awt.Color(rgbColor[0], rgbColor[1], rgbColor[2]), new DefaultIndexedColorMap()); + return xssfColor; + } + + /** + * 将颜色码 转换为 r g b + * @param hex + * @return + */ + public static int[] hexToRgb(String hex) { + String colorStr = hex; + if (hex.startsWith("#")) { + colorStr = hex.substring(1); + } + if (StringUtils.length(colorStr) == 8) { + colorStr = hex.substring(2); + } + int r= Integer.valueOf( colorStr.substring( 0, 2 ), 16 ); + int g= Integer.valueOf( colorStr.substring( 2, 4 ), 16 ); + int b= Integer.valueOf( colorStr.substring( 4, 6 ), 16 ); + + return new int[] { r, g, b }; + } + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/sqx/ws/BaseInfoModel.java b/src/main/java/com/sqx/ws/BaseInfoModel.java new file mode 100644 index 0000000..00153bf --- /dev/null +++ b/src/main/java/com/sqx/ws/BaseInfoModel.java @@ -0,0 +1,30 @@ +package com.sqx.ws; + +import lombok.Data; + +@Data +public class BaseInfoModel { + + private String code; + private String msg; + private T data; + + public static BaseResponseMessage success(String type, T data) { + BaseResponseMessage baseResponseMessage = new BaseResponseMessage<>(); + baseResponseMessage.setCode("0"); + baseResponseMessage.setType(type); + baseResponseMessage.setMsg("成功"); + baseResponseMessage.setData(data); + return baseResponseMessage; + } + + public static BaseResponseMessage error(String type,String code,String msg, T data) { + BaseResponseMessage baseResponseMessage = new BaseResponseMessage<>(); + baseResponseMessage.setCode(code); + baseResponseMessage.setType(type); + baseResponseMessage.setMsg(msg); + baseResponseMessage.setData(data); + return baseResponseMessage; + } + +} diff --git a/src/main/java/com/sqx/ws/BaseModelEncoder.java b/src/main/java/com/sqx/ws/BaseModelEncoder.java new file mode 100644 index 0000000..753991d --- /dev/null +++ b/src/main/java/com/sqx/ws/BaseModelEncoder.java @@ -0,0 +1,41 @@ +package com.sqx.ws; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.json.JsonMapper; +import lombok.extern.slf4j.Slf4j; + +import javax.websocket.EncodeException; +import javax.websocket.Encoder; +import javax.websocket.EndpointConfig; + +/** + * @author YUSHENGDADA + * @title: BaseModelEncoder + * @projectName v2_lab + * @description: 实体编码器 + * @date 2022/8/22 0022下午 14:15 + */ +@Slf4j +public class BaseModelEncoder implements Encoder.Text { + @Override + public String encode(BaseResponseMessage baseResponseMessage) throws EncodeException { + try { + JsonMapper jsonMapper = new JsonMapper(); + return jsonMapper.writeValueAsString(baseResponseMessage); + + } catch (JsonProcessingException e) { + log.error(e.getMessage(),e); + } + return null; + } + + @Override + public void init(EndpointConfig endpointConfig) { + + } + + @Override + public void destroy() { + + } +} diff --git a/src/main/java/com/sqx/ws/BaseResponseMessage.java b/src/main/java/com/sqx/ws/BaseResponseMessage.java new file mode 100644 index 0000000..2975cfc --- /dev/null +++ b/src/main/java/com/sqx/ws/BaseResponseMessage.java @@ -0,0 +1,13 @@ +package com.sqx.ws; + +import lombok.Data; + +@Data +public class BaseResponseMessage { + + private String code; + private String type; + private String msg; + private T data; + +} diff --git a/src/main/java/com/sqx/ws/HashMapEncoder.java b/src/main/java/com/sqx/ws/HashMapEncoder.java new file mode 100644 index 0000000..9cf5c2c --- /dev/null +++ b/src/main/java/com/sqx/ws/HashMapEncoder.java @@ -0,0 +1,51 @@ +package com.sqx.ws; +import com.alibaba.fastjson.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.websocket.EncodeException; +import javax.websocket.Encoder; +import javax.websocket.EndpointConfig; +import java.util.HashMap; + +/** + * @author YUSHENGDADA + * @title: ServerEncoder + * @projectName v2_lab + * @description: WebSocket编码器 + * @date 2022/8/22 0022上午 11:42 + */ +public class HashMapEncoder implements Encoder.Text { + private static final Logger log = LoggerFactory.getLogger(HashMapEncoder.class); + + /** + * 这里的参数 hashMap 要和 Encoder.Text保持一致 + * @param hashMap + * @return + * @throws EncodeException + */ + @Override + public String encode(HashMap hashMap) throws EncodeException { + /* + * 这里是重点,只需要返回Object序列化后的json字符串就行 + * 你也可以使用gosn,fastJson来序列化。 + * 这里我使用fastjson + */ + try { + return JSONObject.toJSONString(hashMap); + }catch (Exception e){ + log.info("ServerEncoder编码异常:{}",e.getMessage()); + } + return null; + } + + @Override + public void init(EndpointConfig endpointConfig) { + //可忽略 + } + + @Override + public void destroy() { + //可忽略 + } +} diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 0000000..15c1a4a --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,55 @@ +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://123.60.46.33:3306/anmo?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT + username: root + password: root + initial-size: 10 + max-active: 100 + min-idle: 10 + max-wait: 60000 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + #Oracle需要打开注释 + #validation-query: SELECT 1 FROM DUAL + test-while-idle: true + test-on-borrow: false + test-on-return: false + stat-view-servlet: + enabled: true + url-pattern: /druid/* + #login-username: admin + #login-password: admin + filter: + stat: + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: false + wall: + config: + multi-statement-allow: true + redis: + open: true # 是否开启redis缓存 true开启 false关闭 + database: 0 + host: localhost + port: 6379 + #password: root # 密码(默认为空) + timeout: 6000ms # 连接超时时长(毫秒) + jedis: + pool: + max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) + max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) + max-idle: 10 # 连接池中的最大空闲连接 + min-idle: 5 # 连接池中的最小空闲连接 +ffmpeg: + path: /usr/bin + core: + executableFile: ${ffmpeg.path}/ffmpeg +business: + audio: + uploadPath: /www/wwwroot/server/audioUpload + diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml new file mode 100644 index 0000000..b9210a1 --- /dev/null +++ b/src/main/resources/application-test.yml @@ -0,0 +1,55 @@ +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://175.178.80.95:3306/anmo1?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT + username: anmo1 + password: sEeTPPk7GWyn8iF7 + initial-size: 10 + max-active: 100 + min-idle: 10 + max-wait: 60000 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + #Oracle需要打开注释 + #validation-query: SELECT 1 FROM DUAL + test-while-idle: true + test-on-borrow: false + test-on-return: false + stat-view-servlet: + enabled: true + url-pattern: /druid/* + #login-username: admin + #login-password: admin + filter: + stat: + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: false + wall: + config: + multi-statement-allow: true + redis: + open: true # 是否开启redis缓存 true开启 false关闭 + database: 1 + host: 192.168.0.169 + port: 6379 + #password: root # 密码(默认为空) + timeout: 6000ms # 连接超时时长(毫秒) + jedis: + pool: + max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) + max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) + max-idle: 10 # 连接池中的最大空闲连接 + min-idle: 5 # 连接池中的最小空闲连接 +ffmpeg: + path: /usr/bin + core: + executableFile: ${ffmpeg.path}/ffmpeg +business: + audio: + uploadPath: /www/wwwroot/server/audioUpload + diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..01f9156 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,73 @@ +logging: + file: + name: logs/anmo.log +# Tomcat +server: + tomcat: + uri-encoding: UTF-8 + max-threads: 1000 + min-spare-threads: 30 + connection-timeout: 5000ms + port: 8187 + servlet: + context-path: /sqx_fast + +spring: + banner: + image: + location: classpath:banner/banner.jpg + main: + allow-circular-references: true + # 环境 dev|test|prod + profiles: + active: prod + # jackson时间格式化 + jackson: + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + servlet: + multipart: + max-file-size: 10240MB + max-request-size: 10240MB + enabled: true + mvc: + throw-exception-if-no-handler-found: true + pathmatch: + matching-strategy: ant_path_matcher +# resources: +# add-mappings: false + + +#mybatis +mybatis-plus: + mapper-locations: classpath*:/mapper/**/*.xml + #实体扫描,多个package用逗号或者分号分隔 + typeAliasesPackage: com.sqx.modules.*.entity + global-config: + #数据库相关配置 + db-config: + #主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; + id-type: AUTO + logic-delete-value: -1 + logic-not-delete-value: 0 + banner: false + #原生配置 + configuration: + map-underscore-to-camel-case: true + cache-enabled: false + call-setters-on-nulls: true + jdbc-type-for-null: 'null' + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + +sqx: + redis: + open: false + shiro: + redis: false + # APP模块,是通过jwt认证的,如果要使用APP模块,则需要修改【加密秘钥】 + jwt: + # 加密秘钥 + secret: f4e2e52034348f86b67cde581c0f9eb5 + # token有效时长,7天,单位秒 + expire: 2592000 + header: token \ No newline at end of file diff --git a/src/main/resources/banner/banner.jpg b/src/main/resources/banner/banner.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9936b89e002d2d21f68561c16844a7a43b14d530 GIT binary patch literal 35981 zcmdS=cUY6(mo|zAse&{C>BIt3A|L`PH6lVlL`0<{5s@w+J+wqbKxvUKphW3C(xpba z^bP`25_(Ul0g`ay=bd+cbItY6{JwL}b^bUZI|<|=+3R`MUh7`>y7%et(>VageQjNB z01XWd;3M@1a7qDiKXJ43^0oG`RlfMd)$z5prz> zGcz(WFr8yQcaDXbg@u*vJO?WqCmRb3#{~{fE^Zzko^$NHd>6R+&U5o{|NRgeTI&DM z(VwNKKg-R^!pi+WzMcLAa59~_cSebp<}%<6Ck-tp&1owD2msK~Q*HQb#=qTY&QRyb zz{qr#nT2{lB?sUP4K3{%I@-UprXC$ceIG!_Nq_#5oCX7zp*7=WckUa(vEP`k+%0Y5 zc|3?0m4D&!_AK)SUOs*Sv8&<|l2QtaH*eimQr5hur47;1z5nE?k+F%XnYqnNTRVFP zM<-7&Zy#TnpMS`^(6I3LA0p!76B3h>Kc%E*WM*aOAP{a5alXXxl? z=@|doMRUfNI%qlR=r74JoYyd9w07sZd?T2N`)=&F(x$UlLUl3KmiV^;r z_K#)%nqhDMZ&~*5hW-ESngpDqrJ-ItT225MKz@=DAp!XR^oU7ZZoEbQ3Kt1fF{Vrt ztWYizjE9`M%et{sPA^0D+Z56U`9}(w4VUsolheb$8A1hNvlM0%teSjJWHUtwGq%WY zsJIa6A`*0mrW2S5scc#`REMF!`-Iue~ zEQpo+2o;B!ug1Z@bxYk1UGR=(G`4vIN+K|}p%`GsH;$`6?A3`02X<%oFR(ciPFhj? zBwyT-s0*}hvSBWMTibQ|3K&m+32}e^SyYT!r;nOhjBZJ22*nP@^P>^GvxJ;E1$2}8 z$B-QGDHM|e1LzcR_V$R*DFDS}Zh$XgF+T;ojU}m+^&j{o7db(v+qJD2Zr&+|h+U3>^(%tf~>;`}`D$-^tg|A;es+zct@TJ*Q7`jKJik&+;G6 z)D15%QIfGG;E2Z?#0tI7Sa>Az8hF?b&W1Y}KEhW_Ot6XfSl7qz>+O{uPh(F3Q%|sr z@5M|zA}`>9V+<)cQyAO0@yr8E@cV+0Qvi+PyYKN9 zD(TZ~pr(VyyxZOT4hr!@KAH3@sRGgq;BT9)PB4%9h*plrl({(ciYaLhrA__PVehMz9QdN26doGW_Z`O4o`sg_HaP{*F2Ucy4sreO)cMR5`#+F0 zY_swN-#zY3u|$*$ET-XkcHCNLiIT=?c6Jr`TjALwLbfK4Mg_Z~M0!d~^w{&wi6G-K z^#1yU%s!}dyCh32)#3w7sra8!)Eq2k@>h*8tzkFxcZ3c9TezW=G%Ulqj$tds~crNRhEzi1w&>rfZ z(W5<#$gM`vs27Ew3;FGa?pFq#9mrK1+``J&!_Rl|$keHs9Fcp-b$CcCnk7(YxNSSk zdrI2w+)Hxmqi2X2%`j*y^Qto*qd~Y(h;`ABtq9Uy*Q?h|OdWb62>*f*IL^e1lenL> zi|{zSs&}*pM(kljZ@Iq^Y!mV%cc^!`SyeWvie?shtIyN7nfi~#NU0(l*Gc0zc!Hso zEk6Dr2G84`<|QIBhNBFEl83fV0iIszm`f+Ww@h9iqV-EIe14X4kWesO%%l8RUp`l7@vX-OA$tMQCgvm3d%eo^(_(Gip+>;*6%f_{iNZfRDO{=4-Pv+$Jv9!3} zMS675a;NF}I6h2RYczLvITDKI*}oNnnfn6eQq@@OEV5jM3kJ7)Dunqlj`H$>qXT^3 zVdhdO+@(4T1ojV=YR1-wxXPz*xsET8ozqQI-PZ#4ZU@Mr(dCO)uCsUq?QTKN+dkat z=*72YUt)M{?zWOIP;Lj|WKN88ADrtj^Fi zuZs4Y6H{55Ks*O1-L&n%aBC1NfHog}yhmN@R|qZlh^z!)tF@p$Uc1g$&@1*D>iO~K z=O#f}lokZP_dB+9-k4DX62%I_2@F<3kNJamqfqz!M~Hf7fiWHk4>JEzayB*B+*ZG8 zwR!T45}9jXa+LZ2F?+ez0!+Lr8^MCeCXVYEo&p}Y*oyC?2aZADVxuj8PHa(?N)skc zou!f*aIKX(CIdZ@(5w9MX9mLM$RJ)JO6!6_+_GqW^ zkYfMS1c85`f@hxybf?+dEoR?SM0!&{sDtqK(~WMV{+?n8qpSL^(%-$JKhlL;L5Fxln&C5TJU8=S)6Dux=Jwx+B8{VgWmACJfQFxw` zpFo%3>Vwc6xG441y9dgTRtw+QH5))$)BpO!enRAxSbHVB$ma>!lZ)aK?zxAIF z5@eide4J7K<@ShioC^NahBiYW(Xa9d{1iS&k|55{%|TKU8$Ce@<~0VmP&hSe?v%gJ9hvFxQhhro?f02N4Z=(1LQASlZT zx(mSGj)4;ndIn=q+Y%jl+g7%g*D{L~A**I?T!yWa>7YN!a3l#+Y*6P=V1BbQml*k= zdc>>lw;~HmC_7JY#ao>}{$WA_b(Z3jIjObO^b{P*ZFq|RuC0_in5Ic5z;DWu) zo3GxY2i$;T0(6q`pa75h>CEsJr%_0Zxz{70RT1)f??$x>FTQhc+lv3>5oN~E0qKoJ zgpHr|43rn{t7lljsxdc%KZGA5X@zLV8tF#7K@BgC1E$tf++@XH?DVT7``Y}8??m5? z;pv`9?`XCo>7G+tncGh`^RoIfi(T`bRn@?a5fb3aT{!#FG*!3~u zru}34k1FYm4MD#6T*}$Oc_7!(t@In1kmf4=w=P%O+9nPzazyU`fhQiYw*V&uvB}MC z5f<$19rYt`7$~b z<63#q^)t#+-N@kNt4UGIIiEpML+#RgAx;?p9>~`-C@qhhi-q5}v4-^*AqQngb?Rhl8$ zhb-fjbh8cq9wWX~xtoimW+IPvF;r9fwOzTxYy0oREGUyXRHttQZ99P+#`0NH=5Zc@ zY#?Gn;z==Z4z5JHOHPJgCCTr;93@G6D}J_TID80nd`D&`&3@upe8sGCaHaUeNNP7I?6i`KybEtmBWHBYSBmNi>33_92@^k#99C9;rfnX`dTXG@0 zKAYl9Lbe}+HZc(>ynfIVgBvq27AxfAH@0D43MgBT)Gip&TaxdNcZw(xU2w>-)JRie z=H2>1SDH!I9z>ldr8}w+PB-o))tuYh|DkOWR?kA-6L@wA^&1alBWDI$;{{E)9DKu; zbz%=KSH>ThPr5y3#NRs63t5kCgQt)f$vLW*2)lZ$S$~4UEk4lxJ%(=3Kap~L3a9{c zfCy_PE45?au)W4pPlnL;!>ktBS}>XnvTAwKEQ{(F3dYY=?(6kz}DgpcFS#RU;u{fFkK z(^>G!koJL&$3_nK*9le+%&C=x%G(HuuV?<{0ix|tR~m#15$z741o}N60hf#|KcStD zvb?R1uV+$C2Dv1)IX&Xbw8I+Ejx)T2Xhj$E9bvG3MO3$1&t@ej!~^lbSCpAFOwI?p z=$qhLtF46apUWLZI9bbdH6+!DjD@~Wx2rMydnMq56mo(0EHbsu{I2Z~NzCQy`ZGm~ z6s9>{8TDO%wh&d5Xa{xR2iF%JXaQ+Zi@#P$?28ccvkGfHkwxTV zgZ$hlynL&yI^Dz#lej!Rn(_j*N8gLHl9AaM14ps_1Iv(g zs4YwoiwbQNSp8s){leC-Q%yxSG6X>HdQB~=b=*M9ue?wh#Rb-CTKr+jT*+j1xPC~D z?`9&Os09k(e>SeV-(j%=6T%Nrcx3b0$>t?pMVD9SzNmN5XYTFteU=?YS3=2|>erC( z5a+fl_3WP%TE;p)&qd9A2j2uwJnALV%wXi)&?Vj~oh4gK0crVvIa^LAf$2q={XsO{tu&~(6+2gFa8ZOVdGiOd={o2K9=y4T zeddHyL2x?y!hybXe=eQeW7+>XeF}&fZ>liKzs7o@C=uDSLP+wwA2^hkRd>4(egW~} zgeBA2Smg5X^AUyaU$Pta&j$Zk{P42g(0YdMK}?*?Q}Xc^t%hN7dT7=^KX|J|7ifli zG$z8=Kzr5qN2R?RZj3)FOL3K!u`zp*=zk;jqjO8E_2OOQ0AR&}(x%W($Y+yl^8`qB z>W*z~4}m>Q0d--uZ1uP=%_VwFC?E4ZG{ST9JI_GR!A*ZS0c7honi?;{=W5) zLffb=fKjr}{Sz;iCh}9nT<#PQWYRLr4L?ilpIgd2fO4w7TLq zKOaYsa|;A!LULir4^R(BU%BiH@{eRy9m<7681pWU+p0dmW{v{Ik=XjHGCSE@dfjey zq#`)4$vC1ccM}tYKiX6U&DVXXls!k_smhx0+ko5=tm`rOmZ3?5@uHT+I~8p?b%!X3pkfd*(68 zetbzR?=7T$o&qi_bNDgT*H&cfPHe!_5|=7Gl>-Nc^t`7iG=*B+#*7vJp& zF!PL&m{-6LKF8u=3R88_SI;u9)>>*-YpON`U#VHSjn1QnVcFj*nnd3N7vFXqJ16YJ z>s34Lbrs`d;C}ShAFrRn&O>j*ggp&#V70cv{wBD@}go7HDeR>vtRm)2*ORNbK&vrLV MReao0%l*%11cJhT0?+9xTe zfEmv|`95W~<_7wwQf~l&*MLnu%S6!qk`tg|@=Ky+jTQ3_#U9iB-B61sc!tc zpAD1bvz|Gn7XL9;4l3Zk`Xl9gUM6WT)5BJbdr|ylWb2z7FrEbjH`qz`3`y3{#nqdA z^O@NV^`=}L#CXqV1r;4wO4vPU9D`r9v~-~Gq`Gjmyh)I6_pzKtK5j{PLLMZ>LzP5y z)%umtFT!X#J&lHckx)wWpA6$OliGCA6$eK$jc9`U7Xo^78MkTK%^R-Jt;TQ$uA40q z_%mR6kqqik)gX-H7$ZbI^I+9RUhwa29)lgHfI!JJKkkD@!$cCnVd6`C^@sB9bz^AR zdmD|5FAaPH+=C>Omi%Ny)vQde87x0~B%ub%v}tzfoO!q*k*VeM;IIybohU0}7*qs_6#9dfY32N$@&x_`*qD|I6`uLf*r#Ge9?@WiG0p#!k| zo(x06e40mxJujkVU;S%F1ZbIk<3WQ^K6FxaaQ2vs9K0+`gL(!(cCp{M;$5M zV~xz&s<9Uq6UjdX#QH=?6d64KKLJ{)r1GK(Sb%Q*s3It#e0T%rxcnmlYoo<)2fib< z8K^}q!UTy!$9A#S`1J=rBo*-%4G%J(zt6Oux3>+b3wihi$^CQhg6 zg?K0d(VKze@m=}*I$66)iAH5qZA zi_@J0sEjwya&84$pLh@n^z%OT1IM_xhkG114DYZF8)+0MQ5tc20#UmS0Au1M{`H=+XLGrLtgwdscl#~}2N*h3Jss*-q>mhK#wN2_RG z=BDzy-_DUq`#yW8fS1qN@9zmn6j``Tr&lV!&ZK{sTK0^C3Vx#hb?o{da4tp-8ZqPy66_Sf*2v*}oW)*tpwrm>N~7t# z?#@C$a1Dl;^ux~XMW3FWXqtYYO!*fZUUUMs6FyuI5i;{FmD z4f6y*M(|h!K-o|uvjISx%@8y4h<=m(UIXE3seQKNfMPFsq41pC#ZEi$GWb5(g!p7m zM_quVJ{YLNcDDS@SxbaacrrKz90uAc)EM6fvN#<~=EVDog=M~)!v2U9{5a3ge}JyV z*dZs|)UW)}#G-iojMFb)xiGG~)8-fRo5I`S8lL_I^sA#eDaY-h>$?jkq7?cTH5W8It82w1QGgMkU6l3UxM$R96ZzJxPY6e<8hr= zd%6G|YkW!6DuGoWTqjhhGY~eS{qVC!KP0o)*Ur8jvr}a_1*BVJJ{SOY&K?zRuKglV z9Rne>!s~yvF1ICr)mP`Sh2OYT%lPk;7-!SI?!*m0SkyVEr>3a}Ng3>&dzmKb5DlagzVCJ0%V+>kHTfx*u~ef99xb zkScfT*^}(-lk7A*pt2&dU;h(WrqQz)lMV!DLYeq zO|zqMh%Th%%4o_okU!}OmoF!#W7UoqSW>{;T?MqpL4T_#Sct&tlWT5G*v zP27NHrjnY_CTCf+diTLHxO#gv2kXmwG3e3FL)jkcx!q$A{>#xM??E}7;DU`Yhq@y& zUQ<7Q-_UoK)Mmt^b12+YuHbIH@7yp?ZiIDY+p!b&K^aPFQ`=9agDvPi(EP|aqR(p{ z{6Uy#2^Xi^zU$)Wby5X}ss+vmbAL6StDOkmgMB<&8 z!S63$6e*p{r85}>(qmlNfq|fa0O|YKdXukLxhJ7D^4gfaKC4XHjC4?c{yS$=`R&(2 zM*Nd}zb6hY0>_VnI@TI^7G~)&j{UTO?iE^t-kgqwq0=(4{`Y*(t_PEzBm6u-W6u4K zZ4)TJ`<2RgBS~F_V`_4f6#So}3!ns|>CS$5cvB@GP&(jx7CFtR<(pz z02wiRc5m1cs0|(AHD|rf4ViDXl_{HB*6yN@zqMSU{RsJ?$SN!$;3}n;IZUS59|x^nfQ;4!ehfw@ta%Ett*d-P+`JgX0nVkXxlGobowQy3$j{mQ^- zSb%a_1h}B=!OPMk7oi7-apR*7rvPp$ZhamQ{2!VkXS}ojk6cW7pk8qs7R|PnTCu?N z%H?HE;OCc@lR8$laV}an`+J~MySPgPREI^h6hGet3{GEWBz~nAtQrMY1mXpbN-9;2 z(E2zems4$9i@bi2w^+*sC9pgfvgLMB?Xd(TPD*_DK%RpDi%6WEbotva<0gKK^SI|; z@$THm%-bRrR5qM)wgI0cses^s%|5Bn&8&6XSQksb-eu$$8y55n`g3G7FTW!t&Gt9{ z((O-J+-A`1OJwlQ4Q)T+eCGp$c3`TPyRQgks zN|GKqh9VItXJ%hJ@US#jn?-Q?Qq&4#?c8kn`pmz1T^lgLObF4Id?cJq|N7zIoV3wKfE#HiVLbgDgz=>T7 zGfz+kIZcz8fX@3J1re!XUV?RKEajcdlfU&p_JmRk?~z=Ah#^S!+a5Xoz@wG>)8mje z54K=L=@f;*I2BhWW0!=UrIVJ1fS{qgO2z_Zm|4)IEaws1!#8~du2n)&%G5^`*( zXf4cM1RCb-O?lR@NyUtxjxYX&jQ`@GT>?+dYX;1Q9&2X{B;7QR%bfFqKsrgIka;NG zK6(@pW5opKpl}nBn$dcey{}%rq3Mie@}^xg0Y<}(bOl?kbX-n|UxZ`ke#RU1PU_O} zztalqbDLwBW*-Ry4>fk8lTQK9_33_-6vrwb|DX(v+@xK*Vu{#jZ~Tf*Y^xiO2j{}f z)3W2O=Vf}yo0t)56kYhI&-mXGnV_E-S1>=K`O=Asb63gZAY+}1m5GN;GQL2PHy>Pa zyAqEfanHAfUQ^}8{-CyKOm}A=rvH@EMwo&8IhXQcamz*&bn;9okvHm<$Lm&BH~jN}Ij@s=lfFE7vYv57 z1?vVssAldW2j12f;&L}S@Z0lrGTsdg60*N8c}uG@$#AEiylDX*2BVEKQe9)hwOw&6HusFG>OvVXpXnkDl)rhrmSI(YeA$Wx)_- zzgOI2d;N_3-Q(hF!MD+Oa|AN8jc>-SG}pR?gU_pK;4|Bd8!zHVPkyg)2wfNIxZ$hI zOH4S1n=1AU>Sv9nd{K_e6}zpX0RIW^16RO9sb#sTr3H5>fxaL(&+*lS!_>(tc|i?1 z=lmN)V8kA_3VUJ^k=Ftt*!A}E5f{OW$ePQC5aAIjhir+kr?O17w>mIqnu=H3Tq>DL zFMP|r&^@Ie1F20fnC|#-5jMJ_?7D8VPeLlk*s$B0+>a#eLJQPxMo5%suK&xZ6QhiI z1$~FWqv2O>mfA4%@>*W?n#5dtLRA6XTMb6lGmZ~ow46J@&IU}HxY^+2RalGVYF9O0 zNBcfESPuA91}w1NJnB`DJGc^v;#w^2DVvO~ZlLc48VxU1fE82*A=y0pkll+S3BG?* zNp{xe9r`md6_02%Zqv=*-pk}!0RrlU8Dl82L>owrx1OI&{VFZ0u{7ioG;pH>=Oix1 zRHGhleBoWG5jH$*$1!NDVTn$`n$QFbo^il})1Nwx?-SZt}nHJ;9$*Gk|8Gwl`*yext=!q4*}t zvzj?M=}TZs9q=V+ULtYx#AqFg{|FzTDAhAw*`yedPqdKKBA{gBa{ZJ#C{oH}E|dNs z3q#jWT_K=x@KtrHmgntDn8~KdRRZ$;7h36t3S+rA^>w)!cOo;H0UZmTORbeCC2Ev7 z@ik#aO_#@C(4$M%n@hG0QPm4i8_&Bcg^=2z$^bq^ zVdd3xo)(rDUwW&(S3GJuc}i)mo@IfL;*boYlgaOPtOC@nf>iyFE8t`ZeDv7*L6T^? zc+5SsE3b_b!!#K4E?4CmKm9Veu%u*rt_vk*gocbFo*|p1KpV1CkOK{Mn)LM!E7l6} zmUwltroji#gA3y17s#U}-Bpt4u}Mee=5SsCBvl;udxP~=V|k{TzxsMD^B&?2N>I@) z7|0>5NLEXA7QZZfw*xHQO1A@^5!Tp09{+4;B9RZ0PmOlOu4xzFa+EeaiJdzITyRWR z#8=oMeOjgw3>4*%-H@LY$ZW-~I!{q4}>~Tk>`k61`?a z)a8?2oVl5-dIzwSInlCIT5X;}*gxE>oI8(rVA!8ljSg+7=mvy1{IAs0zEccDO%1<|5_bcyg~ zCL}-KOS5ruMdm#2%AqB~@b`kr@KD>6q9dCc(s=6YCF_JCqf$A`;>p#SnOuG?ZWFT| z>}1qm?aw24!Xp}s8Ct?i3Oyk`8pjftqHvP+Idtt8dmknu2^jr+|LaiPV|{sZBQfnP zr>2RvoCd=adMw#vxOGxErqD*J*WQo0mn;95REy#_C>y*3QQ?9K6Og5arLJh^>Wh=~ z+{D1wWDJgT)DqIu!(;Xj&wsZ)m&Kv2A-uj&_&AaONBMD@c(20}Q3off1|QluM(^xg zpziPMDcVso)F+Ymu1e&Mb&5|U1?*UcX z5T1T5p&wUlr#ZT9XG5$(>oL|N`)@Z|E%F^<2D+&0Y#1yLegd9LA7H}R70dl>ihtB# za|%GbrzGxW2TuL4gd!atXC3Xr2z?j;72p*Xz}@-|iG=$=X8IieN;W+Gor zWC<$m5bXAwO3ZmOYSVDlc+>aVmBI{KV}2EUmhhm)=C(`IQn;DUlwj9eRR4I zZ~mt_`ND7}k{0+=;J?XaDP5jp%)@LF+^0sb(GNMiHo2H`D zMNpJm3K64aHSVQ1%j#@${4kr=!s&v1LuISZ_%VKZdr8 zw_hze2h=%UaIkxrx29n%GWW*$K=Z(tSjyOrcy}!Oeju;jffV^WxIg*zCpK^_$(fMT z*hYgnCY&n^H34BeI&nDU9-_^SOHdW-)h-=@IG3S>%&R@~;m*z2y zk6g0&Wb(~`=l)Y?Z9-f*Wd0QJAy6d`rfG#4tTbh<`eqB#RIo1`7KK^KnYW4Hix2 zTOr?8kJ~e||NLI94Y@Jduk6Cbv;M{pJ>V9KDieRJF7(NDtGNIDzE{(U(Q$|X>frJU zSa{Za0pa%Lreq_pLoy%JSZ(SCz(?+T$I)KV1*L~s*7TWbUG@AHjLF9BFP694o@v3+ z!x<<2ArfB+e*yAWiC(HoZp4Nk?MJjYc|q*Pwnxa zRJDsK@z@}_aZJ2u1j1NxCz_##lB;=S;O=hc@r7J>l1YI~`a?^s3J8`2cVUzR2F>(nv^Kx34$MbQ#*^ox z$VM0tu$Ur1jKm`OewI7b?uTVW4|jgi1GW@oUc{)s^Rz0R zlby`OiN8sez>Q6rls;7NEI=x`Qw}tjDfE_4y0aP?J=ecmBJR3C__aFvl+ksNBUH|a zNiUEU;R-!V{M6=*3vdjS_y6O!a8%WUn4$Gp9%fvJYCHN@CRN)CFQI%{H;Y0f73+fs zD3|LehQ5e976LQp%CB9uVGESj5?id@w?L=3QiCW`=RXJ0!UCDi8yo)3RR0uKB>Li> z?vNk_xreTcRJBH<^P!AsYpJqG6cf4?{C+H_1IHU7jbsphye3b)-*Rk{9Wn!14uk@I zq8bpI>How{MX(;VX_i*|y`Fd}&vdK*ccq!O+O0RUV~wR~s-*7|T=Y@nZTt~f$-(XC zK}QlIJ80gD)!QkG+AxYu1Mft&ACeaCh36*}U{VSHyI2?=ngY0GIt@VN6xq z)$UNG@x}WUVHXU@ z|8+RGr+9=u@rPX`Y972B*&33S8Mb(Ua;g)n_LRd>bw?-d+6~ao9igc4%21So^ly^q zhu4v;G2WLe(lP3o<=qRl?BR{qe-IJ#(JZY#Ma|D{?0`N?E{>XBfM&`-<}JxQBcr1! zJNVD}y$@B24W^%g48u)^rDcn!U%p)uOW}X0agGMqS3Lfn(ylJ+#t-jH=StU>RZP&& z)oI;%AZ}+cM<3uFxRDHUpuB4tHCkydIMD^yQ(Y*rGCC;^ou!^)|gQs;7 z?adSC;`-(3jeyYAnc$llX|A2T>saJe$h=50Zfg2gv$AxTRa;KqIBzoN%}06_d3XGU z&gdSt*-!?6m6ZJX!vNwhPU@c(0H(XqFA-+?*A>h*k!AK*i zpbp%hCv9G(Pji#!DkFy;lX;KG(=9_W6)z$V41T?hU=?99mOB1K!?IIgDQoR+1cmT}bQ zm$k+G$3VQ^!B6~hEAq;N@p=r~`erB#6%J(f&2A{I7#v!Nyh%M~!w8nYWtxl85H4Jm zoj3&?U`AEX983ZuU#1!3SDGPSaOX&k;k6Yt<(LUHFK2LdgWeYS#jhU|Po3FQ9gYoh z$@R7V#VUvDr+|z+2lFiy&gCjqO0$J){9bd1V8Fs)3^d13bJ?1c?tPinzpmH(za=ji z0feI(6VY?NKjzx~jVn)*ULnQ}W)K_uC(_U)1pbl1Ibqs^@cR0x(9sQ-ZB3iEcjSO% zZcrV==1t^#T$knV+fSi(&{PDTJ#{4`V!ywOJqz)ioe$A0ccL+2+IcZ%)~q6_w^PlO zm4Ivu1MRD0*aK;C`6TxFAja04E%K|$rOz(*-7pGngHNprWLMQ>o2}h^e70x{tBd{U z_3}Bt0geeR&MT;|S96R$i&M+F;3Y!vJ)&-#NTPndpfpIM>(@6Swh8p^!ck~vhh4DRylP%4RjI5qxyC7iU04g!-q-Rm&1AKe8cGhjT| z38;hEp=2%M?tGzk63 zM2L?XASd4S*M~j@-14oL)h}T49m?PqH0!i;>f+?2=~RsFN#FF}!$RR6fiUtn@BV22 z8i@TcNrffeIS1svv4il#B*6+0!s<%vKta{}u3M4j4hI{?9S>P|S}`+jCTjh2w|SPl z_ikHW&Z=1^z#((0`fc((S@<6iCy?(L6t5zS`PIhF`L|wBVrKnc@#E{6m_4sd1%O=$ zRkFmaJouSP5%6WiBme~dn)~-4b|@Kzarj~}S5@}?*ASFwhcnnKJToDgUItm2nO@)X zZElnrA~}DZSXWk@v|1h45mB-Mf4WjC%%ld|VQWAi*pt7Oz*&j0ulCQ1qMFCI=tnLt z{Omv~GFH3)F-eSUmWrIzaHc|t*J!S8+S_xbaSh_-6ewkU2dul2cg?MMUqwP@^QvB? z*?=y0>F2_HemdZTr~A9h+q$z)sZ}lQKNp4=Kw);Ct3utwhev!vM*3xc{}Dg&6V^dd z5nqPB9*?7pg4r=x+dyW5cCr9teb}Fw$@spBD@Q*Lr+&Z{EBQU1KG>0eb!!Z77N-)S-*~Xc7$1Z#5YN-ZtXjP$& z+Lwj1p3cgAi(wjx-dE^2S0jc#Pb*1Y2?2(Lf!U>alqu|);Ik`eKXTD2z^<bG3D}OI%89 z-2K(|iLARY_VhcY%d#^)#xcEHp`|@)bs{$)H>Ve#Ne#d2>Q7JDDQDx{2{vt+rGvbu z07y1GW_ec!SM}W3%t|c;wQo~3b^4YF7$pShzkzTzm=tRib(Y0`VVFanGwu9ftBI`YVuv0w zTF({-E?QC8S$;KS9j?H++WzS7ch)nUht@&4ppFN7&`9bsXt3FtQ}}036t(fN3UTw7 z_)1&M%`8EqCBCjD%=+(AEdGor!#j*rk?9*|6+?*SBgXOBQbClnPk+n6TH>-=YT+rtmY6kOYR^? z?*7g9sVikyK!C0mI+1rz^1iZnKqteo0VFZvI8IpDM$+0{5>qB#efE0iBUg%&huztt_UebYA>;tCe)?$=jmbi-t&Q#h{#Kd)MYJWb*2@-J`oVz&mI9E@Z&R6YrkOX_ zk8}^r$?9l^O0fOST42orasQL`6+?`l0~s;*cmLY+0Bb7s#=ssE$eKZd;2Wr$HZ@)* zA3wvriW3(KnMgQz?#F-uVI08|&{iOz@`H?_?P#Ew3Kc-D<<;!$z+zqnjcuk!PkjzP zo;6Z*x!V0~xI}@hJtVjedMDTI_BwcQB#J|0-D0R%%0M5|O zI0>D7{x!9>0PeNsj6qcFd|ACQ6l5IpWo*_jl3M?CBv9=-qrOeOEY=QF;W3reDZU*B zKY|{c%qZ@lNnFWP-9C_3#@qODoYQ1N+4Cq{na0MtfByd_TjI&VFLI_pud6C8wywDR`&7Yn>z|BMKtKJJ8j7r|%6JxhWVYfOl!>H9 zj?d~s;<6mi(*1{pKoP z8e~_T{h`5890sq9U-QrzRIYcmiPf?7zAXj03sU}QbaC!DJq#L^pNz}LI)A(5_xS1>)770NbzI_G=rFipzIwiN;F#-E7)JZU<2%c& zet@55;rT)ghfUkiq{^B(q`(@L949@=g@xa(b=H5_t|98Ge5>I5R@O_-ZByf{g7#?x zH;JC*B$MSCc5MvwDI8~LWpbiQLJX>dVKUMWo07&&s*Us^`gYw@oiUlC>^4^UR$LEd zddO9YrY3Lm^=D+CQ*{#p)Khtf-WrDa*(gGwBu)Ch-*c9>>)E+nANrCxNE^cV$9R+b z)q{+znwKTWxcVR}4~xUIzqisQDdjnd@PA%-Z$ufSaeICATrC*QM1YXE+;AcZrYn<; zu_b6*J7+tR?@NCNEKABhX{Z#uitg0YFJ`F z*i&`LsmjZ#6r+>EaHPTH&Ebqahg$wuwYU;4NY0&DYx;=b6U6+rBq<e-@9km>W+>n_De22_D_ao_MY9vHB%-nKvVW|y>80f zu;1QvA{qsw>%hbc+(utHHoT3UBk&Tz8~wgs3FhKveH+#<*DvB1qeT$|=Ng7U3o+%} zn_Sp_B!$nS_oi0)n9B$Y`Kk$nso)60@9atop$XmLG>LbM+DC^|E?17Lg7frqoP2r{ zQZKYaysZZl4jF0+9~l{qEe|g8k3J|1EE`Lk_SuDwxtmfkH&P4lniw4a)hLAg-3t9*di8&P zPb#OdVA8?grSBWUT{t_j!pmvpQq@&zQTuda{0b-+RO!CU&a~SVe}`F z$OWeWMdTf(jquW7PeXZ`wwST}V`4c`CmQ|5$zz zs<{rcv(@K(kU;(_)2IMT`&H&BO_F`SU^bP0u6Uqle&j$nyip(4%WX0;oGajN7}K$P z^Om5+^;SKu_r3|3LRnF28g_X7kM{^WP`#X>mxym-S_L0t_1wmWlk2bVFXjqJov#185XLd7tpfI6lx zWKEZ*ejI4W2XhbcLiqI>hVFS)oc@lfl|BQwHl+*sYdro_JO1%T{|Jnh0~=kau_-aT zgd$xCqNNt)Z{Qo$DgHYUg&AxLpNJ9d=SSnMzUuR~xnJUNDiuHOzxRo~zGnOXs_xCh zq5S{$VTBY*LS&nS$eJRuO%hYYSc$&>ezx#Ra<@bH=-yhFE&mR|#aX6UE`+6paib@CzLFhWa(iWnkinWmiYxf^O*E z_IRkstf=uSlbDH!QVxvTi=-A6`*tAN>eUFcEqkktqJ#4zUTd`-H+FN%uB{i|Y~mlY z;=h--dI0HuS#y@P`9NrUcxM2RccGUNmj_@^DZW6_66hD!>|yDMWt)YvukqImiGbHW zpa2$fT4o7N;`kz|c}2G_VQ_cW!Xo!`)`wpqR;SlbD{S1&a+GXC$J<=ziDEdGY@ZDR zWnPJaglfeq+W*$9u{y_$HV6ciAZ6ICqar_k3wvvI4kr>XPU%2od3z$z6|_45q3&Oo zOFCwb6w_DW$_jbgfxFIe_({}F1~mezwq_xW1`{|mg3a*Dd2R&`Lu?67zP&@#QGv%{ zuU=`nnc`qAsK`bMqFzxkU@q`HNM_~Dm21C@#cxkt5#$NvC3nmxQaCkR(j+dD>`*Ra zEy~Hyz~#c-WAQWr1{4_W6wn!X|0WmmN;nLUYAfu|d;P9dx-&{FS4Cxjn zfO1h&SmViB@&0&!bFnumc2As>!YT@P#L5GzXjXujC5xITN|-)U=fqdEXfBLT*^c1& z71o%xQ6xJGEq+gw6PP7u^U5tnP$s@C`$dhNC-8*%4tVK)2cC%{XMYWdInX3E{8O}L zHUKeS3ucz^=MVyjHkvBoYvkgiP%!Hg zMHS4Oo9xr4JA?_C?0QBr7X^$@OuUuDFnhJ$+Sifk2nLmc=MZ{c4Yv>GWcVT=leQG0 zB%2~JHao%HA^aR34BnSzbrKY>Bi}-0&#YI0_PTmc#bZTJHF&llOR=px=NbIH!o5E8 z5qFBYo&*_OXxYUKSc%;m+UL8!<+ULh$Yo^W)ooMu5*r*9LsCyOk0Oa;1un;`HVGXBb9Z!aV|PYP+KoCg zq+j#hjVA?xe54xW7rbi&`6RKqT`^8~bid*LiB@RiH6H5yDbiS^-^P4jv^wunz2;Xd zGmBtUg~ag(yP;o}mZ3$3uIZkX2yaAy}yQhSW5K|0I3ZJs3daYEr9EU8P+gn&^~tXI-tCKbZv@<03o`G6X6$O5+P4 zP)8JJ-Pn0Z&Ief8iQw#iI@o_lt^awRaG7vhb+wb(Q{GZ$8T?tVob$e~K`wU_&W)W{wi3i%xLUhveOh}9Vd z@;$~V(!FL&**ufUxz~U7COPUkt+?;}Ei4V{wzJB>4W*ppSb%k)_$Zee_UdJep$@J+ zwYq1({w`w0HqOP!NqY5z!>VQ|QT!;(d*N&%O1=Ysu-2SRzHVD#la|H*oy|iJ5wKpX zMhm$eY+O=1^sQI5uG;)6-nzX+pz- z+s+?3g_k0^XzOBk)JSQ+$I`=^dMm#VfSA$?*MY)gDYBo!!WYx}k}FM^L&gET-VH?4 zwZD~z0O7Clb=dF@fGdCEoy4Qx9?S_i>gKHSKJG2>>fn zxSL|(mND|VB5z@iWt}E7Y*RAeHI-^a=)EXu-wo<0p*U^Gh9FCv$~1!(8}2iL6c4Ra zW`fd;lmkNOH(;hj$d5^;*ZU(S{qo6HG81)s4tvLNp@W01J-JmS~_zaV9Ra~DXfHPi?QY0uLC3!8V@AK zV$Zq%1YY1#lkX4xtB6$#6ACU8T&Ol5_BfW@rdo~8hz95p)TZOE)68nYyCr=c!)aXm z{OU5NXlSc8A@RU_8P##-d7yvVHN(u0Jek6*T$ktHUW?y{ZWZBcRJjPeY60zRvU+2W zx)!*XbVC4jEyL}O(MBIkQMTdZw@K?rsh56dmOj^h)=6&Lnejr(1BI8P{~L{r;KA4D z!~yCr-E$yT(H~%P!B6?FCgWaWJwwl&ON@&7asvZOa9W~`9HJ>4i}$<+>n#fEALfY+ zSU`lV`RR0@k}pWU=RLN+PZng)SYMHM8Qj@^NTU5)Ec{y!PCkI~=8#`N#xZ4<va~-a0y&?C=Gwo}-X$$*rO`!= z+;IXmYgqzRU&Gv@#faS6w6m^!-TCWZ7gy&tJP8G@urkFqS=LZq)Enk4)&Q-jt?=d_y0IrMNae8& zmo@Qk{@C@xYr4s7)`rM2Cs1*XsqVY9IO;SE(; z0<0-b;r^5+K|4NA9_=IU8utr~Kk3WXRojIR#Ege6Fzot&@O!Z~=o847cjejs<>gw? zIa+TL_}$y9(KzJAHM}gPMDJPZ>3yN5Lf$a#z(*^Q=8xYY^k{mBoPvQz3NE4Cx6w%@<_uC;(-n{hOXVL0l& z98P|H12CZ2!vgG6M^HHI{OA*zii9C&5k|dlNviRZs~vfijmk9U@*|T2bwz=8Gn2Cl z`iMcR%&OUaa&gcI;pX87ykhfemY$}G?v|Ek6?Eulf>F@9bKEorjYCYdx-4xhO_mtH z@?@3&QtCVYbA!2 zC#M?07osG0#mK#{3W!N$`h~Dffouna-cGbPM}cLO+|Xvk{S*5yRjaChkj92+g81IJ z1+`m}XF<@aA?HP&CoYT3bTn+VzqjY<4jsppwJ)%fIH$>P>ejt#3Eu(b84-OAevKNu zwM79Oj0Dy}4soHh?vm%{169M~w&^HN>nIkY<~_Xi=OjePHwy=!a60y>c5bBuwFgJH ziy|f4^US@imixv$D4C4$Er~38Vsk!J;JE?xUR)8I|0(JHha@N{OnydGfSciUAEz29 zjK+2&Ic&B=!1ciM#$viWgJ>icXhYfkY)l5T3_1gyr0eMWLyfSbSfQ7i{4wvI7O)2& zU;<_07sU_3=Lqzy>5-WcFbDZRbX#LUVfQp6rrfj`VZ`~Dm91Xx1$+c1AsbqB_Qb$D zjRcb#o6NP6gwr+x<0+o2Oh$opP6x&drY%4sqA?8CtGqa2@nlcxb5nwGcg@k& zMt5ph;~AvgI2Lu_2OgApoH4lgA?PPb9&56yR<;4N8tYvwAV2Vc*dC*?udH?ON_NqO z4Wwj$2<;p#0mv2gE&Crb{z0GqN3{rjXQLdgSDlYo!)J9nPJ1lgT`=c`Pie=U#Y`0D zN~1b4VjdlZJSpny;$-R~q%S-ozww2a-)E-RfUJOsHop2+<+JrQL)(ZZ6UZf2HUlkh zqgI`?Xe%GP?w2WQVZYprQc@*QTM%7RF&6#h*xQ!;0IpZc1G}{D0Yo`}pg>R_gic~{ zvB+P2l0L^7##G4-SR}X<^_JpcTR$*RFPnc$e?wGI6MdMm3Z7R|*sW>>O$g&aZ+OjY zhP1IyYub9h?4_LBMEgTltQ(Z8&Fiv&-(wAy!dVtm;_Z}VN(zvB6;~7=aXWMGa<%rkNf&;*jq?-X=lrPik;ofU7tgC} zpNU(4SrfINXYDo$rF2imG~_uBU2^kgDX4*(B)xo&G|!w9D-y^pGSapAm9nJRqv!)* zB0CRX15pKKy;0^kVEJ3WIK_=q67>64_N3bcejUwyQ=XBkH{Z3JctVf9Wp zq{JdDfsJ+I7EczozFN3?T*>%AAzEj64eoqUa$8?TF21BZrJfW-2Ho~nuUMNq3$_FE zQ;g*FzB$M`d}{>bY~ZX0izA-hRBnYM?iRNR=nwEY)x04+-qEbjV3%Qnq}_<|cHYs+ zhIiryfRFEwllA#EVLDFBeM8@SPfq$rL&-ki0^lj#Q+FcTk!cvqxa{D}CfmplCELMD)TKwh=e| zX2nId^-i`HPDahYGF83Dc9hIRI_dNd4}E(83s=8d+VAD$=^o^>U`ozym_a>dx{VoT zdk16j0!%EK%lp0N1;&mN6-AyEUlm^VJbrra2lF1`Gs;#FVD~jFJbbfUjVd&S)dY`` z`>KwQ9fmgwrJfE+eJ!tucv|`9qSB(q>-ZA2o3Ko$s z!;J=gZ8UT@k$tIMjfgL8i1-1kj~$~H>+oz>rY?yMMsboZ1@PN}l2zb(m4E2W=2IUd zKIYN13sA4I>^xh7XGZ|dWHFc;Kz*E1P8-OZ5JZyRyaoWWG79)7rK*COj1ZfNpO`Ot zNKetv%{*{i_d<==;X-pCH746WWi$5m;Rd}vg@vr<`G=T(*WRyYlL|gsxeXtrvV~J_ z|LvtmzP$+YY`Zm@M=_YNNVM61eupYKMiC-&!f)dzVstkG`_Ai!`D`5j1oXmng8h)v zp1>`x9@WPVJHo54>TiB}Ca|EPNZkqCtND`dXLldpkXt#hU#BKRC$}_treh89vTLzwN^J(vT}$xsT<3l@IoW)~eN!n$>A6wwrXSsj z;jvZFW)1nK7QVI_e4ZG}ncQZ2ZMXGR_wz6!q#$jjN@LyMohQ6MdX~zT{qwu>@u=`b z%YE5ME9`t@DBw%jM+RF^c=2PCm{AoJC+w@D=bMkr2j|oG1^PTUPpRccI>$=gw;Gpt z6RQWWUy+FQNZ6z$G(Qucw}-IZy%ps{t2+|Vx_p~1CN$ye=6~v7#PcU(vK_L_bp3-o zxl*%qYagt<3J)HR`|(vTtGHXNHL{OMXtdO^AcAlA_W;b;x7eeA$Fd+9Yev#*@CY z=DgKu?Hmy|Qfv&ftzczGNEN|FElmesMryh5#UY40L$HS~$0-xRuQ3%09%$X_|IWFG zxVv)|YCp)npDAE9P6y_=bHUJZWTzE-#v$uHmSgQA0CgTJ&|a3Yb%4V(O5mOgfXm>x z4u~dEbQk)+m>=fK)Elcsi*_Nt%>)|$*DGyKofYc+aLlPXR492VUEbZX&dO~ zqxLi&cFdcQG(F1YFl_oRZr^qi5YOlS_dn?`j`=@cCveD0P$W|*jd8=Uzy)n+zxl!L z5^D>Rrp$}I<+K5s+UN*2Ajm{4h>LVR(ROp?9)$2fDZb!Tcq;6{n=nzn#+*G2@8U&C z1uxwGw@-*bZ0{T(d6gVcKP@pDpFQgo5Z#D=<|4hc)e^q&mP=~8qlBwy-tEK&n!R4* zRP@&;ok4-uev2OqTW@X+JPJsno+Z+g6;{!wq%Lkh6U@Om#Br>%)@!R|-PwmBzEu-= zKKGl<9I96dEllfs8-EEbPuQh$`x0exRLJs(?n*3+OFDrmTsUU0&7;^5v1@ixeVv3Y zKv-Aot8tkc4{ym^spCjAoQkfB*9~3OUtH`EqX(FzlqD0(!D(7#)6|7qBe4qKTm=B-MU)bp~y%my*5JHl~r!cEZ5;NXpIRRz*4I z#yyM3ja>k(9Y^F;HNMhfTv{wNtlGy5ruX?!!4KW;x(DojV`Kr*E^xUdR zw{Kl$YlMFPyob!7 z-Wh;!ntp{}252DwjZj+5oNgPz2X`R&HYYD7Ym8(^PFKDt{k&6^xE>Zoj?oI5z>6Jb z0rsQq3@H6tmJH%28S{4S37^ zi#;(MAJ6}xbKbX3RUS<`)zPb=J|iyrKrN)l(^{Pvy#Q#8lZ4j+&@E$VE9^Ae4IO0d z`w>(L22A`zN7eys1{gQbW-%w_M0|VL^ptNY%E$lys#-1Dk#a~_X%z^>nP6{~;#iJl zi&H-2cbowzcHZ0>sAtxppfeJ)djlYrR{qDD;tkB|RM#19%rOE|L$RV(s%qlKs!Q;n zJp6oh;psKfwd;oKZ1(~FLy*%-G!!;`P(#_$G^lMzB<}$p8pe;5BPHi@v{OaxGx7BZ zm*`*1D-pSK37rAbAyQDI2S@UsISofERo_RR5xAlLiMahTBtA3Y-ct|eQl8w^jXOh5 zHs1%-ZxA24pU=Qw=IDu*##>X!cJq-Dk!3GEd03wAv9~G%4&+ zx!&a(r4b;dVZEOGVtA)c_)OzU`Vsd#u-n$Dqwe>uNsP0fiO1Vg<9a+K*;$M?9?}7# zr)WOn6$>w1seXq3{*z|evK}1_iw9+k&%ad?P8TSM^bfiXm+2UvC+=KNw~dI*ZCp7j z0@EMfIsfCl22*u5rhA7DF^D~n5GZ#a-zc-5xVGGFs1AP-aB@NdJaeV-GtrmqZ_is3 zIn_4#qE?{$nchsXZI#H8@QyfTqbKie0rXLEJ*t0~Cf6-D8vP*fwok$wVlD`kZ(oQy zORUl+grWrwBl4ykePV8Wx46$^GgnPx_{nMr$e?fk#|ru{PWD~Z3>OGu zBsv+5DO_VPF*z^4%MWNL#E-=2*o-8t8!u5S5Xw2>2SW2!7v|N`wpXdz_PzJY*y?!H znh(^8`^Ax*sSdfB&Anyj{@UmKzU-8n`VLX%KJKAVsxbe>9UjNo%Z<0IvDFThEANaD zj|G1`FR@=US7r+HhH^QUtktT$BgIp494)54ErS;h6b>Bwqbu*ztUl%A@@rJOJdn30 zQj-qm-onaEBN}g5K|DTI#w{#4>*n>QDCW0=!)d_{fpdU2+<4^K8}}7Zpzqd}GJ_TWw;G9D-KX{ka)> z3!X&v-QN#0T_**&t$H9?5gbI{g{yCCt>3&9IvcFky(bUwKV1LN=?7Q%$iI7iMvTt% z4cv`dTz?ziX*VQq%pDHbu7O>>_3I*_r_|%|25-g$wfVD0ZRm8H^o=^u}rE#r!;Q3x{2Rg8^^$I1|EIlGzmI49M)N+jho*4GawuL^@anE~+g~YQuE!zuZ21 z{dRrPq5TO}A5_ac4-X;$#(c?`&H`d6O?T?s0w;lAmpW`6sUF{B+7Q~*p4gyfMzlNc z?gAeq!WCzZ9Dw9AM=Cxa_RTN~N!?+m3c4j`CcqTHE?!E7Y63>X`Txzz(pQmC&bK#4qz7? z=h*5scxw7pp{@q4D<{M>K6&puzdF4WxzJ`DmDwj6h=5GI>IJihwFQ|+>q8wf)@y35 zd;-;LXPkrh6t~9k3sUz8ZH3)({1)%ESlMdkq5{Xz8svL^bBD2nPwMCKkHne-9)4|D z{u;e(nMEJ!LOkJ_LU+m|V5|pxk;Xd*7bDDOE=*0=HcxG>v@_t-fWe?lW7w6(UTUZ+ z)45=LqZ@nu)7cGQ)_dl~J)8+TA1jDq5 z3m23F;^K}?FJ44dnU7-XA^9_o0ja}@iAVY` zlKd^Cej)pGvb6*@)&_O&Ar*CuQc|+E$3fYgh7Uii{d_z%5Ad<`=CT7hyC zH{;Zl6gjtQo;@1xlLfjldAF{Vx-bw{%3wN-WyfOdw9z}A9gmv6)34~yLL?r1-` zH>VtUBMpL+%*6a;J4Xa0NHIBr=^5*a%2w;=?~M*}fl<%ZfNJ6~KJjp?ru_UGO|?|f z5TE(D#DG7r^U^#iHV2QnSb6f*C@-d!8hmXLepP0eP%zQmNI>QvuPp}^XnD?_CB9jh z3+MHi^9wYs9Jwqk)`?67|Jy2uRi_?@oR^4?XPOHi&2OV0=L2E>PuM#tp5%d{Mg5pCh{GEn#J59Oqz&rJ&Wrs|*-K9^E@$frL?tkc_blHRRS%lZ+I>Jb zZ#P^SRIuR|iln1(=Cri{-yn-p0$^AO8ppKK6ztt7`aKIp0wuG?bYmWv@B0r)DQHKs@j_p-8w*8Z zh!Gv;RlUW+s_QW)zXvk$?3=%?#^?jE-Pp1An3Hfhh@P=o%rb@kJqxRzoNy_92zZCx zI!I^4U1sjB`U?FgTezC;%vw%ufV_)-bhU*Zg7T7{Ay2v!-w$1b;SJqR8ua{g%y>e zaqULW8IxkGI-}e8(q)lM1+@xY{a=<`#M?r|BY1h!~XR*EOm-J$}DbCFD5mOn}`4 z6dWB;wOONT3ZkP3_J1(2s7(ooumlbB=8<(Kr`FJA=!l}1-dFe-Bd^R%bFmN!)^_Am z@O$r#@u4{jED>~dLoXF?t?MgliW#WK@Su-E;ByVCibOLidynp!)<}}_@E^KeKcy^PP1@hAilM~VTXcN`w^%MeC(vL-^MCBo7)H<(PZ_UB1F5D1tic#p}xEEnnC-< zde+lON(wQ1z78EWcV3}~d5gKCsN3IJo4&n6yk&}MUtuKifwkc}yf0i{Lh0ECCgc{n zprVlsu3pj;5YJ3HVry&uXW$A><)rh;l=lVbery#$&<1YqVDOz&fBn_$=~nGGG&24& z`yh^V1O0GFzMq9*3?PRYmXV+O+507^HCktsINz@`Euf?h%qk-*C zVCjIBFtDpzSU~O9;ZvCzUE_RqRX4=dH@|?QUqM;S`C7>-vYfU&+1q1=LD}210EF0p zylL9%Tse13s#pFbvE#uWUzX8yp)2xKQ*mQU>!fz>iL&7>8I83i{US=Vr&52(cdmsbotDV6KA^1#^5{q+8n^z_`aS(Vq5CZJUJIkkR!h}<&rgg50o;bVx7;|NKqP`T{6zPbL3oC4MEpGM78UE2488$kvFGNE3V!2>Xy)mwHcSAAa}h3y z#^4^P=OpQ@hr;y195s79v&z4mW|jQ%opz9cLwGd^U`A11)yfv$_`-B@YJ41fs!w0= z;fuhEr;!mZUPEjlFn8S38yFYc*;#=e+tR7- ztp~7q!g5Kj$u5~|qocPBvMW-{omj88U(b!aPDeUn4JF@zbD`#sUT0cV4->t)0ycM74UtQq@(5SX3$5%=Os(( zZ`UZvgUS+ByLmNw+{GA@UAWgz1r_byi-vnb2ip93M+~Ovp>17ZwFi)9cQzKoUL^9t z?&E)_)oP#9<2nSjx{dRC$68<*H*~LX#FvaH36JY!<_seg_U7KJpCpo-9(EYxdv=?1 zPWlP&88$Ro60EmWwItB2s8+(nDci)Vt<^eTb4&xGQi)kYx4_>yOK$oe9(-hLlyi_9 zOh0X^F)u%g8_TrLrKFnQ3;tVr=SjgvFWR?Qk(`5=Mg{CIEWTY>!ja#IDzNv*e!0yi<2i+G6asK^T3a+rt^#4B{cHqNmcJ4WnjI*o5`_L0~EcJpzf5s0q0Lp3CX*@p!p zLh@$s%TJkwPbX8@?uQBg0(pRQ*MoXhOnbpB zG@*463*0To@4dcCR;9D#tk-htWwN3sa&wp*|KM*+(Im#ti zhe)vJKqq#liToY6TW$8(wiu3IBrWag+R}m!z?Kx2#UNRnSV*DwmY};@{G=;C<>$;m z!)aAsVBJjLp>G^6?L(SS|Fg3=7xf$8&R=&E;s@YtKW|v8FXj{04n4_aNEF4LEEYU! zNsLjSc+Msf;9p9*PK7X)f-+}02(EF9(Wl1D24ropL))evx|i10Pj5nAIW_0$`{_g) zPNkE5tUk|Im&qmw)*fx`K=P5lu=-PA@Xv_(gi(K?q+6l(;|1-DtXbX+KJvW>Bq6dU zqD$GX%}vFke^Oewji+0VCv=l^pGg}~TOw{_-coGlqkR`>6;~56Yh?~q;eKYOOYZAM z17U*=wLG6q&E3W+ZYm3#)_R6}#g0KDmB)w3!Rvd#9LH?8Y4#1!JOexd6$3i^E#ONI zjju)kmGo~%9VspkNTf3X=LJ9*LdPU;sImMHvy@rRMkTq%GZj-;N+wL%LD^7S?vc&IYi82ep#+iH+lfd)7F+zGOE<6KwY4?U$UGNDdnXkld2Dzd8C<8s z2n&QSS$C-%fFI5O3f@q-XcK{|;odIZ!DdjXEMA6Meq!7Iy4L{|jr!>e0&FHSZeA|x z`0AERTZWya-=_39w=iIxW?gxhF#V; z$Xk+Br)^M~G{fh4a^5N=+u@93oDU>9Dm~yvyo6y2Nz4Ua?197=sh>5HBV|m&s?3e2+yJ_@=|sP9dEp$VQE+E`zs2--vPQX1N(06p|{#_j7FhA zBoi}O;xK{bi`63^umGAzN_FP;ywD|S-ie$eP}Ue2q|WTeQ#GL=aOKj_N5L;Pd+78> z08j1~ArZipvMn+JF~qs)+0K4TM}48kN8@!7pm0otoR$+mqiA7qADF%UIR5_bvqfH~ zPAi%s?9CeJ0@xk~4E|*=VhUAnoduSZkwMc<#Md5k_$y95q*vk@b&IE)%q2Qnp1XS! z;?;_;xEgKGG{@{4ns|f+ur;$q&k7T77E&<~bWdsgo0=gzk(TQuBnz?}%)gIO&&+<9 zeyP|@GBf9FMA5qf-hGip(K5)oV$;qfee)d8{(-Vff7wVp5}7?+av^=&l)SMGY_`cG zbhPxb!6AbneZslKQ<<(BlP@e)?M8S!a)1fvq2iIU)o)WD-wWn5_k1DpGLJuz*%S3Rd5ihRM~(%wm(?_uAIt2db_>J1f9RC3`UOi!&0UDR=_Cxm z^PlRP{i;%D9qlO))C$c>fHrGgBAo>D9-}*u^b|MzEQEI@Y&)Y87)@vYX!K$T*m?Md zI6qbZ<gSZS+yH9)A8>gWu2!(i6gI2t2RD6{iDqqrrd0rGNyjJQP6Kwtyx{oK9g7u7*EX zM7Y_Opbi>H-*erzSpI;D-9kGv~X~IwbCUN9(OFL}#wV9&M47PE|3@ z3~5uAO@OieMg+D};-+ z&n7+{8IO;O2Jt%TtkMtw*Zk!guv=~*r}kNrIOoeRpS=LOticHgQs>{^(wR-SZLjXE znzHJIQQVD7wjo{Dg{Mtx{pb(-iEri!{Jc^9#H3EY31lnw2=943_SVqsQ8sgup5=at zS;9@3#9J2&P~YYh0KX;*JK3Gc(Rx>@;!_=dY3LbpPe!}rpf%RmXg{WC@I3lRE-|^e zQRD$cY;!Ut5ZbT20yeh3w%|7T9%uKiIU5_XE&B|#+h=(4w@p8HCnzMKDhxaSRb8k; zB55p4$}LmiMa9QVPa=P0n?c(EQDE#~dVk%HUlw2uHVpob+i*h2%`N*KMS))e!~e$9 zv!t+4ndK_$s*A!~>~Gd}>_E}}W$gnh!g&xtjelJOQ@;IJGgRr(Do(&gZxQun}6OtAkmmaL{AE+u*M86DL4rk=c5Mq&`QOB{7`*Rl%J;)1i={WBNi@NZ{IE5IQ z^9V_6f8XrcwcUEtTX9oA!&tw!cWE5`EY2N%N8|QfcIS~Y;hJo?1{slmyrXsMwWMY^ zm{(lh`z!q*@T|~R0Q5(u0CD+px=+tzJ^`BYr~yENcg;cWuU2j_$`hc9B9+DIz78Y- zfcxLGxL;6vD>?`#U^1pRRFqZUSo=YXm0e~TaGBwxGPRIUkqYl!WOd3CNVKJ9Ee6Si z=g2;D>N#pM_GL0CILTu@>1zzRE%91}9e;LyT4@K>0y|hE2hdAUUk=R9X~0y9?8)V0 zZL$Nt$V343F0^tqN6Ia`^-}<%;+10RtJGBVHg9q%0Zf8%@(b zHqEcji$mDLqBB7oJ3##VuXK{Xa>W1rr8>3f_M?Yw(KM{5h{R%L0(b}JX=Cf(kw81w zwsY`J%UD2B36~zDari~*30qglRY@~;oqS#m-4UXtY9YP@?v-o{jll%XmcdmLHFn0L zO75pp?8VKWGpJ*Qnb0EoP|!lBi70RFZBZ3_?bGgU?VUwm63a(Fa#GM^5LLS zq@R_8Pj8W&AF7Y!^=4_F-UrRPX@O!S_bnEHGJ_2+h~IUnm2Q0b>TJ*c*Gt8q5!AEQ z%r~SlbVOS_s!rfV&=}jR2KcN_g;O&M@qHJzQkC}$PDf4kLcUG96JP15E>e9*rs5*3 zjs`d#njWYD^sv>8Mjy{lzn8@FsEi@a15Jj}tg8Mt0zi7UF9|>mG&W!tDM8ftu3nXBOCpkGW)eQAmuYtc@`uh6S+7iK@LN=q z+^Urfc$}j(%S!Nkh(41%c=+TqNuhQh`K@E|U4N&G{6{@LEh*>6i{26dEnj2RA)aJN zs5`X8kG1_=Y7F7lB3zt{B{7_^ReP7Oj$i9DgfRiK0u>zUT|i#>*e0)%S!GMmd1*IA za?!@7{~;zLJu<}QRuJmP&0^m67rUNLY3M!K5id%8FEGjD8i$Af^Om*$b84mM$#`r3 zS9YOh|G(txxf_roI*>V=x!OOk|8+<}j8tgt$V^*PIS~+>C0JGxU zS{mn|^nSyYE&(vK%Br;KJt>>v z2b6id2jYu4XC)l59DB}-Z(mh+k2Hbp)aPu0y${_`;a!Uct^;J7+c@;mAg{#^15ChV zD1p{jFJz~&TC9X1@-R)0{X$&E&lW9M-PIMafmRQ>E~=PIhIgg>p@TIy-Q_*|fwEeKS{k2ueo}!qXvqA-6jjn20 zftZSirrYT&1aKl0J>3^iV?#6_)qV&zCTw*-vEaWx=mI zmG>)eV9~1@lDa}Jnfht~&D(x(pgP*dwJ?HF?%lK7y7W@_ZI@7YNC?{Gz-@%~{thtm z{y*@e`4<`Ozn!`t1mx>_wZ$oVJKWhTV~>J)1OwpRv<o(?S(qGgW!^WMCUC#SykExVwH>#~#&T=R zn8!ZIK=R;uX4>iPXMW$JZ6n$*2>@Qi?|ApGE#|j8a6|?FQj(NzxArp5mX&T?Aw8kE zGZk@>d>7FZ!3%RJ-%jszNX|?na}_u+H&DJFrmuVu53yYzSP#EeK@jmM0X_ zQQ|#)hQb)&McB_F*dyFx=2QAu{0((7b_b|^`!%~z9m)QB3p_oJ?d^+ad4A9L+i&j` zacrH26dNmnEKSkf98+BbUD5mnBmB?8hIzN67S*0_!}Z`Y!Ynf8`_r%_r#(I`&c`X~ zqfrC@%PipBCjfZ~9QX^pBmwyqAR>s<9b`nFGJ6~IB!yAn!Twi8X2}|S4!}eaBu?IM z|G40y{m3&U$*(>fRqcN(n84&x~8+@+%S?bfY?!L&D0pi`5DuFYP zVx&e9)cj(zwJEMMGy8tW2h#P0&iltvaZ3}h1>T0h>y5h8FSBD~6YSBs)C}Ire2Ta? zHb-Nm#x)A~fx6?pP+RX?>8WDIZt^R`vH-+zuo3vg8TaIC#N~(p5l1e_ykt+_=lySu zd;6?Rbb6CdNR_*&W9+V72lyQL>C3B0^z&CZIPbki4Y#!24l^%i?iA zE&P17D~CQs$>-K(Bac#+P%Bn?TuZ|kBTReW(2dQw6Y-cs^9SlXrbpPJ|Buh?|K@D7 zf4YA8wZ?p~Wk-ZMH&M5Z@NQI9EoUxwZTSv3+ndu^ugEY}=T(8A`A0qfb@(4T9CSQx zp|>)|dA@#NMdZWbP;4-b&JS|~P~^;`FTCxzM|ciCGNMfvgSq;4F=h6}pK%464j`5A zg~Cj(Li`$7)_1q`c&3on0x0Fmn{k5zU=#YBiQ>0F^@&Y(3I_^&K&>5cldBs4R|y&P zwhs^)alrC8O&@wP7kGWys{mN(c}2JN!SaCknS}m$1mqM|i|h-saM>cWk7Ip9%h2Tt zlzM!iEI`A&SlrUBbJ~olhFBAaEj@1 zCSmB+0VtI(EEh9w=B1|W@i5_H?}N^(qQ7a6Es47Kq~o$CR>pq9@cFbs+6utwr&~q{ z>V5-^Rz(0w66&Y)4_|sh!No&G#o+4}-AcV+uaFvwTlCMjNNZeaEv!99&_{2|WnR2skYz>VXt3Mn9yc z(nQuS3+1pAA!3XHU# zyG7J~Huki&$)*Pc&x-cr0I!9`G<_9}hrVBVp*;5f@;l^(af?Lo9T?YPHdmjNw}bO$ zpqG-YSSCTEZv;Eo(M#i_hSCIA=Wl&=tN0S;|7{$7^b=!_2ejX(h_cTH;J0(em08aS zzjjmqo%Z0UxHfVr-mDK7-}kM>){h@VZs6${kff5MV-zAzUU_Hu<1x?4R4uNL>j0+- NsAT^CeS!W={9hL5qE-L^ literal 0 HcmV?d00001 diff --git a/src/main/resources/mapper/app/AddressDao.xml b/src/main/resources/mapper/app/AddressDao.xml new file mode 100644 index 0000000..8e7bf6f --- /dev/null +++ b/src/main/resources/mapper/app/AddressDao.xml @@ -0,0 +1,12 @@ + + + + + + + + update address set is_default=0 where user_id=#{userId} + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/app/AppDao.xml b/src/main/resources/mapper/app/AppDao.xml new file mode 100644 index 0000000..62704ed --- /dev/null +++ b/src/main/resources/mapper/app/AppDao.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/app/MsgDao.xml b/src/main/resources/mapper/app/MsgDao.xml new file mode 100644 index 0000000..cb6980b --- /dev/null +++ b/src/main/resources/mapper/app/MsgDao.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/app/UserBrowseDao.xml b/src/main/resources/mapper/app/UserBrowseDao.xml new file mode 100644 index 0000000..6349410 --- /dev/null +++ b/src/main/resources/mapper/app/UserBrowseDao.xml @@ -0,0 +1,47 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/app/UserCertificationDao.xml b/src/main/resources/mapper/app/UserCertificationDao.xml new file mode 100644 index 0000000..37d2d95 --- /dev/null +++ b/src/main/resources/mapper/app/UserCertificationDao.xml @@ -0,0 +1,35 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/app/UserDao.xml b/src/main/resources/mapper/app/UserDao.xml new file mode 100644 index 0000000..c95dbd7 --- /dev/null +++ b/src/main/resources/mapper/app/UserDao.xml @@ -0,0 +1,403 @@ + + + + + + + + + + + + + + + + + + + + INSERT INTO tb_user + + + user_name, + + + phone, + + + avatar, + + + sex, + + + age, + + + open_id, + + + artificer_open_id, + + + wx_open_id, + + + password, + + + create_time, + + + update_time, + + + apple_id, + + + sys_phone, + + + status, + + + platform, + + + jifen, + + + invitation_code, + + + inviter_code, + + + clientid, + + + zhi_fu_bao_name, + + + zhi_fu_bao + + + + + #{userName}, + + + #{phone}, + + + #{avatar}, + + + #{sex}, + + + #{age}, + + + #{openId}, + + + #{artificerOpenId}, + + + #{wxOpenId}, + + + #{password}, + + + #{createTime}, + + + #{updateTime}, + + + #{appleId}, + + + #{sysPhone}, + + + #{status}, + + + #{platform}, + + + #{jifen}, + + + #{invitationCode}, + + + #{inviterCode}, + + + #{clientid}, + + + #{zhiFuBaoName}, + + + #{zhiFuBao} + + + + + + + update tb_user + set clientid='' + where clientid = #{clientid} + + + + update tb_user set consortia_id=null where user_id=#{userId} + + + + update tb_user + set consortia_id=null + where consortia_id = #{consortiaId} + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/app/UserFollowDao.xml b/src/main/resources/mapper/app/UserFollowDao.xml new file mode 100644 index 0000000..c472ccc --- /dev/null +++ b/src/main/resources/mapper/app/UserFollowDao.xml @@ -0,0 +1,54 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/app/UserMoneyArtificerDao.xml b/src/main/resources/mapper/app/UserMoneyArtificerDao.xml new file mode 100644 index 0000000..8c96dba --- /dev/null +++ b/src/main/resources/mapper/app/UserMoneyArtificerDao.xml @@ -0,0 +1,19 @@ + + + + + + + update user_money_artificer set + + money=money+#{money} + + + money=money-#{money} + + where user_id=#{userId} and artificer_id=#{artificerId} + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/app/UserMoneyDao.xml b/src/main/resources/mapper/app/UserMoneyDao.xml new file mode 100644 index 0000000..fc6d62d --- /dev/null +++ b/src/main/resources/mapper/app/UserMoneyDao.xml @@ -0,0 +1,30 @@ + + + + + + + update user_money set + + money=money+#{money} + + + money=money-#{money} + + where user_id=#{userId} + + + + update user_money set + + cash_deposit=cash_deposit+#{cashDeposit} + + + cash_deposit=cash_deposit-#{cashDeposit} + + where user_id=#{userId} + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/app/UserMoneyDetailsDao.xml b/src/main/resources/mapper/app/UserMoneyDetailsDao.xml new file mode 100644 index 0000000..2ab62b0 --- /dev/null +++ b/src/main/resources/mapper/app/UserMoneyDetailsDao.xml @@ -0,0 +1,22 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/app/UserVisitorDao.xml b/src/main/resources/mapper/app/UserVisitorDao.xml new file mode 100644 index 0000000..80cfe8a --- /dev/null +++ b/src/main/resources/mapper/app/UserVisitorDao.xml @@ -0,0 +1,32 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/artificer/ArtificerDao.xml b/src/main/resources/mapper/artificer/ArtificerDao.xml new file mode 100644 index 0000000..03e8b10 --- /dev/null +++ b/src/main/resources/mapper/artificer/ArtificerDao.xml @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/artificer/ArtificerMassageMapper.xml b/src/main/resources/mapper/artificer/ArtificerMassageMapper.xml new file mode 100644 index 0000000..cabd01a --- /dev/null +++ b/src/main/resources/mapper/artificer/ArtificerMassageMapper.xml @@ -0,0 +1,35 @@ + + + + + + + + + update artificer_massage set status=1 where massage_type_id=#{massageTypeId} + + + \ No newline at end of file diff --git a/src/main/resources/mapper/artificer/CollectArtificerDao.xml b/src/main/resources/mapper/artificer/CollectArtificerDao.xml new file mode 100644 index 0000000..f20ab98 --- /dev/null +++ b/src/main/resources/mapper/artificer/CollectArtificerDao.xml @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/artificer/MassageTypeDao.xml b/src/main/resources/mapper/artificer/MassageTypeDao.xml new file mode 100644 index 0000000..a30fbd5 --- /dev/null +++ b/src/main/resources/mapper/artificer/MassageTypeDao.xml @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/artificer/OrdersDao.xml b/src/main/resources/mapper/artificer/OrdersDao.xml new file mode 100644 index 0000000..1b3ffba --- /dev/null +++ b/src/main/resources/mapper/artificer/OrdersDao.xml @@ -0,0 +1,986 @@ + + + + + + + INSERT INTO orders + + + artificer_id, + + + user_id, + + + serve_time, + + + phone, + + + address, + + + remark, + + + pay_money, + + + orders_no, + + + pay_time, + + + pay_way, + + + status, + + + create_time, + + + artificer_money, + + + longitude, + + + latitude, + + + sum_money, + + + add_num, + + + add_time, + + + taxi_money, + + + parent_id, + + + start_time, + + + coupon_id, + + + coupon_name, + + + coupon_money, + + + add_artificer_money, + + + add_money, + + + price, + + + sum_artificer_money, + + + is_send, + + + end_time, + + + user_name, + + + one_user_money, + + + one_user_id, + + + one_user_name, + + + one_artificer_money, + + + one_artificer_user_id, + + + one_artificer_user_name, + + + ping_money, + + + massage_type_id, + + + over_time_orders, + + + end_times, + + + trip_way, + + + km + + + + + #{artificerId}, + + + #{userId}, + + + #{serveTime}, + + + #{phone}, + + + #{address}, + + + #{remark}, + + + #{payMoney}, + + + #{ordersNo}, + + + #{payTime}, + + + #{payWay}, + + + #{status}, + + + #{createTime}, + + + #{artificerMoney}, + + + #{longitude}, + + + #{latitude}, + + + #{sumMoney}, + + + #{addNum}, + + + #{addTime}, + + + #{taxiMoney}, + + + #{parentId}, + + + #{startTime}, + + + #{couponId}, + + + #{couponName}, + + + #{couponMoney}, + + + #{addArtificerMoney}, + + + #{addMoney}, + + + #{price}, + + + #{sumArtificerMoney}, + + + #{isSend}, + + + #{endTime}, + + + #{userName}, + + + #{oneUserMoney}, + + + #{oneUserId}, + + + #{oneUserName}, + + + #{oneArtificerMoney}, + + + #{oneArtificerUserId}, + + + #{oneArtificerUserName}, + + + #{pingMoney}, + + + #{massageTypeId}, + + + #{overTimeOrders}, + + + #{endTimes}, + + + #{tripWay}, + + + #{km} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + update orders set warning=1 where now()>= DATE_ADD( end_time, INTERVAL #{time} MINUTE ) and status=6 and warning is null + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/artificer/RealNameMapper.xml b/src/main/resources/mapper/artificer/RealNameMapper.xml new file mode 100644 index 0000000..58f779f --- /dev/null +++ b/src/main/resources/mapper/artificer/RealNameMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/artificer/UserRechargeDao.xml b/src/main/resources/mapper/artificer/UserRechargeDao.xml new file mode 100644 index 0000000..41bec99 --- /dev/null +++ b/src/main/resources/mapper/artificer/UserRechargeDao.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/banner/ActivityDao.xml b/src/main/resources/mapper/banner/ActivityDao.xml new file mode 100644 index 0000000..1426bb4 --- /dev/null +++ b/src/main/resources/mapper/banner/ActivityDao.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/banner/BannerDao.xml b/src/main/resources/mapper/banner/BannerDao.xml new file mode 100644 index 0000000..baebc4b --- /dev/null +++ b/src/main/resources/mapper/banner/BannerDao.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/chat/ChatContentDao.xml b/src/main/resources/mapper/chat/ChatContentDao.xml new file mode 100644 index 0000000..98c94f2 --- /dev/null +++ b/src/main/resources/mapper/chat/ChatContentDao.xml @@ -0,0 +1,29 @@ + + + + + + + + + update chat_content set status=1 where user_id!=#{userId} and chat_conversation_id=#{chatConversationId} + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/chat/ChatConversationDao.xml b/src/main/resources/mapper/chat/ChatConversationDao.xml new file mode 100644 index 0000000..5420e7c --- /dev/null +++ b/src/main/resources/mapper/chat/ChatConversationDao.xml @@ -0,0 +1,73 @@ + + + + + + + + + INSERT INTO chat_conversation + + + user_id, + + + focused_user_id, + + + status, + + + create_time, + + + update_time, + + + remark + + + + + #{userId}, + + + #{focusedUserId}, + + + #{status}, + + + #{createTime}, + + + #{updateTime}, + + + #{remark} + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/common/CommonInfoDao.xml b/src/main/resources/mapper/common/CommonInfoDao.xml new file mode 100644 index 0000000..320abee --- /dev/null +++ b/src/main/resources/mapper/common/CommonInfoDao.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/consortia/ConsortiaMapper.xml b/src/main/resources/mapper/consortia/ConsortiaMapper.xml new file mode 100644 index 0000000..fe90b3c --- /dev/null +++ b/src/main/resources/mapper/consortia/ConsortiaMapper.xml @@ -0,0 +1,40 @@ + + + + + + + + update consortia set user_id=null,is_shop=null where consort_id=#{consortId} + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/coupon/CouponIssueMapper.xml b/src/main/resources/mapper/coupon/CouponIssueMapper.xml new file mode 100644 index 0000000..02cb387 --- /dev/null +++ b/src/main/resources/mapper/coupon/CouponIssueMapper.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/coupon/TbCouponMapper.xml b/src/main/resources/mapper/coupon/TbCouponMapper.xml new file mode 100644 index 0000000..bc32a49 --- /dev/null +++ b/src/main/resources/mapper/coupon/TbCouponMapper.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/coupon/TbCouponUserMapper.xml b/src/main/resources/mapper/coupon/TbCouponUserMapper.xml new file mode 100644 index 0000000..f8d85f6 --- /dev/null +++ b/src/main/resources/mapper/coupon/TbCouponUserMapper.xml @@ -0,0 +1,64 @@ + + + + + + + + + + update coupon_user set status = 2 where status=0 and date_format(expiration_time,'%Y-%m-%d') < date_format(#{date},'%Y-%m-%d') + + + + + + + + insert into coupon_user (user_id, coupon_name, coupon_picture, create_time, expiration_time, min_money, money, status, end_time) values + + (#{item}, #{couponName}, #{couponPicture}, #{createTime}, #{expirationTime}, #{minMoney}, #{money}, #{status}, #{endTime}) + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/invite/InviteDao.xml b/src/main/resources/mapper/invite/InviteDao.xml new file mode 100644 index 0000000..e1fdede --- /dev/null +++ b/src/main/resources/mapper/invite/InviteDao.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/invite/InviteMoneyDao.xml b/src/main/resources/mapper/invite/InviteMoneyDao.xml new file mode 100644 index 0000000..f0ad518 --- /dev/null +++ b/src/main/resources/mapper/invite/InviteMoneyDao.xml @@ -0,0 +1,26 @@ + + + + + + + + + update invite_money set money=money+#{money},money_sum=money_sum+#{money} where user_id=#{userId} + + + + update invite_money set + + cash_out=cash_out-#{money},money=money+#{money} + + + cash_out=cash_out+#{money},money=money-#{money} + + where user_id=#{userId} + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/job/ScheduleJobDao.xml b/src/main/resources/mapper/job/ScheduleJobDao.xml new file mode 100644 index 0000000..7def400 --- /dev/null +++ b/src/main/resources/mapper/job/ScheduleJobDao.xml @@ -0,0 +1,14 @@ + + + + + + + + update schedule_job set status = #{status} where job_id in + + #{jobId} + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/job/ScheduleJobLogDao.xml b/src/main/resources/mapper/job/ScheduleJobLogDao.xml new file mode 100644 index 0000000..8081592 --- /dev/null +++ b/src/main/resources/mapper/job/ScheduleJobLogDao.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/material/MaterialArtificerMapper.xml b/src/main/resources/mapper/material/MaterialArtificerMapper.xml new file mode 100644 index 0000000..67128e2 --- /dev/null +++ b/src/main/resources/mapper/material/MaterialArtificerMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + id,artificer_id,material_id, + residue,create_user,create_time, + update_user,update_time + + diff --git a/src/main/resources/mapper/material/MaterialMapper.xml b/src/main/resources/mapper/material/MaterialMapper.xml new file mode 100644 index 0000000..646ccc9 --- /dev/null +++ b/src/main/resources/mapper/material/MaterialMapper.xml @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + t.id,t.detail, t.material_name , t.material_minimum , t.status , t.create_user , t.create_time , t.update_user , t.update_time + + + + + + + INSERT INTO material + material_name,t.detail, material_minimum, status, create_user, + create_time, update_user, update_time, + + #{materialName}, #{detail}, #{materialMinimum}, #{status}, + #{createUser}, #{createTime}, #{updateUser}, #{updateTime}, + + + + +INSERT INTO material + + material_name, + material_minimum, + goods_id, + status, + detail, + create_user, + create_time, + update_user, + update_time, + + + #{materialName}, + #{materialMinimum}, + #{goodsId}, + #{status}, + #{detail}, + #{createUser}, + #{createTime}, + #{updateUser}, + #{updateTime}, + + + + UPDATE material + material_name=#{materialName},detail=#{detail}, material_minimum=#{materialMinimum}, status=#{status}, + create_user=#{createUser}, create_time=#{createTime}, update_user=#{updateUser}, update_time=#{updateTime}, + + WHERE id = #{id} + + + UPDATE material + + material_name=#{materialName}, + detail=#{detail}, + goods_id=#{goodsId}, + material_minimum=#{materialMinimum}, + status=#{status}, + create_user=#{createUser}, + create_time=#{createTime}, + update_user=#{updateUser}, + update_time=#{updateTime}, + + WHERE id = #{id} + + + + UPDATE material + SET is_deleted=1 + WHERE id = #{id} + + + + + + diff --git a/src/main/resources/mapper/material/MaterialMassageMapper.xml b/src/main/resources/mapper/material/MaterialMassageMapper.xml new file mode 100644 index 0000000..5037a07 --- /dev/null +++ b/src/main/resources/mapper/material/MaterialMassageMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + id,material_id,massage_type_id, + consume,create_user,create_time, + update_user,update_time + + diff --git a/src/main/resources/mapper/material/MaterialRecordMapper.xml b/src/main/resources/mapper/material/MaterialRecordMapper.xml new file mode 100644 index 0000000..6830fbb --- /dev/null +++ b/src/main/resources/mapper/material/MaterialRecordMapper.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + id,number,material_id, + create_user,create_time,update_user, + update_time + + + diff --git a/src/main/resources/mapper/message/ActivityMessageInfoDao.xml b/src/main/resources/mapper/message/ActivityMessageInfoDao.xml new file mode 100644 index 0000000..9ef48de --- /dev/null +++ b/src/main/resources/mapper/message/ActivityMessageInfoDao.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + update activity_message_info s set s.state=#{state} where s.id=#{id} + + + + update activity_message_info s set s.send_state=#{state} where s.id=#{id} + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/message/MessageInfoAudioDao.xml b/src/main/resources/mapper/message/MessageInfoAudioDao.xml new file mode 100644 index 0000000..8f831c4 --- /dev/null +++ b/src/main/resources/mapper/message/MessageInfoAudioDao.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/message/MessageInfoDao.xml b/src/main/resources/mapper/message/MessageInfoDao.xml new file mode 100644 index 0000000..8fe4dd0 --- /dev/null +++ b/src/main/resources/mapper/message/MessageInfoDao.xml @@ -0,0 +1,79 @@ + + + + + + + update message_info s set s.is_see=2 where s.user_id=#{userId} and s.state=#{state} + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/oss/SysOssDao.xml b/src/main/resources/mapper/oss/SysOssDao.xml new file mode 100644 index 0000000..8b2feb3 --- /dev/null +++ b/src/main/resources/mapper/oss/SysOssDao.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/pay/CashDao.xml b/src/main/resources/mapper/pay/CashDao.xml new file mode 100644 index 0000000..b85927e --- /dev/null +++ b/src/main/resources/mapper/pay/CashDao.xml @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + update user_money set + + money=money+#{money} + + + money=money-#{money} + + where user_id=#{userId} + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/pay/PayClassifyDao.xml b/src/main/resources/mapper/pay/PayClassifyDao.xml new file mode 100644 index 0000000..8790a5f --- /dev/null +++ b/src/main/resources/mapper/pay/PayClassifyDao.xml @@ -0,0 +1,11 @@ + + + + + + + update pay_classify set coupon_id=null,give_num=null where pay_classify_id=#{payClassifyId} + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/pay/PayDetailsDao.xml b/src/main/resources/mapper/pay/PayDetailsDao.xml new file mode 100644 index 0000000..c7e033d --- /dev/null +++ b/src/main/resources/mapper/pay/PayDetailsDao.xml @@ -0,0 +1,179 @@ + + + + + + + + + + + + + update pay_details set `state`=#{state},pay_time=#{time},trade_no=#{tradeNo} where id=#{id} + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/risk/RiskDao.xml b/src/main/resources/mapper/risk/RiskDao.xml new file mode 100644 index 0000000..dea8a94 --- /dev/null +++ b/src/main/resources/mapper/risk/RiskDao.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/search/AppSearchDao.xml b/src/main/resources/mapper/search/AppSearchDao.xml new file mode 100644 index 0000000..db3855e --- /dev/null +++ b/src/main/resources/mapper/search/AppSearchDao.xml @@ -0,0 +1,14 @@ + + + + + + + + + delete from `search` where user_id=#{userId} + + \ No newline at end of file diff --git a/src/main/resources/mapper/sys/SysConfigDao.xml b/src/main/resources/mapper/sys/SysConfigDao.xml new file mode 100644 index 0000000..dabb7c4 --- /dev/null +++ b/src/main/resources/mapper/sys/SysConfigDao.xml @@ -0,0 +1,15 @@ + + + + + + + update sys_config set param_value = #{paramValue} where param_key = #{paramKey} + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/sys/SysDictDao.xml b/src/main/resources/mapper/sys/SysDictDao.xml new file mode 100644 index 0000000..09ba58a --- /dev/null +++ b/src/main/resources/mapper/sys/SysDictDao.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/main/resources/mapper/sys/SysLogDao.xml b/src/main/resources/mapper/sys/SysLogDao.xml new file mode 100644 index 0000000..048d81a --- /dev/null +++ b/src/main/resources/mapper/sys/SysLogDao.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/sys/SysMenuDao.xml b/src/main/resources/mapper/sys/SysMenuDao.xml new file mode 100644 index 0000000..003d107 --- /dev/null +++ b/src/main/resources/mapper/sys/SysMenuDao.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/sys/SysRoleDao.xml b/src/main/resources/mapper/sys/SysRoleDao.xml new file mode 100644 index 0000000..5b5f4dc --- /dev/null +++ b/src/main/resources/mapper/sys/SysRoleDao.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/sys/SysRoleMenuDao.xml b/src/main/resources/mapper/sys/SysRoleMenuDao.xml new file mode 100644 index 0000000..3cece0a --- /dev/null +++ b/src/main/resources/mapper/sys/SysRoleMenuDao.xml @@ -0,0 +1,17 @@ + + + + + + + + + delete from sys_role_menu where role_id in + + #{roleId} + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/sys/SysUserDao.xml b/src/main/resources/mapper/sys/SysUserDao.xml new file mode 100644 index 0000000..2999b6d --- /dev/null +++ b/src/main/resources/mapper/sys/SysUserDao.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/sys/SysUserRoleDao.xml b/src/main/resources/mapper/sys/SysUserRoleDao.xml new file mode 100644 index 0000000..0ab4280 --- /dev/null +++ b/src/main/resources/mapper/sys/SysUserRoleDao.xml @@ -0,0 +1,16 @@ + + + + + + + delete from sys_user_role where role_id in + + #{roleId} + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/sys/SysUserTokenDao.xml b/src/main/resources/mapper/sys/SysUserTokenDao.xml new file mode 100644 index 0000000..d7f9db4 --- /dev/null +++ b/src/main/resources/mapper/sys/SysUserTokenDao.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/taking/OrderTakingCommentDao.xml b/src/main/resources/mapper/taking/OrderTakingCommentDao.xml new file mode 100644 index 0000000..57fd79a --- /dev/null +++ b/src/main/resources/mapper/taking/OrderTakingCommentDao.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + DELETE + FROM comment_fabulous + WHERE id = #{id} + + + INSERT + comment_fabulous ( taking_comment_id, user_id ) + VALUES ( + #{commentId}, + #{userId} + ) + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/taking/OrderTakingDao.xml b/src/main/resources/mapper/taking/OrderTakingDao.xml new file mode 100644 index 0000000..51c6254 --- /dev/null +++ b/src/main/resources/mapper/taking/OrderTakingDao.xml @@ -0,0 +1,338 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/weixin/apiclient_cert.p12 b/src/main/resources/weixin/apiclient_cert.p12 new file mode 100644 index 0000000000000000000000000000000000000000..eaeb5db238272a7052a608c443c395d1e749814e GIT binary patch literal 4918 zcmZWsX-}Nj6`q0F7!VAGVKa+i0JAeN?8fX2FlIBD)eHv1fZ4Gzo6X?3S=v-eoJCFi z!BW&nZKKGlirl!arO1-w)-iGvJ5^)XiDRiBT2=iJslTAl!?}KmvGknhEcd?ed+)jD zo&o2Nw?4N*0`!4SWtxJrU^PP+(3|zjf-*1yc|MieXx{sP2~mKPIe|JruX}FpovnAq zo2)NCf%CWD zDwQ#C(G+M#b7AcB^Rwj=8WDB>x1xhOtXa!dr;Ge&;CmpEbuu9AhMI%4xe~ySUnK(z zhd}PwXt0`YlmRdoE%3RxrNyNsEwTp73(3y|B|`XBK@60SIX^VE34Z#?yqj+dhXBiv ztc`zsIQZa}1i*#gUlLp2y1U)P0mL>Weu}T-8U-_%(0Osm;OTS6KyjrY`u)5PHtNOcUY(~$Wn&}J9t>FYd<5(@|z zToGLp4BY~GvK8jDJ0vLVEDa5N@-wmbcTBI?xUflEs%QJkLKq)!%8@~4u#$-taJNO8 z_w65HGX3@2@BioKpJDK8z!$HAn3LY&r1DZ*`pAUD%kEwqg0&BFOd=ZBidA^5AI8w& z-eE@u!cDrIk=>LcV3&t@Jn?hA;8Y3Js}iW?5eLOEPuxQqB!bnq4gpevL&3MNMu>Z= zU#D-3haEJ|q}zL|j`&B%XqKF6KQD8@4yLAE)n>p!I5zb@Z3@$*A)Ds~sDrFvVGOk# z1xGUxItWj%?g&T^(a^8=!(N1NNJ9wE{?XQ;H7zN)x{!NogBZ)I563}wLjd)njwaX^ z##+C5C$iiNV-y19S(!-|1#`uugs62^(kX!evk+bKSHGxVfHA|$u7_lt0`W*oxdGM# zFUL8x>o~3$@KlQ~tZM6oH4xh+ey0UGS!`jR4OO^KvvF@q$@b%N~jTl(}!_)%f6A6_nkd1YR)xl`p6- z2T{1U@g1-k)sP}qOU&bo z4Ps80JpA;3H?Q1iyZa#m;~qU5YG5-{WSNpFoh*Uw%ue6w5^is_gA9CkZA^^)6JK1- zZG?UQQ"jD~ZEKv>B})*^H+M4f0txH=|;)XQ?x%y5A0LD4Mu;d!y$6^6**%tSS{ z$E@}l+%ChW;|Z#bi639j1fE&_*GHHANj)&TN!*s@`_I4{HWoc5+ktfPS?n5k+E(sO z<++&`3}7Zx3RES9!11h^JqMw^>+SJz(16<80L;fXd+|yEMz;)l3*cA-t{p z4YSqqi`Kd1R;V&aLnM<|I6Phw2Hlji3f7RupF6-RibXiVW@A_P8zwJ}S~sjaTYrDI z!N_+6gj)@b+^HaHZPl(hCRlv)ek~GdqdV2htIR5oVqF8h-@PJ+Zq>S(3bW(!CGfHn zWL$aa&l#C(oaEESv7JdLcKEm{nCoU10INR4s^?h(oXROX`sKfd0{PbvTNJ>>MRhy* z_Yh|rzWhDdUCtNBLIkBNd|RD3cR%^^;);b^otD6qqvkj))+Ccza~8Co(Mh)_ItB`` zLcEad3%t?){`Gs{)u&rvz{QHRmF0CU=cU5p+$A^wHI0E#Gvf7&Dl%umh-r35Kvh8US*AR2;BRk>2J;qZu!xneYNFi_Ka4FE`1&en z?%{PXYa3u^8gPjH;5FMcEbrj@vrBAG&#pgy3yMkLx#g()#FPOJE(kCWGB5-QmB8i* z^fuGgIaB~X3E^IW*quKl**{dz;W)r+v#u_G8i#Ze7dF`0_-13rMskL~y`j1oA_GRl zvdkzR;s$HQVO$4;pxQ1vD22ayK4zC04=+=e6TfDtG>1OPDT%%@PG#M0H27 zg4hMuG9qIhZM8{Q<1_mVd`Q5T^OzoebQpXn&C0d`IMo>&P28{Dosu`+XqX%I~V2%Ycv8f4oRS9LDoU~&JWRNhA2!|Wxn6k zH8$OQ{z6-3==KMQsH{F?B?7yjfs<6W$%ZuxVKVN&2hxz8n^DVq3aH|V{6Fl zTq=`S#kEzjQ3D1D*PAJ>a3WOwgUk8inRpO8|9=!q06ggzGorP5g}c*moYfJ3`=%C{ zgr$dYS(8gu%pt4kpcN#z_j$GT$r~AmH==@~5Q&(`)`qr!r7CZQpXT8*cRXO=IBS$X zx018FfdHN?kO0{6d~3ZoRql4~TfI z5MBUIo6Q$TzUj;TNGv&SW#$>5SmBu&%s=SJPu=Sas zlaPK$a3yEeoC`nA%>#|IGsRGe>Ir6GwX?>~{xbW+XJA3yv43kIEzJ%20(*$bi!EMtHjPeZOj zGhwVj4zU{oPS@UdL>8ncrs|IAe7bqvqHa{Tt~;Qshj&JIRyU=afQ%t}R_Al(I+LA2 nCS!JJU_hKv_x!{1-Z4Gf|8$~S#tS{!9A&T!m{^*N>IeG&P|X`2 literal 0 HcmV?d00001 diff --git a/tbdm.bat b/tbdm.bat new file mode 100644 index 0000000..877739f --- /dev/null +++ b/tbdm.bat @@ -0,0 +1,3 @@ +@echo off +TortoiseGitProc /command:sync /path:"./" /seq:0 /hwnd:0000000000390AF0 x64 TortoiseGitProc.exe +exit \ No newline at end of file