From 18b52a121492ed5e413056a0dc1de09c02519ec2 Mon Sep 17 00:00:00 2001 From: yeungchihang <842328916@qq.com> Date: Tue, 17 Jan 2023 14:37:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96-=E6=B8=85?= =?UTF-8?q?=E7=90=86=E8=87=83=E8=82=BF=E7=9A=84=E5=89=8D=E6=9C=9D=E9=81=97?= =?UTF-8?q?=E7=89=A9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auditaudio/AuditAudioAdminService.java | 379 ------------ .../record/OfficialGoldRecordService.java | 5 +- .../service/system/AdminUserService.java | 10 +- .../transfer/AlipayTransferService.java | 99 --- .../service/transfer/ITransferService.java | 45 -- .../transfer/JoinpayTransferService.java | 196 ------ .../service/transfer/TransferFactory.java | 52 -- .../service/user/AccountAdminService.java | 3 +- .../withdraw/PacketWithdrawAdminService.java | 244 -------- .../api/JoinpayTransferController.java | 45 -- .../auditaudio/AuditAudioAdminController.java | 171 ------ .../controller/system/LoginController.java | 16 +- .../user/UserPasswordModifyController.java | 2 +- .../PacketWithdrawAdminController.java | 242 -------- .../controller/system/LoginController.java | 4 +- .../common/config/AuditMediaConfig.java | 49 -- .../common/constant/BillTypeConstant.java | 102 ---- .../accompany/common/constant/Constant.java | 10 - .../common/constant/FirstPageConstant.java | 8 - .../accompany/common/constant/MQConstant.java | 19 - .../accompany/common/constant/SexType.java | 25 - .../common/constant/WeXinPayTypeEnum.java | 19 - .../com/accompany/common/wx/HttpUtils.java | 334 ---------- .../accompany/common/wx/IServiceRequest.java | 11 - .../java/com/accompany/common/wx/MD5.java | 76 --- .../java/com/accompany/common/wx/PayUtil.java | 87 --- .../java/com/accompany/common/wx/Util.java | 122 ---- .../com/accompany/common/wx/XMLParser.java | 104 ---- .../common/wx/result/WxAccessTokenRet.java | 42 -- .../common/wx/result/WxTicketRet.java | 43 -- .../accompany/core/model/UserTeenConf.java | 11 - .../core/service/user/UsersBaseService.java | 20 - .../java/com/accompany/core/util/MD5.java | 4 +- .../AlipayNativeAgentChangeStrategy.java | 206 ------- .../IAgentChangeStrategy.java | 22 - .../payment/alipay/AbstractAlipayService.java | 120 ---- .../payment/alipay/AliPayClientParam.java | 93 --- .../payment/alipay/AlipayNotifyParam.java | 265 -------- .../payment/alipay/AlipayService.java | 23 - .../payment/alipay/TransferService.java | 58 -- .../payment/alipay/YinyouAlipayService.java | 23 - .../payment/config/AliPayConfig.java | 20 - .../payment/config/BaseAliPayConfig.java | 24 - .../payment/config/BaseWxPayConfig.java | 23 - .../accompany/payment/config/HuiKaConfig.java | 59 -- .../payment/config/JoinPayConfig.java | 45 -- .../payment/config/MultiAliPayConfig.java | 27 - .../payment/config/PingxxConfig.java | 49 -- .../payment/config/SandPayConfig.java | 116 ---- .../accompany/payment/config/WxConfig.java | 107 ---- .../payment/config/WxMicroMallConfig.java | 106 ---- .../payment/config/WxMiniAppConfig.java | 53 -- .../accompany/payment/config/WxPayConfig.java | 20 - .../payment/config/WxPub2Config.java | 107 ---- .../payment/config/WxPub2WapConfig.java | 20 - .../payment/config/YinyouAliPayConfig.java | 20 - .../payment/config/YinyouWxPayConfig.java | 13 - .../dto/AgentChangeStrategyConfigDTO.java | 29 - .../accompany/payment/dto/AlipayAgentDTO.java | 13 - .../payment/dto/PayAgentConfDTO.java | 17 - .../payment/fufeitong/FufeitongConfig.java | 29 - .../payment/fufeitong/FufeitongConstant.java | 16 - .../fufeitong/FufeitongPayService.java | 191 ------ .../fufeitong/bo/FufeitongBaseRes.java | 25 - .../fufeitong/bo/FufeitongWxOpenOrderRes.java | 14 - .../FufeitongCreateOrderBaseReqParams.java | 37 -- .../params/FufeitongWxOrderReqParams.java | 9 - .../guotongpay/BaseGuotongPayConfig.java | 25 - .../guotongpay/GuotongForZjlxPayConfig.java | 15 - .../payment/guotongpay/GuotongPayConfig.java | 15 - .../guotongpay/GuotongPayConstant.java | 20 - .../payment/guotongpay/GuotongPayService.java | 256 -------- .../guotongpay/bo/GuotongPayResultBO.java | 47 -- .../bo/GuotongWxMiniPayResultBO.java | 46 -- .../params/GuoTongCreateOrderReqParams.java | 13 - .../params/GuotongBaseReqParams.java | 23 - .../params/GuotongWxMiniPayReqParams.java | 12 - .../accompany/payment/heepay/BaseConfig.java | 20 - .../payment/heepay/HeePayConstant.java | 18 - .../payment/heepay/HeePayH5Config.java | 19 - .../payment/heepay/HeePayService.java | 327 ---------- .../payment/heepay/HeePayWxConfig.java | 34 -- .../payment/heepay/bo/ResponseBO.java | 37 -- .../payment/heepay/bo/WxH5PayResBO.java | 25 - .../payment/heepay/bo/WxMiniproPayResBO.java | 23 - .../payment/heepay/bo/WxPubPayResBO.java | 25 - .../payment/heepay/params/NotifyParams.java | 49 -- .../heepay/params/PayRequestParams.java | 63 -- .../heepay/params/WxH5PayReqParams.java | 16 - .../payment/heepay/sdk/Common/DataHelper.java | 160 ----- .../heepay/sdk/Common/GatewayHelper.java | 98 --- .../payment/heepay/sdk/Common/Md5Tools.java | 33 - .../heepay/sdk/HeepayModel/GatewayModel.java | 140 ----- .../heepay/sdk/HeepayReturn/SubmitReturn.java | 32 - .../com/accompany/payment/huiju/Constant.java | 15 - .../accompany/payment/huiju/HuiJuConfig.java | 33 - .../huiju/HuiJuPublicPayResponseVO.java | 33 - .../accompany/payment/huiju/HuiJuService.java | 232 ------- .../huiju/HuiJuWeChatMiniPayInfoVO.java | 33 - .../payment/huiju/NotifyResponse.java | 62 -- .../accompany/payment/huiju/RequestVO.java | 70 --- .../accompany/payment/huiju/ResponseVO.java | 71 --- .../payment/huiju/TransactionTypeEnum.java | 23 - .../payment/iospay/IOSPayPlaService.java | 98 +-- .../payment/joinpay/HttpRequester.java | 192 ------ .../payment/joinpay/HttpResponse.java | 181 ------ .../payment/joinpay/JoinpayService.java | 278 --------- .../payment/params/AgentChangeDimensions.java | 11 - .../payment/sandpay/SandPayCommParams.java | 65 -- .../sandpay/SandPayMiniAppReqBaseParams.java | 76 --- .../sandpay/SandPayMiniAppReqParams.java | 35 -- .../payment/sandpay/SandPayRequestParam.java | 38 -- .../payment/sandpay/SandPayService.java | 369 ----------- .../sandpay/bo/SandPayWxMiniPayResultBO.java | 45 -- .../payment/sandpay/utils/CertUtil.java | 182 ------ .../payment/sandpay/utils/CryptoUtil.java | 423 ------------- .../payment/sandpay/utils/HttpClient.java | 325 ---------- .../payment/sandpay/utils/SDKUtil.java | 132 ---- .../payment/service/ChargeCheckService.java | 143 ----- .../payment/service/ChargeNotifyService.java | 214 ------- .../payment/service/PayCenterService.java | 172 ------ .../payment/strategy/AlipayStrategy.java | 139 ----- .../payment/strategy/AlipayV2Strategy.java | 170 ------ .../payment/strategy/AlipayWapStrategy.java | 144 ----- .../strategy/LuckyTarotPayStrategy.java | 88 --- .../payment/strategy/WxJoinpayStrategy.java | 43 -- .../strategy/WxMicroMallPubPayStrategy.java | 141 ----- .../strategy/WxMiniAppPayStrategy.java | 135 ---- .../payment/strategy/WxNativeStrategy.java | 87 --- .../payment/strategy/WxPayStrategy.java | 50 -- .../payment/strategy/WxPub2PayStrategy.java | 141 ----- .../strategy/WxPub2WapPayStrategy.java | 54 -- .../strategy/WxPubJoinpayStrategy.java | 130 ---- .../payment/strategy/WxPubNativeStrategy.java | 139 ----- .../payment/strategy/WxPubPayStrategy.java | 134 ---- .../payment/strategy/WxWapPayStrategy.java | 109 ---- .../strategy/decorator/JointPayDecorator.java | 38 -- .../payment/utils/MultiAliPayUtil.java | 50 -- .../accompany/payment/utils/SandpayUtils.java | 107 ---- .../accompany/payment/vo/AlipayResult.java | 17 - .../com/accompany/payment/vo/HttpForm.java | 30 - .../com/accompany/payment/vo/HttpHeader.java | 36 -- .../accompany/payment/vo/JsapiReturnVo.java | 138 ----- .../payment/vo/WeChatMiniAppPayRequestVO.java | 44 -- .../vo/WeChatMiniAppPayResponseVO.java | 59 -- .../accompany/payment/vo/WeXinPayTypeVO.java | 30 - .../payment/wanxiang/WanXiangPayConfig.java | 29 - .../payment/wanxiang/WanXiangPayService.java | 170 ------ .../payment/wanxiang/bo/WanXiangBaseRes.java | 20 - .../WanXiangCreateOrderBaseReqParams.java | 34 -- ...WanXiangWxMiniproCreateOrderReqParams.java | 20 - .../payment/wanxiang/utils/RSAUtils.java | 69 --- .../wanxiang/utils/WanxiangPayConsts.java | 17 - .../accompany/payment/wxpay/HttpUtils.java | 320 ---------- .../java/com/accompany/payment/wxpay/MD5.java | 80 --- .../com/accompany/payment/wxpay/PayUtil.java | 138 ----- .../com/accompany/payment/wxpay/Util.java | 125 ---- .../payment/wxpay/WeChatNotifyParam.java | 274 --------- .../payment/wxpay/WeChatPayService.java | 199 ------ .../payment/wxpay/WeChatPayUtil.java | 82 --- .../payment/wxpay/WeChatQueryResultParam.java | 95 --- .../payment/wxpay/WeChatResultParam.java | 139 ----- .../accompany/payment/wxpay/XMLParser.java | 104 ---- .../listener/CloseAuditAudioRoomListener.java | 46 -- .../listener/SendAuditAudioRoomListener.java | 53 -- .../listener/UserRegisterSuccessListener.java | 34 -- .../business/service/AppPictureService.java | 311 ---------- .../business/service/AutoGenRobotService.java | 2 +- .../business/service/ChargeService.java | 66 -- .../business/service/WXOrderQueryService.java | 62 -- .../business/service/api/WxpayService.java | 105 ---- .../auditaudio/AuditAudioRoomService.java | 202 ------ .../service/auditaudio/AuditAudioService.java | 105 ---- .../charge/LuckyTarotChargeService.java | 54 +- .../service/drawprize/UserDrawService.java | 10 +- .../service/hall/HallManageService.java | 4 +- .../KuaishouAdCalBackRecordService.java | 25 - .../service/kuaishou/KuaishouService.java | 304 ---------- .../KuaishouAdCalBackRecordServiceImpl.java | 32 - .../match/GameMatchJoinRecordService.java | 1 - .../miniGame/MiniGameCallbackService.java | 1 - .../service/mission/MissionService.java | 4 +- .../observe/BiliObserveRecordService.java | 100 --- .../service/observe/ObserveService.java | 165 ----- .../service/payment/WxCallbackService.java | 21 - .../business/service/wx/SignService.java | 73 --- .../service/wx/WXMircoMallPubService.java | 344 ----------- .../business/service/wx/WXPub2Service.java | 82 --- .../business/service/wx/WXPubService.java | 344 ----------- .../business/service/wx/WXResponse.java | 61 -- .../business/service/wx/WxMpOpenidResp.java | 33 - .../business/service/wx/WxMpService.java | 49 -- .../business/service/wx/WxService.java | 194 ------ .../business/testclient/HomeJobClient.java | 7 - .../business/testclient/RoomClient.java | 24 - .../accompany/business/util/ImageUtil.java | 87 --- .../java/com/accompany/business/util/MD5.java | 39 -- .../accompany/business/util/WeiXinUtil.java | 296 --------- .../business/wechat/AccessToken.java | 29 - .../business/wechat/MenuManager.java | 97 --- .../business/wechat/MyX509TrustManager.java | 30 - .../wechat/message/req/BaseMessage.java | 64 -- .../wechat/message/req/EventMessage.java | 61 -- .../wechat/message/req/ImageMessage.java | 22 - .../wechat/message/req/LinkMessage.java | 37 -- .../wechat/message/req/LocationMessage.java | 46 -- .../wechat/message/req/TextMessage.java | 24 - .../wechat/message/req/package-info.java | 9 - .../wechat/message/resp/ArticleModel.java | 48 -- .../wechat/message/resp/BaseMessage.java | 68 --- .../wechat/message/resp/ModelData.java | 27 - .../wechat/message/resp/ModelMsg.java | 33 - .../wechat/message/resp/MusicMessage.java | 25 - .../wechat/message/resp/MusicModle.java | 48 -- .../wechat/message/resp/NewsMessage.java | 36 -- .../wechat/message/resp/TextMessage.java | 24 - .../wechat/message/resp/package-info.java | 9 - .../business/wechat/pojo/Button.java | 22 - .../business/wechat/pojo/CommonButton.java | 61 -- .../business/wechat/pojo/ComplexButton.java | 23 - .../accompany/business/wechat/pojo/Menu.java | 23 - .../business/wechat/util/MessageUtil.java | 206 ------- .../business/wechat/util/SignUtil.java | 56 -- .../business/wechat/util/StringUtil.java | 65 -- .../business/common/BaseController.java | 113 ---- .../accompany/business/config/BeanConfig.java | 41 -- .../business/config/WebPropertyConfig.java | 65 -- .../controller/AppPictureController.java | 45 -- .../business/controller/ChargeController.java | 68 --- .../business/controller/JSAPIController.java | 574 ------------------ .../controller/ReciveWxController.java | 72 --- .../accompany/business/controller/Test.java | 43 -- .../UserRegisterSuccessNotifyController.java | 29 - .../business/controller/WXCoreController.java | 331 ---------- .../controller/WithdrawController.java | 0 .../SuperAdminWebController.java | 3 - .../apppay/BankCardSignController.java | 125 ---- .../apppay/ChargeNotifyController.java | 369 ----------- .../controller/apppay/FastpayController.java | 161 ----- .../apppay/FufeitongPayController.java | 93 --- .../GooglePlayBillingChargeController.java | 2 - .../apppay/GuotongPayController.java | 148 ----- .../controller/apppay/HeePayController.java | 138 ----- .../controller/apppay/JoinpayController.java | 115 ---- .../controller/apppay/SandPayController.java | 127 ---- .../apppay/WanXiangPayController.java | 102 ---- .../ReceiveAuditAudioController.java | 93 --- .../ExchangeDiamondGoldRecordController.java | 10 +- .../controller/game/DragonBallController.java | 69 --- .../game/doll/SingleDollController.java | 267 -------- .../controller/home/ClientController.java | 1 - .../kuaishou/KuaishouAdController.java | 88 --- .../controller/observe/ObserveController.java | 164 ----- .../controller/room/RoomController.java | 11 +- .../controller/sign/SignController.java | 10 +- .../statis/StatBasicUsersController.java | 48 -- .../controller/world/WorldController.java | 18 - .../CustomHttpServletRequestWrapper.java | 55 -- .../business/filter/CustomParamFilter.java | 32 - .../interceptor/SecurityInterceptor.java | 4 +- .../pingplusplus/BatchTransferExample.java | 302 --------- .../business/pingplusplus/ChargeExample.java | 567 ----------------- .../business/pingplusplus/CustomsExample.java | 109 ---- .../business/pingplusplus/EventExample.java | 64 -- .../pingplusplus/IdentificationExample.java | 107 ---- .../accompany/business/pingplusplus/Main.java | 120 ---- .../pingplusplus/RedEnvelopeExample.java | 153 ----- .../business/pingplusplus/RefundExample.java | 148 ----- .../pingplusplus/TransferExample.java | 309 ---------- .../pingplusplus/WebhooksVerifyExample.java | 128 ---- .../pingplusplus/WxPubOAuthExample.java | 83 --- .../ChargeNotifyControllerTest.java | 34 -- .../servicetest/FufeitongPayServiceTest.java | 50 -- .../servicetest/GuotongPayServiceTest.java | 84 --- .../java/servicetest/WXPub2ServiceTest.java | 22 - .../servicetest/WanXiangPayServiceTest.java | 47 -- .../interceptor/SecurityInterceptor.java | 4 +- .../scheduler/task/AuditAudioRoomTask.java | 183 ------ pom.xml | 50 -- .../rewardstategy/AbstractRewardStategy.java | 4 - .../EliminateNumRewardStategy.java | 1 - 281 files changed, 46 insertions(+), 24598 deletions(-) delete mode 100644 accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/auditaudio/AuditAudioAdminService.java delete mode 100644 accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/transfer/AlipayTransferService.java delete mode 100644 accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/transfer/ITransferService.java delete mode 100644 accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/transfer/JoinpayTransferService.java delete mode 100644 accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/transfer/TransferFactory.java delete mode 100644 accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/withdraw/PacketWithdrawAdminService.java delete mode 100644 accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/api/JoinpayTransferController.java delete mode 100644 accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/auditaudio/AuditAudioAdminController.java delete mode 100644 accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/withdraw/PacketWithdrawAdminController.java delete mode 100644 accompany-base/accompany-common/src/main/java/com/accompany/common/config/AuditMediaConfig.java delete mode 100644 accompany-base/accompany-common/src/main/java/com/accompany/common/constant/BillTypeConstant.java delete mode 100644 accompany-base/accompany-common/src/main/java/com/accompany/common/constant/FirstPageConstant.java delete mode 100644 accompany-base/accompany-common/src/main/java/com/accompany/common/constant/MQConstant.java delete mode 100644 accompany-base/accompany-common/src/main/java/com/accompany/common/constant/SexType.java delete mode 100644 accompany-base/accompany-common/src/main/java/com/accompany/common/constant/WeXinPayTypeEnum.java delete mode 100644 accompany-base/accompany-common/src/main/java/com/accompany/common/wx/HttpUtils.java delete mode 100644 accompany-base/accompany-common/src/main/java/com/accompany/common/wx/IServiceRequest.java delete mode 100644 accompany-base/accompany-common/src/main/java/com/accompany/common/wx/MD5.java delete mode 100644 accompany-base/accompany-common/src/main/java/com/accompany/common/wx/PayUtil.java delete mode 100644 accompany-base/accompany-common/src/main/java/com/accompany/common/wx/Util.java delete mode 100644 accompany-base/accompany-common/src/main/java/com/accompany/common/wx/XMLParser.java delete mode 100644 accompany-base/accompany-common/src/main/java/com/accompany/common/wx/result/WxAccessTokenRet.java delete mode 100644 accompany-base/accompany-common/src/main/java/com/accompany/common/wx/result/WxTicketRet.java delete mode 100644 accompany-base/accompany-core/src/main/java/com/accompany/core/model/UserTeenConf.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/agentchangestrategy/AlipayNativeAgentChangeStrategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/agentchangestrategy/IAgentChangeStrategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/AbstractAlipayService.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/AliPayClientParam.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/AlipayNotifyParam.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/AlipayService.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/TransferService.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/YinyouAlipayService.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/AliPayConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/BaseAliPayConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/BaseWxPayConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/HuiKaConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/JoinPayConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/MultiAliPayConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/PingxxConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/SandPayConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxMicroMallConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxMiniAppConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxPayConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxPub2Config.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxPub2WapConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/YinyouAliPayConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/YinyouWxPayConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/dto/AgentChangeStrategyConfigDTO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/dto/AlipayAgentDTO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/dto/PayAgentConfDTO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/FufeitongConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/FufeitongConstant.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/FufeitongPayService.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/bo/FufeitongBaseRes.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/bo/FufeitongWxOpenOrderRes.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/params/FufeitongCreateOrderBaseReqParams.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/params/FufeitongWxOrderReqParams.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/BaseGuotongPayConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/GuotongForZjlxPayConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/GuotongPayConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/GuotongPayConstant.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/GuotongPayService.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/bo/GuotongPayResultBO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/bo/GuotongWxMiniPayResultBO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/params/GuoTongCreateOrderReqParams.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/params/GuotongBaseReqParams.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/params/GuotongWxMiniPayReqParams.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/BaseConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/HeePayConstant.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/HeePayH5Config.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/HeePayService.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/HeePayWxConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/bo/ResponseBO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/bo/WxH5PayResBO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/bo/WxMiniproPayResBO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/bo/WxPubPayResBO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/params/NotifyParams.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/params/PayRequestParams.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/params/WxH5PayReqParams.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/sdk/Common/DataHelper.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/sdk/Common/GatewayHelper.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/sdk/Common/Md5Tools.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/sdk/HeepayModel/GatewayModel.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/sdk/HeepayReturn/SubmitReturn.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/Constant.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/HuiJuConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/HuiJuPublicPayResponseVO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/HuiJuService.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/HuiJuWeChatMiniPayInfoVO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/NotifyResponse.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/RequestVO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/ResponseVO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/TransactionTypeEnum.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/joinpay/HttpRequester.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/joinpay/HttpResponse.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/joinpay/JoinpayService.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/params/AgentChangeDimensions.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayCommParams.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayMiniAppReqBaseParams.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayMiniAppReqParams.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayRequestParam.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayService.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/bo/SandPayWxMiniPayResultBO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/utils/CertUtil.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/utils/CryptoUtil.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/utils/HttpClient.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/utils/SDKUtil.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/service/ChargeCheckService.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/service/ChargeNotifyService.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/AlipayStrategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/AlipayV2Strategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/AlipayWapStrategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/LuckyTarotPayStrategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxJoinpayStrategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxMicroMallPubPayStrategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxMiniAppPayStrategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxNativeStrategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPayStrategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPub2PayStrategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPub2WapPayStrategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPubJoinpayStrategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPubNativeStrategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPubPayStrategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxWapPayStrategy.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/decorator/JointPayDecorator.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/utils/MultiAliPayUtil.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/utils/SandpayUtils.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/AlipayResult.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/HttpForm.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/HttpHeader.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/JsapiReturnVo.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/WeChatMiniAppPayRequestVO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/WeChatMiniAppPayResponseVO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/WeXinPayTypeVO.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/WanXiangPayConfig.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/WanXiangPayService.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/bo/WanXiangBaseRes.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/params/WanXiangCreateOrderBaseReqParams.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/params/WanXiangWxMiniproCreateOrderReqParams.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/utils/RSAUtils.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/utils/WanxiangPayConsts.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/HttpUtils.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/MD5.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/PayUtil.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/Util.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatNotifyParam.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatPayService.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatPayUtil.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatQueryResultParam.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatResultParam.java delete mode 100644 accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/XMLParser.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/event/listener/CloseAuditAudioRoomListener.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/event/listener/SendAuditAudioRoomListener.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/event/listener/UserRegisterSuccessListener.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/AppPictureService.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/WXOrderQueryService.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/api/WxpayService.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/auditaudio/AuditAudioRoomService.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/auditaudio/AuditAudioService.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/kuaishou/KuaishouAdCalBackRecordService.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/kuaishou/KuaishouService.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/kuaishou/impl/KuaishouAdCalBackRecordServiceImpl.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/observe/BiliObserveRecordService.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/observe/ObserveService.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/payment/WxCallbackService.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/SignService.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WXMircoMallPubService.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WXPub2Service.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WXPubService.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WXResponse.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WxMpOpenidResp.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WxMpService.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WxService.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/testclient/HomeJobClient.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/testclient/RoomClient.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/util/ImageUtil.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/util/MD5.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/util/WeiXinUtil.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/AccessToken.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/MenuManager.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/MyX509TrustManager.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/BaseMessage.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/EventMessage.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/ImageMessage.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/LinkMessage.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/LocationMessage.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/TextMessage.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/package-info.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/ArticleModel.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/BaseMessage.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/ModelData.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/ModelMsg.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/MusicMessage.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/MusicModle.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/NewsMessage.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/TextMessage.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/package-info.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/pojo/Button.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/pojo/CommonButton.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/pojo/ComplexButton.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/pojo/Menu.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/util/MessageUtil.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/util/SignUtil.java delete mode 100644 accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/util/StringUtil.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/config/BeanConfig.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/config/WebPropertyConfig.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/AppPictureController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/JSAPIController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/ReciveWxController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/Test.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/UserRegisterSuccessNotifyController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/WXCoreController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/WithdrawController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/BankCardSignController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/ChargeNotifyController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/FastpayController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/FufeitongPayController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/GuotongPayController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/HeePayController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/JoinpayController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/SandPayController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/WanXiangPayController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/auditaudio/ReceiveAuditAudioController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/game/DragonBallController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/game/doll/SingleDollController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/kuaishou/KuaishouAdController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/observe/ObserveController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/statis/StatBasicUsersController.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/filter/CustomHttpServletRequestWrapper.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/filter/CustomParamFilter.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/BatchTransferExample.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/ChargeExample.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/CustomsExample.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/EventExample.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/IdentificationExample.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/Main.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/RedEnvelopeExample.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/RefundExample.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/TransferExample.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/WebhooksVerifyExample.java delete mode 100644 accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/WxPubOAuthExample.java delete mode 100644 accompany-business/accompany-business-web/src/test/java/controllertest/ChargeNotifyControllerTest.java delete mode 100644 accompany-business/accompany-business-web/src/test/java/servicetest/FufeitongPayServiceTest.java delete mode 100644 accompany-business/accompany-business-web/src/test/java/servicetest/GuotongPayServiceTest.java delete mode 100644 accompany-business/accompany-business-web/src/test/java/servicetest/WXPub2ServiceTest.java delete mode 100644 accompany-business/accompany-business-web/src/test/java/servicetest/WanXiangPayServiceTest.java delete mode 100644 accompany-scheduler/accompany-scheduler-service/src/main/java/com/accompany/scheduler/task/AuditAudioRoomTask.java diff --git a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/auditaudio/AuditAudioAdminService.java b/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/auditaudio/AuditAudioAdminService.java deleted file mode 100644 index ff2f84351..000000000 --- a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/auditaudio/AuditAudioAdminService.java +++ /dev/null @@ -1,379 +0,0 @@ -package com.accompany.admin.service.auditaudio; - -import com.accompany.admin.common.BusinessException; -import com.accompany.admin.model.AdminUser; -import com.accompany.admin.service.AccountBlockAdminService; -import com.accompany.admin.service.base.BaseService; -import com.accompany.admin.service.system.AdminUserService; -import com.accompany.admin.vo.AuditAudioAdminVo; -import com.accompany.business.constant.AuditAudioResultEnum; -import com.accompany.business.constant.RiskLevelEnum; -import com.accompany.business.constant.RiskTypeEnum; -import com.accompany.business.model.AuditAudioRoom; -import com.accompany.business.mongodb.DAO.auditaudio.AuditAudioDAO; -import com.accompany.business.mongodb.document.auditaudio.AuditAudio; -import com.accompany.business.service.account.AccountBlockService; -import com.accompany.business.service.auditaudio.AuditAudioRoomService; -import com.accompany.business.service.auditaudio.AuditAudioService; -import com.accompany.business.service.room.RoomService; -import com.accompany.business.service.user.UsersService; -import com.accompany.business.vo.RunningRoomVo; -import com.accompany.common.constant.Constant; -import com.accompany.common.constant.RoomMonitorTypeEnum; -import com.accompany.common.redis.RedisKey; -import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.StringUtils; -import com.accompany.core.constant.BlockSourceEnum; -import com.accompany.core.constant.BlockTypeEnum; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.model.Room; -import com.accompany.core.model.Users; -import com.accompany.core.service.user.UsersBaseService; -import com.google.common.collect.Maps; -import org.apache.commons.collections.CollectionUtils; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Sort; -import org.springframework.data.mongodb.core.query.Criteria; -import org.springframework.data.mongodb.core.query.Query; -import org.springframework.data.mongodb.core.query.Update; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.stream.Collectors; - -/** - * 2 * @Author: zhuct - * 3 * @Date: 2019/8/19 17:08 - * 4 - */ -@Service -public class AuditAudioAdminService extends BaseService { - @Autowired - private UsersService usersService; - @Autowired - private UsersBaseService usersBaseService; - @Autowired - private AuditAudioDAO auditAudioDAO; - @Autowired - private AuditAudioService auditAudioService; - @Autowired - private AdminUserService adminUserService; - @Autowired - private AccountBlockAdminService accountBlockAdminService; - @Autowired - private AccountBlockService accountBlockService; - @Autowired - private AuditAudioRoomService auditAudioRoomService; - @Autowired - private RoomService roomService; - - - private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - - - public Map getAuditAudioList(Long erbanNo, Byte riskLevel, Integer riskType, String operatorName, Integer manualAuditResult, - Integer systemAuditResult, Integer pageNum, Integer pageSize, Date beginDate, - Date endDate, Integer startRejectCount, Integer endRejectCount, Integer startScore, Integer endScore) { - - Map data = Maps.newHashMap(); - logger.info("erbanNo:{}",erbanNo); - Long roomUid = null; - List roomUids = new ArrayList<>(); - if (erbanNo != null) { - logger.info("getAuditAudioList erbanNo:{}",erbanNo); - Users user = usersService.getUserByErbanNo(erbanNo); - if (user == null) { - logger.info("getAuditAudioList erbanNo1:{}",erbanNo); - data.put("rows", Collections.emptyList()); - data.put("total", 0); - return data; - } else { - roomUid = user.getUid(); - roomUids.add(roomUid); - } - } - if (startRejectCount != null || endRejectCount != null) { - if (roomUid != null) { - Double score = jedisService.zscore(RedisKey.reject_audio_count.getKey(), roomUid.toString()); - if (score == null || (startRejectCount != null && score.intValue() < startRejectCount) - || (endRejectCount != null && score.intValue() > endRejectCount)) { - logger.info("getAuditAudioList erbanNo2:{}",erbanNo); - data.put("rows", Collections.emptyList()); - data.put("total", 0); - return data; - } - - } else { - String start = startRejectCount == null ? "-inf" : startRejectCount.toString(); - String end = endRejectCount == null ? "+inf" : endRejectCount.toString(); - Set strings = jedisService.zrangeByScore(RedisKey.reject_audio_count.getKey(), start, end); - if (CollectionUtils.isEmpty(strings)) { - logger.info("getAuditAudioList erbanNo3:{}",erbanNo); - data.put("rows", Collections.emptyList()); - data.put("total", 0); - return data; - } - roomUids = strings.stream().map(uid -> Long.valueOf(uid)).collect(Collectors.toList()); - } - } - pageNum = pageNum != null ? pageNum : Constant.DEFAULT_PAGE; - pageSize = pageSize != null ? pageSize : Constant.DEFAULT_PAGE_SIZE; - int start = (pageNum - 1) * pageSize; - Query query = new Query(); - if (CollectionUtils.isNotEmpty(roomUids)) { - query.addCriteria(Criteria.where("roomUid").in(roomUids)); - } - if (riskLevel != null) { - query.addCriteria(Criteria.where("riskLevel").is(riskLevel)); - } - if (riskType != null) { - query.addCriteria(Criteria.where("riskType").is(riskType)); - } - if (StringUtils.isNotBlank(operatorName)) { - query.addCriteria(Criteria.where("operatorName").is(operatorName)); - } - if (manualAuditResult != null) { - query.addCriteria(Criteria.where("manualAuditResult").is(manualAuditResult)); - } - if (systemAuditResult != null) { - query.addCriteria(Criteria.where("systemAuditResult").is(systemAuditResult)); - } - if (beginDate != null && endDate == null) { - query.addCriteria(Criteria.where("createTime").gte(beginDate.getTime())); - } else if (endDate != null && beginDate == null) { - query.addCriteria(Criteria.where("createTime").lte(endDate.getTime())); - } else if (beginDate != null && endDate != null) { - Criteria cr = new Criteria(); - cr.andOperator(Criteria.where("createTime").gte(beginDate.getTime()), - Criteria.where("createTime").lte(endDate.getTime())); - query.addCriteria(cr); - } - if (startScore != null && endScore == null) { - query.addCriteria(Criteria.where("score").gte(startScore)); - } else if (endScore != null && startScore == null) { - query.addCriteria(Criteria.where("score").lte(endScore)); - } else if (startScore != null && endScore != null) { - Criteria cr = new Criteria(); - cr.andOperator(Criteria.where("score").gte(startScore), - Criteria.where("score").lte(endScore)); - query.addCriteria(cr); - } - long count = auditAudioDAO.count(query); - query.skip(start).limit(pageSize); - query.with(Sort.by(Sort.Order.desc("createTime"))); - List auditAudioList = auditAudioDAO.findByQuery(query); - logger.info("getAuditAudioList auditAudioList:{}",auditAudioList); - data.put("rows", buildAuditAudioAdminVo(auditAudioList)); - data.put("total", count); - return data; - } - - private List buildAuditAudioAdminVo(List audioList) { - if (CollectionUtils.isEmpty(audioList)) { - return Collections.emptyList(); - } - List voList = new ArrayList<>(); - audioList.forEach(auditAudio -> { - AuditAudioAdminVo vo = new AuditAudioAdminVo(); - BeanUtils.copyProperties(auditAudio, vo); - Users user = usersService.getUsersByUid(auditAudio.getRoomUid()); - vo.setErbanNo(user == null ? null : user.getErbanNo()); - vo.setRejectCount(auditAudioService.getRejectAudioCount(auditAudio.getRoomUid())); - voList.add(vo); - }); - return voList; - } - - /** - * 处理为正常 - * - * @param recordId - * @return - */ - @Transactional(rollbackFor = Exception.class) - public void handlePass(String recordId, Integer adminId) { - AuditAudio auditAudio = auditAudioDAO.findById(recordId); - if (auditAudio == null || auditAudio.getManualAuditResult() != AuditAudioResultEnum.TO_BE_HANDLE.getValue()) { - throw new ServiceException(BusiStatus.PARAMERROR); - } - AdminUser adminUser = adminUserService.getAdminUserById(adminId); - auditAudio.setManualAuditResult(AuditAudioResultEnum.NORMAL.getValue()); - auditAudio.setUpdateTime(System.currentTimeMillis()); - auditAudio.setOperatorName(adminUser == null ? null : adminUser.getUsername()); - auditAudioDAO.save(auditAudio); - } - - /** - * 解禁 - * - * @param recordId - * @return - */ - @Transactional(rollbackFor = Exception.class) - public void handleUnBlock(String recordId, String adminName) throws Exception{ - AuditAudio auditAudio = auditAudioDAO.findById(recordId); - if (auditAudio == null) { - throw new BusinessException("音频记录不存在"); - } - if (auditAudio.getBlockId() == null) { - throw new BusinessException("封禁记录不存在"); - } - if (auditAudio.getManualAuditResult() != null && auditAudio.getManualAuditResult() == AuditAudioResultEnum.REMOVE_BLOCK.getValue()) { - throw new BusinessException("该记录已处理为解禁"); - } - //解除封禁 - accountBlockAdminService.deleteAccountBlock(auditAudio.getBlockId().toString(), adminName); - - } - - public void updateMultiAuditAudioStatus(Integer blockId, String adminName) { - Query query = new Query(); - query.addCriteria(Criteria.where("blockId").is(blockId).and("manualAuditResult").ne(AuditAudioResultEnum.REMOVE_BLOCK.getValue())); - Update update = new Update(); - update.set("updateTime", System.currentTimeMillis()); - update.set("operatorName", adminName); - update.set("manualAuditResult", AuditAudioResultEnum.REMOVE_BLOCK.getValue()); - auditAudioDAO.updateMulti(query, update); - } - - /** - * 处理违规 - * - * @param recordId - * @return - */ - @Transactional(rollbackFor = Exception.class) - public void handleReject(String recordId, Integer resultValue, Integer riskType, String adminName) throws Exception { - AuditAudio auditAudio = auditAudioDAO.findById(recordId); - if (auditAudio == null) { - throw new BusinessException("音频记录不存在"); - } - if (auditAudio.getManualAuditResult() != null && auditAudio.getManualAuditResult() != AuditAudioResultEnum.TO_BE_HANDLE.getValue()) { - throw new BusinessException("不能处理该记录"); - } - Long roomUid = auditAudio.getRoomUid(); - Users users = usersService.getUsersByUid(roomUid); - if (users == null) { - throw new BusinessException("房主用户不存在"); - } - LocalDateTime now = LocalDateTime.now(); - AuditAudioResultEnum resultEnum = AuditAudioResultEnum.get(resultValue); - String endBlockTime = getEndBlockTime(resultEnum, now); - Integer blockedAccountId = null; - riskType = riskType == null ? auditAudio.getRiskType() : riskType; - RiskTypeEnum riskTypeEnum = RiskTypeEnum.get(riskType); - if (StringUtils.isNotBlank(endBlockTime)) { - //封禁账号 - accountBlockService.saveBlockedAccount(users.getErbanNo(), BlockTypeEnum.BLOCK_ACCOUNT.getValue(), now.format(formatter), - endBlockTime, riskTypeEnum.getDesc(), BlockSourceEnum.AUDIT_AUDIO.getValue(), adminName, false); - } - auditAudio.setBlockId(users.getErbanNo().intValue()); - auditAudio.setManualAuditResult(resultEnum.getValue()); - auditAudio.setUpdateTime(System.currentTimeMillis()); - auditAudio.setOperatorName(adminName); - auditAudioDAO.save(auditAudio); - if(auditAudio.getRiskLevel() != RiskLevelEnum.REJECT.getValue()){ - //违规次数加一 - jedisService.zincrby(RedisKey.reject_audio_count.getKey(), 1d, roomUid.toString()); - } - auditAudioService.sendAuditAudioMsg(roomUid.toString(), riskTypeEnum.getDesc(), resultEnum.getDesc()); - - } - - private String getEndBlockTime(AuditAudioResultEnum resultEnum, LocalDateTime now) { - switch (resultEnum) { - case BLOCK_24_HOURS: - return now.plusDays(1).format(formatter); - case BLOCK_THREE_DAY: - return now.plusDays(3).format(formatter); - case BLOCK_SEVEN_HOURS: - return now.plusDays(7).format(formatter); - case BLOCK_PERMANENT: - return now.plusYears(10).format(formatter); - default: - return null; - } - } - - /** - * 获取监控规则 - * - * @return - */ - public Map getMonitorRule() { - Map data = Maps.newHashMap(); - Integer monitorType = auditAudioRoomService.getRoomMonitorType(); - String erbanNoStr = ""; - if (monitorType != null && monitorType == RoomMonitorTypeEnum.GIVEN_ROOM.getValue()) { - Set roomUids = jedisService.smembers(RedisKey.given_audit_audio_room.getKey()); - for (String roomUid : roomUids) { - Users users = usersService.getUsersByUid(Long.valueOf(roomUid)); - if (users != null) { - erbanNoStr += users.getErbanNo() + ","; - } - } - - - } - data.put("roomMonitorType", monitorType); - data.put("erbanNos", erbanNoStr); - return data; - } - - public void saveMonitorRule(Byte type, String erbanNos) { - Integer beforeMonitorType = auditAudioRoomService.getRoomMonitorType(); - List auditAudioRoomList = auditAudioRoomService.getAuditAudioRoomList(); - if (beforeMonitorType != null && beforeMonitorType != type.intValue()) { - //关闭之前送审的房间 - for (AuditAudioRoom room : auditAudioRoomList) { - auditAudioRoomService.closeAuditAudioRoom(room); - } - if (beforeMonitorType == RoomMonitorTypeEnum.GIVEN_ROOM.getValue()) { - jedisService.del(RedisKey.given_audit_audio_room.getKey()); - } - } - if (type == RoomMonitorTypeEnum.GIVEN_ROOM.getValue()) { - List erbanNoList = Arrays.asList(erbanNos.split(",")).stream().filter(string -> !"".equals(string)).collect(Collectors.toList()); - Set roomUids = jedisService.smembers(RedisKey.given_audit_audio_room.getKey()); - for (String roomUid : roomUids) { - Users users = usersService.getUsersByUid(Long.valueOf(roomUid)); - if (!erbanNoList.contains(users.getErbanNo().toString())) {//如果之前送审房间已经不存在这次保存的指定房间内,则关闭对应房间 - String jsonStr = jedisService.hget(RedisKey.audit_audio_room.getKey(), roomUid); - if (StringUtils.isNotBlank(jsonStr)) {//如果房间在审核,则关闭房间 - auditAudioRoomService.closeAuditAudioRoom(gson.fromJson(jsonStr, AuditAudioRoom.class)); - } - //移除指定房间 - jedisService.srem(RedisKey.given_audit_audio_room.getKey(), roomUid); - } - } - //送审这次保存的房间 - for (String erbanNo : erbanNoList) { - Users users = usersBaseService.getUsersByErBanNo(Long.valueOf(erbanNo)); - if (users == null) { - continue; - } - long result = jedisService.sadd(RedisKey.given_audit_audio_room.getKey(), users.getUid().toString()); - if (result > 0) {//如果保存成功,说明是新增指定房间,则判断是否开房中并且有人,如果是,则立马送审 - String runningRoomStr = jedisService.hget(RedisKey.room_running.getKey(), users.getUid().toString()); - if (StringUtils.isNotBlank(runningRoomStr)) { - RunningRoomVo runningRoomVo = gson.fromJson(runningRoomStr, RunningRoomVo.class); - if (runningRoomVo != null && runningRoomVo.getOnlineNum() != 0) { - Room room = roomService.getRoomByUid(users.getUid()); - auditAudioRoomService.sendAuditRoom(room, type); - } - } - } - } - } else { - //送审所有在线房间 - auditAudioRoomService.sendAuditOnlineRoom(); - } - jedisService.set(RedisKey.room_monitor_type.getKey(), type.toString()); - } - - -} diff --git a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/record/OfficialGoldRecordService.java b/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/record/OfficialGoldRecordService.java index 011c9e0cf..262ce95c9 100644 --- a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/record/OfficialGoldRecordService.java +++ b/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/record/OfficialGoldRecordService.java @@ -16,7 +16,6 @@ import com.accompany.business.service.purse.UserPurseService; import com.accompany.admin.service.push.EnterpriseWeChatPushAdminService; import com.accompany.business.service.record.BillRecordService; import com.accompany.business.service.user.UsersService; -import com.accompany.business.service.wx.WXPubService; import com.accompany.common.constant.Constant; import com.accompany.common.redis.RedisKey; import com.accompany.common.result.BusiResult; @@ -68,8 +67,6 @@ public class OfficialGoldRecordService extends BaseService { @Autowired private JedisService jedisService; @Autowired - private WXPubService wxPubService; - @Autowired private OfficialGoldBusTypeAdminService officialGoldBusTypeAdminService; @Autowired private EnterpriseWeChatPushAdminService enterpriseWeChatPushAdminService; @@ -493,7 +490,7 @@ public class OfficialGoldRecordService extends BaseService { keyword3 += "笔数"; } String keyword4 = "充值时间:" + DateTimeUtil.convertDate(new Date(),"yyyy-MM-dd hh:mm"); - wxPubService.sendAlertMsg(openId,first,keyword1,keyword2,keyword3,keyword4,""); + //wxPubService.sendAlertMsg(openId,first,keyword1,keyword2,keyword3,keyword4,""); } } diff --git a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/system/AdminUserService.java b/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/system/AdminUserService.java index bb51b80b2..e68b04ca3 100644 --- a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/system/AdminUserService.java +++ b/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/system/AdminUserService.java @@ -8,7 +8,6 @@ import com.accompany.admin.model.AdminLoginRecordExample; import com.accompany.admin.model.AdminUser; import com.accompany.admin.model.AdminUserExample; import com.accompany.admin.service.base.BaseService; -import com.accompany.business.util.MD5; import com.accompany.business.util.ReplaceDomainUtil; import com.accompany.common.constant.Constant; import com.accompany.common.constant.SmsTypeEnum; @@ -20,6 +19,7 @@ import com.accompany.common.utils.DateTimeUtil; import com.accompany.common.utils.RandomUtil; import com.accompany.common.utils.StringUtils; import com.accompany.core.service.SysConfService; +import com.accompany.core.util.MD5; import com.accompany.sms.service.SmsService; import com.aliyuncs.exceptions.ClientException; import com.github.pagehelper.PageHelper; @@ -151,15 +151,15 @@ public class AdminUserService extends BaseService { return adminUserMapper.deleteByPrimaryKey(id); } - public BusiResult sendSmsCode(String account, String realIpAddress) throws UnsupportedEncodingException, ClientException { + public BusiResult sendSmsCode(String account, String realIpAddress) throws UnsupportedEncodingException, ClientException { logger.info("getUserByName"); AdminUser adminUser = getUserByName(account); if (adminUser == null) { jedisService.setex(RedisKey.admin_account_not_exist.getKey(account), 10, account); - return new BusiResult(BusiStatus.USERNOTEXISTS); + return new BusiResult<>(BusiStatus.USERNOTEXISTS); } if (BlankUtil.isBlank(adminUser.getPhone())) { - return new BusiResult(BusiStatus.ADMIN_PHONE_NO_BIND); + return new BusiResult<>(BusiStatus.ADMIN_PHONE_NO_BIND); } CompletableFuture templateCodeFuture = CompletableFuture.supplyAsync(() -> sysConfService.getSysConfValueById(Constant.SysConfId.ADMIN_SMS_TEMPLATE_CODE) @@ -170,7 +170,7 @@ public class AdminUserService extends BaseService { smsService.sendSmsCode(adminUser.getPhone(), SmsTypeEnum.SUPER_ADMIN_LOGIN.value, null, realIpAddress, smsCode); saveSmsCode(adminUser, smsCode, realIpAddress); - return new BusiResult(BusiStatus.SUCCESS); + return new BusiResult<>(BusiStatus.SUCCESS); } /** diff --git a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/transfer/AlipayTransferService.java b/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/transfer/AlipayTransferService.java deleted file mode 100644 index f05094619..000000000 --- a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/transfer/AlipayTransferService.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.accompany.admin.service.transfer; - -import com.accompany.payment.alipay.AlipayService; -import com.accompany.payment.config.AliPayConfig; -import com.alipay.api.AlipayApiException; -import com.alipay.api.AlipayClient; -import com.alipay.api.DefaultAlipayClient; -import com.alipay.api.domain.AlipayFundTransOrderQueryModel; -import com.alipay.api.domain.AlipayFundTransToaccountTransferModel; -import com.alipay.api.request.AlipayFundTransOrderQueryRequest; -import com.alipay.api.request.AlipayFundTransToaccountTransferRequest; -import com.alipay.api.response.AlipayFundTransOrderQueryResponse; -import com.alipay.api.response.AlipayFundTransToaccountTransferResponse; -import com.accompany.admin.transfer.*; -import com.accompany.business.apppay.constant.PayConstant; -import com.accompany.common.constant.Constant; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.NotImplementedException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * {这里添加描述} - * - * @author fangchengyan - * @date 2019-12-26 10:08 上午 - */ -@Service -@Slf4j -public class AlipayTransferService implements ITransferService { - - @Override - public Byte getAccountType() { - return Constant.WithdrawAccountType.ALIPAY; - } - @Autowired - private AlipayService alipayService; - - @Override - public TransferPayResult transferPay(TransferPayParam param) throws Exception { - AlipayClient alipayClient = alipayService.getAlipayClientInstance(); - - AlipayFundTransToaccountTransferModel model = new AlipayFundTransToaccountTransferModel(); - model.setOutBizNo(param.getBillId()); - model.setPayeeType(PayConstant.ALIPAY_PAYEE_TYPE); - model.setPayeeAccount(param.getAccount()); - model.setAmount(param.getTransferAmount().toString()); - model.setPayeeRealName(param.getAccountName()); - model.setRemark(param.getDescription()); - - AlipayFundTransToaccountTransferRequest request = new AlipayFundTransToaccountTransferRequest(); - request.setBizModel(model); - - AlipayFundTransToaccountTransferResponse response = alipayClient.execute(request); - - //构建返回值 - TransferPayResult transferPayResult = new TransferPayResult(); - if(response != null && PayConstant.ALIPAY_TRANSFER_SUCCESS_CODE.equals(response.getCode())) { - transferPayResult.setStatus(PayConstant.Transfer.RESULT_SUCCESS); - } else { - transferPayResult.setStatus(PayConstant.Transfer.RESULT_FAIL); - } - transferPayResult.setPayId(response.getOrderId()); - transferPayResult.setErrorCode(response.getSubCode()); - transferPayResult.setErrorMsg(response.getSubMsg()); - - return transferPayResult; - } - - @Override - public TransferQueryResult transferQuery(TransferQueryParam param) throws AlipayApiException { - AlipayClient alipayClient = alipayService.getAlipayClientInstance(); - - AlipayFundTransOrderQueryModel model = new AlipayFundTransOrderQueryModel(); - model.setOutBizNo(param.getBillId()); - model.setOrderId(param.getPayId()); - - AlipayFundTransOrderQueryRequest request = new AlipayFundTransOrderQueryRequest(); - request.setBizModel(model); - AlipayFundTransOrderQueryResponse response = alipayClient.execute(request); - - //构建返回值 - TransferQueryResult transferQueryResult = new TransferQueryResult(); - if(response != null && PayConstant.ALIPAY_TRANSFER_SUCCESS_CODE.equals(response.getCode())) { - transferQueryResult.setStatus(PayConstant.Transfer.RESULT_SUCCESS); - } else { - transferQueryResult.setStatus(PayConstant.Transfer.RESULT_FAIL); - } - transferQueryResult.setPayId(response.getOrderId()); - transferQueryResult.setErrorCode(response.getSubCode()); - transferQueryResult.setErrorMsg(response.getSubMsg()); - return transferQueryResult; - } - - @Override - public TransferNotifyResult handlerNotify(Object param) { - throw new NotImplementedException("方法未实现"); - } -} diff --git a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/transfer/ITransferService.java b/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/transfer/ITransferService.java deleted file mode 100644 index ca6690501..000000000 --- a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/transfer/ITransferService.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.accompany.admin.service.transfer; - -import com.accompany.admin.transfer.*; - -/** - * {这里添加描述} - * - * @author fangchengyan - * @date 2019-12-25 5:37 下午 - */ -public interface ITransferService { - - /** - * 转账类型 - * @return - */ - Byte getAccountType(); - - /** - * 转账-付款 - * @param param - * @return - * - * @throws Exception - */ - TransferPayResult transferPay(TransferPayParam param) throws Exception; - - /** - * 转账-查询 - * @param param - * @return - * - * @throws Exception - */ - TransferQueryResult transferQuery(TransferQueryParam param) throws Exception; - - /** - * 处理异步 - * - * @param param - * @return - */ - TransferNotifyResult handlerNotify(Object param); - -} diff --git a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/transfer/JoinpayTransferService.java b/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/transfer/JoinpayTransferService.java deleted file mode 100644 index eb12fb2ea..000000000 --- a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/transfer/JoinpayTransferService.java +++ /dev/null @@ -1,196 +0,0 @@ -package com.accompany.admin.service.transfer; - -import com.accompany.admin.transfer.*; -import com.accompany.admin.util.PropertyUtil; -import com.accompany.business.apppay.constant.JoinpayTransferStatusEnum; -import com.accompany.business.apppay.constant.PayConstant; -import com.accompany.common.constant.Constant; -import com.accompany.common.utils.DateTimeUtil; -import com.accompany.common.utils.HttpUtils; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.util.StringUtils; -import com.accompany.payment.config.JoinPayConfig; -import com.alibaba.fastjson.JSON; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.codec.digest.DigestUtils; -import org.springframework.stereotype.Service; - -import java.util.Date; - -/** - * 汇聚代付 - * 代付产品 - * - * @author fangchengyan - * @date 2019-12-26 3:39 下午 - */ -@Service -@Slf4j -public class JoinpayTransferService implements ITransferService { - - /** - * 单笔代付 - */ - private String singlePayUrl = "https://www.joinpay.com/payment/pay/singlePay"; - - /** - * 单笔代付查询AlipayTransferService - */ - private String singlePayQueryUrl = "https://www.joinpay.com/payment/pay/singlePayQuery"; - - @Override - public Byte getAccountType() { - return Constant.WithdrawAccountType.BANK; - } - - /** - * 汇聚代付 - * @param param - * @return - * @throws Exception - */ - @Override - public TransferPayResult transferPay(TransferPayParam param) throws Exception { - JoinpayTransferPayReq req = new JoinpayTransferPayReq(); - // 商户编号 - req.setUserNo(String.valueOf(JoinPayConfig.merchantNo)); - // 产品类型, BANK_PAY_DAILY_ORDER: 朝夕付 - req.setProductCode("BANK_PAY_DAILY_ORDER"); - req.setRequestTime(DateTimeUtil.convertDate(new Date(), DateTimeUtil.DEFAULT_DATETIME_PATTERN)); - req.setMerchantOrderNo(param.getBillId()); - req.setReceiverAccountNoEnc(param.getAccount()); - req.setReceiverNameEnc(param.getAccountName()); - // 账户类型: 对私账户:201 对公账户:204 - req.setReceiverAccountType(201); - req.setPaidAmount(param.getTransferAmount()); - req.setCurrency("201"); - // 是否复核,复核:201,不复核:202 - req.setIsChecked("202"); - // 代付描述,最长为25个字符 - String desc = param.getDescription(); - if(StringUtils.length(desc) > 25) { - desc = StringUtils.substring(desc, 0, 25); - } - req.setPaidDesc(desc); - // 代付用途: 202: 活动经费 - req.setPaidUse("202"); - // 代付完成后异步回调通知地址 - req.setCallbackUrl(PropertyUtil.getProperty("transferCallbackUrl")); - req.setHmac(signByMD5(req.plainTextSign(), JoinPayConfig.key)); - - String reqJson = JSON.toJSONString(req); - log.info("请求参数:{}", reqJson); - - String jsonResp = HttpUtils.doPostForJson(singlePayUrl, reqJson); - log.info("转账结果:{}", jsonResp); - - TransferPayResult transferPayResult = new TransferPayResult(); - if(StringUtils.isBlank(jsonResp)) { - transferPayResult.setStatus(PayConstant.Transfer.RESULT_FAIL); - return transferPayResult; - } - JoinpayTransferPayResp payResp = JSON.parseObject(jsonResp, JoinpayTransferPayResp.class); - // 转账是异步操作,这里的成功仅表示受理成功,转账结果还需要另外查询 - if(PayConstant.JOINPAY_TRANSFER_SUCCESS.equals(payResp.getStatusCode())) { - transferPayResult.setStatus(PayConstant.Transfer.RESULT_PROCESSING); - } else { - transferPayResult.setStatus(PayConstant.Transfer.RESULT_FAIL); - } - transferPayResult.setPayId(payResp.getData().getMerchantOrderNo()); - transferPayResult.setErrorCode(payResp.getData().getErrorCode()); - transferPayResult.setErrorMsg(payResp.getData().getErrorDesc()); - return transferPayResult; - } - - /** - * 转账查询 - * @param param - * @return - * @throws Exception - */ - @Override - public TransferQueryResult transferQuery(TransferQueryParam param) throws Exception { - JoinpayTransQueryReq req = new JoinpayTransQueryReq(); - req.setMerchantOrderNo(param.getBillId()); - req.setUserNo(String.valueOf(JoinPayConfig.merchantNo)); - req.setHmac(signByMD5(req.plainTextSign(), JoinPayConfig.key)); - String reqJson = JSON.toJSONString(req); - log.info("请求参数:{}", reqJson); - - String jsonResp = HttpUtils.doPostForJson(singlePayQueryUrl, reqJson); - log.info("查询结果:{}", jsonResp); - - //构建返回值 - TransferQueryResult transferQueryResult = new TransferQueryResult(); - if(StringUtils.isBlank(jsonResp)) { - transferQueryResult.setStatus(PayConstant.Transfer.RESULT_FAIL); - return transferQueryResult; - } - - JoinpayTransQueryResp response = JSON.parseObject(jsonResp, JoinpayTransQueryResp.class); - JoinpayTransferQueryRespData data = response.getData(); - if(PayConstant.JOINPAY_TRANSFER_SUCCESS.equals(response.getStatusCode())) { - if(null != data.getStatus() - && data.getStatus().equals(JoinpayTransferStatusEnum.JOINPAY_TRANSFER_DETAIL_SUCCESS.getCode())) { - transferQueryResult.setStatus(PayConstant.Transfer.RESULT_SUCCESS); - } else { - transferQueryResult.setStatus(PayConstant.Transfer.RESULT_FAIL); - } - } else { - transferQueryResult.setStatus(PayConstant.Transfer.RESULT_FAIL); - } - transferQueryResult.setPayId(data.getPlatformSerialNo()); - if(StringUtils.isNotEmpty(data.getErrorCode())) { - transferQueryResult.setErrorCode(data.getErrorCode()); - transferQueryResult.setErrorMsg(data.getErrorDesc()); - } else { - transferQueryResult.setErrorCode(String.valueOf(data.getStatus())); - transferQueryResult.setErrorMsg(JoinpayTransferStatusEnum.getDescByCode(String.valueOf(data.getStatus()))); - } - - return transferQueryResult; - } - - @Override - public TransferNotifyResult handlerNotify(Object param) { - JoinpayTransferPayNotifyReq req = (JoinpayTransferPayNotifyReq)param; - String key = signByMD5(req.plainTextSign(), JoinPayConfig.key); - // 验证签名 - if(!StringUtils.equalsIgnoreCase(req.getHmac(), key)) { - log.warn("签名验证失败,参数中的hmac:{},生成的hmac:{}", req.getHmac(), key); - throw new ServiceException("签名错误!"); - } - - TransferNotifyResult result = new TransferNotifyResult(); - String statusStr = String.valueOf(req.getStatus()); - if(StringUtils.equalsIgnoreCase(JoinpayTransferStatusEnum.JOINPAY_TRANSFER_DETAIL_SUCCESS.getCode(), statusStr)) { - result.setStatus(PayConstant.Transfer.RESULT_SUCCESS); - } else { - result.setStatus(PayConstant.Transfer.RESULT_FAIL); - } - - result.setPayId(req.getPlatformSerialNo()); - result.setBillId(req.getMerchantOrderNo()); - result.setAccountType(getAccountType()); - if(StringUtils.isNotEmpty(req.getErrorCode())) { - result.setErrorCode(req.getErrorCode()); - result.setErrorMsg(req.getErrorCodeDesc()); - } else { - result.setErrorCode(String.valueOf(req.getStatus())); - result.setErrorMsg(JoinpayTransferStatusEnum.getDescByCode(String.valueOf(req.getStatus()))); - } - return result; - } - - /** - * 对请求参数进行签名 - * @param signString - * @param encryptKey - * @return - */ - private String signByMD5(String signString, String encryptKey) { - String plain = signString + encryptKey; - log.info("签名原文:{}", plain); - return DigestUtils.md5Hex(plain).toUpperCase(); - } -} diff --git a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/transfer/TransferFactory.java b/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/transfer/TransferFactory.java deleted file mode 100644 index 0c25fb8ea..000000000 --- a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/transfer/TransferFactory.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.accompany.admin.service.transfer; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Component; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -/** - * {这里添加描述} - * - * @author fangchengyan - * @date 2019-07-26 23:06 - */ -@Slf4j -@Component -public class TransferFactory implements ApplicationContextAware { - - private volatile ApplicationContext applicationContext; - - private Map serviceMap = new HashMap<>(); - - /** - * 根据payType与platform获取ChannelService - * @return - */ - public ITransferService getChannelService(Byte accountType) { - if(serviceMap.size() == 0){ - load(); - } - return Optional.ofNullable(serviceMap.get(accountType)) - .orElseThrow(() -> new IllegalStateException("Can't be find the account type:" + accountType)); - } - - private void load() { - Map beanMap = applicationContext.getBeansOfType(ITransferService.class); - beanMap.forEach((name, bean) -> { - serviceMap.put(bean.getAccountType(), bean); - log.info("Successful register pay type-{} of bean.The beanName: {}", - bean.getAccountType(), name); - }); - } - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = applicationContext; - } -} diff --git a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/user/AccountAdminService.java b/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/user/AccountAdminService.java index a61973890..53a142cdf 100644 --- a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/user/AccountAdminService.java +++ b/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/user/AccountAdminService.java @@ -2,9 +2,8 @@ package com.accompany.admin.service.user; import com.accompany.admin.common.BusinessException; import com.accompany.core.model.Account; -import com.accompany.core.mybatismapper.AccountMapper; -import com.accompany.business.util.MD5; import com.accompany.core.service.account.AccountService; +import com.accompany.core.util.MD5; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/withdraw/PacketWithdrawAdminService.java b/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/withdraw/PacketWithdrawAdminService.java deleted file mode 100644 index 47e2ca257..000000000 --- a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/withdraw/PacketWithdrawAdminService.java +++ /dev/null @@ -1,244 +0,0 @@ -package com.accompany.admin.service.withdraw; - -import com.accompany.admin.service.transfer.ITransferService; -import com.accompany.admin.service.transfer.TransferFactory; -import com.accompany.admin.service.user.BillRecordAdminService; -import com.accompany.admin.transfer.TransferPayParam; -import com.accompany.admin.transfer.TransferPayResult; -import com.accompany.business.apppay.constant.PayConstant; -import com.accompany.business.model.PacketWithdrawRecord; -import com.accompany.business.mybatismapper.PacketWithdrawRecordExpandMapper; -import com.accompany.business.mybatismapper.PacketWithdrawRecordMapper; -import com.accompany.business.service.user.UsersService; -import com.accompany.business.vo.PacketWithdrawRecordAdminVo; -import com.accompany.common.constant.Constant; -import com.accompany.common.result.BusiResult; -import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.DateTimeUtil; -import com.accompany.common.utils.UUIDUitl; -import com.accompany.core.model.Users; -import com.accompany.core.util.StringUtils; -import com.alibaba.fastjson.JSONObject; -import com.google.common.collect.Maps; -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 java.math.BigDecimal; -import java.util.Calendar; -import java.util.List; -import java.util.Map; - -/** - * @author yangziwen - * @description - * @date 2018/1/31 21:05 - */ -@Service -public class PacketWithdrawAdminService { - - private static final Logger logger = LoggerFactory.getLogger(PacketWithdrawAdminService.class); - - @Autowired - private PacketWithdrawRecordMapper packetWithdrawRecordMapper; - - @Autowired - private PacketWithdrawRecordExpandMapper packetWithdrawRecordExpandMapper; - - @Autowired - private UsersService usersService; - - @Autowired - private BillRecordAdminService billRecordAdminService; - - @Autowired - private TransferFactory transferFactory; - - - public BusiResult getPacketWithdrawList(String erbanNo, String account, String accountName, String phone, String beginDate, - String endDate, Byte status, String payStatus, Integer pageNum, Integer pageSize) { - //为了尽量降低表结构修改,使用连表查询(仅在管理后台使用) - BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS); - pageNum = pageNum != null ? pageNum : Constant.DEFAULT_PAGE; - pageSize = pageSize != null ? pageSize : Constant.DEFAULT_PAGE_SIZE; - Integer start = (pageNum-1)*pageSize; - Map record = Maps.newHashMap(); - if (StringUtils.isNotEmpty(erbanNo)) { - record.put("erbanNo",erbanNo); - } - if (StringUtils.isNotBlank(account)) { - record.put("account",account); - } - if (StringUtils.isNotBlank(accountName)) { - record.put("accountName",accountName); - } - if (StringUtils.isNotBlank(payStatus) && !Constant.WithdrawPayStatus.ALL.equalsIgnoreCase(payStatus)) { - record.put("payStatus",payStatus); - } - if (StringUtils.isNotBlank(phone)) { - record.put("phone",phone); - } - if (StringUtils.isNotBlank(beginDate)) { - record.put("beginDate",beginDate); - } - if (StringUtils.isNotBlank(endDate)) { - record.put("endDate",endDate); - } - if (status != null && status != -1) { - record.put("recordStatus",status); - } - List withdrawList = this.packetWithdrawRecordExpandMapper.queryPacketWithdrowList(record,start,pageSize); - int count = this.packetWithdrawRecordExpandMapper.queryPacketWithdrowCount(record); - JSONObject data = new JSONObject(); - data.put("rows",withdrawList); - data.put("total",count); - busiResult.setData(data); - return busiResult; - } - - @Transactional(rollbackFor = Exception.class) - public String approvePacketWithdraw(String id) { - PacketWithdrawRecord packetWithdrawRecord = this.packetWithdrawRecordMapper.selectByPrimaryKey(id); - if (packetWithdrawRecord == null) { - logger.error("illegal data, packet withdrad record not exists[id={}]", id); - return "提现申请记录不存在"; - } - - if (packetWithdrawRecord.getRecordStatus().byteValue()!=Constant.WithDrawStatus.ing) { - logger.error("request is not in progress[id={}]", id); - return "该请求不是发起提现状态"; - } - - packetWithdrawRecord.setRecordStatus(Constant.WithDrawStatus.APPROVED); - packetWithdrawRecord.setUpdateTime(Calendar.getInstance().getTime()); - this.packetWithdrawRecordMapper.updateByPrimaryKeySelective(packetWithdrawRecord); - return null; - } - - /** - * 驳回提现申请 - * - * @param id - * @param remark - */ - public String reject(String id, String remark) { - PacketWithdrawRecord packetWithdrawRecord = this.packetWithdrawRecordMapper.selectByPrimaryKey(id); - if(packetWithdrawRecord == null){ - logger.error("illegal data, packet withdrad record not exists[id={}]", id); - return "提现申请记录不存在"; - } - if(Constant.WithdrawPayStatus.PENDING.equals(packetWithdrawRecord.getPayStatus()) - ||Constant.WithdrawPayStatus.SCHEDULED.equals(packetWithdrawRecord.getPayStatus()) - ||Constant.WithdrawPayStatus.PAID.equals(packetWithdrawRecord.getPayStatus())){ - logger.error("request is not in progress[id={}]", id); - return "正在支付中或已支付成功"; - } - - packetWithdrawRecord.setRecordStatus(Constant.WithDrawStatus.reject); - packetWithdrawRecord.setRemark(remark); - packetWithdrawRecord.setUpdateTime(Calendar.getInstance().getTime()); - this.packetWithdrawRecordMapper.updateByPrimaryKeySelective(packetWithdrawRecord); - return null; - } - - /** - * 单个转账 - * - * @param id - */ - public String transfer(String id) { - PacketWithdrawRecord packetWithdrawRecord = this.packetWithdrawRecordMapper.selectByPrimaryKey(id); - Long uid = packetWithdrawRecord.getUid(); - Users user = usersService.getUsersByUid(uid); - if(user==null){ - return "转账用户信息不存在,uid="+uid; - } - //校验红包提现条件 - String message = checkPacketTransfer(packetWithdrawRecord); - if(!StringUtils.isEmpty(message)){ - return message; - } - - //实际提现金额为扣除税额后的金额 - Double TaxNum = 0D; - if(packetWithdrawRecord.getTaxNum()!=null){ - TaxNum = packetWithdrawRecord.getTaxNum(); - } - Double withdrawMoney = packetWithdrawRecord.getPacketNum().doubleValue() - TaxNum.doubleValue(); - if(withdrawMoney.doubleValue()<0){ - return "提现金额小于税额,不允许提现"; - } - BigDecimal realMoney = new BigDecimal(withdrawMoney).setScale(0, BigDecimal.ROUND_HALF_UP); - String defDes = user.getAlipayAccountName()+DateTimeUtil.convertDate(Calendar.getInstance().getTime(), DateTimeUtil.SIMPLE_MONTH_DATE_PATTERN)+packetWithdrawRecord.getPacketNum().doubleValue()+"红包提现款"; - //防止description为空导致转账失败 - String description = StringUtils.isBlank(packetWithdrawRecord.getDescription())?defDes:packetWithdrawRecord.getDescription(); - - try { - ITransferService transferService = transferFactory.getChannelService(Constant.WithdrawAccountType.ALIPAY); - TransferPayParam param = TransferPayParam.builder() - .billId(UUIDUitl.get()) - .account(user.getAlipayAccount()) - .accountName(user.getAlipayAccountName()) - .transferAmount(realMoney) - .description(description) - .build(); - TransferPayResult transfer = transferService.transferPay(param); - if (PayConstant.Transfer.RESULT_SUCCESS == transfer.getStatus()) { - packetWithdrawRecord.setPayId(transfer.getPayId()); - packetWithdrawRecord.setPayStatus(Constant.WithdrawPayStatus.PAID); - packetWithdrawRecord.setUpdateTime(Calendar.getInstance().getTime()); - this.packetWithdrawRecordMapper.updateByPrimaryKeySelective(packetWithdrawRecord); - }else{ - packetWithdrawRecord.setPayStatus(Constant.WithdrawPayStatus.FAILED); - packetWithdrawRecord.setPayResult(transfer.getErrorMsg()); - packetWithdrawRecord.setRemark(transfer.getErrorCode()); - packetWithdrawRecord.setUpdateTime(Calendar.getInstance().getTime()); - this.packetWithdrawRecordMapper.updateByPrimaryKeySelective(packetWithdrawRecord); - message = transfer.getErrorMsg(); - } - } catch (Exception e) { - logger.error("红包提现转账失败[id={}, reason={}]", id, e.getMessage(), e); - message = e.getMessage(); - - packetWithdrawRecord.setPayStatus(Constant.WithdrawPayStatus.FAILED); - packetWithdrawRecord.setPayResult("支付失败"); - packetWithdrawRecord.setRemark("发起转账请求失败,详情请查看日志"); - packetWithdrawRecord.setUpdateTime(Calendar.getInstance().getTime()); - this.packetWithdrawRecordMapper.updateByPrimaryKeySelective(packetWithdrawRecord); - } - - return message; - } - - public String batchTransfer(List withdrawIds) { - logger.info("batchTransfer(), withdrawIds={}", withdrawIds); - - StringBuilder builder = new StringBuilder(); - for (String withdrawId : withdrawIds) { - String message = this.transfer(withdrawId); - if (!StringUtils.isEmpty(message)) { - builder.append(message).append("[").append(withdrawId).append("]\n"); - } - } - - return builder.toString(); - } - - private String checkPacketTransfer(PacketWithdrawRecord packetWithdrawRecord){ - if (packetWithdrawRecord == null || (Constant.WithDrawStatus.APPROVED!=packetWithdrawRecord.getRecordStatus().byteValue())) { - return "非批准状态无法转账"; - } - - if (Constant.WithdrawPayStatus.PAID.equals(packetWithdrawRecord.getPayStatus())){ - return "已经支付成功无法再次转账"; - } - - if (Constant.WithdrawPayStatus.SCHEDULED.equals(packetWithdrawRecord.getPayStatus()) || Constant.WithdrawPayStatus.PENDING.equals(packetWithdrawRecord.getPayStatus())){ - return "等待支付完成"; - } - return null; - } - -} diff --git a/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/api/JoinpayTransferController.java b/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/api/JoinpayTransferController.java deleted file mode 100644 index 6a5ab3eb7..000000000 --- a/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/api/JoinpayTransferController.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.accompany.admin.controller.api; - -import com.alibaba.fastjson.JSON; -import com.accompany.admin.service.transfer.JoinpayTransferService; -import com.accompany.admin.service.user.WithdrawAdminService; -import com.accompany.admin.transfer.JoinpayTransferPayNotifyReq; -import com.accompany.admin.transfer.JoinpayTransferPayNotifyResp; -import com.accompany.admin.transfer.TransferNotifyResult; -import com.accompany.business.apppay.constant.PayConstant; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * {这里添加描述} - * - * @author fangchengyan - * @date 2019-12-27 5:03 下午 - */ -@Slf4j -@RestController -@RequestMapping("/api/joinpay/transfer") -public class JoinpayTransferController { - - @Autowired - private WithdrawAdminService withdrawAdminService; - @Autowired - private JoinpayTransferService joinpayTransferService; - - /** - * 汇聚转账结果通知 - */ - @RequestMapping(value = "/notify") - public JoinpayTransferPayNotifyResp notify(@RequestBody JoinpayTransferPayNotifyReq req) { - log.info("收到汇聚转账结果通知:{}", JSON.toJSONString(req)); - TransferNotifyResult result = joinpayTransferService.handlerNotify(req); - return JoinpayTransferPayNotifyResp.builder() - .statusCode(PayConstant.JOINPAY_TRANSFER_SUCCESS) - .message("成功") - .build(); - } - -} diff --git a/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/auditaudio/AuditAudioAdminController.java b/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/auditaudio/AuditAudioAdminController.java deleted file mode 100644 index 4fef256ea..000000000 --- a/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/auditaudio/AuditAudioAdminController.java +++ /dev/null @@ -1,171 +0,0 @@ -package com.accompany.admin.controller.auditaudio; - -import com.alibaba.fastjson.JSON; -import com.accompany.admin.common.BusinessException; -import com.accompany.admin.controller.BaseController; -import com.accompany.admin.service.auditaudio.AuditAudioAdminService; -import com.accompany.admin.vo.AuditAudioAdminVo; -import com.accompany.business.constant.AuditAudioResultEnum; -import com.accompany.business.constant.RiskLevelEnum; -import com.accompany.business.constant.RiskTypeEnum; -import com.accompany.core.exception.ServiceException; -import com.accompany.common.result.BusiResult; -import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.DateTimeUtil; -import org.apache.poi.hssf.usermodel.HSSFRow; -import org.apache.poi.hssf.usermodel.HSSFSheet; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Date; -import java.util.List; -import java.util.Map; - -/** - * 2 * @Author: zhuct - * 3 * @Date: 2019/8/16 11:33 - * 4 - */ -@RestController -@RequestMapping("/admin/audit/audio") -public class AuditAudioAdminController extends BaseController { - @Autowired - private AuditAudioAdminService auditAudioAdminService; - - @RequestMapping(value = "/list", method = RequestMethod.GET) - public void getTopicStatistic(Long erbanNo, Byte riskLevel, Integer riskType, String operatorName, Integer manualAuditResult, - Integer systemAuditResult, Integer pageNum, Integer pageSize, Date beginDate, Date endDate, - Integer startRejectCount, Integer endRejectCount, Integer startScore, Integer endScore) { - - - Map map = this.auditAudioAdminService.getAuditAudioList(erbanNo, riskLevel, riskType, operatorName, manualAuditResult, - systemAuditResult, pageNum, pageSize, beginDate, endDate, startRejectCount, endRejectCount, startScore, endScore); - writeJson(JSON.toJSONString(map)); - } - - @RequestMapping(value = "/handle/pass", method = RequestMethod.POST) - public BusiResult handlePass(String recordId) { - logger.info("handlePass recordId={}", recordId); - try { - auditAudioAdminService.handlePass(recordId, getAdminId()); - } catch (ServiceException e) { - return new BusiResult(BusiStatus.SERVERERROR, e.getBusiStatus().getReasonPhrase()); - } catch (Exception e) { - logger.error("Failed to handlePass.Cause by {}", e.getMessage()); - return new BusiResult(BusiStatus.SERVERERROR); - } - return new BusiResult(BusiStatus.SUCCESS); - } - - @RequestMapping(value = "/handle/unBlock", method = RequestMethod.POST) - public BusiResult handleUnBlock(String recordId){ - logger.info("handleUnBlock recordId={}", recordId); - try { - auditAudioAdminService.handleUnBlock(recordId, getAdminName()); - } catch (BusinessException e) { - return new BusiResult(BusiStatus.SERVERERROR, e.getMessage()); - } catch (Exception e) { - logger.error("Failed to handleUnBlock.Cause by {}", e.getMessage()); - return new BusiResult(BusiStatus.SERVERERROR); - } - return new BusiResult(BusiStatus.SUCCESS); - } - - @RequestMapping(value = "/handle/reject", method = RequestMethod.POST) - public BusiResult handleReject(String recordId, Integer resultValue, Integer riskType) { - logger.info("handleReject recordId={},resultValue={},riskType={}", recordId, resultValue, riskType); - try { - auditAudioAdminService.handleReject(recordId, resultValue, riskType, getAdminName()); - } catch (BusinessException e) { - return new BusiResult(BusiStatus.SERVERERROR, e.getMessage()); - } catch (ServiceException e) { - return new BusiResult(BusiStatus.SERVERERROR, e.getBusiStatus().getReasonPhrase()); - } catch (Exception e) { - logger.error("Failed to handleReject.Cause by {}", e.getMessage()); - return new BusiResult(BusiStatus.SERVERERROR); - } - return new BusiResult(BusiStatus.SUCCESS); - } - - @RequestMapping(value = "/export", method = RequestMethod.GET) - public void export(HttpServletResponse response, Long erbanNo, Byte riskLevel, Integer riskType, String operatorName, Integer manualAuditResult, - Integer systemAuditResult, Date beginDate, Date endDate, Integer startRejectCount, Integer endRejectCount, Integer startScore, Integer endScore) throws IOException { - Map map = auditAudioAdminService.getAuditAudioList(erbanNo, riskLevel, riskType, operatorName, manualAuditResult, - systemAuditResult, 1, 5000, beginDate, endDate, startRejectCount, endRejectCount, startScore, endScore); - - List carRecordStatisticsList = (List) map.get("rows"); - HSSFWorkbook workbook = this.buildWithdrawExcel(carRecordStatisticsList); - // 设置下载时客户端Excel的名称 - String filename = "audit_audio_list.xls"; - response.setContentType("application/vnd.ms-excel"); - response.setHeader("Content-disposition", "attachment;filename=" + filename); - response.setCharacterEncoding("UTF-8"); - OutputStream ouputStream = response.getOutputStream(); - workbook.write(ouputStream); - ouputStream.flush(); - ouputStream.close(); - } - - @RequestMapping(value = "/get/rule", method = RequestMethod.GET) - public BusiResult getMonitorRule() { - try { - Map monitorRule = auditAudioAdminService.getMonitorRule(); - return new BusiResult(monitorRule); - } catch (Exception e) { - logger.error("Failed to getMonitorRule.Cause by {}", e.getMessage()); - return new BusiResult(BusiStatus.SERVERERROR); - } - } - - @RequestMapping(value = "/rule/save", method = RequestMethod.POST) - public BusiResult saveMonitorRule(Byte type, String erbanNos) { - logger.info("saveMonitorRule type={},erbanNos={}", type, erbanNos); - if (type == null) { - return new BusiResult(BusiStatus.PARAMERROR); - } - try { - auditAudioAdminService.saveMonitorRule(type, erbanNos); - } catch (Exception e) { - logger.error("Failed to saveMonitorRule.Cause by {}", e.getMessage()); - return new BusiResult(BusiStatus.SERVERERROR); - } - return new BusiResult(BusiStatus.SUCCESS); - } - - - private HSSFWorkbook buildWithdrawExcel(List voList) { - HSSFWorkbook workbook = new HSSFWorkbook(); - HSSFSheet sheet = workbook.createSheet("音频监控记录"); - - String[] headers = {"房间号", "房间UID", "语音url", "数美判断结果", "违规类型", "人工审核结果", "系统审核结果", "历史违规次数", - "发生时间", "处理时间", "风险值", "操作人"}; - HSSFRow header = sheet.createRow(0); - for (int i = 0; i < headers.length; i++) { - header.createCell(i).setCellValue(headers[i]); - } - int rowNum = 1; - for (AuditAudioAdminVo item : voList) { - HSSFRow row = sheet.createRow(rowNum++); - row.createCell(0).setCellValue(item.getErbanNo()); - row.createCell(1).setCellValue(item.getRoomUid()); - row.createCell(2).setCellValue(item.getAudioUrl()); - row.createCell(3).setCellValue(item.getRiskLevel() == RiskLevelEnum.REJECT.getValue() ? "违规" : "可疑"); - row.createCell(4).setCellValue(item.getRiskType() == null ? "" : RiskTypeEnum.get(item.getRiskType()).getDesc()); - row.createCell(5).setCellValue(item.getManualAuditResult() == null ? "" : AuditAudioResultEnum.get(item.getManualAuditResult()).getDesc()); - row.createCell(6).setCellValue(item.getSystemAuditResult() == null ? "" : AuditAudioResultEnum.get(item.getSystemAuditResult()).getDesc()); - row.createCell(7).setCellValue(item.getRejectCount() == null ? 0 : item.getRejectCount()); - row.createCell(8).setCellValue(item.getCreateTime() == null ? "" : DateTimeUtil.convertDate(new Date(item.getCreateTime()))); - row.createCell(9).setCellValue(item.getUpdateTime() == null ? "" : DateTimeUtil.convertDate(new Date(item.getUpdateTime()))); - row.createCell(10).setCellValue(item.getScore() == null ? "" : item.getScore() + ""); - row.createCell(11).setCellValue(item.getOperatorName() == null ? "" : item.getOperatorName()); - } - return workbook; - } - -} diff --git a/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/system/LoginController.java b/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/system/LoginController.java index 06e636317..3ccf377bc 100644 --- a/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/system/LoginController.java +++ b/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/system/LoginController.java @@ -1,6 +1,7 @@ package com.accompany.admin.controller.system; +import com.accompany.core.util.MD5; import com.aliyuncs.exceptions.ClientException; import com.accompany.admin.common.AdminConstants; import com.accompany.admin.controller.BaseController; @@ -12,7 +13,6 @@ import com.accompany.admin.util.StringUtil; import com.accompany.core.exception.ServiceException; import com.accompany.core.service.common.JedisService; import com.accompany.common.utils.IPUitls; -import com.accompany.business.util.MD5; import com.accompany.common.redis.RedisKey; import com.accompany.common.result.BusiResult; import com.accompany.common.status.BusiStatus; @@ -190,7 +190,7 @@ public class LoginController extends BaseController { } String smsCode = jedisService.get(RedisKey.admin_sms_code.getKey(account)); return Optional.ofNullable(smsCode) - .map(sc -> MD5.getMD5(sc)) + .map(MD5::getMD5) .map(sc -> sc.equals(authCode)) .orElse(false); } @@ -201,25 +201,25 @@ public class LoginController extends BaseController { @RequestMapping("/login/sendSmsCode") @ResponseBody - public BusiResult sendSmsCode(String account, HttpServletRequest request) throws UnsupportedEncodingException, ClientException { + public BusiResult sendSmsCode(String account, HttpServletRequest request) throws UnsupportedEncodingException, ClientException { String realIpAddress = IPUitls.getRealIpAddress(request); logger.info("admin getSmsCode account:{},ip:{}", account, realIpAddress); if (BlankUtil.isBlank(accountFilter(account))) { - return new BusiResult(BusiStatus.ALERT_PARAMETER_ILLEGAL); + return new BusiResult<>(BusiStatus.ALERT_PARAMETER_ILLEGAL); } if (jedisService.exits(RedisKey.admin_account_not_exist.getKey(account))) { - return new BusiResult(BusiStatus.USERNOTEXISTS); + return new BusiResult<>(BusiStatus.USERNOTEXISTS); } if (jedisService.exits(RedisKey.admin_sent_sms.getKey(account))) { - return new BusiResult(BusiStatus.SMS_NOT_EXPIRED3); + return new BusiResult<>(BusiStatus.SMS_NOT_EXPIRED3); } if (adminUserService.checkSendCodeLimit(account)) { - return new BusiResult(BusiStatus.SMS_SENDING_FREQUENCY_TOO_HIGH); + return new BusiResult<>(BusiStatus.SMS_SENDING_FREQUENCY_TOO_HIGH); } try { return adminUserService.sendSmsCode(account, realIpAddress); } catch (ServiceException e) { - return new BusiResult(e.getBusiStatus()); + return new BusiResult<>(e.getBusiStatus()); } } } diff --git a/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/user/UserPasswordModifyController.java b/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/user/UserPasswordModifyController.java index 2379c06fa..9ccdde4f2 100644 --- a/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/user/UserPasswordModifyController.java +++ b/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/user/UserPasswordModifyController.java @@ -5,7 +5,7 @@ import com.accompany.admin.mapper.AdminUserMapper; import com.accompany.admin.model.AdminUser; import com.accompany.admin.service.system.AdminUserService; import com.accompany.admin.service.user.UserPurseAdminService; -import com.accompany.business.util.MD5; +import com.accompany.core.util.MD5; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/withdraw/PacketWithdrawAdminController.java b/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/withdraw/PacketWithdrawAdminController.java deleted file mode 100644 index d130602d0..000000000 --- a/accompany-admin/accompany-admin-web/src/main/java/com/accompany/admin/controller/withdraw/PacketWithdrawAdminController.java +++ /dev/null @@ -1,242 +0,0 @@ -package com.accompany.admin.controller.withdraw; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.accompany.admin.controller.BaseController; -import com.accompany.admin.service.withdraw.PacketWithdrawAdminService; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.util.StringUtils; -import com.accompany.business.vo.PacketWithdrawRecordAdminVo; -import com.accompany.common.constant.Constant; -import com.accompany.common.result.BusiResult; -import com.accompany.common.utils.DateTimeUtil; -import org.apache.poi.hssf.usermodel.HSSFRow; -import org.apache.poi.hssf.usermodel.HSSFSheet; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.CollectionUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * Created by yangziwen on 2018/01/31. - */ -@RestController -@RequestMapping("/admin/packet/withdraw") -public class PacketWithdrawAdminController extends BaseController { - - private static final Logger logger = LoggerFactory.getLogger(PacketWithdrawAdminController.class); - - @Autowired - PacketWithdrawAdminService packetWithdrawAdminService; - - @RequestMapping(value = "/list", method = RequestMethod.GET) - public void getList(String erbanNo, String account, String accountName, String phone, String beginDate, String endDate, Byte status, String payStatus, Integer pageNum, - Integer pageSize) { - BusiResult busiResult = this.packetWithdrawAdminService.getPacketWithdrawList(erbanNo, account, accountName, phone, beginDate, endDate, status, payStatus, pageNum, pageSize); - JSONObject jsonObject = (JSONObject) busiResult.getData(); - writeJson(jsonObject.toJSONString()); - } - - @RequestMapping(value = "/approve", method = RequestMethod.POST) - public void approveWithdraw(@RequestParam(value = "id", required = true) String id) { - logger.debug("approveWithdraw({})", id); - - try { - String result = this.packetWithdrawAdminService.approvePacketWithdraw(id); - if (StringUtils.isEmpty(result)) { - writeJson(true, "操作成功"); - return; - } - - writeJson(false, result); - return; - } catch (Exception e) { - logger.error("Failed to save withdraw. Cause by {}", e.getCause().getMessage()); - } - - writeJson(false, "操作失败"); - } - - @RequestMapping(value = "/batchApprove", method = RequestMethod.POST) - public void batchApproveWithdraw(HttpServletRequest request) { - List ids = getRequestArray(request, "ids", String.class); - logger.debug("batchConfirmPayment(), ids={}", ids); - if (CollectionUtils.isEmpty(ids)) { - writeJson(false, "参数有误"); - return; - } - - Integer success = 0; - for (String id : ids) { - try { - String result = this.packetWithdrawAdminService.approvePacketWithdraw(id); - logger.debug("batchConfirmPayment(), result={}", result); - if (StringUtils.isBlank(result)) { - success++; - } - } catch (Exception e) { - logger.error("Failed to save withdraw {}. Cause by {}", id, e.getCause().getMessage(), e); - } - } - - if (ids.size() == success.intValue()) { - writeJson(true, "全部批准成功"); - return; - } - - if (success.intValue() > 0 && success.intValue() < ids.size()) { - writeJson(true, "部分批准成功"); - return; - } - - writeJson(false, "全部批准失败"); - } - - @RequestMapping(value = "/transfer", method = RequestMethod.POST) - public void transfer(String id) { - try { - String message = this.packetWithdrawAdminService.transfer(id); - if (StringUtils.isEmpty(message)) { - writeJson(true, "转账成功"); - return; - } else { - writeJson(false, message); - } - }catch (ServiceException se){ - writeJson(false,se.getMessage()); - }catch (Exception e){ - writeJson(false,e.getMessage()); - } - } - - @RequestMapping(value = "/batchTransfer", method = RequestMethod.POST) - public void batchTransfer(HttpServletRequest request) { - List ids = getRequestArray(request, "ids", String.class); - logger.debug("batchConfirmPayment(), ids={}", ids); - if (CollectionUtils.isEmpty(ids)) { - writeJson(false, "参数有误"); - return; - } - - try { - String message = this.packetWithdrawAdminService.batchTransfer(ids); - if (!StringUtils.isEmpty(message)) { - writeJson(false, "具体原因请查看备注"); - return; - } - } catch (Exception e) { - logger.error("转账失败[withdrawIds={}]", JSON.toJSONString(ids), e); - writeJson(false, e.getMessage()); - } - - writeJson(true, "已成功转账"); - } - - @RequestMapping(value = "/reject", method = RequestMethod.POST) - public void reject(String withdrawId, String remark) { - logger.info("reject(), id={}, remark={}", withdrawId, remark); - try { - String message = this.packetWithdrawAdminService.reject(withdrawId, remark); - if(StringUtils.isEmpty(message)) { - writeJson(true, "已拒绝提现申请"); - } - writeJson(false,message); - }catch (ServiceException se){ - writeJson(false,se.getMessage()); - }catch (Exception e){ - writeJson(false,e.getMessage()); - } - } - - @RequestMapping(value = "/export", method = RequestMethod.GET) - public void export(HttpServletRequest request, HttpServletResponse response, String erbanNo, String account, String accountName, String payStatus, String phone, - String beginDate, String endDate, Byte status) throws IOException { - BusiResult busiResult = this.packetWithdrawAdminService.getPacketWithdrawList(erbanNo, account, accountName, phone, beginDate, endDate, status, payStatus, 1, 5000); - List list = new ArrayList<>(); - if(busiResult.getData()!=null){ - Map data = (Map)busiResult.getData(); - list =(List)data.get("rows"); - } - HSSFWorkbook workbook = this.buildPacketWithdrawExcel(list); - - // 设置下载时客户端Excel的名称 - String filename = "packet_withdraw_list.xls"; - response.setContentType("application/vnd.ms-excel"); - response.setHeader("Content-disposition", "attachment;filename=" + filename); - response.setCharacterEncoding("UTF-8"); - OutputStream ouputStream = response.getOutputStream(); - workbook.write(ouputStream); - ouputStream.flush(); - ouputStream.close(); - } - - private HSSFWorkbook buildPacketWithdrawExcel(List withdrawList) { - HSSFWorkbook workbook = new HSSFWorkbook(); - HSSFSheet sheet = workbook.createSheet("红包提现申请名单"); - - String[] headers = {"平台号", "手机号码", "支付宝账号", "账号名", "提现金额(元)","税额(元)", "审核状态", "支付状态", "支付结果","申请时间", "备注"}; - HSSFRow header = sheet.createRow(0); - for (int i = 0; i < headers.length; i++) { - header.createCell(i).setCellValue(headers[i]); - } - - int rowNum = 1; - for (PacketWithdrawRecordAdminVo withdraw : withdrawList) { - HSSFRow row = sheet.createRow(rowNum++); - row.createCell(0).setCellValue(withdraw.getErbanNo() == null ? 0 : withdraw.getErbanNo()); - row.createCell(1).setCellValue(withdraw.getPhone() == null ? "" : withdraw.getPhone()); - row.createCell(2).setCellValue(withdraw.getAccount() == null ? "" : withdraw.getAccount()); - row.createCell(3).setCellValue(withdraw.getAccountName() == null ? "" : withdraw.getAccountName()); - row.createCell(4).setCellValue(String.valueOf(withdraw.getPacketNum()==null?0:withdraw.getPacketNum())); - row.createCell(5).setCellValue(String.valueOf(withdraw.getTaxNum()==null?0:withdraw.getTaxNum())); - String recordStatus = ""; - if(withdraw.getRecordStatus()!=null) { - if (withdraw.getRecordStatus().byteValue()==Constant.WithDrawStatus.deleted) { - recordStatus = "作废"; - } else if (withdraw.getRecordStatus().byteValue()==Constant.WithDrawStatus.ing) { - recordStatus = "申请中"; - } else if (withdraw.getRecordStatus().byteValue()==Constant.WithDrawStatus.APPROVED) { - recordStatus = "已批准"; - } else if (withdraw.getRecordStatus().byteValue()==Constant.WithDrawStatus.reject) { - recordStatus = "已驳回"; - } - } - row.createCell(6).setCellValue(recordStatus); - - String payStatus = ""; - if (withdraw.getPayStatus() != null) { - if (Constant.WithdrawPayStatus.PENDING.equals(withdraw.getPayStatus())) { - payStatus = "申请中"; - } else if (Constant.WithdrawPayStatus.SCHEDULED.equals(withdraw.getPayStatus())) { - payStatus = "计划中"; - } else if (Constant.WithdrawPayStatus.PAID.equals(withdraw.getPayStatus())) { - payStatus = "已支付"; - } else if (Constant.WithdrawPayStatus.FAILED.equals(withdraw.getPayStatus())) { - payStatus = "支付失败"; - } else { - payStatus = "支付出错"; - } - } - row.createCell(7).setCellValue(payStatus); - row.createCell(8).setCellValue(withdraw.getPayResult() == null ? "" : withdraw.getPayResult()); - row.createCell(9).setCellValue(DateTimeUtil.convertDate(withdraw.getCreateTime())); - row.createCell(10).setCellValue(withdraw.getRemark() == null ? "" : withdraw.getRemark()); - } - - return workbook; - } - -} \ No newline at end of file diff --git a/accompany-admin/accompany-flow-team-admin-web/src/main/java/com/accompany/flowteam/admin/controller/system/LoginController.java b/accompany-admin/accompany-flow-team-admin-web/src/main/java/com/accompany/flowteam/admin/controller/system/LoginController.java index 471cd047a..1f163a135 100644 --- a/accompany-admin/accompany-flow-team-admin-web/src/main/java/com/accompany/flowteam/admin/controller/system/LoginController.java +++ b/accompany-admin/accompany-flow-team-admin-web/src/main/java/com/accompany/flowteam/admin/controller/system/LoginController.java @@ -4,13 +4,13 @@ package com.accompany.flowteam.admin.controller.system; import com.accompany.admin.common.AdminConstants; import com.accompany.admin.frame.Scope; import com.accompany.admin.util.StringUtil; -import com.accompany.business.util.MD5; import com.accompany.common.redis.RedisKey; import com.accompany.common.result.BusiResult; import com.accompany.common.status.BusiStatus; import com.accompany.common.utils.*; import com.accompany.core.exception.ServiceException; import com.accompany.core.service.common.JedisService; +import com.accompany.core.util.MD5; import com.accompany.flowteam.admin.common.FlowTeamAdminConstants; import com.accompany.flowteam.admin.controller.BaseController; import com.accompany.flowteam.admin.service.FlowTeamAdminUserService; @@ -189,7 +189,7 @@ public class LoginController extends BaseController { } String smsCode = jedisService.get(RedisKey.flow_team_admin_sms_code.getKey(account)); return Optional.ofNullable(smsCode) - .map(sc -> MD5.getMD5(sc)) + .map(MD5::getMD5) .map(sc -> sc.equals(authCode)) .orElse(false); } diff --git a/accompany-base/accompany-common/src/main/java/com/accompany/common/config/AuditMediaConfig.java b/accompany-base/accompany-common/src/main/java/com/accompany/common/config/AuditMediaConfig.java deleted file mode 100644 index 8b161ba2c..000000000 --- a/accompany-base/accompany-common/src/main/java/com/accompany/common/config/AuditMediaConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.accompany.common.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -@Component -@Lazy(value = false) -@Order(-1) -@ConfigurationProperties(prefix = "audit.media") -public class AuditMediaConfig { - - public static String accessKey; - - public static String appId; - - public static String url; - - public static String callBackUrl; - - public static String queryUrl; - - public static String closeUrl; - - public void setAccessKey(String accessKey) { - AuditMediaConfig.accessKey = accessKey; - } - - public void setAppId(String appId) { - AuditMediaConfig.appId = appId; - } - - public void setUrl(String url) { - AuditMediaConfig.url = url; - } - - public void setCallBackUrl(String callBackUrl) { - AuditMediaConfig.callBackUrl = callBackUrl; - } - - public void setQueryUrl(String queryUrl) { - AuditMediaConfig.queryUrl = queryUrl; - } - - public void setCloseUrl(String closeUrl) { - AuditMediaConfig.closeUrl = closeUrl; - } -} diff --git a/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/BillTypeConstant.java b/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/BillTypeConstant.java deleted file mode 100644 index 164c4c401..000000000 --- a/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/BillTypeConstant.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.accompany.common.constant; - -/** - * @author yangziwen - * @description 账单类型常量类. - * @date 2018/3/19 14:42 - */ -public class BillTypeConstant { - - // 充值 - public static final Byte IN_RECHARGE = 1; - - // 提现 - public static final Byte OUT_WITHDRAW = 2; - - // 拍卖 - public static final Byte OUT_AUCTION = 3; - - // 订单收入 - public static final Byte IN_ORDER_INCOME = 4; - - // 刷礼物支出 - public static final Byte OUT_GIFT_PAY = 5; - - // 收礼物收入 - public static final Byte IN_GIFT_INCOME = 6; - - // 发红包支出 - public static final Byte OUT_RED_PACKET_PAY = 7; - - // 收红包收入 - public static final Byte IN_RED_PACKET_INCOME = 8; - - // 房主佣金收入 - public static final Byte IN_ROOM_OWNER_COMMISSION = 9; - - // 注册送金币奖励 - public static final Byte IN_REGISTER_REWARD = 10; - - // 分享送金币奖励 - public static final Byte IN_SHARE_REWARD = 11; - - // 官方赠送金币 - public static final Byte IN_OFFICAL_DONATE = 12; - - // 关注公众号奖励金币 - public static final Byte IN_FOLLOW_OFFICAL_ACCOUNT_REWARD = 13; - - // 钻石兑换金币支出 - public static final Byte OUT_EXCHANGE_DIAMOND_TO_GOLD_PAY = 14; - - // 钻石兑换金币收入 - public static final Byte IN_EXCHANGE_DIAMOND_TO_GOLD_INCOME = 15; - - // 万圣节活动奖励 - public static final Byte IN_HALLOWEEN_REWARD = 16; - - // 活动奖励 - public static final Byte IN_ACTIVITY_REWARD = 17; - - // 打款至公司账号充值 - public static final Byte IN_RECHARGE_BY_COMPANY_ACCOUNT = 20; - - // 兑换码兑换金币 - public static final Byte IN_REDEEM_CODE_EXCHANGE = 21; - - // 促销活动得金币 - public static final Byte IN_LUCKY_DRAW = 23; - - // 发送的 - public static Byte bonusPerDaySend = 24; - - // 钻石回馈账单 - public static Byte bonusPerDayRecv = 25; - - // 开通贵族 - public static final Byte OUT_OPEN_NOBLE = 26; - - // 续费贵族 - public static Byte OUT_RENEW_NOBLE = 27; - - //public static Byte roomNoble = 28; - // 房间内开通贵族分成 - public static final Byte IN_ROOM_NOBLE_COMMISSION = 28; - - //public static Byte openNobleReturn = 29; - // 开通贵族返还 - public static final Byte IN_OPEN_NOBLE_RETURN = 29; - - //public static Byte renewNobleReturn = 30; - // 续费贵族 - public static final Byte IN_RENEW_NOBLE_RETURN = 30; - - //public static Byte purchaseCarGoods = 31; - // 购买座驾 - public static final Byte OUT_BUY_CAR_GOODS = 31; - - //public static Byte renewCarGoods = 32; - // 续费座驾 - public static Byte OUT_RENEW_CAR_GOODS = 32; - -} diff --git a/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/Constant.java b/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/Constant.java index a687a0150..15dcbe9bb 100644 --- a/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/Constant.java +++ b/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/Constant.java @@ -1285,16 +1285,6 @@ public class Constant { */ public static final String ACTIVITY_ANNIVERSARY_LOTTERY = "activity_anniversary_lottery"; - /** - * 青少年模式充值开关 - */ - public static final String TEEN_CHARGE_SWITCH = "teen_charge_switch"; - - /** - * 青少年模式提现开关 - */ - public static final String TEEN_WITHDRAWAL_SWITCH = "teen_withdrawal_switch"; - /** * 实名未成年人充值开关 */ diff --git a/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/FirstPageConstant.java b/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/FirstPageConstant.java deleted file mode 100644 index 570394488..000000000 --- a/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/FirstPageConstant.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.accompany.common.constant; - -/** - * Created By LeeNana on 2019/12/25. - */ -public class FirstPageConstant { - public static final Integer HALF_HOUR_RANKS_ROOM_NUM = 1; -} diff --git a/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/MQConstant.java b/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/MQConstant.java deleted file mode 100644 index 1728eba7e..000000000 --- a/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/MQConstant.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.accompany.common.constant; - -/** - * @author yangziwen - * @description - * @date 2018/3/19 17:45 - */ -public class MQConstant { - - // 赠送礼物队列 - public static final String QUEUE_GIFT = "gift-queue"; - - // 开通或者续费规则队列 - public static final String QUEUE_NOBLE = "noble-queue"; - - // 魔法表情队列名 - public static final String QUEUE_MAGIC_GIFT = "magic-gift-queue"; - -} diff --git a/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/SexType.java b/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/SexType.java deleted file mode 100644 index 9ab724416..000000000 --- a/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/SexType.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.accompany.common.constant; - -/** - *性别常量 - */ -public enum SexType { - - MAEL(1), //男性 - - FEMAEL(2); //女性 - - Integer type; - - SexType(Integer type) { - this.type = type; - } - - public byte getType() { - return type.byteValue(); - } - - - - -} diff --git a/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/WeXinPayTypeEnum.java b/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/WeXinPayTypeEnum.java deleted file mode 100644 index c175d3145..000000000 --- a/accompany-base/accompany-common/src/main/java/com/accompany/common/constant/WeXinPayTypeEnum.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.accompany.common.constant; - -/** - * 微信开启的支付方式 - * - * @author linuxea - * @date 2019/8/8 16:02 - */ -public enum WeXinPayTypeEnum { - - /** - * app 支付 - */ - APP, - /** - * 小程序支付 - */ - MINI_APP -} diff --git a/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/HttpUtils.java b/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/HttpUtils.java deleted file mode 100644 index 94b9dfc6f..000000000 --- a/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/HttpUtils.java +++ /dev/null @@ -1,334 +0,0 @@ -package com.accompany.common.wx; - -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpException; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; -import org.apache.commons.httpclient.methods.GetMethod; -import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.*; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -/** - * HTTP工具类 - * - * @author lixiangyang - * - */ -public class HttpUtils { - - private static Log log = LogFactory.getLog ( HttpUtils.class ); - - /** - * 定义编码格式 UTF-8 - */ - public static final String URL_PARAM_DECODECHARSET_UTF8 = "UTF-8"; - - /** - * 定义编码格式 GBK - */ - public static final String URL_PARAM_DECODECHARSET_GBK = "GBK"; - - private static final String URL_PARAM_CONNECT_FLAG = "&"; - - private static final String EMPTY = ""; - - private static MultiThreadedHttpConnectionManager connectionManager = null; - - private static int connectionTimeOut = 25000; - - private static int socketTimeOut = 25000; - - private static int maxConnectionPerHost = 20; - - private static int maxTotalConnections = 20; - - private static HttpClient client; - - static { - connectionManager = new MultiThreadedHttpConnectionManager ( ); - connectionManager.getParams ( ).setConnectionTimeout ( connectionTimeOut ); - connectionManager.getParams ( ).setSoTimeout ( socketTimeOut ); - connectionManager.getParams ( ).setDefaultMaxConnectionsPerHost ( maxConnectionPerHost ); - connectionManager.getParams ( ).setMaxTotalConnections ( maxTotalConnections ); - client = new HttpClient ( connectionManager ); - } - - /** - * POST方式提交数据 - * @param url - * 待请求的URL - * @param params - * 要提交的数据 - * @param enc - * 编码 - * @return - * 响应结果 - * @throws IOException - * IO异常 - */ - public static String URLPost ( String url, Map params, String enc ) { - - String response = EMPTY; - PostMethod postMethod = null; - try { - postMethod = new PostMethod ( url ); - postMethod.setRequestHeader ( "Content-Type", "application/x-www-form-urlencoded;charset=" + enc ); - //将表单的值放入postMethod中 - Set keySet = params.keySet ( ); - for ( String key : keySet ) { - String value = params.get ( key ); - postMethod.addParameter ( key, value ); - } - //执行postMethod - int statusCode = client.executeMethod ( postMethod ); - if ( statusCode == HttpStatus.SC_OK ) { - response = postMethod.getResponseBodyAsString ( ); - } else { - log.error ( "响应状态码 = " + postMethod.getStatusCode ( ) ); - } - } catch ( HttpException e ) { - log.error ( "发生致命的异常,可能是协议不对或者返回的内容有问题", e ); - e.printStackTrace ( ); - } catch ( IOException e ) { - log.error ( "发生网络异常", e ); - e.printStackTrace ( ); - } finally { - if ( postMethod != null ) { - postMethod.releaseConnection ( ); - postMethod = null; - } - } - - return response; - } - - /** - * GET方式提交数据 - * @param url - * 待请求的URL - * @param params - * 要提交的数据 - * @param enc - * 编码 - * @return - * 响应结果 - * @throws IOException - * IO异常 - */ - public static String URLGet ( String url, Map params, String enc ) { - - String response = EMPTY; - GetMethod getMethod = null; - StringBuffer strtTotalURL = new StringBuffer ( EMPTY ); - - if ( strtTotalURL.indexOf ( "?" ) == - 1 ) { - strtTotalURL.append ( url ).append ( "?" ).append ( getUrl ( params, enc ) ); - } else { - strtTotalURL.append ( url ).append ( "&" ).append ( getUrl ( params, enc ) ); - } - log.debug ( "GET请求URL = \n" + strtTotalURL.toString ( ) ); - - try { - getMethod = new GetMethod ( strtTotalURL.toString ( ) ); - getMethod.setRequestHeader ( "Content-Type", "application/x-www-form-urlencoded;charset=" + enc ); - //执行getMethod - int statusCode = client.executeMethod ( getMethod ); - if ( statusCode == HttpStatus.SC_OK ) { - response = getMethod.getResponseBodyAsString ( ); - } else { - log.debug ( "响应状态码 = " + getMethod.getStatusCode ( ) ); - } - } catch ( HttpException e ) { - log.error ( "发生致命的异常,可能是协议不对或者返回的内容有问题", e ); - e.printStackTrace ( ); - } catch ( IOException e ) { - log.error ( "发生网络异常", e ); - e.printStackTrace ( ); - } finally { - if ( getMethod != null ) { - getMethod.releaseConnection ( ); - getMethod = null; - } - } - - return response; - } - - /** - * 据Map生成URL字符串 - * @param map - * Map - * @param valueEnc - * URL编码 - * @return - * URL - */ - private static String getUrl ( Map map, String valueEnc ) { - - if ( null == map || map.keySet ( ).size ( ) == 0 ) { - return ( EMPTY ); - } - StringBuffer url = new StringBuffer ( ); - Set keys = map.keySet ( ); - for ( Iterator it = keys.iterator ( ) ; it.hasNext ( ) ; ) { - String key = it.next ( ); - if ( map.containsKey ( key ) ) { - String val = map.get ( key ); - String str = val != null ? val : EMPTY; - try { - str = URLEncoder.encode ( str, valueEnc ); - } catch ( UnsupportedEncodingException e ) { - e.printStackTrace ( ); - } - url.append ( key ).append ( "=" ).append ( str ).append ( URL_PARAM_CONNECT_FLAG ); - } - } - String strURL = EMPTY; - strURL = url.toString ( ); - if ( URL_PARAM_CONNECT_FLAG.equals ( EMPTY + strURL.charAt ( strURL.length ( ) - 1 ) ) ) { - strURL = strURL.substring ( 0, strURL.length ( ) - 1 ); - } - return ( strURL ); - } - - - /** - * 向指定URL发送GET方法的请求 - * - * @param url - * 发送请求的URL - * @param param - * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 - * @return URL 所代表远程资源的响应结果 - */ - public static String sendGet ( String url, String param ) { - String result = ""; - BufferedReader in = null; - try { - //自带“?” - String urlNameString = url + "?" + param; - //创建URL对象 - URL realUrl = new URL ( urlNameString ); - // 打开和URL之间的连接 - URLConnection connection = realUrl.openConnection ( ); - // 设置通用的请求属性 - connection.setRequestProperty ( "accept", "*/*" ); - connection.setRequestProperty ( "connection", "Keep-Alive" ); - connection.setRequestProperty ( "user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)" ); - // 建立实际的连接 - connection.connect ( ); - // 获取所有响应头字段 - - /* - * Map> map = connection.getHeaderFields(); // - * 遍历所有的响应头字段 for (String key : map.keySet()) { //禁止数据 - * System.out.println(key + "--->" + map.get(key)); } - */ - // 定义 BufferedReader输入流来读取URL的响应 - in = new BufferedReader ( new InputStreamReader ( connection.getInputStream ( ) ) ); - String line; - while ( ( line = in.readLine ( ) ) != null ) { - result += line; - } - } catch ( Exception e ) { - System.out.println ( "发送GET请求出现异常!" + e ); - e.printStackTrace ( ); - } - // 使用finally块来关闭输入流 - finally { - try { - if ( in != null ) { - in.close ( ); - } - } catch ( Exception e2 ) { - e2.printStackTrace ( ); - } - } - return result; - } - - /** - * 向指定 URL 发送POST方法的请求 - * - * @param url - * 发送请求的 URL - * @param param - * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 - * @return 所代表远程资源的响应结果 - */ - public static String sendPost ( String url, String param ) { - PrintWriter out = null; - BufferedReader in = null; - String result = ""; - 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.setRequestProperty ( "charset" , "UTF-8"); - // 发送POST请求必须设置如下两行 - conn.setDoOutput ( true ); - conn.setDoInput ( true ); - // 获取URLConnection对象对应的输出流 - out = new PrintWriter ( conn.getOutputStream ( ) ); - // 发送请求参数 - out.print ( param ); - // flush输出流的缓冲 - out.flush ( ); - // 定义BufferedReader输入流来读取URL的响应 - in = new BufferedReader ( new InputStreamReader ( conn.getInputStream ( ) ) ); - String line; - while ( ( line = in.readLine ( ) ) != null ) { - result += line; - } - } catch ( Exception e ) { - System.out.println ( "发送 POST 请求出现异常!" + e ); - e.printStackTrace ( ); - } - // 使用finally块来关闭输出流、输入流 - finally { - try { - if ( out != null ) { - out.close ( ); - } - if ( in != null ) { - in.close ( ); - } - } catch ( IOException ex ) { - ex.printStackTrace ( ); - } - } - return result; - - } - - - public static void main ( String[] args ) throws Exception { - - /*Map map = new HashMap <> ( ); - map.put ( "appid", "wx009d793f92c24eec" ); - map.put ( "mch_id", "1484701192" ); - map.put ( "nonce_str", PayUtil.getRandomStringByLength(16) ); - map.put ( "out_trade_no", "20150806125346" ); - map.put ( "sign", PayUtil.getSign ( map ) ); - //以XML格式的数据发送 - String request = XMLParser.getXMLFromMap (map ); - System.out.println (request ); - String data = sendPost ( "https://api.mch.weixin.qq.com/pay/orderquery", request); - System.out.println ( data );*/ - - } - -} \ No newline at end of file diff --git a/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/IServiceRequest.java b/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/IServiceRequest.java deleted file mode 100644 index 29ee0490a..000000000 --- a/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/IServiceRequest.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.accompany.common.wx; - -import java.io.IOException; -import java.security.KeyManagementException; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.UnrecoverableKeyException; - -public interface IServiceRequest { - String sendPost(String var1, Object var2) throws UnrecoverableKeyException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, IOException; -} \ No newline at end of file diff --git a/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/MD5.java b/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/MD5.java deleted file mode 100644 index b286238b0..000000000 --- a/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/MD5.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.accompany.common.wx; - - -import java.security.MessageDigest; - -/** - * User: rizenguo - * Date: 2014/10/23 - * Time: 15:43 - */ -public class MD5 { - private final static String[] hexDigits = {"0", "1", "2", "3", "4", "5", "6", "7", - "8", "9", "a", "b", "c", "d", "e", "f"}; - - /** - * 转换字节数组为16进制字串 - * @param b 字节数组 - * @return 16进制字串 - */ - public static String byteArrayToHexString(byte[] b) { - StringBuilder resultSb = new StringBuilder(); - for (byte aB : b) { - resultSb.append(byteToHexString(aB)); - } - return resultSb.toString(); - } - - /** - * 转换byte到16进制 - * @param b 要转换的byte - * @return 16进制格式 - */ - private static String byteToHexString(byte b) { - int n = b; - if (n < 0) { - n = 256 + n; - } - int d1 = n / 16; - int d2 = n % 16; - return hexDigits[d1] + hexDigits[d2]; - } - - /** - * MD5编码 - * @param origin 原始字符串 - * @return 经过MD5加密之后的结果 - */ - public static String MD5Encode(String origin) { - String resultString = null; - try { - resultString = origin; - MessageDigest md = MessageDigest.getInstance("MD5"); - md.update(resultString.getBytes("UTF-8")); - resultString = byteArrayToHexString(md.digest()); - } catch (Exception e) { - e.printStackTrace(); - } - return resultString; - } - public static String MD5Encode(String origin, String charsetname) { - String resultString = null; - try { - resultString = new String(origin); - MessageDigest md = MessageDigest.getInstance("MD5"); - if (charsetname == null || "".equals(charsetname)) - resultString = byteArrayToHexString(md.digest(resultString - .getBytes())); - else - resultString = byteArrayToHexString(md.digest(resultString - .getBytes(charsetname))); - } catch (Exception exception) { - } - return resultString; - } - -} diff --git a/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/PayUtil.java b/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/PayUtil.java deleted file mode 100644 index 5cc2f68c1..000000000 --- a/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/PayUtil.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.accompany.common.wx; - - -import org.xml.sax.SAXException; - -import javax.xml.parsers.ParserConfigurationException; -import java.io.IOException; -import java.util.*; - -public class PayUtil { - public static String getTime_stamp ( ) { - /*String stamp="1472275204"; - *//*Date d=new Date(); - d.getTime();*//* - return stamp;*/ - - String stamp = String.valueOf ( new Date ( ).getTime ( ) ); - return stamp; - - } - - public static String getRandomStringByLength ( int len ) { - String base = "abcdefghijklmnopqrstuvwxyz0123456789"; - Random random = new Random ( ); - StringBuffer sb = new StringBuffer ( ); - for ( int i = 0 ; i < len ; i++ ) { - int number = random.nextInt ( base.length ( ) ); - sb.append ( base.charAt ( number ) ); - } - return sb.toString ( ); - } - - public static String getSign ( Map map ,String wxPayKey) { - ArrayList list = new ArrayList ( ); - for ( Map.Entry entry : map.entrySet ( ) ) { - if ( entry.getValue ( ) != "" && ! entry.toString ( ).equals ( "return_code" ) && ! entry.toString ( ).equals ( "return_msg" ) && ! entry.toString ( ).equals ( "result_code" ) ) { -// System.out.println ( ); - list.add ( entry.getKey ( ) + "=" + entry.getValue ( ) + "&" ); - } - } - int size = list.size ( ); - String[] arrayToSort = list.toArray ( new String[ size ] ); - Arrays.sort ( arrayToSort, String.CASE_INSENSITIVE_ORDER ); - StringBuilder sb = new StringBuilder ( ); - for ( int i = 0 ; i < size ; i++ ) { - sb.append ( arrayToSort[ i ] ); - } - - String result = sb.toString ( ); - //key 该方法key的需要根据你当前公众号的key进行修改 - result += "key="+wxPayKey; - //Util.log("Sign Before MD5:" + result); - result = MD5.MD5Encode ( result ).toUpperCase ( ); - //Util.log("Sign Result:" + result); - return result; - } - - public static void main ( String[] args ) throws IOException, SAXException, ParserConfigurationException { - - /*String string = "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - *//* " \n" +*//* - " \n" + - " \n" + - " 1\n" + - " \n" + - " \n" + - " \n" + - ""; - - Map map = XMLParser.getMapFromXML ( string ); - String s = PayUtil.getSign ( map ); - System.out.println (s );//"0C1D1ADD0DD75F9F90D6CF48C90E5AB0"*/ - - - - } - -} diff --git a/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/Util.java b/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/Util.java deleted file mode 100644 index 86430d99e..000000000 --- a/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/Util.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.accompany.common.wx; - -import com.thoughtworks.xstream.XStream; - -import java.io.*; -import java.lang.reflect.Field; -import java.net.InetAddress; -import java.util.Map; - -public class Util { - - //打log用 - //private static Log logger = new Log(log) - - /** - * 通过反射的方式遍历对象的属性和属性值,方便调试 - * - * @param o 要遍历的对象 - * @throws Exception - */ - public static void reflect(Object o) throws Exception { - Class cls = o.getClass(); - Field[] fields = cls.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) { - Field f = fields[i]; - f.setAccessible(true); - Util.log(f.getName() + " -> " + f.get(o)); - } - } - - public static byte[] readInput(InputStream in) throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - int len = 0; - byte[] buffer = new byte[1024]; - while ((len = in.read(buffer)) > 0) { - out.write(buffer, 0, len); - } - out.close(); - in.close(); - return out.toByteArray(); - } - - public static String inputStreamToString(InputStream is) throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - int i; - while ((i = is.read()) != -1) { - baos.write(i); - } - return baos.toString(); - } - - - public static InputStream getStringStream(String sInputString) throws UnsupportedEncodingException { - ByteArrayInputStream tInputStringStream = null; - if (sInputString != null && !sInputString.trim().equals("")) { - tInputStringStream = new ByteArrayInputStream(sInputString.getBytes("UTF-8")); - } - return tInputStringStream; - } - - public static Object getObjectFromXML(String xml, Class tClass) { - //将从API返回的XML数据映射到Java对象 - XStream xStreamForResponseData = new XStream(); - xStreamForResponseData.alias("xml", tClass); - xStreamForResponseData.ignoreUnknownElements();//暂时忽略掉一些新增的字段 - return xStreamForResponseData.fromXML(xml); - } - - public static String getStringFromMap( Map map, String key, String defaultValue) { - if (key == "" || key == null) { - return defaultValue; - } - String result = (String) map.get(key); - if (result == null) { - return defaultValue; - } else { - return result; - } - } - - public static int getIntFromMap(Map map, String key) { - if (key == "" || key == null) { - return 0; - } - if (map.get(key) == null) { - return 0; - } - return Integer.parseInt((String) map.get(key)); - } - - /** - * 打log接口 - * @param log 要打印的log字符串 - * @return 返回log - */ - public static String log(Object log){ - // logger.i(log.toString()); - System.out.println(log); - return log.toString(); - } - - /** - * 获取ip - * @return - * @throws IOException - */ - public static String getIpAdd()throws IOException { - InetAddress[] inetAdds = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName()); - return inetAdds[0].getHostAddress(); - } - - /** - * 读取本地的xml数据,一般用来自测用 - * @param localPath 本地xml文件路径 - * @return 读到的xml字符串 - */ - public static String getLocalXMLString(String localPath) throws IOException { - return Util.inputStreamToString( Util.class.getResourceAsStream(localPath)); - } - - -} diff --git a/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/XMLParser.java b/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/XMLParser.java deleted file mode 100644 index 7f8acdb7b..000000000 --- a/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/XMLParser.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.accompany.common.wx; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - - -/** - * User: rizenguo - * Date: 2014/11/1 - * Time: 14:06 - */ -public class XMLParser { - - /** - * 修复XXE漏洞 - * @return - * @throws ParserConfigurationException - */ - private static DocumentBuilderFactory getSafeDocumentBuilderFactory() throws ParserConfigurationException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - String reature = "http://apache.org/xml/features/disallow-doctype-decl"; - factory.setFeature(reature, true); - - // If you can't completely disable DTDs, then at least do the following: - // Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-general-entities - // Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-general-entities - // JDK7+ - http://xml.org/sax/features/external-general-entities - reature = "http://xml.org/sax/features/external-general-entities"; - factory.setFeature(reature, false); - - // Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-parameter-entities - // Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-parameter-entities - // JDK7+ - http://xml.org/sax/features/external-parameter-entities - reature = "http://xml.org/sax/features/external-parameter-entities"; - factory.setFeature(reature, false); - - // Disable external DTDs as well - reature = "http://apache.org/xml/features/nonvalidating/load-external-dtd"; - factory.setFeature(reature, false); - - // and these as well, per Timothy Morgan's 2014 paper: "XML Schema, DTD, and Entity Attacks" - factory.setXIncludeAware(false); - factory.setExpandEntityReferences(false); - - return factory; - } - - public static Map getMapFromXML(String xmlString) throws ParserConfigurationException, IOException, SAXException { - - //这里用Dom的方式解析回包的最主要目的是防止API新增回包字段 - DocumentBuilderFactory factory = XMLParser.getSafeDocumentBuilderFactory(); - DocumentBuilder builder = factory.newDocumentBuilder(); - InputStream is = Util.getStringStream(xmlString); - Document document = builder.parse(is); - - //获取到document里面的全部结点 - NodeList allNodes = document.getFirstChild().getChildNodes(); - Node node; - Map map = new HashMap(); - int i=0; - while (i < allNodes.getLength()) { - node = allNodes.item(i); - if(node instanceof Element){ - map.put(node.getNodeName(),node.getTextContent()); - } - i++; - } - return map; - - } - - - - public static String getXMLFromMap(Map map)throws Exception{ - StringBuffer sb = new StringBuffer(); - sb.append(""); - - Set set = map.keySet(); - Iterator it = set.iterator(); - while(it.hasNext()){ - String key = it.next(); - sb.append("<"+key+">").append(map.get(key)).append(""); - } - - sb.append(""); - return sb.toString(); - } - - - -} \ No newline at end of file diff --git a/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/result/WxAccessTokenRet.java b/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/result/WxAccessTokenRet.java deleted file mode 100644 index af0a59faf..000000000 --- a/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/result/WxAccessTokenRet.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.accompany.common.wx.result; - -/** - * Created by liuguofu on 2017/7/10. - */ -public class WxAccessTokenRet { - private String access_token;// 获取到的凭证 - private int expires_in;//凭证有效时间,单位:秒 - private int errcode; - private String errmsg; - public String getAccess_token() { - return access_token; - } - - public void setAccess_token(String access_token) { - this.access_token = access_token; - } - - public int getErrcode() { - return errcode; - } - - public void setErrcode(int errcode) { - this.errcode = errcode; - } - - public String getErrmsg() { - return errmsg; - } - - public void setErrmsg(String errmsg) { - this.errmsg = errmsg; - } - - public int getExpires_in() { - return expires_in; - } - - public void setExpires_in(int expires_in) { - this.expires_in = expires_in; - } -} diff --git a/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/result/WxTicketRet.java b/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/result/WxTicketRet.java deleted file mode 100644 index bf2c34eeb..000000000 --- a/accompany-base/accompany-common/src/main/java/com/accompany/common/wx/result/WxTicketRet.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.accompany.common.wx.result; - -/** - * Created by liuguofu on 2017/7/10. - */ -public class WxTicketRet { - private String ticket;// 获取到的ticket - private int expires_in;//凭证有效时间,单位:秒 - private int errcode; - private String errmsg; - - public String getTicket() { - return ticket; - } - - public void setTicket(String ticket) { - this.ticket = ticket; - } - - public int getErrcode() { - return errcode; - } - - public void setErrcode(int errcode) { - this.errcode = errcode; - } - - public String getErrmsg() { - return errmsg; - } - - public void setErrmsg(String errmsg) { - this.errmsg = errmsg; - } - - public int getExpires_in() { - return expires_in; - } - - public void setExpires_in(int expires_in) { - this.expires_in = expires_in; - } -} diff --git a/accompany-base/accompany-core/src/main/java/com/accompany/core/model/UserTeenConf.java b/accompany-base/accompany-core/src/main/java/com/accompany/core/model/UserTeenConf.java deleted file mode 100644 index 6dccb93d8..000000000 --- a/accompany-base/accompany-core/src/main/java/com/accompany/core/model/UserTeenConf.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.accompany.core.model; - -import lombok.Data; - -@Data -public class UserTeenConf { - /** - * 每日限额充值元 - */ - private Integer limitEveryDay; -} diff --git a/accompany-base/accompany-core/src/main/java/com/accompany/core/service/user/UsersBaseService.java b/accompany-base/accompany-core/src/main/java/com/accompany/core/service/user/UsersBaseService.java index 2b5a870ef..d8c408c52 100644 --- a/accompany-base/accompany-core/src/main/java/com/accompany/core/service/user/UsersBaseService.java +++ b/accompany-base/accompany-core/src/main/java/com/accompany/core/service/user/UsersBaseService.java @@ -5,7 +5,6 @@ import com.accompany.common.constant.Constant; import com.accompany.common.redis.RedisKey; import com.accompany.common.utils.*; import com.accompany.core.model.Account; -import com.accompany.core.model.UserTeenConf; import com.accompany.core.model.Users; import com.accompany.core.model.UsersExample; import com.accompany.core.mybatismapper.AccountMapper; @@ -508,25 +507,6 @@ public class UsersBaseService extends BaseService { return usersList; } - - public UserTeenConf getUserTeenConfig() { - UserTeenConf userTeenConf = JSONObject.parseObject(sysConfService.getDefaultSysConfValueById(Constant.SysConfId.USER_TEEN, "{}"), UserTeenConf.class); - if (userTeenConf.getLimitEveryDay() == null) { - userTeenConf.setLimitEveryDay(50); - } - return userTeenConf; - } - - public Boolean getTeenChargeSwitch(){ - Boolean teenChargeSwitch = Boolean.valueOf(sysConfService.getDefaultSysConfValueById(Constant.SysConfId.TEEN_CHARGE_SWITCH, "true")); - return teenChargeSwitch; - } - - public Boolean getTeenWithdrawalSwitch(){ - Boolean teenWithdrawalSwitch = Boolean.valueOf(sysConfService.getDefaultSysConfValueById(Constant.SysConfId.TEEN_WITHDRAWAL_SWITCH, "true")); - return teenWithdrawalSwitch; - } - /** * 获取客服uid */ diff --git a/accompany-base/accompany-core/src/main/java/com/accompany/core/util/MD5.java b/accompany-base/accompany-core/src/main/java/com/accompany/core/util/MD5.java index c4e91152e..27df7c937 100644 --- a/accompany-base/accompany-core/src/main/java/com/accompany/core/util/MD5.java +++ b/accompany-base/accompany-core/src/main/java/com/accompany/core/util/MD5.java @@ -1,5 +1,7 @@ package com.accompany.core.util; +import java.nio.charset.StandardCharsets; + public class MD5 { public static void main(String[] args) throws Exception { String str = "12345678"; @@ -7,7 +9,7 @@ public class MD5 { } public static String getMD5(String source){ - return getMD5(source.getBytes()); + return getMD5(source.getBytes(StandardCharsets.UTF_8)); } public static String getMD5(byte[] source) { diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/agentchangestrategy/AlipayNativeAgentChangeStrategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/agentchangestrategy/AlipayNativeAgentChangeStrategy.java deleted file mode 100644 index a9d23e37f..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/agentchangestrategy/AlipayNativeAgentChangeStrategy.java +++ /dev/null @@ -1,206 +0,0 @@ -package com.accompany.payment.agentchangestrategy; - -import com.accompany.common.constant.Constant; -import com.accompany.common.redis.RedisKey; -import com.accompany.common.utils.RandomUtil; -import com.accompany.common.utils.StringUtils; -import com.accompany.core.service.SysConfService; -import com.accompany.core.service.common.JedisService; -import com.accompany.payment.config.AliPayConfig; -import com.accompany.payment.constant.PayConstant; -import com.accompany.payment.dto.AgentChangeStrategyConfigDTO; -import com.accompany.payment.dto.AlipayAgentDTO; -import com.accompany.payment.dto.PayAgentConfDTO; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.params.AgentChangeDimensions; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.collections.CollectionUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import javax.annotation.PostConstruct; -import java.util.List; - -@Service("alipayNativeAgentChangeStrategy") -@Slf4j -public class AlipayNativeAgentChangeStrategy implements IAgentChangeStrategy { - - @Autowired - private SysConfService sysConfService; - @Autowired - private JedisService jedisService; - @Autowired - private AliPayConfig aliPayConfig; - - private PayAgentConfDTO defaultAlipayAgentConf; - - @PostConstruct - public void init() { - defaultAlipayAgentConf = new PayAgentConfDTO(); - - AlipayAgentDTO defaultAlipayAgent = new AlipayAgentDTO(); - defaultAlipayAgent.setAppId(aliPayConfig.getAppId()); - defaultAlipayAgent.setAppPrivateKey(aliPayConfig.getAppPrivateKey()); - defaultAlipayAgent.setPublicKey(aliPayConfig.getPublicKey()); - - defaultAlipayAgentConf.setPayAgent(defaultAlipayAgent); - } - - - @Override - public PayAgentConfDTO getPayAgentConfig(AgentChangeDimensions dimensions) { - String strategyStr = sysConfService.getSysConfValueById(Constant.SysConfId.ALIPAY_NATIVE_AGENT_CHANGE_STRATEGY); - if (StringUtils.isBlank(strategyStr)) { - log.warn("[AlipayNativeAgentChangeStrategy]没有支付宝实体切换策略配置,返回默认的支付宝商户"); - return defaultAlipayAgentConf; - } - - AgentChangeStrategyConfigDTO strategyConfig = JSONObject.parseObject(strategyStr, AgentChangeStrategyConfigDTO.class); - - log.info("[AlipayNativeAgentChangeStrategy]当前启用的模式为:{}", strategyConfig.getMode()); - switch (strategyConfig.getMode()) { - case PayConstant.AgentChangeMode.MANUAL: - return getManualModeAgentConf(strategyConfig); - case PayConstant.AgentChangeMode.AUTO: - return getAutoModeAgentConf(dimensions, strategyConfig); - default: - return getManualModeAgentConf(strategyConfig); - } - - } - - @Override - public Object getPayAgentByConfId(String confId) { - String agentConfigStr = sysConfService.getSysConfValueById(confId); - if (StringUtils.isBlank(agentConfigStr)) { - return null; - } - - AlipayAgentDTO alipayAgent = JSONObject.parseObject(agentConfigStr, AlipayAgentDTO.class); - if (StringUtils.isBlank(alipayAgent.getAppId()) || StringUtils.isBlank(alipayAgent.getAppPrivateKey()) || StringUtils.isBlank(alipayAgent.getPublicKey())) { - return null; - } - return alipayAgent; - } - - @Override - public void postProcessAfterPay(ChargeRecord chargeRecord) { - if (chargeRecord == null) { - return; - } - - Long uid = chargeRecord.getUid(); - - jedisService.hincr(RedisKey.alipay_native_user_pay_count.getKey(), uid.toString()); - } - - private PayAgentConfDTO getAutoModeAgentConf(AgentChangeDimensions dimensions, AgentChangeStrategyConfigDTO strategyConfig) { - if (dimensions == null || dimensions.getUid() == null) { - log.warn("[AlipayNativeAgentChangeStrategy]策略判断必要维度为空,返回默认的支付宝商户"); - return defaultAlipayAgentConf; - } - - String usingAgentConfigId = jedisService.hget(RedisKey.alipay_user_using_agent.getKey(), dimensions.getUid().toString()); - if (StringUtils.isBlank(usingAgentConfigId)) { - usingAgentConfigId = getRandomAgentConfigId(strategyConfig.getAutoAgentConfigIds()); - if (StringUtils.isBlank(usingAgentConfigId)) { - // 获取不到初始的id,则使用默认的 - return defaultAlipayAgentConf; - } else { - renewUserUsingAgent(dimensions.getUid(), usingAgentConfigId); - } - } else { - if (CollectionUtils.isNotEmpty(strategyConfig.getAutoAgentConfigIds()) && strategyConfig.getAutoAgentConfigIds().indexOf(usingAgentConfigId) >= 0) { - String paidCountStr = jedisService.hget(RedisKey.alipay_native_user_pay_count.getKey(), dimensions.getUid().toString()); - if (StringUtils.isNotBlank(paidCountStr)) { - Integer paidCount = Integer.valueOf(paidCountStr); - if (paidCount >= strategyConfig.getUserPaidCount()) { - String oldUsingAgentConfigId = usingAgentConfigId; - usingAgentConfigId = getNextAgentConfigId(strategyConfig, usingAgentConfigId); - log.info("用户 {} 已使用 {} 支付了 {} 次,下一次使用 {} 支付", dimensions.getUid(), oldUsingAgentConfigId, paidCount, usingAgentConfigId); - if (StringUtils.isNotBlank(usingAgentConfigId)) { - renewUserUsingAgent(dimensions.getUid(), usingAgentConfigId); - } else { - return defaultAlipayAgentConf; - } - } - } - } else { - // 不在当前配置的id数组中,则认为是存在问题等原因去掉了,重新随机选择 - log.info("用户 {} 使用的id {} 已从候选库中移除,重新选择", dimensions.getUid(), usingAgentConfigId); - usingAgentConfigId = getRandomAgentConfigId(strategyConfig.getAutoAgentConfigIds()); - if (StringUtils.isBlank(usingAgentConfigId)) { - // 获取不到初始的id,则使用默认的 - return defaultAlipayAgentConf; - } else { - renewUserUsingAgent(dimensions.getUid(), usingAgentConfigId); - } - } - } - - return getAlipayAgentDTOByConfId(usingAgentConfigId); - } - - private void renewUserUsingAgent(Long uid, String usingAgentConfigId) { - jedisService.hset(RedisKey.alipay_user_using_agent.getKey(), uid.toString(), usingAgentConfigId); - jedisService.hdel(RedisKey.alipay_native_user_pay_count.getKey(), uid.toString()); - } - - private String getNextAgentConfigId(AgentChangeStrategyConfigDTO strategyConfig, String usingAgentConfigId) { - List autoAgentConfigIds = strategyConfig.getAutoAgentConfigIds(); - if (CollectionUtils.isEmpty(autoAgentConfigIds)) { - log.warn("[AlipayNativeAgentChangeStrategy]支付宝实体切换策略配置中的autoAgentConfigIds为空"); - return null; - } - int idx = autoAgentConfigIds.indexOf(usingAgentConfigId); - if (idx < 0) { - // 不在列表中,可能是被移除了,则随机返回一个 - return getRandomAgentConfigId(autoAgentConfigIds); - } else { - int nextIdx = (idx + 1) % autoAgentConfigIds.size(); - return autoAgentConfigIds.get(nextIdx); - } - } - - private String getRandomAgentConfigId(List autoAgentConfigIds) { - if (CollectionUtils.isEmpty(autoAgentConfigIds)) { - log.warn("[AlipayNativeAgentChangeStrategy]支付宝实体切换策略配置中的autoAgentConfigIds为空"); - return null; - } - int idx = RandomUtil.randomByRange(0, autoAgentConfigIds.size()) % autoAgentConfigIds.size(); - log.info("[AlipayNativeAgentChangeStrategy]随机选择支付商户,候选配置: {}, 随机使用第 {} 个", JSONArray.toJSONString(autoAgentConfigIds), idx + 1); - - return autoAgentConfigIds.get(idx); - } - - private PayAgentConfDTO getManualModeAgentConf(AgentChangeStrategyConfigDTO strategyConfig) { - if (StringUtils.isBlank(strategyConfig.getManualAgentConfigId())) { - log.warn("[AlipayNativeAgentChangeStrategy]支付宝实体切换策略配置中的manualAgentConfigId为空,返回默认的支付宝商户"); - return defaultAlipayAgentConf; - } - - return getAlipayAgentDTOByConfId(strategyConfig.getManualAgentConfigId()); - } - - private PayAgentConfDTO getAlipayAgentDTOByConfId(String configId) { - String manualAgentConfigStr = sysConfService.getSysConfValueById(configId); - if (StringUtils.isBlank(manualAgentConfigStr)) { - log.warn("[AlipayNativeAgentChangeStrategy]没有{}这个配置项,返回默认的支付宝商户", configId); - return defaultAlipayAgentConf; - } - - AlipayAgentDTO alipayAgent = JSONObject.parseObject(manualAgentConfigStr, AlipayAgentDTO.class); - if (StringUtils.isBlank(alipayAgent.getAppId()) || StringUtils.isBlank(alipayAgent.getAppPrivateKey()) || StringUtils.isBlank(alipayAgent.getPublicKey())) { - log.warn("[AlipayNativeAgentChangeStrategy]{}配置项不正确:{},返回默认的支付宝商户", configId, JSONObject.toJSONString(alipayAgent)); - return defaultAlipayAgentConf; - } - - PayAgentConfDTO agentConf = new PayAgentConfDTO(); - agentConf.setConfigId(configId); - agentConf.setPayAgent(alipayAgent); - - return agentConf; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/agentchangestrategy/IAgentChangeStrategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/agentchangestrategy/IAgentChangeStrategy.java deleted file mode 100644 index f6d7656b7..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/agentchangestrategy/IAgentChangeStrategy.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.accompany.payment.agentchangestrategy; - -import com.accompany.payment.dto.PayAgentConfDTO; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.params.AgentChangeDimensions; - -/** - * 支付实体切换策略接口 - */ -public interface IAgentChangeStrategy { - - /** - * 获取实体配置 - * @param dimensions - * @return - */ - PayAgentConfDTO getPayAgentConfig(AgentChangeDimensions dimensions); - - Object getPayAgentByConfId(String confId); - - void postProcessAfterPay(ChargeRecord chargeRecord); -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/AbstractAlipayService.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/AbstractAlipayService.java deleted file mode 100644 index 16d7c631c..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/AbstractAlipayService.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.accompany.payment.alipay; - -import com.accompany.common.constant.Constant; -import com.accompany.common.utils.DateTimeUtil; -import com.accompany.core.service.SysConfService; -import com.accompany.core.util.StringUtils; -import com.accompany.payment.config.AliPayConfig; -import com.accompany.payment.config.BaseAliPayConfig; -import com.accompany.payment.constant.PayConstant; -import com.alipay.api.AlipayClient; -import com.alipay.api.DefaultAlipayClient; -import com.alipay.api.domain.AlipayTradeAppPayModel; -import com.alipay.api.domain.AlipayTradeWapPayModel; -import com.alipay.api.domain.ExtUserInfo; -import com.alipay.api.request.AlipayTradeAppPayRequest; -import com.alipay.api.request.AlipayTradeWapPayRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Calendar; -import java.util.Date; - -/** - * @date 2021年01月12日 - * @descrition 支付宝支付业务处理抽象类 - */ -public abstract class AbstractAlipayService { - - @Autowired - private SysConfService sysConfService; - - public AlipayClient getAlipayClientInstance() { - BaseAliPayConfig aliPayConfig = getAliPayConfig(); - return new DefaultAlipayClient( - aliPayConfig.getUrl(), - aliPayConfig.getAppId(), - aliPayConfig.getAppPrivateKey(), - PayConstant.ALIPAY_FORMAT, - PayConstant.ALIPAY_CHATSET, - aliPayConfig.getPublicKey(), - PayConstant.ALIPAY_SIGN_TYPE); - } - - - public AlipayTradeAppPayRequest buildAliAppRequest(Long amount, String orderNo, String subject, String body, - String realName, String idCardNum) { - AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); - AlipayTradeAppPayModel model = new AlipayTradeAppPayModel(); - model.setBody(body); - model.setSubject(subject); - model.setOutTradeNo(orderNo); - model.setTotalAmount(amount.toString()); - model.setProductCode(PayConstant.alipayProdCode.QUICK_MSECURITY_PAY); - model.setGoodsType("0"); - String userSwitch = sysConfService.getSysConfValueById(Constant.SysConfId.ALIPAY_ORDER_USER); - if (StringUtils.isNotBlank(userSwitch) && Boolean.parseBoolean(userSwitch)) { - //买家实名信息 - ExtUserInfo userInfo = buildAlipayUserInfo(realName, idCardNum); - model.setExtUserInfo(userInfo); - } - //订单失效时间 - String timeout = sysConfService.getSysConfValueById(Constant.SysConfId.ALIPAY_ORDER_TIMEOUT); - if (StringUtils.isNotBlank(timeout)) { - Date date = DateTimeUtil.getNextMinute(Calendar.getInstance().getTime(), Integer.parseInt(timeout)); - String time = DateTimeUtil.convertDate(date, DateTimeUtil.DEFAULT_DATE_MINUTE_PATTERN); - model.setTimeExpire(time); - } - model.setDisablePayChannels("pcredit,pcreditpayInstallment"); - request.setBizModel(model); - request.setNotifyUrl(getAliPayConfig().getNotifyUrl()); - - return request; - } - - public AlipayTradeWapPayRequest buildAliWapRequest(Long amount, String orderNo, String subject, String body, - String successUrl, String realName, String idCardNum) { - AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest(); - AlipayTradeWapPayModel model = new AlipayTradeWapPayModel(); - model.setBody(body); - model.setSubject(subject); - model.setOutTradeNo(orderNo); - model.setTotalAmount(amount.toString()); - model.setProductCode(PayConstant.alipayProdCode.QUICK_WAP_WAY); - model.setGoodsType("0"); - //买家实名信息 - String userSwitch = sysConfService.getSysConfValueById(Constant.SysConfId.ALIPAY_ORDER_USER); - if (StringUtils.isNotBlank(userSwitch) && Boolean.parseBoolean(userSwitch)) { - ExtUserInfo userInfo = buildAlipayUserInfo(realName, idCardNum); - model.setExtUserInfo(userInfo); - } - //订单失效时间 - String timeout = sysConfService.getDefaultSysConfValueById(Constant.SysConfId.H5_ORDER_TIMEOUT, "1"); - Date date = DateTimeUtil.getNextMinute(Calendar.getInstance().getTime(), Integer.parseInt(timeout)); - String time = DateTimeUtil.convertDate(date, DateTimeUtil.DEFAULT_DATE_MINUTE_PATTERN); - model.setTimeExpire(time); - - model.setDisablePayChannels("pcredit,pcreditpayInstallment"); - request.setBizModel(model); - request.setNotifyUrl(getAliPayConfig().getNotifyUrl()); - request.setReturnUrl(successUrl); - - return request; - } - - private ExtUserInfo buildAlipayUserInfo(String realName, String idCardNum) { - ExtUserInfo userInfo = new ExtUserInfo(); - userInfo.setMinAge("18"); - userInfo.setNeedCheckInfo("T"); - if (StringUtils.isNotBlank(realName) && StringUtils.isNotBlank(idCardNum)) { - userInfo.setName(realName); - userInfo.setCertType("IDENTITY_CARD"); - userInfo.setCertNo(idCardNum); - userInfo.setFixBuyer("T"); - } - return userInfo; - } - - protected abstract BaseAliPayConfig getAliPayConfig(); - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/AliPayClientParam.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/AliPayClientParam.java deleted file mode 100644 index 7917ff9ca..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/AliPayClientParam.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.accompany.payment.alipay; - -/** - * 支付宝客户端配置 - */ -public class AliPayClientParam { - - /** - * 开放状态 - */ - private Boolean status; - /** - * 支付配置的序号 - * 用于回调的时候获取公钥 - */ - private Integer index; - /** - * 支付url - */ - private String url; - /** - * appId - */ - private String appId; - /** - * 应用私钥 - */ - private String appPrivateKey; - /** - * 支付宝公钥 - */ - private String publicKey; - /** - * 回调地址 - */ - private String notifyUrl; - - public Boolean getStatus() { - return status; - } - - public void setStatus(Boolean status) { - this.status = status; - } - - public Integer getIndex() { - return index; - } - - public void setIndex(Integer index) { - this.index = index; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getAppId() { - return appId; - } - - public void setAppId(String appId) { - this.appId = appId; - } - - public String getAppPrivateKey() { - return appPrivateKey; - } - - public void setAppPrivateKey(String appPrivateKey) { - this.appPrivateKey = appPrivateKey; - } - - public String getPublicKey() { - return publicKey; - } - - public void setPublicKey(String publicKey) { - this.publicKey = publicKey; - } - - public String getNotifyUrl() { - return notifyUrl; - } - - public void setNotifyUrl(String notifyUrl) { - this.notifyUrl = notifyUrl; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/AlipayNotifyParam.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/AlipayNotifyParam.java deleted file mode 100644 index 09a4e00a3..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/AlipayNotifyParam.java +++ /dev/null @@ -1,265 +0,0 @@ -package com.accompany.payment.alipay; - -import java.math.BigDecimal; -import java.util.Date; - -/** - * @author yangming - * @date 2018-10-24 - * @descrition 支付宝回调参数实体 - */ -public class AlipayNotifyParam { - - /** - * 应用appId - **/ - private String app_id; - /** - * 支付宝交易凭证号 - **/ - private String trade_no; - /** - * 原支付请求的商户订单号 - **/ - private String out_trade_no; - /** - * 商户业务ID,主要是退款通知中返回退款申请的流水号 - **/ - private String out_biz_no; - /** - * 买家支付宝账号对应的支付宝唯一用户号。以2088开头的纯16位数字 - **/ - private String buyer_id; - /** - * 买家支付宝账号 - **/ - private String buyer_logon_id; - /** - * 卖家支付宝用户号 - **/ - private String seller_id; - /** - * 卖家支付宝账号 - **/ - private String seller_email; - /** - * 交易目前所处的状态,见交易状态说明 - **/ - private String trade_status; - /** - * 本次交易支付的订单金额 - **/ - private BigDecimal total_amount; - /** - * 商家在交易中实际收到的款项 - **/ - private BigDecimal receipt_amount; - /** - * 用户在交易中支付的金额 - **/ - private BigDecimal buyer_pay_amount; - /** - * 退款通知中,返回总退款金额,单位为元,支持两位小数 - **/ - private BigDecimal refund_fee; - /** - * 商品的标题/交易标题/订单标题/订单关键字等 - **/ - private String subject; - /** - * 该订单的备注、描述、明细等。对应请求时的body参数,原样通知回来 - **/ - private String body; - /** - * 该笔交易创建的时间。格式为yyyy-MM-dd HH:mm:ss - **/ - private Date gmt_create; - /** - * 该笔交易的买家付款时间。格式为yyyy-MM-dd HH:mm:ss - **/ - private Date gmt_payment; - /** - * 该笔交易的退款时间。格式为yyyy-MM-dd HH:mm:ss.S - **/ - private Date gmt_refund; - /** - * 该笔交易结束时间。格式为yyyy-MM-dd HH:mm:ss - **/ - private Date gmt_close; - /** - * 支付成功的各个渠道金额信息,array - **/ - private String fund_bill_list; - /** - * 公共回传参数,如果请求时传递了该参数,则返回给商户时会在异步通知时将该参数原样返回 - **/ - private String passback_params; - - public String getApp_id() { - return app_id; - } - - public void setApp_id(String app_id) { - this.app_id = app_id; - } - - public String getTrade_no() { - return trade_no; - } - - public void setTrade_no(String trade_no) { - this.trade_no = trade_no; - } - - public String getOut_trade_no() { - return out_trade_no; - } - - public void setOut_trade_no(String out_trade_no) { - this.out_trade_no = out_trade_no; - } - - public String getOut_biz_no() { - return out_biz_no; - } - - public void setOut_biz_no(String out_biz_no) { - this.out_biz_no = out_biz_no; - } - - public String getBuyer_id() { - return buyer_id; - } - - public void setBuyer_id(String buyer_id) { - this.buyer_id = buyer_id; - } - - public String getBuyer_logon_id() { - return buyer_logon_id; - } - - public void setBuyer_logon_id(String buyer_logon_id) { - this.buyer_logon_id = buyer_logon_id; - } - - public String getSeller_id() { - return seller_id; - } - - public void setSeller_id(String seller_id) { - this.seller_id = seller_id; - } - - public String getSeller_email() { - return seller_email; - } - - public void setSeller_email(String seller_email) { - this.seller_email = seller_email; - } - - public String getTrade_status() { - return trade_status; - } - - public void setTrade_status(String trade_status) { - this.trade_status = trade_status; - } - - public BigDecimal getTotal_amount() { - return total_amount; - } - - public void setTotal_amount(BigDecimal total_amount) { - this.total_amount = total_amount; - } - - public BigDecimal getReceipt_amount() { - return receipt_amount; - } - - public void setReceipt_amount(BigDecimal receipt_amount) { - this.receipt_amount = receipt_amount; - } - - public BigDecimal getBuyer_pay_amount() { - return buyer_pay_amount; - } - - public void setBuyer_pay_amount(BigDecimal buyer_pay_amount) { - this.buyer_pay_amount = buyer_pay_amount; - } - - public BigDecimal getRefund_fee() { - return refund_fee; - } - - public void setRefund_fee(BigDecimal refund_fee) { - this.refund_fee = refund_fee; - } - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public String getBody() { - return body; - } - - public void setBody(String body) { - this.body = body; - } - - public Date getGmt_create() { - return gmt_create; - } - - public void setGmt_create(Date gmt_create) { - this.gmt_create = gmt_create; - } - - public Date getGmt_payment() { - return gmt_payment; - } - - public void setGmt_payment(Date gmt_payment) { - this.gmt_payment = gmt_payment; - } - - public Date getGmt_refund() { - return gmt_refund; - } - - public void setGmt_refund(Date gmt_refund) { - this.gmt_refund = gmt_refund; - } - - public Date getGmt_close() { - return gmt_close; - } - - public void setGmt_close(Date gmt_close) { - this.gmt_close = gmt_close; - } - - public String getFund_bill_list() { - return fund_bill_list; - } - - public void setFund_bill_list(String fund_bill_list) { - this.fund_bill_list = fund_bill_list; - } - - public String getPassback_params() { - return passback_params; - } - - public void setPassback_params(String passback_params) { - this.passback_params = passback_params; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/AlipayService.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/AlipayService.java deleted file mode 100644 index b59e1489d..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/AlipayService.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.accompany.payment.alipay; - -import com.accompany.payment.config.AliPayConfig; -import com.accompany.payment.config.BaseAliPayConfig; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * @author yangming - * @date 2018-10-18 - * @descrition 支付宝支付业务处理 - */ -@Service -public class AlipayService extends AbstractAlipayService { - - @Autowired - private AliPayConfig aliPayConfig; - - @Override - protected BaseAliPayConfig getAliPayConfig() { - return aliPayConfig; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/TransferService.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/TransferService.java deleted file mode 100644 index f175390cb..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/TransferService.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.accompany.payment.alipay; - -import com.accompany.payment.config.AliPayConfig; -import com.accompany.payment.constant.PayConstant; -import com.alipay.api.AlipayClient; -import com.alipay.api.DefaultAlipayClient; -import com.alipay.api.domain.AlipayFundTransToaccountTransferModel; -import com.alipay.api.request.AlipayFundTransToaccountTransferRequest; -import com.alipay.api.response.AlipayFundTransToaccountTransferResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * @author yangming - * @date 2018-10-22 - * @description 支付宝转账处理 - */ -@Service -public class TransferService { - - @Autowired - private AlipayService alipayService; - /** - * 支付宝单人转账 - * - * @param model - * @return - * @throws Exception - */ - public AlipayFundTransToaccountTransferResponse AlipayTransfer(AlipayFundTransToaccountTransferModel model) throws Exception { - AlipayClient alipayClient = alipayService.getAlipayClientInstance(); - AlipayFundTransToaccountTransferRequest request = new AlipayFundTransToaccountTransferRequest(); - request.setBizModel(model); - AlipayFundTransToaccountTransferResponse response = alipayClient.execute(request); - return response; - } - - /** - * 构造Transfer对象 - * - * @param orderNo - * @param account - * @param accountName - * @param amount - * @param remark - * @return - */ - public AlipayFundTransToaccountTransferModel buildTransferModel(String orderNo, String account, String accountName, String amount, String remark) { - AlipayFundTransToaccountTransferModel model = new AlipayFundTransToaccountTransferModel(); - model.setOutBizNo(orderNo); - model.setPayeeType(PayConstant.ALIPAY_PAYEE_TYPE); - model.setPayeeAccount(account); - model.setAmount(amount); - model.setPayeeRealName(accountName); - model.setRemark(remark); - return model; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/YinyouAlipayService.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/YinyouAlipayService.java deleted file mode 100644 index 382a75b59..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/alipay/YinyouAlipayService.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.accompany.payment.alipay; - -import com.accompany.payment.config.AliPayConfig; -import com.accompany.payment.config.BaseAliPayConfig; -import com.accompany.payment.config.YinyouAliPayConfig; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * @date 2021年01月12日 - * @descrition 平台支付宝支付业务处理 - */ -@Service -public class YinyouAlipayService extends AbstractAlipayService { - - @Autowired - private YinyouAliPayConfig aliPayConfig; - - @Override - protected BaseAliPayConfig getAliPayConfig() { - return aliPayConfig; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/AliPayConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/AliPayConfig.java deleted file mode 100644 index e34e62548..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/AliPayConfig.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.accompany.payment.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -/** - * 支付宝支付配置 - * - * @author xiaoyuyou - * @date 2019/5/31 16:41 - */ -@Component -@Order(-1) -@Lazy(false) -@ConfigurationProperties(prefix = "alipay") -public class AliPayConfig extends BaseAliPayConfig { - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/BaseAliPayConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/BaseAliPayConfig.java deleted file mode 100644 index dd43f0bdd..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/BaseAliPayConfig.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.accompany.payment.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -/** - * 支付宝支付配置 - * - * @author xiaoyuyou - * @date 2019/5/31 16:41 - */ -@Data -public abstract class BaseAliPayConfig { - - private String url; - private String appId; - private String appPrivateKey; - private String publicKey; - private String notifyUrl; - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/BaseWxPayConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/BaseWxPayConfig.java deleted file mode 100644 index 920be4bce..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/BaseWxPayConfig.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.accompany.payment.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -/** - * 微信支付配置 - * - * @author xiaoyuyou - * @date 2019/5/31 16:35 - */ -@Data -public class BaseWxPayConfig { - - private String url; - private String appId; - private String mchId; - private String apiKey; - private String notifyUrl; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/HuiKaConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/HuiKaConfig.java deleted file mode 100644 index eae6c15a2..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/HuiKaConfig.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.accompany.payment.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -import javax.validation.constraints.NotBlank; - -/** - * @author linuxea - * @date 2019/8/6 10:24 - */ -@ConfigurationProperties(prefix = "hui-ka") -@Configuration -@Data -public class HuiKaConfig { - - /** - * 统一下单地址 - */ - @NotBlank(message = "统一下单地址不能为空") - private String unifiedOrderUrl; - - /** - * 后端通知地址 - */ - @NotBlank(message = "后端通知地址不能为空") - private String backendNotifyUrl; - - /** - * 机构号 - */ - @NotBlank(message = "机构号不能空") - private String orgId; - - /** - * 商户号 - */ - @NotBlank(message = "商户号不能为空") - private String mchNo; - - /** - * 私钥 - */ - @NotBlank(message = "商户号不能为空") - private String accessPrvKey; - - /** - * 公钥 - */ - @NotBlank(message = "公钥不能为空") - private String accessPubKey; - - /** - * 平台公钥 - */ - @NotBlank(message = "平台公钥不能为空") - private String platformPubKey; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/JoinPayConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/JoinPayConfig.java deleted file mode 100644 index fae60f170..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/JoinPayConfig.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.accompany.payment.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -/** - * 汇聚支付配置 - * - * @author xiaoyuyou - * @date 2019/5/31 16:42 - */ -@Component -@Order(-1) -@Lazy(false) -@ConfigurationProperties(prefix = "joinpay") -public class JoinPayConfig { - - public static String merchantNo; - public static String key; - public static String applyTradeUrl; - public static String callbackUrl; - public static Boolean open; - - public void setMerchantNo(String merchantNo) { - JoinPayConfig.merchantNo = merchantNo; - } - - public void setKey(String key) { - JoinPayConfig.key = key; - } - - public void setApplyTradeUrl(String applyTradeUrl) { - JoinPayConfig.applyTradeUrl = applyTradeUrl; - } - - public void setCallbackUrl(String callbackUrl) { - JoinPayConfig.callbackUrl = callbackUrl; - } - - public static void setOpen(Boolean open) { - JoinPayConfig.open = open; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/MultiAliPayConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/MultiAliPayConfig.java deleted file mode 100644 index b8b0b1164..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/MultiAliPayConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.accompany.payment.config; - -import com.accompany.payment.alipay.AliPayClientParam; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; - -@Component -@Order(-1) -@Lazy(false) -@ConfigurationProperties(prefix = "multi-alipay") -public class MultiAliPayConfig { - - public static List alipayConfigs = new ArrayList<>(); - - public List getAlipayConfigs() { - return alipayConfigs; - } - - public void setAlipayConfigs(List alipayConfigs) { - MultiAliPayConfig.alipayConfigs = alipayConfigs; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/PingxxConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/PingxxConfig.java deleted file mode 100644 index 1f6fe2e66..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/PingxxConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.accompany.payment.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -/** - * Created by PaperCut on 2018/2/3. - * Pingxx支付配置 - */ -@Configuration -@ConfigurationProperties(prefix = "pingxx") -public class PingxxConfig { - public String apiKey; - public String appId; - public String publicKey; - private String privateKey; - - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - } - - public void setAppId(String appId) { - this.appId = appId; - } - - public void setPublicKey(String publicKey) { - this.publicKey = publicKey; - } - - public void setPrivateKey(String privateKey) { - this.privateKey = privateKey; - } - - public String getApiKey() { - return apiKey; - } - - public String getAppId() { - return appId; - } - - public String getPublicKey() { - return publicKey; - } - - public String getPrivateKey() { - return privateKey; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/SandPayConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/SandPayConfig.java deleted file mode 100644 index 880cd622d..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/SandPayConfig.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.accompany.payment.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -/** - * 衫德支付配置 - * - */ -@Configuration -@ConfigurationProperties("sand-pay") -@Lazy(false) -@Data -public class SandPayConfig { - - /** - * 商户号 - */ - private String agentId; - - /** - * 约定秘钥,无需更改 - */ - private String alipayPrivateKeyMi; - - /** - * 约定的公钥,无需更改 - */ - private String alipayPublicKey; - - /** - * 商户秘钥 - */ - private String alipayPrivateKey; - - /** - * 随机md5 key - */ - private String md5Key; - - /** - * 支付宝支付回调地址 - */ - private String alipayNotifyUrl; - - /** - * 支付宝支付地址 - */ - private String alipayUrl; - - /** - * 支付成功返回地址 - */ - private String returnUrl; - - private String metaOption; - - /** - * 订单过期时间(分钟) - */ - private Integer expireMinutes; - - - @Component - @Lazy(value = false) - @Order(-1) - @ConfigurationProperties(prefix = "sand-pay.wxminiapps") - public static class MiniAppConfig { - public static String mid; - /** - * 商户公钥base64 - */ - public static String pubKeyBase64; - - /** - * 商户私钥base64 - */ - public static String privateKeyBase64; - - /** - * 商户私钥密码 - */ - public static String privateKeyPwd; - public static String createOrderUrl; - // 小程序appid - public static String subAppid; - public static String notifyUrl; - // 公众号appId - public static String wxpubAppid; - - public void setPubKeyBase64(String pubKeyBase64) { - MiniAppConfig.pubKeyBase64 = pubKeyBase64; - } - public void setPrivateKeyBase64(String privateKeyBase64) { - MiniAppConfig.privateKeyBase64 = privateKeyBase64; - } - public void setPrivateKeyPwd(String privateKeyPwd) { - MiniAppConfig.privateKeyPwd = privateKeyPwd; - } - public void setWxpubAppid(String wxpubAppid) { MiniAppConfig.wxpubAppid = wxpubAppid; } - public void setNotifyUrl(String notifyUrl) { - MiniAppConfig.notifyUrl = notifyUrl; - } - public void setSubAppid(String subAppid) { MiniAppConfig.subAppid = subAppid; } - public void setCreateOrderUrl(String createOrderUrl) { - MiniAppConfig.createOrderUrl = createOrderUrl; - } - public void setMid(String mid) { - MiniAppConfig.mid = mid; - } - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxConfig.java deleted file mode 100644 index cfcfc2cff..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxConfig.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.accompany.payment.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -/** - * Created by PaperCut on 2018/2/3. - * 微信配置 - */ -@Component -@Order(-1) -@Lazy(false) -@ConfigurationProperties(prefix = "wx") -public class WxConfig { - public static String appId; - public static String appSecret; - public static String mchId; - public static String token; - public static String returnUrl; - public static Boolean isCreateMenu; - public static String key; - public static String getCodeUrl; - public static String modelMsgId; - public static String guide; - public static String home; - public static String payUrl; - public static String giveGold; - public static String alertMsgId; - public static String alertAdminUser; - public static String wxEncodingAESKey; - public static Boolean pubValidOpenId; - public static String openIdKey; - - public void setAppId(String appId) { - WxConfig.appId = appId; - } - - public void setAppSecret(String appSecret) { - WxConfig.appSecret = appSecret; - } - - public void setMchId(String mchId) { - WxConfig.mchId = mchId; - } - - public void setToken(String token) { - WxConfig.token = token; - } - - public void setReturnUrl(String returnUrl) { - WxConfig.returnUrl = returnUrl; - } - - public void setIsCreateMenu(Boolean isCreateMenu) { - WxConfig.isCreateMenu = isCreateMenu; - } - - public void setKey(String key) { - WxConfig.key = key; - } - - public void setGetCodeUrl(String getCodeUrl) { - WxConfig.getCodeUrl = getCodeUrl; - } - - public void setModelMsgId(String modelMsgId) { - WxConfig.modelMsgId = modelMsgId; - } - - public void setGuide(String guide) { - WxConfig.guide = guide; - } - - public void setHome(String home) { - WxConfig.home = home; - } - - public void setPayUrl(String payUrl) { - WxConfig.payUrl = payUrl; - } - - public void setGiveGold(String giveGold) { - WxConfig.giveGold = giveGold; - } - - public void setAlertMsgId(String alertMsgId) { - WxConfig.alertMsgId = alertMsgId; - } - - public void setAlertAdminUser(String alertAdminUser) { - WxConfig.alertAdminUser = alertAdminUser; - } - - public void setWxEncodingAESKey(String wxEncodingAESKey) { - WxConfig.wxEncodingAESKey = wxEncodingAESKey; - } - - public void setPubValidOpenId(Boolean pubValidOpenId) { - WxConfig.pubValidOpenId = pubValidOpenId; - } - - public void setOpenIdKey(String openIdKey) { - WxConfig.openIdKey = openIdKey; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxMicroMallConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxMicroMallConfig.java deleted file mode 100644 index 1d3bbe7a6..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxMicroMallConfig.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.accompany.payment.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -/** - * 微商城公众号配置 - */ -@Component -@Order(-1) -@Lazy(false) -@ConfigurationProperties(prefix = "wx-micro-mall") -public class WxMicroMallConfig { - public static String appId; - public static String appSecret; - public static String mchId; - public static String token; - public static String returnUrl; - public static Boolean isCreateMenu; - public static String key; - public static String getCodeUrl; - public static String modelMsgId; - public static String guide; - public static String home; - public static String payUrl; - public static String giveGold; - public static String alertMsgId; - public static String alertAdminUser; - public static String wxEncodingAESKey; - public static Boolean pubValidOpenId; - public static String openIdKey; - - public void setAppId(String appId) { - WxMicroMallConfig.appId = appId; - } - - public void setAppSecret(String appSecret) { - WxMicroMallConfig.appSecret = appSecret; - } - - public void setMchId(String mchId) { - WxMicroMallConfig.mchId = mchId; - } - - public void setToken(String token) { - WxMicroMallConfig.token = token; - } - - public void setReturnUrl(String returnUrl) { - WxMicroMallConfig.returnUrl = returnUrl; - } - - public void setIsCreateMenu(Boolean isCreateMenu) { - WxMicroMallConfig.isCreateMenu = isCreateMenu; - } - - public void setKey(String key) { - WxMicroMallConfig.key = key; - } - - public void setGetCodeUrl(String getCodeUrl) { - WxMicroMallConfig.getCodeUrl = getCodeUrl; - } - - public void setModelMsgId(String modelMsgId) { - WxMicroMallConfig.modelMsgId = modelMsgId; - } - - public void setGuide(String guide) { - WxMicroMallConfig.guide = guide; - } - - public void setHome(String home) { - WxMicroMallConfig.home = home; - } - - public void setPayUrl(String payUrl) { - WxMicroMallConfig.payUrl = payUrl; - } - - public void setGiveGold(String giveGold) { - WxMicroMallConfig.giveGold = giveGold; - } - - public void setAlertMsgId(String alertMsgId) { - WxMicroMallConfig.alertMsgId = alertMsgId; - } - - public void setAlertAdminUser(String alertAdminUser) { - WxMicroMallConfig.alertAdminUser = alertAdminUser; - } - - public void setWxEncodingAESKey(String wxEncodingAESKey) { - WxMicroMallConfig.wxEncodingAESKey = wxEncodingAESKey; - } - - public void setPubValidOpenId(Boolean pubValidOpenId) { - WxMicroMallConfig.pubValidOpenId = pubValidOpenId; - } - - public void setOpenIdKey(String openIdKey) { - WxMicroMallConfig.openIdKey = openIdKey; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxMiniAppConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxMiniAppConfig.java deleted file mode 100644 index 391278e23..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxMiniAppConfig.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.accompany.payment.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -import javax.validation.constraints.NotBlank; - -/** - * @author linuxea - * @date 2019/8/6 17:47 - */ -@ConfigurationProperties(prefix = "wxmini") -@Configuration -@Data -public class WxMiniAppConfig { - - /** - * appId 小程序 id - */ - @NotBlank(message = "小程序 appId 不能为空") - private String appId; - - /** - * appSecret 小程序后台管理可生成 - */ - @NotBlank(message = "小程序 appSecret 不能为空") - private String appSecret; - - /** - * 获取 openId 的请求 url - */ - @NotBlank(message = "小程序 openUrl 不能为空") - private String openUrl; - - /** - * appId 小程序 id (芒果主体的) - */ - @NotBlank(message = "小程序 appId 不能为空") - private String mangguoAppId; - - /** - * appSecret 小程序后台管理可生成(芒果主体的) - */ - @NotBlank(message = "小程序 appSecret 不能为空") - private String mangguoAppSecret; - - /** - * 获取 openId 的请求 url(芒果主体的) - */ - @NotBlank(message = "小程序 openUrl 不能为空") - private String mangguoOpenUrl; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxPayConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxPayConfig.java deleted file mode 100644 index f4cdde5b2..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxPayConfig.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.accompany.payment.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -/** - * 微信支付配置 - * - * @author xiaoyuyou - * @date 2019/5/31 16:35 - */ -@Component -@Order(-1) -@Lazy(false) - @ConfigurationProperties(prefix = "wxpay") -public class WxPayConfig extends BaseWxPayConfig { - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxPub2Config.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxPub2Config.java deleted file mode 100644 index ec4c896d6..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxPub2Config.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.accompany.payment.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -/** - * Created by PaperCut on 2018/2/3. - * 微信配置 - */ -@Component -@Order(-1) -@Lazy(false) -@ConfigurationProperties(prefix = "wx-pub2") -public class WxPub2Config { - public static String appId; - public static String appSecret; - public static String mchId; - public static String token; - public static String returnUrl; - public static Boolean isCreateMenu; - public static String key; - public static String getCodeUrl; - public static String modelMsgId; - public static String guide; - public static String home; - public static String payUrl; - public static String giveGold; - public static String alertMsgId; - public static String alertAdminUser; - public static String wxEncodingAESKey; - public static Boolean pubValidOpenId; - public static String openIdKey; - - public void setAppId(String appId) { - WxPub2Config.appId = appId; - } - - public void setAppSecret(String appSecret) { - WxPub2Config.appSecret = appSecret; - } - - public void setMchId(String mchId) { - WxPub2Config.mchId = mchId; - } - - public void setToken(String token) { - WxPub2Config.token = token; - } - - public void setReturnUrl(String returnUrl) { - WxPub2Config.returnUrl = returnUrl; - } - - public void setIsCreateMenu(Boolean isCreateMenu) { - WxPub2Config.isCreateMenu = isCreateMenu; - } - - public void setKey(String key) { - WxPub2Config.key = key; - } - - public void setGetCodeUrl(String getCodeUrl) { - WxPub2Config.getCodeUrl = getCodeUrl; - } - - public void setModelMsgId(String modelMsgId) { - WxPub2Config.modelMsgId = modelMsgId; - } - - public void setGuide(String guide) { - WxPub2Config.guide = guide; - } - - public void setHome(String home) { - WxPub2Config.home = home; - } - - public void setPayUrl(String payUrl) { - WxPub2Config.payUrl = payUrl; - } - - public void setGiveGold(String giveGold) { - WxPub2Config.giveGold = giveGold; - } - - public void setAlertMsgId(String alertMsgId) { - WxPub2Config.alertMsgId = alertMsgId; - } - - public void setAlertAdminUser(String alertAdminUser) { - WxPub2Config.alertAdminUser = alertAdminUser; - } - - public void setWxEncodingAESKey(String wxEncodingAESKey) { - WxPub2Config.wxEncodingAESKey = wxEncodingAESKey; - } - - public void setPubValidOpenId(Boolean pubValidOpenId) { - WxPub2Config.pubValidOpenId = pubValidOpenId; - } - - public void setOpenIdKey(String openIdKey) { - WxPub2Config.openIdKey = openIdKey; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxPub2WapConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxPub2WapConfig.java deleted file mode 100644 index 741f6b6f9..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/WxPub2WapConfig.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.accompany.payment.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -/** - * 微信支付配置 - * - * @author xiaoyuyou - * @date 2019/5/31 16:35 - */ -@Component -@Order(-1) -@Lazy(false) -@ConfigurationProperties(prefix = "wx-pub2-h5") -public class WxPub2WapConfig extends BaseWxPayConfig { - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/YinyouAliPayConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/YinyouAliPayConfig.java deleted file mode 100644 index f2196850c..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/YinyouAliPayConfig.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.accompany.payment.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -/** - * 支付宝支付配置 - * - * @author xiaoyuyou - * @date 2019/5/31 16:41 - */ -@Component -@Order(-1) -@Lazy(false) -@ConfigurationProperties(prefix = "yinyou-alipay") -public class YinyouAliPayConfig extends BaseAliPayConfig { - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/YinyouWxPayConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/YinyouWxPayConfig.java deleted file mode 100644 index 7bb886f93..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/config/YinyouWxPayConfig.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.accompany.payment.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -@Component -@Order(-1) -@Lazy(false) -@ConfigurationProperties(prefix = "yinyou-wxpay") -public class YinyouWxPayConfig extends BaseWxPayConfig { -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/dto/AgentChangeStrategyConfigDTO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/dto/AgentChangeStrategyConfigDTO.java deleted file mode 100644 index ef56e10e7..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/dto/AgentChangeStrategyConfigDTO.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.accompany.payment.dto; - -import lombok.Data; - -import java.util.List; - -@Data -public class AgentChangeStrategyConfigDTO { - - /** - * mode:策略模式,manual(手动,模式1)|auto(自动,模式2) - */ - private String mode; - - /** - * 模式2时,单人单实体接受的笔数 - */ - private Integer userPaidCount; - - /** - * 模式1时,对应实体的配置id,必须是在系统配置中已有的配置 - */ - private String manualAgentConfigId; - - /** - * 模式2时,轮询的实体配置ID,也是必须都在系统配置中已有的配置 - */ - private List autoAgentConfigIds; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/dto/AlipayAgentDTO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/dto/AlipayAgentDTO.java deleted file mode 100644 index 1873c2b10..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/dto/AlipayAgentDTO.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.accompany.payment.dto; - - -import lombok.Data; - -@Data -public class AlipayAgentDTO { - - private String appId; - private String appPrivateKey; - private String publicKey; - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/dto/PayAgentConfDTO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/dto/PayAgentConfDTO.java deleted file mode 100644 index aaba2dbf0..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/dto/PayAgentConfDTO.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.accompany.payment.dto; - -import lombok.Data; - -@Data -public class PayAgentConfDTO { - - /** - * 配置id - */ - private String configId; - - /** - * 配置信息 - */ - private Object payAgent; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/FufeitongConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/FufeitongConfig.java deleted file mode 100644 index 4f8d6cef8..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/FufeitongConfig.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.accompany.payment.fufeitong; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -@Component -@ConfigurationProperties("fu-fei-tong") -@Data -public class FufeitongConfig { - - /** 后台异步通知 url */ - private String notifyUrl; - - /** 商户号 */ - private String agentId; - - /** 商户密钥 */ - private String agentKey; - - /** 微信公众号、小程序支付地址 */ - private String wxOpenPayUrl; - - /** h5支付地址 */ - private String wapPayUrl; - - /** 支付宝地址 */ - private String aliPayUrl; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/FufeitongConstant.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/FufeitongConstant.java deleted file mode 100644 index 187bfb26c..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/FufeitongConstant.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.accompany.payment.fufeitong; - -public final class FufeitongConstant { - - public final static String SUCCESS_CODE = "00"; - - public final static String CUST1_MINIAPP = "miniApp"; - - public final static String PAY_TYPE_ZFB = "1"; - - public final static String PAY_TYPE_WX = "2"; - - public final static String SETTLE_TYPE_T1 = "1"; - - public static final String SIGN_FIELD_NAME = "signature"; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/FufeitongPayService.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/FufeitongPayService.java deleted file mode 100644 index 355058743..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/FufeitongPayService.java +++ /dev/null @@ -1,191 +0,0 @@ -package com.accompany.payment.fufeitong; - -import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.BeanUtil; -import com.accompany.common.utils.StringUtils; -import com.accompany.core.dto.HttpForm; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.util.JsonUtil; -import com.accompany.core.util.OkHttpUtils; -import com.accompany.payment.fufeitong.bo.FufeitongBaseRes; -import com.accompany.payment.fufeitong.bo.FufeitongWxOpenOrderRes; -import com.accompany.payment.fufeitong.params.FufeitongCreateOrderBaseReqParams; -import com.accompany.payment.fufeitong.params.FufeitongWxOrderReqParams; -import com.accompany.payment.utils.CommonPayUtils; -import com.accompany.payment.vo.WeChatMiniAppPayResponseVO; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -@Service -@Slf4j -public class FufeitongPayService { - - @Autowired - private FufeitongConfig fufeitongConfig; - - /** - * 微信公众号、小程序支付 - * @param orderReqParams - * @return - */ - public FufeitongWxOpenOrderRes createWxOpenOrder(FufeitongWxOrderReqParams orderReqParams) { - checkParams(orderReqParams); - - String result = null; - try { - Map requestParams = toMapParams(orderReqParams); - requestParams.put("payType", FufeitongConstant.PAY_TYPE_WX); - - String sign = getSign(requestParams, fufeitongConfig); - requestParams.put(FufeitongConstant.SIGN_FIELD_NAME, sign); - - log.info("付费通公众号、小程序支付请求参数:{}", JSONObject.toJSONString(requestParams)); - - List httpForms = requestParams.entrySet().stream().map(it -> { - HttpForm form = new HttpForm(it.getKey(), it.getValue()); - return form; - }).collect(Collectors.toList()); - result = OkHttpUtils.postWithForm(fufeitongConfig.getWxOpenPayUrl(), httpForms); - - log.info("付费通公众号、小程序请求结果:{}",result); - - } catch (Exception e) { - log.error("付费通公众号、小程序创建订单失败。params:" + JSONObject.toJSONString(orderReqParams), e); - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失败,请重试"); - } - - FufeitongWxOpenOrderRes res = JSONObject.parseObject(result, FufeitongWxOpenOrderRes.class); - if (!res.getRespCode().equals(FufeitongConstant.SUCCESS_CODE)) { - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失败:" + res.getMessage()); - } - res.setMiniAppPayInfo(JsonUtil.parseToClass(res.getPayInfoStr(), WeChatMiniAppPayResponseVO.class)); - return res; - } - - private Map toMapParams(FufeitongCreateOrderBaseReqParams orderReqParams) { - Map tmpParams = BeanUtil.map(orderReqParams, Map.class); - Map requestParams = tmpParams.keySet().stream().filter(it -> tmpParams.get(it) != null) - .collect(Collectors.toMap(it -> it, it -> { - if (tmpParams.containsKey(it) && tmpParams.get(it) != null) { - return tmpParams.get(it).toString(); - } else { - return ""; - } - })); - requestParams.put("merchno", fufeitongConfig.getAgentId()); - requestParams.put("notifyUrl", fufeitongConfig.getNotifyUrl()); - requestParams.put("settleType", FufeitongConstant.SETTLE_TYPE_T1); - return requestParams; - } - - private String getSign(Map requestParams, FufeitongConfig payConfig) { - return CommonPayUtils.signParams(requestParams, null, payConfig.getAgentKey()); - } - - private void checkParams(FufeitongCreateOrderBaseReqParams params) { - if (params == null) { - throw new ServiceException(BusiStatus.PARAMERROR); - } - if (params.getAmount() == null || params.getAmount().compareTo(BigDecimal.ZERO) <= 0) { - params.setAmount(new BigDecimal("0.01")); - } - if (StringUtils.isBlank(params.getTraceno())) { - throw new ServiceException(BusiStatus.PARAMERROR, "商户订单号不能为空"); - } - if (StringUtils.isBlank(params.getGoodsName())) { - throw new ServiceException(BusiStatus.PARAMERROR, "商品订单描述不能为空"); - } - } - - /** - * h5支付 - * @param orderReqParams - * @return - */ - public FufeitongBaseRes createWapOrder(FufeitongCreateOrderBaseReqParams orderReqParams) { - checkParams(orderReqParams); - - String result = null; - try { - Map requestParams = toMapParams(orderReqParams); - - String sign = getSign(requestParams, fufeitongConfig); - requestParams.put(FufeitongConstant.SIGN_FIELD_NAME, sign); - - log.info("付费通h5支付请求参数:{}", JSONObject.toJSONString(requestParams)); - - List httpForms = requestParams.entrySet().stream().map(it -> { - HttpForm form = new HttpForm(it.getKey(), it.getValue()); - return form; - }).collect(Collectors.toList()); - result = OkHttpUtils.postWithForm(fufeitongConfig.getWapPayUrl(), httpForms); - - log.info("付费通h5请求结果:{}",result); - - } catch (Exception e) { - log.error("付费通h5创建订单失败。params:" + JSONObject.toJSONString(orderReqParams), e); - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失败,请重试"); - } - - FufeitongBaseRes res = JSONObject.parseObject(result, FufeitongBaseRes.class); - if (!res.getRespCode().equals(FufeitongConstant.SUCCESS_CODE)) { - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失败:" + res.getMessage()); - } - return res; - } - - public FufeitongBaseRes createAlipayOrder(FufeitongCreateOrderBaseReqParams orderReqParams) { - checkParams(orderReqParams); - - String result = null; - try { - Map requestParams = toMapParams(orderReqParams); - requestParams.put("payType", FufeitongConstant.PAY_TYPE_ZFB); - - String sign = getSign(requestParams, fufeitongConfig); - requestParams.put(FufeitongConstant.SIGN_FIELD_NAME, sign); - - log.info("付费通支付宝支付请求参数:{}", JSONObject.toJSONString(requestParams)); - - List httpForms = requestParams.entrySet().stream().map(it -> { - HttpForm form = new HttpForm(it.getKey(), it.getValue()); - return form; - }).collect(Collectors.toList()); - result = OkHttpUtils.postWithForm(fufeitongConfig.getAliPayUrl(), httpForms); - - log.info("付费通支付宝请求结果:{}",result); - - } catch (Exception e) { - log.error("付费通支付宝创建订单失败。params:" + JSONObject.toJSONString(orderReqParams), e); - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失败,请重试"); - } - - FufeitongBaseRes res = JSONObject.parseObject(result, FufeitongBaseRes.class); - if (!res.getRespCode().equals(FufeitongConstant.SUCCESS_CODE)) { - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失败:" + res.getMessage()); - } - return res; - } - - public boolean verifySign(Map resultMap) { - Map paramsMap = new HashMap<>(resultMap.size()); - resultMap.forEach((key, value) -> { - if (!key.toString().equals(FufeitongConstant.SIGN_FIELD_NAME) && value != null) { - paramsMap.put(key.toString(), value.toString()); - } - }); - - String sign = getSign(paramsMap, fufeitongConfig); - String resultSign = resultMap.get(FufeitongConstant.SIGN_FIELD_NAME).toString(); - - return sign.equalsIgnoreCase(resultSign); - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/bo/FufeitongBaseRes.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/bo/FufeitongBaseRes.java deleted file mode 100644 index f41ce8c4f..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/bo/FufeitongBaseRes.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.accompany.payment.fufeitong.bo; - -import lombok.Data; - -@Data -public class FufeitongBaseRes { - - /** 响应码 */ - protected String respCode; - - /** 响应信息 */ - protected String message; - - /** 商户编号 */ - protected String merchno; - - /** 商户支付订单号 */ - protected String traceno; - - /** 渠道订单号 */ - protected String refno; - - /** 跳转地址或二维码地址 */ - protected String barCode; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/bo/FufeitongWxOpenOrderRes.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/bo/FufeitongWxOpenOrderRes.java deleted file mode 100644 index 66860d77f..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/bo/FufeitongWxOpenOrderRes.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.accompany.payment.fufeitong.bo; - -import com.accompany.payment.vo.WeChatMiniAppPayResponseVO; -import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; - -@Data -public class FufeitongWxOpenOrderRes extends FufeitongBaseRes { - - private WeChatMiniAppPayResponseVO miniAppPayInfo; - - @JSONField(name = "payInfo") - private String payInfoStr; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/params/FufeitongCreateOrderBaseReqParams.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/params/FufeitongCreateOrderBaseReqParams.java deleted file mode 100644 index 07f555dcb..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/params/FufeitongCreateOrderBaseReqParams.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.accompany.payment.fufeitong.params; - -import lombok.Data; - -import java.math.BigDecimal; - -@Data -public class FufeitongCreateOrderBaseReqParams { - - /** - * 商户订单号 - */ - protected String traceno; - - /** - * 交易金额 - */ - protected BigDecimal amount; - - /** - * 支付方式 - */ - protected String payType; - - /** - * 页面返回地址 - */ - protected String returnUrl; - - /** - * 商品名称 - */ - protected String goodsName; - - /** 自定义域1 **/ - protected String cust1; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/params/FufeitongWxOrderReqParams.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/params/FufeitongWxOrderReqParams.java deleted file mode 100644 index 2b271d912..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/fufeitong/params/FufeitongWxOrderReqParams.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.accompany.payment.fufeitong.params; - -import lombok.Data; - -@Data -public class FufeitongWxOrderReqParams extends FufeitongCreateOrderBaseReqParams { - - private String openId; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/BaseGuotongPayConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/BaseGuotongPayConfig.java deleted file mode 100644 index 8442eff42..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/BaseGuotongPayConfig.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.accompany.payment.guotongpay; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -@Data -public class BaseGuotongPayConfig { - private String account; - - private String key; - - private String wxMiniproAppId; - - private String notifyUrl; - - private String unifiedorderUrl; - - private String wxMiniproOrderUrl; - - /** - * 微信公众号appid - */ - private String wxPubAppId; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/GuotongForZjlxPayConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/GuotongForZjlxPayConfig.java deleted file mode 100644 index 59fd44d8b..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/GuotongForZjlxPayConfig.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.accompany.payment.guotongpay; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -/** - * 中嘉主体的国通配置 - */ -@Configuration -@ConfigurationProperties("guotong-pay-zjlx") -@Data -public class GuotongForZjlxPayConfig extends BaseGuotongPayConfig { - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/GuotongPayConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/GuotongPayConfig.java deleted file mode 100644 index fe83741f9..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/GuotongPayConfig.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.accompany.payment.guotongpay; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -/** - * 芒果主体的国通配置 - */ -@Configuration -@ConfigurationProperties("guotong-pay") -@Data -public class GuotongPayConfig extends BaseGuotongPayConfig { - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/GuotongPayConstant.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/GuotongPayConstant.java deleted file mode 100644 index 8bea7583f..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/GuotongPayConstant.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.accompany.payment.guotongpay; - -public class GuotongPayConstant { - - public final static int PAY_TYPE_WX = 0; - - public final static int PAY_TYPE_ZFB = 1; - - /** - * 下单成功 - */ - public final static int CREATE_ORDER_STATUS_SUCCESS = 100; - - public final static String SIGN_FIELD_NAME = "sign"; - - /** - * 支付状态 - */ - public final static int PAY_STATUS_SUCCESS = 0; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/GuotongPayService.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/GuotongPayService.java deleted file mode 100644 index ab7af9020..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/GuotongPayService.java +++ /dev/null @@ -1,256 +0,0 @@ -package com.accompany.payment.guotongpay; - -import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.BeanUtil; -import com.accompany.common.utils.HttpUtils; -import com.accompany.common.utils.StringUtils; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.util.JsonUtil; -import com.accompany.payment.guotongpay.bo.GuotongPayResultBO; -import com.accompany.payment.guotongpay.bo.GuotongWxMiniPayResultBO; -import com.accompany.payment.guotongpay.params.GuoTongCreateOrderReqParams; -import com.accompany.payment.guotongpay.params.GuotongWxMiniPayReqParams; -import com.accompany.payment.utils.CommonPayUtils; -import com.accompany.payment.vo.JsapiReturnVo; -import com.accompany.payment.vo.WeChatMiniAppPayResponseVO; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.jetbrains.annotations.NotNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; - -@Service -@Slf4j -public class GuotongPayService { - - @Autowired - private GuotongPayConfig guotongPayConfig; - @Autowired - GuotongForZjlxPayConfig guotongForZjlxPayConfig; - - /** - * 公众号、小程序支付中设置是否小程序支付 - */ - private static final String IS_MINI_PG = "1"; - private static final String IS_NOT_MINI_PG = "0"; - - public GuotongPayResultBO createOrder(GuoTongCreateOrderReqParams params) { - checkParams(params); - - String result = null; - try { - Map tmpParams = BeanUtil.objectToMap(params); - Map requestParams = tmpParams.keySet().stream().collect(Collectors.toMap(it -> it, it -> { - if (tmpParams.containsKey(it)) { - return tmpParams.get(it).toString(); - } else { - return null; - } - })); - requestParams.put("account", guotongPayConfig.getAccount()); - requestParams.put("notifyUrl", guotongPayConfig.getNotifyUrl()); - - String sign = getSign(requestParams, guotongPayConfig); - requestParams.put("sign", sign); - - Map headers = buildHeaders(); - - log.info("国通支付请求参数:{}, 请求头:{}",JSONObject.toJSONString(requestParams), JSONObject.toJSONString(headers)); - - result = HttpUtils.doPostForJson(guotongPayConfig.getUnifiedorderUrl(), JSONObject.toJSONString(requestParams), headers); - - log.info("国通支付请求结果:{}",result); - - } catch (IOException e) { - log.error("国通创建订单失败。params:" + JSONObject.toJSONString(params), e); - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失败,请重试"); - } - - GuotongPayResultBO res = JSONObject.parseObject(result, GuotongPayResultBO.class); - if (res.getStatus() != GuotongPayConstant.CREATE_ORDER_STATUS_SUCCESS) { - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失败:" + res.getMessage()); - } - return res; - - } - - @NotNull - private String getSign(Map requestParams, BaseGuotongPayConfig guotongPayConfig) { - return CommonPayUtils.signParams(requestParams, "key", guotongPayConfig.getKey()); - } - - private Map buildHeaders() { - Map headers = new HashMap<>(); - headers.put("Content-Type", "application/json"); - - return headers; - } - - private void checkParams(GuoTongCreateOrderReqParams params) { - if (params == null) { - throw new ServiceException(BusiStatus.PARAMERROR); - } - if (params.getPayMoney() == null || params.getPayMoney().compareTo(BigDecimal.ZERO) <= 0) { - params.setPayMoney(new BigDecimal("0.01")); - } - if (StringUtils.isBlank(params.getLowOrderId())) { - throw new ServiceException(BusiStatus.PARAMERROR, "商户订单号不能为空"); - } - if (StringUtils.isBlank(params.getBody())) { - throw new ServiceException(BusiStatus.PARAMERROR, "商品订单描述不能为空"); - } - if (params.getPayType() == null) { - throw new ServiceException(BusiStatus.PARAMERROR, "支付方式不能为空"); - } - } - - public GuotongWxMiniPayResultBO createWxMiniproOrder(GuotongWxMiniPayReqParams params) { - return createWxMiniproOrderBase(params, guotongPayConfig); - } - - public GuotongWxMiniPayResultBO createWxMiniproOrderForZjlx(GuotongWxMiniPayReqParams params) { - return createWxMiniproOrderBase(params, guotongForZjlxPayConfig); - } - - private GuotongWxMiniPayResultBO createWxMiniproOrderBase(GuotongWxMiniPayReqParams params, BaseGuotongPayConfig guotongPayConfig) { - checkWxMiniPayParams(params); - - String result = null; - try { - Map tmpParams = BeanUtil.objectToMap(params); - Map requestParams = tmpParams.keySet().stream().collect(Collectors.toMap(it -> it, it -> { - if (tmpParams.containsKey(it)) { - return tmpParams.get(it).toString(); - } else { - return null; - } - })); - requestParams.put("account", guotongPayConfig.getAccount()); - requestParams.put("notifyUrl", guotongPayConfig.getNotifyUrl()); - requestParams.put("appId", guotongPayConfig.getWxMiniproAppId()); - requestParams.put("isMinipg", IS_MINI_PG); - - String sign = getSign(requestParams, guotongPayConfig); - requestParams.put("sign", sign); - - Map headers = buildHeaders(); - - log.info("国通小程序支付请求参数:{}, 请求头:{}",JSONObject.toJSONString(requestParams), JSONObject.toJSONString(headers)); - - result = HttpUtils.doPostForJson(guotongPayConfig.getWxMiniproOrderUrl(), JSONObject.toJSONString(requestParams), headers); - - log.info("国通支付请求结果:{}",result); - - } catch (IOException e) { - log.error("国通小程序创建订单失败。params:" + JSONObject.toJSONString(params), e); - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失败,请重试"); - } - - GuotongWxMiniPayResultBO res = JSONObject.parseObject(result, GuotongWxMiniPayResultBO.class); - if (res.getStatus() != GuotongPayConstant.CREATE_ORDER_STATUS_SUCCESS) { - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失败:" + res.getMessage()); - } - res.setPayInfo(JsonUtil.parseToClass(res.getPayInfoStr(), WeChatMiniAppPayResponseVO.class)); - return res; - } - - public JsapiReturnVo createWxPubOrderForZjlx(GuotongWxMiniPayReqParams params) { - return createWxPubOrderBase(params, guotongForZjlxPayConfig); - } - - /** - * 创建公众号订单 - * @param params - * @param guotongPayConfig - * @return - */ - private JsapiReturnVo createWxPubOrderBase(GuotongWxMiniPayReqParams params, BaseGuotongPayConfig guotongPayConfig) { - checkWxMiniPayParams(params); - - String result = null; - try { - Map tmpParams = BeanUtil.objectToMap(params); - Map requestParams = tmpParams.keySet().stream().collect(Collectors.toMap(it -> it, it -> { - if (tmpParams.containsKey(it)) { - return tmpParams.get(it).toString(); - } else { - return null; - } - })); - requestParams.put("account", guotongPayConfig.getAccount()); - requestParams.put("notifyUrl", guotongPayConfig.getNotifyUrl()); - requestParams.put("appId", guotongPayConfig.getWxPubAppId()); - requestParams.put("isMinipg", IS_NOT_MINI_PG); - - String sign = getSign(requestParams, guotongPayConfig); - requestParams.put("sign", sign); - - Map headers = buildHeaders(); - - log.info("国通公众号支付请求参数:{}, 请求头:{}",JSONObject.toJSONString(requestParams), JSONObject.toJSONString(headers)); - - result = HttpUtils.doPostForJson(guotongPayConfig.getWxMiniproOrderUrl(), JSONObject.toJSONString(requestParams), headers); - - log.info("国通公众号支付请求结果:{}",result); - - } catch (IOException e) { - log.error("国通公众号创建订单失败。params:" + JSONObject.toJSONString(params), e); - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失败,请重试"); - } - - GuotongWxMiniPayResultBO res = JSONObject.parseObject(result, GuotongWxMiniPayResultBO.class); - if (res.getStatus() != GuotongPayConstant.CREATE_ORDER_STATUS_SUCCESS) { - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失败:" + res.getMessage()); - } - return buildUnionPublicVO(JsonUtil.parseToClass(res.getPayInfoStr(), WeChatMiniAppPayResponseVO.class)); - } - - private JsapiReturnVo buildUnionPublicVO(WeChatMiniAppPayResponseVO publicPayResponseVO) { - JsapiReturnVo jsapiReturnVo = new JsapiReturnVo(); - jsapiReturnVo.setTimestamp(publicPayResponseVO.getTimeStamp()); - jsapiReturnVo.setNonce_str(publicPayResponseVO.getNonceStr()); - jsapiReturnVo.setPrepay_id(publicPayResponseVO.getPackageInfo()); - jsapiReturnVo.setSign(publicPayResponseVO.getPaySign()); - jsapiReturnVo.setAppid(publicPayResponseVO.getAppId()); - jsapiReturnVo.setSign_type(publicPayResponseVO.getSignType()); - return jsapiReturnVo; - } - - private void checkWxMiniPayParams(GuotongWxMiniPayReqParams params) { - if (params == null) { - throw new ServiceException(BusiStatus.PARAMERROR); - } - if (params.getPayMoney() == null || params.getPayMoney().compareTo(BigDecimal.ZERO) <= 0) { - params.setPayMoney(new BigDecimal("0.01")); - } - if (StringUtils.isBlank(params.getLowOrderId())) { - throw new ServiceException(BusiStatus.PARAMERROR, "商户订单号不能为空"); - } - if (StringUtils.isBlank(params.getBody())) { - throw new ServiceException(BusiStatus.PARAMERROR, "商品订单描述不能为空"); - } - if (StringUtils.isBlank(params.getOpenId())) { - throw new ServiceException(BusiStatus.PARAMERROR, "微信openId不能为空"); - } - } - - public boolean checkSign(Map resultMap, BaseGuotongPayConfig guotongPayConfig) { - Map paramsMap = new HashMap<>(resultMap.size()); - resultMap.forEach((key, value) -> { - if (!key.toString().equals(GuotongPayConstant.SIGN_FIELD_NAME) && value != null) { - paramsMap.put(key.toString(), value.toString()); - } - }); - - String sign = getSign(paramsMap, guotongPayConfig); - String resultSign = resultMap.get(GuotongPayConstant.SIGN_FIELD_NAME).toString(); - - return sign.equalsIgnoreCase(resultSign); - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/bo/GuotongPayResultBO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/bo/GuotongPayResultBO.java deleted file mode 100644 index 4d0c09238..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/bo/GuotongPayResultBO.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.accompany.payment.guotongpay.bo; - -import lombok.Data; - -@Data -public class GuotongPayResultBO { - - /** - * 订单二维码url - */ - private String codeUrl; - - /** - * 通莞金服订单 - */ - private String orderId; - - /** - * 4:待支付 - */ - private String state; - - /** - * 签名 - */ - private String sign; - - /** - * 信息描述 - */ - private String message; - - /** - * 下游订单号 - */ - private String lowOrderId; - - /** - * 聚合支付账号 - */ - private String account; - - /** - * 100:成功,101:失败 - */ - private Integer status; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/bo/GuotongWxMiniPayResultBO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/bo/GuotongWxMiniPayResultBO.java deleted file mode 100644 index 3a5041455..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/bo/GuotongWxMiniPayResultBO.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.accompany.payment.guotongpay.bo; - -import com.accompany.payment.vo.WeChatMiniAppPayResponseVO; -import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; - -@Data -public class GuotongWxMiniPayResultBO { - - /** - * 通莞金服订单 - */ - private String upOrderId; - - /** - * 原生态js支付是的参数 - */ - @JSONField(name = "pay_info") - private String payInfoStr; - - /** - * 签名 - */ - private String sign; - - /** - * 信息描述 - */ - private String message; - - /** - * 微信禁用pay_url,返参为null - */ - @JSONField(name = "pay_url") - private String payUrl; - - /** - * 100:成功,101:失败 - */ - private Integer status; - - /** - * payInfoStrjson解析后的对象 - */ - private WeChatMiniAppPayResponseVO payInfo; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/params/GuoTongCreateOrderReqParams.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/params/GuoTongCreateOrderReqParams.java deleted file mode 100644 index b17ad4b20..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/params/GuoTongCreateOrderReqParams.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.accompany.payment.guotongpay.params; - -import lombok.Data; - -@Data -public class GuoTongCreateOrderReqParams extends GuotongBaseReqParams { - - /** - * 支付方式 0:微信,1:支付宝,4:银联 - */ - private Integer payType; - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/params/GuotongBaseReqParams.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/params/GuotongBaseReqParams.java deleted file mode 100644 index 67dd793f7..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/params/GuotongBaseReqParams.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.accompany.payment.guotongpay.params; - -import lombok.Data; - -import java.math.BigDecimal; - -@Data -public class GuotongBaseReqParams { - /** - * 支付金额 单位:元 - */ - private BigDecimal payMoney; - - /** - * 下游订单号 - */ - private String lowOrderId; - - /** - * 商品订单描述 - */ - private String body; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/params/GuotongWxMiniPayReqParams.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/params/GuotongWxMiniPayReqParams.java deleted file mode 100644 index ef6c051a2..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/guotongpay/params/GuotongWxMiniPayReqParams.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.accompany.payment.guotongpay.params; - -import lombok.Data; - -@Data -public class GuotongWxMiniPayReqParams extends GuotongBaseReqParams { - - /** - * 微信openId - */ - private String openId; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/BaseConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/BaseConfig.java deleted file mode 100644 index 6590a5e51..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/BaseConfig.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.accompany.payment.heepay; - -import lombok.Data; - -@Data -public abstract class BaseConfig { - /** 后台异步通知 url */ - protected String notifyUrl; - - /** 商户号 */ - protected String agentId; - - /** 商户密钥 */ - protected String agentKey; - - /** - * 请求时的meta_option参数 - */ - protected String metaOption; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/HeePayConstant.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/HeePayConstant.java deleted file mode 100644 index 6ce0030d3..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/HeePayConstant.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.accompany.payment.heepay; - -public class HeePayConstant { - - public final static String VERSION = "1"; - - public final static int PAY_TYPE_WX = 30; - - public final static String PAY_SCENE_H5 = "h5"; - - public final static String SIGN_TYPE = "MD5"; - - public final static String PAYMENT_MODE = "cashier"; - - public final static byte BANK_CARD_TYPE_UNKONW = -1; - - public final static String SUCCESS_CODE = "0000"; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/HeePayH5Config.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/HeePayH5Config.java deleted file mode 100644 index 8e31f640c..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/HeePayH5Config.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.accompany.payment.heepay; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - * 汇付宝支付的配置 - */ -@Component -@ConfigurationProperties("hui-fu-bao") -@Data -public class HeePayH5Config extends BaseConfig { - - /** - * 微信h5支付url - */ - private String wxH5PayUrl; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/HeePayService.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/HeePayService.java deleted file mode 100644 index 78325c773..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/HeePayService.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.accompany.payment.heepay; - -import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.StringUtils; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.util.JsonUtil; -import com.accompany.payment.heepay.bo.WxH5PayResBO; -import com.accompany.payment.heepay.bo.WxMiniproPayResBO; -import com.accompany.payment.heepay.bo.WxPubPayResBO; -import com.accompany.payment.heepay.params.NotifyParams; -import com.accompany.payment.heepay.params.PayRequestParams; -import com.accompany.payment.heepay.params.WxH5PayReqParams; -import com.accompany.payment.heepay.sdk.Common.DataHelper; -import com.accompany.payment.heepay.sdk.Common.Md5Tools; -import com.accompany.payment.huiju.HuiJuWeChatMiniPayInfoVO; -import com.accompany.payment.wxpay.XMLParser; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.xml.sax.SAXException; -import sun.misc.BASE64Encoder; - -import javax.xml.parsers.ParserConfigurationException; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -@Service -@Slf4j -@Lazy(false) -public class HeePayService { - - @Autowired - private HeePayH5Config heePayH5Config; - @Autowired - private HeePayWxConfig heePayWxConfig; - - private final static String RES_FIELD_RET_CODE = "ret_code"; - private final static String RES_FIELD_RET_MSG = "ret_msg"; - - private static final String REAL_PAY_CHANNEL_HUI_FU_BAO = "hui_fu_bao"; - - // 用于匹配微信支付调用成功时返回的tokenId - private final static Pattern TOKEN_ID_PATTERN = Pattern.compile("(.*)"); - - private final static String IS_PHONE_YES = "1"; - - private final static String IS_FRAME_YES = "1"; - - /** - * 发起微信h5支付 - * - * @param params - * @return - * - * @author Chenzhixiang - */ - public WxH5PayResBO wxH5Pay(WxH5PayReqParams params) { - String sign = signForH5Pay(params); - try { - String requestUrl = buildReqUrlForH5Pay(params, sign); - String result = DataHelper.RequestGetUrl(requestUrl); - return buildResForH5Pay(result); - } catch (Exception e) { - log.error("汇付宝支付异常", e); - throw new ServiceException(BusiStatus.UNKNOWN); - } - } - - private WxH5PayResBO buildResForH5Pay(String result) throws IOException, SAXException, ParserConfigurationException { - log.info("pay result: {}", result); - Map resMap = XMLParser.getMapFromXML(result); - WxH5PayResBO res = new WxH5PayResBO(); - res.setRetCode(resMap.get(RES_FIELD_RET_CODE).toString()); - res.setRetMsg(resMap.get(RES_FIELD_RET_MSG).toString()); - if (HeePayConstant.SUCCESS_CODE.equalsIgnoreCase(res.getRetCode())) { - res.setSuccess(true); - res.setRedirectUrl(resMap.get("redirectUrl").toString()); - } else { - res.setSuccess(false); - } - return res; - } - - private String signForH5Pay(WxH5PayReqParams params) { - StringBuilder strForSign = new StringBuilder("version=").append(HeePayConstant.VERSION) - .append("&agent_id=").append(heePayH5Config.getAgentId()) - .append("&agent_bill_id=").append(params.getAgentBillId()) - .append("&agent_bill_time=").append(params.getAgentBillTime()) - .append("&pay_type=").append(HeePayConstant.PAY_TYPE_WX) - .append("&pay_amt=").append(params.getPayAmt().toString()) - .append("¬ify_url=").append(heePayH5Config.getNotifyUrl()) - .append("&return_url=").append(params.getReturnUrl()) - .append("&user_ip=").append(params.getUserIp()) - .append("&bank_card_type=").append(params.getBankCardType()) - .append("&remark=").append(params.getRemark()) - .append("&key=").append(heePayH5Config.getAgentKey()); - - return Md5Tools.MD5(strForSign.toString()); - } - - private String buildReqUrlForH5Pay(WxH5PayReqParams params, String sign) throws UnsupportedEncodingException { - StringBuilder reqUrl = new StringBuilder(heePayH5Config.getWxH5PayUrl()).append("?") - .append("version=").append(HeePayConstant.VERSION) - .append("&scene=").append(params.getScene()) - .append("&pay_type=").append(HeePayConstant.PAY_TYPE_WX) - .append("&agent_id=").append(heePayH5Config.getAgentId()) - .append("&agent_bill_id=").append(params.getAgentBillId()) - .append("&pay_amt=").append(params.getPayAmt().toString()) - .append("¬ify_url=").append(heePayH5Config.getNotifyUrl()) - .append("&return_url=").append(params.getReturnUrl()) - .append("&user_ip=").append(params.getUserIp()) - .append("&agent_bill_time=").append(params.getAgentBillTime()) - .append("&goods_name=").append(URLEncoder.encode(params.getGoodsName(), DataHelper.GBKEncode)) - .append("&remark=").append(URLEncoder.encode(params.getRemark(), DataHelper.GBKEncode)) - .append("&sign_type=").append(HeePayConstant.SIGN_TYPE); - if (StringUtils.isNotBlank(params.getGoodsNote())) { - reqUrl.append("&goods_note=").append(URLEncoder.encode(params.getGoodsNote(), DataHelper.GBKEncode)); - } - String metaOption = encodeMetaOption(heePayH5Config.getMetaOption()); - reqUrl.append("&meta_option=").append(metaOption) - .append("&payment_mode=").append(HeePayConstant.PAYMENT_MODE) - .append("&bank_card_type=").append(params.getBankCardType()) - .append("&sign=").append(sign); - - return reqUrl.toString(); - } - - private String encodeMetaOption(String metaOption) throws UnsupportedEncodingException { - return URLEncoder.encode(new BASE64Encoder().encode(metaOption.getBytes("gb2312")),DataHelper.UTF8Encode); - } - - /** - * 发起小程序支付 - * - * @param params - * @return - * - * @author Chenzhixiang - */ - public WxMiniproPayResBO payByWxMinipro(PayRequestParams params) { - try { - String sign = signForWxMiniproPay(params); - String requestUrl = buildReqUrlForWxMiniproPay(params, sign); - String result = DataHelper.RequestGetUrl(requestUrl); - return buildResForWxMiniproPay(result); - } catch (Exception e) { - log.error("汇付宝发起微信小程序支付异常", e); - throw new ServiceException(BusiStatus.UNKNOWN); - } - } - - public HuiJuWeChatMiniPayInfoVO weChatMiniAppPay(PayRequestParams params) { - WxMiniproPayResBO bo = payByWxMinipro(params); - String requestUrl = heePayWxConfig.getWxMiniproJsUrl() + String.format("?stid=%s&sub_appid=%s&sub_openid=%s", - bo.getTokenId(), heePayWxConfig.getWxMiniproAppid(), params.getOpenId()); - String result = DataHelper.RequestGetUrl(requestUrl); - return JsonUtil.parseToClass(result, HuiJuWeChatMiniPayInfoVO.class); - } - - private String signForWxMiniproPay(PayRequestParams params) { - StringBuilder strForSign = new StringBuilder("version=").append(HeePayConstant.VERSION) - .append("&agent_id=").append(heePayWxConfig.getAgentId()) - .append("&agent_bill_id=").append(params.getAgentBillId()) - .append("&agent_bill_time=").append(params.getAgentBillTime()) - .append("&pay_type=").append(HeePayConstant.PAY_TYPE_WX) - .append("&pay_amt=").append(params.getPayAmt().toString()) - .append("¬ify_url=").append(heePayWxConfig.getNotifyUrl()) - .append("&user_ip=").append(params.getUserIp()) - .append("&key=").append(heePayWxConfig.getAgentKey()); - return Md5Tools.MD5(strForSign.toString()); - } - - private String buildReqUrlForWxMiniproPay(PayRequestParams params, String sign) throws UnsupportedEncodingException { - String metaOption = encodeMetaOption(heePayWxConfig.getMetaOption()); - StringBuilder reqUrl = new StringBuilder(heePayWxConfig.getWxMiniproPayUrl()).append("?") - .append("version=").append(HeePayConstant.VERSION) - .append("&pay_type=").append(HeePayConstant.PAY_TYPE_WX) - .append("&agent_id=").append(heePayWxConfig.getAgentId()) - .append("&agent_bill_id=").append(params.getAgentBillId()) - .append("&pay_amt=").append(params.getPayAmt().toString()) - .append("¬ify_url=").append(heePayWxConfig.getNotifyUrl()) - .append("&return_url=").append(params.getReturnUrl()) - .append("&user_ip=").append(params.getUserIp()) - .append("&agent_bill_time=").append(params.getAgentBillTime()) - .append("&goods_name=").append(URLEncoder.encode(params.getGoodsName(), DataHelper.GBKEncode)) - .append("&remark=").append(URLEncoder.encode(params.getRemark(), DataHelper.GBKEncode)) - .append("&sign_type=").append(HeePayConstant.SIGN_TYPE) - .append("&meta_option=").append(metaOption) - .append("&sign=").append(sign); - return reqUrl.toString(); - } - - private WxMiniproPayResBO buildResForWxMiniproPay(String result) throws IOException, SAXException, ParserConfigurationException { - log.info("huifubao wx minipro pay result: {}", result); - Map resMap = XMLParser.getMapFromXML(result); - WxMiniproPayResBO res = new WxMiniproPayResBO(); - res.setSuccess(false); - if (resMap.size() == 0) { - // 没有解析出来东西,表示只有一个token_id节点,使用正则表达式获取 - Matcher matcher = TOKEN_ID_PATTERN.matcher(result); - if (matcher.find()) { - res.setSuccess(true); - res.setTokenId(matcher.group(1)); - } - } else { - if (resMap.containsKey(RES_FIELD_RET_CODE)) { - res.setRetCode(resMap.get(RES_FIELD_RET_CODE).toString()); - } - if (resMap.containsKey(RES_FIELD_RET_MSG)) { - res.setRetMsg(resMap.get(RES_FIELD_RET_MSG).toString()); - } - if (StringUtils.isNotBlank(res.getRetCode()) && !HeePayConstant.SUCCESS_CODE.equalsIgnoreCase(res.getRetCode())) { - res.setSuccess(false); - } else { - res.setSuccess(true); - res.setTokenId(resMap.get("token_id").toString()); - } - } - res.setRealPayChannel(REAL_PAY_CHANNEL_HUI_FU_BAO); - return res; - } - - /** - * 微信公众号支付 - * - * @param params - * @return - */ - public WxPubPayResBO payByWxPub(PayRequestParams params) { - try { - String sign = signforWxPubPay(params); - String requestUrl = buildReqUrlForWxPubPay(params, sign); - log.info("huifubao wx pub pay redirect: {}", requestUrl); - // 公众号的直接将拼接好的url给客户端跳转 - WxPubPayResBO res = new WxPubPayResBO(); - res.setSuccess(true); - res.setRealPayChannel(REAL_PAY_CHANNEL_HUI_FU_BAO); - res.setRedirectUrl(requestUrl); - return res; - } catch (Exception e) { - log.error("汇付宝发起微信公众号支付异常", e); - throw new ServiceException(BusiStatus.UNKNOWN); - } - } - - private String signforWxPubPay(PayRequestParams params) { - StringBuilder strForSign = new StringBuilder("version=").append(HeePayConstant.VERSION) - .append("&agent_id=").append(heePayWxConfig.getAgentId()) - .append("&agent_bill_id=").append(params.getAgentBillId()) - .append("&agent_bill_time=").append(params.getAgentBillTime()) - .append("&pay_type=").append(HeePayConstant.PAY_TYPE_WX) - .append("&pay_amt=").append(params.getPayAmt().toString()) - .append("¬ify_url=").append(heePayWxConfig.getNotifyUrl()) - .append("&return_url=").append(params.getReturnUrl()) - .append("&user_ip=").append(params.getUserIp()) - .append("&key=").append(heePayWxConfig.getAgentKey()); - - return Md5Tools.MD5(strForSign.toString()); - } - - private String buildReqUrlForWxPubPay(PayRequestParams params, String sign) throws UnsupportedEncodingException { - String metaOption = encodeMetaOption(heePayWxConfig.getMetaOption()); - StringBuilder reqUrl = new StringBuilder(heePayWxConfig.getWxPubPayUrl()).append("?") - .append("version=").append(HeePayConstant.VERSION) - .append("&is_phone=").append(IS_PHONE_YES) - .append("&is_frame=").append(IS_FRAME_YES) - .append("&pay_type=").append(HeePayConstant.PAY_TYPE_WX) - .append("&agent_id=").append(heePayWxConfig.getAgentId()) - .append("&agent_bill_id=").append(params.getAgentBillId()) - .append("&pay_amt=").append(params.getPayAmt().toString()) - .append("¬ify_url=").append(heePayWxConfig.getNotifyUrl()) - .append("&return_url=").append(params.getReturnUrl()) - .append("&user_ip=").append(params.getUserIp()) - .append("&agent_bill_time=").append(params.getAgentBillTime()) - .append("&goods_name=").append(URLEncoder.encode(params.getGoodsName(), DataHelper.GBKEncode)) - .append("&remark=").append(URLEncoder.encode(params.getRemark(), DataHelper.GBKEncode)) - .append("&sign_type=").append(HeePayConstant.SIGN_TYPE) - .append("&meta_option=").append(metaOption) - .append("&sign=").append(sign); - return reqUrl.toString(); - } - - /** - * 校验支付通知sign - * @param params - * @return - */ - public boolean verifyNotifySign(NotifyParams params) { - String signCalFromParams = calcSign(params, heePayH5Config.getAgentKey()); - return signCalFromParams.equalsIgnoreCase(params.getSign()); - } - - /** - * 计算签名 - * - * @param params - * @param agentKey - * @return - */ - private String calcSign(NotifyParams params, String agentKey) { - StringBuilder strForSign = new StringBuilder("result=").append(params.getResult()) - .append("&agent_id=").append(params.getAgentId()) - .append("&jnet_bill_no=").append(params.getJnetBillNo()) - .append("&agent_bill_id=").append(params.getAgentBillId()) - .append("&pay_type=").append(params.getPayType()) - .append("&pay_amt=").append(params.getPayAmt().toString()) - .append("&remark=").append(params.getRemark()) - .append("&key=").append(agentKey); - - return Md5Tools.MD5(strForSign.toString()); - } - - /** - * 校验支付通知sign,供小程序、公众号环境使用 - * @param params - * @return - */ - public boolean verifyNotifySignForWxEnv(NotifyParams params) { - String signCalFromParams = calcSign(params, heePayWxConfig.getAgentKey()); - return signCalFromParams.equalsIgnoreCase(params.getSign()); - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/HeePayWxConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/HeePayWxConfig.java deleted file mode 100644 index 0a31d83b8..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/HeePayWxConfig.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.accompany.payment.heepay; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - * 用于微信公众号或小程序支付的配置 - */ -@Component -@ConfigurationProperties("hui-fu-bao-wx-env") -@Data -public class HeePayWxConfig extends BaseConfig { - - /** - * 微信小程序支付tokenid url - */ - private String wxMiniproPayUrl; - - /** - * 微信小程序支付jsapi url - */ - private String wxMiniproJsUrl; - - /** - * 微信公众号支付url - */ - private String wxPubPayUrl; - - /** - * 微信小程序appid - */ - private String wxMiniproAppid; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/bo/ResponseBO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/bo/ResponseBO.java deleted file mode 100644 index dd0096d79..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/bo/ResponseBO.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.accompany.payment.heepay.bo; - -import lombok.Data; - -/** - * 调用结果 - * - * @author Chenzhixiang - * @date 2020年08月13日 - */ -@Data -public class ResponseBO { - - /** - * 请求是否成功 - */ - private Boolean success; - - /** - * 返回码 - */ - private String retCode; - - /** - * 返回码信息提示 - */ - private String retMsg; - /** - * 昵称 - */ - private String nick; - - /** - * 平台号 - */ - private Long erban_no; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/bo/WxH5PayResBO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/bo/WxH5PayResBO.java deleted file mode 100644 index 338d697fe..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/bo/WxH5PayResBO.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.accompany.payment.heepay.bo; - -import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; - -/** - * 微信h5调用结果 - * - * @author Chenzhixiang - * @date 2020年08月13日 - */ -@Data -public class WxH5PayResBO extends ResponseBO { - - /** - * 返回的URL - */ - @JSONField(name = "mweb_url") - private String redirectUrl; - - /** - * MD5签名 - */ - private String sign; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/bo/WxMiniproPayResBO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/bo/WxMiniproPayResBO.java deleted file mode 100644 index 0219adaca..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/bo/WxMiniproPayResBO.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.accompany.payment.heepay.bo; - -import lombok.Data; - -/** - * 微信小程序支付调用结果 - * - * @author Chenzhixiang - * @date 2020年08月14日 - */ -@Data -public class WxMiniproPayResBO extends ResponseBO { - - /** - * token - */ - private String tokenId; - - /** - * 真正的支付渠道,供前端判断 - */ - private String realPayChannel; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/bo/WxPubPayResBO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/bo/WxPubPayResBO.java deleted file mode 100644 index dc0ee0bb8..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/bo/WxPubPayResBO.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.accompany.payment.heepay.bo; - -import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; - -/** - * 微信公众号支付结果 - * - * @author Chenzhixiang - * @date 2020年08月17日 - */ -@Data -public class WxPubPayResBO extends ResponseBO { - - /** - * 返回的URL - */ - @JSONField(name = "mweb_url") - private String redirectUrl; - - /** - * 真正的支付渠道,供前端判断 - */ - private String realPayChannel; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/params/NotifyParams.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/params/NotifyParams.java deleted file mode 100644 index fd6d13776..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/params/NotifyParams.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.accompany.payment.heepay.params; - -import lombok.Data; - -import java.math.BigDecimal; - -@Data -public class NotifyParams { - - /** - * 支付结果,, 1=成功 其它为未知 - */ - private Short result; - - /** - * 商户编号 - */ - private String agentId; - - /** - * 汇付宝订单号 - */ - private String jnetBillNo; - - /** - * 商户系统内部的订单号 - */ - private String agentBillId; - - /** - * 支付类型 - */ - private String payType; - - /** - * 订单实际支付金额 - */ - private BigDecimal payAmt; - - /** - * 商家数据包,原样返回 - */ - private String remark; - - /** - * MD5签名 - */ - private String sign; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/params/PayRequestParams.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/params/PayRequestParams.java deleted file mode 100644 index 0e9c7f625..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/params/PayRequestParams.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.accompany.payment.heepay.params; - -import lombok.Data; - -import java.math.BigDecimal; - -/** - * 支付请求参数 - * - */ -@Data -public class PayRequestParams { - - /** - * 商户订单号 - */ - private String agentBillId; - - /** - * 支付金额,单位元 - */ - private BigDecimal payAmt; - - /** - * 同步通知地址 - */ - private String returnUrl; - - /** - * 用户ip - */ - private String userIp; - - /** - * 提交单据的时间yyyyMMddHHmmss - */ - private String agentBillTime; - - /** - * 商品名称 - */ - private String goodsName; - - /** - * 自定义参数 - */ - private String remark; - - /** - * 支付说明 - */ - private String goodsNote; - - /** - * 银行类型 - */ - private Byte bankCardType; - - /** - * openid - */ - private String openId; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/params/WxH5PayReqParams.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/params/WxH5PayReqParams.java deleted file mode 100644 index fbe73f6a9..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/params/WxH5PayReqParams.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.accompany.payment.heepay.params; - -import lombok.Data; - -/** - * 微信h5支付请求参数 - * - */ -@Data -public class WxH5PayReqParams extends PayRequestParams { - - /** - * 支付方式,h5表示h5, - */ - private String scene; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/sdk/Common/DataHelper.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/sdk/Common/DataHelper.java deleted file mode 100644 index 530db9c20..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/sdk/Common/DataHelper.java +++ /dev/null @@ -1,160 +0,0 @@ -package com.accompany.payment.heepay.sdk.Common; - -import java.io.DataInputStream; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -public class DataHelper { - public final static String UTF8Encode="UTF-8"; - public final static String GBKEncode="GBK"; - public final static String sign_key = "33B1FEF26A9E445A9E683EEC"; //�滻���̻��Լ���key - - public static String GetQueryString(Map map) - { - Iterator> iter = map.entrySet().iterator(); - StringBuilder sb = new StringBuilder(); - while (iter.hasNext()) { - Entry entry = iter.next(); - Object key = entry.getKey().toString(); - Object val = entry.getValue().toString(); - sb.append(key + "=" +val).append("&"); - } - if(sb.length()==0) return ""; - return sb.substring(0, sb.length()-1); - - } - - //对值进行转码 将本地编码的字符 转换为汇付宝的编码 - public static void TranferCharsetEncode(Map map) throws UnsupportedEncodingException - { - for (Entry entry : map.entrySet()) { - if(entry.getValue()==null) continue; - String utf8=URLEncoder.encode(entry.getValue(), DataHelper.UTF8Encode); - - entry.setValue(utf8); - } - - } - - - public static String GetSortQueryToLowerString(Map map) - { - List> keyValues = - new ArrayList>(map.entrySet()); - - Collections.sort(keyValues, new Comparator>() { - public int compare(Entry o1, Entry o2) { - - return (o1.getKey()).toString().compareTo(o2.getKey()); - } - }); - - StringBuilder sb = new StringBuilder(); - for (int i=0;i map) - { - List> keyValues = - new ArrayList>(map.entrySet()); - - Collections.sort(keyValues, new Comparator>() { - public int compare(Entry o1, Entry o2) { - - return (o1.getKey()).toString().compareTo(o2.getKey()); - } - }); - - StringBuilder sb = new StringBuilder(); - for (int i=0;i"); - String[] str2=str[1].split(">> 4 & 0xf]; - str[k++] = hexDigits[byte0 & 0xf]; - } - return new String(str); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/sdk/HeepayModel/GatewayModel.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/sdk/HeepayModel/GatewayModel.java deleted file mode 100644 index 73a092d47..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/sdk/HeepayModel/GatewayModel.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.accompany.payment.heepay.sdk.HeepayModel; - -public class GatewayModel -{ - private String version; - private String agent_id; - private String agent_bill_id; - private String pay_type; - - private String pay_amt; - private String notify_url; - private String return_url; - private String user_ip; - private String agent_bill_time; - private String goods_name; - private String goods_num; - private String remark; - private String goods_note; - - public String getversion()// - { - return version; - } - public void setversion(String version) - { - this.version = version; - } - - public String getagent_id()// - { - return agent_id; - } - public void setagent_id(String agent_id) - { - this.agent_id = agent_id; - } - - public String getagent_bill_id()// - { - return agent_bill_id; - } - public void setagent_bill_id(String agent_bill_id) - { - this.agent_bill_id = agent_bill_id; - } - - public String getpay_type()// - { - return pay_type; - } - public void setpay_type(String pay_type) - { - this.pay_type = pay_type; - } - - - - public String getpay_amt()// - { - return pay_amt; - } - public void setpay_amt(String pay_amt) - { - this.pay_amt = pay_amt; - } - - public String getnotify_url()// - { - return notify_url; - } - public void setnotify_url(String notify_url) - { - this.notify_url = notify_url; - } - - public String getreturn_url()// - { - return return_url; - } - public void setreturn_url(String return_url) - { - this.return_url = return_url; - } - - public String getuser_ip()// - { - return user_ip; - } - public void setuser_ip(String user_ip) - { - this.user_ip = user_ip; - } - - public String getagent_bill_time()// - { - return agent_bill_time; - } - public void setagent_bill_time(String agent_bill_time) - { - this.agent_bill_time = agent_bill_time; - } - - public String getgoods_name()// - { - return goods_name; - } - public void setgoods_name(String goods_name) - { - this.goods_name = goods_name; - } - - public String getgoods_num()// - { - return goods_num; - } - public void setgoods_num(String goods_num) - { - this.goods_num = goods_num; - } - - public String getremark()// - { - return remark; - } - public void setremark(String remark) - { - this.remark = remark; - } - - public String getgoods_note()// - { - return goods_note; - } - public void setgoods_note(String goods_note) - { - this.goods_note = goods_note; - } - - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/sdk/HeepayReturn/SubmitReturn.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/sdk/HeepayReturn/SubmitReturn.java deleted file mode 100644 index 817587990..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/heepay/sdk/HeepayReturn/SubmitReturn.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.accompany.payment.heepay.sdk.HeepayReturn; - -import java.util.Map; - -public class SubmitReturn { - private boolean _success; - private String _error_message; - private Map _map_list; - - public boolean is_success() { - return _success; - } - - public void set_success(boolean _success) { - this._success = _success; - } - - public String get_error_message() { - return _error_message; - } - - public void set_error_message(String _error_message) { - this._error_message = _error_message; - } - public Map get_map_list() { - return _map_list; - } - - public void set_map_list(Map _map_list) { - this._map_list = _map_list; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/Constant.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/Constant.java deleted file mode 100644 index 8f01c7b79..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/Constant.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.accompany.payment.huiju; - -/** - * @author linuxea - * @date 2019/9/5 10:56 - */ -public class Constant { - - /** 支付成功状态 */ - public static final String PAY_SUCCESS = "100"; - /** 接口版本 */ - static final String API_VERSION = "1.0"; - /** 支付币种 */ - static final Integer RMB_CURRENCY = 1; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/HuiJuConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/HuiJuConfig.java deleted file mode 100644 index 5347ab750..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/HuiJuConfig.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.accompany.payment.huiju; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - * @author linuxea - * @date 2019/9/5 14:43 - */ -@Component -@ConfigurationProperties("hui-ju") -@Data -public class HuiJuConfig { - - /** 请求支付参数 url */ - private String payUrl; - - /** 后台异步通知 url */ - private String notifyUrl; - - /** 商户订单号 */ - private String merchantNo; - - /** 商户密钥 */ - private String merchantSecret; - - /** 交易商户号(小程序) */ - private String tradeMerchantNo; - - /** 交易商户号(公众号) **/ - private String pubTradeMerchantNo; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/HuiJuPublicPayResponseVO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/HuiJuPublicPayResponseVO.java deleted file mode 100644 index ab492f550..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/HuiJuPublicPayResponseVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.accompany.payment.huiju; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 汇聚微信公众号支付请求返回 sdk 参数类 - * - * @author linuxea - * @date 2019/9/6 16:06 - */ -@NoArgsConstructor -@Data -class HuiJuPublicPayResponseVO { - - /** - * 示例 appId : wx06187f0efc2b85dd timeStamp : 1567757163 nonceStr : - * dabf18feb76749a3af391848eb9ee65c package : prepay_id=wx06160603180023df6e10d3e91324739700 - * signType : RSA paySign : - * B6cwgBW3HGQ6F00Lh7K4ZcCcUptrKmgMD3cf65UAYBB8t1XgQqG7wBY7Vl9Z/fp/wbJhBCLUsYwh2tAkjsiWiWeCmextga/a7I0Wj4/vyLpDJxl01cueGaMIbFLajozGTZSKxD+AaSUstMIqnK2KP+tWhhoaQo808RM4vdK35Ynx+Oo1SOqaA/ZgXeNkIGJE1r1z8Cnco69Q5GiM9/Rnpg1fZhDqMsE53apl4JyEKqK3+/tyqCsC4/wjLy/tCWYUBi7sX5lsVpDNdXc/F2jjTZizRs8AcaCFhdK+SoUuJzNPQ3OGI4IGk+kNA+oVox4C9i3NBL3vqmV+yxNHE4T1dw== - */ - private String appId; - - private String timeStamp; - private String nonceStr; - - @JsonProperty("package") - private String packageInfo; - - private String signType; - private String paySign; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/HuiJuService.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/HuiJuService.java deleted file mode 100644 index 72291be11..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/HuiJuService.java +++ /dev/null @@ -1,232 +0,0 @@ -package com.accompany.payment.huiju; - -import com.accompany.common.utils.BeanUtil; -import com.accompany.core.dto.HttpForm; -import com.accompany.core.service.base.BaseService; -import com.accompany.core.util.JsonUtil; -import com.accompany.core.util.OkHttpUtils; -import com.accompany.core.util.StringUtils; -import com.accompany.payment.config.WxConfig; -import com.accompany.payment.config.WxMiniAppConfig; -import com.accompany.payment.vo.JsapiReturnVo; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.codec.digest.DigestUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.math.BigDecimal; -import java.util.*; -import java.util.stream.Collectors; - -import static com.accompany.payment.huiju.Constant.API_VERSION; -import static com.accompany.payment.huiju.Constant.RMB_CURRENCY; - -/** - * 汇聚 支付 - * - * @author linuxea - * @date 2019/9/5 10:32 - */ -@Service -@Slf4j -@Transactional(rollbackFor = Exception.class) -@Lazy(false) -public class HuiJuService extends BaseService { - - private final HuiJuConfig huiJuConfig; - private final WxMiniAppConfig wxMiniAppConfig; - - @Autowired - public HuiJuService(HuiJuConfig huiJuConfig, WxMiniAppConfig wxMiniAppConfig) { - this.huiJuConfig = huiJuConfig; - this.wxMiniAppConfig = wxMiniAppConfig; - } - - /** - * 小程序支付 - * - * @param openId openId - * @param transAmount 交易金额(单位分) - * @param outTransNo 交易订单号 - * @param goodsSubject 交易订单标题 - * @param successUrl 页面跳转 url - * @return 交易 sdk 参数 - */ - public HuiJuWeChatMiniPayInfoVO weChatMiniAppPay( - String openId, Long transAmount, String outTransNo, String goodsSubject, String successUrl) throws Exception{ - RequestVO requestVO = - this.buildWechatMiniAppPay(openId, transAmount, outTransNo, goodsSubject, successUrl); - ResponseVO responseVO = this.send(requestVO); - return JsonUtil.parseToClass(responseVO.getRcResult(), HuiJuWeChatMiniPayInfoVO.class); - } - - /** - * 公众号支付 - * - * @param openId openId - * @param transAmount 交易金额(单位分) - * @param outTransNo 交易订单号 - * @param goodsSubject 交易订单标题 - * @param successUrl 页面跳转 url - * @param nick 昵称 - * @param strawberryNo 抖抖号 - * @return 交易 sdk 参数 - */ - public JsapiReturnVo publicPay( - String openId, - Long transAmount, - String outTransNo, - String goodsSubject, - String successUrl, - String nick, - Long strawberryNo) throws Exception{ - RequestVO requestVO = - this.buildWechatPublicPay(openId, transAmount, outTransNo, goodsSubject, successUrl); - ResponseVO responseVO = this.send(requestVO); - HuiJuPublicPayResponseVO huiJuPublicPayResponseVO = - Objects.requireNonNull( - JsonUtil.parseToClass(responseVO.getRcResult(), HuiJuPublicPayResponseVO.class)); - final JsapiReturnVo jsapiReturnVo = buildUnionPublicVO(huiJuPublicPayResponseVO); - jsapiReturnVo.setErban_no(String.valueOf(strawberryNo)); - jsapiReturnVo.setNick(nick); - return jsapiReturnVo; - } - - /** - * 构建统一的公众号请求参数 - * - * @param huiJuPublicPayResponseVO 汇聚微信公众号请求返回 - * @return 统一的公众号请求参数 - */ - private JsapiReturnVo buildUnionPublicVO(HuiJuPublicPayResponseVO huiJuPublicPayResponseVO) { - JsapiReturnVo jsapiReturnVo = new JsapiReturnVo(); - jsapiReturnVo.setTimestamp(huiJuPublicPayResponseVO.getTimeStamp()); - jsapiReturnVo.setNonce_str(huiJuPublicPayResponseVO.getNonceStr()); - jsapiReturnVo.setPrepay_id(huiJuPublicPayResponseVO.getPackageInfo()); - jsapiReturnVo.setSign(huiJuPublicPayResponseVO.getPaySign()); - jsapiReturnVo.setAppid(huiJuPublicPayResponseVO.getAppId()); - jsapiReturnVo.setSign_type(huiJuPublicPayResponseVO.getSignType()); - return jsapiReturnVo; - } - - private RequestVO buildWechatPublicPay( - String openId, Long transAmount, String outTransNo, String goodsSubject, String successUrl) { - return buildPay( - openId, - transAmount, - outTransNo, - goodsSubject, - successUrl, - TransactionTypeEnum.WEIXIN_GZH.name(), - WxConfig.appId); - } - - /** - * 构建支付请求 - * - * @param openId 微信 openId - * @param transAmount 交易金额 单位为: 分 - * @param outTransNo 交易订单号 - * @param goodsSubject 交易订单标题 - * @param successUrl 页面跳转 url - * @return {@link RequestVO} - */ - private RequestVO buildWechatMiniAppPay( - String openId, Long transAmount, String outTransNo, String goodsSubject, String successUrl) { - return buildPay( - openId, - transAmount, - outTransNo, - goodsSubject, - successUrl, - TransactionTypeEnum.WEIXIN_XCX.name(), - wxMiniAppConfig.getAppId()); - } - - private RequestVO buildPay( - String openId, - Long transAmount, - String outTransNo, - String goodsSubject, - String successUrl, - String transactionType, - String appId) { - RequestVO requestVO = new RequestVO(); - requestVO.setP0Version(API_VERSION); - requestVO.setP1MerchantNo(huiJuConfig.getMerchantNo()); - requestVO.setP2OrderNo(outTransNo); - double amount = BigDecimal.valueOf(transAmount).divide(BigDecimal.valueOf(100)) - .setScale(2,BigDecimal.ROUND_HALF_DOWN).doubleValue(); - requestVO.setP3Amount(amount); - requestVO.setP5ProductName(goodsSubject); - requestVO.setQ5OpenId(openId); - requestVO.setP8ReturnUrl(successUrl); - requestVO.setP9NotifyUrl(huiJuConfig.getNotifyUrl()); - requestVO.setQ1FrpCode(transactionType); - requestVO.setP4Cur(RMB_CURRENCY); - requestVO.setQ7AppId(appId); - if(transactionType.equalsIgnoreCase(TransactionTypeEnum.WEIXIN_XCX.name())){ - requestVO.setQaTradeMerchantNo(huiJuConfig.getTradeMerchantNo()); - }else if(transactionType.equalsIgnoreCase(TransactionTypeEnum.WEIXIN_GZH.name())){ - requestVO.setQaTradeMerchantNo(huiJuConfig.getPubTradeMerchantNo()); - } - // 签名要放在最后 - requestVO.setHmac(requestSign(requestVO)); - return requestVO; - } - - /** - * 支付 - * - * @param requestVO {@link RequestVO} 请求参数 - * @return {@link ResponseVO} 响应参数 - */ - @SuppressWarnings("unchecked") - public ResponseVO send(RequestVO requestVO){ - Map requestMap = JsonUtil.parseToClass(JsonUtil.parseToString(requestVO),Map.class); - List params = Objects.requireNonNull(requestMap).keySet().stream() - .map(x -> new HttpForm(x, requestMap.get(x).toString())) - .collect(Collectors.toList()); - String responseBody = OkHttpUtils.postWithForm(huiJuConfig.getPayUrl(), params); - log.info("huiju response ,param:{}, body:{}",gson.toJson(requestVO),responseBody); - return JsonUtil.parseToClass(responseBody, ResponseVO.class); - } - - /** - * 签名 除 hmac 字段外,所有参数按照文档要求的顺序设值,并参与拼接待签 名字符串; 在待签名字符串中,字段名和字段值都采用原始值,不进行 URL Encode - * - * @param requestVO 请求参数 - * @return 生成签名数据 - */ - @SuppressWarnings("unchecked") - public String requestSign(RequestVO requestVO) { - Map params = BeanUtil.objectToMap(requestVO); - return md5Sign(params); - } - - /** - * md5 签名 - * - * @param params 参数 map - * @return 签名结果 - */ - public String md5Sign(Map params) { - List keys = new ArrayList<>(Objects.requireNonNull(params).keySet()); - Collections.sort(keys); - StringBuilder stringBuilder = new StringBuilder(); - for (String key : keys) { - // hmac 不参与签名 - Object value = params.get(key); - //空对象和空值不参与签名 - if ("hmac".equalsIgnoreCase(key) || value == null || StringUtils.isBlank(value.toString())) { - continue; - } - stringBuilder.append(value); - } - log.info("按要求参数拼接的东东是 {}", stringBuilder.toString()); - return DigestUtils.md5Hex(stringBuilder.toString() + huiJuConfig.getMerchantSecret()) - .toUpperCase(); - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/HuiJuWeChatMiniPayInfoVO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/HuiJuWeChatMiniPayInfoVO.java deleted file mode 100644 index 051120fb9..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/HuiJuWeChatMiniPayInfoVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.accompany.payment.huiju; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * @author linuxea - * @date 2019/9/5 15:18 - */ -@NoArgsConstructor -@Data -public class HuiJuWeChatMiniPayInfoVO { - - /** appId */ - private String appId; - - /** 创建支付时间戳 秒 */ - private String timeStamp; - - /** 随机字符串 */ - private String nonceStr; - - /** 前端调起支付参数 */ - @JsonProperty("package") - private String packageInfo; - - /** 签名类型 */ - private String signType; - - /** 支付签名 */ - private String paySign; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/NotifyResponse.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/NotifyResponse.java deleted file mode 100644 index f2e720572..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/NotifyResponse.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.accompany.payment.huiju; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 汇聚回调参数 get 请求,应该是因为不走 requestBody 封装,所以 JsonProperty 失效 所以有下划线 _ 这种东东去不掉 将就看一下吧 - * - * @author linuxea - * @date 2019/9/5 10:49 - */ -@Data -@AllArgsConstructor -@NoArgsConstructor -public class NotifyResponse { - - /** 商户编号 */ - private String r1_MerchantNo; - - /** 商户订单号 */ - private String r2_OrderNo; - - /** 支付金额 */ - private String r3_Amount; - - /** 交易币种 1 代表人民币 */ - private String r4_Cur; - - /** 公用回传参数 */ - private String r5_Mp; - - /** 支付状态 100 表示成功 */ - private String r6_Status; - - /** 交易流水号 */ - private String r7_TrxNo; - - /** 银行订单号 */ - private String r8_BankOrderNo; - - /** 银行流水号 */ - private String r9_BankTrxNo; - - /** 支付时间 格式:YYYY-MM-DD HH:mm:s(s HH代表24小时制) */ - private String ra_PayTime; - - /** 交易通知时间 格式:YYYY-MM-DD HH:mm:s(s HH代表24小时制) */ - private String rb_DealTime; - - /** 银行编码 */ - private String rc_BankCode; - - /** 用户标识 */ - private String rd_OpenId; - - /** 平台优惠金额 平台优惠金额,单位:元,精确 到分,保留两位小数 */ - private String re_DiscountAmount; - - /** 签名数据 */ - private String hmac; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/RequestVO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/RequestVO.java deleted file mode 100644 index 334e9f1e0..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/RequestVO.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.accompany.payment.huiju; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * @author linuxea - * @date 2019/9/5 10:34 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class RequestVO { - - /** 版本号 */ - @JsonProperty("p0_Version") - private String p0Version; - - /** 商户编号 */ - @JsonProperty("p1_MerchantNo") - private String p1MerchantNo; - - /** 商户订单号 */ - @JsonProperty("p2_OrderNo") - private String p2OrderNo; - - /** 订单金额 单位:元,精确到分,保留两位小数 */ - @JsonProperty("p3_Amount") - private Double p3Amount; - - /** 交易币种 */ - @JsonProperty("p4_Cur") - private Integer p4Cur; - - /** 商品名称 */ - @JsonProperty("p5_ProductName") - private String p5ProductName; - - /** 服务器异步通知地址 */ - @JsonProperty("p9_NotifyUrl") - private String p9NotifyUrl; - - /** 交易类型 */ - @JsonProperty("q1_FrpCode") - private String q1FrpCode; - - /** 微信 openId */ - @JsonProperty("q5_OpenId") - private String q5OpenId; - - /** 微信 appId */ - @JsonProperty("q7_AppId") - private String q7AppId; - - /** 页面返回地址 */ - @JsonProperty("p8_ReturnUrl") - private String p8ReturnUrl; - - /** 签名数据 */ - @JsonProperty("hmac") - private String hmac; - - /** 交易商户号 **/ - @JsonProperty("qa_TradeMerchantNo") - private String qaTradeMerchantNo; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/ResponseVO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/ResponseVO.java deleted file mode 100644 index b0cecc034..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/ResponseVO.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.accompany.payment.huiju; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * @author linuxea - * @date 2019/9/5 10:42 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ResponseVO { - - /** 版本号 */ - @JsonProperty("r0_Version") - private String r0Version; - - /** 商户编号 */ - @JsonProperty("r1_MerchantNo") - private String r1MerchantNo; - - /** 商户订单号 */ - @JsonProperty("r2_OrderNo") - private String r2OrderNo; - - /** 订单金额 单位:元,精确到分,保留两 位小数。 */ - @JsonProperty("r3_Amount") - private String r3Amount; - - /** 默认设置为1(代表人民币) */ - @JsonProperty("r4_Cur") - private String r4Cur; - - /** 交易类型 */ - @JsonProperty("r6_FrpCode") - private String r6FrpCode; - - /** 交易流水号 */ - @JsonProperty("r7_TrxNo") - private String r7TrxNo; - - /** 银行商户编码 */ - @JsonProperty("r8_MerchantBankCode") - private String r8MerchantBankCode; - - /** 子商户号 */ - @JsonProperty("r9_SubMerchantNo") - private String r9SubMerchantNo; - - /** 响应码 返回 100 时表示成功,响应 码描述为空。 */ - @JsonProperty("ra_Code") - private String raCode; - - /** 响应码描述 */ - @JsonProperty("rb_CodeMsg") - private String rbCodeMsg; - - /** 结果 */ - @JsonProperty("rc_Result") - private String rcResult; - - @JsonProperty("rd_Pic") - private String rdPic; - - /** 签名数据 */ - @JsonProperty("hmac") - private String hmac; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/TransactionTypeEnum.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/TransactionTypeEnum.java deleted file mode 100644 index 3b6a2df24..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/huiju/TransactionTypeEnum.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.accompany.payment.huiju; - -import lombok.Getter; - -/** - * @author linuxea - * @date 2019/9/5 10:30 - */ -public enum TransactionTypeEnum { - - /** 微信公众号 */ - WEIXIN_GZH("微信公众号"), - /** 微信小程序 */ - WEIXIN_XCX("微信小程序"), - ; - - @Getter - private String memo; - - TransactionTypeEnum(String memo) { - this.memo = memo; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/iospay/IOSPayPlaService.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/iospay/IOSPayPlaService.java index d18a0ea05..0b5bec3b0 100644 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/iospay/IOSPayPlaService.java +++ b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/iospay/IOSPayPlaService.java @@ -44,8 +44,6 @@ public class IOSPayPlaService extends BaseService { @Autowired private SysConfService sysConfService; @Autowired - private ChargeCheckService chargeCheckService; - @Autowired private UsersBaseService usersService; @Autowired private PayCenterService payCenterService; @@ -63,53 +61,15 @@ public class IOSPayPlaService extends BaseService { ChargeProd chargeProd = chargeProdService.getChargeProdById(chargeProdId); if (chargeProd == null || !Constant.ChargeProdStatus.using.equals(chargeProd.getProdStatus())) { logger.debug("===========订单类型不存在=================="); - return new BusiResult(BusiStatus.BUSIERROR); + return new BusiResult<>(BusiStatus.BUSIERROR); } // 实名限额 Users users = usersService.getUsersByUid(uid); - BusiResult result = new BusiResult(BusiStatus.SUCCESS); - if (users.getParentMode()) { - // 校验青少年是否可充值 - Boolean teenChargeSwitch = Boolean.valueOf(sysConfService.getDefaultSysConfValueById(Constant.SysConfId.TEEN_CHARGE_SWITCH, "true")); - if(teenChargeSwitch){ - // 校验青少年充值每日限额 - Integer limitMoney = usersService.getUserTeenConfig().getLimitEveryDay(); - String chargeLimit = jedisService.hget(RedisKey.user_charge_limit.getKey(), uid.toString()); - if (StringUtils.isBlank(chargeLimit)) { - chargeLimit = chargeProd.getMoney().toString(); - } else { - chargeLimit = String.valueOf(Integer.valueOf(chargeLimit) + chargeProd.getMoney().intValue()); - } - if (Integer.valueOf(chargeLimit) > limitMoney) { - result.setCode(25000); - result.setMessage("充值失败:超出当日充值限制"); - return result; - } - }else{ - result.setCode(25006); - result.setMessage("当前处于青少年模式下,无法使用充值功能哦"); - return result; - } - } else{ - // 2020-02-25: 改为从2020.02.25 0点起,累计充值≥指定人民币金额,需先实名认证 - Long historyRechargeAmount = chargeRecordService.historyRechargeAmount(users.getUid()); - // 进行实名认证充值校验 - Integer resultCode = chargeCheckService.needCertification(users, chargeProd.getMoney(), historyRechargeAmount); - if(resultCode != null && resultCode.equals(BusiStatus.CHARGE_LIMIT.value())){ - result.setCode(resultCode); - result.setMessage("充值失败,已超出充值限制"); - return result; - }else if(resultCode != null && resultCode.equals(BusiStatus.UNDER_AGE_WITHDRAWAL.value())){ - result.setCode(resultCode); - result.setMessage("未成年用户 (<18岁),无法使用充值功能哦"); - return result; - }else if(resultCode != null && resultCode.equals(BusiStatus.NEED_CERTIFICATION.value())){ - result.setCode(resultCode); - result.setMessage(BusiStatus.NEED_CERTIFICATION.getReasonPhrase()); - return result; - } + if (null == users){ + return new BusiResult<>(BusiStatus.BUSIERROR); } + // 充值 BusiResult BusiResult; String lockval = jedisLockService.lock(RedisKey.lock_apply_charge.getKey(uid.toString()), 10); @@ -140,7 +100,7 @@ public class IOSPayPlaService extends BaseService { chargeRecord.setChargeApp(deviceInfo.getApp()); } - BusiResult = new BusiResult(BusiStatus.SUCCESS); + BusiResult = new BusiResult<>(BusiStatus.SUCCESS); try { //写入数据库 chargeRecordService.insertChargeRecord(chargeRecord); @@ -162,54 +122,6 @@ public class IOSPayPlaService extends BaseService { return BusiResult; } - public RecordIdVo placeOrderByShop(Long uid, String chargeProdId, String clientIp, Byte bussType, Integer productType, Integer productId) { - String lockval = jedisLockService.lock(RedisKey.lock_apply_charge.getKey(uid.toString()), 10000); - if (StringUtils.isEmpty(lockval)) { - throw new ServiceException(BusiStatus.SERVERBUSY); - } - - try { - ChargeProd chargeProd = chargeProdService.getChargeProdById(chargeProdId); - if (chargeProd == null) { - logger.debug("===========订单类型不存在=================="); - throw new ServiceException(BusiStatus.CHARGE_PROD_NOT_EXIST); - } - //保存充值记录 - //1.创建订单号 - //UUID不会重复,所以不需要判断是否生成重复的订单号 - String chargeRecordId = UUIDUitl.get(); - ChargeRecord chargeRecord = new ChargeRecord(); - chargeRecord.setChargeRecordId(chargeRecordId); - chargeRecord.setChargeProdId(chargeProdId); - chargeRecord.setUid(uid); - chargeRecord.setBussType(bussType); - chargeRecord.setChannel(Constant.ChargeChannel.ios_pay); - chargeRecord.setChargeStatus(Constant.ChargeRecordStatus.create); - Long money = chargeProd.getMoney(); - Long amount = money * 100; - String body = chargeProd.getProdDesc(); - String subject = chargeProd.getProdDesc(); - chargeRecord.setAmount(amount); - chargeRecord.setSubject(subject); - chargeRecord.setBody(body); - chargeRecord.setClientIp(clientIp); - - JSONObject jsonObject = new JSONObject(); - jsonObject.put("product_type", productType); - jsonObject.put("product_id", productId); - chargeRecord.setExtra(jsonObject.toJSONString()); - - //写入数据库 - chargeRecordService.insertChargeRecord(chargeRecord); - //订单创建成功返回订单号 - RecordIdVo recordIdVo = new RecordIdVo(); - recordIdVo.setRecordId(chargeRecordId); - return recordIdVo; - } finally { - jedisLockService.unlock(RedisKey.lock_apply_charge.getKey(uid.toString()), lockval); - } - } - /** * 开通贵族 * @param params diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/joinpay/HttpRequester.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/joinpay/HttpRequester.java deleted file mode 100644 index 78824c5c5..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/joinpay/HttpRequester.java +++ /dev/null @@ -1,192 +0,0 @@ -package com.accompany.payment.joinpay; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLEncoder; -import java.nio.charset.Charset; -import java.util.Map; -import java.util.Vector; - -public class HttpRequester { - - private String defaultContentEncoding; - - public HttpRequester() { - this.defaultContentEncoding = Charset.defaultCharset().name(); - } - - /** - * 发送POST请求 - * - * @param urlString URL地址 - * @return 响应对象 - * @throws IOException - */ - public HttpResponse sendPost(String urlString) throws IOException { - return this.send(urlString, "POST", null, null); - } - - /** - * 发送POST请求 - * - * @param urlString URL地址 - * @param params 参数集合 - * @return 响应对象 - * @throws IOException - */ - public HttpResponse sendPost(String urlString, Map params) throws IOException { - for (String key : params.keySet()) { - if (params.get(key) != null && !"".equals(params.get(key))) { - params.put(key, (String) URLEncoder.encode(String.valueOf(params.get(key)), "utf-8"));//(String) 强制类型转换 - } - } - - return this.send(urlString, "POST", params, null); - } - - /** - * 发送POST请求 - * - * @param urlString URL地址 - * @param params 参数集合 - * @param propertys 请求属性 - * @return 响应对象 - * @throws IOException - */ - public HttpResponse sendPost(String urlString, Map params, Map propertys) throws IOException { - return this.send(urlString, "POST", params, propertys); - } - - /** - * 发送HTTP请求 - * - * @param urlString - * @return 响映对象 - * @throws IOException - */ - private HttpResponse send(String urlString, String method, Map parameters, Map propertys) throws IOException { - HttpURLConnection urlConnection = null; - - if (method.equalsIgnoreCase("GET") && parameters != null) { - StringBuffer param = new StringBuffer(); - int i = 0; - for (String key : parameters.keySet()) { - if (i == 0) - param.append("?"); - else - param.append("&"); - param.append(key).append("=").append(parameters.get(key)); - i++; - } - urlString += param; - } - - URL url = new URL(urlString); - urlConnection = (HttpURLConnection) url.openConnection(); - - urlConnection.setRequestMethod(method); - urlConnection.setDoOutput(true); - urlConnection.setDoInput(true); - urlConnection.setUseCaches(false); - - if (propertys != null) - for (String key : propertys.keySet()) { - urlConnection.addRequestProperty(key, propertys.get(key)); - } - - if (method.equalsIgnoreCase("POST") && parameters != null) { - StringBuffer param = new StringBuffer(); - for (String key : parameters.keySet()) { - param.append("&"); - param.append(key).append("=").append(parameters.get(key)); - } - urlConnection.getOutputStream().write(param.toString().getBytes()); - urlConnection.getOutputStream().flush(); - urlConnection.getOutputStream().close(); - } - - return this.makeContent(urlString, urlConnection); - } - - /** - * 得到响应对象 - * - * @param urlConnection - * @return 响应对象 - * @throws IOException - */ - private HttpResponse makeContent(String urlString, HttpURLConnection urlConnection) throws IOException { - HttpResponse httpResponser = new HttpResponse(); - try { - InputStream in = urlConnection.getInputStream(); - BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in)); - httpResponser.contentCollection = new Vector(); - StringBuffer temp = new StringBuffer(); - String line = bufferedReader.readLine(); - while (line != null) { - httpResponser.contentCollection.add(line); - temp.append(line).append("\r\n"); - line = bufferedReader.readLine(); - } - bufferedReader.close(); - - String ecod = urlConnection.getContentEncoding(); - if (ecod == null) { - ecod = this.defaultContentEncoding; - } - - httpResponser.urlString = urlString; - - httpResponser.defaultPort = urlConnection.getURL().getDefaultPort(); - httpResponser.file = urlConnection.getURL().getFile(); - httpResponser.host = urlConnection.getURL().getHost(); - httpResponser.path = urlConnection.getURL().getPath(); - httpResponser.port = urlConnection.getURL().getPort(); - httpResponser.protocol = urlConnection.getURL().getProtocol(); - httpResponser.query = urlConnection.getURL().getQuery(); - httpResponser.ref = urlConnection.getURL().getRef(); - httpResponser.userInfo = urlConnection.getURL().getUserInfo(); - - httpResponser.content = new String(temp.toString().getBytes(), ecod); - httpResponser.contentEncoding = ecod; - httpResponser.code = urlConnection.getResponseCode(); - httpResponser.message = urlConnection.getResponseMessage(); - httpResponser.contentType = urlConnection.getContentType(); - httpResponser.method = urlConnection.getRequestMethod(); - httpResponser.connectTimeout = urlConnection.getConnectTimeout(); - httpResponser.readTimeout = urlConnection.getReadTimeout(); - - return httpResponser; - } catch (IOException e) { - throw e; - } finally { - if (urlConnection != null) - urlConnection.disconnect(); - } - } - - /** - * 默认的响应字符集 - */ - public String getDefaultContentEncoding() { - return this.defaultContentEncoding; - } - - /** - * 设置默认的响应字符集 - */ - public void setDefaultContentEncoding(String defaultContentEncoding) { - this.defaultContentEncoding = defaultContentEncoding; - } - -} - - - - - - diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/joinpay/HttpResponse.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/joinpay/HttpResponse.java deleted file mode 100644 index 99a50c48b..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/joinpay/HttpResponse.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.accompany.payment.joinpay; - -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.methods.InputStreamRequestEntity; -import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.commons.httpclient.methods.RequestEntity; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Vector; - - -public class HttpResponse { - String urlString; - - int defaultPort; - - String file; - - String host; - - String path; - - int port; - - String protocol; - - String query; - - String ref; - - String userInfo; - - String contentEncoding; - - String content; - - String contentType; - - int code; - - String message; - - String method; - - int connectTimeout; - - int readTimeout; - - Vector contentCollection; - - public String getContent() { - return content; - } - - public String getContentType() { - return contentType; - } - - public int getCode() { - return code; - } - - public String getMessage() { - return message; - } - - public Vector getContentCollection() { - return contentCollection; - } - - public String getContentEncoding() { - return contentEncoding; - } - - public String getMethod() { - return method; - } - - public int getConnectTimeout() { - return connectTimeout; - } - - public int getReadTimeout() { - return readTimeout; - } - - public String getUrlString() { - return urlString; - } - - public int getDefaultPort() { - return defaultPort; - } - - public String getFile() { - return file; - } - - public String getHost() { - return host; - } - - public String getPath() { - return path; - } - - public int getPort() { - return port; - } - - public String getProtocol() { - return protocol; - } - - public String getQuery() { - return query; - } - - public String getRef() { - return ref; - } - - public String getUserInfo() { - return userInfo; - } - - - public static String post(String params, String requestUrl) throws IOException { - // TODO Auto-generated method stub - // try { - //HttpRequester request = new HttpRequester(); - // request.setDefaultContentEncoding("utf-8"); - byte[] requestBytes = params.getBytes("utf-8"); // 将参数转为二进制流 - HttpClient httpClient = new HttpClient(); // 客户端实例化 - PostMethod postMethod = new PostMethod(requestUrl); - //设置请求头Authorization - // postMethod.setRequestHeader("Authorization", "Basic " + authorization); - // 设置请求头 Content-Type - postMethod.setRequestHeader("Content-Type", "application/json"); - InputStream inputStream = new ByteArrayInputStream(requestBytes, 0, requestBytes.length); - RequestEntity requestEntity = new InputStreamRequestEntity(inputStream, requestBytes.length, "application/json; charset=utf-8"); // 请求体 - postMethod.setRequestEntity(requestEntity); - httpClient.executeMethod(postMethod);// 执行请求 - InputStream soapResponseStream = postMethod.getResponseBodyAsStream();// 获取返回的流 - byte[] datas = null; - try { - datas = readInputStream(soapResponseStream);// 从输入流中读取数据 - } catch (Exception e) { - e.printStackTrace(); - } - String result = new String(datas, "UTF-8");// 将二进制流转为String - // 打印返回结果 - // System.out.println(result); - - return result; - } - - - /** - * 从输入流中读取数据 - * - * @param inStream - * @return - * @throws Exception - */ - public static byte[] readInputStream(InputStream inStream) throws Exception { - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - byte[] buffer = new byte[1024]; - int len = 0; - while ((len = inStream.read(buffer)) != -1) { - outStream.write(buffer, 0, len); - } - byte[] data = outStream.toByteArray(); - outStream.close(); - inStream.close(); - return data; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/joinpay/JoinpayService.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/joinpay/JoinpayService.java deleted file mode 100644 index eeb02d42d..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/joinpay/JoinpayService.java +++ /dev/null @@ -1,278 +0,0 @@ -package com.accompany.payment.joinpay; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.google.common.collect.Maps; -import com.accompany.payment.config.JoinPayConfig; -import com.accompany.payment.config.WxConfig; -import com.accompany.payment.config.WxPayConfig; -import org.apache.commons.codec.digest.DigestUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.*; - -/** - * @Description 汇聚支付服务类 - * @Author Vicente - * @Date 2019-01-08 18:33:00 - * @Since - */ -@Service -public class JoinpayService { - - private static final Logger logger = LoggerFactory.getLogger(JoinpayService.class); - - public static final String VERSION_KEY = "p0_Version"; - public static final String MERCHANTNO_KEY = "p1_MerchantNo"; - public static final String ORDER_NO_KEY = "p2_OrderNo"; - public static final String AMOUNT_KEY = "p3_Amount"; - public static final String CURRENCY_KEY = "p4_Cur"; - public static final String PRODUCT_NAME_KEY = "p5_ProductName"; - public static final String TRADE_STATUS_KEY = "r6_Status"; - public static final String TRADE_STATUS_SUCCESS = "100"; - public static final String NOTIFY_URL_KEY = "p9_NotifyUrl"; - public static final String TRADE_TYPE_KEY = "q1_FrpCode"; - public static final String WX_APPID_KEY = "q7_AppId"; - public static final String SIGN_KEY = "hmac"; - public static final String HJ_TRADE_NO_KEY = "r7_TrxNo"; - public static final String RC_RESULT_KEY = "rc_Result"; - public static final String TRADE_OPENID = "q5_OpenId"; - - private static final String TRADE_TYPE_WX_APP = "WEIXIN_APP"; - private static final String TRADE_TYPE_WX_GZH = "WEIXIN_GZH"; - private static final String REQUEST_VERSION = "1.0"; - private static final Integer CURRENCY_CNY = 1; - - @Autowired - private WxPayConfig wxPayConfig; - - /** - * 向汇聚支付发起交易并返回调起微信支付参数 - * - * @param chargeRecordId - * @param amount - * @param subject - * @return - * @throws IOException - */ - public Map applyTradeAndReturnRequestParams(String chargeRecordId, Long amount, String subject) throws IOException { - Map requestMap = this.buildApplyTradeParams(chargeRecordId, amount, subject); - return this.sendTradeApply(requestMap, TRADE_TYPE_WX_APP); - } - - /** - * 向汇聚支付发起交易(微信公众号支付类型) - * - * @param chargeRecordId - * @param amount - * @param subject - * @return - * @throws IOException - */ - public Map applyWxPubTrade(String chargeRecordId, Long amount, String openId, String subject) throws IOException { - Map requestMap = this.buildApplyWxPubTradeParams(chargeRecordId, amount, openId, subject); - return this.sendTradeApply(requestMap, TRADE_TYPE_WX_GZH); - } - - /** - * 发送交易请求 - * - * @param request - * @return - * @throws IOException - */ - private Map sendTradeApply(Map request, String tradeType) throws IOException { - HttpRequester requester = new HttpRequester(); - logger.info("joinpay request : {}", JSON.toJSONString(request)); - HttpResponse response = requester.sendPost(JoinPayConfig.applyTradeUrl, request); - JSONObject content = JSONObject.parseObject(response.getContent()); - JSONObject result = content.getJSONObject(RC_RESULT_KEY); - logger.info("joinpay reponse: {}", JSON.toJSONString(response)); - - //需要校验签名 - if (!this.verifySign(response.getContent())) { - logger.error("汇聚支付校验签名失败:{}", content); - return Maps.newHashMap(); - } - Map ret = Maps.newHashMap(); - switch (tradeType) { - case TRADE_TYPE_WX_APP: - ret = buildRequestMap(result.toJavaObject(Map.class), content.getString(HJ_TRADE_NO_KEY)); - break; - case TRADE_TYPE_WX_GZH: - ret = buildWxPubRequestMap(result.toJavaObject(Map.class), content.getString(HJ_TRADE_NO_KEY)); - break; - } - return ret; - } - - /** - * 组装汇聚支付请求Map - * - * @param huijuMap - * @param huijuOrderNo - * @return - */ - private Map buildRequestMap(Map huijuMap, String huijuOrderNo) { - Map map = new HashMap<>(); - map.put("timestamp", huijuMap.get("timeStamp")); - map.put("package", huijuMap.get("package")); - map.put("sign", huijuMap.get("paySign")); - map.put("appid", huijuMap.get("appId")); - map.put("partnerid", huijuMap.get("partnerId")); - map.put("prepayid", huijuMap.get("prepayId")); - map.put("noncestr", huijuMap.get("nonceStr")); - map.put("orderno", huijuOrderNo); - - return map; - } - - /** - * 组装汇聚公众号支付请求Map - * - * @param huijuMap - * @param huijuOrderNo - * @return - */ - private Map buildWxPubRequestMap(Map huijuMap, String huijuOrderNo) { - Map map = new HashMap<>(); - map.put("timestamp", huijuMap.get("timeStamp")); - map.put("package", huijuMap.get("package")); - map.put("sign", huijuMap.get("paySign")); - map.put("appid", huijuMap.get("appId")); - map.put("noncestr", huijuMap.get("nonceStr")); - map.put("signType", huijuMap.get("signType")); - map.put("orderno", huijuOrderNo); - - return map; - } - - /** - * 组装交易请求参数 - * XXX: 目前仅微信,接入其它渠道需作重构 - * - * @param orderNo - * @param amount - * @param productName - * @return - */ - public Map buildApplyTradeParams(String orderNo, Long amount, String productName) { - // 单位为元 - BigDecimal amountInFen = new BigDecimal(amount); - BigDecimal unit = new BigDecimal(100); - BigDecimal amountInYuan = amountInFen.divide(unit, 2, 2); - - Map tradeParams = new HashMap<>(11); - tradeParams.put(VERSION_KEY, REQUEST_VERSION); - tradeParams.put(TRADE_TYPE_KEY, TRADE_TYPE_WX_APP); - tradeParams.put(CURRENCY_KEY, CURRENCY_CNY); - tradeParams.put(WX_APPID_KEY, wxPayConfig.getAppId()); - tradeParams.put(MERCHANTNO_KEY, JoinPayConfig.merchantNo); - tradeParams.put(NOTIFY_URL_KEY, JoinPayConfig.callbackUrl); - tradeParams.put(ORDER_NO_KEY, orderNo); - tradeParams.put(AMOUNT_KEY, amountInYuan); - tradeParams.put(PRODUCT_NAME_KEY, productName); - - // 添加签名 - String signString = this.buildSignString(tradeParams); - String sign = this.signByMD5(signString, JoinPayConfig.key); - tradeParams.put(SIGN_KEY, sign); - - return tradeParams; - } - - /** - * 组装交易请求参数 - * XXX: 微信公众号,接入其它渠道需作重构 - * - * @param orderNo - * @param amount - * @param productName - * @return - */ - public Map buildApplyWxPubTradeParams(String orderNo, Long amount, String openId, String productName) { - // 单位为元 - BigDecimal amountInFen = new BigDecimal(amount); - BigDecimal unit = new BigDecimal(100); - BigDecimal amountInYuan = amountInFen.divide(unit, 2, 2); - - Map tradeParams = new HashMap<>(11); - tradeParams.put(VERSION_KEY, REQUEST_VERSION); - tradeParams.put(TRADE_TYPE_KEY, TRADE_TYPE_WX_GZH); - tradeParams.put(CURRENCY_KEY, CURRENCY_CNY); - tradeParams.put(WX_APPID_KEY, WxConfig.appId); - tradeParams.put(MERCHANTNO_KEY, JoinPayConfig.merchantNo); - tradeParams.put(NOTIFY_URL_KEY, JoinPayConfig.callbackUrl); - tradeParams.put(ORDER_NO_KEY, orderNo); - tradeParams.put(AMOUNT_KEY, amountInYuan); - tradeParams.put(PRODUCT_NAME_KEY, productName); - tradeParams.put(TRADE_OPENID, openId); - - // 添加签名 - String signString = this.buildSignString(tradeParams); - String sign = this.signByMD5(signString, JoinPayConfig.key); - tradeParams.put(SIGN_KEY, sign); - - return tradeParams; - } - - /** - * 校验签名 - * - * @param content - * @return - */ - public boolean verifySign(String content) { - logger.info("verifySign, content={}", content); - - JSONObject contentJson = JSONObject.parseObject(content); - Map contentMap = contentJson.toJavaObject(Map.class); - - String responseSign = (String) contentMap.remove(SIGN_KEY); - String correctSign = this.signByMD5(this.buildSignString(contentMap), JoinPayConfig.key); - logger.info("joinpay client sign: {}, server sign: {}", responseSign, correctSign); - return correctSign.equalsIgnoreCase(responseSign); - } - - /** - * 对请求参数进行签名 - * - * @param signString - * @param encryptKey - * @return - */ - private String signByMD5(String signString, String encryptKey) { - return DigestUtils.md5Hex(signString + encryptKey).toUpperCase(); - } - - /** - * 组装签名参数字符串 - * - * @param params - * @return - */ - private String buildSignString(Map params) { - List keys = new ArrayList(params.keySet()); - Collections.sort(keys); - String signString = ""; - for (int i = 0; i < keys.size(); i++) { - String key = keys.get(i); - Object value = params.get(key); - if (value instanceof Long) { - value = (Long) value; - } - if (i == keys.size() - 1) { - signString = signString + value.toString(); - } else { - signString = signString + value; - } - } - return signString; - } - -} \ No newline at end of file diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/params/AgentChangeDimensions.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/params/AgentChangeDimensions.java deleted file mode 100644 index f23345566..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/params/AgentChangeDimensions.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.accompany.payment.params; - -import lombok.Data; - -@Data -public class AgentChangeDimensions { - /** - * 用户uid - */ - private Long uid; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayCommParams.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayCommParams.java deleted file mode 100644 index 5cc46ceea..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayCommParams.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 文 件 名: SandPayCommParams - * 版 权: - * 描 述: <描述> - * 创建人: H1 - * 创建时间: 2022/4/27 - * 修改人: - * 修改内容: - * 修改时间: - */ -package com.accompany.payment.sandpay; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - *
类描述: - *
功能详细描述: - * - * @author H1 - * @date [2022/4/27] - */ -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class SandPayCommParams { - /** - * 版本号(默认1.0) - */ - private String version; - /** - * 接口名称(参考各接口文档中"请求地址-method") - */ - private String method; - /** - * 产品编码 - */ - private String productId; - /** - * 接入类型 (1-普通商户接入 2-平台商户接入) - */ - private String accessType; - /** - * 商户ID (收款方商户号) - */ - private String mid; - /** - * 平台ID 接入类型为2时必填,在担保支付模式下填写核心商户号;在杉德宝平台终端模式下填写平台商户号 - */ - private String plMid; - /** - * 渠道类型 商户的真实应用场景,可选项包括: - * 07-互联网 - * 08-移动端 - */ - private String channelType; - /** - * 请求时间 格式:yyyyMMddHHmmss - */ - private String reqTime; - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayMiniAppReqBaseParams.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayMiniAppReqBaseParams.java deleted file mode 100644 index 2558a04ed..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayMiniAppReqBaseParams.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 文 件 名: SandPayMiniAppReqParams - * 版 权: - * 描 述: <描述> - * 创建人: H1 - * 创建时间: 2022/4/27 - * 修改人: - * 修改内容: - * 修改时间: - */ -package com.accompany.payment.sandpay; - -import lombok.Data; - -import java.math.BigDecimal; - -/** - *
类描述: 杉德小程序/公众号统一下单请求参数 - *
功能详细描述: - * - * @author H1 - * @date [2022/4/27] - */ -@Data -public class SandPayMiniAppReqBaseParams { - - private SandPayCommParams head; - private SandPayMiniAppReqBodyParams body; - - - @Data - public static class SandPayMiniAppReqBodyParams { - /** - * 商户订单号 长度12位起步,商户唯一 - */ - private String orderCode; - /** - * 订单金额 例000000000101代表1.01元 - */ - private String totalAmount; - /** - * 订单标题 - */ - private String subject; - /** - * 订单描述 - */ - private String body; - /** - * 支付模式 https://open.sandpay.com.cn/product/detail/43311/43787/43788 - */ - private String payMode; - - private SandPayMiniAppReqBodyPayExtra payExtra; - /** - *客户端IP - */ - private String clientIp; - /** - * 异步通知地址 - */ - private String notifyUrl; - /** - * 前台通知地址 - */ - private String frontUrl; - } - - - @Data - public static class SandPayMiniAppReqBodyPayExtra { - private String subAppid; - private String userId; - } - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayMiniAppReqParams.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayMiniAppReqParams.java deleted file mode 100644 index 6af8345ea..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayMiniAppReqParams.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 文 件 名: SandPayMiniAppReqParams - * 版 权: - * 描 述: <描述> - * 创建人: H1 - * 创建时间: 2022/4/27 - * 修改人: - * 修改内容: - * 修改时间: - */ -package com.accompany.payment.sandpay; - -import lombok.Data; - -import java.math.BigDecimal; - -/** - *
类描述: - *
功能详细描述: - * - * @author H1 - * @date [2022/4/27] - */ -@Data -public class SandPayMiniAppReqParams { - private String openId; - private String chargeRecordId; - private BigDecimal chargeAmount; - private String subject; - private String body; - private String clientIp; - private String notifyUrl; - private String frontUrl; - private String subAppId; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayRequestParam.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayRequestParam.java deleted file mode 100644 index cdc94ad8e..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayRequestParam.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.accompany.payment.sandpay; - -import lombok.Data; - -import java.math.BigDecimal; - -@Data -public class SandPayRequestParam { - /** - * 商户订单号 - */ - private String agentBillId; - - /** - * 支付金额,单位元 - */ - private BigDecimal payAmt; - - /** - * 同步通知地址 - */ - private String returnUrl; - - /** - * 用户ip - */ - private String userIp; - - /** - * 提交单据的时间yyyyMMddHHmmss - */ - private String agentBillTime; - - /** - * 商品名称 - */ - private String goodsName; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayService.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayService.java deleted file mode 100644 index fcf1144ec..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/SandPayService.java +++ /dev/null @@ -1,369 +0,0 @@ -package com.accompany.payment.sandpay; - -import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.DateTimeUtil; -import com.accompany.common.utils.StringUtils; -import com.accompany.core.dto.HttpForm; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.util.OkHttpUtils; -import com.accompany.payment.config.SandPayConfig; -import com.accompany.payment.sandpay.bo.SandPayWxMiniPayResultBO; -import com.accompany.payment.sandpay.utils.CertUtil; -import com.accompany.payment.sandpay.utils.CryptoUtil; -import com.accompany.payment.sandpay.utils.HttpClient; -import com.accompany.payment.sandpay.utils.SDKUtil; -import com.accompany.payment.utils.CommonPayUtils; -import com.accompany.payment.vo.JsapiReturnVo; -import com.accompany.payment.wanxiang.utils.RSAUtils; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import org.apache.commons.codec.binary.Base64; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import sun.misc.BASE64Decoder; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.math.BigDecimal; -import java.net.URLDecoder; -import java.net.URLEncoder; -import java.util.*; -import java.util.stream.Collectors; - -@Service -public class SandPayService { - - private static final Logger log = LoggerFactory.getLogger(SandPayService.class); - - private static final String VERSION = "10"; - public static final String PAY_TYPE = "1"; - public static final String PAY_CODE = "1"; - public static final String CONST_TYPE = "1"; - public static final String ENC_UTF_8 = "UTF-8"; - public static final String STORE_ID = "000000"; - public static final String PRODUCT_CODE_ALIPAY_H_5 = "02020002"; - public static final String CLEAR_CYCLE_T1 = "0"; - public static final String ACCSPLIT_FLAG_NO = "NO"; - public static final String JUMP_SCHEME_NULL = "sandcash://scpay"; - public static final String SIGN_TYPE_MD5 = "MD5"; - public static String encoding = "UTF-8"; - - /** - * 小程序/公众号支付 - */ - public static final String MINIAPP_VERSION = "1.0"; - public static final String MINIPRO_PRODID = "00002021"; - public static final String WXPUB_PRODID = "00002020"; - public static final String MINIPRO_ACCESSTYPE = "1"; - public static final String MINIPRO_METHOD = "sandpay.trade.pay"; - public static final String MINIPRO_PAYMODE = "sand_wx"; - public static final String MINIPRO_CHANNEL_TYPE = "08"; - - //http连接超时时间 - public static int connectTimeout = 300000; - //http响应超时时间 - public static int readTimeout = 600000; - - - - - - @Autowired - private SandPayConfig sandpayConfig; - - public Object payByAlipayInH5(SandPayRequestParam params) { - try { - String url = createOrder(params); - - HashMap result = new HashMap<>(); - result.put("mweb_url", url); - return result; - } catch (ServiceException apiE) { - throw apiE; - } catch (Exception e) { - log.error("衫德支付支付异常", e); - throw new ServiceException(BusiStatus.UNKNOWN); - } - } - - protected String createOrder(SandPayRequestParam params) throws Exception { - Map map1 = createReqParams(params); - log.info("[sandpay payByAlipayInH5] params: {}", JSONObject.toJSONString(map1)); - String name = CommonPayUtils.parseToQueryStr(map1); - return sandpayConfig.getAlipayUrl().replaceAll("\\{\\$params\\}", "?" + name); - } - - /** - * 构造请求参数 - * - * @param params - * @return - * @throws UnsupportedEncodingException - */ - private Map createReqParams(SandPayRequestParam params) throws Exception { - Map reqParams = new HashMap(); - reqParams.put("version", VERSION); - reqParams.put("mer_no", sandpayConfig.getAgentId()); - reqParams.put("mer_key", sandpayConfig.getAlipayPrivateKey()); - reqParams.put("mer_order_no", params.getAgentBillId()); - reqParams.put("create_time",params.getAgentBillTime()); - String expireTime = DateTimeUtil.convertDate(DateTimeUtil.addMinutes(DateTimeUtil.convertStrToDate(params.getAgentBillTime(), - DateTimeUtil.DEFAULT_DATE_PATTERN__), sandpayConfig.getExpireMinutes()), - DateTimeUtil.DEFAULT_DATE_PATTERN__); - reqParams.put("order_amt", params.getPayAmt().toString()); - reqParams.put("notify_url",sandpayConfig.getAlipayNotifyUrl()); - if (StringUtils.isBlank(params.getReturnUrl())) { - reqParams.put("return_url", Optional.ofNullable(sandpayConfig.getReturnUrl()).orElse("")); - } else { - reqParams.put("return_url", params.getReturnUrl()); - } - reqParams.put("create_ip", params.getUserIp().replaceAll("\\.", "_")); - reqParams.put("store_id", STORE_ID); - reqParams.put("pay_extra", ""); - reqParams.put("accsplit_flag", ACCSPLIT_FLAG_NO); - reqParams.put("sign_type", SIGN_TYPE_MD5); - - generAndSetSign(reqParams); - // URL 编码 - reqParams.put("mer_key", URLEncoder.encode(reqParams.get("mer_key"),ENC_UTF_8)); - reqParams.put("notify_url", URLEncoder.encode(reqParams.get("notify_url"),ENC_UTF_8)); - reqParams.put("return_url", URLEncoder.encode(reqParams.get("return_url"),ENC_UTF_8)); - reqParams.put("pay_extra", URLEncoder.encode(reqParams.get("pay_extra"),ENC_UTF_8)); - // 以下字段不参与签名 - reqParams.put("expire_time",expireTime); - reqParams.put("goods_name", URLEncoder.encode(params.getGoodsName(),ENC_UTF_8)); - reqParams.put("product_code", PRODUCT_CODE_ALIPAY_H_5); - reqParams.put("clear_cycle", CLEAR_CYCLE_T1); - reqParams.put("jump_scheme", JUMP_SCHEME_NULL); - reqParams.put("meta_option", URLEncoder.encode(sandpayConfig.getMetaOption(),ENC_UTF_8)); - return reqParams; - } - - /** - * 生成签名,并放入map中 - * - * @param reqParams - */ - private void generAndSetSign(Map reqParams) throws Exception { - String sign = CommonPayUtils.signParams(reqParams, "key", sandpayConfig.getMd5Key()); - reqParams.put("sign",sign); - } - - /** - * 校验支付宝回调 - * - * @param requestData - * @return - */ - public boolean verifyAlipayNotifyData(Map requestData) throws Exception { - String data = requestData.get("data"); - String sign = requestData.get("sign"); - log.info("[sandpay verifyAlipayNotifyData]data: {}, sign: {}", data, sign); - boolean valid = CryptoUtil.verifyDigitalSign(data.getBytes("utf-8"), Base64.decodeBase64(sign), - CertUtil.getPublicKey(sandpayConfig.getAlipayPublicKey()), "SHA1WithRSA"); - return valid; - } - - public String payByAlipayForNative(SandPayRequestParam params) { - try { - return createOrder(params); - } catch (ServiceException apiE) { - throw apiE; - } catch (Exception e) { - log.error("[payByAlipayForNative] 衫德支付支付异常", e); - throw new ServiceException(BusiStatus.UNKNOWN); - } - } - - public JsapiReturnVo createWxPubOrder(SandPayMiniAppReqParams params) { - checkOrderParams(params); - SandPayCommParams head = buildCommParams(MINIPRO_METHOD, WXPUB_PRODID); - SandPayWxMiniPayResultBO resultBO = createWxOrderBase(params, head); - return buildUnionPublicVO(resultBO); - } - - /** - * 构建统一的公众号请求参数 - * - * @param resultBO 杉德请求返回 - * @return 统一的公众号请求参数 - */ - private JsapiReturnVo buildUnionPublicVO(SandPayWxMiniPayResultBO resultBO) { - JsapiReturnVo jsapiReturnVo = new JsapiReturnVo(); - jsapiReturnVo.setTimestamp(resultBO.getTimeStamp()); - jsapiReturnVo.setNonce_str(resultBO.getNonceStr()); - jsapiReturnVo.setPrepay_id(resultBO.getPackageInfo()); - jsapiReturnVo.setSign(resultBO.getPaySign()); - jsapiReturnVo.setAppid(resultBO.getAppId()); - jsapiReturnVo.setSign_type(resultBO.getSignType()); - return jsapiReturnVo; - } - - /** - * 小程序下单 - * @param params - * @return - */ - public SandPayWxMiniPayResultBO createWxMiniAppOrder(SandPayMiniAppReqParams params) { - checkOrderParams(params); - SandPayCommParams head = buildCommParams(MINIPRO_METHOD, MINIPRO_PRODID); - return createWxOrderBase(params, head); - } - - private SandPayWxMiniPayResultBO createWxOrderBase(SandPayMiniAppReqParams params, SandPayCommParams head) { - String result = null; - try { - SandPayMiniAppReqBaseParams baseParams = new SandPayMiniAppReqBaseParams(); - baseParams.setHead(head); - SandPayMiniAppReqBaseParams.SandPayMiniAppReqBodyParams body = buildBody(params); - baseParams.setBody(body); - Map reqMap = new HashMap(); - JSONObject reqJson=new JSONObject(); - reqJson.put("head", head); - reqJson.put("body", body); - String reqStr= reqJson.toJSONString(); - String reqSign; - // 签名 - try { - reqSign = new String(Base64.encodeBase64(CryptoUtil.digitalSign(reqStr.getBytes(encoding), - CertUtil.getPrivateKey(baseToInputStream(), SandPayConfig.MiniAppConfig.privateKeyPwd), - "SHA1WithRSA"))); - } catch (Exception e) { - log.error(e.getMessage(), e); - return null; - } - //整体报文格式 - reqMap.put("charset", "utf-8"); - reqMap.put("data", reqStr); - reqMap.put("signType", "01"); - reqMap.put("sign", reqSign); - reqMap.put("extend", ""); - log.info("杉德微信小程序/公众号支付请求参数 {}", JSON.toJSONString(reqMap)); - log.info("请求报文:\n"+JSONObject.toJSONString(reqJson)); - log.info("请求报文:\n"+JSONObject.toJSONString(reqSign)); - result = HttpClient.doPost(SandPayConfig.MiniAppConfig.createOrderUrl, - reqMap, connectTimeout, readTimeout); - log.info("响应报文:\n" + result); - log.info("杉德小程序/公众号支付请求结果:{}",result); - result = URLDecoder.decode(result, encoding); - } catch (Exception e) { - log.error("杉德小程序/公众号创建订单失败。params:" + JSONObject.toJSONString(params), e); - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失敗,請重試"); - } - Map respMap = SDKUtil.convertResultStringToMap(result); - String respData = respMap.get("data"); - String respSign = respMap.get("sign"); - // 验证签名 - boolean valid; - SandPayWxMiniPayResultBO resultBO = new SandPayWxMiniPayResultBO(); - try { - valid = CryptoUtil.verifyDigitalSign(respData.getBytes(encoding), Base64.decodeBase64(respSign), - CertUtil.getPublicKey(sandpayConfig.getAlipayPublicKey()), - "SHA1WithRSA"); - if(!valid) { - log.error("verify sign fail."); - return null; - } - log.info("verify sign success"); - JSONObject respJson = JSONObject.parseObject(respData); - if (respJson != null) { - log.info("响应码:[" + respJson.getJSONObject("head").getString("respCode") + "]"); - log.info("响应描述:[" + respJson.getJSONObject("head").getString("respMsg") + "]"); - log.info("响应报文:\n" + JSONObject.toJSONString(respJson, true)); - result = respJson.getJSONObject("body").getJSONObject("credential").getString("params"); - log.info("响应报文:\n" + JSONObject.toJSONString(result, true)); - resultBO = JSONObject.parseObject(result, SandPayWxMiniPayResultBO.class); - log.info("杉德小程序/公众号 resultBO {}", JSON.toJSONString(resultBO)); - } else { - log.error("服务器请求异常!!!"); - } - } catch (Exception e) { - log.error(e.getMessage()); - return null; - } - return resultBO; - } - - /** - * @return - * @throws IOException - */ - public InputStream baseToInputStream () throws IOException { - String base64 = SandPayConfig.MiniAppConfig.privateKeyBase64; - //将字符串转换为byte数组 - byte[] bytes = new BASE64Decoder().decodeBuffer(base64.trim()); - //转化为输入流 - ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes); - return inputStream; - } - - /** - * 构建请求公参 - * @param method - * @param prodId - * @return - */ - private SandPayCommParams buildCommParams(String method, String prodId) { - String reqTime = DateTimeUtil.convertDate(new Date(), DateTimeUtil.DEFAULT_DATE_PATTERN__); - SandPayCommParams commParams = SandPayCommParams.builder() - .version(MINIAPP_VERSION).method(method) - .productId(prodId).accessType(MINIPRO_ACCESSTYPE) - .channelType(MINIPRO_CHANNEL_TYPE) - .mid(SandPayConfig.MiniAppConfig.mid).reqTime(reqTime) - .build(); - return commParams; - } - - private SandPayMiniAppReqBaseParams.SandPayMiniAppReqBodyParams buildBody(SandPayMiniAppReqParams params) { - SandPayMiniAppReqBaseParams.SandPayMiniAppReqBodyParams body = new SandPayMiniAppReqBaseParams.SandPayMiniAppReqBodyParams(); - body.setOrderCode(params.getChargeRecordId()); - body.setTotalAmount(String.format("%012d",params.getChargeAmount().intValue())); - body.setSubject(params.getSubject()); - body.setBody(params.getBody()); - body.setPayMode(MINIPRO_PAYMODE); - SandPayMiniAppReqBaseParams.SandPayMiniAppReqBodyPayExtra extra = new SandPayMiniAppReqBaseParams.SandPayMiniAppReqBodyPayExtra(); - extra.setUserId(params.getOpenId()); - extra.setSubAppid(params.getSubAppId()); - body.setPayExtra(extra); - body.setClientIp(params.getClientIp()); - body.setNotifyUrl(SandPayConfig.MiniAppConfig.notifyUrl); - if (StringUtils.isBlank(params.getFrontUrl())) { - body.setFrontUrl(Optional.ofNullable(sandpayConfig.getReturnUrl()).orElse("")); - } else { - body.setFrontUrl(params.getFrontUrl()); - } - return body; - } - - - /** - * 校验下单参数 - */ - private void checkOrderParams(SandPayMiniAppReqParams params) { - if (params == null) { - throw new ServiceException(BusiStatus.PARAMERROR); - } - if (params.getChargeAmount() == null || params.getChargeAmount().compareTo(BigDecimal.ZERO) <= 0) { - throw new ServiceException(BusiStatus.PARAMERROR); - } - if (StringUtils.isBlank(params.getChargeRecordId())) { - throw new ServiceException(BusiStatus.PARAMERROR, "商戶訂單號不能為空"); - } - if (StringUtils.isBlank(params.getBody())) { - throw new ServiceException(BusiStatus.PARAMERROR, "商品訂單描述不能為空"); - } - if (StringUtils.isBlank(params.getOpenId())) { - throw new ServiceException(BusiStatus.PARAMERROR, "微信openId不能為空"); - } - if (StringUtils.isBlank(params.getSubject())) { - throw new ServiceException(BusiStatus.PARAMERROR, "訂單標題不能為空"); - } - if (StringUtils.isBlank(params.getClientIp())) { - throw new ServiceException(BusiStatus.PARAMERROR, "客戶端IP不能為空"); - } - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/bo/SandPayWxMiniPayResultBO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/bo/SandPayWxMiniPayResultBO.java deleted file mode 100644 index d5941ab59..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/bo/SandPayWxMiniPayResultBO.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 文 件 名: SandPayWxMiniPayResultBO - * 版 权: - * 描 述: <描述> - * 创建人: H1 - * 创建时间: 2022/4/27 - * 修改人: - * 修改内容: - * 修改时间: - */ -package com.accompany.payment.sandpay.bo; - -import com.alibaba.fastjson.annotation.JSONField; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -/** - *
类描述: 杉德小程序/公众号支付返回BO - *
功能详细描述: - * - * @author H1 - * @date [2022/4/27] - */ -@Data -public class SandPayWxMiniPayResultBO { - /** appId */ - private String appId; - - /** 创建支付时间戳 秒 */ - private String timeStamp; - - /** 随机字符串 */ - private String nonceStr; - - /** 前端调起支付参数 */ - @JSONField(name = "package") - @JsonProperty("package") - private String packageInfo; - - /** 签名类型 */ - private String signType; - - /** 支付签名 */ - private String paySign; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/utils/CertUtil.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/utils/CertUtil.java deleted file mode 100644 index 152c82acb..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/utils/CertUtil.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * - * Licensed Property to Sand Co., Ltd. - * - * (C) Copyright of Sand Co., Ltd. 2010 - * All Rights Reserved. - * - * - * Modification History: - * ============================================================================= - * Author Date Description - * ------------ ---------- --------------------------------------------------- - * 企业产品团队 2016-10-12 证书工具类. - * ============================================================================= - */ -package com.accompany.payment.sandpay.utils; -//微信公众号/微信小程序 -import java.io.*; -import java.security.KeyStore; -import java.security.NoSuchAlgorithmException; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import java.util.Enumeration; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.commons.codec.binary.Base64; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * @ClassName: CertUtil - * @Description: sdk证书工具类,主要用于对证书的加载和使用 - * @version 2.0.0 - */ -public class CertUtil { - - public static final String PUBLIC_KEY = "public_key"; - public static final String PRIVATE_KEY = "private_key"; - - private static final Logger logger = LoggerFactory.getLogger(CertUtil.class); - - private static final ConcurrentHashMap keys = new ConcurrentHashMap(); - - public static void init(String publicKeyPath, String privateKeyPath, String keyPassword) throws Exception { - // 加载私钥 - initPulbicKey(publicKeyPath); - // 加载公钥 - initPrivateKey(privateKeyPath, keyPassword); - } - - public static PublicKey getPublicKey() { - return (PublicKey) keys.get(PUBLIC_KEY); - } - - public static PrivateKey getPrivateKey() { - return (PrivateKey) keys.get(PRIVATE_KEY); - } - - private static void initPulbicKey(String publicKeyPath) throws Exception { - - String classpathKey = "classpath:"; - if (publicKeyPath != null) { - try { - InputStream inputStream = null; - if (publicKeyPath.startsWith(classpathKey)) { - inputStream = CertUtil.class.getClassLoader() - .getResourceAsStream(publicKeyPath.substring(classpathKey.length())); - } else { - inputStream = new FileInputStream(publicKeyPath); - } - PublicKey publicKey = CertUtil.getPublicKey(inputStream); - keys.put(PUBLIC_KEY, publicKey); - } catch (Exception e) { - logger.error("无法加载公钥[{}]", new Object[] { publicKeyPath }); - logger.error(e.getMessage(), e); - throw e; - } - } - } - - private static void initPrivateKey(String privateKeyPath, String keyPassword) throws Exception { - - String classpathKey = "classpath:"; - - try { - InputStream inputStream = null; - if (privateKeyPath.startsWith(classpathKey)) { - inputStream = CertUtil.class.getClassLoader() - .getResourceAsStream(privateKeyPath.substring(classpathKey.length())); - } else { - inputStream = new FileInputStream(privateKeyPath); - } - PrivateKey privateKey = CertUtil.getPrivateKey(inputStream, keyPassword); - keys.put(PRIVATE_KEY, privateKey); - } catch (Exception e) { - logger.error("无法加载本地私银[" + privateKeyPath + "]"); - logger.error(e.getMessage(), e); - throw e; - } - } - - - public static PublicKey getPublicKey(InputStream inputStream) throws Exception { - try { - - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - X509Certificate oCert = (X509Certificate) cf.generateCertificate(inputStream); - PublicKey publicKey = oCert.getPublicKey(); - return publicKey; - } catch (Exception e) { - e.printStackTrace(); - throw new Exception("读取公钥异常"); - } finally { - try { - if (inputStream != null) { - inputStream.close(); - } - } catch (IOException e) { - } - } - } - - public static PublicKey getPublicKey(String base64String) throws Exception { - try { - ByteArrayInputStream stream = new ByteArrayInputStream(Base64.decodeBase64(base64String)); - return getPublicKey(stream); - } catch (Exception e) { - e.printStackTrace(); - throw new Exception("读取公钥异常"); - } - } - - - /** - * 获取私钥对象 - * - * @param inputStream - * 私钥输入流 - * @param keyAlgorithm - * 密钥算法 - * @return 私钥对象 - * @throws Exception - */ - public static PrivateKey getPrivateKey(InputStream inputStream, String password) throws Exception { - try { - KeyStore ks = KeyStore.getInstance("PKCS12"); - char[] nPassword = null; - if ((password == null) || password.trim().equals("")) { - nPassword = null; - } else { - nPassword = password.toCharArray(); - } - - ks.load(inputStream, nPassword); - Enumeration enumas = ks.aliases(); - String keyAlias = null; - if (enumas.hasMoreElements()) { - keyAlias = (String) enumas.nextElement(); - } - - PrivateKey privateKey = (PrivateKey) ks.getKey(keyAlias, nPassword); - return privateKey; - } catch (FileNotFoundException e) { - throw new Exception("私钥路径文件不存在"); - } catch (IOException e) { - throw new Exception(e); - } catch (NoSuchAlgorithmException e) { - throw new Exception("生成私钥对象异常"); - } finally { - try { - if (inputStream != null) { - inputStream.close(); - } - } catch (IOException e) { - } - } - } - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/utils/CryptoUtil.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/utils/CryptoUtil.java deleted file mode 100644 index 0ec497666..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/utils/CryptoUtil.java +++ /dev/null @@ -1,423 +0,0 @@ -/** - * - * Licensed Property to Sand Co., Ltd. - * - * (C) Copyright of Sand Co., Ltd. 2010 - * All Rights Reserved. - * - * - * Modification History: - * ============================================================================= - * Author Date Description - * ------------ ---------- --------------------------------------------------- - * 企业产品团队 2016-10-12 加解密工具类. - * ============================================================================= - */ -package com.accompany.payment.sandpay.utils; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.math.BigInteger; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.KeyFactory; -import java.security.NoSuchAlgorithmException; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.Signature; -import java.security.SignatureException; -import java.security.cert.X509Certificate; -import java.security.spec.RSAPrivateKeySpec; -import java.security.spec.RSAPublicKeySpec; - -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.SecretKey; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; - -import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * @ClassName: CryptoUtil - * @Description: sdk加解密工具类,主要用于签名、验证、RSA加解密等 - * @version 2.0.0 - */ - -public class CryptoUtil { - - public static Logger logger = LoggerFactory.getLogger(CryptoUtil.class); - - /** - * 数字签名函数入口 - * - * @param plainBytes - * 待签名明文字节数组 - * @param privateKey - * 签名使用私钥 - * @param signAlgorithm - * 签名算法 - * @return 签名后的字节数组 - * @throws Exception - */ - public static byte[] digitalSign(byte[] plainBytes, PrivateKey privateKey, String signAlgorithm) throws Exception { - try { - Signature signature = Signature.getInstance(signAlgorithm); - signature.initSign(privateKey); - signature.update(plainBytes); - byte[] signBytes = signature.sign(); - - return signBytes; - } catch (NoSuchAlgorithmException e) { - throw new Exception(String.format("数字签名时没有[%s]此类算法", signAlgorithm)); - } catch (InvalidKeyException e) { - throw new Exception("数字签名时私钥无效", e); - } catch (SignatureException e) { - throw new Exception("数字签名时出现异常", e); - } - } - - /** - * 验证数字签名函数入口 - * - * @param plainBytes - * 待验签明文字节数组 - * @param signBytes - * 待验签签名后字节数组 - * @param publicKey - * 验签使用公钥 - * @param signAlgorithm - * 签名算法 - * @return 验签是否通过 - * @throws Exception - */ - public static boolean verifyDigitalSign(byte[] plainBytes, byte[] signBytes, PublicKey publicKey, String signAlgorithm) throws Exception { - boolean isValid = false; - try { - Signature signature = Signature.getInstance(signAlgorithm); - signature.initVerify(publicKey); - signature.update(plainBytes); - isValid = signature.verify(signBytes); - return isValid; - } catch (NoSuchAlgorithmException e) { - throw new Exception(String.format("验证数字签名时没有[%s]此类算法", signAlgorithm), e); - } catch (InvalidKeyException e) { - throw new Exception("验证数字签名时公钥无效", e); - } catch (SignatureException e) { - throw new Exception("验证数字签名时出现异常", e); - } - } - - /** - * 验证数字签名函数入口 - * - * @param plainBytes - * 待验签明文字节数组 - * @param signBytes - * 待验签签名后字节数组 - * @param publicKey - * 验签使用公钥 - * @param signAlgorithm - * 签名算法 - * @return 验签是否通过 - * @throws Exception - */ - public static boolean verifyDigitalSign(byte[] plainBytes, byte[] signBytes, X509Certificate cert, String signAlgorithm) throws Exception { - boolean isValid = false; - try { - Signature signature = Signature.getInstance(signAlgorithm); - signature.initVerify(cert); - signature.update(plainBytes); - isValid = signature.verify(signBytes); - return isValid; - } catch (NoSuchAlgorithmException e) { - throw new Exception(String.format("验证数字签名时没有[%s]此类算法", signAlgorithm)); - } catch (InvalidKeyException e) { - throw new Exception("验证数字签名时公钥无效", e); - } catch (SignatureException e) { - throw new Exception("验证数字签名时出现异常", e); - } - } - - /** - * RSA加密 - * - * @param plainBytes - * 明文字节数组 - * @param publicKey - * 公钥 - * @param keyLength - * 密钥bit长度 - * @param reserveSize - * padding填充字节数,预留11字节 - * @param cipherAlgorithm - * 加解密算法,一般为RSA/ECB/PKCS1Padding - * @return 加密后字节数组,不经base64编码 - * @throws Exception - */ - public static byte[] RSAEncrypt(byte[] plainBytes, PublicKey publicKey, int keyLength, int reserveSize, String cipherAlgorithm) - throws Exception { - int keyByteSize = keyLength / 8; // 密钥字节数 - int encryptBlockSize = keyByteSize - reserveSize; // 加密块大小=密钥字节数-padding填充字节数 - int nBlock = plainBytes.length / encryptBlockSize;// 计算分段加密的block数,向上取整 - if ((plainBytes.length % encryptBlockSize) != 0) { // 余数非0,block数再加1 - nBlock += 1; - } - - try { - Cipher cipher = Cipher.getInstance(cipherAlgorithm); - cipher.init(Cipher.ENCRYPT_MODE, publicKey); - - // 输出buffer,大小为nBlock个keyByteSize - ByteArrayOutputStream outbuf = new ByteArrayOutputStream(nBlock * keyByteSize); - // 分段加密 - for (int offset = 0; offset < plainBytes.length; offset += encryptBlockSize) { - int inputLen = plainBytes.length - offset; - if (inputLen > encryptBlockSize) { - inputLen = encryptBlockSize; - } - - // 得到分段加密结果 - byte[] encryptedBlock = cipher.doFinal(plainBytes, offset, inputLen); - // 追加结果到输出buffer中 - outbuf.write(encryptedBlock); - } - - outbuf.flush(); - outbuf.close(); - return outbuf.toByteArray(); - } catch (NoSuchAlgorithmException e) { - throw new Exception(String.format("没有[%s]此类加密算法", cipherAlgorithm)); - } catch (NoSuchPaddingException e) { - throw new Exception(String.format("没有[%s]此类填充模式", cipherAlgorithm)); - } catch (InvalidKeyException e) { - throw new Exception("无效密钥", e); - } catch (IllegalBlockSizeException e) { - throw new Exception("加密块大小不合法", e); - } catch (BadPaddingException e) { - throw new Exception("错误填充模式", e); - } catch (IOException e) { - throw new Exception("字节输出流异常", e); - } - } - - /** - * RSA解密 - * - * @param encryptedBytes - * 加密后字节数组 - * @param privateKey - * 私钥 - * @param keyLength - * 密钥bit长度 - * @param reserveSize - * padding填充字节数,预留11字节 - * @param cipherAlgorithm - * 加解密算法,一般为RSA/ECB/PKCS1Padding - * @return 解密后字节数组,不经base64编码 - * @throws Exception - */ - public static byte[] RSADecrypt(byte[] encryptedBytes, PrivateKey privateKey, int keyLength, int reserveSize, String cipherAlgorithm) - throws Exception { - int keyByteSize = keyLength / 8; // 密钥字节数 - int decryptBlockSize = keyByteSize - reserveSize; // 解密块大小=密钥字节数-padding填充字节数 - int nBlock = encryptedBytes.length / keyByteSize;// 计算分段解密的block数,理论上能整除 - - try { - Cipher cipher = Cipher.getInstance(cipherAlgorithm); - cipher.init(Cipher.DECRYPT_MODE, privateKey); - - // 输出buffer,大小为nBlock个decryptBlockSize - ByteArrayOutputStream outbuf = new ByteArrayOutputStream(nBlock * decryptBlockSize); - // 分段解密 - for (int offset = 0; offset < encryptedBytes.length; offset += keyByteSize) { - // block大小: decryptBlock 或 剩余字节数 - int inputLen = encryptedBytes.length - offset; - if (inputLen > keyByteSize) { - inputLen = keyByteSize; - } - - // 得到分段解密结果 - byte[] decryptedBlock = cipher.doFinal(encryptedBytes, offset, inputLen); - // 追加结果到输出buffer中 - outbuf.write(decryptedBlock); - } - - outbuf.flush(); - outbuf.close(); - return outbuf.toByteArray(); - } catch (NoSuchAlgorithmException e) { - throw new Exception(String.format("没有[%s]此类解密算法", cipherAlgorithm)); - } catch (NoSuchPaddingException e) { - throw new Exception(String.format("没有[%s]此类填充模式", cipherAlgorithm)); - } catch (InvalidKeyException e) { - throw new Exception("无效密钥", e); - } catch (IllegalBlockSizeException e) { - throw new Exception("解密块大小不合法", e); - } catch (BadPaddingException e) { - throw new Exception("错误填充模式", e); - } catch (IOException e) { - throw new Exception("字节输出流异常", e); - } - } - - public static PublicKey toPublicKey(BigInteger exponent,BigInteger modulus) throws Exception { - - KeyFactory keyFactory = KeyFactory.getInstance("RSA"); - RSAPublicKeySpec pubSpec = new RSAPublicKeySpec(modulus, exponent); - PublicKey key = keyFactory.generatePublic(pubSpec); - return key; - } - - public static PrivateKey toPrivateKey(BigInteger exponent,BigInteger modulus) throws Exception { - - KeyFactory keyFactory = KeyFactory.getInstance("RSA"); - RSAPrivateKeySpec prispec = new RSAPrivateKeySpec(modulus, exponent); - PrivateKey key = keyFactory.generatePrivate(prispec); - return key; - } - - - /** - * AES加密 - * - * @param plainBytes - * 明文字节数组 - * @param keyBytes - * 密钥字节数组 - * @param keyAlgorithm - * 密钥算法 - * @param cipherAlgorithm - * 加解密算法 - * @param IV - * 随机向量 - * @return 加密后字节数组,不经base64编码 - * @throws Exception - */ - public static byte[] AESEncrypt(byte[] plainBytes, byte[] keyBytes, String keyAlgorithm, String cipherAlgorithm, String IV) - throws Exception { - try { - // AES密钥长度为128bit、192bit、256bit,默认为128bit - if (keyBytes.length % 8 != 0 || keyBytes.length < 16 || keyBytes.length > 32) { - throw new Exception("AES密钥长度不合法"); - } - - Cipher cipher = Cipher.getInstance(cipherAlgorithm); - SecretKey secretKey = new SecretKeySpec(keyBytes, keyAlgorithm); - if (StringUtils.trimToNull(IV) != null) { - IvParameterSpec ivspec = new IvParameterSpec(IV.getBytes()); - cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivspec); - } else { - cipher.init(Cipher.ENCRYPT_MODE, secretKey); - } - - byte[] encryptedBytes = cipher.doFinal(plainBytes); - - return encryptedBytes; - } catch (NoSuchAlgorithmException e) { - throw new Exception(String.format("没有[%s]此类加密算法", cipherAlgorithm)); - } catch (NoSuchPaddingException e) { - throw new Exception(String.format("没有[%s]此类填充模式", cipherAlgorithm)); - } catch (InvalidKeyException e) { - throw new Exception("无效密钥", e); - } catch (InvalidAlgorithmParameterException e) { - throw new Exception("无效密钥参数", e); - } catch (BadPaddingException e) { - throw new Exception("错误填充模式", e); - } catch (IllegalBlockSizeException e) { - throw new Exception("加密块大小不合法", e); - } - } - - /** - * AES解密 - * - * @param encryptedBytes - * 密文字节数组,不经base64编码 - * @param keyBytes - * 密钥字节数组 - * @param keyAlgorithm - * 密钥算法 - * @param cipherAlgorithm - * 加解密算法 - * @param IV - * 随机向量 - * @return 解密后字节数组 - * @throws Exception - */ - public static byte[] AESDecrypt(byte[] encryptedBytes, byte[] keyBytes, String keyAlgorithm, String cipherAlgorithm, String IV) - throws Exception { - try { - // AES密钥长度为128bit、192bit、256bit,默认为128bit - if (keyBytes.length % 8 != 0 || keyBytes.length < 16 || keyBytes.length > 32) { - throw new Exception("AES密钥长度不合法"); - } - - Cipher cipher = Cipher.getInstance(cipherAlgorithm); - SecretKey secretKey = new SecretKeySpec(keyBytes, keyAlgorithm); - if (IV != null && StringUtils.trimToNull(IV) != null) { - IvParameterSpec ivspec = new IvParameterSpec(IV.getBytes()); - cipher.init(Cipher.DECRYPT_MODE, secretKey, ivspec); - } else { - cipher.init(Cipher.DECRYPT_MODE, secretKey); - } - - byte[] decryptedBytes = cipher.doFinal(encryptedBytes); - - return decryptedBytes; - } catch (NoSuchAlgorithmException e) { - throw new Exception(String.format("没有[%s]此类加密算法", cipherAlgorithm)); - } catch (NoSuchPaddingException e) { - throw new Exception(String.format("没有[%s]此类填充模式", cipherAlgorithm)); - } catch (InvalidKeyException e) { - throw new Exception("无效密钥", e); - } catch (InvalidAlgorithmParameterException e) { - throw new Exception("无效密钥参数", e); - } catch (BadPaddingException e) { - throw new Exception("错误填充模式", e); - } catch (IllegalBlockSizeException e) { - throw new Exception("解密块大小不合法", e); - } - } - - public static byte[] hexString2ByteArr(String hexStr) { - return new BigInteger(hexStr, 16).toByteArray(); - } - public static final byte[] hexStrToBytes(String s) { - byte[] bytes; - bytes = new byte[s.length() / 2]; - for (int i = 0; i < bytes.length; i++) { - bytes[i] = (byte) Integer.parseInt(s.substring(2 * i, 2 * i + 2), 16); - } - return bytes; - } - /** - * 字符数组16进制字符 - * - * @param bytes - * @return - */ - public static String bytes2string(byte[] bytes, int radix) { - int size = 2; - if (radix == 2) { - size = 8; - } - StringBuilder sb = new StringBuilder(bytes.length * size); - for (int i = 0; i < bytes.length; i++) { - int integer = bytes[i]; - while (integer < 0) { - integer = integer + 256; - } - String str = Integer.toString(integer, radix); - sb.append(StringUtils.leftPad(str.toUpperCase(), size, "0")); - } - return sb.toString(); - } - - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/utils/HttpClient.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/utils/HttpClient.java deleted file mode 100644 index da7bfab81..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/utils/HttpClient.java +++ /dev/null @@ -1,325 +0,0 @@ -/** - * - * Licensed Property to Sand Co., Ltd. - * - * (C) Copyright of Sand Co., Ltd. 2010 - * All Rights Reserved. - * - * - * Modification History: - * ============================================================================= - * Author Date Description - * ------------ ---------- --------------------------------------------------- - * 企业产品团队 2016-10-12 Http通讯工具类. - * ============================================================================= - */ -package com.accompany.payment.sandpay.utils; - -import org.apache.commons.lang.StringUtils; -import org.apache.http.HttpHost; -import org.apache.http.HttpResponse; -import org.apache.http.NameValuePair; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.ResponseHandler; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.utils.URLEncodedUtils; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -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 org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.net.ssl.*; -import java.io.IOException; -import java.net.URL; -import java.security.SecureRandom; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.*; -import java.util.Map.Entry; - - -/** - * @ClassName: HttpClient - * @Description: 主要用于Http通讯 - * @version 2.0.0 - */ -public class HttpClient { - - private static Logger logger = LoggerFactory.getLogger(HttpClient.class); - - private static final String DEFAULT_CHARSET = "UTF-8"; - - private static SSLContext sslcontext; - - private static SSLConnectionSocketFactory sslsf; - - public static String doPost(String url, Map params, int connectTimeout, int readTimeout) - throws IOException { - return doPost(url, params, DEFAULT_CHARSET, connectTimeout, readTimeout); - } - - public static String doPost(String url, Map params, String charset, int connectTimeout, - int readTimeout) throws IOException { - Map headers = new HashMap(); - headers.put("Content-type", "application/x-www-form-urlencoded;charset=" + charset); - return doPost(url, headers, params, charset, connectTimeout, readTimeout); - } - - public static String doPost(String url, Map headers, Map params, - final String charset, int connectTimeout, int readTimeout) throws IOException { - - URL targetUrl = new URL(url); - HttpHost httpHost = new HttpHost(targetUrl.getHost(), targetUrl.getPort(), targetUrl.getProtocol()); - logger.info("host:" + targetUrl.getHost() + ",port:" + targetUrl.getPort() + ",protocol:" - + targetUrl.getProtocol() + ",path:" + targetUrl.getPath()); - - CloseableHttpClient httpclient = getHttpClient(targetUrl); - - try { - HttpPost httpPost = getHttpPost(targetUrl, headers, params, charset, connectTimeout, readTimeout); - - String resp = httpclient.execute(httpHost, httpPost, new ResponseHandler() { - public String handleResponse(HttpResponse response) throws ClientProtocolException, IOException { - - int status = response.getStatusLine().getStatusCode(); - - logger.info("status:["+status+"]"); - if (status == 200) { - return EntityUtils.toString(response.getEntity(), charset); - } else { - return ""; - } - } - }); - return resp; - } finally { - httpclient.close(); - } - - } - - /** - * 执行HTTP GET请求。 - * - * @param url - * 请求地址 - * @param params - * 请求参数 - * @return 响应字符串 - * @throws IOException - */ - public static String doGet(String url, Map params) throws IOException { - return doGet(url, params, DEFAULT_CHARSET); - } - - /** - * 执行HTTP GET请求。 - * - * @param url - * 请求地址 - * @param params - * 请求参数 - * @param charset - * 字符集,如UTF-8, GBK, GB2312 - * @return 响应字符串 - * @throws IOException - */ - public static String doGet(String url, Map params, String charset) throws IOException { - - Map headers = new HashMap(); - headers.put("Content-type", "application/x-www-form-urlencoded;charset=" + charset); - return doGet(url, headers, params, charset); - - } - - /** - * - * @param url - * @param headers - * @param params - * @param charset - * @return - * @throws IOException - * @throws ClientProtocolException - */ - public static String doGet(String url, Map headers, Map params, - final String charset) throws IOException { - - URL targetUrl = new URL(url); - CloseableHttpClient httpclient = getHttpClient(targetUrl); - - try { - - HttpGet httpGet = getHttpGet(url, headers, params, charset); - - String resp = httpclient.execute(httpGet, new ResponseHandler() { - public String handleResponse(HttpResponse response) throws ClientProtocolException, IOException { - int status = response.getStatusLine().getStatusCode(); - - logger.info("status:[{}]", new Object[] { status }); - if (status == 200) { - return EntityUtils.toString(response.getEntity(), charset); - } else { - return ""; - } - } - }); - return resp; - - } finally { - httpclient.close(); - } - } - - /** - * - * @param targetUrl - * @param headers - * @param params - * @param charset - * @param isProxy - * @return - * @throws IOException - */ - private static HttpGet getHttpGet(String url, Map headers, Map params, - String charset) throws IOException { - - URL targetUrl = buildGetUrl(url, buildQuery(params, charset)); - HttpGet httpGet = new HttpGet(targetUrl.toString()); - - Iterator> iterator = headers.entrySet().iterator(); - while (iterator.hasNext()) { - Entry entry = iterator.next(); - httpGet.setHeader(entry.getKey(), entry.getValue()); - } - - return httpGet; - - } - - /** - * @param isProxy - * - * @param targetUrl @param headers @param params @param charset @param - * connectTimeout @param readTimeout @return @throws IOException @throws - */ - private static HttpPost getHttpPost(URL targetUrl, Map headers, Map params, - String charset, int connectTimeout, int readTimeout) throws IOException { - - HttpPost httpPost = new HttpPost(targetUrl.getPath()); - - Iterator> iterator = headers.entrySet().iterator(); - while (iterator.hasNext()) { - Entry entry = iterator.next(); - httpPost.setHeader(entry.getKey(), entry.getValue()); - } - - RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(readTimeout) - .setConnectTimeout(connectTimeout) // Connection timeout is the timeout until a connection with the - // server is established. - .build(); - httpPost.setConfig(requestConfig); - - StringEntity entity = new StringEntity(buildQuery(params, charset), charset); - httpPost.setEntity(entity); - - return httpPost; - } - - /** - * - * @param targetUrl - * @return - */ - private static CloseableHttpClient getHttpClient(URL targetUrl) { - - CloseableHttpClient httpClient = null; - if ("https".equals(targetUrl.getProtocol())) { - - httpClient = HttpClients.custom().setSSLSocketFactory(sslsf).build(); - } else { - httpClient = HttpClients.createDefault(); - } - return httpClient; - } - - private static class DefaultTrustManager implements X509TrustManager { - public X509Certificate[] getAcceptedIssuers() { - return null; - } - - public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { - } - - public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { - } - } - - static { - try { - sslcontext = SSLContext.getInstance("TLS"); - sslcontext.init(new KeyManager[0], new TrustManager[] { new DefaultTrustManager() }, new SecureRandom()); - - // Allow TLSv1 protocol only - sslsf = new SSLConnectionSocketFactory(sslcontext, new String[] { "TLSv1" }, null, new HostnameVerifier() { - public boolean verify(String hostname, SSLSession session) { - return true;// 默认认证不通过,进行证书校验。 - } - }); - - // javax.net.ssl.SSLPeerUnverifiedException: Host name '192.168.92.124' does not - // match the certificate subject provided by the peer - // (EMAILADDRESS=lsq1015@qq.com, CN=ipay, OU=CMBC, O=XMCMBC, L=Xiamen, - // ST=Fujian, C=CN) - // at - // org.apache.http.conn.ssl.SSLConnectionSocketFactory.verifyHostname(SSLConnectionSocketFactory.java:394) - - } catch (Exception e) { - e.printStackTrace(); - } - - } - - public static String buildQuery(Map params, String charset) throws IOException { - - List nvps = new LinkedList(); - - Set> entries = params.entrySet(); - for (Entry entry : entries) { - nvps.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); - } - String str = URLEncodedUtils.format(nvps, charset); - - return str; - } - - public static URL buildGetUrl(String strUrl, String query) throws IOException { - URL url = new URL(strUrl); - if (StringUtils.isEmpty(query)) { - return url; - } - - if (StringUtils.isEmpty(url.getQuery())) { - if (strUrl.endsWith("?")) { - strUrl = strUrl + query; - } else { - strUrl = strUrl + "?" + query; - } - } else { - if (strUrl.endsWith("&")) { - strUrl = strUrl + query; - } else { - strUrl = strUrl + "&" + query; - } - } - - return new URL(strUrl); - } - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/utils/SDKUtil.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/utils/SDKUtil.java deleted file mode 100644 index 51e18071e..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/sandpay/utils/SDKUtil.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * - * Licensed Property to Sand Co., Ltd. - * - * (C) Copyright of Sand Co., Ltd. 2010 - * All Rights Reserved. - * - * - * Modification History: - * ============================================================================= - * Author Date Description - * ------------ ---------- --------------------------------------------------- - * 企业产品团队 2016-10-12 SDK工具类. - * ============================================================================= - */ -package com.accompany.payment.sandpay.utils; - -import org.apache.commons.lang.StringUtils; - -import java.io.UnsupportedEncodingException; -import java.util.HashMap; -import java.util.Map; - -/** - * @ClassName: SDKUtil - * @Description: - * @version 2.0.0 - */ -public class SDKUtil { - - /** - * 将形如key=value&key=value的字符串转换为相应的Map对象 - * - * @param result - * @return - */ - public static Map convertResultStringToMap(String result) { - Map map = null; - try { - - if (StringUtils.isNotBlank(result)) { - if (result.startsWith("{") && result.endsWith("}")) { - System.out.println(result.length()); - result = result.substring(1, result.length() - 1); - } - map = parseQString(result); - } - - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - return map; - } - - /** - * 解析应答字符串,生成应答要素 - * - * @param str - * 需要解析的字符串 - * @return 解析的结果map - * @throws UnsupportedEncodingException - */ - public static Map parseQString(String str) throws UnsupportedEncodingException { - - Map map = new HashMap(); - int len = str.length(); - StringBuilder temp = new StringBuilder(); - char curChar; - String key = null; - boolean isKey = true; - boolean isOpen = false;// 值里有嵌套 - char openName = 0; - if (len > 0) { - for (int i = 0; i < len; i++) {// 遍历整个带解析的字符串 - curChar = str.charAt(i);// 取当前字符 - if (isKey) {// 如果当前生成的是key - - if (curChar == '=') {// 如果读取到=分隔符 - key = temp.toString(); - temp.setLength(0); - isKey = false; - } else { - temp.append(curChar); - } - } else {// 如果当前生成的是value - if (isOpen) { - if (curChar == openName) { - isOpen = false; - } - - } else {// 如果没开启嵌套 - if (curChar == '{') {// 如果碰到,就开启嵌套 - isOpen = true; - openName = '}'; - } - if (curChar == '[') { - isOpen = true; - openName = ']'; - } - } - if (curChar == '&' && !isOpen) {// 如果读取到&分割符,同时这个分割符不是值域,这时将map里添加 - putKeyValueToMap(temp, isKey, key, map); - temp.setLength(0); - isKey = true; - } else { - temp.append(curChar); - } - } - - } - putKeyValueToMap(temp, isKey, key, map); - } - return map; - } - - private static void putKeyValueToMap(StringBuilder temp, boolean isKey, String key, Map map) - throws UnsupportedEncodingException { - if (isKey) { - key = temp.toString(); - if (key.length() == 0) { - throw new RuntimeException("QString format illegal"); - } - map.put(key, ""); - } else { - if (key.length() == 0) { - throw new RuntimeException("QString format illegal"); - } - map.put(key, temp.toString()); - } - } - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/service/ChargeCheckService.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/service/ChargeCheckService.java deleted file mode 100644 index 3c86860fe..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/service/ChargeCheckService.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.accompany.payment.service; - -import com.accompany.common.constant.Constant; -import com.accompany.common.result.BusiResult; -import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.CommonUtil; -import com.accompany.common.utils.DateTimeUtil; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.model.Users; -import com.accompany.core.service.SysConfService; -import com.accompany.core.service.base.BaseService; -import com.accompany.core.util.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.*; - -/** - * {这里添加描述} - * - * @author fangchengyan - * @date 2020-02-27 2:50 下午 - */ -@Service -public class ChargeCheckService extends BaseService { - - @Autowired - private SysConfService sysConfService; - @Autowired - private ChargeRecordService chargeRecordService; - - public Integer needCertification(Users users) { - return needCertification(users, Long.valueOf(0),Long.valueOf(0)); - } - - public Integer needCertification(Users users, Long currentAmount, Long historyRechargeAmount) { - return needCertificationBase(users, currentAmount, historyRechargeAmount, Constant.SysConfId.CERTIFICATION_CHARGE_LIMIT_AMOUNT); - } - - public Integer needCertificationForIosPay(Users users, Long currentAmount) { - return needCertificationBase(users, currentAmount, Long.valueOf(0), Constant.SysConfId.IOS_PAY_AMOUNT_LIMIT); - } - - private Integer needCertificationBase(Users user ,Long currentAmount, Long historyRechargeAmount, String limitAmountConfId) { - Integer resultCode = null; - // 判断用户是否已实名 - if (StringUtils.isNotBlank(user.getRealName()) && StringUtils.isNotBlank(user.getIdCardNum())) { - String idCard = user.getIdCardNum(); - // 用户已实名判断用户是否已成年 - if(CommonUtil.checkUserIsUnderAge(idCard)){ - // 判断未成年是否可充值和充值限额 - resultCode = checkChargeUserUnderAge(currentAmount, historyRechargeAmount); - } - } else { - // 是否开启 实名认证充值限额开关 - String limitSwitch = sysConfService.getSysConfValueById(Constant.SysConfId.CERTIFICATION_CHARGE_LIMIT_SWITCH); - Boolean isChargeLimit = Optional.ofNullable(Boolean.parseBoolean(limitSwitch)).orElse(Boolean.FALSE); - if (isChargeLimit) { - // 获取实名认证的限制金额 - String limitMoney = sysConfService.getSysConfValueById(limitAmountConfId); - Long limitAmount = Optional.ofNullable(Long.parseLong(limitMoney)).orElse(0L); - // 转成分为单位 - Long currentAmountInFen = currentAmount * 100; - // 历史累计 + 本次 是否大于限额 - historyRechargeAmount = historyRechargeAmount == null ? currentAmountInFen : historyRechargeAmount + currentAmountInFen; - if (historyRechargeAmount.compareTo(limitAmount * 100) >= 0) { - resultCode = BusiStatus.NEED_CERTIFICATION.value(); - } - } - } - return resultCode; - } - - - /** - * 强制验证实名信息 - * - * @param users - * @return - */ - public boolean needCheckRealNameInfo(Users users) { - // 是否开启强制验证 - String limitSwitch = sysConfService.getSysConfValueById(Constant.SysConfId.CHECK_CERTIFICATION_CHARGE_LIMIT_SWITCH); - Boolean isChargeLimit = Optional.ofNullable(Boolean.parseBoolean(limitSwitch)).orElse(Boolean.FALSE); - if (!isChargeLimit) { - return false; - } - // 强制验证金额金额 - String limitMoney = sysConfService.getSysConfValueById(Constant.SysConfId.CHECK_CERTIFICATION_CHARGE_LIMIT_AMOUNT); - if(null == limitMoney) { - return false; - } - Long limitAmount = Optional.ofNullable(Long.parseLong(limitMoney)).orElse(0L); - - // 从2020.03.03 0点起,已通过实名认证的用户,已累计充值≥指定金额,判断用户账号实名认证信息和充值付款的 - // 微信/支付宝账号实名认证信息需一致,才能进行充值 - Long amount = chargeRecordService.historyRechargeAmount(users.getUid()); - if (null == amount) { - return false; - } - if (amount.compareTo(limitAmount * 100) >= 0) { - if(StringUtils.isBlank(users.getRealName()) || StringUtils.isBlank(users.getIdCardNum())) { - throw new ServiceException(BusiStatus.NEED_CERTIFICATION); - } - return true; - } - return false; - } - - /** - * 校验未成年实名用户 - * @return - */ - public Integer checkChargeUserUnderAge(Long currentAmount,Long historyRechargeAmount){ - Integer resultCode = null; - // 获取 实名未成年人充值开关 - Boolean underAgeChargeSwitch = Boolean.valueOf(sysConfService.getDefaultSysConfValueById(Constant.SysConfId.UNDER_AGE_CHARGE_SWITCH, "true")); - if(underAgeChargeSwitch){ - // 实名未成年的限制充值金额 - String underAgeLimitMoney = sysConfService.getSysConfValueById(Constant.SysConfId.UNDER_AGE_CHARGE_LIMIT_AMOUNT); - Long limitAmount = Optional.ofNullable(Long.parseLong(underAgeLimitMoney)).orElse(0L); - if(limitAmount == 0){ - return null; - }else{ - // 转成分为单位 - Long currentAmountInFen = currentAmount * 100; - if (null == historyRechargeAmount) { - historyRechargeAmount = currentAmountInFen; - } else { - historyRechargeAmount += currentAmountInFen; - } - if (historyRechargeAmount.compareTo(limitAmount * 100) >= 0) { - resultCode = BusiStatus.CHARGE_LIMIT.value(); - } - } - }else{ - resultCode = BusiStatus.UNDER_AGE_WITHDRAWAL.value(); - } - return resultCode; - } - - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/service/ChargeNotifyService.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/service/ChargeNotifyService.java deleted file mode 100644 index becc1455c..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/service/ChargeNotifyService.java +++ /dev/null @@ -1,214 +0,0 @@ -package com.accompany.payment.service; - -import com.accompany.common.constant.PaymentConstant; -import com.accompany.common.exception.BusinessException; -import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.StringUtils; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.service.base.BaseService; -import com.accompany.payment.agentchangestrategy.IAgentChangeStrategy; -import com.accompany.payment.alipay.AlipayNotifyParam; -import com.accompany.payment.config.AliPayConfig; -import com.accompany.payment.config.BaseAliPayConfig; -import com.accompany.payment.config.BaseWxPayConfig; -import com.accompany.payment.config.WxPayConfig; -import com.accompany.payment.dto.AlipayAgentDTO; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.wxpay.WeChatNotifyParam; -import com.accompany.payment.wxpay.WeChatPayUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.alipay.api.AlipayApiException; -import com.alipay.api.internal.util.AlipaySignature; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -@Service -public class ChargeNotifyService extends BaseService { - - @Autowired - private ChargeRecordService chargeRecordService; - @Autowired - @Qualifier("alipayNativeAgentChangeStrategy") - private IAgentChangeStrategy alipayNativeAgentChangeStrategy; - - - /** - * 将支付宝的请求参数设置转换为Map结构 - * - * @param request - * @return - */ - public Map convertRequetsToMap(HttpServletRequest request) { - Map retMap = new HashMap(); - logger.info("request parameter = {}", JSON.toJSONString(request.getParameterMap())); - - 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 originalParams - * @param alipayNotifyParam - * @param aliPayConfig - * @throws AlipayApiException - */ - public ChargeRecord checkAliPayParams(Map originalParams, AlipayNotifyParam alipayNotifyParam, BaseAliPayConfig aliPayConfig) throws AlipayApiException { - String outTradeNo = alipayNotifyParam.getOut_trade_no(); - - // 1、商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号, - ChargeRecord chargeRecord = chargeRecordService.getChargeRecordById(outTradeNo); - if (chargeRecord == null) { - throw new BusinessException("充值记录不存在"); - } - - String appId = null; - String publicKey = null; - if (StringUtils.isBlank(chargeRecord.getAgentConfId())) { - appId = aliPayConfig.getAppId(); - publicKey = aliPayConfig.getPublicKey(); - } else { - logger.info("订单 {} 使用的支付使用的商户配置id为:{}", outTradeNo, chargeRecord.getAgentConfId()); - Object payAgent = alipayNativeAgentChangeStrategy.getPayAgentByConfId(chargeRecord.getAgentConfId()); - if (payAgent == null || !(payAgent instanceof AlipayAgentDTO)) { - logger.error("商户配置不正确,AgentConfId={}", chargeRecord.getAgentConfId()); - throw new BusinessException("商户配置不正确,不能处理回调"); - } - - AlipayAgentDTO alipayAgent = (AlipayAgentDTO) payAgent; - appId = alipayAgent.getAppId(); - publicKey = alipayAgent.getPublicKey(); - } - - logger.info("订单 {} 使用的支付商户为:{}", outTradeNo, appId); - - //校验签名 - boolean flag = AlipaySignature.rsaCheckV1(originalParams, publicKey, "utf-8", "RSA2"); - if (!flag) { - //验证失败 - logger.error("支付宝回调签名验证失败,param={}", JSON.toJSONString(originalParams)); - throw new BusinessException("支付宝回调签名验证失败"); - } - logger.info("支付宝回调签名验证成功,param={}", JSON.toJSONString(originalParams)); - - if (chargeRecord.getChargeStatus().equals(PaymentConstant.ChargeStatus.PAIED)) { - logger.error("订单已到账,不能重复处理: chargeRecord={}", JSONObject.toJSONString(chargeRecord)); - throw new ServiceException(BusiStatus.DUPLICATE_TRANSFER_REQUEST); - } - - // 2、判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额), - long total_amount = alipayNotifyParam.getTotal_amount().multiply(new BigDecimal(100)).longValue(); - if (total_amount != chargeRecord.getAmount().longValue()) { - throw new AlipayApiException("error total_amount"); - } - - // 3、校验通知中的seller_id(或者seller_email)是否为out_trade_no这笔单据的对应的操作方(有的时候,一个商户可能有多个seller_id/seller_email), - // 第三步可根据实际情况省略 - - // 4、验证app_id是否为该商户本身。 - if (!appId.equals(alipayNotifyParam.getApp_id())) { - throw new AlipayApiException("app_id不一致"); - } - - return chargeRecord; - } - - public String verifyWxRequestParams(Map map, WeChatNotifyParam weChatNotifyParam, BaseWxPayConfig wxPayConfig) { - // 校验签名 - if (!verifyWxSign(map, wxPayConfig)) { - logger.error("签名失败,request params={}", weChatNotifyParam); - return "签名失败"; - } - - // 验证app_id是否为该商户本身。 - if (!wxPayConfig.getAppId().equals(weChatNotifyParam.getAppid())) { - logger.error("app_id不一致,request params={}", weChatNotifyParam); - return "app_id不一致"; - } - - if (!wxPayConfig.getMchId().equals(weChatNotifyParam.getMch_id())) { - logger.error("mch_id不一致,request params={}", weChatNotifyParam); - return "mch_id不一致"; - } - - return null; - } - - /** - * 支付宝通知结果 - * - * @param params - * @return - */ - public AlipayNotifyParam buildAlipayNotifyParam(Map params) { - String json = JSONObject.toJSONString(params); - return JSONObject.parseObject(json, AlipayNotifyParam.class); - } - - public WeChatNotifyParam buildWeChatNotifyParam(Map params) { - String json = JSONObject.toJSONString(params); - return JSONObject.parseObject(json, WeChatNotifyParam.class); - } - - public void writeWxResponse(HttpServletResponse response, String returnCode, String returnMessage) throws IOException { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(""); - buffer.append(""); - buffer.append(""); - - response.setContentType("text/xml"); - response.getWriter().print(buffer.toString()); - response.getWriter().flush(); - response.getWriter().close(); - } - - /** - * 校验微信签名 - * - * @param requestMap - * @return - */ - public Boolean verifyWxSign(Map requestMap, BaseWxPayConfig wxPayConfig) { - logger.info("=====微信回调返回数据:" + JSONObject.toJSONString(requestMap)); - - String requestSign = (String) requestMap.get("sign"); - logger.info("传入的签名:" + requestSign); - - requestMap.remove("sign"); - String sign = WeChatPayUtil.getWeChatSign(requestMap, wxPayConfig); - logger.info("校验的签名:" + sign); - - return sign.equals(requestSign); - } -} \ No newline at end of file diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/service/PayCenterService.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/service/PayCenterService.java index d7d5487be..9a9287d4c 100644 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/service/PayCenterService.java +++ b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/service/PayCenterService.java @@ -5,7 +5,6 @@ import com.accompany.common.device.DeviceInfo; import com.accompany.common.exception.ApiException; import com.accompany.common.redis.RedisKey; import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.BeanUtil; import com.accompany.common.utils.EnvComponent; import com.accompany.common.utils.UUIDUitl; import com.accompany.core.enumeration.BusinessStatusCodeEnum; @@ -13,13 +12,7 @@ import com.accompany.core.exception.ServiceException; import com.accompany.core.service.SysConfService; import com.accompany.core.service.common.JedisService; import com.accompany.core.vo.BaseResponseVO; -import com.accompany.payment.alipay.AlipayService; -import com.accompany.payment.alipay.YinyouAlipayService; -import com.accompany.payment.config.AliPayConfig; -import com.accompany.payment.config.BaseWxPayConfig; import com.accompany.payment.constant.CurrencyTypeEnum; -import com.accompany.payment.constant.PayConstant; -import com.accompany.payment.dto.AlipayAgentDTO; import com.accompany.payment.event.ChargeEvent; import com.accompany.payment.model.ChargeProd; import com.accompany.payment.model.ChargeRecord; @@ -29,15 +22,7 @@ import com.accompany.payment.strategy.PayContext; import com.accompany.payment.strategy.PayStrategy; import com.accompany.payment.strategy.factory.PayStrategyFactory; import com.accompany.payment.vo.TarotChargeRetVo; -import com.accompany.payment.wxpay.*; import com.alibaba.fastjson.JSON; -import com.alipay.api.AlipayApiException; -import com.alipay.api.AlipayClient; -import com.alipay.api.DefaultAlipayClient; -import com.alipay.api.request.AlipayTradeAppPayRequest; -import com.alipay.api.request.AlipayTradeWapPayRequest; -import com.alipay.api.response.AlipayTradeAppPayResponse; -import com.alipay.api.response.AlipayTradeWapPayResponse; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -48,7 +33,6 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.Calendar; -import java.util.Map; /** * @author yangming @@ -59,10 +43,6 @@ import java.util.Map; @Slf4j @Transactional(rollbackFor = Exception.class) public class PayCenterService { - @Autowired - private WeChatPayService weChatPayService; - @Autowired - private AlipayService alipayService; @Autowired private ChargeRecordService chargeRecordService; @Autowired @@ -74,10 +54,6 @@ public class PayCenterService { @Autowired private SysConfService sysConfService; @Autowired - private YinyouAlipayService yinyouAlipayService; - @Autowired - private AliPayConfig aliPayConfig; - @Autowired private JedisService jedisService; @Autowired private ApplicationContext applicationContext; @@ -136,104 +112,6 @@ public class PayCenterService { return channel; } - /** - * 支付宝APP支付统一下单接口 - * - * @param amount - * @param orderNo - * @param subject - * @param body - * @return - */ - public AlipayTradeAppPayResponse createAliAppOrder( - Long amount, String orderNo, String subject, String body, String realName, String idCardNum) throws Exception { - - log.info("crateAliPayOrder(),orderNo={}", orderNo); - // 实例化客户端 - AlipayClient client = alipayService.getAlipayClientInstance(); - // 实例化请求参数 - AlipayTradeAppPayRequest request = - alipayService.buildAliAppRequest(amount, orderNo, subject, body, realName, idCardNum); - // 调用接口 - AlipayTradeAppPayResponse response = client.sdkExecute(request); - - return response; - } - - public AlipayTradeAppPayResponse createYinyouAliAppOrder(Long amount, String orderNo, String subject, String body, String realName, String idCardNum) throws AlipayApiException { - log.info("crateYinyouAliPayOrder(),orderNo={}", orderNo); - // 实例化客户端 - AlipayClient client = yinyouAlipayService.getAlipayClientInstance(); - // 实例化请求参数 - AlipayTradeAppPayRequest request = - yinyouAlipayService.buildAliAppRequest(amount, orderNo, subject, body, realName, idCardNum); - // 调用接口 - AlipayTradeAppPayResponse response = client.sdkExecute(request); - - return response; - } - - /** - * 支付宝网页支付统一下单接口 - * - * @param amount - * @param orderNo - * @param subject - * @param body - * @param successUrl - * @return - * @throws Exception - */ - public AlipayTradeWapPayResponse createAliWapOrder( - Long amount, String orderNo, String subject, String body, String successUrl, String realName, String idCardNum) - throws Exception { - log.info("createAliWebOrder(),orderNo={}", orderNo); - AlipayClient client = alipayService.getAlipayClientInstance(); - // 实例化请求参数 - AlipayTradeWapPayRequest request = - alipayService.buildAliWapRequest(amount, orderNo, subject, body, successUrl, realName, idCardNum); - // 调用接口 - AlipayTradeWapPayResponse response = client.pageExecute(request); - - return response; - } - - /** - * 微信统一下单接口 - * - * @param amount - * @param orderNo - * @param subject - * @param body - * @param clientIp - * @param successUrl - * @return - */ - public WeChatResultParam createWeChatOrder(BaseWxPayConfig wxPayConfig, - Long amount, - String orderNo, - String subject, - String body, - String channel, - String clientIp, - String successUrl) - throws Exception { - - log.info("crateWeChatOrder(),orderNo={}", orderNo); - // 构建请求参数 - Map requestMap = - weChatPayService.buildWxRequestMap(wxPayConfig, amount, orderNo, subject, body, channel, clientIp); - // 转化为XML格式 - String requestXML = WeChatPayUtil.getRequestXml(requestMap); - // 调用统一下单接口 - String result = weChatPayService.createOrder(wxPayConfig, requestXML); - // 将返回结果解析为Map - Map resultMap = XMLParser.getMapFromXML(result); - // 将Map转化为对象 - WeChatResultParam weChatResultParam = weChatPayService.convertToObject(resultMap); - return weChatResultParam; - } - public ChargeRecord buildChargeRecord(Byte type, Long uid, ChargeProd chargeProd, String channel, String clientIp, DeviceInfo deviceInfo, String openId, String paymentType, String countryCode){ String chargeRecordId = UUIDUitl.get(); @@ -289,27 +167,6 @@ public class PayCenterService { return payContext; } - /** - * 微信订单查询接口 - * @param orderNo - * @return - */ - public WeChatQueryResultParam queryWeChatOrder(BaseWxPayConfig wxPayConfig, String orderNo) throws Exception { - log.info("queryWeChatOrder(),orderNo={}",orderNo); - //构建请求参数 - Map requestMap = weChatPayService.buildWxQueryRequestMap(wxPayConfig, orderNo); - //转化为XML格式 - String requestXML = WeChatPayUtil.getRequestXml(requestMap); - log.info("微信订单查询,请求参数:{}", requestXML); - //调用统一下单接口 - String result = weChatPayService.queryOrder(requestXML); - log.info("微信订单查询,响应参数:{}", result); - //将返回结果解析为Map - Map resultMap = XMLParser.getMapFromXML(result); - //将Map转化为对象 - return BeanUtil.mapToObject(resultMap, WeChatQueryResultParam.class); - } - /** * 幸运塔罗充值的接口 * @param uid @@ -447,33 +304,4 @@ public class PayCenterService { } return chargeRecord; } - - public AlipayTradeAppPayResponse createAliAppOrder(AlipayAgentDTO agent, Long amount, String orderNo, String subject, String body, String realName, String idCardNum) throws Exception { - String appId = aliPayConfig.getAppId(); - String privateKey = aliPayConfig.getAppPrivateKey(); - String publicKey = aliPayConfig.getPublicKey(); - if (agent != null) { - appId = agent.getAppId(); - privateKey = agent.getAppPrivateKey(); - publicKey = agent.getPublicKey(); - } - log.info("crateAliPayOrder(),agent = {},orderNo={}", appId, orderNo); - // 实例化客户端 - AlipayClient client = - new DefaultAlipayClient( - aliPayConfig.getUrl(), - appId, - privateKey, - PayConstant.ALIPAY_FORMAT, - PayConstant.ALIPAY_CHATSET, - publicKey, - PayConstant.ALIPAY_SIGN_TYPE); - // 实例化请求参数 - AlipayTradeAppPayRequest request = - alipayService.buildAliAppRequest(amount, orderNo, subject, body, realName, idCardNum); - // 调用接口 - AlipayTradeAppPayResponse response = client.sdkExecute(request); - - return response; - } } diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/AlipayStrategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/AlipayStrategy.java deleted file mode 100644 index 2f7b4ffeb..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/AlipayStrategy.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.accompany.payment.strategy; - -import com.accompany.common.constant.AppEnum; -import com.accompany.common.constant.Constant; -import com.accompany.common.device.DeviceInfo; -import com.accompany.common.utils.DateTimeUtil; -import com.accompany.common.utils.RandomUtil; -import com.accompany.common.utils.StringUtils; -import com.accompany.core.service.SysConfService; -import com.accompany.payment.agentchangestrategy.IAgentChangeStrategy; -import com.accompany.payment.annotation.PayChannelSupport; -import com.accompany.payment.dto.AlipayAgentDTO; -import com.accompany.payment.dto.PayAgentConfDTO; -import com.accompany.payment.guotongpay.GuotongPayConstant; -import com.accompany.payment.guotongpay.GuotongPayService; -import com.accompany.payment.guotongpay.bo.GuotongPayResultBO; -import com.accompany.payment.guotongpay.params.GuoTongCreateOrderReqParams; -import com.accompany.payment.model.ChargeProd; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.params.AgentChangeDimensions; -import com.accompany.payment.service.PayCenterService; -import com.alibaba.fastjson.JSONObject; -import com.alipay.api.response.AlipayTradeAppPayResponse; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.util.Date; - -/** - * @Author: chucheng - * @Date: 2019/4/29 17:09 - * @Description: - */ -@Service -@PayChannelSupport(Constant.ChargeChannel.alipay) -@Slf4j -public class AlipayStrategy extends AbstractPayStrategy { - @Autowired - private PayCenterService payCenterService; - @Autowired - private SysConfService sysConfService; - @Autowired - private GuotongPayService guotongPayService; - @Autowired - @Qualifier("alipayNativeAgentChangeStrategy") - private IAgentChangeStrategy alipayNativeAgentChangeStrategy; - - private static final String APP = "APP"; - - private static final String GUOTONG = "GUOTONG"; - - @Override - public Object pay(PayContext context) throws Exception { - - String payType = sysConfService.getDefaultSysConfValueById(Constant.SysConfId.ALI_PAY_INNER_TYPE, APP); - - log.info("app支付宝当前使用的渠道:{}", payType); - - ChargeProd chargeProd = context.getChargeProd(); - ChargeRecord chargeRecord = context.getChargeRecord(); - DeviceInfo deviceInfo = context.getDeviceInfo(); - log.info("用户设备信息: {}", JSONObject.toJSONString(deviceInfo)); - if (payType.equalsIgnoreCase(GUOTONG)) { - GuoTongCreateOrderReqParams params = new GuoTongCreateOrderReqParams(); - params.setPayMoney(new BigDecimal(chargeProd.getMoney())); - params.setLowOrderId(chargeRecord.getChargeRecordId()); - params.setBody(chargeProd.getProdName()); - params.setPayType(GuotongPayConstant.PAY_TYPE_ZFB); - GuotongPayResultBO result = guotongPayService.createOrder(params); - - return new StringBuilder("alipays://platformapi/startapp?saId=10000007&clientVersion=3.7.0.0718&qrcode=").append(result.getCodeUrl()).toString(); - } else { - //支付宝APP支付,支付单位是元 - String realName = context.getRealName(); - String idCardNum = context.getIdCardNum(); - AlipayTradeAppPayResponse response = null; -// if (isYinyouApp(deviceInfo)) { -// response = payCenterService.createYinyouAliAppOrder(chargeProd.getMoney(), -// chargeRecord.getChargeRecordId(), -// chargeRecord.getSubject(), -// chargeRecord.getBody(), -// realName, -// idCardNum); -// } else { -// response = payCenterService.createAliAppOrder(chargeProd.getMoney(), -// chargeRecord.getChargeRecordId(), -// chargeRecord.getSubject(), -// chargeRecord.getBody(), -// realName, -// idCardNum); - -// } - - AgentChangeDimensions dimensions = new AgentChangeDimensions(); - dimensions.setUid(chargeRecord.getUid()); - PayAgentConfDTO payAgentConfig = alipayNativeAgentChangeStrategy.getPayAgentConfig(dimensions); - AlipayAgentDTO agent = null; - String agentConfigId = null; - if (payAgentConfig != null) { - agentConfigId = payAgentConfig.getConfigId(); - if (payAgentConfig.getPayAgent() != null && payAgentConfig.getPayAgent() instanceof AlipayAgentDTO) { - agent = (AlipayAgentDTO) payAgentConfig.getPayAgent(); - } - } - response = payCenterService.createAliAppOrder(agent, chargeProd.getMoney(), - chargeRecord.getChargeRecordId(), - chargeRecord.getSubject(), - chargeRecord.getBody(), - realName, - idCardNum); - chargeRecord.setAgentConfId(agentConfigId); - if (agent != null) { - chargeRecord.setAgentId(agent.getAppId()); - } - - return response.getBody(); - } - } - - /** - * 判断是否平台app - * @param deviceInfo - * @return - */ - private boolean isYinyouApp(DeviceInfo deviceInfo) { - if (deviceInfo == null || StringUtils.isBlank(deviceInfo.getApp())) { - return false; - } - - if (deviceInfo.getApp().equalsIgnoreCase(AppEnum.yinyou.getValue()) || deviceInfo.getApp().equalsIgnoreCase(AppEnum.yinyouEnterprise.getValue())) { - return true; - } - - return false; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/AlipayV2Strategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/AlipayV2Strategy.java deleted file mode 100644 index d0842d248..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/AlipayV2Strategy.java +++ /dev/null @@ -1,170 +0,0 @@ -package com.accompany.payment.strategy; - -import com.accompany.common.constant.Constant; -import com.accompany.common.utils.DateTimeUtil; -import com.accompany.common.utils.StringUtils; -import com.accompany.core.service.SysConfService; -import com.accompany.payment.agentchangestrategy.AlipayNativeAgentChangeStrategy; -import com.accompany.payment.agentchangestrategy.IAgentChangeStrategy; -import com.accompany.payment.annotation.PayChannelSupport; -import com.accompany.payment.constant.PayConstant; -import com.accompany.payment.dto.AlipayAgentDTO; -import com.accompany.payment.dto.PayAgentConfDTO; -import com.accompany.payment.fufeitong.FufeitongConstant; -import com.accompany.payment.fufeitong.FufeitongPayService; -import com.accompany.payment.fufeitong.bo.FufeitongBaseRes; -import com.accompany.payment.fufeitong.params.FufeitongCreateOrderBaseReqParams; -import com.accompany.payment.guotongpay.GuotongPayConstant; -import com.accompany.payment.guotongpay.GuotongPayService; -import com.accompany.payment.guotongpay.bo.GuotongPayResultBO; -import com.accompany.payment.guotongpay.params.GuoTongCreateOrderReqParams; -import com.accompany.payment.model.ChargeProd; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.params.AgentChangeDimensions; -import com.accompany.payment.sandpay.SandPayRequestParam; -import com.accompany.payment.sandpay.SandPayService; -import com.accompany.payment.service.PayCenterService; -import com.accompany.payment.vo.AlipayResult; -import com.accompany.payment.wanxiang.WanXiangPayConfig; -import com.accompany.payment.wanxiang.WanXiangPayService; -import com.accompany.payment.wanxiang.bo.WanXiangBaseRes; -import com.accompany.payment.wanxiang.params.WanXiangCreateOrderBaseReqParams; -import com.alipay.api.response.AlipayTradeAppPayResponse; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.net.URLEncoder; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import static com.accompany.payment.constant.PayConstant.HUNDRED; - -/** - * @Date: 2021年02月27日 - * @Description: v2版app内支付宝支付策略 - */ -@Service -@PayChannelSupport(Constant.ChargeChannel.alipay_v2) -@Slf4j -public class AlipayV2Strategy extends AbstractPayStrategy { - @Autowired - private PayCenterService payCenterService; - @Autowired - private SysConfService sysConfService; - @Autowired - private SandPayService sandPayService; - @Autowired - private FufeitongPayService fufeitongPayService; - @Autowired - @Qualifier("alipayNativeAgentChangeStrategy") - private IAgentChangeStrategy alipayNativeAgentChangeStrategy; - @Autowired - private WanXiangPayService wanXiangPayService; - @Autowired - private WanXiangPayConfig wanXiangPayConfig; - - private static final String APP = "APP"; - - private static final String SAND_PAY = "SAND_PAY"; - - private static final String FU_FEI_TONG = "FU_FEI_TONG"; - - private static final String WAN_XIANG = "WANG_XIANG"; - - private static final String PAY_TYPE_NATIVE = "native"; - - private static final String PAY_TYPE_H5 = "h5"; - - @Override - public Object pay(PayContext context) throws Exception { - - String payType = sysConfService.getDefaultSysConfValueById(Constant.SysConfId.ALI_PAY_V2_INNER_TYPE, APP); - - log.info("app支付宝当前使用的渠道:{}", payType); - - ChargeProd chargeProd = context.getChargeProd(); - ChargeRecord chargeRecord = context.getChargeRecord(); - AlipayResult result = new AlipayResult(); - if (payType.equalsIgnoreCase(SAND_PAY)) { - SandPayRequestParam params = new SandPayRequestParam(); - params.setAgentBillId(chargeRecord.getChargeRecordId()); - params.setPayAmt(new BigDecimal(chargeRecord.getAmount().toString()).divide(HUNDRED, 2, BigDecimal.ROUND_HALF_UP)); - params.setReturnUrl(context.getSuccessUrl()); - params.setUserIp(chargeRecord.getClientIp()); - params.setAgentBillTime(DateTimeUtil.convertDate(new Date(), DateTimeUtil.DEFAULT_DATE_PATTERN__)); - params.setGoodsName(chargeRecord.getSubject()); - String url = sandPayService.payByAlipayForNative(params); - result.setOrderData(url); - result.setPayType(PAY_TYPE_H5); - - // 需要调整记录中的支付渠道为h5 - chargeRecord.setChannel(Constant.ChargeChannel.alipay_wap); - } else if (payType.equalsIgnoreCase(FU_FEI_TONG)) { - FufeitongCreateOrderBaseReqParams params = new FufeitongCreateOrderBaseReqParams(); - params.setAmount(new BigDecimal(chargeRecord.getAmount().toString()).divide(HUNDRED, 2, BigDecimal.ROUND_HALF_UP)); - params.setGoodsName(chargeRecord.getSubject()); - params.setTraceno(chargeRecord.getChargeRecordId()); - params.setPayType(FufeitongConstant.PAY_TYPE_ZFB); - - FufeitongBaseRes wapOrder = fufeitongPayService.createAlipayOrder(params); - - result.setOrderData(wapOrder.getBarCode()); - result.setPayType(PAY_TYPE_H5); - - // 需要调整记录中的支付渠道为h5 - chargeRecord.setChannel(Constant.ChargeChannel.alipay_wap); - } else if (payType.equalsIgnoreCase(WAN_XIANG)) { - WanXiangCreateOrderBaseReqParams params = new WanXiangCreateOrderBaseReqParams(); - params.setOrderNo(chargeRecord.getChargeRecordId()); - params.setSubject(chargeRecord.getSubject()); - params.setAmount(new BigDecimal(chargeRecord.getAmount().toString()).divide(HUNDRED, 2, BigDecimal.ROUND_HALF_UP)); - params.setReturnUrl(context.getSuccessUrl()); - params.setClientIp(chargeRecord.getClientIp()); - - WanXiangBaseRes alipayH5Order = wanXiangPayService.createAlipayH5Order(params); - String payUrl = alipayH5Order.getData(); - if (StringUtils.isNotBlank(wanXiangPayConfig.getToAlipayH5Url()) && payUrl.startsWith("alipay")) { - payUrl = wanXiangPayConfig.getToAlipayH5Url() + URLEncoder.encode(payUrl, "UTF-8"); - } - - result.setOrderData(payUrl); - result.setPayType(PAY_TYPE_H5); - - // 需要调整记录中的支付渠道为h5 - chargeRecord.setChannel(Constant.ChargeChannel.alipay_wap); - } else { - //支付宝APP支付,支付单位是元 - String realName = context.getRealName(); - String idCardNum = context.getIdCardNum(); - AgentChangeDimensions dimensions = new AgentChangeDimensions(); - dimensions.setUid(chargeRecord.getUid()); - PayAgentConfDTO payAgentConfig = alipayNativeAgentChangeStrategy.getPayAgentConfig(dimensions); - AlipayAgentDTO agent = null; - String agentConfigId = null; - if (payAgentConfig != null) { - agentConfigId = payAgentConfig.getConfigId(); - if (payAgentConfig.getPayAgent() != null && payAgentConfig.getPayAgent() instanceof AlipayAgentDTO) { - agent = (AlipayAgentDTO) payAgentConfig.getPayAgent(); - } - } - AlipayTradeAppPayResponse response = payCenterService.createAliAppOrder(agent, chargeProd.getMoney(), - chargeRecord.getChargeRecordId(), - chargeRecord.getSubject(), - chargeRecord.getBody(), - realName, - idCardNum); - chargeRecord.setAgentConfId(agentConfigId); - if (agent != null) { - chargeRecord.setAgentId(agent.getAppId()); - } - result.setOrderData(response.getBody()); - result.setPayType(PAY_TYPE_NATIVE); - } - - return result; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/AlipayWapStrategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/AlipayWapStrategy.java deleted file mode 100644 index 57b0edbbf..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/AlipayWapStrategy.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.accompany.payment.strategy; - -import com.accompany.common.constant.Constant; -import com.accompany.common.utils.DateTimeUtil; -import com.accompany.core.service.SysConfService; -import com.accompany.payment.annotation.PayChannelSupport; -import com.accompany.payment.constant.PayConstant; -import com.accompany.payment.fufeitong.FufeitongConstant; -import com.accompany.payment.fufeitong.FufeitongPayService; -import com.accompany.payment.fufeitong.bo.FufeitongBaseRes; -import com.accompany.payment.fufeitong.params.FufeitongCreateOrderBaseReqParams; -import com.accompany.payment.model.ChargeProd; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.sandpay.SandPayRequestParam; -import com.accompany.payment.sandpay.SandPayService; -import com.accompany.payment.service.PayCenterService; -import com.accompany.payment.wanxiang.WanXiangPayService; -import com.accompany.payment.wanxiang.bo.WanXiangBaseRes; -import com.accompany.payment.wanxiang.params.WanXiangCreateOrderBaseReqParams; -import com.alipay.api.response.AlipayTradeWapPayResponse; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import static com.accompany.common.constant.Constant.SysConfId.ALIPAY_H5_PAY_THIRD; -import static com.accompany.payment.constant.PayConstant.HUNDRED; - -/** - * @Author: chucheng - * @Date: 2019/4/29 17:09 - * @Description: - */ -@Service -@PayChannelSupport(Constant.ChargeChannel.alipay_wap) -@Slf4j -public class AlipayWapStrategy extends AbstractPayStrategy { - - @Autowired - private PayCenterService payCenterService; - @Autowired - private SandPayService sandPayService; - @Autowired - private FufeitongPayService fufeitongPayService; - @Autowired - private SysConfService sysConfService; - @Autowired - private WanXiangPayService wanXiangPayService; - - /** 付费通h5 */ - private static final String FU_FEI_TONG = "FU_FEI_TONG"; - /** - * 万象支付 - */ - private static final String WAN_XIANG = "WANG_XIANG"; - - @Override - public Object pay(PayContext context) throws Exception { - String realPayChannel = sysConfService.getSysConfValueById(ALIPAY_H5_PAY_THIRD); - log.info("当前开启的支付宝h5渠道方是 {}", realPayChannel); - - if (FU_FEI_TONG.equals(realPayChannel)) { - return fufeitongPay(context); - } else if (WAN_XIANG.equalsIgnoreCase(realPayChannel)) { - return wanxiangPay(context); - } else { - // 默认杉德支付宝H5支付 - return sandPay(context); - } - } - - private Object wanxiangPay(PayContext context) { - ChargeRecord chargeRecord = context.getChargeRecord(); - - WanXiangCreateOrderBaseReqParams params = new WanXiangCreateOrderBaseReqParams(); - params.setOrderNo(chargeRecord.getChargeRecordId()); - params.setSubject(chargeRecord.getSubject()); - params.setAmount(new BigDecimal(chargeRecord.getAmount().toString()).divide(HUNDRED, 2, BigDecimal.ROUND_HALF_UP)); - params.setReturnUrl(context.getSuccessUrl()); - params.setClientIp(chargeRecord.getClientIp()); - - WanXiangBaseRes alipayH5Order = wanXiangPayService.createAlipayH5Order(params); - - Map appMap = new HashMap<>(); - appMap.put(PayConstant.H5_PAY_URL_FIELD, alipayH5Order.getData()); - - return appMap; - } - - private Object fufeitongPay(PayContext context) { - ChargeRecord chargeRecord = context.getChargeRecord(); - - Map appMap = new HashMap<>(); - - FufeitongCreateOrderBaseReqParams params = new FufeitongCreateOrderBaseReqParams(); - params.setAmount(new BigDecimal(chargeRecord.getAmount().toString()).divide(HUNDRED, 2, BigDecimal.ROUND_HALF_UP)); - params.setGoodsName(chargeRecord.getSubject()); - params.setTraceno(chargeRecord.getChargeRecordId()); - params.setPayType(FufeitongConstant.PAY_TYPE_ZFB); - - FufeitongBaseRes wapOrder = fufeitongPayService.createAlipayOrder(params); - appMap.put(PayConstant.H5_PAY_URL_FIELD, wapOrder.getBarCode()); - - return appMap; - } - - /** - * 官方支付宝H5支付 - */ - public Object officialPay(PayContext context) throws Exception { - //支付宝网页支付,支付单位是元 - ChargeProd chargeProd = context.getChargeProd(); - ChargeRecord chargeRecord = context.getChargeRecord(); - String realName = context.getRealName(); - String idCardNum = context.getIdCardNum(); - AlipayTradeWapPayResponse response = payCenterService.createAliWapOrder(chargeProd.getMoney(), - chargeRecord.getChargeRecordId(), - chargeRecord.getSubject(), - chargeRecord.getBody(), - context.getSuccessUrl(), - realName, - idCardNum); - return response.getBody(); - } - - /** - * 杉德支付宝H5支付 - */ - public Object sandPay(PayContext context) { - ChargeRecord chargeRecord = context.getChargeRecord(); - SandPayRequestParam params = new SandPayRequestParam(); - params.setAgentBillId(chargeRecord.getChargeRecordId()); - params.setPayAmt(new BigDecimal(chargeRecord.getAmount().toString()).divide(HUNDRED, 2, BigDecimal.ROUND_HALF_UP)); - params.setReturnUrl(context.getSuccessUrl()); - params.setUserIp(chargeRecord.getClientIp()); - params.setAgentBillTime(DateTimeUtil.convertDate(new Date(), DateTimeUtil.DEFAULT_DATE_PATTERN__)); - params.setGoodsName(chargeRecord.getSubject()); - return sandPayService.payByAlipayInH5(params); - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/LuckyTarotPayStrategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/LuckyTarotPayStrategy.java deleted file mode 100644 index 37c1d5b7b..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/LuckyTarotPayStrategy.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.accompany.payment.strategy; - -import com.accompany.common.constant.AppEnum; -import com.accompany.common.constant.Constant; -import com.accompany.common.device.DeviceInfo; -import com.accompany.common.exception.BusinessException; -import com.accompany.common.utils.StringUtils; -import com.accompany.payment.annotation.PayChannelSupport; -import com.accompany.payment.config.BaseWxPayConfig; -import com.accompany.payment.config.WxPayConfig; -import com.accompany.payment.config.YinyouWxPayConfig; -import com.accompany.payment.constant.PayConstant; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.service.PayCenterService; -import com.accompany.payment.wxpay.WeChatPayService; -import com.accompany.payment.wxpay.WeChatResultParam; -import com.alibaba.fastjson.JSONObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.net.URLEncoder; -import java.util.Map; - -/** - * @Author: yangming - * @Date: 2019/11/4 18:49 - * @Description: 幸运塔罗充值 - **/ -@Service -@PayChannelSupport(Constant.ChargeChannel.lucky_tarot) -public class LuckyTarotPayStrategy extends AbstractPayStrategy{ - @Autowired - private PayCenterService payCenterService; - @Autowired - private WeChatPayService weChatPayService; - @Autowired - private WxPayConfig wxPayConfig; - @Autowired - private YinyouWxPayConfig yinyouWxPayConfig; - - - @Override - public Object pay(PayContext context) throws Exception { - ChargeRecord chargeRecord = context.getChargeRecord(); - String clientIp = chargeRecord.getClientIp(); - Map appMap = null; - DeviceInfo deviceInfo = context.getDeviceInfo(); - - BaseWxPayConfig usingWxPayConfig = wxPayConfig; - if (isYinyouApp(deviceInfo)) { - usingWxPayConfig = yinyouWxPayConfig; - } - - WeChatResultParam weChatResultParam = payCenterService.createWeChatOrder(usingWxPayConfig, chargeRecord.getAmount(), - chargeRecord.getChargeRecordId(), - chargeRecord.getSubject(), - chargeRecord.getBody(), - Constant.ChargeChannel.wx_wap, - clientIp, - context.getSuccessUrl()); - if (!PayConstant.WeChatTradeStatus.TRADE_SUCCESS.equals(weChatResultParam.getReturnCode())) { - throw new BusinessException(weChatResultParam.getReturmMsg()); - } - appMap = weChatPayService.buildAppParamMap(usingWxPayConfig, weChatResultParam.getPrepayId(), weChatResultParam.getNonceStr()); - StringBuilder payUrl = new StringBuilder(weChatResultParam.getMwebUrl()).append("&redirect_url=").append(URLEncoder.encode(context.getSuccessUrl(), "UTF-8")); - appMap.put(PayConstant.H5_PAY_URL_FIELD, payUrl.toString()); - appMap.put(PayConstant.H5_PAY_NICK_FIELD, context.getNick()); - appMap.put(PayConstant.H5_PAY_ERBANNO_FIELD, context.getErbanNo()); - return JSONObject.toJSON(appMap); - } - - /** - * 判断是否平台app - * @param deviceInfo - * @return - */ - private boolean isYinyouApp(DeviceInfo deviceInfo) { - if (deviceInfo == null || StringUtils.isBlank(deviceInfo.getApp())) { - return false; - } - - if (deviceInfo.getApp().equalsIgnoreCase(AppEnum.yinyou.getValue()) || deviceInfo.getApp().equalsIgnoreCase(AppEnum.yinyouEnterprise.getValue())) { - return true; - } - - return false; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxJoinpayStrategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxJoinpayStrategy.java deleted file mode 100644 index 90eab1657..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxJoinpayStrategy.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.accompany.payment.strategy; - -import com.accompany.common.constant.Constant; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.service.SysConfService; -import com.accompany.payment.annotation.PayChannelSupport; -import com.accompany.payment.joinpay.JoinpayService; -import com.accompany.payment.model.ChargeRecord; -import com.alibaba.fastjson.JSONObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Map; - -/** - * @Author: chucheng - * @Date: 2019/4/29 17:09 - * @Description:微信汇聚支付 - */ -@Service -@PayChannelSupport(Constant.ChargeChannel.wx_joinpay) -public class WxJoinpayStrategy extends AbstractPayStrategy { - @Autowired - private JoinpayService joinpayService; - @Autowired - private SysConfService sysConfService; - - @Override - public Object pay(PayContext context) throws Exception { - ChargeRecord chargeRecord = context.getChargeRecord(); - Map requestParams = this.joinpayService.applyTradeAndReturnRequestParams( - chargeRecord.getChargeRecordId(), - chargeRecord.getAmount(), - chargeRecord.getSubject()); - //汇聚支付失败, - if (requestParams.isEmpty()) { - throw new ServiceException("汇聚支付失败"); - } - String thirdOrderNo = (String) requestParams.get("orderno"); - chargeRecord.setPingxxChargeId(thirdOrderNo); - return JSONObject.toJSON(requestParams); - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxMicroMallPubPayStrategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxMicroMallPubPayStrategy.java deleted file mode 100644 index 3608c171b..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxMicroMallPubPayStrategy.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.accompany.payment.strategy; - -import com.accompany.common.constant.Constant; -import com.accompany.core.exception.ServiceException; -import com.accompany.payment.annotation.PayChannelSupport; -import com.accompany.payment.config.WxMicroMallConfig; -import com.accompany.payment.model.ChargeProd; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.vo.JsapiReturnVo; -import com.accompany.payment.wxpay.HttpUtils; -import com.accompany.payment.wxpay.MD5; -import com.accompany.payment.wxpay.PayUtil; -import com.accompany.payment.wxpay.XMLParser; -import com.alibaba.fastjson.JSON; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -/** - * @Author: chucheng - * @Date: 2019/4/29 17:09 - * @Description: - * @see WxPubNativeStrategy - * @see WxPubJoinpayStrategy - */ -@Service -@PayChannelSupport(Constant.ChargeChannel.wx_micro_mall_pub) -@Slf4j -public class WxMicroMallPubPayStrategy extends AbstractPayStrategy { - private static final String UNIFIEDORDER_URL = "https://api.mch.weixin.qq.com/pay/unifiedorder"; - - @Override - public Object pay(PayContext context) throws Exception { - ChargeProd chargeProd = context.getChargeProd(); - ChargeRecord chargeRecord = context.getChargeRecord(); - String ip = chargeRecord.getClientIp(); - String openId = chargeRecord.getWxPubOpenid(); - Long uid = chargeRecord.getUid(); - Long erbanNo = context.getErbanNo(); - String nick = context.getNick(); - String nonce_str = PayUtil.getRandomStringByLength(16);//生成随机数,可直接用系统提供的方法 - String trade_type = "JSAPI"; - String outTradeNo = chargeRecord.getChargeRecordId(); - - Long amount = chargeProd.getMoney() * 100; - HashMap map = new HashMap(); - map.put("appid", WxMicroMallConfig.appId); - map.put("mch_id", WxMicroMallConfig.mchId); - map.put("device_info", "WEB"); - map.put("nonce_str", nonce_str); - map.put("body", "充值 " + amount / 10 + " 金币"); //订单标题(描述) - map.put("out_trade_no", outTradeNo); //订单ID - /* - 测试环境下,total_fee为money(分) - 正式环境为amount - */ - //TODO 正式环境为amount(测试环境下统统一分钱) - map.put("total_fee", String.valueOf(amount)); //订单需要支付的金额 - map.put("spbill_create_ip", ip); - map.put("trade_type", trade_type); - //TODO 添加回调地址 - map.put("notify_url", WxMicroMallConfig.returnUrl); //notify_url 支付成功之后 微信会进行异步回调的地址 - map.put("openid", openId); //trade_type=JSAPI时(即公众号支付),此参数必传,此参数为微信用户在商户对应appid下的唯一标识。 - String sign = PayUtil.getSignForMicroMall(map); - map.put("sign", sign); - String content = XMLParser.getXMLFromMap(map); - log.info("========统一接口发送内容:=======" + content); - //调用统一下单接口 - String postResult = HttpUtils.sendPost(UNIFIEDORDER_URL, content); - log.info("=========统一下单返回结果:=======" + postResult); - //=============解析返回的结果=======================// - Map cbMap = XMLParser.getMapFromXML(postResult); - //下单成功 - if (!(cbMap.get("return_code").equals("SUCCESS") && cbMap.get("result_code").equals("SUCCESS"))) { - log.error("=======uid:" + uid + "==========微信公众号下单失败================="+cbMap.toString()); - throw new ServiceException("微信公众号下单失败"); - } - //将订单记录转成Json发送给H5 - return buildReturnVo(nonce_str, cbMap.get("prepay_id") + "", "MD5", null, null, - String.valueOf(erbanNo), nick); - } - - private JsapiReturnVo buildReturnVo(String nonceStr, String prepayId, String signType, String paySign, String timestamp, - String erbanNo, String nick) { - JsapiReturnVo returnVo = new JsapiReturnVo(); - returnVo.setAppid(WxMicroMallConfig.appId); - returnVo.setSign_type(signType); - returnVo.setNonce_str(nonceStr); - returnVo.setPrepay_id("prepay_id=" + prepayId); - returnVo.setTimestamp(String.valueOf(System.currentTimeMillis() / 1000)); - String sign = getSign(returnVo); - returnVo.setSign(sign); - log.info("给H5的签名:{},签名方式:{},是否汇聚支付:{}", returnVo.getSign(), returnVo.getSign_type(), false); - - returnVo.setErban_no(erbanNo); - returnVo.setNick(nick); - returnVo.setMch_id(WxMicroMallConfig.mchId); - log.info("submitPay return :{}, isJoinPay: {}", JSON.toJSONString(returnVo), false); - return returnVo; - } - - private String getSign(JsapiReturnVo returnVo) { - - Map map = new HashMap(); - map.put("appId", returnVo.getAppid()); - map.put("nonceStr", returnVo.getNonce_str()); - map.put("package", returnVo.getPrepay_id()); - map.put("timeStamp", returnVo.getTimestamp()); - map.put("signType", returnVo.getSign_type()); - return getSignByMap(map); - } - - private static String getSignByMap(Map map) { - ArrayList list = new ArrayList(); - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue() != "" && !entry.toString().equals("return_code") && !entry.toString().equals("return_msg") && !entry.toString() - .equals("result_code")) { - list.add(entry.getKey() + "=" + entry.getValue() + "&"); - } - } - int size = list.size(); - String[] arrayToSort = list.toArray(new String[size]); - Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < size; i++) { - sb.append(arrayToSort[i]); - } - - String result = sb.toString(); - //key 该方法key的需要根据你当前公众号的key进行修改 - result += "key=" + WxMicroMallConfig.key; - log.info("=====================result========" + result); - result = MD5.MD5Encode(result).toUpperCase(); - log.info("=====================result after MD5========" + result); - return result; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxMiniAppPayStrategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxMiniAppPayStrategy.java deleted file mode 100644 index 7d9d0b1d1..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxMiniAppPayStrategy.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.accompany.payment.strategy; - -import com.accompany.common.constant.Constant; -import com.accompany.common.utils.DateTimeUtil; -import com.accompany.core.service.SysConfService; -import com.accompany.payment.annotation.PayChannelSupport; -import com.accompany.payment.config.SandPayConfig; -import com.accompany.payment.fufeitong.FufeitongConstant; -import com.accompany.payment.fufeitong.FufeitongPayService; -import com.accompany.payment.fufeitong.bo.FufeitongWxOpenOrderRes; -import com.accompany.payment.fufeitong.params.FufeitongWxOrderReqParams; -import com.accompany.payment.guotongpay.GuotongPayService; -import com.accompany.payment.guotongpay.bo.GuotongWxMiniPayResultBO; -import com.accompany.payment.guotongpay.params.GuotongWxMiniPayReqParams; -import com.accompany.payment.heepay.HeePayService; -import com.accompany.payment.heepay.params.PayRequestParams; -import com.accompany.payment.huiju.HuiJuService; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.sandpay.SandPayMiniAppReqParams; -import com.accompany.payment.sandpay.SandPayService; -import com.google.common.base.Strings; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.math.BigDecimal; -import java.util.Date; - -import static com.accompany.common.constant.Constant.SysConfId.WX_MINI_APP_PAY_THIRD; -import static com.accompany.payment.constant.PayConstant.HUNDRED; - -/** - * 微信小程序支付策略 - * - * @author linuxea - * @date 2019/8/19 10:50 - */ -@Slf4j -@PayChannelSupport(Constant.ChargeChannel.wx_mini_app_channel) -@Component -public class WxMiniAppPayStrategy extends AbstractPayStrategy { - - private final HuiJuService huiJuService; - private final HeePayService heePayService; - private final SysConfService sysConfService; - private final GuotongPayService guotongPayService; - private final FufeitongPayService fufeitongPayService; - private final SandPayService sandPayService; - - private static final String HUI_FU_BAO = "HUI_FU_BAO"; - - private static final String GUO_TONG = "GUO_TONG"; - // 中嘉主体国通渠道 - private static final String GUO_TONG_ZJLX = "GUO_TONG_ZJLX"; - - private static final String FU_FEI_TONG = "FU_FEI_TONG"; - - private static final String SAND = "SAND"; - - @Autowired - public WxMiniAppPayStrategy( - HuiJuService huiJuService, HeePayService heePayService, SysConfService sysConfService, - GuotongPayService guotongPayService, FufeitongPayService fufeitongPayService, - SandPayService sandPayService) { - this.huiJuService = huiJuService; - this.heePayService = heePayService; - this.sysConfService = sysConfService; - this.guotongPayService = guotongPayService; - this.fufeitongPayService = fufeitongPayService; - this.sandPayService = sandPayService; - } - - @Override - public Object pay(PayContext context) throws Exception{ - ChargeRecord chargeRecord = context.getChargeRecord(); - String value = Strings.nullToEmpty(sysConfService.getSysConfValueById(WX_MINI_APP_PAY_THIRD)); - log.info("小程序支付第三方正在开启的是:{}", value); - if (HUI_FU_BAO.equalsIgnoreCase(value)) { - PayRequestParams params = new PayRequestParams(); - params.setAgentBillId(chargeRecord.getChargeRecordId()); - params.setPayAmt(new BigDecimal(chargeRecord.getAmount().toString()).divide(HUNDRED, 2, BigDecimal.ROUND_HALF_UP)); - params.setReturnUrl(context.getSuccessUrl()); - params.setUserIp(chargeRecord.getClientIp()); - params.setAgentBillTime(DateTimeUtil.convertDate(new Date(), DateTimeUtil.DEFAULT_DATE_PATTERN__)); - params.setGoodsName(chargeRecord.getSubject()); - params.setRemark(chargeRecord.getChargeProdId()); - params.setOpenId(chargeRecord.getWxPubOpenid()); - return heePayService.weChatMiniAppPay(params); - } else if (GUO_TONG.equalsIgnoreCase(value)) { - GuotongWxMiniPayReqParams params = new GuotongWxMiniPayReqParams(); - params.setPayMoney(new BigDecimal(chargeRecord.getAmount().toString()).divide(HUNDRED, 2, BigDecimal.ROUND_HALF_UP)); - params.setLowOrderId(chargeRecord.getChargeRecordId()); - params.setBody(chargeRecord.getSubject()); - params.setOpenId(chargeRecord.getWxPubOpenid()); - - GuotongWxMiniPayResultBO order = guotongPayService.createWxMiniproOrder(params); - - return order.getPayInfo(); - } else if (GUO_TONG_ZJLX.equalsIgnoreCase(value)) { - GuotongWxMiniPayReqParams params = new GuotongWxMiniPayReqParams(); - params.setPayMoney(new BigDecimal(chargeRecord.getAmount().toString()).divide(HUNDRED, 2, BigDecimal.ROUND_HALF_UP)); - params.setLowOrderId(chargeRecord.getChargeRecordId()); - params.setBody(chargeRecord.getSubject()); - params.setOpenId(chargeRecord.getWxPubOpenid()); - - GuotongWxMiniPayResultBO order = guotongPayService.createWxMiniproOrderForZjlx(params); - - return order.getPayInfo(); - } else if (FU_FEI_TONG.equals(value)) { - FufeitongWxOrderReqParams params = new FufeitongWxOrderReqParams(); - params.setAmount(new BigDecimal(chargeRecord.getAmount().toString()).divide(HUNDRED, 2, BigDecimal.ROUND_HALF_UP)); - params.setCust1(FufeitongConstant.CUST1_MINIAPP); - params.setGoodsName(chargeRecord.getSubject()); - params.setTraceno(chargeRecord.getChargeRecordId()); - params.setOpenId(chargeRecord.getWxPubOpenid()); - - FufeitongWxOpenOrderRes wxOpenOrder = fufeitongPayService.createWxOpenOrder(params); - return wxOpenOrder.getMiniAppPayInfo(); - } else if (SAND.equals(value)) { - // 杉德 - SandPayMiniAppReqParams params = new SandPayMiniAppReqParams(); - params.setChargeRecordId(chargeRecord.getChargeRecordId()); - params.setClientIp(chargeRecord.getClientIp()); - params.setOpenId(chargeRecord.getWxPubOpenid()); - params.setSubject(chargeRecord.getSubject()); - params.setBody(chargeRecord.getSubject()); - params.setChargeAmount(new BigDecimal(chargeRecord.getAmount())); - params.setSubAppId(SandPayConfig.MiniAppConfig.subAppid); - return sandPayService.createWxMiniAppOrder(params); - } else { - return huiJuService.weChatMiniAppPay(chargeRecord.getWxPubOpenid(), chargeRecord.getAmount(), - chargeRecord.getChargeRecordId(), chargeRecord.getSubject(), context.getSuccessUrl()); - } - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxNativeStrategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxNativeStrategy.java deleted file mode 100644 index 370a8fb8c..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxNativeStrategy.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.accompany.payment.strategy; - -import com.accompany.common.constant.AppEnum; -import com.accompany.common.constant.Constant; -import com.accompany.common.device.DeviceInfo; -import com.accompany.common.utils.StringUtils; -import com.accompany.core.exception.ServiceException; -import com.accompany.payment.annotation.PayChannelSupport; -import com.accompany.payment.config.BaseWxPayConfig; -import com.accompany.payment.config.WxPayConfig; -import com.accompany.payment.config.YinyouWxPayConfig; -import com.accompany.payment.constant.PayConstant; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.service.PayCenterService; -import com.accompany.payment.wxpay.WeChatPayService; -import com.accompany.payment.wxpay.WeChatResultParam; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Map; - -/** - * @Author: chucheng - * @Date: 2019/4/29 17:09 - * @Description:微信原生支付 - */ -@Service -@PayChannelSupport(Constant.ChargeChannel.wx_native) -@Slf4j -public class WxNativeStrategy extends AbstractPayStrategy { - - @Autowired - private PayCenterService payCenterService; - @Autowired - private WeChatPayService weChatPayService; - @Autowired - private WxPayConfig wxPayConfig; - @Autowired - private YinyouWxPayConfig yinyouWxPayConfig; - - @Override - public Object pay(PayContext context) throws Exception { - ChargeRecord chargeRecord = context.getChargeRecord(); - String clientIp = chargeRecord.getClientIp(); - String successUrl = context.getSuccessUrl(); - DeviceInfo deviceInfo = context.getDeviceInfo(); - - BaseWxPayConfig usingWxPayConfig = wxPayConfig; - if (isYinyouApp(deviceInfo)) { - usingWxPayConfig = yinyouWxPayConfig; - } - - log.info("微信原生支付使用的appid为:{}", usingWxPayConfig.getAppId()); - - WeChatResultParam weChatResultParam = payCenterService.createWeChatOrder(usingWxPayConfig, chargeRecord.getAmount(), - chargeRecord.getChargeRecordId(), - chargeRecord.getSubject(), - chargeRecord.getBody(), - Constant.ChargeChannel.wx, - clientIp, - successUrl); - if (!PayConstant.WeChatTradeStatus.TRADE_SUCCESS.equals(weChatResultParam.getReturnCode())) { - throw new ServiceException(weChatResultParam.getReturmMsg()); - } - Map appMap = weChatPayService.buildAppParamMap(usingWxPayConfig, weChatResultParam.getPrepayId(), weChatResultParam.getNonceStr()); - return JSONObject.toJSON(appMap); - } - - /** - * 判断是否平台app - * @param deviceInfo - * @return - */ - private boolean isYinyouApp(DeviceInfo deviceInfo) { - if (deviceInfo == null || StringUtils.isBlank(deviceInfo.getApp())) { - return false; - } - - if (deviceInfo.getApp().equalsIgnoreCase(AppEnum.yinyou.getValue()) || deviceInfo.getApp().equalsIgnoreCase(AppEnum.yinyouEnterprise.getValue())) { - return true; - } - - return false; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPayStrategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPayStrategy.java deleted file mode 100644 index b2dc6b1b9..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPayStrategy.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.accompany.payment.strategy; - -import com.accompany.common.constant.Constant; -import com.accompany.core.service.SysConfService; -import com.accompany.core.util.StringUtils; -import com.accompany.payment.annotation.PayChannelSupport; -import com.accompany.payment.constant.PayConstant; -import com.accompany.payment.strategy.decorator.JointPayDecorator; -import com.accompany.payment.strategy.factory.PayStrategyFactory; -import org.springframework.stereotype.Service; - -/** - * @author : chucheng @Date: 2019/4/29 17:09 @Description: - * @see WxNativeStrategy - * @see WxJoinpayStrategy - */ -@Service -@PayChannelSupport(Constant.ChargeChannel.wx) -public class WxPayStrategy extends AbstractPayStrategy { - - private final PayStrategyFactory payStrategyFactory; - private final SysConfService sysConfService; - - public WxPayStrategy(PayStrategyFactory payStrategyFactory, SysConfService sysConfService) { - this.payStrategyFactory = payStrategyFactory; - this.sysConfService = sysConfService; - } - - @Override - public Object pay(PayContext context) throws Exception { - // TODO 待优化 - PayStrategy payStrategy; - String wxpayType = sysConfService.getSysConfValueById(Constant.SysConfId.WXPAY_PAY_TYPE); - // 默认是原生支付 - byte payType = - StringUtils.isBlank(wxpayType) ? PayConstant.PayType.nativepay : Byte.parseByte(wxpayType); - switch (payType) { - case PayConstant.PayType.joinpay: - payStrategy = - new JointPayDecorator( - payStrategyFactory.getStrategy(Constant.ChargeChannel.wx_joinpay), - payStrategyFactory.getStrategy(Constant.ChargeChannel.wx_native)); - break; - default: - payStrategy = payStrategyFactory.getStrategy(Constant.ChargeChannel.wx_native); - break; - } - return payStrategy.pay(context); - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPub2PayStrategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPub2PayStrategy.java deleted file mode 100644 index c1cd01075..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPub2PayStrategy.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.accompany.payment.strategy; - -import com.accompany.common.constant.Constant; -import com.accompany.core.exception.ServiceException; -import com.accompany.payment.annotation.PayChannelSupport; -import com.accompany.payment.config.WxPub2Config; -import com.accompany.payment.model.ChargeProd; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.vo.JsapiReturnVo; -import com.accompany.payment.wxpay.HttpUtils; -import com.accompany.payment.wxpay.MD5; -import com.accompany.payment.wxpay.PayUtil; -import com.accompany.payment.wxpay.XMLParser; -import com.alibaba.fastjson.JSON; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -/** - * @Author: chucheng - * @Date: 2019/4/29 17:09 - * @Description: - * @see WxPubNativeStrategy - * @see WxPubJoinpayStrategy - */ -@Service -@PayChannelSupport(Constant.ChargeChannel.wx_pub2) -@Slf4j -public class WxPub2PayStrategy extends AbstractPayStrategy { - private static final String UNIFIEDORDER_URL = "https://api.mch.weixin.qq.com/pay/unifiedorder"; - - @Override - public Object pay(PayContext context) throws Exception { - ChargeProd chargeProd = context.getChargeProd(); - ChargeRecord chargeRecord = context.getChargeRecord(); - String ip = chargeRecord.getClientIp(); - String openId = chargeRecord.getWxPubOpenid(); - Long uid = chargeRecord.getUid(); - Long erbanNo = context.getErbanNo(); - String nick = context.getNick(); - String nonce_str = PayUtil.getRandomStringByLength(16);//生成随机数,可直接用系统提供的方法 - String trade_type = "JSAPI"; - String outTradeNo = chargeRecord.getChargeRecordId(); - - Long amount = chargeProd.getMoney() * 100; - HashMap map = new HashMap(); - map.put("appid", WxPub2Config.appId); - map.put("mch_id", WxPub2Config.mchId); - map.put("device_info", "WEB"); - map.put("nonce_str", nonce_str); - map.put("body", "充值 " + amount / 10 + " 金币"); //订单标题(描述) - map.put("out_trade_no", outTradeNo); //订单ID - /* - 测试环境下,total_fee为money(分) - 正式环境为amount - */ - //TODO 正式环境为amount(测试环境下统统一分钱) - map.put("total_fee", String.valueOf(amount)); //订单需要支付的金额 - map.put("spbill_create_ip", ip); - map.put("trade_type", trade_type); - //TODO 添加回调地址 - map.put("notify_url", WxPub2Config.returnUrl); //notify_url 支付成功之后 微信会进行异步回调的地址 - map.put("openid", openId); //trade_type=JSAPI时(即公众号支付),此参数必传,此参数为微信用户在商户对应appid下的唯一标识。 - String sign = PayUtil.getSign(map, WxPub2Config.key); - map.put("sign", sign); - String content = XMLParser.getXMLFromMap(map); - log.info("========统一接口发送内容:=======" + content); - //调用统一下单接口 - String postResult = HttpUtils.sendPost(UNIFIEDORDER_URL, content); - log.info("=========统一下单返回结果:=======" + postResult); - //=============解析返回的结果=======================// - Map cbMap = XMLParser.getMapFromXML(postResult); - //下单成功 - if (!(cbMap.get("return_code").equals("SUCCESS") && cbMap.get("result_code").equals("SUCCESS"))) { - log.error("=======uid:" + uid + "==========微信公众号下单失败================="+cbMap.toString()); - throw new ServiceException("微信公众号下单失败"); - } - //将订单记录转成Json发送给H5 - return buildReturnVo(nonce_str, cbMap.get("prepay_id") + "", "MD5", null, null, - String.valueOf(erbanNo), nick); - } - - private JsapiReturnVo buildReturnVo(String nonceStr, String prepayId, String signType, String paySign, String timestamp, - String erbanNo, String nick) { - JsapiReturnVo returnVo = new JsapiReturnVo(); - returnVo.setAppid(WxPub2Config.appId); - returnVo.setSign_type(signType); - returnVo.setNonce_str(nonceStr); - returnVo.setPrepay_id("prepay_id=" + prepayId); - returnVo.setTimestamp(String.valueOf(System.currentTimeMillis() / 1000)); - String sign = getSign(returnVo); - returnVo.setSign(sign); - log.info("给H5的签名:{},签名方式:{},是否汇聚支付:{}", returnVo.getSign(), returnVo.getSign_type(), false); - - returnVo.setErban_no(erbanNo); - returnVo.setNick(nick); - returnVo.setMch_id(WxPub2Config.mchId); - log.info("submitPay return :{}, isJoinPay: {}", JSON.toJSONString(returnVo), false); - return returnVo; - } - - private String getSign(JsapiReturnVo returnVo) { - - Map map = new HashMap(); - map.put("appId", returnVo.getAppid()); - map.put("nonceStr", returnVo.getNonce_str()); - map.put("package", returnVo.getPrepay_id()); - map.put("timeStamp", returnVo.getTimestamp()); - map.put("signType", returnVo.getSign_type()); - return getSignByMap(map); - } - - private static String getSignByMap(Map map) { - ArrayList list = new ArrayList(); - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue() != "" && !entry.toString().equals("return_code") && !entry.toString().equals("return_msg") && !entry.toString() - .equals("result_code")) { - list.add(entry.getKey() + "=" + entry.getValue() + "&"); - } - } - int size = list.size(); - String[] arrayToSort = list.toArray(new String[size]); - Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < size; i++) { - sb.append(arrayToSort[i]); - } - - String result = sb.toString(); - //key 该方法key的需要根据你当前公众号的key进行修改 - result += "key=" + WxPub2Config.key; - log.info("=====================result========" + result); - result = MD5.MD5Encode(result).toUpperCase(); - log.info("=====================result after MD5========" + result); - return result; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPub2WapPayStrategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPub2WapPayStrategy.java deleted file mode 100644 index 69229a70f..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPub2WapPayStrategy.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.accompany.payment.strategy; - -import com.accompany.common.constant.Constant; -import com.accompany.core.exception.ServiceException; -import com.accompany.payment.annotation.PayChannelSupport; -import com.accompany.payment.config.WxPub2WapConfig; -import com.accompany.payment.constant.PayConstant; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.service.PayCenterService; -import com.accompany.payment.wxpay.WeChatResultParam; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.HashMap; -import java.util.Map; - -/** - * @Author: chucheng - * @Date: 2019/4/29 17:09 - * @Description: - */ -@Service -@PayChannelSupport(Constant.ChargeChannel.wx_pub2_h5) -@Slf4j -public class WxPub2WapPayStrategy extends AbstractPayStrategy { - - @Autowired - private PayCenterService payCenterService; - @Autowired - private WxPub2WapConfig wxPayConfig; - - @Override - public Object pay(PayContext context) throws Exception { - ChargeRecord chargeRecord = context.getChargeRecord(); - String clientIp = chargeRecord.getClientIp(); - String mwebUrl; - WeChatResultParam weChatResultParam = payCenterService.createWeChatOrder(wxPayConfig, chargeRecord.getAmount(), - chargeRecord.getChargeRecordId(), - chargeRecord.getSubject(), - chargeRecord.getBody(), - Constant.ChargeChannel.wx_wap, - clientIp, - context.getSuccessUrl()); - if (!PayConstant.WeChatTradeStatus.TRADE_SUCCESS.equals(weChatResultParam.getReturnCode())) { - throw new ServiceException(weChatResultParam.getReturmMsg()); - } - mwebUrl = weChatResultParam.getMwebUrl(); - Map appMap = new HashMap<>(); - appMap.put("mweb_url", mwebUrl); - return JSONObject.toJSON(appMap); - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPubJoinpayStrategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPubJoinpayStrategy.java deleted file mode 100644 index 09b8a48cc..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPubJoinpayStrategy.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.accompany.payment.strategy; - -import com.accompany.common.constant.Constant; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.service.SysConfService; -import com.accompany.payment.annotation.PayChannelSupport; -import com.accompany.payment.config.WxConfig; -import com.accompany.payment.joinpay.JoinpayService; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.vo.JsapiReturnVo; -import com.alibaba.fastjson.JSON; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Arrays; -import java.util.Map; -import java.util.Optional; - -/** - * @Author: chucheng - * @Date: 2019/4/29 17:09 - * @Description: 微信公众号汇聚支付 - */ -@Slf4j -@Service -@PayChannelSupport(Constant.ChargeChannel.wx_pub_joinpay) -public class WxPubJoinpayStrategy extends AbstractPayStrategy { - - @Autowired - private JoinpayService joinpayService; - @Autowired - private SysConfService sysConfService; - - @Override - public Object pay(PayContext context) throws Exception { - ChargeRecord chargeRecord = context.getChargeRecord(); - Long uid = chargeRecord.getUid(); - if (!(this.isJoinpayWxPubEnable() && this.isJoinpayWxPubGrayTestUser(uid))) { - throw new ServiceException("不支持汇聚支付"); - } - //汇聚支付 - JsapiReturnVo returnVo = joinPayWxPub(context); - if (returnVo == null) { - throw new ServiceException("汇聚支付失败"); - } - //汇聚支付成功 - return returnVo; - } - - /** - * 判断汇聚公众号支付是否已开启 - * - * @return - */ - private boolean isJoinpayWxPubEnable() { - String joinpaySwitch = sysConfService.getSysConfValueById(Constant.SysConfId.JOINPAY_GZH_SWITCH); - return Boolean.parseBoolean(joinpaySwitch); - } - - /** - * 判断是否灰度测试用户 - * - * @param uid - * @return - */ - private boolean isJoinpayWxPubGrayTestUser(Long uid) { - String isTestEnable = sysConfService.getSysConfValueById(Constant.SysConfId.JOINPAY_GZH_TEST_SWITCH); - if (!Boolean.parseBoolean(isTestEnable)) { - return true; - } - - String testUser = sysConfService.getSysConfValueById(Constant.SysConfId.JOINPAY_GZH_TEST_USER); - String[] uidsArray = StringUtils.isNotBlank(testUser) ? testUser.split(",") : new String[0]; - Optional optional = Arrays.stream(uidsArray).filter(item -> item.equals(uid.toString())).findAny(); - return optional.isPresent(); - } - - /** - * 汇聚支付 (微信公众号) - * - * @param context - * @return - * @throws Exception - */ - private JsapiReturnVo joinPayWxPub(PayContext context) throws Exception { - ChargeRecord chargeRecord = context.getChargeRecord(); - Long erbanNo = context.getErbanNo(); - String nick = context.getNick(); - String openId = chargeRecord.getWxPubOpenid(); - Map requestParams = this.joinpayService - .applyWxPubTrade(chargeRecord.getChargeRecordId(), chargeRecord.getAmount(), openId, chargeRecord.getSubject()); - log.info("joinpay pub apply trade response: {}", JSON.toJSONString(requestParams)); - - //汇聚支付成功 - if (!requestParams.isEmpty()) { - String thirdOrderNo = (String) requestParams.get("orderno"); - String nonceStr = (String) requestParams.get("noncestr"); - String packages = (String) requestParams.get("package"); - - String signType = (String) requestParams.get("signType"); - String paySign = (String) requestParams.get("sign"); - String timestamp = (String) requestParams.get("timestamp"); - - chargeRecord.setPingxxChargeId(thirdOrderNo); - return buildReturnVo(nonceStr, packages, signType, paySign, timestamp, String.valueOf(erbanNo), nick); - } - - return null; - } - - private JsapiReturnVo buildReturnVo(String nonceStr, String prepayId, String signType, String paySign, String timestamp, - String erbanNo, String nick) { - JsapiReturnVo returnVo = new JsapiReturnVo(); - returnVo.setAppid(WxConfig.appId); - returnVo.setSign_type(signType); - returnVo.setNonce_str(nonceStr); - returnVo.setPrepay_id(prepayId); - returnVo.setTimestamp(timestamp); - returnVo.setSign(paySign); - log.info("给H5的签名:{},签名方式:{},是否汇聚支付:{}", returnVo.getSign(), returnVo.getSign_type(), true); - returnVo.setErban_no(erbanNo); - returnVo.setNick(nick); - returnVo.setMch_id(WxConfig.mchId); - log.info("submitPay return :{}, isJoinPay: {}", JSON.toJSONString(returnVo), true); - return returnVo; - } - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPubNativeStrategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPubNativeStrategy.java deleted file mode 100644 index 11f6f8951..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPubNativeStrategy.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.accompany.payment.strategy; - -import com.accompany.common.constant.Constant; -import com.accompany.core.exception.ServiceException; -import com.accompany.payment.annotation.PayChannelSupport; -import com.accompany.payment.config.WxConfig; -import com.accompany.payment.model.ChargeProd; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.vo.JsapiReturnVo; -import com.accompany.payment.wxpay.HttpUtils; -import com.accompany.payment.wxpay.MD5; -import com.accompany.payment.wxpay.PayUtil; -import com.accompany.payment.wxpay.XMLParser; -import com.alibaba.fastjson.JSON; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -/** - * @Author: chucheng - * @Date: 2019/4/29 17:09 - * @Description: 微信公众号原生支付 - */ -@Slf4j -@Service -@PayChannelSupport(Constant.ChargeChannel.wx_pub_native) -public class WxPubNativeStrategy extends AbstractPayStrategy { - private static final String UNIFIEDORDER_URL = "https://api.mch.weixin.qq.com/pay/unifiedorder"; - - @Override - public Object pay(PayContext context) throws Exception { - ChargeProd chargeProd = context.getChargeProd(); - ChargeRecord chargeRecord = context.getChargeRecord(); - String ip = chargeRecord.getClientIp(); - String openId = chargeRecord.getWxPubOpenid(); - Long uid = chargeRecord.getUid(); - Long erbanNo = context.getErbanNo(); - String nick = context.getNick(); - String nonce_str = PayUtil.getRandomStringByLength(16);//生成随机数,可直接用系统提供的方法 - String trade_type = "JSAPI"; - String outTradeNo = chargeRecord.getChargeRecordId(); - - Long amount = chargeProd.getMoney() * 100; - HashMap map = new HashMap(); - map.put("appid", WxConfig.appId); - map.put("mch_id", WxConfig.mchId); - map.put("device_info", "WEB"); - map.put("nonce_str", nonce_str); - map.put("body", "充值 " + amount / 10 + " 金币"); //订单标题(描述) - map.put("out_trade_no", outTradeNo); //订单ID - /* - 测试环境下,total_fee为money(分) - 正式环境为amount - */ - //TODO 正式环境为amount(测试环境下统统一分钱) - map.put("total_fee", String.valueOf(amount)); //订单需要支付的金额 - map.put("spbill_create_ip", ip); - map.put("trade_type", trade_type); - //TODO 添加回调地址 - map.put("notify_url", WxConfig.returnUrl); //notify_url 支付成功之后 微信会进行异步回调的地址 - map.put("openid", openId); //trade_type=JSAPI时(即公众号支付),此参数必传,此参数为微信用户在商户对应appid下的唯一标识。 - String sign = PayUtil.getSign(map); - map.put("sign", sign); - String content = XMLParser.getXMLFromMap(map); - log.info("========统一接口发送内容:=======" + content); - //调用统一下单接口 - String postResult = HttpUtils.sendPost(UNIFIEDORDER_URL, content); - log.info("=========统一下单返回结果:=======" + postResult); - //=============解析返回的结果=======================// - Map cbMap = XMLParser.getMapFromXML(postResult); - //下单成功 - if (!(cbMap.get("return_code").equals("SUCCESS") && cbMap.get("result_code").equals("SUCCESS"))) { - log.error("=======uid:" + uid + "==========微信公众号下单失败================="+cbMap.toString()); - throw new ServiceException("微信公众号下单失败"); - } - //将订单记录转成Json发送给H5 - return buildReturnVo(nonce_str, cbMap.get("prepay_id") + "", "MD5", null, null, - String.valueOf(erbanNo), nick); - } - - private JsapiReturnVo buildReturnVo(String nonceStr, String prepayId, String signType, String paySign, String timestamp, - String erbanNo, String nick) { - JsapiReturnVo returnVo = new JsapiReturnVo(); - returnVo.setAppid(WxConfig.appId); - returnVo.setSign_type(signType); - returnVo.setNonce_str(nonceStr); - returnVo.setPrepay_id("prepay_id=" + prepayId); - returnVo.setTimestamp(String.valueOf(System.currentTimeMillis() / 1000)); - String sign = getSign(returnVo); - returnVo.setSign(sign); - log.info("给H5的签名:{},签名方式:{},是否汇聚支付:{}", returnVo.getSign(), returnVo.getSign_type(), false); - - returnVo.setErban_no(erbanNo); - returnVo.setNick(nick); - returnVo.setMch_id(WxConfig.mchId); - log.info("submitPay return :{}, isJoinPay: {}", JSON.toJSONString(returnVo), false); - return returnVo; - } - - private String getSign(JsapiReturnVo returnVo) { - - Map map = new HashMap(); - map.put("appId", returnVo.getAppid()); - map.put("nonceStr", returnVo.getNonce_str()); - map.put("package", returnVo.getPrepay_id()); - map.put("timeStamp", returnVo.getTimestamp()); - map.put("signType", returnVo.getSign_type()); - return getSignByMap(map); - } - - private static String getSignByMap(Map map) { - ArrayList list = new ArrayList(); - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue() != "" && !entry.toString().equals("return_code") && !entry.toString().equals("return_msg") && !entry.toString() - .equals("result_code")) { - list.add(entry.getKey() + "=" + entry.getValue() + "&"); - } - } - int size = list.size(); - String[] arrayToSort = list.toArray(new String[size]); - Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < size; i++) { - sb.append(arrayToSort[i]); - } - - String result = sb.toString(); - //key 该方法key的需要根据你当前公众号的key进行修改 - result += "key=" + WxConfig.key; - log.info("=====================result========" + result); - result = MD5.MD5Encode(result).toUpperCase(); - log.info("=====================result after MD5========" + result); - return result; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPubPayStrategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPubPayStrategy.java deleted file mode 100644 index aac54f54e..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxPubPayStrategy.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.accompany.payment.strategy; - -import com.accompany.common.constant.Constant; -import com.accompany.common.exception.BusinessException; -import com.accompany.common.utils.DateTimeUtil; -import com.accompany.core.service.SysConfService; -import com.accompany.payment.annotation.PayChannelSupport; -import com.accompany.payment.config.SandPayConfig; -import com.accompany.payment.guotongpay.GuotongPayService; -import com.accompany.payment.guotongpay.bo.GuotongWxMiniPayResultBO; -import com.accompany.payment.guotongpay.params.GuotongWxMiniPayReqParams; -import com.accompany.payment.heepay.HeePayService; -import com.accompany.payment.heepay.bo.WxPubPayResBO; -import com.accompany.payment.heepay.params.PayRequestParams; -import com.accompany.payment.huiju.HuiJuService; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.sandpay.SandPayMiniAppReqParams; -import com.accompany.payment.sandpay.SandPayService; -import com.accompany.payment.strategy.factory.PayStrategyFactory; -import com.accompany.payment.vo.JsapiReturnVo; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.util.Date; - -import static com.accompany.common.constant.Constant.SysConfId.WX_PUBLIC_PAY_THIRD; -import static com.accompany.payment.constant.PayConstant.HUNDRED; - -/** - * @Author: chucheng - * @Date: 2019/4/29 17:09 - * @Description: - * @see WxPubNativeStrategy - * @see WxPubJoinpayStrategy - */ -@Service -@PayChannelSupport(Constant.ChargeChannel.wx_pub) -@Slf4j -public class WxPubPayStrategy extends AbstractPayStrategy { - - /** 微信公众号支付 */ - private static final String NATIVE = "NATIVE"; - /** 微信公众号第三方支付 汇聚 */ - private static final String HUI_JU = "HUI_JU"; - /** 微信公众号第三方支付 汇付宝 */ - private static final String HUI_FU_BAO = "HUI_FU_BAO"; - /** 微信公众号第三方支付 国通 中嘉主体 */ - private static final String GUO_TONG_ZJLX = "GUO_TONG_ZJLX"; - /** 微信公众号第三方支付 杉德 */ - private static final String SAND = "SAND"; - - @Autowired - private PayStrategyFactory payStrategyFactory; - @Autowired - private SysConfService sysConfService; - @Autowired - private HuiJuService huiJuService; - @Autowired - private HeePayService heePayService; - @Autowired - private GuotongPayService guotongPayService; - @Autowired - private SandPayService sandPayService; - - - @Override - public Object pay(PayContext context) throws Exception { - String wxPublicPayThird = sysConfService.getSysConfValueById(WX_PUBLIC_PAY_THIRD); - log.info("当前开启的微信公众号第三方是 {}", wxPublicPayThird); - if (NATIVE.equalsIgnoreCase(wxPublicPayThird)) { - return payStrategyFactory.getStrategy(Constant.ChargeChannel.wx_pub_native).pay(context); - } else if (HUI_JU.equalsIgnoreCase(wxPublicPayThird)) { - ChargeRecord chargeRecord = context.getChargeRecord(); - return huiJuService.publicPay( - chargeRecord.getWxPubOpenid(), - chargeRecord.getAmount(), - chargeRecord.getChargeRecordId(), - chargeRecord.getSubject(), - context.getSuccessUrl(), - context.getNick(), - context.getErbanNo()); - } else if (HUI_FU_BAO.equalsIgnoreCase(wxPublicPayThird)) { - ChargeRecord chargeRecord = context.getChargeRecord(); - PayRequestParams params = new PayRequestParams(); - params.setAgentBillId(chargeRecord.getChargeRecordId()); - params.setPayAmt(new BigDecimal(chargeRecord.getAmount().toString()).divide(HUNDRED, 2, BigDecimal.ROUND_HALF_UP)); - params.setReturnUrl(context.getSuccessUrl()); - params.setUserIp(chargeRecord.getClientIp()); - params.setAgentBillTime(DateTimeUtil.convertDate(new Date(), DateTimeUtil.DEFAULT_DATE_PATTERN__)); - params.setGoodsName(chargeRecord.getSubject()); - params.setRemark(chargeRecord.getChargeProdId()); - - WxPubPayResBO res = heePayService.payByWxPub(params); - if (!res.getSuccess()) { - throw new BusinessException(res.getRetMsg()); - } - res.setNick(context.getNick()); - res.setErban_no(context.getErbanNo()); - return res; - } else if (GUO_TONG_ZJLX.equalsIgnoreCase(wxPublicPayThird)) { - ChargeRecord chargeRecord = context.getChargeRecord(); - GuotongWxMiniPayReqParams params = new GuotongWxMiniPayReqParams(); - params.setPayMoney(new BigDecimal(chargeRecord.getAmount().toString()).divide(HUNDRED, 2, BigDecimal.ROUND_HALF_UP)); - params.setLowOrderId(chargeRecord.getChargeRecordId()); - params.setBody(chargeRecord.getSubject()); - params.setOpenId(chargeRecord.getWxPubOpenid()); - - JsapiReturnVo order = guotongPayService.createWxPubOrderForZjlx(params); - - order.setNick(context.getNick()); - order.setErban_no(context.getErbanNo().toString()); - return order; - } else if (SAND.equalsIgnoreCase(wxPublicPayThird)) { - // 杉德 - ChargeRecord chargeRecord = context.getChargeRecord(); - SandPayMiniAppReqParams params = new SandPayMiniAppReqParams(); - params.setChargeRecordId(chargeRecord.getChargeRecordId()); - params.setClientIp(chargeRecord.getClientIp()); - params.setOpenId(chargeRecord.getWxPubOpenid()); - params.setSubject(chargeRecord.getSubject()); - params.setBody(chargeRecord.getSubject()); - params.setChargeAmount(new BigDecimal(chargeRecord.getAmount())); - params.setSubAppId(SandPayConfig.MiniAppConfig.wxpubAppid); - JsapiReturnVo order = sandPayService.createWxPubOrder(params); - order.setNick(context.getNick()); - order.setErban_no(context.getErbanNo().toString()); - return order; - } - log.warn("微信公众号支付第三方配置异常, 默认走原生"); - return payStrategyFactory.getStrategy(Constant.ChargeChannel.wx_pub_native).pay(context); - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxWapPayStrategy.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxWapPayStrategy.java deleted file mode 100644 index 4fa81b95a..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/WxWapPayStrategy.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.accompany.payment.strategy; - -import com.accompany.common.constant.Constant; -import com.accompany.common.device.DeviceInfo; -import com.accompany.common.utils.AppUtils; -import com.accompany.common.utils.DateTimeUtil; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.service.SysConfService; -import com.accompany.payment.annotation.PayChannelSupport; -import com.accompany.payment.config.BaseWxPayConfig; -import com.accompany.payment.config.WxPayConfig; -import com.accompany.payment.config.YinyouWxPayConfig; -import com.accompany.payment.constant.PayConstant; -import com.accompany.payment.heepay.HeePayService; -import com.accompany.payment.heepay.bo.WxH5PayResBO; -import com.accompany.payment.heepay.params.WxH5PayReqParams; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.service.PayCenterService; -import com.accompany.payment.wxpay.WeChatResultParam; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import static com.accompany.common.constant.Constant.SysConfId.WX_H5_PAY_THIRD; -import static com.accompany.payment.constant.PayConstant.HUNDRED; -import static com.accompany.payment.heepay.HeePayConstant.BANK_CARD_TYPE_UNKONW; -import static com.accompany.payment.heepay.HeePayConstant.PAY_SCENE_H5; - -/** - * @Author: chucheng - * @Date: 2019/4/29 17:09 - * @Description: - */ -@Service -@PayChannelSupport(Constant.ChargeChannel.wx_wap) -@Slf4j -public class WxWapPayStrategy extends AbstractPayStrategy { - - /** 微信h5原生支付 */ - private static final String NATIVE = "NATIVE"; - /** 汇付宝微信h5 */ - private static final String HUI_FU_BAO = "HUI_FU_BAO"; - - @Autowired - private PayCenterService payCenterService; - @Autowired - private SysConfService sysConfService; - @Autowired - private HeePayService heePayService; - @Autowired - private WxPayConfig wxPayConfig; - @Autowired - private YinyouWxPayConfig yinyouWxPayConfig; - - @Override - public Object pay(PayContext context) throws Exception { - String wxH5PayThird = sysConfService.getSysConfValueById(WX_H5_PAY_THIRD); - log.info("当前开启的微信h5第三方是 {}", wxH5PayThird); - ChargeRecord chargeRecord = context.getChargeRecord(); - String clientIp = chargeRecord.getClientIp(); - DeviceInfo deviceInfo = context.getDeviceInfo(); - String mwebUrl; - - BaseWxPayConfig usingWxPayConfig = wxPayConfig; - if (AppUtils.isYinyouApp(deviceInfo)) { - usingWxPayConfig = yinyouWxPayConfig; - } - - if (HUI_FU_BAO.equalsIgnoreCase(wxH5PayThird)) { - WxH5PayReqParams params = new WxH5PayReqParams(); - params.setScene(PAY_SCENE_H5); - params.setAgentBillId(chargeRecord.getChargeRecordId()); - params.setPayAmt(new BigDecimal(chargeRecord.getAmount().toString()).divide(HUNDRED, 2, BigDecimal.ROUND_HALF_UP)); - params.setReturnUrl(context.getSuccessUrl()); - params.setUserIp(clientIp); - params.setAgentBillTime(DateTimeUtil.convertDate(new Date(), DateTimeUtil.DEFAULT_DATE_PATTERN__)); - params.setGoodsName(chargeRecord.getSubject()); - // remark自定义参数,暂时放入商品id - params.setRemark(chargeRecord.getChargeProdId()); - params.setBankCardType(BANK_CARD_TYPE_UNKONW); - WxH5PayResBO res = heePayService.wxH5Pay(params); - if (!res.getSuccess()) { - throw new ServiceException(res.getRetMsg()); - } - mwebUrl = res.getRedirectUrl(); - } else { - WeChatResultParam weChatResultParam = payCenterService.createWeChatOrder(usingWxPayConfig, chargeRecord.getAmount(), - chargeRecord.getChargeRecordId(), - chargeRecord.getSubject(), - chargeRecord.getBody(), - Constant.ChargeChannel.wx_wap, - clientIp, - context.getSuccessUrl()); - if (!PayConstant.WeChatTradeStatus.TRADE_SUCCESS.equals(weChatResultParam.getReturnCode())) { - throw new ServiceException(weChatResultParam.getReturmMsg()); - } - mwebUrl = weChatResultParam.getMwebUrl(); - } - Map appMap = new HashMap<>(); - appMap.put("mweb_url", mwebUrl); - return JSONObject.toJSON(appMap); - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/decorator/JointPayDecorator.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/decorator/JointPayDecorator.java deleted file mode 100644 index 5fa1dabac..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/strategy/decorator/JointPayDecorator.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.accompany.payment.strategy.decorator; - -import com.alibaba.fastjson.JSON; -import com.accompany.payment.strategy.AbstractPayStrategy; -import com.accompany.payment.strategy.PayContext; -import com.accompany.payment.strategy.PayStrategy; -import lombok.extern.slf4j.Slf4j; -import org.springframework.util.Assert; - -/** - * @author PaperCut - * Created by PaperCut on 2019/5/14. - * 结合第三方和原生支付的装饰类 - */ -@Slf4j -public class JointPayDecorator extends AbstractPayStrategy { - private final PayStrategy payStrategy; - private final PayStrategy switchPayStrategy; - - public JointPayDecorator(PayStrategy payStrategy, PayStrategy switchPayStrategy) { - Assert.notNull(payStrategy, "The payStrategy can't be null"); - Assert.notNull(switchPayStrategy, "The switchPayStrategy can't be null"); - - this.payStrategy = payStrategy; - this.switchPayStrategy = switchPayStrategy; - } - - @Override - public Object pay(PayContext context) throws Exception { - try { - Object ret = payStrategy.pay(context); - return ret; - } catch (Exception e) { - log.error("Failed to do pay..The context:{}", JSON.toJSONString(context)); - return switchPayStrategy.pay(context); - } - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/utils/MultiAliPayUtil.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/utils/MultiAliPayUtil.java deleted file mode 100644 index a50205bf7..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/utils/MultiAliPayUtil.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.accompany.payment.utils; - -import com.accompany.payment.alipay.AliPayClientParam; -import com.accompany.payment.config.MultiAliPayConfig; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.collections.CollectionUtils; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * 切换支付宝的工具类 - */ -@Slf4j -public class MultiAliPayUtil { - - public static List validConfigs; - - public static int currentIndex; - - private static int totalSize; - - /** - * 进行轮询处理 - * - * @return - */ - public static AliPayClientParam round() { - setValidConfigs(MultiAliPayConfig.alipayConfigs); - totalSize = validConfigs.size(); - if (totalSize <= 0) { - //支付宝配置不能为空 - log.error("aliPayClientConfig valid list can not be null"); - } - currentIndex = (currentIndex + 1) % totalSize; - return validConfigs.get(currentIndex); - } - - /** - * 设置有效的支付宝配置 - * - * @param clientConfigs - */ - public static void setValidConfigs(List clientConfigs) { - if (CollectionUtils.isEmpty(clientConfigs)) { - return; - } - validConfigs = clientConfigs.stream().filter(clientConfig -> clientConfig.getStatus()).collect(Collectors.toList()); - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/utils/SandpayUtils.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/utils/SandpayUtils.java deleted file mode 100644 index 6b71e138b..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/utils/SandpayUtils.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.accompany.payment.utils; - -import com.accompany.common.utils.StringUtils; -import com.fasterxml.jackson.databind.ObjectMapper; - -import javax.crypto.Cipher; -import java.io.ByteArrayOutputStream; -import java.security.KeyFactory; -import java.security.PrivateKey; -import java.security.spec.PKCS8EncodedKeySpec; -import java.util.*; - -/** - * 杉德支付工具类 - * - * @author Chenzhixiang - */ -public final class SandpayUtils { - - private static ObjectMapper objectMapper = new ObjectMapper(); - - private static String algorithm = "RSA"; //$NON-NLS-1$ - public static String testEncrypt(String key,String data) throws Exception { - byte[] decode = java.util.Base64.getDecoder().decode(key); - PKCS8EncodedKeySpec pkcs8EncodedKeySpec = new PKCS8EncodedKeySpec(decode); - KeyFactory kf = KeyFactory.getInstance(algorithm); - PrivateKey generatePrivate = kf.generatePrivate(pkcs8EncodedKeySpec); - Cipher ci = Cipher.getInstance(algorithm); - ci.init(Cipher.ENCRYPT_MODE, generatePrivate); - byte[] bytes = data.getBytes(); - int inputLen = bytes.length; - int offLen = 0;//偏移量 - int i = 0; - ByteArrayOutputStream bops = new ByteArrayOutputStream(); - while(inputLen - offLen > 0){ - byte [] cache; - if(inputLen - offLen > 117){ - cache = ci.doFinal(bytes, offLen,117); - }else{ - cache = ci.doFinal(bytes, offLen,inputLen - offLen); - } - bops.write(cache); - i++; - offLen = 117 * i; - } - bops.close(); - byte[] encryptedData = bops.toByteArray(); - String encodeToString = java.util.Base64.getEncoder().encodeToString(encryptedData); - return encodeToString; - } - - public static String getSignContent(Map sortedParams) { - StringBuilder content = new StringBuilder(); - List keys = new ArrayList<>(sortedParams.keySet()); - Collections.sort(keys); - int index = 0; - for (String key : keys) { - String value = sortedParams.get(key); - if (StringUtils.isNotBlank(key) && StringUtils.isNotBlank(value)) { - content.append(index == 0 ? "" : "&").append(key).append("=").append(value); - ++index; - } - } - return content.toString(); - } - - public static Map getUrlParams(String param) { - Map map = new HashMap(0); - if (StringUtils.isBlank(param)) { - return map; - } - String[] params = param.split("&"); - for (int i = 0; i < params.length; i++) { - String[] p = params[i].split("="); - if (p.length == 2) { - map.put(p[0], p[1]); - } - } - return map; - } - - public static Map parseToMap(String json) { - return parseToObject(json, Map.class); - } - - public static T parseToObject(String json, Class toClass) { - try { - return objectMapper.readValue(json, toClass); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - - public static String parseToJson(Object o) { - if (o == null) { - return null; - } - try { - return objectMapper.writeValueAsString(o); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/AlipayResult.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/AlipayResult.java deleted file mode 100644 index 39b806533..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/AlipayResult.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.accompany.payment.vo; - -import lombok.Data; - -@Data -public class AlipayResult { - - /** - * 支付方式类型:native 原生;h5 h5跳转支付 - */ - private String payType; - - /** - * 下单结果数据 - */ - private Object orderData; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/HttpForm.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/HttpForm.java deleted file mode 100644 index 7eea02638..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/HttpForm.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.accompany.payment.vo; - -public class HttpForm { - private String name; - private String value; - - public HttpForm(String name, String value) { - this.name = name; - this.value = value; - } - - public HttpForm() { - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return this.value; - } - - public void setValue(String value) { - this.value = value; - } -} \ No newline at end of file diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/HttpHeader.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/HttpHeader.java deleted file mode 100644 index 0a8a72ea9..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/HttpHeader.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.accompany.payment.vo; - -/** - * @Author: yangming - * @Date: 2020/5/8 19:27 - * @Description: HttpHeader - **/ -public class HttpHeader { - private String name; - private String value; - - public HttpHeader(String name, String value) { - this.name = name; - this.value = value; - } - - public HttpHeader(String name) { - this.name = name; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return this.value; - } - - public void setValue(String value) { - this.value = value; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/JsapiReturnVo.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/JsapiReturnVo.java deleted file mode 100644 index 8c59067dc..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/JsapiReturnVo.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.accompany.payment.vo; - -/** - * @Author: chucheng - * @Date: 2019/4/30 10:33 - * @Description: - */ - -public class JsapiReturnVo { - - private String return_code; - private String return_msg; - private String appid; - private String mch_id; - private String nonce_str; - private String openid; - private String sign; - private String result_code; - private String prepay_id; - private String trade_type; - private String nick; - private String timestamp; - private String erban_no; - - private String sign_type; - - public String getSign_type() { - return sign_type; - } - - public void setSign_type(String sign_type) { - this.sign_type = sign_type; - } - - public String getErban_no() { - return erban_no; - } - - public void setErban_no(String erban_no) { - this.erban_no = erban_no; - } - - public String getTimestamp() { - return timestamp; - } - - public void setTimestamp(String timestamp) { - this.timestamp = timestamp; - } - - public String getNick() { - return nick; - } - - public void setNick(String nick) { - this.nick = nick; - } - - public String getReturn_code() { - return return_code; - } - - public void setReturn_code(String return_code) { - this.return_code = return_code; - } - - public String getReturn_msg() { - return return_msg; - } - - public void setReturn_msg(String return_msg) { - this.return_msg = return_msg; - } - - public String getAppid() { - return appid; - } - - public void setAppid(String appid) { - this.appid = appid; - } - - public String getMch_id() { - return mch_id; - } - - public void setMch_id(String mch_id) { - this.mch_id = mch_id; - } - - public String getNonce_str() { - return nonce_str; - } - - public void setNonce_str(String nonce_str) { - this.nonce_str = nonce_str; - } - - public String getOpenid() { - return openid; - } - - public void setOpenid(String openid) { - this.openid = openid; - } - - public String getSign() { - return sign; - } - - public void setSign(String sign) { - this.sign = sign; - } - - public String getResult_code() { - return result_code; - } - - public void setResult_code(String result_code) { - this.result_code = result_code; - } - - public String getPrepay_id() { - return prepay_id; - } - - public void setPrepay_id(String prepay_id) { - this.prepay_id = prepay_id; - } - - public String getTrade_type() { - return trade_type; - } - - public void setTrade_type(String trade_type) { - this.trade_type = trade_type; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/WeChatMiniAppPayRequestVO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/WeChatMiniAppPayRequestVO.java deleted file mode 100644 index 8921edbe8..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/WeChatMiniAppPayRequestVO.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.accompany.payment.vo; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -/** - * 站外小程序支付请求实体 - * - * @author linuxea - * @date 2019/8/14 14:19 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class WeChatMiniAppPayRequestVO { - - /** - * 交易产品 - */ - @NotBlank(message = "交易产品 id 不可为空") - private String chargeProdId; - - /** - * 支付成功跳转链接 - */ - @NotBlank(message = "支付成功跳转链接不能为空") - private String successUrl; - - /** - * 小程序 openId - */ - @NotBlank(message = "openId不能为空") - private String openId; - - /** - * target 充值账号 - */ - @NotNull(message = "账号不能为空") - private Long account; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/WeChatMiniAppPayResponseVO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/WeChatMiniAppPayResponseVO.java deleted file mode 100644 index d1e9a0cf8..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/WeChatMiniAppPayResponseVO.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.accompany.payment.vo; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 站外小程序支付响应实体 - * - * @author linuxea - * @date 2019/8/14 14:49 - */ -@Data -@AllArgsConstructor -@NoArgsConstructor -public class WeChatMiniAppPayResponseVO { - - /** - * appId - */ - private String appId; - - /** - * 创建支付时间戳 秒 - */ - private String timeStamp; - - /** - * 随机字符串 - */ - private String nonceStr; - - /** - * 前端调起支付参数 - */ - @JsonProperty("package") - private String packageInfo; - - /** - * 签名类型 - */ - private String signType; - - /** - * 支付签名 - */ - private String paySign; - - /** - * 昵称 - */ - private String nick; - - /** - * 草莓号 - */ - private Long erbanNo; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/WeXinPayTypeVO.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/WeXinPayTypeVO.java deleted file mode 100644 index 01bd4a147..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/vo/WeXinPayTypeVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.accompany.payment.vo; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * @author linuxea - * @date 2019/8/8 15:57 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class WeXinPayTypeVO { - - /** - * 当前微信开启的支付方式 - */ - private String wxPayType; - - /** - * 微信小程序AppId - */ - private String wxminiAppid; - - /** - * 微信小程序原始ID - */ - private String wxminiId; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/WanXiangPayConfig.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/WanXiangPayConfig.java deleted file mode 100644 index 4fef519a9..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/WanXiangPayConfig.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.accompany.payment.wanxiang; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ConfigurationProperties("wanxiang-pay") -@Data -public class WanXiangPayConfig { - - private String merchantId; - - private String merchantPrivKey; - - private String platformPubKey; - - private String notifyUrl; - - private String createOrderUrl; - - private String wxMiniproAppId; - - private String toAlipayH5Url; - - private Integer alipayChannel; - private Integer alipayScene; - private Integer expireMinutes; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/WanXiangPayService.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/WanXiangPayService.java deleted file mode 100644 index 15366d2ab..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/WanXiangPayService.java +++ /dev/null @@ -1,170 +0,0 @@ -package com.accompany.payment.wanxiang; - -import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.DateTimeUtil; -import com.accompany.common.utils.DateUtil; -import com.accompany.common.utils.HttpUtils; -import com.accompany.common.utils.StringUtils; -import com.accompany.core.exception.ServiceException; -import com.accompany.payment.utils.CommonPayUtils; -import com.accompany.payment.wanxiang.bo.WanXiangBaseRes; -import com.accompany.payment.wanxiang.params.WanXiangCreateOrderBaseReqParams; -import com.accompany.payment.wanxiang.params.WanXiangWxMiniproCreateOrderReqParams; -import com.accompany.payment.wanxiang.utils.RSAUtils; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -@Service -@Slf4j -public class WanXiangPayService { - - @Autowired - private WanXiangPayConfig wanXiangPayConfig; - - private final static String API_VERSION = "0.0.1"; - - /** - * 支付渠道:金运通 - */ - private final static int PAY_CHANNEL_JYT = 1; - - /** - * 支付场景:小程序 - */ - private final static int PAY_SCENE_WX_MINIPRO = 1; - /** - * 支付场景:支付宝h5 - */ - private final static int PAY_SCENE_ALIPAY_H5 = 5; - - private final static String CODE_SUCCESS = "2"; - - private static final String SIGN_FIELD_NAME = "sign"; - - /** - * 支付宝h5支付 - * @param params - * @return - */ - public WanXiangBaseRes createAlipayH5Order(WanXiangCreateOrderBaseReqParams params) { - checkParams(params); - - String result = null; - try { - int payChannel = wanXiangPayConfig.getAlipayChannel() != null ? wanXiangPayConfig.getAlipayChannel(): PAY_CHANNEL_JYT; - int payScene = wanXiangPayConfig.getAlipayScene() != null ? wanXiangPayConfig.getAlipayScene(): PAY_SCENE_ALIPAY_H5; - Map paramsMap = buildMapParams(payChannel, payScene, params); - - String signContent = CommonPayUtils.getSignContent(paramsMap); - - String sign = RSAUtils.sign(signContent.getBytes(), wanXiangPayConfig.getMerchantPrivKey()); - - paramsMap.put("t_Sign", sign); - - log.info("万象支付宝h5支付请求参数:{}",JSONObject.toJSONString(paramsMap)); - - result = HttpUtils.doPost(wanXiangPayConfig.getCreateOrderUrl(), paramsMap); - - log.info("万象支付宝h5支付请求结果:{}",result); - } catch (Exception e) { - log.error("万象支付宝h5创建订单失败。params:" + JSONObject.toJSONString(params), e); - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失败,请重试"); - } - - WanXiangBaseRes res = JSONObject.parseObject(result, WanXiangBaseRes.class); - if (CODE_SUCCESS.equalsIgnoreCase(res.getCode())) { - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失败:" + res.getMessage()); - } - return res; - } - - private Map buildMapParams(int payChannel, int payScene, WanXiangCreateOrderBaseReqParams params) { - Map reqParams = new HashMap<>(); - reqParams.put("t_Version", API_VERSION); - reqParams.put("t_MerchantId", wanXiangPayConfig.getMerchantId()); - reqParams.put("t_PayChannel", String.valueOf(payChannel)); - reqParams.put("t_PayScene", String.valueOf(payScene)); - reqParams.put("t_OrderNo", params.getOrderNo()); - reqParams.put("t_Subject", params.getSubject()); - reqParams.put("t_Amount", params.getAmount().toString()); - reqParams.put("t_NotifyUrl", wanXiangPayConfig.getNotifyUrl()); - if (StringUtils.isNotBlank(params.getReturnUrl())) { - reqParams.put("t_ReturnUrl", params.getReturnUrl()); - } - reqParams.put("t_ClientIp", params.getClientIp()); - // 订单失效时间 - reqParams.put("t_ExpireTime", DateTimeUtil.convertDate(DateTimeUtil.addMinutes(new Date(), wanXiangPayConfig.getExpireMinutes()), - DateTimeUtil.DEFAULT_DATE_PATTERN__)); - - return reqParams; - } - - private void checkParams(WanXiangCreateOrderBaseReqParams params) { - if (StringUtils.isBlank(params.getOrderNo())) { - throw new ServiceException(BusiStatus.PARAMERROR, "商户订单号不能为空"); - } - if (StringUtils.isBlank(params.getSubject())) { - throw new ServiceException(BusiStatus.PARAMERROR, "商户订单描述不能为空"); - } - if (params.getAmount() == null || params.getAmount().compareTo(BigDecimal.ZERO) <= 0) { - params.setAmount(new BigDecimal("0.01")); - } - } - - /** - * 小程序支付 - * @param params - * @return - */ - public WanXiangBaseRes createWxMiniproOrder(WanXiangWxMiniproCreateOrderReqParams params) { - checkParams(params); - - String result = null; - try { - Map paramsMap = buildMapParams(PAY_CHANNEL_JYT, PAY_SCENE_WX_MINIPRO, params); - paramsMap.put("t_OpenId", params.getOpenId()); - paramsMap.put("t_AppId", wanXiangPayConfig.getWxMiniproAppId()); - - String signContent = CommonPayUtils.getSignContent(paramsMap); - - String sign = RSAUtils.sign(signContent.getBytes(), wanXiangPayConfig.getMerchantPrivKey()); - - paramsMap.put("t_Sign", sign); - - log.info("万象微信小程序支付请求参数:{}",JSONObject.toJSONString(paramsMap)); - - result = HttpUtils.doPost(wanXiangPayConfig.getCreateOrderUrl(), paramsMap); - - log.info("万象微信小程序请求结果:{}",result); - } catch (Exception e) { - log.error("万象微信小程序创建订单失败。params:" + JSONObject.toJSONString(params), e); - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失败,请重试"); - } - - WanXiangBaseRes res = JSONObject.parseObject(result, WanXiangBaseRes.class); - if (CODE_SUCCESS.equalsIgnoreCase(res.getCode())) { - throw new ServiceException(BusiStatus.PAYMENT_FAIL, "支付失败:" + res.getMessage()); - } - return res; - } - - public boolean verifySign(Map resultMap) throws Exception { - Map paramsMap = new HashMap<>(resultMap.size()); - resultMap.forEach((key, value) -> { - if (!key.equals(SIGN_FIELD_NAME) && value != null) { - paramsMap.put(key, value); - } - }); - - String signContent = CommonPayUtils.getSignContent(paramsMap); - - return RSAUtils.verifyRsaSign(signContent, resultMap.get(SIGN_FIELD_NAME), wanXiangPayConfig.getPlatformPubKey()); - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/bo/WanXiangBaseRes.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/bo/WanXiangBaseRes.java deleted file mode 100644 index 719ffdb1d..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/bo/WanXiangBaseRes.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.accompany.payment.wanxiang.bo; - -import lombok.Data; - -@Data -public class WanXiangBaseRes { - - /** 响应码 */ - protected String code; - - /** 响应信息 */ - protected String message; - - /** 订单号 */ - protected String orderNo; - - /** data */ - protected String data; - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/params/WanXiangCreateOrderBaseReqParams.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/params/WanXiangCreateOrderBaseReqParams.java deleted file mode 100644 index 1601f5b57..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/params/WanXiangCreateOrderBaseReqParams.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.accompany.payment.wanxiang.params; - -import lombok.Data; - -import java.math.BigDecimal; - -@Data -public class WanXiangCreateOrderBaseReqParams { - - /** - * 商户订单号 - */ - private String orderNo; - - /** - * 订单描述 - */ - private String subject; - - /** - * 下单金额 - */ - private BigDecimal amount; - - /** - * 页面返回地址 - */ - private String returnUrl; - - /** - * 下单ip - */ - private String clientIp; -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/params/WanXiangWxMiniproCreateOrderReqParams.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/params/WanXiangWxMiniproCreateOrderReqParams.java deleted file mode 100644 index 33a02755c..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/params/WanXiangWxMiniproCreateOrderReqParams.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.accompany.payment.wanxiang.params; - -import lombok.Data; - -import java.math.BigDecimal; - -@Data -public class WanXiangWxMiniproCreateOrderReqParams extends WanXiangCreateOrderBaseReqParams { - - /** - * openId - */ - private String openId; - - /** - * 小程序appid - */ - private String appId; - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/utils/RSAUtils.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/utils/RSAUtils.java deleted file mode 100644 index cc2c290be..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/utils/RSAUtils.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.accompany.payment.wanxiang.utils; - -import org.apache.commons.codec.binary.Base64; - -import java.security.KeyFactory; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.Signature; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.PKCS8EncodedKeySpec; -import java.security.spec.X509EncodedKeySpec; - -public class RSAUtils { - - public static final String SIGNATURE_ALGORITHM = "SHA1withRSA"; - - public static String sign(byte[] data, String privateKeyStr) throws Exception { - PrivateKey privateKey = getPrivateKey(privateKeyStr); - Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM); - - signature.initSign(privateKey); - signature.update(data); - return Base64.encodeBase64String(signature.sign()); - - } - - /** - * SHA256withRSA 验签 - * @param signString 需要签名的参数拼接字符串 - * @param sign 签名字符串 - * @param publicKey - * @return - * @throws Exception - */ - public static boolean verifyRsaSign(String signString, String sign, String publicKey) throws Exception { -// String SIGNATURE_ALGORITHM = "SHA1withRSA"; - Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM); - signature.initVerify(RSAUtils.getPublicKey(publicKey)); - signature.update(signString.getBytes()); - // 如果是Base64编码的话,需要对验签的数组以Base64解码 - boolean isValid = signature.verify(Base64.decodeBase64(sign.getBytes())); - return isValid; - } - - public static PrivateKey getPrivateKey(String key) throws Exception { - try { - byte[] keyBytes = Base64.decodeBase64(key.getBytes()); - PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes); - KeyFactory keyFactory = KeyFactory.getInstance("RSA"); - PrivateKey privateKey = keyFactory.generatePrivate(keySpec); - return privateKey; - } catch (InvalidKeySpecException e) { - throw new Exception("私钥非法", e); - } - } - - public static PublicKey getPublicKey(String key) throws Exception { - try { - byte[] keyBytes = Base64.decodeBase64(key.getBytes()); - X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes); - KeyFactory keyFactory = KeyFactory.getInstance("RSA"); - PublicKey publicKey = keyFactory.generatePublic(keySpec); - return publicKey; - } catch (InvalidKeySpecException e) { - throw new Exception("公钥非法"); - } - } - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/utils/WanxiangPayConsts.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/utils/WanxiangPayConsts.java deleted file mode 100644 index 5d661606c..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wanxiang/utils/WanxiangPayConsts.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.accompany.payment.wanxiang.utils; - -public class WanxiangPayConsts { - - public final static class OrderStatus { - // 处理中 - public final static int PROCESSING = 1; - // 下单成功 - public final static int ORDER_SUCCESS = 2; - // 下单失败 - public final static int ORDER_FAIL = 3; - // 支付成功 - public final static int PAY_SUCCESS = 4; - // 支付失败 - public final static int PAY_FAIL = 5; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/HttpUtils.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/HttpUtils.java deleted file mode 100644 index dfa0da8ee..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/HttpUtils.java +++ /dev/null @@ -1,320 +0,0 @@ -package com.accompany.payment.wxpay; - -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpException; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; -import org.apache.commons.httpclient.methods.GetMethod; -import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.*; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -/** - * HTTP工具类 - * - * @author lixiangyang - */ -public class HttpUtils { - - private static Log log = LogFactory.getLog(HttpUtils.class); - - /** - * 定义编码格式 UTF-8 - */ - public static final String URL_PARAM_DECODECHARSET_UTF8 = "UTF-8"; - - /** - * 定义编码格式 GBK - */ - public static final String URL_PARAM_DECODECHARSET_GBK = "GBK"; - - private static final String URL_PARAM_CONNECT_FLAG = "&"; - - private static final String EMPTY = ""; - - private static MultiThreadedHttpConnectionManager connectionManager = null; - - private static int connectionTimeOut = 25000; - - private static int socketTimeOut = 25000; - - private static int maxConnectionPerHost = 20; - - private static int maxTotalConnections = 20; - - private static HttpClient client; - - static { - connectionManager = new MultiThreadedHttpConnectionManager(); - connectionManager.getParams().setConnectionTimeout(connectionTimeOut); - connectionManager.getParams().setSoTimeout(socketTimeOut); - connectionManager.getParams().setDefaultMaxConnectionsPerHost(maxConnectionPerHost); - connectionManager.getParams().setMaxTotalConnections(maxTotalConnections); - client = new HttpClient(connectionManager); - } - - /** - * POST方式提交数据 - * - * @param url 待请求的URL - * @param params 要提交的数据 - * @param enc 编码 - * @return 响应结果 - * @throws IOException IO异常 - */ - public static String URLPost(String url, Map params, String enc) { - - String response = EMPTY; - PostMethod postMethod = null; - try { - postMethod = new PostMethod(url); - postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=" + enc); - //将表单的值放入postMethod中 - Set keySet = params.keySet(); - for (String key : keySet) { - String value = params.get(key); - postMethod.addParameter(key, value); - } - //执行postMethod - int statusCode = client.executeMethod(postMethod); - if (statusCode == HttpStatus.SC_OK) { - response = postMethod.getResponseBodyAsString(); - } else { - log.error("响应状态码 = " + postMethod.getStatusCode()); - } - } catch (HttpException e) { - log.error("发生致命的异常,可能是协议不对或者返回的内容有问题", e); - e.printStackTrace(); - } catch (IOException e) { - log.error("发生网络异常", e); - e.printStackTrace(); - } finally { - if (postMethod != null) { - postMethod.releaseConnection(); - postMethod = null; - } - } - - return response; - } - - /** - * GET方式提交数据 - * - * @param url 待请求的URL - * @param params 要提交的数据 - * @param enc 编码 - * @return 响应结果 - * @throws IOException IO异常 - */ - public static String URLGet(String url, Map params, String enc) { - - String response = EMPTY; - GetMethod getMethod = null; - StringBuffer strtTotalURL = new StringBuffer(EMPTY); - - if (strtTotalURL.indexOf("?") == -1) { - strtTotalURL.append(url).append("?").append(getUrl(params, enc)); - } else { - strtTotalURL.append(url).append("&").append(getUrl(params, enc)); - } - log.debug("GET请求URL = \n" + strtTotalURL.toString()); - - try { - getMethod = new GetMethod(strtTotalURL.toString()); - getMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=" + enc); - //执行getMethod - int statusCode = client.executeMethod(getMethod); - if (statusCode == HttpStatus.SC_OK) { - response = getMethod.getResponseBodyAsString(); - } else { - log.debug("响应状态码 = " + getMethod.getStatusCode()); - } - } catch (HttpException e) { - log.error("发生致命的异常,可能是协议不对或者返回的内容有问题", e); - e.printStackTrace(); - } catch (IOException e) { - log.error("发生网络异常", e); - e.printStackTrace(); - } finally { - if (getMethod != null) { - getMethod.releaseConnection(); - getMethod = null; - } - } - - return response; - } - - /** - * 据Map生成URL字符串 - * - * @param map Map - * @param valueEnc URL编码 - * @return URL - */ - private static String getUrl(Map map, String valueEnc) { - - if (null == map || map.keySet().size() == 0) { - return (EMPTY); - } - StringBuffer url = new StringBuffer(); - Set keys = map.keySet(); - for (Iterator it = keys.iterator(); it.hasNext(); ) { - String key = it.next(); - if (map.containsKey(key)) { - String val = map.get(key); - String str = val != null ? val : EMPTY; - try { - str = URLEncoder.encode(str, valueEnc); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - url.append(key).append("=").append(str).append(URL_PARAM_CONNECT_FLAG); - } - } - String strURL = EMPTY; - strURL = url.toString(); - if (URL_PARAM_CONNECT_FLAG.equals(EMPTY + strURL.charAt(strURL.length() - 1))) { - strURL = strURL.substring(0, strURL.length() - 1); - } - return (strURL); - } - - - /** - * 向指定URL发送GET方法的请求 - * - * @param url 发送请求的URL - * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 - * @return URL 所代表远程资源的响应结果 - */ - public static String sendGet(String url, String param) { - String result = ""; - BufferedReader in = null; - try { - //自带“?” - String urlNameString = url + "?" + param; - //创建URL对象 - URL realUrl = new URL(urlNameString); - // 打开和URL之间的连接 - URLConnection connection = realUrl.openConnection(); - // 设置通用的请求属性 - connection.setRequestProperty("accept", "*/*"); - connection.setRequestProperty("connection", "Keep-Alive"); - connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); - // 建立实际的连接 - connection.connect(); - // 获取所有响应头字段 - - /* - * Map> map = connection.getHeaderFields(); // - * 遍历所有的响应头字段 for (String key : map.keySet()) { //禁止数据 - * System.out.println(key + "--->" + map.get(key)); } - */ - // 定义 BufferedReader输入流来读取URL的响应 - in = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String line; - while ((line = in.readLine()) != null) { - result += line; - } - } catch (Exception e) { - System.out.println("发送GET请求出现异常!" + e); - e.printStackTrace(); - } - // 使用finally块来关闭输入流 - finally { - try { - if (in != null) { - in.close(); - } - } catch (Exception e2) { - e2.printStackTrace(); - } - } - return result; - } - - /** - * 向指定 URL 发送POST方法的请求 - * - * @param url 发送请求的 URL - * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 - * @return 所代表远程资源的响应结果 - */ - public static String sendPost(String url, String param) { - PrintWriter out = null; - BufferedReader in = null; - String result = ""; - 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.setRequestProperty ( "charset" , "UTF-8"); - // 发送POST请求必须设置如下两行 - conn.setDoOutput(true); - conn.setDoInput(true); - // 获取URLConnection对象对应的输出流 - out = new PrintWriter(conn.getOutputStream()); - // 发送请求参数 - out.print(param); - // flush输出流的缓冲 - out.flush(); - // 定义BufferedReader输入流来读取URL的响应 - in = new BufferedReader(new InputStreamReader(conn.getInputStream())); - String line; - while ((line = in.readLine()) != null) { - result += line; - } - } catch (Exception e) { - System.out.println("发送 POST 请求出现异常!" + e); - e.printStackTrace(); - } - // 使用finally块来关闭输出流、输入流 - finally { - try { - if (out != null) { - out.close(); - } - if (in != null) { - in.close(); - } - } catch (IOException ex) { - ex.printStackTrace(); - } - } - return result; - - } - - - public static void main(String[] args) throws Exception { - - Map map = new HashMap<>(); - map.put("appid", "wx009d793f92c24eec"); - map.put("mch_id", "1484701192"); - map.put("nonce_str", PayUtil.getRandomStringByLength(16)); - map.put("out_trade_no", "20150806125346"); - map.put("sign", PayUtil.getSign(map)); - //以XML格式的数据发送 - String request = XMLParser.getXMLFromMap(map); - System.out.println(request); - String data = sendPost("https://api.mch.weixin.qq.com/pay/orderquery", request); - System.out.println(data); - - } - -} \ No newline at end of file diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/MD5.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/MD5.java deleted file mode 100644 index c64c6f343..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/MD5.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.accompany.payment.wxpay; - - -import java.security.MessageDigest; - -/** - * User: rizenguo - * Date: 2014/10/23 - * Time: 15:43 - */ -public class MD5 { - private final static String[] hexDigits = {"0", "1", "2", "3", "4", "5", "6", "7", - "8", "9", "a", "b", "c", "d", "e", "f"}; - - /** - * 转换字节数组为16进制字串 - * - * @param b 字节数组 - * @return 16进制字串 - */ - public static String byteArrayToHexString(byte[] b) { - StringBuilder resultSb = new StringBuilder(); - for (byte aB : b) { - resultSb.append(byteToHexString(aB)); - } - return resultSb.toString(); - } - - /** - * 转换byte到16进制 - * - * @param b 要转换的byte - * @return 16进制格式 - */ - private static String byteToHexString(byte b) { - int n = b; - if (n < 0) { - n = 256 + n; - } - int d1 = n / 16; - int d2 = n % 16; - return hexDigits[d1] + hexDigits[d2]; - } - - /** - * MD5编码 - * - * @param origin 原始字符串 - * @return 经过MD5加密之后的结果 - */ - public static String MD5Encode(String origin) { - String resultString = null; - try { - resultString = origin; - MessageDigest md = MessageDigest.getInstance("MD5"); - md.update(resultString.getBytes("UTF-8")); - resultString = byteArrayToHexString(md.digest()); - } catch (Exception e) { - e.printStackTrace(); - } - return resultString; - } - - public static String MD5Encode(String origin, String charsetname) { - String resultString = null; - try { - resultString = new String(origin); - MessageDigest md = MessageDigest.getInstance("MD5"); - if (charsetname == null || "".equals(charsetname)) - resultString = byteArrayToHexString(md.digest(resultString - .getBytes())); - else - resultString = byteArrayToHexString(md.digest(resultString - .getBytes(charsetname))); - } catch (Exception exception) { - } - return resultString; - } - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/PayUtil.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/PayUtil.java deleted file mode 100644 index 7e2b8e430..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/PayUtil.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.accompany.payment.wxpay; - - -import com.accompany.payment.config.WxConfig; -import com.accompany.payment.config.WxMicroMallConfig; -import org.xml.sax.SAXException; - -import javax.xml.parsers.ParserConfigurationException; -import java.io.IOException; -import java.util.*; - -public class PayUtil { - public static String getTime_stamp() { - /*String stamp="1472275204"; - *//*Date d=new Date(); - d.getTime();*//* - return stamp;*/ - - String stamp = String.valueOf(new Date().getTime()); - return stamp; - - } - - public static String getRandomStringByLength(int len) { - String base = "abcdefghijklmnopqrstuvwxyz0123456789"; - Random random = new Random(); - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < len; i++) { - int number = random.nextInt(base.length()); - sb.append(base.charAt(number)); - } - return sb.toString(); - } - - public static String getSign(Map map) { - ArrayList list = new ArrayList(); - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue() != "" && !entry.toString().equals("return_code") && !entry.toString().equals("return_msg") && !entry.toString().equals("result_code")) { -// System.out.println ( ); - list.add(entry.getKey() + "=" + entry.getValue() + "&"); - } - } - int size = list.size(); - String[] arrayToSort = list.toArray(new String[size]); - Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < size; i++) { - sb.append(arrayToSort[i]); - } - - String result = sb.toString(); - //key 该方法key的需要根据你当前公众号的key进行修改 - result += "key=" + WxConfig.key; - //Util.log("Sign Before MD5:" + result); - result = MD5.MD5Encode(result).toUpperCase(); - //Util.log("Sign Result:" + result); - return result; - } - - public static String getSignForMicroMall(Map map) { - ArrayList list = new ArrayList(); - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue() != "" && !entry.toString().equals("return_code") && !entry.toString().equals("return_msg") && !entry.toString().equals("result_code")) { -// System.out.println ( ); - list.add(entry.getKey() + "=" + entry.getValue() + "&"); - } - } - int size = list.size(); - String[] arrayToSort = list.toArray(new String[size]); - Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < size; i++) { - sb.append(arrayToSort[i]); - } - - String result = sb.toString(); - //key 该方法key的需要根据你当前公众号的key进行修改 - result += "key=" + WxMicroMallConfig.key; - //Util.log("Sign Before MD5:" + result); - result = MD5.MD5Encode(result).toUpperCase(); - //Util.log("Sign Result:" + result); - return result; - } - - public static String getSign(Map map, String key) { - ArrayList list = new ArrayList(); - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue() != "" && !entry.toString().equals("return_code") && !entry.toString().equals("return_msg") && !entry.toString().equals("result_code")) { -// System.out.println ( ); - list.add(entry.getKey() + "=" + entry.getValue() + "&"); - } - } - int size = list.size(); - String[] arrayToSort = list.toArray(new String[size]); - Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < size; i++) { - sb.append(arrayToSort[i]); - } - - String result = sb.toString(); - //key 该方法key的需要根据你当前公众号的key进行修改 - result += "key=" + key; - //Util.log("Sign Before MD5:" + result); - result = MD5.MD5Encode(result).toUpperCase(); - //Util.log("Sign Result:" + result); - return result; - } - - public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException { - - String string = "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - /* " \n" +*/ - " \n" + - " \n" + - " 1\n" + - " \n" + - " \n" + - " \n" + - ""; - - Map map = XMLParser.getMapFromXML(string); - String s = PayUtil.getSign(map); - System.out.println(s);//"0C1D1ADD0DD75F9F90D6CF48C90E5AB0" - - - } - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/Util.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/Util.java deleted file mode 100644 index 1247e7bb1..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/Util.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.accompany.payment.wxpay; - -import com.thoughtworks.xstream.XStream; - -import java.io.*; -import java.lang.reflect.Field; -import java.net.InetAddress; -import java.util.Map; - -public class Util { - - //打log用 - //private static Log logger = new Log(log) - - /** - * 通过反射的方式遍历对象的属性和属性值,方便调试 - * - * @param o 要遍历的对象 - * @throws Exception - */ - public static void reflect(Object o) throws Exception { - Class cls = o.getClass(); - Field[] fields = cls.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) { - Field f = fields[i]; - f.setAccessible(true); - Util.log(f.getName() + " -> " + f.get(o)); - } - } - - public static byte[] readInput(InputStream in) throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - int len = 0; - byte[] buffer = new byte[1024]; - while ((len = in.read(buffer)) > 0) { - out.write(buffer, 0, len); - } - out.close(); - in.close(); - return out.toByteArray(); - } - - public static String inputStreamToString(InputStream is) throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - int i; - while ((i = is.read()) != -1) { - baos.write(i); - } - return baos.toString(); - } - - - public static InputStream getStringStream(String sInputString) throws UnsupportedEncodingException { - ByteArrayInputStream tInputStringStream = null; - if (sInputString != null && !sInputString.trim().equals("")) { - tInputStringStream = new ByteArrayInputStream(sInputString.getBytes("UTF-8")); - } - return tInputStringStream; - } - - public static Object getObjectFromXML(String xml, Class tClass) { - //将从API返回的XML数据映射到Java对象 - XStream xStreamForResponseData = new XStream(); - xStreamForResponseData.alias("xml", tClass); - xStreamForResponseData.ignoreUnknownElements();//暂时忽略掉一些新增的字段 - return xStreamForResponseData.fromXML(xml); - } - - public static String getStringFromMap(Map map, String key, String defaultValue) { - if (key == "" || key == null) { - return defaultValue; - } - String result = (String) map.get(key); - if (result == null) { - return defaultValue; - } else { - return result; - } - } - - public static int getIntFromMap(Map map, String key) { - if (key == "" || key == null) { - return 0; - } - if (map.get(key) == null) { - return 0; - } - return Integer.parseInt((String) map.get(key)); - } - - /** - * 打log接口 - * - * @param log 要打印的log字符串 - * @return 返回log - */ - public static String log(Object log) { - // logger.i(log.toString()); - System.out.println(log); - return log.toString(); - } - - /** - * 获取ip - * - * @return - * @throws IOException - */ - public static String getIpAdd() throws IOException { - InetAddress[] inetAdds = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName()); - return inetAdds[0].getHostAddress(); - } - - /** - * 读取本地的xml数据,一般用来自测用 - * - * @param localPath 本地xml文件路径 - * @return 读到的xml字符串 - */ - public static String getLocalXMLString(String localPath) throws IOException { - return Util.inputStreamToString(Util.class.getResourceAsStream(localPath)); - } - - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatNotifyParam.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatNotifyParam.java deleted file mode 100644 index 496ef45f9..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatNotifyParam.java +++ /dev/null @@ -1,274 +0,0 @@ -package com.accompany.payment.wxpay; - -/** - * @author yangming - * @date 2018-10-24 - * @description 微信回调参数实体 - */ -public class WeChatNotifyParam { - - /** - * 返回编码 - **/ - private String return_code; - /** - * 返回信息 - **/ - private String return_msg; - /** - * 应用appId - **/ - private String appid; - /** - * 商户mchId - **/ - private String mch_id; - /** - * 设备信息 - **/ - private String device_info; - /** - * 随机字符串 - **/ - private String nonce_str; - /** - * 签名 - **/ - private String sign; - /** - * 支付结果编码 - **/ - private String result_code; - /** - * 支付结果错误编码 - **/ - private String err_code; - /** - * 支付结果错误描述 - **/ - private String err_code_des; - /** - * 微信号唯一标识 - **/ - private String openid; - /** - * 是否关注公众账号 - **/ - private String is_subscribe; - /** - * 交易类型 - **/ - private String trade_type; - /** - * 付款银行 - **/ - private String bank_type; - /** - * 总金额 - **/ - private Integer total_fee; - /** - * 货币种类 - **/ - private String fee_type; - /** - * 现金支付金额 - **/ - private Integer cash_fee; - /** - * 现金支付货币类型 - **/ - private String cash_fee_type; - /** - * 微信支付订单号 - **/ - private String transaction_id; - /** - * 商户订单号 - **/ - private String out_trade_no; - /** - * 商家数据包 - **/ - private String attach; - /** - * 支付完成时间 - **/ - private String time_end; - - public String getReturn_code() { - return return_code; - } - - public void setReturn_code(String return_code) { - this.return_code = return_code; - } - - public String getReturn_msg() { - return return_msg; - } - - public void setReturn_msg(String return_msg) { - this.return_msg = return_msg; - } - - public String getAppid() { - return appid; - } - - public void setAppid(String appid) { - this.appid = appid; - } - - public String getMch_id() { - return mch_id; - } - - public void setMch_id(String mch_id) { - this.mch_id = mch_id; - } - - public String getDevice_info() { - return device_info; - } - - public void setDevice_info(String device_info) { - this.device_info = device_info; - } - - public String getNonce_str() { - return nonce_str; - } - - public void setNonce_str(String nonce_str) { - this.nonce_str = nonce_str; - } - - public String getSign() { - return sign; - } - - public void setSign(String sign) { - this.sign = sign; - } - - public String getResult_code() { - return result_code; - } - - public void setResult_code(String result_code) { - this.result_code = result_code; - } - - public String getErr_code() { - return err_code; - } - - public void setErr_code(String err_code) { - this.err_code = err_code; - } - - public String getErr_code_des() { - return err_code_des; - } - - public void setErr_code_des(String err_code_des) { - this.err_code_des = err_code_des; - } - - public String getOpenid() { - return openid; - } - - public void setOpenid(String openid) { - this.openid = openid; - } - - public String getIs_subscribe() { - return is_subscribe; - } - - public void setIs_subscribe(String is_subscribe) { - this.is_subscribe = is_subscribe; - } - - public String getTrade_type() { - return trade_type; - } - - public void setTrade_type(String trade_type) { - this.trade_type = trade_type; - } - - public String getBank_type() { - return bank_type; - } - - public void setBank_type(String bank_type) { - this.bank_type = bank_type; - } - - public Integer getTotal_fee() { - return total_fee; - } - - public void setTotal_fee(Integer total_fee) { - this.total_fee = total_fee; - } - - public String getFee_type() { - return fee_type; - } - - public void setFee_type(String fee_type) { - this.fee_type = fee_type; - } - - public Integer getCash_fee() { - return cash_fee; - } - - public void setCash_fee(Integer cash_fee) { - this.cash_fee = cash_fee; - } - - public String getCash_fee_type() { - return cash_fee_type; - } - - public void setCash_fee_type(String cash_fee_type) { - this.cash_fee_type = cash_fee_type; - } - - public String getTransaction_id() { - return transaction_id; - } - - public void setTransaction_id(String transaction_id) { - this.transaction_id = transaction_id; - } - - public String getOut_trade_no() { - return out_trade_no; - } - - public void setOut_trade_no(String out_trade_no) { - this.out_trade_no = out_trade_no; - } - - public String getAttach() { - return attach; - } - - public void setAttach(String attach) { - this.attach = attach; - } - - public String getTime_end() { - return time_end; - } - - public void setTime_end(String time_end) { - this.time_end = time_end; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatPayService.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatPayService.java deleted file mode 100644 index 9b0dddaad..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatPayService.java +++ /dev/null @@ -1,199 +0,0 @@ -package com.accompany.payment.wxpay; - -import com.accompany.common.constant.Constant; -import com.accompany.common.utils.DateTimeUtil; -import com.accompany.core.service.SysConfService; -import com.accompany.payment.config.BaseWxPayConfig; -import com.accompany.payment.config.WxPayConfig; -import com.accompany.payment.constant.PayConstant; -import com.google.common.collect.Maps; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Calendar; -import java.util.Date; -import java.util.Map; - -/** - * @author yangming - * @data 2018-10-18 - * @description 微信支付业务处理 - */ -@Service -public class WeChatPayService { - - private static final Logger logger = LoggerFactory.getLogger(WeChatPayService.class); - - private final String WEIXIN_QUERY_URL = "https://api.mch.weixin.qq.com/pay/orderquery"; - - @Autowired - private SysConfService sysConfService; - - /** - * 微信统一下单接口 - * - * @param requestXml - * @return - */ - public String createOrder(BaseWxPayConfig wxPayConfig, String requestXml) { - logger.info("wechat createOrder(),requestXml={}", requestXml); - String requestUrl = wxPayConfig.getUrl(); - String responseXml = HttpUtils.sendPost(requestUrl, requestXml); - logger.info("wechat createOrder(),responseXml={}", responseXml); - return responseXml; - } - - /** - * 构建微信请求参数 - * - * - * @param wxPayConfig - * @param amount - * @param orderNo - * @param subject - * @param body - * @param clientIp - * @return - */ - public Map buildWxRequestMap(BaseWxPayConfig wxPayConfig, Long amount, String orderNo, String subject, String body, String channel, String clientIp) { - - Map map = Maps.newHashMap(); - map.put("appid", wxPayConfig.getAppId()); - map.put("mch_id", wxPayConfig.getMchId()); - map.put("device_info", "WEB"); - map.put("nonce_str", PayUtil.getRandomStringByLength(16)); - map.put("body", body); - map.put("attach", subject); - map.put("out_trade_no", orderNo); - //微信没有沙箱环境,充值1分 - map.put("total_fee", String.valueOf(amount)); - map.put("spbill_create_ip", clientIp); - //TODO 添加回调地址 - map.put("notify_url", wxPayConfig.getNotifyUrl()); - if (Constant.ChargeChannel.wx.equals(channel)) { - map.put("trade_type", PayConstant.WxTradeType.APP); - } else if (Constant.ChargeChannel.wx_wap.equals(channel)) { - map.put("trade_type", PayConstant.WxTradeType.MWEB); - //订单失效时间 - String timeout = sysConfService.getDefaultSysConfValueById(Constant.SysConfId.H5_ORDER_TIMEOUT, "1"); - Date date = DateTimeUtil.getNextMinute(Calendar.getInstance().getTime(), Integer.parseInt(timeout)); - String time = DateTimeUtil.convertDate(date, DateTimeUtil.DEFAULT_DATE_PATTERN__); - map.put("time_expire", time); - } else if (Constant.ChargeChannel.wx_pub.equals(channel)) { - map.put("trade_type", PayConstant.WxTradeType.JSAPI); - } - String sign = WeChatPayUtil.getWeChatSign(map, wxPayConfig); - map.put("sign", sign); - return map; - } - - /** - * 返回给APP端的二次签名 - * - * @param prepayId - * @param nonceStr - * @return - */ - public Map buildAppParamMap(BaseWxPayConfig wxPayConfig, String prepayId, String nonceStr) { - - Map signParam = Maps.newHashMap(); - //app_id - signParam.put("appid", wxPayConfig.getAppId()); - //微信商户账号 - signParam.put("partnerid", wxPayConfig.getMchId()); - //预付订单id - signParam.put("prepayid", prepayId); - //默认sign=WXPay - signParam.put("package", "Sign=WXPay"); - //自定义不重复的长度不长于32位 - signParam.put("noncestr", nonceStr); - //生成时间戳 - long currentTimeMillis = System.currentTimeMillis(); - long second = currentTimeMillis / 1000L; - String seconds = String.valueOf(second).substring(0, 10); - signParam.put("timestamp", seconds); - //再次生成签名 - String signAgain = WeChatPayUtil.getWeChatSign(signParam, wxPayConfig); - signParam.put("sign", signAgain); - return signParam; - } - - public WeChatResultParam convertToObject(Map resultMap) { - - WeChatResultParam weChatResultParam = new WeChatResultParam(); - if (resultMap.get("return_code") != null) { - weChatResultParam.setReturnCode(resultMap.get("return_code").toString()); - } - if (resultMap.get("return_msg") != null) { - weChatResultParam.setReturmMsg(resultMap.get("return_msg").toString()); - } - if (resultMap.get("appid") != null) { - weChatResultParam.setAppId(resultMap.get("appid").toString()); - } - if (resultMap.get("mch_id") != null) { - weChatResultParam.setMchId(resultMap.get("mch_id").toString()); - } - if (resultMap.get("device_info") != null) { - weChatResultParam.setDeviceInfo(resultMap.get("device_info").toString()); - } - if (resultMap.get("nonce_str") != null) { - weChatResultParam.setNonceStr(resultMap.get("nonce_str").toString()); - } - if (resultMap.get("sign") != null) { - weChatResultParam.setSign(resultMap.get("sign").toString()); - } - if (resultMap.get("result_code") != null) { - weChatResultParam.setResultCode(resultMap.get("result_code").toString()); - } - if (resultMap.get("err_code") != null) { - weChatResultParam.setErrCode(resultMap.get("err_code").toString()); - } - if (resultMap.get("err_code_des") != null) { - weChatResultParam.setErrCodeDes(resultMap.get("err_code_des").toString()); - } - if (resultMap.get("trade_type") != null) { - weChatResultParam.setTradeType(resultMap.get("trade_type").toString()); - } - if (resultMap.get("prepay_id") != null) { - weChatResultParam.setPrepayId(resultMap.get("prepay_id").toString()); - } - if (resultMap.get("mweb_url") != null) { - weChatResultParam.setMwebUrl(resultMap.get("mweb_url").toString()); - } - - return weChatResultParam; - } - - /** - * 构建微信查单请求参数 - * - * @param wxPayConfig - * @param orderNo - * @return - */ - public Map buildWxQueryRequestMap(BaseWxPayConfig wxPayConfig, String orderNo){ - Map map = Maps.newHashMap(); - map.put("appid", wxPayConfig.getAppId()); - map.put("mch_id", wxPayConfig.getMchId()); - map.put("nonce_str",PayUtil.getRandomStringByLength(16)); - map.put("out_trade_no",orderNo); - map.put("sign_type", "MD5"); - String sign = WeChatPayUtil.getWeChatSign(map, wxPayConfig); - map.put("sign",sign); - return map; - } - - /** - * 微信订单查询接口 - * @param requestXml - * @return - */ - public String queryOrder(String requestXml){ - logger.info("wechat queryOrder(),requestXml={}",requestXml); - String responseXml = HttpUtils.sendPost(WEIXIN_QUERY_URL, requestXml); - logger.info("wechat queryOrder(),responseXml={}",responseXml); - return responseXml; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatPayUtil.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatPayUtil.java deleted file mode 100644 index c9f064299..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatPayUtil.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.accompany.payment.wxpay; - -import com.accompany.payment.config.BaseWxPayConfig; -import com.accompany.payment.config.WxPayConfig; -import lombok.extern.slf4j.Slf4j; - -import java.util.*; - -/** - * @author yangming - * @date 2018-10-15 - * @description 微信支付通用工具类 - */ -@Slf4j -public class WeChatPayUtil { - - /** - * 微信签名 - * - * @param map - * @return - */ - public static String getWeChatSign(Map map, BaseWxPayConfig wxPayConfig) { - String sign = ""; - try { - // 构造签名键值对的格式 - ArrayList list = new ArrayList(); - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue() != "" && !entry.toString().equals("return_code") && !entry.toString().equals("return_msg") && !entry.toString().equals("result_code")) { - list.add(entry.getKey() + "=" + entry.getValue() + "&"); - } - } - int size = list.size(); - String[] arrayToSort = list.toArray(new String[size]); - Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < size; i++) { - sb.append(arrayToSort[i]); - } - - //拼接商户平台的秘钥 - sb.append("key=").append(wxPayConfig.getApiKey()); - log.info("before MD5 Encode,sign={}", sb.toString()); - sign = MD5.MD5Encode(sb.toString()).toUpperCase(); - log.info("after MD5 Encode,sign={}", sign); - - } catch (Exception e) { - log.error("getWeChatSign(),error={}", e); - } finally { - return sign; - } - } - - /** - * 将参数转化为XML格式 - * - * @param map - * @return - */ - public static String getRequestXml(Map map) { - StringBuffer sb = new StringBuffer(); - sb.append(""); - Set es = map.entrySet(); - Iterator it = es.iterator(); - while (it.hasNext()) { - Map.Entry entry = (Map.Entry) it.next(); - String k = (String) entry.getKey(); - if (entry.getValue() != null && entry.getValue() != "") { - String v = (String) entry.getValue(); - if ("attach".equalsIgnoreCase(k) || "body".equalsIgnoreCase(k)) { - sb.append("<" + k + ">" + ""); - } else { - sb.append("<" + k + ">" + v + ""); - } - } - } - //拼接签名,CDATA标签用于说明数据不被XML解析器解析 - sb.append("<" + "sign" + ">" + ""); - sb.append(""); - return sb.toString(); - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatQueryResultParam.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatQueryResultParam.java deleted file mode 100644 index eeb9c53dc..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatQueryResultParam.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.accompany.payment.wxpay; - -import lombok.Data; -import lombok.ToString; - -/** - * @author yangming - * @date 2018-10-24 - * @description 微信统一下单返回结果实体 - */ -@Data -@ToString -public class WeChatQueryResultParam { - - /**返回编码**/ - private String return_code; - - /**返回信息**/ - private String return_msg; - - /****以下字段在return_code为SUCCESS的时候有返回 **/ - /**应用appId**/ - private String appid; - - /**商户mchId**/ - private String mch_id; - - /** 子商户号 */ - private String sub_mch_id; - - /**随机字符串**/ - private String nonce_str; - - /**签名**/ - private String sign; - - /**支付结果编码**/ - private String result_code; - - /**支付结果错误编码**/ - private String err_code; - - /**支付结果错误描述**/ - private String err_code_des; - - /** 以下字段在return_code 、result_code、trade_state都为SUCCESS时有返回 */ - /** 设备号 */ - private String device_info; - - /**微信号唯一标识**/ - private String openid; - - /**是否关注公众账号**/ - private String is_subscribe; - - /**交易类型**/ - private String trade_type; - - /**交易状态**/ - private String trade_state; - - /**付款银行**/ - private String bank_type; - - private String detail; - - /**总金额**/ - private Integer total_fee; - - /**货币种类**/ - private String fee_type; - - /**现金支付金额**/ - private Integer cash_fee; - - /**现金支付货币类型**/ - private String cash_fee_type; - - /**微信支付订单号**/ - private String transaction_id; - - /**商户订单号**/ - private String out_trade_no; - - /**商家数据包**/ - private String attach; - - /**支付完成时间**/ - private String time_end; - - /** 支付状态描述 */ - private String trade_state_desc; - - -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatResultParam.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatResultParam.java deleted file mode 100644 index 3c2958477..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/WeChatResultParam.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.accompany.payment.wxpay; - -/** - * @author yangming - * @date 2018-10-24 - * @description 微信统一下单返回结果实体 - */ -public class WeChatResultParam { - - private String returnCode; - - private String returmMsg; - - private String appId; - - private String mchId; - - private String deviceInfo; - - private String nonceStr; - - private String sign; - - private String resultCode; - - private String errCode; - - private String errCodeDes; - - private String tradeType; - - private String prepayId; - - private String mwebUrl; - - public String getMwebUrl() { - return mwebUrl; - } - - public void setMwebUrl(String mwebUrl) { - this.mwebUrl = mwebUrl; - } - - public String getReturnCode() { - return returnCode; - } - - public void setReturnCode(String returnCode) { - this.returnCode = returnCode; - } - - public String getReturmMsg() { - return returmMsg; - } - - public void setReturmMsg(String returmMsg) { - this.returmMsg = returmMsg; - } - - public String getAppId() { - return appId; - } - - public void setAppId(String appId) { - this.appId = appId; - } - - public String getMchId() { - return mchId; - } - - public void setMchId(String mchId) { - this.mchId = mchId; - } - - public String getDeviceInfo() { - return deviceInfo; - } - - public void setDeviceInfo(String deviceInfo) { - this.deviceInfo = deviceInfo; - } - - public String getNonceStr() { - return nonceStr; - } - - public void setNonceStr(String nonceStr) { - this.nonceStr = nonceStr; - } - - public String getSign() { - return sign; - } - - public void setSign(String sign) { - this.sign = sign; - } - - public String getResultCode() { - return resultCode; - } - - public void setResultCode(String resultCode) { - this.resultCode = resultCode; - } - - public String getErrCode() { - return errCode; - } - - public void setErrCode(String errCode) { - this.errCode = errCode; - } - - public String getErrCodeDes() { - return errCodeDes; - } - - public void setErrCodeDes(String errCodeDes) { - this.errCodeDes = errCodeDes; - } - - public String getTradeType() { - return tradeType; - } - - public void setTradeType(String tradeType) { - this.tradeType = tradeType; - } - - public String getPrepayId() { - return prepayId; - } - - public void setPrepayId(String prepayId) { - this.prepayId = prepayId; - } -} diff --git a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/XMLParser.java b/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/XMLParser.java deleted file mode 100644 index f60f7893c..000000000 --- a/accompany-base/accompany-payment/src/main/java/com/accompany/payment/wxpay/XMLParser.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.accompany.payment.wxpay; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - - -/** - * User: rizenguo - * Date: 2014/11/1 - * Time: 14:06 - */ -public class XMLParser { - - - /** - * 修复XXE漏洞 - * - * @return - * @throws ParserConfigurationException - */ - private static DocumentBuilderFactory getSafeDocumentBuilderFactory() throws ParserConfigurationException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - String reature = "http://apache.org/xml/features/disallow-doctype-decl"; - factory.setFeature(reature, true); - - // If you can't completely disable DTDs, then at least do the following: - // Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-general-entities - // Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-general-entities - // JDK7+ - http://xml.org/sax/features/external-general-entities - reature = "http://xml.org/sax/features/external-general-entities"; - factory.setFeature(reature, false); - - // Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-parameter-entities - // Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-parameter-entities - // JDK7+ - http://xml.org/sax/features/external-parameter-entities - reature = "http://xml.org/sax/features/external-parameter-entities"; - factory.setFeature(reature, false); - - // Disable external DTDs as well - reature = "http://apache.org/xml/features/nonvalidating/load-external-dtd"; - factory.setFeature(reature, false); - - // and these as well, per Timothy Morgan's 2014 paper: "XML Schema, DTD, and Entity Attacks" - factory.setXIncludeAware(false); - factory.setExpandEntityReferences(false); - - return factory; - } - - public static Map getMapFromXML(String xmlString) throws ParserConfigurationException, IOException, SAXException { - - //这里用Dom的方式解析回包的最主要目的是防止API新增回包字段 - DocumentBuilderFactory factory = XMLParser.getSafeDocumentBuilderFactory(); - DocumentBuilder builder = factory.newDocumentBuilder(); - InputStream is = Util.getStringStream(xmlString); - Document document = builder.parse(is); - - //获取到document里面的全部结点 - NodeList allNodes = document.getFirstChild().getChildNodes(); - Node node; - Map map = new HashMap(); - int i = 0; - while (i < allNodes.getLength()) { - node = allNodes.item(i); - if (node instanceof Element) { - map.put(node.getNodeName(), node.getTextContent()); - } - i++; - } - return map; - - } - - - public static String getXMLFromMap(Map map) throws Exception { - StringBuffer sb = new StringBuffer(); - sb.append(""); - - Set set = map.keySet(); - Iterator it = set.iterator(); - while (it.hasNext()) { - String key = it.next(); - sb.append("<" + key + ">").append(map.get(key)).append(""); - } - - sb.append(""); - return sb.toString(); - } - - -} \ No newline at end of file diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/event/listener/CloseAuditAudioRoomListener.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/event/listener/CloseAuditAudioRoomListener.java deleted file mode 100644 index 3d1ae2d9a..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/event/listener/CloseAuditAudioRoomListener.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.accompany.business.event.listener; - -import com.accompany.business.event.RoomCloseEvent; -import com.accompany.business.model.AuditAudioRoom; -import com.accompany.core.model.Room; -import com.accompany.business.service.auditaudio.AuditAudioRoomService; -import com.accompany.core.service.common.JedisService; -import com.accompany.core.util.StringUtils; -import com.google.gson.Gson; -import com.accompany.common.redis.RedisKey; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationListener; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - -/** - * 关闭房间音频审核 - * 2 * @Author: zhuct - * 3 * @Date: 2019/8/26 10:23 - * 4 - */ -//@Component -public class CloseAuditAudioRoomListener implements ApplicationListener { - - private static final transient Logger logger = LoggerFactory.getLogger(CloseAuditAudioRoomListener.class); - - @Autowired - private AuditAudioRoomService auditAudioRoomService; - @Autowired - private JedisService jedisService; - private Gson gson = new Gson(); - - @Override - @Async - public void onApplicationEvent(RoomCloseEvent event) { - Room room = (Room) event.getSource(); - Long roomUid = room.getUid(); - String jsonStr = jedisService.hget(RedisKey.audit_audio_room.getKey(), roomUid.toString()); - if (StringUtils.isNotBlank(jsonStr)) {//如果房间在审核,则关闭房间 - auditAudioRoomService.closeAuditAudioRoom(gson.fromJson(jsonStr, AuditAudioRoom.class)); - } - - } -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/event/listener/SendAuditAudioRoomListener.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/event/listener/SendAuditAudioRoomListener.java deleted file mode 100644 index 56361f3b5..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/event/listener/SendAuditAudioRoomListener.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.accompany.business.event.listener; - -import com.accompany.business.event.RoomOpenEvent; -import com.accompany.core.model.Room; -import com.accompany.business.service.auditaudio.AuditAudioRoomService; -import com.accompany.core.service.common.JedisService; -import com.accompany.business.service.room.RoomService; -import com.accompany.common.constant.RoomMonitorTypeEnum; -import com.accompany.common.redis.RedisKey; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationListener; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - -/** - * 发房间音频审核 - * 2 * @Author: zhuct - * 3 * @Date: 2019/8/26 10:23 - * 4 - */ -//@Component -public class SendAuditAudioRoomListener implements ApplicationListener { - - private static final transient Logger logger = LoggerFactory.getLogger(SendAuditAudioRoomListener.class); - - @Autowired - private AuditAudioRoomService auditAudioRoomService; - @Autowired - private JedisService jedisService; - @Autowired - private RoomService roomService; - - @Override - @Async - public void onApplicationEvent(RoomOpenEvent event) { - Room room = (Room) event.getSource(); - Long roomUid = room.getUid(); - Integer monitorType = auditAudioRoomService.getRoomMonitorType(); - if (monitorType == null) { - return; - } - if (monitorType == RoomMonitorTypeEnum.GIVEN_ROOM.getValue()) { - if (jedisService.sismember(RedisKey.given_audit_audio_room.getKey(), roomUid.toString())) {//如果改房间是指定送审房间 - auditAudioRoomService.sendAuditRoom(room, RoomMonitorTypeEnum.GIVEN_ROOM.getValue()); - } - - } else if (monitorType == RoomMonitorTypeEnum.ALL_ROOM.getValue()) {//如果是全部房间都送审,则直接送审 - auditAudioRoomService.sendAuditRoom(room, RoomMonitorTypeEnum.ALL_ROOM.getValue()); - } - } -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/event/listener/UserRegisterSuccessListener.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/event/listener/UserRegisterSuccessListener.java deleted file mode 100644 index 0026e7020..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/event/listener/UserRegisterSuccessListener.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.accompany.business.event.listener; - -import com.accompany.business.service.observe.BiliObserveRecordService; -import com.accompany.core.model.Account; -import com.google.gson.Gson; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * 用户注册成功处理 - */ -@Component -public class UserRegisterSuccessListener { - - private static final Logger logger = LoggerFactory.getLogger(UserRegisterSuccessListener.class); - - private Gson gson = new Gson(); - - @Autowired - private BiliObserveRecordService biliObserveRecordService; - - public void onApplicationEvent(String data) { - logger.info("UserRegisterSuccessListener start =============="); - Account account = gson.fromJson(data, Account.class); - logger.info("UserRegisterSuccessListener account:{} ==============", account.getUid()); - - // B站注册通知 - biliObserveRecordService.handle(account); - - logger.info("UserRegisterSuccessListener end =============="); - } -} \ No newline at end of file diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/AppPictureService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/AppPictureService.java deleted file mode 100644 index ab79ffcdf..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/AppPictureService.java +++ /dev/null @@ -1,311 +0,0 @@ -package com.accompany.business.service; - -import com.accompany.business.model.AdminPicture; -import com.accompany.business.model.AdminPictureExample; -import com.accompany.business.mybatismapper.AdminPictureMapper; -import com.accompany.business.service.api.QinniuService; -import com.accompany.business.util.PictureUtil; -import com.accompany.business.util.ReplaceDomainUtil; -import com.accompany.common.constant.Constant; -import com.accompany.common.utils.BlankUtil; -import org.apache.commons.collections.CollectionUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import javax.imageio.ImageIO; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.List; - -/** - * Created by liuyang on 2019/2/21. - */ -@Service("pictureService") -public class AppPictureService { - private static final Logger logger = LoggerFactory.getLogger(AppPictureService.class); - @Autowired - private AdminPictureMapper pictureMapper; - - @Autowired - private QinniuService qinniuService; - - /* 要放置的头像半径 */ - public static final int AVATAR_SIZE = 130; - private static final int SIGN_AVATAR_SIZE = 84;//签到分享的头像半径 - /* 要放置的头像y坐标 */ - private static final int AVATAR_Y = 220; - - /** - * 合成分享图片 - * - * @param - * @return - */ - public String getShareImgUrl(String avatar, Long erbanNo, String nick, Integer gameResult,String app,String accessUrl,String bucket) { - AdminPictureExample example = new AdminPictureExample(); - example.createCriteria().andGameResultTypeEqualTo(gameResult).andTypeEqualTo(1).andStateEqualTo(1).andAppIdEqualTo(app); - List adminPictures = pictureMapper.selectByExample(example); - AdminPicture adminPicture = adminPictures.get(0); - String imgUrl = adminPicture.getImgUrl(); - String url = buildSharePic(avatar, erbanNo, nick, imgUrl,accessUrl,bucket); - return url; - } - - - private String buildSharePic(String avatar, Long erbanNo, String nick, String imgUrl,String accessUrl,String bucket) { - logger.info("buildSharePic avatar:{},erbanNo:{},nick:{},imgUrl:{}", avatar, erbanNo, nick, imgUrl); - URL url; - String picUrl = ""; - InputStream is = null; - ByteArrayOutputStream os = null; - try { - url = new URL(imgUrl); - BufferedImage image = ImageIO.read(url); - - //裁剪为圆形头像 - BufferedImage roundedImage = PictureUtil.createRoundedImage(avatar, AVATAR_SIZE); - //合并模板,头像,昵称,平台号 - if (nick.length() > 8) { - nick = nick.substring(0, 8) + "..."; - } - BufferedImage mergeImage = mergePicture(image, roundedImage, nick, erbanNo); - os = new ByteArrayOutputStream(); - ImageIO.write(mergeImage, "png", os); - is = new ByteArrayInputStream(os.toByteArray()); - - try { - String filepath = qinniuService.uploadUnInterceptByStream(is,bucket); - if (!BlankUtil.isBlank(filepath)) { - picUrl = qinniuService.mergeUrlAndSlim(filepath,accessUrl); - } - } catch (Exception e) { - logger.error("图片上传失败: e:{}", e); - } - } catch (Exception e) { - logger.error("buildSharePic error avatar:{},erbanNo:{},nick:{},imgUrl:{}", avatar, erbanNo, nick, imgUrl); - e.printStackTrace(); - } finally { - try { - if (is != null) { - is.close(); - } - if (os != null) { - os.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - return picUrl; - } - - /** - * 合并头像和昵称 - * - * @param baseImage the base image - * @param topImage the top image - * @return the buffered image - * @throws Exception the exception - */ - public static BufferedImage mergePicture(BufferedImage baseImage, BufferedImage topImage, String nickName, Long erbanNo) throws IOException { - int width = baseImage.getWidth(null); //底图的宽度 - int height = baseImage.getHeight(null); //底图的高度 - System.out.println("底图的宽度 :" + width + ", 底图的高度" + height); - // 按照底图的宽高生成新的图片 - BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - Graphics g = image.createGraphics(); - g.drawImage(baseImage, 0, 0, width, height, null); - - int smallWidth = topImage.getWidth(null); // 上层图片的宽度 - // 设置上层图片放置的位置的坐标及大小 - g.drawImage(topImage, 155, 514, AVATAR_SIZE, AVATAR_SIZE, null); - - // 普通字体 - // 昵称长度和放置的位置 - Font font = new Font("微软雅黑", Font.BOLD, 30); - g.setFont(font); - g.setColor(new Color(68, 68, 68)); - FontMetrics fm = g.getFontMetrics(font); - g.drawString(nickName, 315, 565); - - //平台号长度和位置 - // 普通字体 - Font font2 = new Font("微软雅黑", Font.PLAIN, 22); - g.setFont(font2); - g.setColor(new Color(105, 105, 105)); - g.drawString("ID: " + erbanNo, 315, 610); - - - g.dispose(); - - return image; - } - - - private AdminPicture getAdminPictureByType(Integer pictureType,String app) { - AdminPictureExample example = new AdminPictureExample(); - example.createCriteria().andTypeEqualTo(pictureType).andStateEqualTo(Constant.PictureStatus.ENABLE).andAppIdEqualTo(app); - List adminPictures = pictureMapper.selectByExample(example); - return CollectionUtils.isNotEmpty(adminPictures) ? adminPictures.get(0) : null; - } - - public String getSignShareImage(Long erbanNo, String avatar, String nick, String day, String reward, Integer shareType, - String app,String accessUrl,String bucket) { - AdminPicture adminPicture = this.getAdminPictureByType(Constant.PictureType.SIGN_SHARE,app); - if (adminPicture == null) { - return null; - } - return this.buildSignShareImage(erbanNo, avatar, nick, day, reward, adminPicture.getImgUrl(), shareType,accessUrl,bucket); - } - - private String buildSignShareImage(Long erbanNo, String avatar, String nick, String day, String reward, String imgUrl, - Integer shareType,String accessUrl,String bucket) { - logger.info("buildSignShareImage avatar:{},erbanNo:{},nick:{},imgUrl:{},shareType:{},day:{},reward:{}", - avatar, erbanNo, nick, imgUrl, shareType, day, reward); - URL url; - String picUrl = ""; - InputStream is = null; - ByteArrayOutputStream os = null; - try { - url = new URL(imgUrl); - BufferedImage image = ImageIO.read(url); - - //裁剪为圆形头像 - BufferedImage roundedImage = PictureUtil.createRoundedImage(avatar, SIGN_AVATAR_SIZE); - //合并模板 - BufferedImage mergeImage = this.mergeSignPicture(erbanNo, nick, day, reward, image, roundedImage, shareType); - os = new ByteArrayOutputStream(); - ImageIO.write(mergeImage, "png", os); - is = new ByteArrayInputStream(os.toByteArray()); - - try { - String filepath = qinniuService.uploadUnInterceptByStream(is,bucket); - if (!BlankUtil.isBlank(filepath)) { - picUrl = qinniuService.mergeUrlAndSlim(filepath,accessUrl); - } - } catch (Exception e) { - logger.error("图片上传失败: e:{}", e); - } - } catch (Exception e) { - logger.error("buildSignShareImage error avatar:{},erbanNo:{},nick:{},imgUrl:{}", avatar, erbanNo, nick, imgUrl); - e.printStackTrace(); - } finally { - try { - if (is != null) { - is.close(); - } - if (os != null) { - os.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - return picUrl; - } - - private BufferedImage mergeSignPicture(Long erbanNo, String nick, String day, String reward, BufferedImage baseImage, - BufferedImage topImage, Integer shareType) { - int width = baseImage.getWidth(null); //底图的宽度 - int height = baseImage.getHeight(null); //底图的高度 - - // 按照底图的宽高生成新的图片 - BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - Graphics g = image.createGraphics(); - g.drawImage(baseImage, 0, 0, width, height, null); - - int smallWidth = topImage.getWidth(null); // 上层图片的宽度 - // 设置上层图片放置的位置的坐标及大小 - g.drawImage(topImage, 140, 502, SIGN_AVATAR_SIZE, SIGN_AVATAR_SIZE, null); - - // 普通字体 - // 昵称长度和放置的位置 - Font font = new Font("微软雅黑", Font.PLAIN, 34); - g.setFont(font); - g.setColor(new Color(255, 247, 38)); - g.drawString(nick, 262, 530); - - //平台号长度和位置 - // 普通字体 - Font font2 = new Font("微软雅黑", Font.PLAIN, 24); - g.setFont(font2); - g.setColor(new Color(255, 255, 255)); - g.drawString("ID:" + erbanNo, 262, 580); - - - if (Constant.SignShareType.COMMON == shareType) {//普通分享 - Font font3 = new Font("微软雅黑", Font.PLAIN, 28); - g.setFont(font3); - g.setColor(new Color(155, 72, 255)); - g.drawString("听说签到可以赚金币", 162, 688); - - Font font4 = new Font("微软雅黑", Font.PLAIN, 28); - g.setFont(font4); - g.setColor(new Color(255, 56, 82)); - g.drawString("赚金币", 444, 688); - - Font font5 = new Font("微软雅黑", Font.PLAIN, 28); - g.setFont(font5); - g.setColor(new Color(155, 72, 255)); - g.drawString("不能让我一个人独享,", 162, 728); - - } else if (Constant.SignShareType.RECEIVE_GIFT == shareType) {//领取礼物 - Font font3 = new Font("微软雅黑", Font.PLAIN, 28); - g.setFont(font3); - g.setColor(new Color(155, 72, 255)); - g.drawString("我累计签到", 162, 688); - - Font font4 = new Font("微软雅黑", Font.PLAIN, 28); - g.setFont(font4); - g.setColor(new Color(255, 56, 82)); - g.drawString(day, 444, 688); - - Font font5 = new Font("微软雅黑", Font.PLAIN, 28); - g.setFont(font5); - g.setColor(new Color(155, 72, 255)); - g.drawString("获得", 162, 728); - - Font font6 = new Font("微软雅黑", Font.PLAIN, 28); - g.setFont(font6); - g.setColor(new Color(255, 56, 82)); - g.drawString(reward, 222, 728); - } else if (Constant.SignShareType.DRAW_GOLD == shareType) {//瓜分金币 - Font font3 = new Font("微软雅黑", Font.PLAIN, 28); - g.setFont(font3); - g.setColor(new Color(155, 72, 255)); - g.drawString("我累计签到", 162, 688); - - Font font4 = new Font("微软雅黑", Font.PLAIN, 28); - g.setFont(font4); - g.setColor(new Color(255, 56, 82)); - g.drawString(day, 444, 688); - - Font font5 = new Font("微软雅黑", Font.PLAIN, 28); - g.setFont(font5); - g.setColor(new Color(155, 72, 255)); - g.drawString("瓜分了", 162, 728); - - Font font6 = new Font("微软雅黑", Font.PLAIN, 28); - g.setFont(font6); - g.setColor(new Color(255, 56, 82)); - g.drawString(reward, 246, 728); - - } - Font font7 = new Font("微软雅黑", Font.PLAIN, 28); - g.setFont(font7); - g.setColor(new Color(155, 72, 255)); - g.drawString("宝贝快来和我一起发家致富呀~~", 162, 764); - - g.dispose(); - - return image; - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/AutoGenRobotService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/AutoGenRobotService.java index e7fd05e4f..2acdc9877 100644 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/AutoGenRobotService.java +++ b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/AutoGenRobotService.java @@ -8,7 +8,6 @@ import com.accompany.business.mybatismapper.AutoGenRobotMapper; import com.accompany.business.mybatismapper.GenAccountRecordMapper; import com.accompany.business.service.random.RandomNickService; import com.accompany.business.service.user.UsersService; -import com.accompany.business.util.MD5; import com.accompany.common.constant.Constant; import com.accompany.common.netease.neteaseacc.result.FileUploadRet; import com.accompany.common.netease.neteaseacc.result.TokenRet; @@ -26,6 +25,7 @@ import com.accompany.core.service.account.ErBanNoService; import com.accompany.core.service.account.NetEaseService; import com.accompany.core.service.base.BaseService; import com.accompany.core.util.KeyStore; +import com.accompany.core.util.MD5; import com.accompany.core.util.StringUtils; import com.xuanyin.gamematch.constants.GamePlatformEnum; import com.xuanyin.gamematch.model.GameManageRobotNick; diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/ChargeService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/ChargeService.java index c15f237ad..6bf722eb3 100644 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/ChargeService.java +++ b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/ChargeService.java @@ -22,12 +22,10 @@ import com.accompany.business.service.vip.VipMessageService; import com.accompany.business.util.VipUtil; import com.accompany.core.vo.vip.VipBaseInfoVO; import com.accompany.common.constant.Constant; -import com.accompany.common.constant.WeXinPayTypeEnum; import com.accompany.common.exception.ApiException; import com.accompany.common.device.DeviceInfo; import com.accompany.common.exception.BusinessException; import com.accompany.common.redis.RedisKey; -import com.accompany.common.result.BusiResult; import com.accompany.common.status.BusiStatus; import com.accompany.common.utils.MoneyUtil; import com.accompany.common.utils.UUIDUitl; @@ -50,9 +48,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.math.NumberUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; -import org.springframework.core.Constants; import org.springframework.core.task.TaskExecutor; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -75,8 +71,6 @@ public class ChargeService extends BaseService { @Autowired private UsersService usersService; @Autowired - private ChargeCheckService chargeCheckService; - @Autowired private PayCenterService payCenterService; @Autowired private BankCardSignService bankCardSignService; @@ -97,14 +91,10 @@ public class ChargeService extends BaseService { @Autowired private SysConfService sysConfService; @Autowired - private ChargeRecordService chargeRecordService; - @Autowired private LuckyTarotRecordService luckyTarotRecordService; @Autowired private LuckyTarotChargeService luckyTarotChargeService; @Autowired - private UsersBaseService usersBaseService; - @Autowired private UserVipRecordService userVipRecordService; @Autowired private VipAuthItemBizService vipAuthItemBizService; @@ -488,62 +478,6 @@ public class ChargeService extends BaseService { } } - /** - * 微信內部支付方式 - * - * @return WeXinPayTypeEnum - */ - public String wxpayType(DeviceInfo deviceInfo) { - // 沒有配置或者配置信息不在候選列表則走 app 支付 - return Optional.ofNullable(sysConfService.getSysConfValueById(Constant.SysConfId.WX_PAY_INNER_TYPE)) - .map(x -> Arrays.stream(WeXinPayTypeEnum.values()) - .filter(y -> y.name().equals(x.toUpperCase())) - .findAny().orElse(WeXinPayTypeEnum.APP)).get().name(); -// if (!AppUtils.isYinyouApp(deviceInfo)) { -// return WeXinPayTypeEnum.APP.name(); -// } else { -// -// } - } - - /** - * 充值業務回調處理 - * - * @param orderNo 訂單號 - * @param otherNo 第三方訂單號 - */ - @Async - public void payCallbackDo(String orderNo, String otherNo) { - String lockResult = null; - try { - // 加鎖邏輯 - int waitSecondTime = 10; - lockResult = - jedisLockService.lock(RedisKey.lock_pay_callback_notify.getKey(orderNo), waitSecondTime * 1000); - if (org.apache.commons.lang3.StringUtils.isEmpty(lockResult)) { - log.warn("订单 {} 处理中,请稍候", orderNo); - return; - } - ChargeRecord chargeRecord = chargeRecordService.getChargeRecordById(orderNo); - if (chargeRecord.getChargeStatus().equals(Constant.ChargeRecordStatus.finish)) { - log.warn("{} 订单已经处理完成", otherNo); - return; - } - - chargeRecord.setPingxxChargeId(otherNo); - chargeRecord.setUpdateTime(Calendar.getInstance().getTime()); - chargeRecordService.updateChargeRecord(chargeRecord); - updateAppPayData(chargeRecord); - } catch (Exception e) { - log.error("回调处理用户钱包和账单记录异常", e); - throw new BusinessException("回調處理用戶錢包和賬單記錄異常", e); - } finally { - if (org.apache.commons.lang3.StringUtils.isNotBlank(lockResult)) { - jedisLockService.unlock(RedisKey.lock_pay_callback_notify.getKey(orderNo), lockResult); - } - } - } - /** * 幸運塔羅充值業務處理 * diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/WXOrderQueryService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/WXOrderQueryService.java deleted file mode 100644 index e6000e757..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/WXOrderQueryService.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.accompany.business.service; - -import com.accompany.business.service.wx.WxService; -import com.accompany.common.result.BusiResult; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * Created by 北岭山下 on 2017/7/24. - */ -/* - 微信订单查询 - - - - wx2421b1c4370ec43b - 10000100 - ec2316275641faa3aacf3cc599e8730f - 1008450740201411110005820873 - FDD167FAA73459FD921B144BAF4F4CA2 - - - - */ -@Service -public class WXOrderQueryService { - - - - @Autowired - WxService wxService; - - - /** - * 查询订单结果 - * @param outTradeNo 商品订单号 - * @return 订单查询结果 - */ - public BusiResult getWXOrder(String outTradeNo){ - -/* - Map map = new HashMap <> ( ); - map.put ( "appid" ,appid); - map.put ( "mch_id", ); - map.put ( "nonce_str", ); - map.put ( "transaction_id", ); - map.put ( "sign", );*/ - - return null; - - - - - - - - } - - - - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/api/WxpayService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/api/WxpayService.java deleted file mode 100644 index 40692b226..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/api/WxpayService.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.accompany.business.service.api; - - -import com.accompany.common.wx.MD5; -import com.accompany.core.model.Users; -import com.accompany.core.service.base.BaseService; -import org.springframework.stereotype.Service; - -import java.util.*; - -/** - * 微信支付 - */ -@Service -public class WxpayService extends BaseService { - // 统一下单接口 - private static final String API_UNIFIED_ORDER ="https://api.mch.weixin.qq.com/pay/unifiedorder"; - - private static final String API_KEY = "6475328bc85411e793637cd30abdabb2"; - private static final String MCH_ID = "1484534822"; // 商户ID - private static final String APPID = "wx9a8220001aa6c5c9"; // 应用ID - - - /** - * 统一下单接口 - * - * @param body - * @param outTradeNo - * @param totalFee - * @param spbillCreateIp - */ - public void createPreOrder(String body, String outTradeNo,String totalFee,String spbillCreateIp){ - - } - - /** - * 生成一个随机字符串 - * - * @return - */ - private String generRandomStr() { - Random random = new Random(); - return random.nextInt(999999999) + ""; - } - - /** - * 生成签名 - * - * @param characterEncoding - * @param parameters - * @return - */ - public static String createSign(String characterEncoding,SortedMap parameters) { - StringBuffer sb = new StringBuffer(); - Set es = parameters.entrySet(); - Iterator it = es.iterator(); - while (it.hasNext()) { - Map.Entry entry = (Map.Entry) it.next(); - String k = (String) entry.getKey(); - Object v = entry.getValue(); - if (null != v && !"".equals(v) && !"sign".equals(k) && !"key".equals(k)) { - sb.append(k + "=" + v + "&"); - } - } - sb.append("key=" + API_KEY); - String sign = MD5.MD5Encode(sb.toString(), characterEncoding).toUpperCase(); - return sign; - } - - /** - * 将请求参数转换成xml的字符串 - * - * @param parameters - * @return - */ - public String getRequestXml(SortedMap parameters) { - StringBuffer sb = new StringBuffer(); - sb.append(""); - Set es = parameters.entrySet(); - Iterator it = es.iterator(); - while (it.hasNext()) { - Map.Entry entry = (Map.Entry) it.next(); - String k = (String) entry.getKey(); - String v = (String) entry.getValue(); - if ("attach".equalsIgnoreCase(k) || "body".equalsIgnoreCase(k)|| "sign".equalsIgnoreCase(k)) { - sb.append("<" + k + ">" + ""); - } else { - sb.append("<" + k + ">" + v + ""); - } - } - sb.append(""); - return sb.toString(); - } - - public static void business(String[] args) { - - Users users = new Users(); - - WxpayService wxpayService = new WxpayService(); - - for (int i = 0; i < 20; i++) { - System.out.println(wxpayService.generRandomStr()); - } - } -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/auditaudio/AuditAudioRoomService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/auditaudio/AuditAudioRoomService.java deleted file mode 100644 index e03827702..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/auditaudio/AuditAudioRoomService.java +++ /dev/null @@ -1,202 +0,0 @@ -package com.accompany.business.service.auditaudio; - -import com.accompany.business.apppay.util.HttpResponse; -import com.accompany.business.model.AuditAudioRoom; -import com.accompany.business.model.AuditAudioRoomExample; -import com.accompany.business.mybatismapper.AuditAudioRoomMapper; -import com.accompany.business.service.room.RoomService; -import com.accompany.business.vo.RunningRoomVo; -import com.accompany.business.vo.auditaudio.AuditAudioBaseRetVo; -import com.accompany.business.vo.auditaudio.AuditAudioListRetVo; -import com.accompany.common.config.AuditMediaConfig; -import com.accompany.common.constant.Constant; -import com.accompany.common.constant.RoomMonitorTypeEnum; -import com.accompany.common.redis.RedisKey; -import com.accompany.common.utils.UUIDUitl; -import com.accompany.core.model.Room; -import com.accompany.core.service.base.BaseService; -import com.accompany.core.util.StringUtils; -import com.beust.jcommander.internal.Maps; -import org.apache.commons.collections.CollectionUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.task.TaskExecutor; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; - -/** - * 2 * @Author: zhuct - * 3 * @Date: 2019/8/20 18:08 - * 4 - */ -@Service -public class AuditAudioRoomService extends BaseService { - @Autowired - private AuditAudioRoomMapper auditAudioRoomMapper; - @Resource(name = "bizExecutor") - private TaskExecutor bizExecutor; - @Autowired - private RoomService roomService; - - - /** - * 发送音频流房间检查请求 - * - * @param roomUid - * @param roomId - * @return - * @throws Exception - */ - public AuditAudioBaseRetVo sendAuditMediaRoom(Long roomUid, Long roomId) throws Exception { - Map param = Maps.newHashMap(); - param.put("accessKey", AuditMediaConfig.accessKey); - param.put("type", "POLITICAL_PORN_MOAN_AD"); - param.put("btid", UUIDUitl.get()); - param.put("callback",AuditMediaConfig.callBackUrl); - Map dataParam = Maps.newHashMap(); - dataParam.put("streamType", "AGORA"); - dataParam.put("room", roomUid.toString()); - dataParam.put("returnAllText", true); - dataParam.put("returnPreText", true); - dataParam.put("returnPreAudio", true); - dataParam.put("tokenId", roomUid.toString()); - dataParam.put("channel", "VOICE_ROOM"); - Map agoraParam = Maps.newHashMap(); - param.put("data", dataParam); - agoraParam.put("appId",AuditMediaConfig.appId); - agoraParam.put("channel", roomId.toString()); - agoraParam.put("isMixingEnabled", true); - dataParam.put("agoraParam", agoraParam); - logger.info("sendAuditMediaRoomApi request: {}", gson.toJson(param)); - String response = HttpResponse.post(gson.toJson(param), AuditMediaConfig.url); - AuditAudioBaseRetVo auditMediaRet = gson.fromJson(response, AuditAudioBaseRetVo.class); - logger.info("sendAuditMediaRoomApi response: {}", gson.toJson(auditMediaRet)); - return auditMediaRet; - } - - - /** - * 查询正在处理的音频流 - * - * @return - * @throws Exception - */ - public AuditAudioListRetVo getAuditMedia() throws Exception { - Map param = Maps.newHashMap(); - param.put("accessKey", AuditMediaConfig.accessKey); - logger.info("getAuditMedia request: {}", gson.toJson(param)); - String response = HttpResponse.post(gson.toJson(param), AuditMediaConfig.queryUrl); - AuditAudioListRetVo auditMediaRet = gson.fromJson(response, AuditAudioListRetVo.class); - logger.info("getAuditMedia response: {}", gson.toJson(auditMediaRet)); - return auditMediaRet; - } - - - /** - * 关闭音频流检查 - * - * @return - * @throws Exception - */ - public AuditAudioBaseRetVo closeAuditMedia(String requestId) throws Exception { - Map param = Maps.newHashMap(); - param.put("accessKey", AuditMediaConfig.accessKey); - param.put("requestId", requestId); - logger.info("closeAuditMedia request: {}", gson.toJson(param)); - String response = HttpResponse.post(gson.toJson(param), AuditMediaConfig.closeUrl); - AuditAudioBaseRetVo auditMediaRet = gson.fromJson(response, AuditAudioBaseRetVo.class); - logger.info("closeAuditMedia response: {}", gson.toJson(auditMediaRet)); - return auditMediaRet; - } - - public Integer getRoomMonitorType() { - String typeStr = jedisService.get(RedisKey.room_monitor_type.getKey()); - return StringUtils.isNotBlank(typeStr) ? Integer.valueOf(typeStr) : null; - - } - - public List getAuditAudioRoomList() { - AuditAudioRoomExample example = new AuditAudioRoomExample(); - example.createCriteria().andStatusEqualTo(Constant.AuditRoomStatus.invalid); - List rooms = auditAudioRoomMapper.selectByExample(example); - return CollectionUtils.isEmpty(rooms) ? Collections.emptyList() : rooms; - } - - private AuditAudioRoom addAuditAudioRoom(Long roomUid, Byte monitorType, String requestId) { - AuditAudioRoom audioRoom = new AuditAudioRoom(); - audioRoom.setRoomUid(roomUid); - audioRoom.setRequestId(requestId); - audioRoom.setStatus(Constant.AuditRoomStatus.invalid); - audioRoom.setMonitorType(monitorType); - audioRoom.setCreateTime(new Date()); - audioRoom.setUpdateTime(new Date()); - auditAudioRoomMapper.insert(audioRoom); - return audioRoom; - } - - public void sendAuditOnlineRoom() { - Map map = jedisService.hgetAll(RedisKey.room_running.getKey()); - if (map == null || map.size() == 0) { - return; - } - //获取公聊大厅uid,不送审公聊大厅 - for (String key : map.keySet()) { - RunningRoomVo runningRoomVo = gson.fromJson(map.get(key), RunningRoomVo.class); - if (runningRoomVo != null && runningRoomVo.getOnlineNum() != 0) { - Room room = roomService.getRoomByUid(Long.valueOf(key)); - sendAuditRoom(room, RoomMonitorTypeEnum.ALL_ROOM.getValue()); - } - } - - } - - public void sendAuditRoom(Room room, Byte monitorType) { - if(room == null){ - return; - } - Long roomUid = room.getUid(); - logger.info("sendAuditRoom roomUid={},monitorType={}", roomUid, monitorType); - bizExecutor.execute(() -> { - //判断是否已经被送审 - String jsonStr = jedisService.hget(RedisKey.audit_audio_room.getKey(), roomUid.toString()); - if (StringUtils.isNotBlank(jsonStr)) { - logger.warn("this room has been sent for audit,roomUid={}", roomUid); - return; - } - try { - AuditAudioBaseRetVo mediaRetVo = this.sendAuditMediaRoom(roomUid, room.getRoomId()); - if (mediaRetVo.getCode() == 1100) { - AuditAudioRoom audioRoom = this.addAuditAudioRoom(room.getUid(), monitorType, mediaRetVo.getRequestId()); - jedisService.hset(RedisKey.audit_audio_room.getKey(), room.getUid().toString(), gson.toJson(audioRoom)); - } - } catch (Exception e) { - logger.error("sendAuditMediaRoom error cause by:", e.getMessage()); - } - - }); - } - - public void closeAuditAudioRoom(AuditAudioRoom room) { - logger.info("sendAuditRoom room={}", gson.toJson(room)); - bizExecutor.execute(() -> { - try { - AuditAudioBaseRetVo auditMedia = this.closeAuditMedia(room.getRequestId()); - if (auditMedia.getCode() == 1100) { - room.setUpdateTime(new Date()); - room.setStatus(Constant.AuditRoomStatus.valid); - auditAudioRoomMapper.updateByPrimaryKeySelective(room); - jedisService.hdel(RedisKey.audit_audio_room.getKey(), room.getRoomUid().toString()); - } - } catch (Exception e) { - logger.error("closeAuditMedia error cause by:", e.getMessage()); - } - }); - - } - - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/auditaudio/AuditAudioService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/auditaudio/AuditAudioService.java deleted file mode 100644 index 731a0957b..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/auditaudio/AuditAudioService.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.accompany.business.service.auditaudio; - -import com.accompany.business.constant.AuditAudioResultEnum; -import com.accompany.business.constant.RiskLevelEnum; -import com.accompany.business.constant.RiskTypeEnum; -import com.accompany.business.mongodb.DAO.auditaudio.AuditAudioDAO; -import com.accompany.business.mongodb.document.auditaudio.AuditAudio; -import com.accompany.business.param.neteasepush.NeteaseSendMsgParam; -import com.accompany.business.service.SendSysMsgService; -import com.accompany.business.service.user.UsersService; -import com.accompany.common.config.SystemConfig; -import com.accompany.common.redis.RedisKey; -import com.accompany.common.status.BusiStatus; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.model.Users; -import com.accompany.core.service.base.BaseService; -import com.alibaba.fastjson.JSONObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.task.TaskExecutor; -import org.springframework.data.mongodb.core.query.Criteria; -import org.springframework.data.mongodb.core.query.Query; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.time.format.DateTimeFormatter; - -/** - * 2 * @Author: zhuct - * 3 * @Date: 2019/8/16 11:45 - * 4 - */ -@Service -public class AuditAudioService extends BaseService { - - @Autowired - private AuditAudioDAO auditAudioDAO; - @Autowired - private UsersService usersService; - @Resource(name = "bizExecutor") - private TaskExecutor bizExecutor; - @Autowired - private SendSysMsgService sendSysMsgService; - - private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - private final String msg = "根据系统检测,您的语音房间出现违规行为,包含%s内容,现对您做出%s处理"; - - - /** - * 音频处理 - * - * @param auditAudio - * @throws Exception - */ - public void handleAudio(AuditAudio auditAudio) throws Exception { - logger.info("handleAudio with auditAudio={}", JSONObject.toJSONString(auditAudio)); - if (auditAudio.getRiskLevel() == RiskLevelEnum.PASS.getValue()) {//如果是正常,则不处理 - return; - } - Long roomUid = auditAudio.getRoomUid(); - Users users = usersService.getUsersByUid(roomUid); - if (users == null) { - throw new ServiceException(BusiStatus.USERNOTEXISTS); - } - if (auditAudio.getRiskLevel() == RiskLevelEnum.REJECT.getValue()) {//如果是违规音频 - //数美判断违规,给予警告处理 - this.sendAuditAudioMsg(roomUid.toString(), RiskTypeEnum.get(auditAudio.getRiskType()).getDesc(), AuditAudioResultEnum.WARN.getDesc()); - jedisService.zincrby(RedisKey.reject_audio_count.getKey(), 1d,roomUid.toString());//违规次数加一 - auditAudio.setSystemAuditResult(AuditAudioResultEnum.WARN.getValue()); - auditAudio.setUpdateTime(System.currentTimeMillis()); - auditAudioDAO.save(auditAudio);//保存音频记录 - } else if (auditAudio.getRiskLevel() == RiskLevelEnum.REVIEW.getValue()) {//可疑音频直接保存,等待后台审核 - auditAudio.setManualAuditResult(AuditAudioResultEnum.TO_BE_HANDLE.getValue()); - auditAudioDAO.save(auditAudio);//保存音频记录 - } - } - - - public long getRejectAudioCount(Long roomUid) { - Double score = jedisService.zscore(RedisKey.reject_audio_count.getKey(), roomUid.toString()); - if (score != null) { - return score.longValue(); - } - Query query = new Query(); - query.addCriteria(Criteria.where("roomUid").is(roomUid).and("manualAuditResult") - .nin(AuditAudioResultEnum.NORMAL.getValue(), AuditAudioResultEnum.TO_BE_HANDLE.getValue())); - long count = auditAudioDAO.count(query); - this.jedisService.zadd(RedisKey.reject_audio_count.getKey(),Double.valueOf(count), roomUid.toString()); - return count; - } - - public void sendAuditAudioMsg(String toUid, String riskType, String handleResult) { - bizExecutor.execute(() -> { - // 发送小秘书通知消息 - NeteaseSendMsgParam neteaseSendMsgParam = new NeteaseSendMsgParam(); - neteaseSendMsgParam.setType(0); - neteaseSendMsgParam.setFrom(SystemConfig.secretaryUid); - neteaseSendMsgParam.setOpe(0); - neteaseSendMsgParam.setTo(toUid); - neteaseSendMsgParam.setBody(String.format(msg, riskType, handleResult)); - sendSysMsgService.sendMsg(neteaseSendMsgParam); - }); - } - - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/charge/LuckyTarotChargeService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/charge/LuckyTarotChargeService.java index 4915efc86..2b78031fe 100644 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/charge/LuckyTarotChargeService.java +++ b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/charge/LuckyTarotChargeService.java @@ -78,8 +78,6 @@ public class LuckyTarotChargeService extends BaseService { @Autowired private EnvComponent envComponent; @Autowired - private ChargeCheckService chargeCheckService; - @Autowired private UsersBaseService usersBaseService; @Autowired private ChargeRecordService chargeRecordService; @@ -138,55 +136,6 @@ public class LuckyTarotChargeService extends BaseService { Long money = chargeProd.getMoney(); Long chargeAmount = money * cardNo.size(); - BaseResponseVO responseVo = new BaseResponseVO(BusinessStatusCodeEnum.SUCCESS); - if (users.getParentMode()) { - // 校验青少年是否可充值 - Boolean teenChargeSwitch = usersBaseService.getTeenChargeSwitch(); - if(teenChargeSwitch){ - // 校验青少年充值每日限额 - Integer limitMoney = usersBaseService.getUserTeenConfig().getLimitEveryDay(); - String chargeLimit = jedisService.hget(RedisKey.user_charge_limit.getKey(), uid.toString()); - if (StringUtils.isBlank(chargeLimit)) { - chargeLimit = chargeAmount.toString(); - } else { - chargeLimit = String.valueOf(Integer.valueOf(chargeLimit) + chargeAmount); - } - if (Integer.valueOf(chargeLimit) > limitMoney) { - responseVo.setSuccess(false); - responseVo.setCode(25000); - responseVo.setMessage("充值失败:超出当日充值限制"); - return responseVo; - } - }else{ - responseVo.setSuccess(false); - responseVo.setCode(25006); - responseVo.setMessage("当前处于青少年模式下,无法使用充值功能哦"); - return responseVo; - } - } else{ - // 2020-02-25: 改为从2020.02.25 0点起,累计充值≥指定人民币金额,需先实名认证 - Long historyRechargeAmount = chargeRecordService.historyRechargeAmount(users.getUid()); - // 进行实名认证充值校验 - Integer resultCode = chargeCheckService.needCertification(users, chargeProd.getMoney(), historyRechargeAmount); - if(resultCode != null && resultCode.equals(BusiStatus.CHARGE_LIMIT.value())){ - responseVo.setSuccess(false); - responseVo.setCode(resultCode); - responseVo.setMessage("充值失败,已超出充值限制"); - return responseVo; - }else if(resultCode != null && resultCode.equals(BusiStatus.UNDER_AGE_WITHDRAWAL.value())){ - responseVo.setSuccess(false); - responseVo.setCode(resultCode); - responseVo.setMessage("未成年用户 (<18岁),无法使用充值功能哦"); - return responseVo; - }else if(resultCode != null && resultCode.equals(BusiStatus.NEED_CERTIFICATION.value())){ - responseVo.setSuccess(false); - responseVo.setCode(resultCode); - responseVo.setMessage(BusiStatus.NEED_CERTIFICATION.getReasonPhrase()); - return responseVo; - } - } - - //今日塔罗充值金额 Long usedAmount = this.getUserTarotChargeAmount(uid,Calendar.getInstance().getTime()); Boolean goldLimit = Optional.ofNullable(Boolean.parseBoolean( @@ -203,9 +152,8 @@ public class LuckyTarotChargeService extends BaseService { LuckyTarotRecord luckyTarotRecord = this.buildLuckyTarotRecord(uid, roomUid, cardNo, chargeAmount, chargeProdId); - BaseResponseVO baseResponseVO = payCenterService.createTarotOrder(uid, luckyTarotRecord, channel, + return payCenterService.createTarotOrder(uid, luckyTarotRecord, channel, clientIp, chargeProd, users.getRealName(), users.getIdCardNum(), successUrl, deviceInfo); - return baseResponseVO; } /** diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/drawprize/UserDrawService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/drawprize/UserDrawService.java index 3c4fdf2cb..9e68fd3c0 100644 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/drawprize/UserDrawService.java +++ b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/drawprize/UserDrawService.java @@ -18,7 +18,6 @@ import com.accompany.business.service.headwear.HeadwearService; import com.accompany.business.service.record.BillRecordService; import com.accompany.business.service.purse.UserPurseService; import com.accompany.business.service.user.UsersService; -import com.accompany.business.service.wx.WXPubService; import com.accompany.business.vo.drawprize.UserDrawDoVo; import com.accompany.business.vo.drawprize.UserDrawRecordVo; import com.accompany.business.vo.drawprize.UserDrawVo; @@ -42,7 +41,6 @@ import com.accompany.core.service.SysConfService; import com.accompany.core.service.common.JedisLockService; import com.accompany.core.service.common.JedisService; import com.accompany.core.vo.UserVo; -import com.accompany.payment.config.WxConfig; import com.beust.jcommander.internal.Lists; import com.google.gson.Gson; import lombok.extern.slf4j.Slf4j; @@ -89,8 +87,6 @@ public class UserDrawService { private UsersMapper usersMapper; @Autowired private ActivityConfigService activityConfigService; - @Autowired - private WXPubService wxPubService; private Gson gson=new Gson(); @@ -409,7 +405,7 @@ public class UserDrawService { } } //预警判断 - IsRadishExceeded(); + //IsRadishExceeded(); } @@ -816,7 +812,7 @@ public class UserDrawService { */ public void sendRadishExceeded(String level, Integer limitTotal, Integer radishTotal){ log.error("Failed to doUserDraw, the number of radishes exceeded . limitTotal=[{}], CurrentTotal=[{}]", limitTotal, radishTotal); - String openId = WxConfig.alertAdminUser; + //String openId = WxConfig.alertAdminUser; String first = "警报警报!"; String keyword1 = "萝卜促销活动活动异常警报"; String keyword2 = "萝卜预算值为:" + limitTotal + ",当前累计送出萝卜为:" + radishTotal; @@ -828,6 +824,6 @@ public class UserDrawService { }else if (Constant.RadishDrawExceedLevel.levelTwo.equals(level)){ remark = "当天萝卜促销活动活动业务已停止,请立即排查数据!"; } - wxPubService.sendAlertMsg(openId,first,keyword1,keyword2,keyword3,keyword4,remark); + //wxPubService.sendAlertMsg(openId,first,keyword1,keyword2,keyword3,keyword4,remark); } } diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/hall/HallManageService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/hall/HallManageService.java index 72cb58f44..314a73c7f 100644 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/hall/HallManageService.java +++ b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/hall/HallManageService.java @@ -26,7 +26,6 @@ import com.accompany.common.redis.RedisKey; import com.accompany.common.result.BusiResult; import com.accompany.common.status.BusiStatus; import com.accompany.common.utils.DateTimeUtil; -import com.accompany.common.wx.MD5; import com.accompany.core.enumeration.BillObjTypeEnum; import com.accompany.core.exception.ServiceException; import com.accompany.core.model.Room; @@ -34,6 +33,7 @@ import com.accompany.core.model.Users; import com.accompany.core.service.SysConfService; import com.accompany.core.service.base.BaseService; import com.accompany.core.service.common.JedisService; +import com.accompany.core.util.MD5; import com.accompany.core.util.StringUtils; import com.accompany.core.vo.UserVo; import com.alibaba.fastjson.JSONObject; @@ -1061,7 +1061,7 @@ public class HallManageService extends BaseService { } private String getInviteCodeKey(String inviteCode) { - return RedisKey.hall_invite_code.getKey(MD5.MD5Encode(inviteCode)); + return RedisKey.hall_invite_code.getKey(MD5.getMD5(inviteCode)); } private HallInviteCodeVo buildHallInviteCodeVo(Long uid, Long hallId, String emojiCode, String nick, String hallName,String app) throws Exception { diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/kuaishou/KuaishouAdCalBackRecordService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/kuaishou/KuaishouAdCalBackRecordService.java deleted file mode 100644 index 61792bebf..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/kuaishou/KuaishouAdCalBackRecordService.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 文 件 名: JuLiangAdCalBackRecordService - * 版 权: - * 描 述: <描述> - * 创建人: H1 - * 创建时间: 2021/8/6 - * 修改人: - * 修改内容: - * 修改时间: - */ -package com.accompany.business.service.kuaishou; - -import com.accompany.business.model.kuaishou.KuaishouAdCalBackRecord; -import com.baomidou.mybatisplus.extension.service.IService; - -/** - *
接口描述: - *
功能详细描述: - * - * @author H1 - * @date [2021/8/6] - */ -public interface KuaishouAdCalBackRecordService extends IService { - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/kuaishou/KuaishouService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/kuaishou/KuaishouService.java deleted file mode 100644 index 12bdd0131..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/kuaishou/KuaishouService.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * 文 件 名: JuLiangService - * 版 权: - * 描 述: <描述> - * 创建人: H1 - * 创建时间: 2021/8/6 - * 修改人: - * 修改内容: - * 修改时间: - */ -package com.accompany.business.service.kuaishou; - -import cn.hutool.core.util.StrUtil; -import com.accompany.business.dto.kuaishou.AdKuaishouTrackActiveReqDto; -import com.accompany.business.enums.AdPlatformEnum; -import com.accompany.business.enums.KuaishouEventTypeEnum; -import com.accompany.business.model.kuaishou.KuaishouAdCalBackRecord; -import com.accompany.business.mybatismapper.kuaishou.KuaishouAdCalBackRecordMapper; -import com.accompany.business.service.ad.IAdPlatformStrategy; -import com.accompany.business.util.MD5; -import com.accompany.common.utils.HttpUtils; -import com.accompany.common.utils.StringUtils; -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.google.gson.Gson; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.collections.CollectionUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Service; - -import java.io.IOException; -import java.net.URLDecoder; -import java.util.*; - -/** - *
类描述: - *
功能详细描述: - * - * @author H1 - * @date [2021/8/6] - */ -@Service -@Slf4j -public class KuaishouService implements IAdPlatformStrategy { - - @Autowired - private KuaishouAdCalBackRecordService kuaishouAdCalBackRecordService; - @Autowired - private KuaishouAdCalBackRecordMapper kuaishouAdCalBackRecordMapper; - - private Gson gson = new Gson(); - - /** - * 安卓 - */ - private final static Integer PLATFORM_OS_ANDROID = 0; - /** - * IOS - */ - private final static Integer PLATFORM_OS_IOS = 1; - - private final static String GROUP_IMEI_MATCH = "imei"; - - private final static String GROUP_ANDROID_ID_MATCH = "androidId"; - - private final static String GROUP_OAID_MATCH = "oaid"; - - private final static String GROUP_OTHER_MATCH = "other"; - - @Override - public AdPlatformEnum getAdEnum() { - return AdPlatformEnum.KUAISHOU; - } - - /** - * 保存快手平台发送过来的用户点击信息 - * @param record - */ - public void saveRecord(KuaishouAdCalBackRecord record) { - if (record == null) { - return; - } - record.setEventType(KuaishouEventTypeEnum.CLICK.getType()); - record.setEventTypeComplete(KuaishouEventTypeEnum.CLICK.getType()); - kuaishouAdCalBackRecordService.save(record); - } - - /** - * 将用户信息进行归因,归因成功后上报快手平台 - * @param params - */ - @Async - @Override - public void activeTrack(AdKuaishouTrackActiveReqDto params) throws IOException { - if (checkParamAndTrack(params)) return; - - KuaishouEventTypeEnum event = KuaishouEventTypeEnum.getByValue(params.getEvenType()); - - List records = new ArrayList<>(); - - log.info("快手上报准备执行查询..."); - QueryWrapper query = new QueryWrapper<>(); - - List beforeTypes = KuaishouEventTypeEnum.listTypeBeforeEventIncludeSelf(event); - query.lambda().in(KuaishouAdCalBackRecord::getEventType, beforeTypes).orderByDesc(KuaishouAdCalBackRecord::getId); - if ((event.equals(KuaishouEventTypeEnum.CHARGE) || event.equals(KuaishouEventTypeEnum.NEXT_DAY_STAY)) && null != params.getUid()) { - query.lambda().eq(KuaishouAdCalBackRecord::getUid, params.getUid()); - } - if (params.getPlatOs() == null || !PLATFORM_OS_IOS.equals(params.getPlatOs())) { - log.info("快手上报当前设备为android..."); - //不是苹果:检查顺序imei、androidSha、oaid - query.lambda().and(wraper -> { - if (StringUtils.isNotBlank(params.getImeiSha())) { - wraper.eq(KuaishouAdCalBackRecord::getImeiSha, params.getImeiSha()); - } - if (StringUtils.isNotBlank(params.getAndroidSha())) { - wraper.or().eq(KuaishouAdCalBackRecord::getAndroidSha, params.getAndroidSha()); - } - if (StringUtils.isNotBlank(params.getOaid())) { - wraper.or().eq(KuaishouAdCalBackRecord::getOaid, params.getOaid()); - } - return wraper; - } - ); - if (params.getPlatOs() != null) query.lambda().eq(KuaishouAdCalBackRecord::getOs, params.getPlatOs()); - - List candidateRecords = kuaishouAdCalBackRecordMapper.selectList(query); - Map recordMap = new HashMap<>(); - if (!CollectionUtils.isEmpty(candidateRecords)) { - - for (KuaishouAdCalBackRecord record : candidateRecords) { - if (StringUtils.isNotBlank(record.getImeiSha()) && StringUtils.isNotBlank(params.getImeiSha()) && record.getImeiSha().equals(params.getImeiSha())) { - recordMap.put(GROUP_IMEI_MATCH, record); - break; - } else if (StringUtils.isNotBlank(record.getAndroidSha()) && StringUtils.isNotBlank(params.getAndroidSha()) && record.getAndroidSha().equals(params.getAndroidSha())) { - recordMap.put(GROUP_ANDROID_ID_MATCH, record); - continue; - } else if (StringUtils.isNotBlank(record.getOaid()) && StringUtils.isNotBlank(params.getOaid()) && record.getOaid().equals(params.getOaid())) { - recordMap.put(GROUP_OAID_MATCH, record); - continue; - } else { - recordMap.put(GROUP_OTHER_MATCH, record); - continue; - } - } - } - if (recordMap.containsKey(GROUP_IMEI_MATCH)) { - log.info("快手上报imei匹配"); - records.add(recordMap.get(GROUP_IMEI_MATCH)); - } - if (recordMap.containsKey(GROUP_ANDROID_ID_MATCH)) { - log.info("快手上报android匹配"); - records.add(recordMap.get(GROUP_ANDROID_ID_MATCH)); - } - if (recordMap.containsKey(GROUP_OAID_MATCH)) { - log.info("快手上报oaid匹配"); - records.add(recordMap.get(GROUP_OAID_MATCH)); - } - - } else { - log.info("快手上报当前设备为iOS..."); - //苹果:检查idfa - query.lambda().eq(KuaishouAdCalBackRecord::getOs, params.getPlatOs()); - if (StringUtils.isNotBlank(params.getIdfa())) { - query.lambda().and(wraper -> { - if (StringUtils.isNotBlank(params.getIdfa())) { - wraper.eq(KuaishouAdCalBackRecord::getIdfaSha, params.getIdfaSha()).or().eq(KuaishouAdCalBackRecord::getIdfaMd5, params.getIdfaMd5()); - } - return wraper; - } - ); - } - - records = kuaishouAdCalBackRecordMapper.selectList(query); - } - if (CollectionUtils.isEmpty(records)) { - log.info("kuaishou activeTrack 没有匹配到相应的信息,不进行事件回传。设备信息: {}", JSONObject.toJSONString(params)); - return; - } - - - // 取第一条进行回传 - KuaishouAdCalBackRecord record = records.get(0); - log.info("kuaishou activeTrack 匹配到相应的信息,进行事件回传。record id: {}", record.getId()); - - log.info("原callbackUrl:{}", record.getCallbackUrl()); - String callbackUrl = URLDecoder.decode(record.getCallbackUrl(), "UTF-8"); - - if (event.getValue().equals(KuaishouEventTypeEnum.REGISTER.getValue()) || event.getValue().equals(KuaishouEventTypeEnum.NEXT_DAY_STAY.getValue()) || event.getValue().equals(KuaishouEventTypeEnum.ACTIVE.getValue())) { - //激活、注册、次留 - callbackUrl = new StringBuffer(callbackUrl).append("&event_type=").append(params.getEvenType()).append("&event_time=").append(new Date().getTime()) - .append("&callback=").append(callbackUrl).toString(); - } else if (event.getValue().equals(KuaishouEventTypeEnum.CHARGE.getValue())) { - //付费 - callbackUrl = new StringBuffer(callbackUrl).append("&event_type=").append(params.getEvenType()).append("&event_time=").append(new Date().getTime()) - .append("&purchase_amount=").append(params.getPurchaseAmount()) - .append("&callback=").append(callbackUrl).toString(); - } else return; - log.info("拼接后的callbackUrl:{}", callbackUrl); - - - String result = HttpUtils.get(callbackUrl); - JSONObject resultObj = JSONObject.parseObject(result); - if (resultObj.getInteger("result").equals(1)) { - log.info("kuaishou 上报成功,[oaid,idfa,imeiMd5,imeiSha,androidMd5,androidSha]为:[{},{},{},{},{},{}], ", params.getOaid(), params.getIdfa(),params.getImeiMd5(), params.getImeiSha(), params.getAndroidMd5(),params.getAndroidSha()); - KuaishouAdCalBackRecord recordForUpdate = new KuaishouAdCalBackRecord(); - recordForUpdate.setId(record.getId()); - recordForUpdate.setEventType(event.getType()); - recordForUpdate.setEventTypeComplete(record.getEventTypeComplete() + StrUtil.COMMA + event.getType()); - if (null != params.getUid()) { - recordForUpdate.setUid(params.getUid()); - } - recordForUpdate.setUpdateTime(new Date()); - log.info("更新记录recordId:{}, eventType:{}", record.getId(), params.getEvenType()); - kuaishouAdCalBackRecordMapper.updateById(recordForUpdate); - } else { - log.error("kuaishou activeTrack 请求事件回传失败,result: {}, params:{}", result, gson.toJson(params)); - } - } - - - private boolean checkParamAndTrack(AdKuaishouTrackActiveReqDto params) { - log.info("执行参数检查:{}", gson.toJson(params)); - if (params == null) return true; - //关键参数检查 - if (StringUtils.isBlank(params.getImei()) && StringUtils.isBlank(params.getAndroidId()) && StringUtils.isBlank(params.getOaid()) && StringUtils.isBlank(params.getIdfa())) return true; - - dealEncryptParam(params); - - KuaishouEventTypeEnum event = KuaishouEventTypeEnum.getByValue(params.getEvenType()); - if (event == null) return true; - log.info("快手上报类型:{}", event.getType()); - - //List afterTypes = KuaishouEventTypeEnum.listTypeAfterEventIncludeSelf(event); - QueryWrapper countQuery = new QueryWrapper<>(); - // 设备没有上报过当前事件或者后置事件 - //countQuery.lambda().in(KuaishouAdCalBackRecord::getEventType, afterTypes); - - if (params.getPlatOs() == null || !PLATFORM_OS_IOS.equals(params.getPlatOs())) { - countQuery.lambda().and(wraper -> { - if (StringUtils.isNotBlank(params.getImeiSha())) { - wraper.eq(KuaishouAdCalBackRecord::getImeiSha, params.getImeiSha()); - } - if (StringUtils.isNotBlank(params.getAndroidSha())) { - wraper.or().eq(KuaishouAdCalBackRecord::getAndroidSha, params.getAndroidSha()); - } - if (StringUtils.isNotBlank(params.getOaid())) { - wraper.or().eq(KuaishouAdCalBackRecord::getOaid, params.getOaid()); - } - return wraper; - } - ); - if (params.getPlatOs() != null) countQuery.lambda().eq(KuaishouAdCalBackRecord::getOs, params.getPlatOs()); - } else { - if (StringUtils.isNotBlank(params.getIdfa())) { - countQuery.lambda().and(wraper -> { - if (StringUtils.isNotBlank(params.getIdfa())) { - wraper.eq(KuaishouAdCalBackRecord::getIdfaSha, params.getIdfaSha()).or().eq(KuaishouAdCalBackRecord::getIdfaMd5, params.getIdfaMd5()); - } - return wraper; - } - ); - } - - countQuery.lambda().eq(KuaishouAdCalBackRecord::getOs, params.getPlatOs()); - } - - if ((event.equals(KuaishouEventTypeEnum.CHARGE) || event.equals(KuaishouEventTypeEnum.NEXT_DAY_STAY)) && null != params.getUid()) { - countQuery.lambda().eq(KuaishouAdCalBackRecord::getUid, params.getUid()); - } - countQuery.lambda().like(KuaishouAdCalBackRecord::getEventTypeComplete, event.getType()); - Integer count = kuaishouAdCalBackRecordMapper.selectCount(countQuery); - if (count > 0) { - log.info("kuaishou activeTrack 该用户(设备)在该事件已进行过上报,无需重复上报"); - return true; - } - return false; - } - - public void dealEncryptParam(AdKuaishouTrackActiveReqDto params) { - if (StringUtils.isNotBlank(params.getIdfa())) { - log.info("idfa参数加密处理前值:{},md5:{},sha:{}", params.getIdfa(), params.getIdfaMd5(), params.getIdfaSha()); - params.setIdfaMd5(MD5.getMD5(params.getIdfa())); - params.setIdfaSha(DigestUtils.sha1Hex(params.getIdfa())); - log.info("idfa参数加密处理后值idfa:{},md5:{},sha:{}", params.getIdfa(), params.getIdfaMd5(), params.getIdfaSha()); - } - - if (StringUtils.isNotBlank(params.getImei())) { - log.info("imei参数加密处理前值:{},md5:{},sha:{}", params.getImei(), params.getImeiMd5(), params.getImeiSha()); - params.setImeiMd5(MD5.getMD5(params.getImei())); - params.setImeiSha(DigestUtils.sha1Hex(params.getImei())); - log.info("imei参数加密处理后值:{},md5:{},sha:{}", params.getImei(), params.getImeiMd5(), params.getImeiSha()); - } - - if (StringUtils.isNotBlank(params.getAndroidId())) { - log.info("android参数加密处理前值:{},md5:{},sha:{}", params.getAndroidId(), params.getAndroidMd5(), params.getAndroidSha()); - params.setAndroidMd5(MD5.getMD5(params.getAndroidId())); - params.setAndroidSha(DigestUtils.sha1Hex(params.getAndroidId())); - log.info("android参数加密处理后值:{},md5:{},sha:{}", params.getAndroidId(), params.getAndroidMd5(), params.getAndroidSha()); - } - } -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/kuaishou/impl/KuaishouAdCalBackRecordServiceImpl.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/kuaishou/impl/KuaishouAdCalBackRecordServiceImpl.java deleted file mode 100644 index b721ea57b..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/kuaishou/impl/KuaishouAdCalBackRecordServiceImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 文 件 名: JuLiangAdCalBackRecordServiceImpl - * 版 权: - * 描 述: <描述> - * 创建人: H1 - * 创建时间: 2021/8/6 - * 修改人: - * 修改内容: - * 修改时间: - */ -package com.accompany.business.service.kuaishou.impl; - -import com.accompany.business.model.kuaishou.KuaishouAdCalBackRecord; -import com.accompany.business.mybatismapper.kuaishou.KuaishouAdCalBackRecordMapper; -import com.accompany.business.service.kuaishou.KuaishouAdCalBackRecordService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -/** - *
类描述: - *
功能详细描述: - * - * @author H1 - * @date [2021/8/6] - */ -@Service -@Slf4j -public class KuaishouAdCalBackRecordServiceImpl extends ServiceImpl - implements KuaishouAdCalBackRecordService { - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/match/GameMatchJoinRecordService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/match/GameMatchJoinRecordService.java index 26544cea3..630cbe53b 100644 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/match/GameMatchJoinRecordService.java +++ b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/match/GameMatchJoinRecordService.java @@ -2,7 +2,6 @@ package com.accompany.business.service.match; import com.accompany.business.model.match.GameMatchJoinRecord; import com.accompany.business.mybatismapper.match.GameMatchJoinRecordMapper; -import com.accompany.business.wechat.util.StringUtil; import com.accompany.common.redis.RedisKey; import com.accompany.common.utils.StringUtils; import com.accompany.core.service.common.JedisService; diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/miniGame/MiniGameCallbackService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/miniGame/MiniGameCallbackService.java index f0559e23a..c4aec744f 100644 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/miniGame/MiniGameCallbackService.java +++ b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/miniGame/MiniGameCallbackService.java @@ -20,7 +20,6 @@ import com.accompany.core.service.user.UsersBaseService; import com.google.gson.Gson; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Lazy; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import tech.sud.mgp.auth.api.SudCode; diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/mission/MissionService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/mission/MissionService.java index cb02f359d..363330e0c 100644 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/mission/MissionService.java +++ b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/mission/MissionService.java @@ -31,13 +31,13 @@ import com.accompany.common.status.BusiStatus; import com.accompany.common.utils.CommonUtil; import com.accompany.common.utils.DateTimeUtil; import com.accompany.common.utils.GetTimeUtils; -import com.accompany.common.wx.MD5; import com.accompany.core.exception.ServiceException; import com.accompany.core.model.SysConf; import com.accompany.core.model.Users; import com.accompany.core.service.SysConfService; import com.accompany.core.service.base.BaseService; import com.accompany.core.util.KeyStore; +import com.accompany.core.util.MD5; import com.accompany.core.vo.UserLevelVo; import com.google.common.collect.Lists; import com.google.gson.reflect.TypeToken; @@ -319,7 +319,7 @@ public class MissionService extends BaseService { private TreeMap buildRequestParams(Long operUid){ StringBuffer buffer = new StringBuffer(); buffer.append("uid="+operUid).append("&key=").append(KeyStore.DES_ENCRYPT_KEY_SMS_PARAMS); - String sign = MD5.MD5Encode(buffer.toString()); + String sign = MD5.getMD5(buffer.toString()); Matcher matcher = pattern.matcher(sign); sign = matcher.replaceAll(""); diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/observe/BiliObserveRecordService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/observe/BiliObserveRecordService.java deleted file mode 100644 index 1a37cf57c..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/observe/BiliObserveRecordService.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.accompany.business.service.observe; - -import com.accompany.business.model.BiliObserveRecord; -import com.accompany.business.mybatismapper.BiliObserveRecordMapper; -import com.accompany.common.constant.ObserveConstant; -import com.accompany.common.utils.DateTimeUtil; -import com.accompany.common.utils.HttpUtils; -import com.accompany.core.model.Account; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.*; - -@Service -public class BiliObserveRecordService extends ServiceImpl { - - private static final Logger logger = LoggerFactory.getLogger(BiliObserveRecordService.class); - - @Autowired - BiliObserveRecordMapper biliObserveRecordMapper; - - public void saveFeedback(BiliObserveRecord biliObserveRecord) { - biliObserveRecord.setCreateTime(new Date()); - save(biliObserveRecord); - } - - public void saveCallback(String deviceId, String imei, String oaid) { - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.lambda().eq(BiliObserveRecord::getDeviceId, deviceId); - BiliObserveRecord biliObserveRecord = getOne(wrapper); - if (null == biliObserveRecord) { - BiliObserveRecord record = new BiliObserveRecord(); - record.setCreateTime(new Date()); - record.setDeviceId(deviceId); - record.setImei(imei); - record.setOaid(oaid); - save(record); - } else { - biliObserveRecord.setImei(imei); - biliObserveRecord.setOaid(oaid); - updateById(biliObserveRecord); - } - } - - public void handle(Account account) { - // 判断渠道 - if (!account.getChannel().equals(ObserveConstant.ObserveChannel.BILIBILI)) { - return; - } - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.lambda().eq(BiliObserveRecord::getDeviceId, account.getDeviceId()); - BiliObserveRecord record = getOne(wrapper); - if (null == record) { - return; - } - Date startTime = DateTimeUtil.addDays(new Date(), -7); - if (record.getOaid() != null) { - wrapper = new QueryWrapper<>(); - wrapper.lambda().eq(BiliObserveRecord::getOaid, record.getOaid()).isNull(BiliObserveRecord::getDeviceId) - .gt(BiliObserveRecord::getCreateTime, startTime).orderByDesc(BiliObserveRecord::getCreateTime); - wrapper.last("LIMIT 1"); - BiliObserveRecord biliObserveRecord = getOne(wrapper); - if (biliObserveRecord != null) { - biliCallback(biliObserveRecord, account, "oaid=" + record.getOaid()); - return; - } - } - if (record.getImei() != null) { - wrapper = new QueryWrapper<>(); - wrapper.lambda().eq(BiliObserveRecord::getImei, record.getImei()).isNull(BiliObserveRecord::getDeviceId) - .gt(BiliObserveRecord::getCreateTime, startTime).orderByDesc(BiliObserveRecord::getCreateTime); - wrapper.last("LIMIT 1"); - BiliObserveRecord biliObserveRecord = getOne(wrapper); - if (biliObserveRecord != null) { - biliCallback(biliObserveRecord, account, "imei=" + record.getImei()); - return; - } - } - - } - - private void biliCallback(BiliObserveRecord record, Account account, String suffix) { - logger.info("biliCallback record id:{}", record.getId()); - Date now = new Date(); - String params = String.format("?conv_type=USER_REGISTER&conv_time=%s&client_ip=%s&conv_count=1&track_id=%s&", - now.getTime(), account.getRegisterIp(), record.getTrackId()); - logger.info("biliCallback params:{}", params + suffix); - try { - String result = HttpUtils.get(ObserveConstant.BILI_CALLBACK_URL + params + suffix); - logger.info("biliCallback result:{}", result); - } catch (Exception e) { - logger.error("biliCallback error:{}", e); - } - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/observe/ObserveService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/observe/ObserveService.java deleted file mode 100644 index 3ceff2071..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/observe/ObserveService.java +++ /dev/null @@ -1,165 +0,0 @@ -package com.accompany.business.service.observe; - -import com.accompany.business.model.BaiduObserveRecord; -import com.accompany.business.model.ObserveRecord; -import com.accompany.business.mongodb.DAO.observe.ObserveChannelRecordDAO; -import com.accompany.business.mongodb.document.observe.ObserveChannelRecord; -import com.accompany.business.mybatismapper.BaiduObserveRecordMapper; -import com.accompany.business.mybatismapper.ObserveRecordMapper; -import com.accompany.common.constant.ObserveConstant; -import com.accompany.common.device.DeviceInfo; -import com.accompany.common.redis.RedisKey; -import com.accompany.common.utils.HttpUtils; -import com.accompany.common.utils.UUIDUitl; -import com.accompany.common.wx.MD5; -import com.accompany.core.service.base.BaseService; -import com.accompany.core.util.StringUtils; -import com.google.common.reflect.TypeToken; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.lang.reflect.Type; -import java.util.Date; -import java.util.Map; - -/** - * Created by yuanyi on 2019/3/6. - */ -@Service -public class ObserveService extends BaseService { - - @Autowired - private BaiduObserveRecordMapper baiduObserveRecordMapper; - @Autowired - private ObserveRecordMapper observeRecordMapper; - @Autowired - private ObserveChannelRecordDAO observeChannelRecordDAO; - - private static final String BAIDU_AKEY = "MjcxOTUyOTQ="; - /** - * 百度信息流回调 - * @param map - */ - public void baiduFeedBack(Map map) throws Exception{ - // 获取操作系统 - String ip = map.get("ip"); - // 获取设备标识码 -// String member = null; -// -// if(ObserveConstant.OsType.IOS.equals(osType)){ -// member = map.get("idfa"); -// }else{ -// member = map.get("imei_md5"); -// } - -// if(StringUtils.isEmpty(member)){ -// throw new BusinessException("设备标识为空,不纳入统计"); -// } - - // 把监测的url放入缓存中 - jedisService.hset(RedisKey.baidu_observe.getKey(),ip,gson.toJson(map)); - - // 每有一条监控记录过来则放到mongo中 - ObserveChannelRecord observeChannelRecord = this.buildObserveChannelRecord(map); - this.observeChannelRecordDAO.insert(observeChannelRecord); - } - - public void testBuild(Map map){ - ObserveChannelRecord observeChannelRecord = this.buildObserveChannelRecord(map); - this.observeChannelRecordDAO.insert(observeChannelRecord); - } - - public void baiduCallback(String id, DeviceInfo deviceInfo,String ip) throws Exception{ - if(!ObserveConstant.ObserveChannel.BAIDUXXL.equals(deviceInfo.getChannel())){ - return; - } - String mapStr = jedisService.hget(RedisKey.baidu_observe.getKey(),ip); - if(StringUtils.isEmpty(mapStr)){ - return; - } - -// // 删除对应的监控信息缓存 - jedisService.hdel(RedisKey.baidu_observe.getKey(),ip); - Type type = new TypeToken>() {}.getType(); - Map map = gson.fromJson(mapStr,type); - logger.info("baidu observe callback param: ip={},map={}",ip,mapStr); - String callbackUrl = map.get("callback_url").replace("{{ATYPE}}","activate").replace("{{AVALUE}}","0"); - String encodeUrl = callbackUrl + BAIDU_AKEY; - String sign = MD5.MD5Encode(encodeUrl); - String requestUrl = callbackUrl + "&sign=" + sign; - String result = HttpUtils.executeGet(requestUrl); - logger.info("request url:{},result from baidu observe:result={}",requestUrl,gson.toJson(result)); - - Double score = jedisService.zincrby(RedisKey.baidu_observe.getKey("active_id"),1.0,id); - if(score > 1.0){ - return; - } - saveObserveRecord(map,id,deviceInfo.getOs(),deviceInfo.getDeviceId()); - - } - - - public void saveObserveRecord(Map map,String member,String os,String deviceId){ - ObserveRecord observeRecord = this.buildObserveRecord(map,member,os,deviceId); - int result = observeRecordMapper.insertSelective(observeRecord); - } - - public BaiduObserveRecord buildBaiduObserve(Map map,String member,String os,String deviceId){ - BaiduObserveRecord baiduObserveRecord = new BaiduObserveRecord(); - baiduObserveRecord.setDeviceId(member); - baiduObserveRecord.setOs(os); - baiduObserveRecord.setIp(map.get("ip")); - baiduObserveRecord.setTutuDeviceid(deviceId); - baiduObserveRecord.setAndroidDeviceId(map.get("android_id")); - return baiduObserveRecord; - } - - public ObserveRecord buildObserveRecord(Map map,String member,String os,String deviceId){ - ObserveRecord observeRecord = new ObserveRecord(); - observeRecord.setDeviceId(member); - observeRecord.setOs(os); - observeRecord.setIp(map.get("ip")); - observeRecord.setTutuDeviceid(deviceId); - observeRecord.setAndroidDeviceId(map.get("android_id")); - observeRecord.setType(ObserveConstant.ObserveType.BAIDUXXL); - return observeRecord; - } - - public ObserveChannelRecord buildObserveChannelRecord(Map map){ - ObserveChannelRecord observeChannelRecord = new ObserveChannelRecord(); - observeChannelRecord.setRecordId(UUIDUitl.get()); - observeChannelRecord.setType(ObserveConstant.ObserveType.BAIDUXXL); - String member = null; - String osType = map.get("os"); - if(ObserveConstant.OsType.IOS.equals(osType)){ - member = map.get("idfa"); - }else{ - member = map.get("imei_md5"); - } - observeChannelRecord.setDeviceId(member); - - observeChannelRecord.setAndroidDeviceId(map.get("android_id")); - observeChannelRecord.setIp(map.get("ip")); - observeChannelRecord.setUa(map.get("ua")); - observeChannelRecord.setOs(map.get("os")); - Date curDate = new Date(); - observeChannelRecord.setCreateTime(curDate.getTime()); - return observeChannelRecord; - } - - - - public static void business(String[] args) { - String callbackUrl = "http://www.tuttuyuiyin.com?a={{ATYPE}}&b={{AVALUE}}"; - System.out.println(callbackUrl); - String callbackUrl1 = callbackUrl.replace("{{ATYPE}}","activate").replace("{{AVALUE}}","0"); - String sign = MD5.MD5Encode("2324324"); - String requestUrl = callbackUrl1 + "&sign=" + sign; -// String callbackUrl2 = callbackUrl1.replace("{{AVALUE}}","0"); -// callbackUrl.replace("{{AVALUE}}","0"); - System.out.println(callbackUrl1); - System.out.println(requestUrl); -// System.out.println(callbackUrl2); - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/payment/WxCallbackService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/payment/WxCallbackService.java deleted file mode 100644 index f4e1b92af..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/payment/WxCallbackService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.accompany.business.service.payment; - -import com.accompany.business.apppay.domain.WxNotifyParam; -import com.accompany.core.service.base.BaseService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -@Service -public class WxCallbackService extends BaseService { - - private static final Logger logger = LoggerFactory.getLogger(WxCallbackService.class); - - public static void business(String[] args) { - WxNotifyParam param = new WxNotifyParam(); - param.setErrCode("SUCCESS"); - - System.out.println(param); - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/SignService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/SignService.java deleted file mode 100644 index 5daf8b79c..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/SignService.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.accompany.business.service.wx; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.UnsupportedEncodingException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Formatter; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -/** - * 用于生成微信页面签名 - * Created by lixiliang - * on 2015/6/15. - */ -public class SignService { - private static final Logger log = LoggerFactory.getLogger(SignService.class); - - - public static Map sign(String jsapi_ticket, String url) { - Map ret = new HashMap(); - String nonce_str = create_nonce_str(); - String timestamp = create_timestamp(); - String string1; - String signature = ""; - - //注意这里参数名必须全部小写,且必须有序 - string1 = "jsapi_ticket=" + jsapi_ticket + - "&noncestr=" + nonce_str + - "×tamp=" + timestamp + - "&url=" + url; - log.info(string1); - try { - MessageDigest crypt = MessageDigest.getInstance("SHA-1"); - crypt.reset(); - crypt.update(string1.getBytes("UTF-8")); - signature = byteToHex(crypt.digest()); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - - ret.put("url", url); - ret.put("jsapi_ticket", jsapi_ticket); - ret.put("nonceStr", nonce_str); - ret.put("timestamp", timestamp); - ret.put("signature", signature); - - return ret; - } - - private static String byteToHex(final byte[] hash) { - Formatter formatter = new Formatter(); - for (byte b : hash) { - formatter.format("%02x", b); - } - String result = formatter.toString(); - formatter.close(); - return result; - } - - private static String create_nonce_str() { - return UUID.randomUUID().toString(); - } - - private static String create_timestamp() { - return Long.toString(System.currentTimeMillis() / 1000); - } -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WXMircoMallPubService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WXMircoMallPubService.java deleted file mode 100644 index b99a37c79..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WXMircoMallPubService.java +++ /dev/null @@ -1,344 +0,0 @@ -package com.accompany.business.service.wx; - -/** - * Created by yuanyi on 2019/4/25. - */ - -import com.accompany.business.model.WXMsgPicInfo; -import com.accompany.business.model.WXPush; -import com.accompany.business.service.WXPushService; -import com.accompany.business.service.api.QinniuService; -import com.accompany.business.util.WeiXinUtil; -import com.accompany.business.vo.OpenIdInfoVo; -import com.accompany.business.vo.user.UserInfo; -import com.accompany.business.wechat.AccessToken; -import com.accompany.business.wechat.message.resp.ArticleModel; -import com.accompany.business.wechat.message.resp.NewsMessage; -import com.accompany.business.wechat.message.resp.TextMessage; -import com.accompany.business.wechat.util.MessageUtil; -import com.accompany.common.utils.StringUtils; -import com.accompany.common.wx.HttpUtils; -import com.accompany.payment.config.WxMicroMallConfig; -import com.google.gson.Gson; -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import javax.servlet.http.HttpServletRequest; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 微商城公众号相关操作 - */ -@Service -public class WXMircoMallPubService { - - private Logger LOGGER = Logger.getLogger ( WXMircoMallPubService.class ); - private static String menuName = "三种方式,任您蹂躏。\n" + - "客服微信号:erban2018\n" + - "QQ一群581321437(已满),二群585749306\n" + - "电话:020-86175180(只接受工作时间内的来电哦。)"; - - - @Autowired - WXPushService pushService; - @Autowired - private QinniuService qinniuService; - - @Autowired - private WeiXinUtil weiXinUtil; - - - /** - * 处理微信用户发来的请求 - * - * @param request - * @return - */ - public String processRequest ( HttpServletRequest request ) { - - String respMessage = null; - try { - //默认的文本回复 - String respContent = "请求处理异常,请稍后再试!"; - - //解析发过来的xml请求 - Map requestMap = MessageUtil.parseXml ( request ); - - //发送发方账号(open_id) - String fromUserName = requestMap.get ( "FromUserName" ); - - //公众账号 - String toUserName = requestMap.get ( "ToUserName" ); - - //消息类型 - String msgType = requestMap.get ( "MsgType" ); - - //回复文本消息 - TextMessage textMessage = new TextMessage ( ); - textMessage.setToUserName ( fromUserName ); - textMessage.setFromUserName ( toUserName ); - textMessage.setCreateTime (System.currentTimeMillis()); - textMessage.setMsgType ( MessageUtil.RESP_MESSAGE_TYPE_TEXT ); - textMessage.setFuncFlag ( 0 ); - - //文本消息 - if ( msgType.equals ( MessageUtil.REQ_MESSAGE_TYPE_TEXT ) ) { - respContent =menuName; - } - //图片消息 - else if ( msgType.equals ( MessageUtil.REQ_MESSAGE_TYPE_IMAGE ) ) { - respContent = menuName; - - } - //地理位置消息 - else if ( msgType.equals ( MessageUtil.REQ_MESSAGE_TYPE_LOCATION ) ) { - respContent = menuName; - } - //链接消息 - else if ( msgType.equals ( MessageUtil.REQ_MESSAGE_TYPE_LINK ) ) { - respContent =menuName; - }//语音消息 - else if ( msgType.equals ( MessageUtil.REQ_MESSAGE_TYPE_VOICE ) ) { - String voiceData = requestMap.get ( "Recognition" ); - //================语音数据处理====================// - respContent = menuName; - } - //事件推送消息 - else if ( msgType.equals ( MessageUtil.REQ_MESSAGE_TYPE_EVENT ) ) { - //事件类型 - String eventType = requestMap.get ( "Event" ); - //订阅 - if ( eventType.equals ( MessageUtil.EVENT_TYPE_SUBSCRIBE ) ) { - LOGGER.info ( "================用户订阅===============" ); - //获取一条订阅推送 - WXPush wxPush = pushService.getSubMsg ( ); - List wxMsgPicInfoList = - pushService.getPicInfoMsgByIds ( wxPush.getMsgId ( ) ); - int articleCount = Integer.parseInt ( wxPush.getArticleCount ( ) ); - //发送订阅消息 - NewsMessage newsMessage = new NewsMessage ( ); - newsMessage.setToUserName ( fromUserName ); - newsMessage.setFromUserName ( toUserName ); - newsMessage.setCreateTime (System.currentTimeMillis()); - newsMessage.setMsgType ( MessageUtil.RESP_MESSAGE_TYPE_NEWS ); - newsMessage.setFuncFlag ( 0 ); - newsMessage.setArticleCount ( ( articleCount ) ); - List list = new ArrayList( ); - - for ( int i = 0 ; i < articleCount ; i++ ) { - ArticleModel articleModel = new ArticleModel ( ); - articleModel.setDescription ( wxMsgPicInfoList.get ( i ).getDescription ( ) ); - articleModel.setPicUrl ( wxMsgPicInfoList.get ( i ).getPicUrl ( ) ); - articleModel.setUrl ( wxMsgPicInfoList.get ( i ).getUrl ( ) ); - articleModel.setTitle ( wxMsgPicInfoList.get ( i ).getTitle ( ) ); - list.add ( articleModel ); //按照对象引用添加 - } - newsMessage.setArticles ( list ); - return MessageUtil.newsMessageToXml ( newsMessage ); - } - //取消订阅 - else if ( eventType.equals ( MessageUtil.EVENT_TYPE_UNSUBSCRIBE ) ) { - // TODO 取消订阅后用户再收不到公众号发送的消息,因此不需要回复消息 - } - //菜单点击事件 - else if ( eventType.equals ( MessageUtil.EVENT_TYPE_CLICK ) ) { - //事件KEY值 - String eventKey = requestMap.get ( "EventKey" ); - String menuName = ""; - //TODO 根据自定义菜单值与eventKey比较来进行下一步操作 - //响应按键数据 - switch ( Integer.valueOf ( eventKey ) ) { - case 31: - menuName = "三种方式,任您蹂躏。\n" + - "客服微信号:erban2018\n" + - "QQ一群581321437(已满),二群585749306\n" + - "电话:020-86175180(只接受工作时间内的来电哦。)"; - break; - case 33: - menuName = "待开发"; - break; - default: - break; - } - respContent = menuName; - } - } - textMessage.setContent ( respContent ); - respMessage = MessageUtil.textMessageToXml ( textMessage ); - - } catch ( Exception e ) { - // TODO: handle exception - e.printStackTrace ( ); - } - return respMessage; - - } - - /** - * 微信oauth2授权登录时根据获取的code来作登录校验 - * @Author yuanyi - * @param code - * @return - */ - -// public OpenIdInfoVo getOpenId ( String code ) { - public OpenIdInfoVo getOpenIdInfo (String code){ - /* - 获取openID(√) - */ - LOGGER.info ( "==============服务器未获取给用户的openid==============" ); - HashMap openIdMap = new HashMap ( ); - openIdMap.put ( "appid" , WxMicroMallConfig.appId); - openIdMap.put ( "secret" , WxMicroMallConfig.appSecret); - openIdMap.put ( "code" , code ); - openIdMap.put ( "grant_type" , "authorization_code" ); - //==================解析openIdInfo json字符串=========================// - String openIdInfo = HttpUtils.URLGet ( - "https://api.weixin.qq.com/sns/oauth2/access_token" , openIdMap , HttpUtils.URL_PARAM_DECODECHARSET_UTF8 ); - LOGGER.info ( "===========获取openIdInfo===========" + openIdInfo ); - Gson gson = new Gson ( ); - OpenIdInfoVo openIdInfoVo = gson.fromJson ( openIdInfo , OpenIdInfoVo.class ); - String openId = openIdInfoVo.getOpenid ( ); - if ( openId == null ) { - LOGGER.error ( "==========请求openId失败=================" ); - return null; - } - return openIdInfoVo; - - } - - - public void sendModelMsg ( Long erbanNo , String openId , String goldNum , String resultStr ) { - - LOGGER.info ( "------------发送订单通知消息请求-----------------" ); - // 第三方用户唯一凭证 - String appId = WxMicroMallConfig.appId; - // 第三方用户唯一凭证密钥 - String appSecret = WxMicroMallConfig.appSecret; - // 调用接口获取access_token - - - try{ -// String accessToken = wxService.getToken(); - AccessToken at = WeiXinUtil.getAccessToken ( appId , appSecret ); - - if (!StringUtils.isEmpty(at.getToken())) { - weiXinUtil.sendModelMsg ( erbanNo , openId , goldNum , at.getToken() , resultStr ); - } - }catch (Exception e){ - LOGGER.error("send model msg failed",e); - } - } - - public void sendAlertMsg(String openId,String first,String keyword1,String keyword2,String keyword3,String keyword4,String remark){ - String appId = WxMicroMallConfig.appId; - // 第三方用户唯一凭证密钥 - String appSecret = WxMicroMallConfig.appSecret; - // 调用接口获取access_token - - try{ -// String accessToken = wxService.getToken(); - AccessToken at = WeiXinUtil.getAccessToken ( appId , appSecret ); - if (!StringUtils.isEmpty(at.getToken())) { -// weiXinUtil.sendAlertMsg(openId,at.getToken(),first,keyword1,keyword2,keyword3,keyword4,remark); - } - }catch (Exception e){ - LOGGER.error("send alert msg failed",e); - } - - - } - - /** - *获取用户信息,此方法只有用户关注了公众号后才能拿到完整的用户信息 - */ - public UserInfo getUserInfo (String openId ) { - //http请求方式: GET https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN - String url = "https://api.weixin.qq.com/cgi-bin/user/info"; - //获取access_token - AccessToken accessToken = WeiXinUtil.getAccessToken ( - WxMicroMallConfig.appId , WxMicroMallConfig.appSecret ); - LOGGER.info ( "==>获取微信用户信息URL:" + url ); - LOGGER.info ( "==>accessToken:" + accessToken.getToken ( ) ); - LOGGER.info ( "==>openid:" + openId ); - String result = HttpUtils.sendGet ( url, - "access_token="+ accessToken.getToken ( )+ - "&openid="+openId+ - "&lang=zh_CN"); - LOGGER.info ( "==>获取微信用户返回结果:" + result ); - UserInfo userInfo = new Gson ().fromJson ( result,UserInfo.class ); - return userInfo; - } - - /** - * 网页授权时获取用户的微信信息 - * @param openId - * @param token - * @return - */ - public UserInfo getUserInfoV2(String openId,String token){ - String url = "https://api.weixin.qq.com/sns/userinfo"; - - LOGGER.info ( "==>网页授权的accessToken:" + token ); - String result = HttpUtils.sendGet ( url, - "access_token="+ token+ - "&openid="+openId+ - "&lang=zh_CN"); - LOGGER.info ( "==>网页授权调用后查询微信用户返回结果:" + result ); - UserInfo userInfo = new Gson().fromJson(result,UserInfo.class); - return userInfo; - } - - public UserInfo getUserInfoByCode(String code){ - OpenIdInfoVo openIdInfoVo = this.getOpenIdInfo(code); - String openId = openIdInfoVo.getOpenid(); - String token = openIdInfoVo.getAccess_token(); - UserInfo userInfo = this.getUserInfoV2(openId,token); - return userInfo; - } - - // public InputStream getWxRecodeInputStream(String code,String mediaId){ -// OpenIdInfoVo openIdInfoVo = this.getOpenIdInfo(code); -// HashMap paramMap = new HashMap (); -// String accessToken = openIdInfoVo.getAccess_token(); -// paramMap.put("access_token",accessToken); -// paramMap.put("media_id",mediaId); -// String url = "http://file.api.weixin.qq.com/cgi-bin/media/get"; -// String result = HttpUtils.URLGet(url,paramMap,HttpUtils.URL_PARAM_DECODECHARSET_UTF8); -// } - - public InputStream getWxRecodeInputStream(String code, String mediaId){ - OpenIdInfoVo openIdInfoVo = this.getOpenIdInfo(code); - String accessToken = openIdInfoVo.getAccess_token(); - String mediaUrl = ""; - String url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=" + accessToken + "&media_id=" + mediaId; - InputStream is = null; - try { - URL urlGet = new URL(url); - HttpURLConnection http = (HttpURLConnection) urlGet.openConnection(); - http.setRequestMethod("GET"); // 必须是get方式请求   - http.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); - http.setDoOutput(true); - http.setDoInput(true); - System.setProperty("sun.net.client.defaultConnectTimeout", "30000");// 连接超时30秒   - System.setProperty("sun.net.client.defaultReadTimeout", "30000"); // 读取超时30秒   - http.connect(); - // 获取文件转化为byte流   - is = http.getInputStream(); - LOGGER.info("文件流======:"+is); - mediaUrl = qinniuService.uploadByStream(is); - LOGGER.info("文件地址为:" + mediaUrl); - } catch (Exception e) { - LOGGER.error("get recode from wx failed",e); - } - return is; - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WXPub2Service.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WXPub2Service.java deleted file mode 100644 index 33fb6e0cb..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WXPub2Service.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.accompany.business.service.wx; - -/** - * Created by yuanyi on 2019/4/25. - */ - -import com.accompany.business.model.WXMsgPicInfo; -import com.accompany.business.model.WXPush; -import com.accompany.business.service.WXPushService; -import com.accompany.business.service.api.QinniuService; -import com.accompany.business.util.WeiXinUtil; -import com.accompany.business.vo.OpenIdInfoVo; -import com.accompany.business.vo.user.UserInfo; -import com.accompany.business.wechat.AccessToken; -import com.accompany.business.wechat.message.resp.ArticleModel; -import com.accompany.business.wechat.message.resp.NewsMessage; -import com.accompany.business.wechat.message.resp.TextMessage; -import com.accompany.business.wechat.util.MessageUtil; -import com.accompany.common.utils.StringUtils; -import com.accompany.common.wx.HttpUtils; -import com.accompany.payment.config.WxMicroMallConfig; -import com.accompany.payment.config.WxPub2Config; -import com.google.gson.Gson; -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import javax.servlet.http.HttpServletRequest; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 新公众号:平台助手相关操作 - */ -@Service -public class WXPub2Service { - - private Logger LOGGER = Logger.getLogger ( WXPub2Service.class ); - private static String menuName = "三种方式,任您蹂躏。\n" + - "客服微信号:erban2018\n" + - "QQ一群581321437(已满),二群585749306\n" + - "电话:020-86175180(只接受工作时间内的来电哦。)"; - - /** - * 微信oauth2授权登录时根据获取的code来作登录校验 - * @Author yuanyi - * @param code - * @return - */ - -// public OpenIdInfoVo getOpenId ( String code ) { - public OpenIdInfoVo getOpenIdInfo (String code){ - /* - 获取openID(√) - */ - LOGGER.info ( "==============服务器未获取给用户的openid==============" ); - HashMap openIdMap = new HashMap ( ); - openIdMap.put ( "appid" , WxPub2Config.appId); - openIdMap.put ( "secret" , WxPub2Config.appSecret); - openIdMap.put ( "code" , code ); - openIdMap.put ( "grant_type" , "authorization_code" ); - //==================解析openIdInfo json字符串=========================// - String openIdInfo = HttpUtils.URLGet ( - "https://api.weixin.qq.com/sns/oauth2/access_token" , openIdMap , HttpUtils.URL_PARAM_DECODECHARSET_UTF8 ); - LOGGER.info ( "===========获取openIdInfo===========" + openIdInfo ); - Gson gson = new Gson ( ); - OpenIdInfoVo openIdInfoVo = gson.fromJson ( openIdInfo , OpenIdInfoVo.class ); - String openId = openIdInfoVo.getOpenid ( ); - if ( openId == null ) { - LOGGER.error ( "==========请求openId失败=================" ); - return null; - } - return openIdInfoVo; - - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WXPubService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WXPubService.java deleted file mode 100644 index f100ac33e..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WXPubService.java +++ /dev/null @@ -1,344 +0,0 @@ -package com.accompany.business.service.wx; - -/** - * Created by yuanyi on 2019/4/25. - */ - -import com.accompany.business.model.WXMsgPicInfo; -import com.accompany.business.model.WXPush; -import com.accompany.business.service.WXPushService; -import com.accompany.business.service.api.QinniuService; -import com.accompany.business.util.WeiXinUtil; -import com.accompany.business.vo.OpenIdInfoVo; -import com.accompany.business.vo.user.UserInfo; -import com.accompany.business.wechat.AccessToken; -import com.accompany.business.wechat.message.resp.ArticleModel; -import com.accompany.business.wechat.message.resp.NewsMessage; -import com.accompany.business.wechat.message.resp.TextMessage; -import com.accompany.business.wechat.util.MessageUtil; -import com.accompany.common.utils.StringUtils; -import com.accompany.common.wx.HttpUtils; -import com.accompany.payment.config.WxConfig; -import com.google.gson.Gson; -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import javax.servlet.http.HttpServletRequest; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 微信相关操作 - */ -@Service -public class WXPubService { - - private Logger LOGGER = Logger.getLogger ( WXPubService.class ); - private static String menuName = "三种方式,任您蹂躏。\n" + - "客服微信号:erban2018\n" + - "QQ一群581321437(已满),二群585749306\n" + - "电话:020-86175180(只接受工作时间内的来电哦。)"; - - - @Autowired - WXPushService pushService; - @Autowired - private QinniuService qinniuService; - - @Autowired - private WeiXinUtil weiXinUtil; - - - /** - * 处理微信用户发来的请求 - * - * @param request - * @return - */ - public String processRequest ( HttpServletRequest request ) { - - String respMessage = null; - try { - //默认的文本回复 - String respContent = "请求处理异常,请稍后再试!"; - - //解析发过来的xml请求 - Map requestMap = MessageUtil.parseXml ( request ); - - //发送发方账号(open_id) - String fromUserName = requestMap.get ( "FromUserName" ); - - //公众账号 - String toUserName = requestMap.get ( "ToUserName" ); - - //消息类型 - String msgType = requestMap.get ( "MsgType" ); - - //回复文本消息 - TextMessage textMessage = new TextMessage ( ); - textMessage.setToUserName ( fromUserName ); - textMessage.setFromUserName ( toUserName ); - textMessage.setCreateTime (System.currentTimeMillis()); - textMessage.setMsgType ( MessageUtil.RESP_MESSAGE_TYPE_TEXT ); - textMessage.setFuncFlag ( 0 ); - - //文本消息 - if ( msgType.equals ( MessageUtil.REQ_MESSAGE_TYPE_TEXT ) ) { - respContent =menuName; - } - //图片消息 - else if ( msgType.equals ( MessageUtil.REQ_MESSAGE_TYPE_IMAGE ) ) { - respContent = menuName; - - } - //地理位置消息 - else if ( msgType.equals ( MessageUtil.REQ_MESSAGE_TYPE_LOCATION ) ) { - respContent = menuName; - } - //链接消息 - else if ( msgType.equals ( MessageUtil.REQ_MESSAGE_TYPE_LINK ) ) { - respContent =menuName; - }//语音消息 - else if ( msgType.equals ( MessageUtil.REQ_MESSAGE_TYPE_VOICE ) ) { - String voiceData = requestMap.get ( "Recognition" ); - //================语音数据处理====================// - respContent = menuName; - } - //事件推送消息 - else if ( msgType.equals ( MessageUtil.REQ_MESSAGE_TYPE_EVENT ) ) { - //事件类型 - String eventType = requestMap.get ( "Event" ); - //订阅 - if ( eventType.equals ( MessageUtil.EVENT_TYPE_SUBSCRIBE ) ) { - LOGGER.info ( "================用户订阅===============" ); - //获取一条订阅推送 - WXPush wxPush = pushService.getSubMsg ( ); - List wxMsgPicInfoList = - pushService.getPicInfoMsgByIds ( wxPush.getMsgId ( ) ); - int articleCount = Integer.parseInt ( wxPush.getArticleCount ( ) ); - //发送订阅消息 - NewsMessage newsMessage = new NewsMessage ( ); - newsMessage.setToUserName ( fromUserName ); - newsMessage.setFromUserName ( toUserName ); - newsMessage.setCreateTime (System.currentTimeMillis()); - newsMessage.setMsgType ( MessageUtil.RESP_MESSAGE_TYPE_NEWS ); - newsMessage.setFuncFlag ( 0 ); - newsMessage.setArticleCount ( ( articleCount ) ); - List list = new ArrayList( ); - - for ( int i = 0 ; i < articleCount ; i++ ) { - ArticleModel articleModel = new ArticleModel ( ); - articleModel.setDescription ( wxMsgPicInfoList.get ( i ).getDescription ( ) ); - articleModel.setPicUrl ( wxMsgPicInfoList.get ( i ).getPicUrl ( ) ); - articleModel.setUrl ( wxMsgPicInfoList.get ( i ).getUrl ( ) ); - articleModel.setTitle ( wxMsgPicInfoList.get ( i ).getTitle ( ) ); - list.add ( articleModel ); //按照对象引用添加 - } - newsMessage.setArticles ( list ); - return MessageUtil.newsMessageToXml ( newsMessage ); - } - //取消订阅 - else if ( eventType.equals ( MessageUtil.EVENT_TYPE_UNSUBSCRIBE ) ) { - // TODO 取消订阅后用户再收不到公众号发送的消息,因此不需要回复消息 - } - //菜单点击事件 - else if ( eventType.equals ( MessageUtil.EVENT_TYPE_CLICK ) ) { - //事件KEY值 - String eventKey = requestMap.get ( "EventKey" ); - String menuName = ""; - //TODO 根据自定义菜单值与eventKey比较来进行下一步操作 - //响应按键数据 - switch ( Integer.valueOf ( eventKey ) ) { - case 31: - menuName = "三种方式,任您蹂躏。\n" + - "客服微信号:erban2018\n" + - "QQ一群581321437(已满),二群585749306\n" + - "电话:020-86175180(只接受工作时间内的来电哦。)"; - break; - case 33: - menuName = "待开发"; - break; - default: - break; - } - respContent = menuName; - } - } - textMessage.setContent ( respContent ); - respMessage = MessageUtil.textMessageToXml ( textMessage ); - - } catch ( Exception e ) { - // TODO: handle exception - e.printStackTrace ( ); - } - return respMessage; - - } - - /** - * 微信oauth2授权登录时根据获取的code来作登录校验 - * @Author yuanyi - * @param code - * @return - */ - -// public OpenIdInfoVo getOpenId ( String code ) { - public OpenIdInfoVo getOpenIdInfo (String code){ - /* - 获取openID(√) - */ - LOGGER.info ( "==============服务器未获取给用户的openid==============" ); - HashMap openIdMap = new HashMap ( ); - openIdMap.put ( "appid" , WxConfig.appId); - openIdMap.put ( "secret" , WxConfig.appSecret); - openIdMap.put ( "code" , code ); - openIdMap.put ( "grant_type" , "authorization_code" ); - //==================解析openIdInfo json字符串=========================// - String openIdInfo = HttpUtils.URLGet ( - "https://api.weixin.qq.com/sns/oauth2/access_token" , openIdMap , HttpUtils.URL_PARAM_DECODECHARSET_UTF8 ); - LOGGER.info ( "===========获取openIdInfo===========" + openIdInfo ); - Gson gson = new Gson ( ); - OpenIdInfoVo openIdInfoVo = gson.fromJson ( openIdInfo , OpenIdInfoVo.class ); - String openId = openIdInfoVo.getOpenid ( ); - if ( openId == null ) { - LOGGER.error ( "==========请求openId失败=================" ); - return null; - } - return openIdInfoVo; - - } - - - public void sendModelMsg ( Long erbanNo , String openId , String goldNum , String resultStr ) { - - LOGGER.info ( "------------发送订单通知消息请求-----------------" ); - // 第三方用户唯一凭证 - String appId = WxConfig.appId; - // 第三方用户唯一凭证密钥 - String appSecret = WxConfig.appSecret; - // 调用接口获取access_token - - - try{ -// String accessToken = wxService.getToken(); - AccessToken at = WeiXinUtil.getAccessToken ( appId , appSecret ); - - if (!StringUtils.isEmpty(at.getToken())) { - weiXinUtil.sendModelMsg ( erbanNo , openId , goldNum , at.getToken() , resultStr ); - } - }catch (Exception e){ - LOGGER.error("send model msg failed",e); - } - } - - public void sendAlertMsg(String openId,String first,String keyword1,String keyword2,String keyword3,String keyword4,String remark){ - String appId = WxConfig.appId; - // 第三方用户唯一凭证密钥 - String appSecret = WxConfig.appSecret; - // 调用接口获取access_token - - try{ -// String accessToken = wxService.getToken(); - AccessToken at = WeiXinUtil.getAccessToken ( appId , appSecret ); - if (!StringUtils.isEmpty(at.getToken())) { -// weiXinUtil.sendAlertMsg(openId,at.getToken(),first,keyword1,keyword2,keyword3,keyword4,remark); - } - }catch (Exception e){ - LOGGER.error("send alert msg failed",e); - } - - - } - - /** - *获取用户信息,此方法只有用户关注了公众号后才能拿到完整的用户信息 - */ - public UserInfo getUserInfo (String openId ) { - //http请求方式: GET https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN - String url = "https://api.weixin.qq.com/cgi-bin/user/info"; - //获取access_token - AccessToken accessToken = WeiXinUtil.getAccessToken ( - WxConfig.appId , WxConfig.appSecret ); - LOGGER.info ( "==>获取微信用户信息URL:" + url ); - LOGGER.info ( "==>accessToken:" + accessToken.getToken ( ) ); - LOGGER.info ( "==>openid:" + openId ); - String result = HttpUtils.sendGet ( url, - "access_token="+ accessToken.getToken ( )+ - "&openid="+openId+ - "&lang=zh_CN"); - LOGGER.info ( "==>获取微信用户返回结果:" + result ); - UserInfo userInfo = new Gson ().fromJson ( result,UserInfo.class ); - return userInfo; - } - - /** - * 网页授权时获取用户的微信信息 - * @param openId - * @param token - * @return - */ - public UserInfo getUserInfoV2(String openId,String token){ - String url = "https://api.weixin.qq.com/sns/userinfo"; - - LOGGER.info ( "==>网页授权的accessToken:" + token ); - String result = HttpUtils.sendGet ( url, - "access_token="+ token+ - "&openid="+openId+ - "&lang=zh_CN"); - LOGGER.info ( "==>网页授权调用后查询微信用户返回结果:" + result ); - UserInfo userInfo = new Gson().fromJson(result,UserInfo.class); - return userInfo; - } - - public UserInfo getUserInfoByCode(String code){ - OpenIdInfoVo openIdInfoVo = this.getOpenIdInfo(code); - String openId = openIdInfoVo.getOpenid(); - String token = openIdInfoVo.getAccess_token(); - UserInfo userInfo = this.getUserInfoV2(openId,token); - return userInfo; - } - - // public InputStream getWxRecodeInputStream(String code,String mediaId){ -// OpenIdInfoVo openIdInfoVo = this.getOpenIdInfo(code); -// HashMap paramMap = new HashMap (); -// String accessToken = openIdInfoVo.getAccess_token(); -// paramMap.put("access_token",accessToken); -// paramMap.put("media_id",mediaId); -// String url = "http://file.api.weixin.qq.com/cgi-bin/media/get"; -// String result = HttpUtils.URLGet(url,paramMap,HttpUtils.URL_PARAM_DECODECHARSET_UTF8); -// } - - public InputStream getWxRecodeInputStream(String code, String mediaId){ - OpenIdInfoVo openIdInfoVo = this.getOpenIdInfo(code); - String accessToken = openIdInfoVo.getAccess_token(); - String mediaUrl = ""; - String url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=" + accessToken + "&media_id=" + mediaId; - InputStream is = null; - try { - URL urlGet = new URL(url); - HttpURLConnection http = (HttpURLConnection) urlGet.openConnection(); - http.setRequestMethod("GET"); // 必须是get方式请求   - http.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); - http.setDoOutput(true); - http.setDoInput(true); - System.setProperty("sun.net.client.defaultConnectTimeout", "30000");// 连接超时30秒   - System.setProperty("sun.net.client.defaultReadTimeout", "30000"); // 读取超时30秒   - http.connect(); - // 获取文件转化为byte流   - is = http.getInputStream(); - LOGGER.info("文件流======:"+is); - mediaUrl = qinniuService.uploadByStream(is); - LOGGER.info("文件地址为:" + mediaUrl); - } catch (Exception e) { - LOGGER.error("get recode from wx failed",e); - } - return is; - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WXResponse.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WXResponse.java deleted file mode 100644 index 16d6dba79..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WXResponse.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.accompany.business.service.wx; - -public class WXResponse { - private String access_token; - private String ticket; - private int expires_in; - private int errcode; - private String errmsg; - - public int getErrcode() { - return errcode; - } - - - public String getTicket() { - return ticket; - } - - public void setTicket(String ticket) { - this.ticket = ticket; - } - - public void setErrcode(int errcode) { - this.errcode = errcode; - } - - public String getErrmsg() { - return errmsg; - } - - public void setErrmsg(String errmsg) { - this.errmsg = errmsg; - } - - public String getAccess_token() { - return access_token; - } - - public void setAccess_token(String access_token) { - this.access_token = access_token; - } - - public int getExpires_in() { - return expires_in; - } - - public void setExpires_in(int expires_in) { - this.expires_in = expires_in; - } - - @Override - public String toString() { - return "WXResponse{" + - "access_token='" + access_token + '\'' + - ", ticket='" + ticket + '\'' + - ", expires_in=" + expires_in + - ", errcode=" + errcode + - ", errmsg='" + errmsg + '\'' + - '}'; - } -} \ No newline at end of file diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WxMpOpenidResp.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WxMpOpenidResp.java deleted file mode 100644 index 613551bcd..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WxMpOpenidResp.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.accompany.business.service.wx; - -import com.google.gson.annotations.SerializedName; -import lombok.Data; - -/** - * 获取微信小程序 openId 响应 - * - * @author linuxea - * @date 2019/8/6 17:55 - */ -@Data -public class WxMpOpenidResp { - - /** 用户唯一标识 */ - private String openid; - - /** 会话密钥 */ - @SerializedName("session_key") - private String sessionKey; - - /** 用户在开放平台的唯一标识符,在满足 UnionID 下发条件的情况下会返回 */ - @SerializedName("unionid") - private String unionId; - - /** 错误码 -1 系统繁忙,此时请开发者稍候再试 0 请求成功 40029 code 无效 45011 频率限制,每个用户每分钟100次 请求正确的结果没有返回 */ - @SerializedName("errcode") - private int errCode; - - /** 错误信息 */ - @SerializedName("errmsg") - private String errMsg; -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WxMpService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WxMpService.java deleted file mode 100644 index cc272e4f9..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WxMpService.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.accompany.business.service.wx; - -import com.accompany.core.util.StringUtils; -import com.google.gson.Gson; -import com.accompany.common.utils.HttpUtils; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.springframework.stereotype.Service; - -import java.io.IOException; - -/** - * 小程序openid获取 - * - * @author fangchengyan - * @date 2019-09-26 10:06 - */ -@Slf4j -@Service -public class WxMpService { - - Gson gson = new Gson(); - - /** - * 获取小程序openid - * @param url - * @return - */ - public String getOpenId(String url) { - try { - String result = HttpUtils.executeGet(url); - if(StringUtils.isBlank(result)) { - return ""; - } - WxMpOpenidResp resp = gson.fromJson(result, WxMpOpenidResp.class); - log.info("获取openid结果:{}", result); - if(null != resp && resp.getErrCode() == 0) { - return resp.getOpenid(); - } else { - log.warn("获取小程序openid失败, url:{}, 返回结果:{}", url, result); - return ""; - } - } catch (IOException e) { - log.error("获取微信小程序openid异常, 异常信息:{}", ExceptionUtils.getStackTrace(e)); - } - return ""; - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WxService.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WxService.java deleted file mode 100644 index e9357fa9f..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/service/wx/WxService.java +++ /dev/null @@ -1,194 +0,0 @@ -package com.accompany.business.service.wx; - -import com.accompany.business.service.ChargeRecordUpdateService; -import com.accompany.business.service.ChargeService; -import com.accompany.business.vo.WxConfigVo; -import com.accompany.common.constant.Constant; -import com.accompany.common.exception.BusinessException; -import com.accompany.common.redis.RedisKey; -import com.accompany.common.result.BusiResult; -import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.EncryptUtils; -import com.accompany.common.utils.UUIDUitl; -import com.accompany.common.wx.result.WxAccessTokenRet; -import com.accompany.common.wx.result.WxTicketRet; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.service.common.JedisLockService; -import com.accompany.core.service.common.JedisService; -import com.accompany.payment.config.WxConfig; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.service.ChargeRecordService; -import com.google.gson.Gson; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -/** - * @author yuanyi - * @since 2020-06-2 - * 公众号充值 - */ -@Slf4j -@Service -public class WxService { - - private static final String wx_access_token_url_base = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential"; - private static final String wx_jsapi_ticket_url_base = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi"; - /** 比微信返回的失效时间提前的时间,单位s**/ - private static final int early_expire = 200; - - private static final List jsApi = Arrays.asList("onMenuShareTimeline", "onMenuShareAppMessage", "onMenuShareQQ", "onMenuShareWeibo"); - - private static Gson gson = new Gson(); - - @Autowired - private JedisService jedisService; - @Autowired - ChargeRecordUpdateService chargeRecordUpdateService; - @Autowired - JedisLockService jedisLockService; - @Autowired - private ChargeRecordService chargeRecordService; - @Autowired - private ChargeService chargeService; - - /** - * 刷新access_token - */ - public String refreshToken() throws Exception { - String url = wx_access_token_url_base + "&appid=" + WxConfig.appId + "&secret=" + WxConfig.appSecret; - String result = com.accompany.common.utils.HttpUtils.executeGet(url); - log.info("refreshToken result=" + result); - WxAccessTokenRet wxAccessTokenRet = gson.fromJson(result, WxAccessTokenRet.class); - if (StringUtils.isBlank(wxAccessTokenRet.getAccess_token())) { - throw new BusinessException(wxAccessTokenRet.getErrmsg()); - } - int expires_in = wxAccessTokenRet.getExpires_in(); - jedisService.write(RedisKey.wx_token.getKey(), wxAccessTokenRet.getAccess_token(), expires_in - early_expire); - return wxAccessTokenRet.getAccess_token(); - } - - /** - * 刷新jsapi_ticket - */ - public String refreshWxTicket(String token) throws Exception { - if (StringUtils.isBlank(token)) { - throw new BusinessException("微信refreshTicket刷新tikcet异常...."); - } - String url = wx_jsapi_ticket_url_base + "&access_token=" + token; - String result = com.accompany.common.utils.HttpUtils.executeGet(url); - log.info("weixin refreshWxTicket result=" + result); - WxTicketRet wxTicketRet = gson.fromJson(result, WxTicketRet.class); - if (StringUtils.isBlank(wxTicketRet.getTicket())) { - throw new BusinessException(wxTicketRet.getErrmsg()); - } - int expires_in = wxTicketRet.getExpires_in(); - jedisService.write(RedisKey.wx_ticket.getKey(), wxTicketRet.getTicket(), expires_in - early_expire); - return wxTicketRet.getTicket(); - } - - /** - * 生成签名 - * - * @return String - */ - public String createSignature(String url, String ticket, String noncestr, String timestamp) { - //注意这里参数名必须全部小写,且必须有序 - String string1 = "jsapi_ticket=" + ticket + "&noncestr=" + noncestr + "×tamp=" + timestamp + "&url=" + url; - log.info("createSignature string=" + string1); - return EncryptUtils.getSHA1(string1); - } - - /** - * 生成页面配置信息 - * - * @return WXConfigVo - */ - public BusiResult getWxConfig(String url) throws Exception { - WxConfigVo wxConfigVo = new WxConfigVo(); - wxConfigVo.setAppId(WxConfig.appId); - wxConfigVo.setJsApiList(jsApi); - String timestamp = createTimestamp(); - String nonceStr = createNonceStr(); - String ticket = getTicket(); - String sign = createSignature(url, ticket, nonceStr, timestamp); - wxConfigVo.setNonceStr(nonceStr); - wxConfigVo.setTimestamp(timestamp); - wxConfigVo.setSignature(sign); - BusiResult busiResult = new BusiResult<>(BusiStatus.SUCCESS); - busiResult.setData(wxConfigVo); - return busiResult; - } - - public String getTicket() throws Exception { - String result = jedisService.read(RedisKey.wx_ticket.getKey()); - if (StringUtils.isBlank(result)) { - result = refreshWxTicket(getToken()); - } - return result; - } - - public String getToken() throws Exception { - String result = jedisService.read(RedisKey.wx_token.getKey()); - if (StringUtils.isBlank(result)) { - result = refreshToken(); - } - return result; - } - - private static String createNonceStr() { - return UUIDUitl.get(); - } - - private static String createTimestamp() { - return Long.toString(System.currentTimeMillis() / 1000); - } - - public BusiResult submitPayWx(Long uid, String chargeProdId, String nick, Long erban_no, String openId, String ip, String app, String successUrl, Integer chargeMoney) { - Object result = chargeService.applyCharge3( - uid, chargeProdId, Constant.ChargeChannel.wx_pub, ip, successUrl, openId, app, null, chargeMoney); - return new BusiResult<>(result); - } - - /** - * @param map 回调数据 - * @return 返回结果 - * @throws Exception - */ - public BusiResult getPayResult(Map map){ - String orderNo = map.get("out_trade_no"); - Integer totalFee = Integer.parseInt(map.get("total_fee")); - ChargeRecord chargeRecord = chargeRecordService.getChargeRecordById(orderNo); - - String lockval = jedisLockService.lock(RedisKey.lock_wx_notify.getKey(orderNo), 5000); - try { - if (StringUtils.isEmpty(lockval)) { - throw new ServiceException(BusiStatus.BUSIERROR); - } - if(totalFee.intValue() != chargeRecord.getAmount().intValue()){ - throw new ServiceException(BusiStatus.CHARGE_AMOUNT_INCORRECT); - } - chargeService.updateAppPayData(chargeRecord); - return new BusiResult(chargeRecord); - } finally { - jedisLockService.unlock(RedisKey.lock_wx_notify.getKey(orderNo), lockval); - } - } - - public BusiResult submitPayWxForMicroMall(Long myUid, String chargeProdId, String nick, Long myErBanNo, String openId, String ip, String app, String successUrl) { - Object result = chargeService.applyCharge3( - myUid, chargeProdId, Constant.ChargeChannel.wx_micro_mall_pub, ip, successUrl, openId, app, null, null); - return new BusiResult<>(result); - } - - public BusiResult submitPayWxForPub2(Long myUid, String chargeProdId, String nick, Long myErBanNo, String openId, String ip, String app, String successUrl, Integer chargeMoney) { - Object result = chargeService.applyCharge3( - myUid, chargeProdId, Constant.ChargeChannel.wx_pub2, ip, successUrl, openId, app, null, chargeMoney); - return new BusiResult<>(result); - } -} \ No newline at end of file diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/testclient/HomeJobClient.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/testclient/HomeJobClient.java deleted file mode 100644 index 3c4004c69..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/testclient/HomeJobClient.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.accompany.business.testclient; - -/** - * Created by liuguofu on 2017/10/6. - */ -public class HomeJobClient { -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/testclient/RoomClient.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/testclient/RoomClient.java deleted file mode 100644 index 2917d87c6..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/testclient/RoomClient.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.accompany.business.testclient; - -import com.accompany.business.service.ErBanNetEaseService; - -/** - * Created by liuguofu on 2017/10/5. - */ -public class RoomClient { - static ErBanNetEaseService erBanNetEaseService=new ErBanNetEaseService(); - public static void business(String args[]) throws Exception{ - getRoomInfo(10740002l); -// getRoomMemberListInfo(17856834L,90575L); - - } - - public static String getRoomInfo(Long roomId) throws Exception{ - erBanNetEaseService.getRoomMessage(roomId); - return ""; - } - public static String getRoomMemberListInfo(Long roomId,Long uid) throws Exception{ - erBanNetEaseService.getRoomMemberListInfo(roomId,uid); - return ""; - } -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/util/ImageUtil.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/util/ImageUtil.java deleted file mode 100644 index 821d72536..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/util/ImageUtil.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.accompany.business.util; - -import javax.imageio.ImageIO; -import javax.imageio.ImageReadParam; -import javax.imageio.ImageReader; -import javax.imageio.stream.ImageInputStream; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.*; -import java.util.Iterator; - -/** - * Created by liuguofu on 2017/4/3. - */ -public class ImageUtil { - public static void cutJPG(InputStream input, OutputStream out, int x, - int y, int width, int height) throws IOException { - ImageInputStream imageStream = null; - try { - Iterator readers = ImageIO.getImageReadersByFormatName("jpg"); - ImageReader reader = readers.next(); - imageStream = ImageIO.createImageInputStream(input); - reader.setInput(imageStream, true); - ImageReadParam param = reader.getDefaultReadParam(); - - System.out.println(reader.getWidth(0)); - System.out.println(reader.getHeight(0)); - Rectangle rect = new Rectangle(x, y, width, height); - param.setSourceRegion(rect); - BufferedImage bi = reader.read(0, param); - ImageIO.write(bi, "jpg", out); - } finally { - imageStream.close(); - } - } - - - public static void cutPNG(InputStream input, OutputStream out, int x, - int y, int width, int height) throws IOException { - ImageInputStream imageStream = null; - try { - Iterator readers = ImageIO.getImageReadersByFormatName("png"); - ImageReader reader = readers.next(); - imageStream = ImageIO.createImageInputStream(input); - reader.setInput(imageStream, true); - ImageReadParam param = reader.getDefaultReadParam(); - - System.out.println(reader.getWidth(0)); - System.out.println(reader.getHeight(0)); - - Rectangle rect = new Rectangle(x, y, width, height); - param.setSourceRegion(rect); - BufferedImage bi = reader.read(0, param); - ImageIO.write(bi, "png", out); - } finally { - imageStream.close(); - } - } - - public static void cutImage(InputStream input, OutputStream out, String type,int x, - int y, int width, int height) throws IOException { - ImageInputStream imageStream = null; - try { - String imageType=(null==type||"".equals(type))?"jpg":type; - Iterator readers = ImageIO.getImageReadersByFormatName(imageType); - ImageReader reader = readers.next(); - imageStream = ImageIO.createImageInputStream(input); - reader.setInput(imageStream, true); - ImageReadParam param = reader.getDefaultReadParam(); - Rectangle rect = new Rectangle(x, y, width, height); - param.setSourceRegion(rect); - BufferedImage bi = reader.read(0, param); - ImageIO.write(bi, imageType, out); - } finally { - imageStream.close(); - } - } - - - public static void business(String[] args) throws Exception { - ImageUtil.cutJPG(new FileInputStream("c:\\test.JPG"), - new FileOutputStream("c:\\test2.jpg"), 0,0,200,100); - - ImageUtil.cutPNG(new FileInputStream("c:\\1.png"), - new FileOutputStream("c:\\test3.png"), 0,0,50,40); - } -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/util/MD5.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/util/MD5.java deleted file mode 100644 index 757a835bf..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/util/MD5.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.accompany.business.util; - -public class MD5 { - public static void main(String[] args) throws Exception { - String str = "12345678"; - System.out.println(getMD5(str)); - } - - public static String getMD5(String source){ - return getMD5(source.getBytes()); - } - - public static String getMD5(byte[] source) { - String s = null; - char hexDigits[] = { // 用来将字节转换成 16 进制表示的字符 - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - md.update(source); - byte tmp[] = md.digest(); // MD5 的计算结果是一个 128 位的长整数, - // 用字节表示就是 16 个字节 - char str[] = new char[16 * 2]; // 每个字节用 16 进制表示的话,使用两个字符, - // 所以表示成 16 进制需要 32 个字符 - int k = 0; // 表示转换结果中对应的字符位置 - for (int i = 0; i < 16; i++) { // 从第一个字节开始,对 MD5 的每一个字节 - // 转换成 16 进制字符的转换 - byte byte0 = tmp[i]; // 取第 i 个字节 - str[k++] = hexDigits[byte0 >>> 4 & 0xf]; // 取字节中高 4 位的数字转换, - // >>> - // 为逻辑右移,将符号位一起右移 - str[k++] = hexDigits[byte0 & 0xf]; // 取字节中低 4 位的数字转换 - } - s = new String(str); // 换后的结果转换为字符串 - - } catch (Exception ignored) { - } - return s; - } -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/util/WeiXinUtil.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/util/WeiXinUtil.java deleted file mode 100644 index f81db6aeb..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/util/WeiXinUtil.java +++ /dev/null @@ -1,296 +0,0 @@ -package com.accompany.business.util; - - -import com.accompany.business.wechat.AccessToken; -import com.accompany.business.wechat.MyX509TrustManager; -import com.accompany.business.wechat.pojo.Menu; -import com.accompany.common.utils.DateTimeUtil; -import com.accompany.payment.config.WxConfig; -import com.google.gson.*; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.ConnectException; -import java.net.URL; -import java.util.Date; - -/** - * 微信公众接口工具类 - * - * 项目名称:WeiChatService - */ -@Slf4j -@Component -public class WeiXinUtil { - // 获取access_token的接口地址(GET) 限200(次/天) - public final static String access_token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET"; - // 菜单创建(POST) 限100(次/天) - public static String menu_create_url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN"; - //发送模板消息 - public static String model_msg_url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN"; - - /** - * 发起https请求 - * @param requestUrl 请求地址 - * @param requestMethod 请求方式(Get或者post) - * @param outputStr 提交数据 - * @return - */ - public static JsonObject httpsRequest ( String requestUrl, String requestMethod, String outputStr ) { - JsonObject jsonObject = null; - StringBuffer buffer = new StringBuffer ( ); - try { - //创建SSLcontext管理器对像,使用我们指定的信任管理器初始化 - TrustManager[] tm = { new MyX509TrustManager ( ) }; - SSLContext sslContext = SSLContext.getInstance ( "SSL", "SunJSSE" ); - sslContext.init ( null, tm, new java.security.SecureRandom ( ) ); - SSLSocketFactory ssf = sslContext.getSocketFactory ( ); - - URL url = new URL ( requestUrl ); - HttpsURLConnection httpsUrlConn = ( HttpsURLConnection ) url.openConnection ( ); - httpsUrlConn.setSSLSocketFactory ( ssf ); - httpsUrlConn.setDoInput ( true ); - httpsUrlConn.setDoOutput ( true ); - httpsUrlConn.setUseCaches ( false ); - //设置请求方式(GET/POST) - httpsUrlConn.setRequestMethod ( requestMethod ); - if ( "GET".equalsIgnoreCase ( requestMethod ) ) { - httpsUrlConn.connect ( ); - } - - //当有数据需要提交时 - if ( outputStr != null ) { - OutputStream outputStream = httpsUrlConn.getOutputStream ( ); - //防止中文乱码 - outputStream.write ( outputStr.getBytes ( "UTF-8" ) ); - outputStream.close ( ); - outputStream = null; - } - - //将返回的输入流转换成字符串 - InputStream inputStream = httpsUrlConn.getInputStream ( ); - InputStreamReader inputStreamReader = new InputStreamReader ( inputStream, "UTF-8" ); - BufferedReader bufferedReader = new BufferedReader ( inputStreamReader ); - - String str = null; - while ( ( str = bufferedReader.readLine ( ) ) != null ) { - buffer.append ( str ); - } - - bufferedReader.close ( ); - inputStreamReader.close ( ); - - inputStream.close ( ); - inputStream = null; - - httpsUrlConn.disconnect ( ); -// jsonObject = JSONObject.fromObject ( buffer.toString ( ) ); - JsonElement jsonElement = new JsonParser ().parse ( buffer.toString () ); - jsonObject = jsonElement.getAsJsonObject (); - } catch ( ConnectException ce ) { - // TODO: handle exception - log.error ( "Weixin server connection timed out." ); - } catch ( Exception e ) { - // TODO: handle exception - log.error ( "https request error:{}", e ); - } - - return jsonObject; - } - - public static AccessToken getAccessToken ( String appid, String appsecret ) { - AccessToken accessToken = null; - String requestUrl = access_token_url.replace ( "APPID", appid ).replace ( "APPSECRET", appsecret ); - log.info ("=========获取AccessToken========"); - log.info ( requestUrl ); - JsonObject jsonObject = httpsRequest ( requestUrl, "GET", null ); - //如果请求成功 - if ( jsonObject != null ) { - try { - accessToken = new AccessToken ( ); - accessToken.setToken ( jsonObject.get ( "access_token" ).toString ().replace ( "\"","" ) ); - accessToken.setExpiresIn ( jsonObject.get ( "expires_in" ).toString ().replace ( "\"","" ) ); - } catch ( Exception e ) { - // TODO: handle exception - // TODO: handle exception - accessToken = null; - // 获取token失败 - log.info ( "获取token失败 errcode:{" + jsonObject.get ( "errcode" ) + "} errmsg:{" + jsonObject.get ( "errmsg" ) + "}" ); - - } - } - return accessToken; - } - public static void business(String [] a){ - String appid="wx009d793f92c24eec"; - String appsecret = "d99ac5ed29071943d1654a40bb0adb68"; - AccessToken accessToken = null; - String requestUrl = access_token_url.replace ( "APPID", appid ).replace ( "APPSECRET", appsecret ); - System.out.println ("===="+requestUrl ); - accessToken = getAccessToken (appid,appsecret ); - System.out.println (accessToken.getToken () ); - System.out.println (accessToken.getExpiresIn () ); - } - - /** - * 创建菜单 - * - * @param menu 菜单实例 - * @param accessToken 有效的access_token - * @return 0表示成功,其他值表示失败 - */ - public static String createMenu ( Menu menu, String accessToken ) { - String result = ""; - - // 拼装创建菜单的url - String url = menu_create_url.replace ( "ACCESS_TOKEN", accessToken ); - // 将菜单对象转换成json字符串 -// String jsonMenu = JSONObject.fromObject ( menu ).toString ( ); - log.info ( "==========url:"+url ); - Gson gson = new GsonBuilder ().disableHtmlEscaping().create(); - String jsonMenu = gson.toJson (menu); - log.info ( "自定义菜单json:" + jsonMenu ); - // 调用接口创建菜单 - JsonObject jsonObject = httpsRequest ( url, "POST", jsonMenu ); - if ( null != jsonObject ) { - if ( !jsonObject.get ( "errcode" ).equals ( "0" ) ) { - result = jsonObject.get ( "errcode" ).toString (); - } - } - - return result; - } - public void sendModelMsg ( Long erbanNo,String openId,String goldNum, String accessToken,String resultStr ) { - - String url = model_msg_url.replace ( "ACCESS_TOKEN", accessToken ); - //TODO 测试,冲多少都只要一分钱 - String jsonModelMsg = "{ \n" + - " \"touser\":\""+openId+"\", \n" + - " \"template_id\":\""+ WxConfig.modelMsgId +"\", \n" + - " \"topcolor\":\"#FF0000\", \n" + - " \"data\":{ \n" + - " \"first\": {\n" + - "\n" + - " \"value\":\""+"66星球支付订单"+"\",\n" + - "\n" + - " \"color\":\"#173177\"\n" + - "\n" + - " },\n" + - " \"keyword1\": {\n" + - "\n" + - " \"value\":\""+erbanNo+""+"\",\n" + - "\n" + - " \"color\":\"#173177\"\n" + - "\n" + - " },\n" + - " \"keyword2\": {\n" + - "\n" + - " \"value\":\""+goldNum+" 金币"+"\",\n" + - "\n" + - " \"color\":\"#173177\"\n" + - "\n" + - " },\n" + - " \"keyword3\": {\n" + - "\n" + - " \"value\":\""+"在线支付"+"\",\n" + - "\n" + - " \"color\":\"#173177\"\n" + - "\n" + - " },\n" + - "\n" + - " \"keyword4\":{\n" + - "\n" + - " \"value\":\""+ DateTimeUtil.convertDate(new Date(),"yyyy-MM-dd hh:mm:ss")+"\",\n" + - "\n" + - " \"color\":\"#173177\"\n" + - "\n" + - " },\n" + - "\n" + - " \"remark\":{ \n" + - " \"value\":\"备注:如有疑问,请致电客服。\", \n" + - " \"color\":\"颜色#173177\" \n" + - " } \n" + - " } \n" + - " }"; -// log.info ( "模板消息json:" + jsonModelMsg ); - JsonObject jsonObject = httpsRequest ( url, "POST", jsonModelMsg ); - //{"errcode":0,"errmsg":"ok","msgid":467018897} - if ( null != jsonObject ) { - if ( !jsonObject.get ( "errcode" ).toString ().equals ( "0" ) ) { - log.info ( "发送充值通知失败 errcode:{" + jsonObject.get ( "errcode" ) + "} errmsg:{" + jsonObject.get ( "errmsg" ) + "}" ); - }else{ - log.info ( "发送充值通知成功!"+"平台号:"+erbanNo); - } - } - } - - public void sendAlertMsg(String openId,String accessToken,String first,String keyword1,String keyword2,String keyword3,String keyword4,String remark){ - String url = model_msg_url.replace ( "ACCESS_TOKEN", accessToken ); - String jsonModelMsg = "{ \n" + - " \"touser\":\""+openId+"\", \n" + - " \"template_id\":\""+ WxConfig.alertMsgId+"\", \n" + - " \"topcolor\":\"#FF0000\", \n" + - " \"data\":{ \n" + - " \"first\": {\n" + - "\n" + - " \"value\":\""+first+"\",\n" + - "\n" + - " \"color\":\"#173177\"\n" + - "\n" + - " },\n" + - " \"keyword1\": {\n" + - "\n" + - " \"value\":\""+keyword1+"\",\n" + - "\n" + - " \"color\":\"#173177\"\n" + - "\n" + - " },\n" + - " \"keyword2\": {\n" + - "\n" + - " \"value\":\""+keyword2+"\",\n" + - "\n" + - " \"color\":\"#173177\"\n" + - "\n" + - " },\n" + - " \"keyword3\": {\n" + - "\n" + - " \"value\":\""+keyword3+"\",\n" + - "\n" + - " \"color\":\"#173177\"\n" + - "\n" + - " },\n" + - " \"keyword4\": {\n" + - "\n" + - " \"value\":\""+keyword4+"\",\n" + - "\n" + - " \"color\":\"#173177\"\n" + - "\n" + - " },\n" + - " \"remark\": {\n" + - "\n" + - " \"value\":\""+remark+"\",\n" + - "\n" + - " \"color\":\"#173177\"\n" + - "\n" + - " }\n" + - "\n" + - " } \n" + - " }"; - JsonObject jsonObject = httpsRequest ( url, "POST", jsonModelMsg ); - if ( null != jsonObject ) { - if ( !jsonObject.get ( "errcode" ).toString ().equals ( "0" ) ) { - log.info ( "发送预警通知失败 errcode:{" + jsonObject.get ( "errcode" ) + "} errmsg:{" + jsonObject.get ( "errmsg" ) + "}" ); - }else{ - log.info ( "发送预警通知成功!"+"平台号:"+openId); - } - } - } -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/AccessToken.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/AccessToken.java deleted file mode 100644 index dcb4407ee..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/AccessToken.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.accompany.business.wechat; - -/** - * access_token响应(重要)微信唯一接口 - * AccessToken - * @author 电子小孩 - * - * 2016年5月27日 下午5:30:27 - */ -public class AccessToken { - - //获取到的凭证 - private String token; - //凭证有效时间 - private String expiresIn; - public String getToken() { - return token; - } - public void setToken(String token) { - this.token = token; - } - public String getExpiresIn() { - return expiresIn; - } - public void setExpiresIn(String expiresIn) { - this.expiresIn = expiresIn; - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/MenuManager.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/MenuManager.java deleted file mode 100644 index 2f49db5ea..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/MenuManager.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.accompany.business.wechat; - - -/** - * MenuManager - * - * @author 电子小孩 - * 菜单创建及管理类 - * 2016年5月27日 下午5:11:32 - */ -public class MenuManager { - -// private static final Logger LOGGER = Logger.getLogger ( MenuManager.class ); -// -// private PropertyConfig propertyConfig; -// -// public static String createMenu ( ) { -// LOGGER.debug ( "------------开始创建菜单--------------------" ); -// // 第三方用户唯一凭证 -// String appId = PropertyUtil.getProperty ( "APP_ID" ); -// LOGGER.info ( "=====appId:" + appId ); -// // 第三方用户唯一凭证密钥 -// String appSecret = PropertyUtil.getProperty ( "APP_SECRET" ); -// LOGGER.info ( "=====appSecret:" + appSecret ); -// // 调用接口获取access_token -// AccessToken at = WeiXinUtil.getAccessToken ( appId , appSecret ); -// -// String result = ""; -// if ( null != at ) { -// LOGGER.info ( "==========AccessToken:" + at.getToken ( ) + "==========" ); -// // 调用接口创建菜单 -// result = WeiXinUtil.createMenu ( getMenu ( ) , at.getToken ( ) ); -// // 判断菜单创建结果 -// if ( result.equals ( "0" ) ) { -// LOGGER.info ( "菜单创建成功!" ); -// } else { -// LOGGER.info ( "菜单创建失败,错误码:" + result ); -// } -// } else { -// LOGGER.info ( "-----------获取 AccessToken 失败----------" ); -// } -// return result; -// } -// -// /** -// * 组装菜单数据 -// * view - URL跳转 -// * check-事件推送 -// * -// * @return -// */ -// private static Menu getMenu ( ) { -// CommonButton btn11 = new CommonButton ( ); -// btn11.setName ( "软件下载" ); -// btn11.setType ( "view" ); -// btn11.setKey ( "11" ); -// btn11.setUrl ( PropertyUtil.getProperty ( "HOME" ) ); -// //==========与设备对接菜单=============// -// CommonButton btn21 = new CommonButton ( ); -// btn21.setName ( "金币充值" ); -// btn21.setType ( "view" ); -// btn21.setKey ( "21" ); -// btn21.setUrl ( "https://open.weixin.qq.com/connect/oauth2/authorize?" + -// "appid=" + PropertyUtil.getProperty ( "APP_ID" ) + -// "&redirect_uri=" + PropertyUtil.getProperty ( "GET_CODE_URL" ) + -// "&response_type=code&scope=snsapi_userinfo" + -// "&state=park" + -// "&connect_redirect=1" ); -// CommonButton btn31 = new CommonButton ( ); -// btn31.setName ( "调戏客服" ); -// btn31.setType ( "click" ); -// btn31.setKey ( "31" ); -// CommonButton btn32 = new CommonButton ( ); -// btn32.setName ( "常见疑难" ); -// btn32.setType ( "view" ); -// btn32.setKey ( "32" ); -// btn32.setUrl ( PropertyUtil.getProperty ( "GUIDE" ) ); -// CommonButton btn33 = new CommonButton ( ); -// btn33.setName ( "轻寻小故事" ); -// btn33.setType ( "click" ); -// btn33.setKey ( "33" ); -// -// -// ComplexButton mainBtn3 = new ComplexButton ( ); -// mainBtn3.setName ( "自助" ); -// mainBtn3.setSub_button ( new CommonButton[] { btn31 , btn32 , btn33 } ); -// -// Menu menu = new Menu ( ); -// menu.setButton ( new Button[] { btn11 , btn21 , mainBtn3 } ); -// -// return menu; -// -// -// } - - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/MyX509TrustManager.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/MyX509TrustManager.java deleted file mode 100644 index 8eb5518e4..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/MyX509TrustManager.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.accompany.business.wechat; - -import javax.net.ssl.X509TrustManager; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; - -/** -* - */ - -public class MyX509TrustManager implements X509TrustManager { - - public void checkClientTrusted(X509Certificate[] chain, String authType) - throws CertificateException { - // TODO Auto-generated method stub - - } - - public void checkServerTrusted(X509Certificate[] chain, String authType) - throws CertificateException { - // TODO Auto-generated method stub - - } - - public X509Certificate[] getAcceptedIssuers() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/BaseMessage.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/BaseMessage.java deleted file mode 100644 index ee5455421..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/BaseMessage.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.accompany.business.wechat.message.req; - -/** - * - * BaseMessage - * @author 电子小孩 - * Message基类(用户向公众号发送的消息) - * 2016年5月27日 下午5:18:37 - */ -public class BaseMessage { - - // 开发者微信号 - private String ToUserName; - // 发送方帐号(一个OpenID) - private String FromUserName; - // 消息创建时间 (整型) - private long CreateTime; - // 消息类型(text/image/location/link) - private String MsgType; - // 消息id,64位整型 - private long MsgId; - //====================新增===================// - //接收的语音消息 - private String Recognition; - - public String getRecognition() - { - return Recognition; - } - public void setRecognition(String recognition) - { - Recognition = recognition; - } - public String getToUserName() { - return ToUserName; - } - public void setToUserName(String toUserName) { - ToUserName = toUserName; - } - public String getFromUserName() { - return FromUserName; - } - public void setFromUserName(String fromUserName) { - FromUserName = fromUserName; - } - public long getCreateTime() { - return CreateTime; - } - public void setCreateTime(long createTime) { - CreateTime = createTime; - } - public String getMsgType() { - return MsgType; - } - public void setMsgType(String msgType) { - MsgType = msgType; - } - public long getMsgId() { - return MsgId; - } - public void setMsgId(long msgId) { - MsgId = msgId; - } -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/EventMessage.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/EventMessage.java deleted file mode 100644 index 12327841b..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/EventMessage.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.accompany.business.wechat.message.req; - -/** - * 请求事件消息 - * EventMessage - * @author 电子小孩 - * - * 2016年5月27日 下午5:20:00 - */ -public class EventMessage { - - // 开发者微信号 - private String ToUserName; - // 发送方帐号(一个OpenID) - private String FromUserName; - // 消息创建时间 (整型) - private long CreateTime; - // 消息类型(text/image/location/link) - private String MsgType; - //事件类型 (subscribe(订阅)、unsubscribe(取消订阅)、CLICK(自定义菜单点击事件)) - private String Event; - //事件KEY值 (与自定义菜单接口中KEY值对应) - private String EventKey; - - public String getToUserName() { - return ToUserName; - } - public void setToUserName(String toUserName) { - ToUserName = toUserName; - } - public String getFromUserName() { - return FromUserName; - } - public void setFromUserName(String fromUserName) { - FromUserName = fromUserName; - } - public long getCreateTime() { - return CreateTime; - } - public void setCreateTime(long createTime) { - CreateTime = createTime; - } - public String getMsgType() { - return MsgType; - } - public void setMsgType(String msgType) { - MsgType = msgType; - } - public String getEvent() { - return Event; - } - public void setEvent(String event) { - Event = event; - } - public String getEventKey() { - return EventKey; - } - public void setEventKey(String eventKey) { - EventKey = eventKey; - } -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/ImageMessage.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/ImageMessage.java deleted file mode 100644 index dfa21b672..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/ImageMessage.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.accompany.business.wechat.message.req; - -/** - * 请求图片消息类 - * ImageMessage - * @author 电子小孩 - * - * 2016年5月27日 下午5:23:59 - */ -public class ImageMessage extends BaseMessage { - - // 图片链接 - private String PicUrl; - - public String getPicUrl() { - return PicUrl; - } - - public void setPicUrl(String picUrl) { - PicUrl = picUrl; - } -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/LinkMessage.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/LinkMessage.java deleted file mode 100644 index 2b56597b0..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/LinkMessage.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.accompany.business.wechat.message.req; - -/** - * 请求连接消息 - * LinkMessage - * @author 电子小孩 - * - * 2016年5月27日 下午5:24:31 - */ -public class LinkMessage extends BaseMessage { - - //消息标题 - private String Title; - // 消息描述 - private String Description; - // 消息链接 - private String Url; - public String getTitle() { - return Title; - } - public void setTitle(String title) { - Title = title; - } - public String getDescription() { - return Description; - } - public void setDescription(String description) { - Description = description; - } - public String getUrl() { - return Url; - } - public void setUrl(String url) { - Url = url; - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/LocationMessage.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/LocationMessage.java deleted file mode 100644 index ef00cc8bd..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/LocationMessage.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.accompany.business.wechat.message.req; - -/** - * 请求地址消息 - * LocationMessage - * @author 电子小孩 - * - * 2016年5月27日 下午5:24:53 - */ -public class LocationMessage extends BaseMessage { - - // 地理位置维度 - private String Location_X; - // 地理位置经度 - private String Location_Y; - // 地图缩放大小 - private String Scale; - // 地理位置信息 - private String Label; - - public String getLocation_X() { - return Location_X; - } - public void setLocation_X(String location_X) { - Location_X = location_X; - } - public String getLocation_Y() { - return Location_Y; - } - public void setLocation_Y(String location_Y) { - Location_Y = location_Y; - } - public String getScale() { - return Scale; - } - public void setScale(String scale) { - Scale = scale; - } - public String getLabel() { - return Label; - } - public void setLabel(String label) { - Label = label; - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/TextMessage.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/TextMessage.java deleted file mode 100644 index b854368e0..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/TextMessage.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.accompany.business.wechat.message.req; - -/*** - * 请求文本消息 - * TextMessage - * @author 电子小孩 - * - * 2016年5月27日 下午5:25:12 - */ -public class TextMessage extends BaseMessage { - - // 消息内容 - private String Content; - - public String getContent() { - return Content; - } - - public void setContent(String content) { - Content = content; - } - - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/package-info.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/package-info.java deleted file mode 100644 index acf4167be..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/req/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * 该包中的所有类都是用户微信处理来自用户的消息集合 - */ -/** - * @author 电子小孩 - * - * 2016年5月25日 上午9:02:23 - */ -package com.accompany.web.wechat.message.req; \ No newline at end of file diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/ArticleModel.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/ArticleModel.java deleted file mode 100644 index d4d3119dc..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/ArticleModel.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.accompany.business.wechat.message.resp; - -/** - * 图文模板 - * ArticleModel - * @author 电子小孩 - * - * 2016年5月27日 下午5:27:39 - */ -public class ArticleModel { - - // 图文消息名称 - private String Title; - // 图文消息描述 - private String Description; - // 图片链接,支持JPG、PNG格式,较好的效果为大图640*320,小图80*80,限制图片链接的域名需要与开发者填写的基本资料中的Url一致 - private String PicUrl; - // 点击图文消息跳转链接 - private String Url; - public String getTitle() { - return Title; - } - public void setTitle(String title) { - Title = title; - } - public String getDescription() { - return Description; - } - public void setDescription(String description) { - Description = description; - } - public String getPicUrl() { - return PicUrl; - } - public void setPicUrl(String picUrl) { - PicUrl = picUrl; - } - public String getUrl() { - return Url; - } - public void setUrl(String url) { - Url = url; - } - - - - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/BaseMessage.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/BaseMessage.java deleted file mode 100644 index 334f7b1fd..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/BaseMessage.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.accompany.business.wechat.message.resp; - - -/** - * 响应消息基类(微信端(服务器)--》用户) - * BaseMessage - * @author 电子小孩 - * - * 2016年5月27日 下午5:28:20 - */ -public class BaseMessage { - - // 接收方帐号(收到的OpenID) - private String ToUserName; - // 开发者微信号 - private String FromUserName; - // 消息创建时间 (整型) - private long CreateTime; - // 消息类型(text/music/news) - private String MsgType; - // 位0x0001被标志时,星标刚收到的消息 - private int FuncFlag; - - //=================新增=================// - //用于发送的语音消息 - private String Recognition; - - public String getRecognition() - { - return Recognition; - } - public void setRecognition(String recognition) - { - Recognition = recognition; - } - public String getToUserName() { - return ToUserName; - } - public void setToUserName(String toUserName) { - ToUserName = toUserName; - } - public String getFromUserName() { - return FromUserName; - } - public void setFromUserName(String fromUserName) { - FromUserName = fromUserName; - } - public long getCreateTime() { - return CreateTime; - } - public void setCreateTime(long createTime) { - CreateTime = createTime; - } - public String getMsgType() { - return MsgType; - } - public void setMsgType(String msgType) { - MsgType = msgType; - } - public int getFuncFlag() { - return FuncFlag; - } - public void setFuncFlag(int funcFlag) { - FuncFlag = funcFlag; - } - - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/ModelData.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/ModelData.java deleted file mode 100644 index 4be92b6c3..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/ModelData.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.accompany.business.wechat.message.resp; - - -/** - * Created by 北岭山下 on 2017/7/31. - */ - -/** - * 根据模板ID - * - * - * {{first.DATA}} - - {{accountType.DATA}}:{{account.DATA}} - 充值金额:{{amount.DATA}} - 充值状态:{{result.DATA}} - {{remark.DATA}} - * - */ -public class ModelData { - - - - - - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/ModelMsg.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/ModelMsg.java deleted file mode 100644 index 1afe90133..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/ModelMsg.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.accompany.business.wechat.message.resp; - - -/** - * Created by 北岭山下 on 2017/7/31. - */ -/* - 模板消息对象 - - - - -您好,您已成功进行话费充值。 - -手机号:13912345678 -充值金额:50元 -充值状态:充值成功 -备注:如有疑问,请致电13912345678联系我们。 - - */ -public class ModelMsg { - - private String touser; - private String template_id; - private String url; - private String appid; - private String pagepath; - private ModelData data; - //以下非必须 - private String miniprogram; - private String color; - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/MusicMessage.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/MusicMessage.java deleted file mode 100644 index 1c240c6eb..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/MusicMessage.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.accompany.business.wechat.message.resp; - - -/** - * 音乐消息响应 - * MusicMessage - * @author 电子小孩 - * - * 2016年5月27日 下午5:29:04 - */ -public class MusicMessage extends BaseMessage { - - //回复音乐 - private MusicModle Music; - - public MusicModle getMusic() { - return Music; - } - - public void setMusic( MusicModle music) { - Music = music; - } - - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/MusicModle.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/MusicModle.java deleted file mode 100644 index 60f20dde2..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/MusicModle.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.accompany.business.wechat.message.resp; - - -/** - * 音乐模板 - * MusicModle - * @author 电子小孩 - * - * 2016年5月27日 下午5:29:25 - */ -public class MusicModle { - - // 音乐名称 - private String Title; - // 音乐描述 - private String Description; - // 音乐链接 - private String MusicUrl; - // 高质量音乐链接,WIFI环境优先使用该链接播放音乐 - private String HQMusicUrl; - public String getTitle() { - return Title; - } - public void setTitle(String title) { - Title = title; - } - public String getDescription() { - return Description; - } - public void setDescription(String description) { - Description = description; - } - public String getMusicUrl() { - return MusicUrl; - } - public void setMusicUrl(String musicUrl) { - MusicUrl = musicUrl; - } - public String getHQMusicUrl() { - return HQMusicUrl; - } - public void setHQMusicUrl(String musicUrl) { - HQMusicUrl = musicUrl; - } - - - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/NewsMessage.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/NewsMessage.java deleted file mode 100644 index 3a43abe7c..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/NewsMessage.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.accompany.business.wechat.message.resp; - - -import java.util.List; - -/** - * 图文响应 - * NewsMessage - * @author 电子小孩 - * - * 2016年5月27日 下午5:29:45 - */ -public class NewsMessage extends BaseMessage { - - // 图文消息个数,限制为10条以内 - private int ArticleCount; - // 多条图文消息信息,默认第一个item为大图 - private List Articles; - - public int getArticleCount() { - return ArticleCount; - } - - public void setArticleCount(int articleCount) { - ArticleCount = articleCount; - } - - public List getArticles() { - return Articles; - } - - public void setArticles(List articles) { - Articles = articles; - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/TextMessage.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/TextMessage.java deleted file mode 100644 index c554d73cb..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/TextMessage.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.accompany.business.wechat.message.resp; - - -/** - * 文本消息响应 - * TextMessage - * @author 电子小孩 - * - * 2016年5月27日 下午5:30:09 - */ -public class TextMessage extends BaseMessage { - - //回复的消息内容 - private String Content; - - public String getContent() { - return Content; - } - - public void setContent(String content) { - Content = content; - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/package-info.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/package-info.java deleted file mode 100644 index 054aac1d6..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/message/resp/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * 该包中的所有的类都是用于处理微信端(服务端)给用户发送消息的消息类集合 - */ -/** - * @author 电子小孩 - * - * 2016年5月25日 上午9:02:23 - */ -package com.accompany.web.wechat.message.resp; \ No newline at end of file diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/pojo/Button.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/pojo/Button.java deleted file mode 100644 index 1d4baa0f9..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/pojo/Button.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.accompany.business.wechat.pojo; - -/** - * 按键基类 - * Button - * @author 电子小孩 - * - * 2016年5月27日 下午5:31:11 - */ -public class Button { - //菜单名称 - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/pojo/CommonButton.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/pojo/CommonButton.java deleted file mode 100644 index 506f2cc87..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/pojo/CommonButton.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.accompany.business.wechat.pojo; - - -/** - * 子按键 - * @author 电子小孩 - * - * 2016年5月20日 下午2:24:58 - */ -public class CommonButton extends Button { - //数据类型 - private String type; - //菜单关键字 - private String key; - - //===========新增==========// - //数据内容 - private String content; - //菜单url - private String url; - - - - public String getUrl() - { - return url; - } - - public void setUrl(String url) - { - this.url = url; - } - - public String getContent() - { - return content; - } - - public void setContent(String content) - { - this.content = content; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/pojo/ComplexButton.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/pojo/ComplexButton.java deleted file mode 100644 index 8f5e50414..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/pojo/ComplexButton.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.accompany.business.wechat.pojo; - - -/** - * 高级按键 - * ComplexButton - * @author 电子小孩 - * - * 2016年5月27日 下午5:31:37 - */ -public class ComplexButton extends Button { - - private Button[] sub_button; - - public Button[] getSub_button() { - return sub_button; - } - - public void setSub_button(Button[] sub_button) { - this.sub_button = sub_button; - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/pojo/Menu.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/pojo/Menu.java deleted file mode 100644 index 7e932d423..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/pojo/Menu.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.accompany.business.wechat.pojo; - - -/** - * 菜单类 - * Menu - * @author 电子小孩 - * - * 2016年5月27日 下午5:31:52 - */ -public class Menu { - - private Button[] button; - - public Button[] getButton() { - return button; - } - - public void setButton(Button[] button) { - this.button = button; - } - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/util/MessageUtil.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/util/MessageUtil.java deleted file mode 100644 index 62b5d9bb1..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/util/MessageUtil.java +++ /dev/null @@ -1,206 +0,0 @@ -package com.accompany.business.wechat.util; - - -import com.accompany.business.wechat.message.resp.ArticleModel; -import com.accompany.business.wechat.message.resp.MusicMessage; -import com.accompany.business.wechat.message.resp.NewsMessage; -import com.accompany.business.wechat.message.resp.TextMessage; -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.core.util.QuickWriter; -import com.thoughtworks.xstream.io.HierarchicalStreamWriter; -import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; -import com.thoughtworks.xstream.io.xml.XppDriver; -import org.dom4j.Document; -import org.dom4j.Element; -import org.dom4j.io.SAXReader; - -import javax.servlet.http.HttpServletRequest; -import java.io.InputStream; -import java.io.Writer; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * 消息处理工具类 - */ -public class MessageUtil { - - //================返回类型=================// - //返回消息类型:文本 - public static final String RESP_MESSAGE_TYPE_TEXT="text"; - //返回消息类型:音乐 - public static final String RESP_MESSAGE_TYPE_MUSIC="music"; - //返回消息类型:图文 - public static final String RESP_MESSAGE_TYPE_NEWS="news"; - //返回消息类型:语音 - public static final String RESP_MESSAGE_TYPE_VOICE = "voice"; - - //==================请求类型===============// - //请求消息类型:文本 - public static final String REQ_MESSAGE_TYPE_TEXT="text"; - //请求消息类型:图片 - public static final String REQ_MESSAGE_TYPE_IMAGE = "image"; - //请求消息类型:语音 - public static final String REQ_MESSAGE_TYPE_VOICE = "voice"; - //请求消息类型:链接 - public static final String REQ_MESSAGE_TYPE_LINK = "link"; - //请求消息类型:地理位置 - public static final String REQ_MESSAGE_TYPE_LOCATION = "location"; - // 请求消息类型:事件 - public static final String REQ_MESSAGE_TYPE_EVENT = "event"; - - //===============时间类型===================// - /** - * 事件类型:subscribe(订阅) - */ - public static final String EVENT_TYPE_SUBSCRIBE = "subscribe"; - - /** - * 事件类型:unsubscribe(取消订阅) - */ - public static final String EVENT_TYPE_UNSUBSCRIBE = "unsubscribe"; - - /** - * 事件类型:CLICK(自定义菜单点击事件) - */ - public static final String EVENT_TYPE_CLICK = "CLICK"; - - - /** - * 解析微信发来的请求(xml) - * @param request - * @return - * @throws Exception - */ - @SuppressWarnings("unchecked") - public static Map parseXml (HttpServletRequest request) throws Exception{ - - //将解析结果存在Map中 - Map map=new HashMap(); - - //从request中取得输入流 - InputStream inputStream=request.getInputStream(); - - //读取输入流 - SAXReader reader=new SAXReader (); - Document document=reader.read(inputStream); - - //取得xml的根元素 - Element root=document.getRootElement(); - - //得到根元素下所有子节点 - List elementList=root.elements(); - - //遍历所有子节点 - for(Element e: elementList){ - map.put(e.getName(), e.getText()); - } - - inputStream.close(); - inputStream=null; - - return map; - - } - - /** - * 回复的文本消息转换成xml格式 - * @param textMessage - * @return - */ - public static String textMessageToXml(TextMessage textMessage){ - xStream.alias("xml", textMessage.getClass()); - return xStream.toXML(textMessage); - } - - /** - * 音乐消息对象转换成xml - * - * @param musicMessage 音乐消息对象 - * @return xml - */ - public static String musicMessageToXml(MusicMessage musicMessage) { - xStream.alias("xml", musicMessage.getClass()); - return xStream.toXML(musicMessage); - } - - /** - * 图文消息对象转换成xml - * - * @param newsMessage 图文消息对象 - * @return xml - */ - public static String newsMessageToXml(NewsMessage newsMessage) { - xStream.alias("xml", newsMessage.getClass()); - xStream.alias("item", new ArticleModel ().getClass()); - return xStream.toXML(newsMessage); - } - - - /** - * 扩展xstream,使其支持CDATA块 - */ - private static XStream xStream=new XStream ( new XppDriver (){ - public HierarchicalStreamWriter createWriter( Writer out){ - return new PrettyPrintWriter (out){ - // 对所有xml节点的转换都增加CDATA标记 - boolean cdata=true; - - public void startNode(String name,Class clazz) { - super.startNode(name, clazz); - } - - protected void writeText( QuickWriter writer, String text) { - if (cdata) { - writer.write(""); - } else { - writer.write(text); - } - } - }; - } - }); - - - /** - * 判断是否是QQ表情 - * - * @param content - * @return - */ - public static boolean isQqFace(String content) { - boolean result = false; - - // 判断QQ表情的正则表达式 - String qqfaceRegex = "/::\\)|/::~|/::B|/::\\||/:8-\\)|/::<|/::$|/::X|/::Z|/::'\\(|/::-\\||/::@|/::P|/::D|/::O|/::\\(|/::\\+|/:--b|/::Q|/::T|/:,@P|/:,@-D|/::d|/:,@o|/::g|/:\\|-\\)|/::!|/::L|/::>|/::,@|/:,@f|/::-S|/:\\?|/:,@x|/:,@@|/::8|/:,@!|/:!!!|/:xx|/:bye|/:wipe|/:dig|/:handclap|/:&-\\(|/:B-\\)|/:<@|/:@>|/::-O|/:>-\\||/:P-\\(|/::'\\||/:X-\\)|/::\\*|/:@x|/:8\\*|/:pd|/:|/:beer|/:basketb|/:oo|/:coffee|/:eat|/:pig|/:rose|/:fade|/:showlove|/:heart|/:break|/:cake|/:li|/:bome|/:kn|/:footb|/:ladybug|/:shit|/:moon|/:sun|/:gift|/:hug|/:strong|/:weak|/:share|/:v|/:@\\)|/:jj|/:@@|/:bad|/:lvu|/:no|/:ok|/:love|/:|/:jump|/:shake|/:|/:circle|/:kotow|/:turn|/:skip|/:oY|/:#-0|/:hiphot|/:kiss|/:<&|/:&>"; - Pattern p = Pattern.compile(qqfaceRegex); - Matcher m = p.matcher(content); - if (m.matches()) { - result = true; - } - return result; - } - - /** - * 将微信消息中的CreateTime转换成标准格式的时间(yyyy-MM-dd HH:mm:ss) - * - * @param createTime 消息创建时间 - * @return - */ - public static String formatTime(String createTime) { - // 将微信传入的CreateTime转换成long类型,再乘以1000 - long msgCreateTime = Long.parseLong(createTime) * 1000L; - DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - return format.format(new Date(msgCreateTime)); - } - - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/util/SignUtil.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/util/SignUtil.java deleted file mode 100644 index e5cfad28b..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/util/SignUtil.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.accompany.business.wechat.util; - - -import com.accompany.common.config.SystemConfig; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.security.MessageDigest; -import java.util.Arrays; - -/** - * 微信认证工具类 - *

- * 项目名称:WeiChatService - * 类名称:SignUtil - */ -@Slf4j -@Component -public class SignUtil { - - public boolean checkSignature ( String signature , String timeStamp , String nonce ) { - String[] arr = new String[] { SystemConfig.secretaryUid , timeStamp , nonce }; - log.info ( "==========token,timeStamp,nonce按字典序排序==========" ); - log.info ( Arrays.toString ( arr ) ); - //将token,timeStamp,nonce按字典序排序 - Arrays.sort ( arr ); - StringBuffer contentBuffer = new StringBuffer ( ); - for ( int i = 0 ; i < arr.length ; i++ ) { - contentBuffer.append ( arr[ i ] ); - } - - MessageDigest mDigest = null; - String tmpString = null; - try { - mDigest = MessageDigest.getInstance ( "SHA-1" ); - //将三个参数拼接成一个字符串进行SHA-1加密 - byte[] digest = mDigest.digest ( contentBuffer.toString ( ).getBytes ( ) ); - tmpString = StringUtil.byteToStr ( digest ); - log.info ( "==========加密后的结果==========" ); - log.info ("tmpString:"+tmpString); - log.info ("signature.toUpperCase:"+signature.toUpperCase ( )); - - - } catch ( Exception e ) { - // TODO: handle exception - e.printStackTrace ( ); - } - contentBuffer = null; - // 将sha1加密后的字符串可与signature对比,标识该请求来源于微信 - return tmpString != null ? tmpString.equals ( signature.toUpperCase ( ) ) : false; - - - } - - -} diff --git a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/util/StringUtil.java b/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/util/StringUtil.java deleted file mode 100644 index b25efdc57..000000000 --- a/accompany-business/accompany-business-service/src/main/java/com/accompany/business/wechat/util/StringUtil.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.accompany.business.wechat.util; - -import java.io.UnsupportedEncodingException; - - -/** - * 字符串转换类 -* -* 项目名称:WeiChatService - */ -public class StringUtil { - - /** - * 将字节数组转换为十六进制字符串 - * - * @param byteArray - * @return - */ - public static String byteToStr(byte[] byteArray) { - String strDigest = ""; - for (int i = 0; i < byteArray.length; i++) { - strDigest += byteToHexStr(byteArray[i]); - } - return strDigest; - } - - - /** - * 将字节转换为十六进制字符串 - * - * @param mByte - * @return - */ - public static String byteToHexStr(byte mByte) { - char[] Digit = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - char[] tempArr = new char[2]; - tempArr[0] = Digit[(mByte >>> 4) & 0X0F]; - tempArr[1] = Digit[mByte & 0X0F]; - - String s = new String(tempArr); - return s; - } - - /** - * 计算采用utf-8编码方式时字符串所占字节数 - * - * @param content - * @return - */ - public static int getByteSize(String content) { - int size = 0; - if (null != content) { - try { - // 汉字采用utf-8编码时占3个字节 - size = content.getBytes("unicode").length; - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - } - return size; - } - - - -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/common/BaseController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/common/BaseController.java index 3e90fbd79..79504f28c 100644 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/common/BaseController.java +++ b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/common/BaseController.java @@ -1,35 +1,23 @@ package com.accompany.business.common; - import com.accompany.common.constant.Constant; import com.accompany.common.utils.AppVersionUtil; import com.accompany.common.utils.DESUtils; import com.accompany.core.exception.ServiceException; import com.accompany.core.util.KeyStore; import com.accompany.core.util.StringUtils; -import com.alibaba.fastjson.JSON; -import com.accompany.business.model.payment.PaymentDTO; import com.accompany.core.service.common.JedisLockService; import com.accompany.core.service.common.JedisService; -import com.accompany.business.config.WebPropertyConfig; -import com.accompany.common.constant.AppEnum; import com.accompany.common.constant.ApplicationConstant; import com.accompany.common.device.DeviceInfo; import com.accompany.common.status.BusiStatus; import com.accompany.common.utils.GsonUtil; import com.google.gson.Gson; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import javax.servlet.http.HttpServletRequest; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; /** * Created by liuguofu on 2017/3/30. @@ -88,15 +76,12 @@ public class BaseController { return sensitiveInfo; } - @Autowired - private WebPropertyConfig webPropertyConfig; @Autowired protected HttpServletRequest request; /** * 从头部信息获取用户id - * @return */ public Long getUid() { String uid = request.getHeader("pub_uid"); @@ -117,102 +102,4 @@ public class BaseController { return true; } - public class ReturnData{ - private int code; - private String message; - private Object data; - - public ReturnData(BusiStatus status){ - this(status,null); - } - - public ReturnData(BusiStatus status,Object data){ - this.code = status.value(); - this.message = status.getReasonPhrase(); - this.data = data; - } - - public int getCode() { - return code; - } - - public String getMessage() { - return message; - } - - public Object getData() { - return data; - } - } - - /** - * 获取来汇微信支付配置 - * @return - */ - protected PaymentDTO getPaymentDTO(String app) { - PaymentDTO dto = new PaymentDTO(); - dto.setFastpayMerchantKey(webPropertyConfig.getFastpayMerchantKey()); - dto.setFastpayMerchantName(webPropertyConfig.getFastpayMerchantName()); - dto.setFastpayMerchantNo(webPropertyConfig.getFastpayMerchantNo()); - dto.setFastpayPayUrl(webPropertyConfig.getFastpayPayUrl()); - dto.setFastpaySignUrl(webPropertyConfig.getFastpaySignUrl()); - dto.setFastpaySmsUrl(webPropertyConfig.getFastpaySmsUrl()); - dto.setFastpayQueryUrl(webPropertyConfig.getFastpayQueryUrl()); - dto.setFastpayUnWindUrl(webPropertyConfig.getFastpayUnWindUrl()); - dto.setFastpayCallbackUrl(webPropertyConfig.getFastpayCallbackUrl()); - dto.setImgDomain(webPropertyConfig.getUsingImgDomain()); - dto.setMaxCardNum(webPropertyConfig.getMaxCardNum()); - dto.setCardMaxBindTime(webPropertyConfig.getCardMaxBindTime()); - dto.setFastpayNotifyMoney(webPropertyConfig.getFastpayNotifyMoney()); - if(AppEnum.ear.getValue().equals(app)){ - dto.setFastpayNotifySmsId(webPropertyConfig.getFastpayNotifyCeerSmsId()); - }else { - dto.setFastpayNotifySmsId(webPropertyConfig.getFastpayNotifySmsId()); - } - dto.setMpAppId(webPropertyConfig.getWxMpAppId()); - dto.setMpOriginalId(webPropertyConfig.getWxMpOriginalId()); - dto.setMpChargePage(webPropertyConfig.getWxMpChargePage()); - dto.setMpProgramType(webPropertyConfig.getWxMpProgramType()); - dto.setMpQxVersion(webPropertyConfig.getWxMpQxVersion()); - dto.setJoinpayMpTradeMerchantNo(webPropertyConfig.getJoinpayMpTradeMerchantNo()); - return dto; - } - - - protected byte[] readBody(HttpServletRequest request) throws IOException { - if (request.getContentLength() > 0) { - byte[] body = new byte[request.getContentLength()]; - IOUtils.readFully(request.getInputStream(), body); - return body; - }else{ - return null; - } - - } - - protected Map convertRequestToMap(HttpServletRequest request) throws UnsupportedEncodingException { - Map retMap = new HashMap<>(); - String defaultCharset = "UTF-8"; - log.info("request parameter = {}", JSON.toJSONString(request.getParameterMap())); - Set> entries = request.getParameterMap().entrySet(); - for (Map.Entry entry : entries) { - String name = entry.getKey(); - String[] values = entry.getValue(); - int valLen = values.length; - if (valLen == 1) { - retMap.put(name, URLDecoder.decode(values[0], defaultCharset)); - } else if (valLen > 1) { - StringBuilder sb = new StringBuilder(); - for (String val : values) { - sb.append(",").append(val); - } - - retMap.put(name, URLDecoder.decode(sb.toString().substring(1), defaultCharset)); - } else { - retMap.put(name, ""); - } - } - - return retMap; - } } diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/config/BeanConfig.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/config/BeanConfig.java deleted file mode 100644 index c94baf4e8..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/config/BeanConfig.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.accompany.business.config; - -import com.accompany.business.filter.CustomParamFilter; -import com.accompany.common.support.InjectBeanSelfBeanPostProcessor; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import javax.servlet.DispatcherType; - -/** - * @Author yubin - * @Description //TODO - * @Date 2019-05-05 19:20 - */ - -@Configuration -public class BeanConfig { - - - @Bean - public InjectBeanSelfBeanPostProcessor initBean() { - return new InjectBeanSelfBeanPostProcessor(); - } - - /** - * xss注入 - * @return - */ - @Bean - public FilterRegistrationBean customParamFilterRegistration() { - FilterRegistrationBean registration = new FilterRegistrationBean(); - registration.setDispatcherTypes(DispatcherType.REQUEST); - registration.setFilter(new CustomParamFilter()); - registration.addUrlPatterns("/*"); - registration.setName("customParamFilter"); - registration.setOrder(Integer.MAX_VALUE); - return registration; - } - -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/config/WebPropertyConfig.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/config/WebPropertyConfig.java deleted file mode 100644 index f93938121..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/config/WebPropertyConfig.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.accompany.business.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.cloud.context.config.annotation.RefreshScope; -import org.springframework.context.annotation.Configuration; - -/** - * 2 * @Author: zhuct - * 3 * @Date: 2019/6/5 14:57 - * 4 - */ -@Data -@Configuration -@RefreshScope -@ConfigurationProperties(prefix = "fastpay") -public class WebPropertyConfig { - - private String fastpaySmsUrl; - - private String fastpaySignUrl; - - private String fastpayPayUrl; - - private String fastpayUnWindUrl; - - private String fastpayQueryUrl; - - private String fastpayMerchantNo; - - private String fastpayMerchantName; - - private String fastpayMerchantKey; - - private String fastpayCallbackUrl; - - private String usingImgDomain; - - private Integer maxCardNum; - - private Integer cardMaxBindTime; - - private Long fastpayNotifyMoney; - - private String fastpayNotifySmsId; - - private String fastpayNotifyCeerSmsId; - - private String qiNiuUnInterceptAccessUrl; - - private String wxMpAppId; - - private String wxMpOriginalId; - - private String wxMpChargePage; - - private Integer wxMpProgramType; - - private String joinpayMpTradeMerchantNo; - - private String wxMpQxVersion; - - private String qiNiuUnInterceptBucket; - -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/AppPictureController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/AppPictureController.java deleted file mode 100644 index 5ab1a187a..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/AppPictureController.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.accompany.business.controller; - -import com.accompany.business.service.AppPictureService; -import com.accompany.business.config.WebPropertyConfig; -import com.accompany.common.result.BusiResult; -import com.accompany.common.status.BusiStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; - -/** - * Created by liuyang on 2019/2/22. - */ -@RestController -@RequestMapping(value = "/picture") -public class AppPictureController { - private static final Logger logger = LoggerFactory.getLogger(AppPictureController.class); - @Autowired - private AppPictureService pictureService; - @Autowired - private WebPropertyConfig webPropertyConfig; - - @RequestMapping(value = "getSharePicture", method = RequestMethod.POST) - @ResponseBody - public BusiResult getSharePicture(String avatar, Long erbanNo, String nick, Integer gameResult,String app) { - logger.info("getSharePicture info avatar:{},erbanNo:{},nick:{},gameResult:{}", avatar, erbanNo, nick, gameResult); - BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS); - String shareImgUrl = pictureService.getShareImgUrl(avatar, erbanNo, nick, gameResult, app, - webPropertyConfig.getQiNiuUnInterceptAccessUrl(),webPropertyConfig.getQiNiuUnInterceptBucket()); - busiResult.setData(shareImgUrl); - return busiResult; - } - - @RequestMapping(value = "test", method = RequestMethod.GET) - @ResponseBody - public String test() { - return "/picture/test"; - } - - -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/ChargeController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/ChargeController.java index 0c7695033..8e0a7d753 100644 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/ChargeController.java +++ b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/ChargeController.java @@ -16,8 +16,6 @@ import com.accompany.core.service.user.UsersBaseService; import com.accompany.payment.vo.ChargeAreaInfoVO; import com.accompany.payment.vo.ChargePageVO; -import com.accompany.payment.vo.WeChatMiniAppPayRequestVO; -import com.accompany.payment.vo.WeXinPayTypeVO; import io.swagger.annotations.Api; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; @@ -112,70 +110,4 @@ public class ChargeController extends BaseController { Object result = chargeService.applyChargeV4(uid, chargeProdId, payChannel, clientIp, successUrl, openId, deviceInfo, roomUid, chargeMoney, paymentType, countryCode); return new BusiResult<>(result); } - - /** - * 微信支付方式 - */ - @GetMapping(value = "/wxpay/type") - public BusiResult wxPayTypeV2(HttpServletRequest request) { - DeviceInfo deviceInfo = getDeviceInfo(request); - - String wxminiId = null; - String wxminiAppId = null; - if (AppUtils.isYinyouApp(deviceInfo)) { - wxminiId = sysConfService.getSysConfValueById(YINYOU_WX_MINIPAY_ID); - wxminiAppId = sysConfService.getSysConfValueById(YINYOU_WX_MINIPAY_APPID); - } else { - wxminiId = sysConfService.getSysConfValueById(WX_MINIPAY_ID); - wxminiAppId = sysConfService.getSysConfValueById(WX_MINIPAY_APPID); - - } - return new BusiResult<>(new WeXinPayTypeVO(chargeService.wxpayType(getDeviceInfo(request)), wxminiAppId, wxminiId)); - } - - /** - * 微信小程序支付 - * - * @param request 请求 servletRequest - * @param weChatMiniAppPayRequestVO 微信小程序支付请求实体 - * @return BusiResult - */ - @PostMapping(value = "/weChatMiniAppPay") - public BusiResult miniAppPay( - HttpServletRequest request, @Validated WeChatMiniAppPayRequestVO weChatMiniAppPayRequestVO) { - // 账号有可能是草莓号也有可能是手机号 - Users chargeUser = null; - if (CommonUtil.checkValidPhone( - String.valueOf(String.valueOf(weChatMiniAppPayRequestVO.getAccount())))) { - chargeUser = - usersBaseService.getByPhone( - String.valueOf(String.valueOf(weChatMiniAppPayRequestVO.getAccount()))); - if (Objects.isNull(chargeUser)) { - return new BusiResult<>(BusiStatus.USERNOTEXISTS); - } - } else { - // modify 2022/03/07 屏蔽通过账号搜索用户 -// chargeUser = usersBaseService.getUsersByErBanNo(weChatMiniAppPayRequestVO.getAccount()); - if (Objects.isNull(chargeUser)) { - return new BusiResult<>(BusiStatus.USERNOTEXISTS); - } - } - BusiResult BusiResult = - applyCharge3( - request, - chargeUser.getUid(), - weChatMiniAppPayRequestVO.getChargeProdId(), - Constant.ChargeChannel.wx_mini_app_channel, - weChatMiniAppPayRequestVO.getSuccessUrl(), - weChatMiniAppPayRequestVO.getOpenId(), null, null, null, null); - log.info("huiju-BusiResult---{}", BusiResult.toString()); - if (BusiResult.getCode() != BusiStatus.SUCCESS.value()) { - return BusiResult; - } - WeChatMiniAppPayResponseVO weChatMiniAppPayResponseVO = new WeChatMiniAppPayResponseVO(); - BeanUtils.copyProperties(BusiResult.getData(), weChatMiniAppPayResponseVO); - weChatMiniAppPayResponseVO.setNick(chargeUser.getNick()); - weChatMiniAppPayResponseVO.setErbanNo(chargeUser.getErbanNo()); - return new BusiResult<>(weChatMiniAppPayResponseVO); - } } diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/JSAPIController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/JSAPIController.java deleted file mode 100644 index 0dc1ee050..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/JSAPIController.java +++ /dev/null @@ -1,574 +0,0 @@ -package com.accompany.business.controller; - -import com.accompany.business.service.WXPushService; -import com.accompany.business.service.user.UsersService; -import com.accompany.business.service.wx.WXMircoMallPubService; -import com.accompany.business.service.wx.WXPubService; -import com.accompany.business.service.wx.WxService; -import com.accompany.common.annotation.H5Authorization; -import com.accompany.common.constant.AppEnum; -import com.accompany.common.result.BusiResult; -import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.DESUtils; -import com.accompany.common.utils.IPUitls; -import com.accompany.common.wx.PayUtil; -import com.accompany.common.wx.Util; -import com.accompany.common.wx.XMLParser; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.model.Users; -import com.accompany.core.util.StringUtils; -import com.accompany.core.vo.UserVo; -import com.accompany.payment.config.WxConfig; -import com.accompany.payment.config.WxMicroMallConfig; -import com.accompany.payment.config.WxPub2Config; -import com.accompany.payment.model.ChargeRecord; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.xml.sax.SAXException; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.xml.parsers.ParserConfigurationException; -import java.io.IOException; -import java.security.KeyManagementException; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.UnrecoverableKeyException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * Created by 北岭山下 on 2017/7/22. - */ -@Slf4j -@Controller -@RequestMapping("/wx") -public class JSAPIController { - - @Autowired - WxService wxService; - @Autowired - UsersService usersService; - @Autowired - WXPubService wxPubService; - @Autowired - WXPushService wxPushService; - @Autowired - WXMircoMallPubService wxMircoMallPubService; - - //支付回调接口(微信异步会通知)【notify_url 配置的值】 - @RequestMapping(value = "/payCallback", method = RequestMethod.POST) - @ResponseBody - public void payCallback(HttpServletRequest request, HttpServletResponse response) throws Exception { - - String retStr = new String(Util.readInput(request.getInputStream()), "utf-8"); - log.info("=======微信支付回调的结果为:" + retStr); - //返回的数据 - Map map = XMLParser.getMapFromXML(retStr); - String return_code = ""; - String return_msg = ""; - String xml = ""; - String openId = (String) map.get("openid"); - - //1.签名验证 - String recSign = (String) map.get("sign"); - log.info("传入的签名:" + recSign); - map.remove("sign"); - String sign = PayUtil.getSign(map,WxConfig.key); - log.info("校验的签名:" + sign); - /** - * 签名验证( 验证调用返回或微信主动通知签名时,传送的sign参数不参与签名,将生成的签名与该sign值作校验。) - */ - if (!sign.equals(recSign)) { - //验证失败 - log.error("=================验证签名失败======================"); - return_code += ""; - return_msg += ""; - } else { - //2.结果判断 - if (map.get("return_code").equals("SUCCESS")) { - //6.返回信息 - try { - BusiResult busiResult = wxService.getPayResult((Map) map); - ChargeRecord chargeRecord = (ChargeRecord) busiResult.getData(); - log.info("=========回调对应操作的充值记录参数:chargeRecordId:{},uid:{}", chargeRecord.getChargeRecordId(), chargeRecord.getUid()); - Users users = usersService.getUsersByUid(chargeRecord.getUid()); - Long erbanNo = users.getErbanNo(); - if (busiResult.getCode() == 200) { - log.info("================验证成功========================="); - return_code += ""; - return_msg += ""; - //发送订单消息给用户 - wxPubService.sendModelMsg(erbanNo, openId, String.valueOf(chargeRecord.getAmount() / 10), "支付成功"); - } else { - wxPubService.sendModelMsg(erbanNo, openId, "--", "支付失败"); - log.info("================验证失败:" + busiResult.getMessage() + "========================="); - return_code += ""; - return_msg += ""; - } - } catch (Exception e) { - String trade_no = (String) map.get("transaction_id"); - log.error("================验证失败,微信流水号为:{}", trade_no, e); - return_code += ""; - return_msg += ""; - response.setContentType("text/xml"); - xml += return_code + return_msg + ""; - response.getWriter().print(xml); - response.getWriter().flush(); - response.getWriter().close(); - } - } - } - response.setContentType("text/xml"); - xml += return_code + return_msg + ""; - response.getWriter().print(xml); - response.getWriter().flush(); - response.getWriter().close(); - - } - - /** - * 支付成功之后 微信会进行异步回调的地址 - * @param erban_no 用户ID - * @param chargeProdId 订单类型 - * @throws UnrecoverableKeyException - * @throws IOException - * @throws NoSuchAlgorithmException - * @throws KeyStoreException - * @throws KeyManagementException - * @throws ParserConfigurationException - * @throws SAXException - */ - @RequestMapping(value = "/submitPay", method = RequestMethod.POST) - @ResponseBody - public BusiResult submitPayWx(Long erban_no, String phone, String chargeProdId, String openId, String app, String data, String successUrl, - HttpServletRequest request, Integer chargeMoney) throws Exception{ - log.info("submitPayWx(), erbanNo={}, phone={}, chargeProdId={}, openId={}, app={},redirectUrl data:{}", erban_no, phone, chargeProdId, openId, app,data); - - String nick = ""; - Long myUid = 0L; - Long myErBanNo = 0L; - - if (StringUtils.isEmpty(chargeProdId) && StringUtils.isEmpty(openId)) { - log.error("============erban_no=" + erban_no + "=======微信公众号下单参数异常========"); - return new BusiResult(BusiStatus.PARAMETERILLEGAL); - } - - if(WxConfig.pubValidOpenId){ - log.info("isValidOpenid openid:{},data:{}",openId,data); - if (StringUtils.isEmpty(data)) { - log.error("============data=" + erban_no + "=======微信公众号下单data参数异常========"); - return new BusiResult(BusiStatus.PARAMETERILLEGAL); - } - - String resultData = DESUtils.DESAndBase64UrlDecrypt(data, WxConfig.openIdKey); - String[] datas = resultData.split("@@"); - if(!openId.equals(datas[0])){ - log.error("openId:{},datas:{}",openId,datas); - return new BusiResult(BusiStatus.PARAMETERILLEGAL); - } - long requestTime = Long.valueOf(datas[1]); - long currentTime = System.currentTimeMillis(); - if(currentTime - requestTime > 5*60*1000){ //超过5分钟 - log.error("openId:{},datas:{},currentTime:{},requestTime:{},value:{}",openId,datas,currentTime,requestTime,currentTime - requestTime ); - return new BusiResult(BusiStatus.ORDER_TIME_OUT); - } - } - - - - if (erban_no == null && phone == null) { - log.error("============erban_no=" + erban_no + "=======微信公众号下单参数异常========"); - return new BusiResult(BusiStatus.PARAMETERILLEGAL); - } - if(StringUtils.isBlank(app)) { - app = AppEnum.qingxun.getValue(); - } - - log.info("===========获取openIdInfo===========" + openId); - try { - if (erban_no != null) { - BusiResult> list1 = usersService.getUserVosByErbanNo(erban_no); - if (list1.getData() == null) { - log.info("=========平台号:" + erban_no + "=====不存在================"); - return new BusiResult(BusiStatus.USERNOTEXISTS); - } - nick = list1.getData().get(0).getNick(); - myUid = list1.getData().get(0).getUid(); - myErBanNo = erban_no; - log.info("=========平台号:" + erban_no + "=====存在================"); - } else if (phone != null) { - List list = new ArrayList<>(); - list.add(phone); - List list1 = usersService.getByPhone(list); - if (list1 == null) { - log.info("=========手机号:" + phone + "=====不存在================"); - return new BusiResult(BusiStatus.PHONEINVALID); - } - if(list1.size() > 1) { - log.info("=========手机号:" + phone + "=====绑定了多个账号================"); - return new BusiResult<>(BusiStatus.PHONE_HAS_MANY_ACCOUNTS); - } - nick = list1.get(0).getNick(); - myUid = list1.get(0).getUid(); - myErBanNo = list1.get(0).getErbanNo(); - log.info("=========手机号:" + phone + "=====存在================"); - } - - String ip = IPUitls.getRealIpAddress(request); - return wxService.submitPayWx(myUid, chargeProdId, nick, myErBanNo, openId, ip, app, successUrl, chargeMoney); - } catch (Exception e) { - log.error("============uid={},openid:{},data:{}=======微信公众号下单错误========",myUid,openId,data, e); - return new BusiResult(BusiStatus.BUSIERROR); - } - } - - /** - * 发起微商城公众号支付 - * @param erban_no 用户ID - * @param chargeProdId 订单类型 - * @throws UnrecoverableKeyException - * @throws IOException - * @throws NoSuchAlgorithmException - * @throws KeyStoreException - * @throws KeyManagementException - * @throws ParserConfigurationException - * @throws SAXException - */ - @RequestMapping(value = "/submitPayForMiroMall", method = RequestMethod.POST) - @ResponseBody - public BusiResult submitPayForMiroMall(Long erban_no, String phone, String chargeProdId, String openId, String app, String data, String successUrl, - HttpServletRequest request) throws Exception { - log.info("submitPayForMiroMall(), erbanNo={}, phone={}, chargeProdId={}, openId={}, app={},redirectUrl data:{}", erban_no, phone, chargeProdId, openId, app, data); - - String nick = ""; - Long myUid = 0L; - Long myErBanNo = 0L; - - if (StringUtils.isEmpty(chargeProdId) && StringUtils.isEmpty(openId)) { - log.error("============erban_no=" + erban_no + "=======微信公众号下单参数异常========"); - return new BusiResult(BusiStatus.PARAMETERILLEGAL); - } - - - if (erban_no == null && phone == null) { - log.error("============erban_no=" + erban_no + "=======微信公众号下单参数异常========"); - return new BusiResult(BusiStatus.PARAMETERILLEGAL); - } - if (StringUtils.isBlank(app)) { - app = AppEnum.qingxun.getValue(); - } - - log.info("===========获取openIdInfo===========" + openId); - try { - if (erban_no != null) { - BusiResult> list1 = usersService.getUserVosByErbanNo(erban_no); - if (list1.getData() == null) { - log.info("=========平台号:" + erban_no + "=====不存在================"); - return new BusiResult(BusiStatus.USERNOTEXISTS); - } - nick = list1.getData().get(0).getNick(); - myUid = list1.getData().get(0).getUid(); - myErBanNo = erban_no; - log.info("=========平台号:" + erban_no + "=====存在================"); - } else if (phone != null) { - List list = new ArrayList<>(); - list.add(phone); - List list1 = usersService.getByPhone(list); - if (list1 == null) { - log.info("=========手机号:" + phone + "=====不存在================"); - return new BusiResult(BusiStatus.PHONEINVALID); - } - if (list1.size() > 1) { - log.info("=========手机号:" + phone + "=====绑定了多个账号================"); - return new BusiResult<>(BusiStatus.PHONE_HAS_MANY_ACCOUNTS); - } - nick = list1.get(0).getNick(); - myUid = list1.get(0).getUid(); - myErBanNo = list1.get(0).getErbanNo(); - log.info("=========手机号:" + phone + "=====存在================"); - } - - String ip = IPUitls.getRealIpAddress(request); - return wxService.submitPayWxForMicroMall(myUid, chargeProdId, nick, myErBanNo, openId, ip, app, successUrl); - } catch (Exception e) { - log.error("============uid={},openid:{},data:{}=======微信公众号下单错误========", myUid, openId, data, e); - return new BusiResult(BusiStatus.BUSIERROR); - } - } - - private UserVo getWxPubPayUserInfo(Long erbanNo, String phone) { - if (erbanNo == null && phone == null) { - log.error("============erban_no=" + erbanNo + "=======微信公众号下单参数异常========"); - throw new ServiceException(BusiStatus.PARAMETERILLEGAL); - } - - if (erbanNo != null) { - BusiResult> list1 = usersService.getUserVosByErbanNo(erbanNo); - if (list1.getData() == null) { - log.info("=========平台号:" + erbanNo + "=====不存在================"); - throw new ServiceException(BusiStatus.USERNOTEXISTS); - } - log.info("=========平台号:" + erbanNo + "=====存在================"); - return list1.getData().get(0); - } else if (phone != null) { - List list = new ArrayList<>(); - list.add(phone); - List list1 = usersService.getByPhone(list); - if (list1 == null) { - log.info("=========手机号:" + phone + "=====不存在================"); - throw new ServiceException(BusiStatus.PHONEINVALID); - } - if (list1.size() > 1) { - log.info("=========手机号:" + phone + "=====绑定了多个账号================"); - throw new ServiceException(BusiStatus.PHONE_HAS_MANY_ACCOUNTS); - } - log.info("=========手机号:" + phone + "=====存在================"); - return list1.get(0); - } - throw new ServiceException(BusiStatus.PARAMETERILLEGAL); - } - - /** - * 支付成功之后 微信会进行异步回调的地址 - * @param erban_no 用户ID - * @param chargeProdId 订单类型 - * @throws UnrecoverableKeyException - * @throws IOException - * @throws NoSuchAlgorithmException - * @throws KeyStoreException - * @throws KeyManagementException - * @throws ParserConfigurationException - * @throws SAXException - */ - @RequestMapping(value = "/submitPayForPub2", method = RequestMethod.POST) - @ResponseBody - public BusiResult submitPayForPub2(Long erban_no, String phone, String chargeProdId, String openId, String app, String data, String successUrl, - HttpServletRequest request, Integer chargeMoney) throws Exception { - log.info("submitPayForPub2(), erbanNo={}, phone={}, chargeProdId={}, openId={}, app={},redirectUrl data:{}", erban_no, phone, chargeProdId, openId, app, data); - - String nick = ""; - Long myUid = 0L; - Long myErBanNo = 0L; - - if (StringUtils.isEmpty(chargeProdId) && StringUtils.isEmpty(openId)) { - log.error("============erban_no=" + erban_no + "=======微信公众号下单参数异常========"); - return new BusiResult(BusiStatus.PARAMETERILLEGAL); - } - - if (StringUtils.isBlank(app)) { - app = AppEnum.qingxun.getValue(); - } - - UserVo userInfo = getWxPubPayUserInfo(erban_no, phone); - nick = userInfo.getNick(); - myUid = userInfo.getUid(); - myErBanNo = userInfo.getErbanNo(); - - log.info("===========获取openIdInfo===========" + openId); - try { - String ip = IPUitls.getRealIpAddress(request); - return wxService.submitPayWxForPub2(myUid, chargeProdId, nick, myErBanNo, openId, ip, app, successUrl, chargeMoney); - } catch (Exception e) { - log.error("============uid={},openid:{},data:{}=======微信公众号下单错误========", myUid, openId, data, e); - return new BusiResult(BusiStatus.BUSIERROR); - } - } - - //支付回调接口(微信异步会通知)【notify_url 配置的值】 - @RequestMapping(value = "/payCallbackForMicroMall", method = RequestMethod.POST) - @ResponseBody - public void payCallbackForMicroMall(HttpServletRequest request, HttpServletResponse response) throws Exception { - - String retStr = new String(Util.readInput(request.getInputStream()), "utf-8"); - log.info("=======微信支付回调的结果为:" + retStr); - //返回的数据 - Map map = XMLParser.getMapFromXML(retStr); - String return_code = ""; - String return_msg = ""; - String xml = ""; - String openId = (String) map.get("openid"); - - //1.签名验证 - String recSign = (String) map.get("sign"); - log.info("传入的签名:" + recSign); - map.remove("sign"); - String sign = PayUtil.getSign(map, WxMicroMallConfig.key); - log.info("校验的签名:" + sign); - /** - * 签名验证( 验证调用返回或微信主动通知签名时,传送的sign参数不参与签名,将生成的签名与该sign值作校验。) - */ - if (!sign.equals(recSign)) { - //验证失败 - log.error("=================验证签名失败======================"); - return_code += ""; - return_msg += ""; - } else { - //2.结果判断 - if (map.get("return_code").equals("SUCCESS")) { - //6.返回信息 - try { - BusiResult busiResult = wxService.getPayResult((Map) map); - ChargeRecord chargeRecord = (ChargeRecord) busiResult.getData(); - log.info("=========回调对应操作的充值记录参数:chargeRecordId:{},uid:{}", chargeRecord.getChargeRecordId(), chargeRecord.getUid()); - Users users = usersService.getUsersByUid(chargeRecord.getUid()); - Long erbanNo = users.getErbanNo(); - if (busiResult.getCode() == 200) { - log.info("================验证成功========================="); - return_code += ""; - return_msg += ""; - //发送订单消息给用户 - wxMircoMallPubService.sendModelMsg(erbanNo, openId, String.valueOf(chargeRecord.getAmount() / 10), "支付成功"); - } else { - wxMircoMallPubService.sendModelMsg(erbanNo, openId, "--", "支付失败"); - log.info("================验证失败:" + busiResult.getMessage() + "========================="); - return_code += ""; - return_msg += ""; - } - } catch (Exception e) { - String trade_no = (String) map.get("transaction_id"); - log.error("================验证失败,微信流水号为:{}", trade_no, e); - return_code += ""; - return_msg += ""; - response.setContentType("text/xml"); - xml += return_code + return_msg + ""; - response.getWriter().print(xml); - response.getWriter().flush(); - response.getWriter().close(); - } - } - } - response.setContentType("text/xml"); - xml += return_code + return_msg + ""; - response.getWriter().print(xml); - response.getWriter().flush(); - response.getWriter().close(); - - } - - @RequestMapping(value = "/payCallbackForPub2", method = RequestMethod.POST) - @ResponseBody - public void payCallbackForPub2(HttpServletRequest request, HttpServletResponse response) throws Exception { - - String retStr = new String(Util.readInput(request.getInputStream()), "utf-8"); - log.info("=======微信支付回调的结果为:" + retStr); - //返回的数据 - Map map = XMLParser.getMapFromXML(retStr); - String return_code = ""; - String return_msg = ""; - String xml = ""; - String openId = (String) map.get("openid"); - - //1.签名验证 - String recSign = (String) map.get("sign"); - log.info("传入的签名:" + recSign); - map.remove("sign"); - String sign = PayUtil.getSign(map, WxPub2Config.key); - log.info("校验的签名:" + sign); - /** - * 签名验证( 验证调用返回或微信主动通知签名时,传送的sign参数不参与签名,将生成的签名与该sign值作校验。) - */ - if (!sign.equals(recSign)) { - //验证失败 - log.error("=================验证签名失败======================"); - return_code += ""; - return_msg += ""; - } else { - //2.结果判断 - if (map.get("return_code").equals("SUCCESS")) { - //6.返回信息 - try { - BusiResult busiResult = wxService.getPayResult((Map) map); - ChargeRecord chargeRecord = (ChargeRecord) busiResult.getData(); - log.info("=========回调对应操作的充值记录参数:chargeRecordId:{},uid:{}", chargeRecord.getChargeRecordId(), chargeRecord.getUid()); - Users users = usersService.getUsersByUid(chargeRecord.getUid()); - Long erbanNo = users.getErbanNo(); - if (busiResult.getCode() == 200) { - log.info("================验证成功========================="); - return_code += ""; - return_msg += ""; - //发送订单消息给用户 - wxMircoMallPubService.sendModelMsg(erbanNo, openId, String.valueOf(chargeRecord.getAmount() / 10), "支付成功"); - } else { - wxMircoMallPubService.sendModelMsg(erbanNo, openId, "--", "支付失败"); - log.info("================验证失败:" + busiResult.getMessage() + "========================="); - return_code += ""; - return_msg += ""; - } - } catch (Exception e) { - String trade_no = (String) map.get("transaction_id"); - log.error("================验证失败,微信流水号为:{}", trade_no, e); - return_code += ""; - return_msg += ""; - response.setContentType("text/xml"); - xml += return_code + return_msg + ""; - response.getWriter().print(xml); - response.getWriter().flush(); - response.getWriter().close(); - } - } - } - response.setContentType("text/xml"); - xml += return_code + return_msg + ""; - response.getWriter().print(xml); - response.getWriter().flush(); - response.getWriter().close(); - - } - - @RequestMapping(value = "/h5/submitPay", method = RequestMethod.POST) - @ResponseBody - @H5Authorization - public BusiResult submitPayWxFromH5(Long uid, String chargeProdId, String openId, String app, String successUrl, HttpServletRequest request) { - if (uid == null || StringUtils.isBlank(chargeProdId) || StringUtils.isBlank(openId)) { - return new BusiResult(BusiStatus.PARAMERROR); - } - - Users users = usersService.getUsersByUid(uid); - - if (users == null) { - return new BusiResult(BusiStatus.USERNOTEXISTS); - } - if(StringUtils.isBlank(app)) { - app = AppEnum.qingxun.getValue(); - } - try { - String ip = IPUitls.getRealIpAddress(request); - return wxService.submitPayWx(uid, chargeProdId, users.getNick(), users.getErbanNo(), openId, ip, app, successUrl, null); - } catch (Exception e) { - log.error("============uid=" + uid + "=======微信公众号h5系统下单错误========", e); - return new BusiResult(BusiStatus.BUSIERROR); - } - } - - //获取openID回调接口 - //获取code并请求openID - @RequestMapping(value = "/codeCallback") - @ResponseBody - public void codeCallback(HttpServletRequest request, HttpServletResponse response) throws IOException { - String code = request.getParameter("code"); - log.info("=========获取code:" + code + " ============="); - try { - // String openId = wxPubService.getOpenId ( code ); - String openId = wxPubService.getOpenIdInfo(code).getOpenid(); - log.info("=========获取openId:" + openId + "============="); - log.info("====PAY_URL" + WxConfig.payUrl); - String data = openId+"@@"+System.currentTimeMillis(); - String encryptData = DESUtils.DESAndBase64UrlEncrypt(data, WxConfig.openIdKey); - String redirectUrl = WxConfig.payUrl + "?openId=" + openId+"&data="+encryptData; - log.info("====redirectUrl:{}", redirectUrl); - response.sendRedirect(redirectUrl); - } catch (Exception e) { - log.error("get codeCallback error",e); - } - } - -} - - - diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/ReciveWxController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/ReciveWxController.java deleted file mode 100644 index 59232f33c..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/ReciveWxController.java +++ /dev/null @@ -1,72 +0,0 @@ - -package com.accompany.business.controller; - -import com.accompany.business.service.wx.WxService; -import com.accompany.business.vo.WxConfigVo; -import com.accompany.common.result.BusiResult; -import com.accompany.common.status.BusiStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.PrintWriter; - -/** - * Created by liuguofu on 2017/7/8. - */ -@Controller -@RequestMapping("/wx") -public class ReciveWxController { - public static final Logger logger = LoggerFactory.getLogger(ReciveWxController.class); - @Autowired - private WxService wxService; - - @RequestMapping(value = "check",method = RequestMethod.GET) - public void getWxConfig(HttpServletRequest request, HttpServletResponse response) throws Exception{ - // 微信加密签名 - String signature = request.getParameter("signature"); - // 时间戳 - String timestamp = request.getParameter("timestamp"); - // 随机数 - String nonce = request.getParameter("nonce"); - // 随机字符串 - String echostr = request.getParameter("echostr"); - logger.info("signature="+signature+"×tamp="+timestamp+"&nonce="+nonce+"&echostr="+echostr); - PrintWriter out = null; - try { - out = response.getWriter(); - } catch (IOException e) { - e.printStackTrace(); - } - // 通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败 -// if (WxUtil.checkSignature(signature, timestamp, nonce)) { -// out.print(echostr); -// System.out.println("微信服务验证成功!"); -// } - out.close(); - out = null; - } - @RequestMapping(value = "config", method = RequestMethod.GET) - @ResponseBody - public BusiResult getWxConfig(String url) { - BusiResult busiResult=null; - try { - busiResult=wxService.getWxConfig(url); - } catch (Exception e) { - logger.error("getWxConfig error..."+e.getMessage()); - busiResult.setCode(BusiStatus.BUSIERROR.value()); - busiResult.setMessage("服务器好繁忙,请稍后重试!"); - return busiResult; - } - return busiResult; - } - - -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/Test.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/Test.java deleted file mode 100644 index 89b9fc676..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/Test.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.accompany.business.controller; - -import com.accompany.common.utils.UUIDUitl; -import com.accompany.core.model.Users; -import com.beust.jcommander.internal.Lists; -import com.google.gson.Gson; - -import java.util.List; - -/** - * Created by liuguofu on 2017/6/6. - */ -public class Test { - - public static void main(String args[]){ -// String str="{\"id\":\"evt_400170707144522227491903\",\"created\":1499409921,\"livemode\":false,\"type\":\"charge.succeeded\",\"data\":{\"object\":{\"id\":\"ch_D480SS1qD4aTWLCKqH9mn1K4\",\"object\":\"charge\",\"created\":1499409913,\"livemode\":false,\"paid\":true,\"refunded\":false,\"reversed\":false,\"app\":\"app_KaPO844ej1G8T40a\",\"channel\":\"alipay\",\"order_no\":\"7b53855ad08b48a8a2ad218924dcc531\",\"client_ip\":\"192.168.0.100\",\"amount\":600,\"amount_settle\":600,\"currency\":\"cny\",\"subject\":\"600金币金币充值\",\"body\":\"600金币金币充值\",\"extra\":{\"rn_check\":\"T\",\"buyer_account\":\"alipay_account\"},\"time_paid\":1499409921,\"time_expire\":1499496313,\"time_settle\":null,\"transaction_no\":\"2017070758155903\",\"refunds\":{\"object\":\"list\",\"url\":\"/v1/charges/ch_D480SS1qD4aTWLCKqH9mn1K4/refunds\",\"has_more\":false,\"data\":[]},\"amount_refunded\":0,\"failure_code\":null,\"failure_msg\":null,\"metadata\":{},\"credential\":{},\"description\":null}},\"object\":\"event\",\"request\":\"iar_DOu9CCuXHqfTS8GGiPqvT088\",\"pending_webhooks\":0}"; - Gson gson=new Gson(); -// Map requstMap=gson.fromJson(str,HashMap.class); -// String type=requstMap.get("type").toString(); -// LinkedTreeMap data=(LinkedTreeMap)requstMap.get("data"); -//// LinkedTreeMap dataMap=gson.fromJson(data,LinkedTreeMap.class); -// LinkedTreeMap dataMap=(LinkedTreeMap) data.get("object"); -//// Charge charge=gson.fromJson(null, Charge.class); -//// System.out.println(charge.getOrderNo()); -// boolean paid=(boolean)dataMap.get("paid"); -// Integer amount=new Double (dataMap.get("amount").toString()).intValue(); -// Long time_paid=(Long)dataMap.get("time_paid"); -// System.out.println(time_paid); - List voiceDescList= Lists.newArrayList(); - voiceDescList.add("声音青涩犹如初恋"); - voiceDescList.add("绵软哼唧小鼻音"); - voiceDescList.add("不太认真"); - String str=gson.toJson(voiceDescList); - Users users=new Users(); - users.setNick(str); - System.out.println(str); - - String userStr=gson.toJson(users); - String s=UUIDUitl.get(); - System.out.println(s); - - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/UserRegisterSuccessNotifyController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/UserRegisterSuccessNotifyController.java deleted file mode 100644 index 5b39044d7..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/UserRegisterSuccessNotifyController.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.accompany.business.controller; - - -import com.accompany.business.event.listener.UserRegisterSuccessListener; -import com.accompany.common.config.WebSecurityConfig; -import com.accompany.common.result.BusiResult; -import com.accompany.common.status.BusiStatus; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -@RestController -@RequestMapping("/userRegisterSuccess") -public class UserRegisterSuccessNotifyController { - - @Autowired - private UserRegisterSuccessListener userRegisterSuccessListener; - - @Autowired - private WebSecurityConfig webSecurityConfig; - - @PostMapping(value = "/notify") - public BusiResult userRegisterSuccessNotify(@RequestParam("data") String data, @RequestParam("key") String key) { - if (webSecurityConfig.getUserRegisterSuccessNotifyKey().equals(key)) { - userRegisterSuccessListener.onApplicationEvent(data); - } - return new BusiResult(BusiStatus.SUCCESS); - } - -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/WXCoreController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/WXCoreController.java deleted file mode 100644 index b89c6ed60..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/WXCoreController.java +++ /dev/null @@ -1,331 +0,0 @@ -package com.accompany.business.controller; - - -import com.accompany.business.service.wx.WXMircoMallPubService; -import com.accompany.business.service.wx.WXPub2Service; -import com.accompany.business.service.wx.WXPubService; -import com.accompany.business.service.wx.WxMpService; -import com.accompany.business.vo.OpenIdInfoVo; -import com.accompany.business.vo.user.UserInfo; -import com.accompany.business.wechat.util.SignUtil; -import com.accompany.common.result.BusiResult; -import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.StringUtils; -import com.accompany.payment.config.WxConfig; -import com.accompany.payment.config.WxMiniAppConfig; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.HashMap; -import java.util.Map; - -/** - * Created by 北岭山下 on 2017/7/28. - */ - -/** - * 微信公众号请求处理 - */ -@Slf4j -@Controller -public class WXCoreController { - - @Autowired - private WXPubService wxPubService; - @Autowired - private WXMircoMallPubService wxMircoMallPubService; - - @Autowired - private WXPub2Service wxPub2Service; - - @Autowired - private SignUtil signUtil; - - @Autowired - private WxMpService wxMpService; - - @Autowired - private WxMiniAppConfig wxMiniAppConfig; - - - @RequestMapping( value = "/wxController", method = RequestMethod.GET ) - public void coreHandlerGET ( HttpServletRequest httpServletRequest , - HttpServletResponse httpServletResponse ) throws IOException { - // 将请求、响应的编码均设置为UTF-8(防止中文乱码) - log.info ( "-------开始验证请求是否来自微信-----------!" ); - //微信加密签名 - String signature = httpServletRequest.getParameter ( "signature" ); - //时间戳 - String timestamp = httpServletRequest.getParameter ( "timestamp" ); - //随机数 - String nonce = httpServletRequest.getParameter ( "nonce" ); - //随机字符串 - String echostr = httpServletRequest.getParameter ( "echostr" ); - log.info ( "---接收到的来自" + httpServletRequest.getRemoteHost ( ) + ",请求参数:signature:" + signature + ",timestamp:" + timestamp + ",nonce:" + nonce + ",echostr:" + echostr ); - PrintWriter out = httpServletResponse.getWriter ( ); - //通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败 - if ( signature == null || timestamp == null || nonce == null || echostr == null ) { - out.write ( "you records has recorded,please leave it now !" ); - } else { - if ( signUtil.checkSignature ( signature , timestamp , nonce ) ) { - out.write ( echostr ); - } - } - - out.close ( ); - - } - - @RequestMapping( value = "/wxController", method = RequestMethod.POST ) - public void coreHandlerPOST ( HttpServletRequest httpServletRequest , - HttpServletResponse response ) throws IOException { - // 将请求、响应的编码均设置为UTF-8(防止中文乱码) - response.setContentType ( "text/html;charset=utf-8" ); - httpServletRequest.setCharacterEncoding ( "UTF-8" ); - //调用核心业务类处理微信请求 - String respMsg = wxPubService.processRequest ( httpServletRequest ); -// log.info ( "微信公众号处理后的信息:"+ respMsg); - PrintWriter writer = response.getWriter ( ); - writer.write ( respMsg ); - writer.close ( ); - } - - - - - /** - * 微信公众号创建接口 - * @param request - * @param response - * @return - */ -// @RequestMapping ( value = "/createMenu", method = RequestMethod.GET ) -// @ResponseBody -// public BusiResult createMenu ( HttpServletRequest request , -// HttpServletResponse response ) { -// BusiResult busiResult = new BusiResult ( BusiStatus.SUCCESS ); -// log.info ( "----------更新微信公众号菜单----------" ); -// try{ -// String resutl = MenuManager.createMenu ( ); -// busiResult.setData ( resutl ); -// }catch(Exception e){ -// log.error ( "##########更新微信公众号菜单失败##########" ); -// e.printStackTrace(); -// return new BusiResult ( BusiStatus.BUSIERROR ); -// } -// return busiResult; -// } - /** - * 获取用户信息回调接口 - * - * https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx009d793f92c24eec&redirect_uri=http%3a%2f%2fwww.erbanyy.com%2fgetUserInfoCallback&response_type=code&scope=snsapi_base#wechat_redirect - */ - - @RequestMapping(value = "/getUserInfoCallback") - public void getUserInfoCallback(HttpServletRequest request , HttpServletResponse response){ - - String code = request.getParameter ( "code" ); - if ( StringUtils.isEmpty ( code ) ){ - log.error ( "#########code 传入参数错误#########" ) ; - return; - } - log.info ( "=========获取code:" + code + " =============" ); - try{ - //获取openID -// String openId = wxPubService.getOpenId ( code );//o5fpU1bSN0b8xcU3syC8Md8ZfrJ4 - String openId = wxPubService.getOpenIdInfo(code).getOpenid(); -// String openId = "o5fpU1bSN0b8xcU3syC8Md8ZfrJ4"; - if(openId != null){ - log.info ( "=========获取openId:" + openId + "=============" ); - UserInfo userInfo = wxPubService.getUserInfo(openId); - log.info ( "==>userInfo"+userInfo.toString () ); - response.sendRedirect ( WxConfig.giveGold +"?"+userInfo.toString () ); - }else{ - log.error ( "#########获取openId失败#########" ) ; - } - }catch(Exception e){ - log.error ( "#########获取用户信息失败#########" ) ; - e.printStackTrace(); - } - } - - /** - * 根据code进行微信oauth2验证 - * @param request - * @return - */ - @RequestMapping(value = "/getCodeCallbackMsg") - @ResponseBody - public BusiResult getCodeCallbackMsg(HttpServletRequest request){ - BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS); - String code = request.getParameter ( "code" ); - if(StringUtils.isEmpty(code)){ - return new BusiResult(BusiStatus.PARAMETERILLEGAL); - } - try{ - OpenIdInfoVo openIdInfoVo = wxPubService.getOpenIdInfo(code); - busiResult.setData(openIdInfoVo); - return busiResult; - }catch (Exception e){ - log.error("getCodeCallbackMsg failed",e); - return new BusiResult(BusiStatus.BUSIERROR); - } - } - - @RequestMapping(value = "/getCodeCallbackMsgFroMicroMall") - @ResponseBody - public BusiResult getCodeCallbackMsgFroMicroMall(HttpServletRequest request){ - BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS); - String code = request.getParameter ( "code" ); - if(StringUtils.isEmpty(code)){ - return new BusiResult(BusiStatus.PARAMETERILLEGAL); - } - try{ - OpenIdInfoVo openIdInfoVo = wxMircoMallPubService.getOpenIdInfo(code); - busiResult.setData(openIdInfoVo); - return busiResult; - }catch (Exception e){ - log.error("getCodeCallbackMsg failed",e); - return new BusiResult(BusiStatus.BUSIERROR); - } - } - - @RequestMapping(value = "/getCodeCallbackMsgFroPub2") - @ResponseBody - public BusiResult getCodeCallbackMsgFroPub2(HttpServletRequest request){ - BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS); - String code = request.getParameter ( "code" ); - if(StringUtils.isEmpty(code)){ - return new BusiResult(BusiStatus.PARAMETERILLEGAL); - } - try{ - OpenIdInfoVo openIdInfoVo = wxPub2Service.getOpenIdInfo(code); - busiResult.setData(openIdInfoVo); - return busiResult; - }catch (Exception e){ - log.error("getCodeCallbackMsg failed",e); - return new BusiResult(BusiStatus.BUSIERROR); - } - } - - /** - * 获取微信用户信息 - * @param code - * @return - */ - @RequestMapping(value = "/getWxUserInfo",method = RequestMethod.POST) - @ResponseBody - public BusiResult getWxUserInfo(String code){ - BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS); - if(StringUtils.isEmpty(code)){ - return new BusiResult(BusiStatus.PARAMETERILLEGAL); - } - try{ - //获取openID - String openId = wxPubService.getOpenIdInfo(code).getOpenid(); - if(openId != null){ - log.info ( "=========获取openId:" + openId + "=============" ); - UserInfo userInfo = wxPubService.getUserInfo(openId); - busiResult.setData(userInfo); - return busiResult; - }else{ - log.error ( "#########获取openId失败#########" ) ; - return new BusiResult(BusiStatus.BUSIERROR); - } - }catch(Exception e){ - log.error ( "#########获取用户信息失败#########" ) ; - return new BusiResult(BusiStatus.BUSIERROR); - } - } - - /** - * 获取微信用户网页授权后的信息 - * @param code - * @return - */ - @RequestMapping(value = "/getWxUserInfoV2",method = RequestMethod.POST ) - @ResponseBody - public BusiResult getWxUserInfoV2(String code){ - BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS); - if(StringUtils.isEmpty(code)){ - return new BusiResult(BusiStatus.PARAMETERILLEGAL); - } - try{ - // 通过code获取对应的token,openId和unionId类 - OpenIdInfoVo openIdInfoVo = wxPubService.getOpenIdInfo(code); - String openId = openIdInfoVo.getOpenid(); - String token = openIdInfoVo.getAccess_token(); - if(openId != null){ - log.info ( "=========获取网页授权openId:" + openId + "=============" ); - UserInfo userInfo = wxPubService.getUserInfoV2(openId,token); - busiResult.setData(userInfo); - return busiResult; - }else{ - log.error ( "#########获取openId失败#########" ) ; - return new BusiResult(BusiStatus.BUSIERROR); - } - }catch(Exception e){ - log.error ( "#########获取网页授权后的用户信息失败#########",e ) ; - return new BusiResult(BusiStatus.BUSIERROR); - } - } - - /** - * 获取微信用户的基本信息,只包含openId和unionId - */ - @RequestMapping(value = "/getWxBaseInfo",method = RequestMethod.GET ) - @ResponseBody - public BusiResult getWxUserBaseInfo(String code){ - BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS); - if ( StringUtils.isEmpty ( code ) ){ - return new BusiResult(BusiStatus.PARAMERROR); - } - try{ - OpenIdInfoVo openIdInfoVo = wxPubService.getOpenIdInfo(code); - Map map = new HashMap<>(); - map.put("openId",openIdInfoVo.getOpenid()); - map.put("unionId",openIdInfoVo.getUnionid()); - busiResult.setData(map); - return busiResult; - }catch (Exception e){ - log.error("getBaseInfo failed",e); - return new BusiResult(BusiStatus.BUSIERROR); - } - } - - @RequestMapping(value = "/miniApp/openId") - @ResponseBody - public BusiResult getMpOpenId(String jsCode) throws Exception { - BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS); - if(StringUtils.isBlank(jsCode)) { - busiResult.setData(""); - return busiResult; - } - String url = StringUtils.replace(wxMiniAppConfig.getOpenUrl(), "{js_code}", jsCode); - String openId = wxMpService.getOpenId(url); - busiResult.setData(openId); - return busiResult; - } - - @RequestMapping(value = "/miniApp/openIdInMangguo") - @ResponseBody - public BusiResult getMpOpenIdInMangguo(String jsCode) throws Exception { - BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS); - if(StringUtils.isBlank(jsCode)) { - busiResult.setData(""); - return busiResult; - } - String url = StringUtils.replace(wxMiniAppConfig.getMangguoOpenUrl(), "{js_code}", jsCode); - String openId = wxMpService.getOpenId(url); - busiResult.setData(openId); - return busiResult; - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/WithdrawController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/WithdrawController.java deleted file mode 100644 index e69de29bb..000000000 diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/administrator/SuperAdminWebController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/administrator/SuperAdminWebController.java index 9e7da8881..ed9b934d7 100644 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/administrator/SuperAdminWebController.java +++ b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/administrator/SuperAdminWebController.java @@ -1,7 +1,5 @@ package com.accompany.business.controller.administrator; - - import com.accompany.business.service.administrator.SuperAdminWebService; import com.accompany.business.service.administrator.SuperManagerOperateRecordService; import com.accompany.common.annotation.Authorization; @@ -10,7 +8,6 @@ import com.accompany.common.status.BusiStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; - /** * @author chucheng * @date 2019-08-20 diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/BankCardSignController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/BankCardSignController.java deleted file mode 100644 index 89bea2cac..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/BankCardSignController.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.accompany.business.controller.apppay; - -import com.alibaba.fastjson.JSON; -import com.accompany.business.model.request.*; -import com.accompany.business.service.BankCardSignService; -import com.accompany.business.vo.BankCardSignVo; -import com.accompany.business.common.BaseController; -import com.accompany.common.result.BusiResult; -import com.accompany.common.status.BusiStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 银行卡签约 - * - * @author fangchengyan - * @date 2019-08-08 11:25 - */ -@RestController -@RequestMapping("/payment/bankCardSign") -public class BankCardSignController extends BaseController { - - private static final Logger logger = LoggerFactory.getLogger(BankCardSignController.class); - - @Autowired - private BankCardSignService bankCardSignService; - - /** - * 获取签约短信 - * - * @param request - * @param req - * @return - */ - @RequestMapping(value = "/getSmsCode", method = RequestMethod.GET) - @ResponseBody - public BusiResult getSmsCode(HttpServletRequest request, @Valid BankCardSmsReq req, String app) throws Exception { - return bankCardSignService.getSmsCode(req, getPaymentDTO(app)); - } - - /** - * 签约 - * - * @param request - * @param req - * @return - */ - @RequestMapping(value = "/sign", method = RequestMethod.POST) - @ResponseBody - public BusiResult sign(HttpServletRequest request, @Valid BankCardSignReq req, String app) throws Exception { - return bankCardSignService.sign(req, getPaymentDTO(app)); - } - - /** - * 解约 - * - * @param request - * @param req - * @return - */ - @RequestMapping(value = "/release", method = RequestMethod.POST) - @ResponseBody - public BusiResult release(HttpServletRequest request, @Valid BankCardReleaseReq req, String app) throws Exception { - return bankCardSignService.release(req, getPaymentDTO(app)); - } - - /** - * 签约支付,直接发起扣款 - * @param request - * @param req - * @return - */ - @RequestMapping(value = "/signPay", method = RequestMethod.POST) - @ResponseBody - public BusiResult signPay(HttpServletRequest request, @Valid BandCardPayReq req, String app) throws Exception { - return bankCardSignService.signPay(req, getPaymentDTO(app)); - } - - /** - * 设置为默认卡 - * @param req - * @return - */ - @RequestMapping(value = "/setDefault", method = RequestMethod.POST) - @ResponseBody - public BusiResult setDefault(@Valid BankCardSetDefaultReq req) { - int result = bankCardSignService.setDefaultCard(req); - if(result > 0) { - return new BusiResult(BusiStatus.SUCCESS); - } else { - logger.warn("设置默认银行卡未成功,记录不存在或当前卡已是默认卡!参数:{}", JSON.toJSONString(req)); - return new BusiResult(BusiStatus.SUCCESS); - } - } - - /** - * 获取签约银行卡列表 - * - * @param uid - * @param payChannel - * @return - */ - @RequestMapping(value = "/list", method = RequestMethod.GET) - @ResponseBody - public BusiResult list(Long uid, String payChannel, String app) { - BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS); - List list = bankCardSignService.list(uid, payChannel); - Map dataMap = new HashMap<>(4); - dataMap.put("list", list); - dataMap.put("maxBindNum", getPaymentDTO(app).getMaxCardNum()); - busiResult.setData(dataMap); - return busiResult; - } -} \ No newline at end of file diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/ChargeNotifyController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/ChargeNotifyController.java deleted file mode 100644 index e93544457..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/ChargeNotifyController.java +++ /dev/null @@ -1,369 +0,0 @@ -package com.accompany.business.controller.apppay; - -import com.accompany.business.apppay.constant.PayConstant; -import com.accompany.business.common.BaseController; -import com.accompany.business.service.ChargeRecordUpdateService; -import com.accompany.business.service.ChargeService; -import com.accompany.common.constant.AppEnum; -import com.accompany.common.constant.ApplicationConstant; -import com.accompany.common.constant.Constant; -import com.accompany.common.constant.PaymentConstant; -import com.accompany.common.device.DeviceInfo; -import com.accompany.common.redis.RedisKey; -import com.accompany.common.status.BusiStatus; -import com.accompany.common.wx.Util; -import com.accompany.common.wx.XMLParser; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.service.common.JedisService; -import com.accompany.core.util.JsonUtil; -import com.accompany.core.util.StringUtils; -import com.accompany.payment.agentchangestrategy.IAgentChangeStrategy; -import com.accompany.payment.alipay.AlipayNotifyParam; -import com.accompany.payment.config.*; -import com.accompany.payment.huiju.HuiJuService; -import com.accompany.payment.huiju.NotifyResponse; -import com.accompany.payment.mapper.ChargeRecordMapper; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.service.ChargeNotifyService; -import com.accompany.payment.service.ChargeRecordService; -import com.accompany.payment.service.PayCenterService; -import com.accompany.payment.wxpay.WeChatNotifyParam; -import com.accompany.payment.wxpay.WeChatQueryResultParam; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.alipay.api.internal.util.AlipaySignature; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.HEAD; -import java.math.BigDecimal; -import java.net.URLDecoder; -import java.util.Calendar; -import java.util.Date; -import java.util.Map; -import java.util.Objects; - -import static com.accompany.payment.huiju.Constant.PAY_SUCCESS; - -/** - * @author yangming - * @date 2018-10-19 - * @description 充值中心(微信支付宝充值回调接口) - */ -@Slf4j -@RestController -@RequestMapping("/notify/url") -public class ChargeNotifyController extends BaseController { - - /** 回调分布式锁时间,毫秒 */ - private static final Integer CALLBACK_LOCK_MILLIS = 60000; - - /** 回调超时时间,秒 */ - private static final Integer CALLBACK_EXPIRE_SECONDS = 30; - - @Autowired - private ChargeService chargeService; - - @Autowired - private ChargeRecordUpdateService chargeRecordUpdateService; - - @Autowired - private ChargeNotifyService chargeNotifyService; - - @Autowired - private PayCenterService payCenterService; - - @Autowired - private ChargeRecordService chargeRecordService; - - @Autowired - private JedisService jedisService; - - @Autowired - private ChargeRecordMapper chargeRecordMapper; - - @Autowired - private HuiJuService huiJuService; - - @Autowired - private AliPayConfig aliPayConfig; - @Autowired - private YinyouAliPayConfig yinyouAliPayConfig; - - @Autowired - private WxPayConfig wxPayConfig; - @Autowired - private YinyouWxPayConfig yinyouWxPayConfig; - @Autowired - private WxPub2WapConfig wxPub2WapConfig; - @Autowired - @Qualifier("alipayNativeAgentChangeStrategy") - private IAgentChangeStrategy alipayNativeAgentChangeStrategy; - - /** 支付成功 */ - private final String TRADE_STATE_SUCCESS = "SUCCESS"; - /** 已关闭 */ - private final String TRADE_STATE_CLOSED = "CLOSED"; - - /** - * 微信回调接口 - * - * @param request - * @param response - */ - @RequestMapping(value = "/wx", method = RequestMethod.POST) - public void WxPayCallBack(HttpServletRequest request, HttpServletResponse response) throws Exception { - handleWxPayCallBack(request, response, wxPayConfig); - } - - /** - * 供平台使用的微信回调接口 - * - * @param request - * @param response - */ - @RequestMapping(value = "/wxForYinyou", method = RequestMethod.POST) - public void WxPayCallBackForYinyou(HttpServletRequest request, HttpServletResponse response) throws Exception { - handleWxPayCallBack(request, response, yinyouWxPayConfig); - } - - /** - * 供平台公众号h5支付使用的微信回调接口 - * - * @param request - * @param response - */ - @RequestMapping(value = "/wxForPub2H5", method = RequestMethod.POST) - public void WxPayCallBackForPub2H5(HttpServletRequest request, HttpServletResponse response) throws Exception { - handleWxPayCallBack(request, response, wxPub2WapConfig); - } - - public void handleWxPayCallBack(HttpServletRequest request, HttpServletResponse response, BaseWxPayConfig wxPayConfig) throws Exception { - String retStr = new String(Util.readInput(request.getInputStream()), ApplicationConstant.DEFAULT_CHARSET); - log.info("=======微信支付回调的结果为:" + retStr); - - // 校验请求参数 - Map map = XMLParser.getMapFromXML(retStr); - WeChatNotifyParam weChatNotifyParam = chargeNotifyService.buildWeChatNotifyParam(map); - boolean allowProcess = this.jedisService.setnx(RedisKey.lock_payment_callback.getKey(weChatNotifyParam.getOut_trade_no()), "Y", CALLBACK_EXPIRE_SECONDS); - if (!allowProcess) { - log.error("重复请求,request={}", weChatNotifyParam); - this.chargeNotifyService.writeWxResponse(response, "FAIL", "已经有请求在处理中"); - return; - } - - log.info("weChatNotifyParam={}", weChatNotifyParam); - String verifyResult = this.chargeNotifyService.verifyWxRequestParams(map, weChatNotifyParam, wxPayConfig); - if (org.apache.commons.lang3.StringUtils.isNotBlank(verifyResult)) { - this.chargeNotifyService.writeWxResponse(response, "FAIL", verifyResult); - return; - } - - // 支付失败逻辑 - if (!PayConstant.WeChatTradeStatus.TRADE_SUCCESS.equals(weChatNotifyParam.getReturn_code()) || !PayConstant.WeChatTradeStatus.TRADE_SUCCESS - .equals(weChatNotifyParam.getResult_code())) { - // TODO: 更新 charge_record 订单状态 - log.error("支付失败,request={}", weChatNotifyParam); - this.chargeNotifyService.writeWxResponse(response, "SUCCESS", "OK"); - return; - } - - //添加分布式锁,防止重复回调造成多次充值 - String outTradeNo = weChatNotifyParam.getOut_trade_no(); - try { - //校验订单数据 - ChargeRecord record = this.chargeRecordService.getChargeRecordById(outTradeNo); - if (record == null) { - log.error("充值记录不存在, requestParam={}", weChatNotifyParam); - this.chargeNotifyService.writeWxResponse(response, "FAIL", "订单不存在"); - return; - } - - // 判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额), - long total_amount = new BigDecimal(weChatNotifyParam.getTotal_fee()).longValue(); - if (total_amount != record.getAmount().longValue()) { - log.error("请求金额与订单金额不一致,request={}, record={}", weChatNotifyParam, JSONObject.toJSONString(record)); - this.chargeNotifyService.writeWxResponse(response, "FAIL", "订单金额不一致"); - return; - } - - // 校验订单状态 - if (record.getChargeStatus().equals(PaymentConstant.ChargeStatus.PAIED)) { - log.error("订单已到账,不能重复处理: chargeRecord={}", JSONObject.toJSONString(record)); - this.chargeNotifyService.writeWxResponse(response, "SUCCESS", "OK"); - return; - } - - //更新用户钱包数据 - record.setPingxxChargeId(weChatNotifyParam.getTransaction_id()); - chargeService.updateAppPayData(record); - chargeNotifyService.writeWxResponse(response, "SUCCESS", "OK"); - log.info("wx callback completed: chargeRecordId, request={}", record.getChargeRecordId(), weChatNotifyParam); - } catch (Exception e) { - log.error("微信支付回调业务处理错误, request={}", weChatNotifyParam, e); - this.chargeNotifyService.writeWxResponse(response, "FAIL", e.getMessage()); - } - } - - /** - * 支付宝回调接口 - * - * @param request - */ - @RequestMapping(value = "/alipay", method = RequestMethod.POST) - public String AlipayCallBack(HttpServletRequest request) throws Exception { - return alipayCallBack(request, aliPayConfig); - } - - /** - * 平台支付宝回调接口 - * - * @param request - */ - @RequestMapping(value = "/alipayForYinyou", method = RequestMethod.POST) - public String AlipayCallBackForYinyou(HttpServletRequest request) throws Exception { - return alipayCallBack(request, yinyouAliPayConfig); - } - - public String alipayCallBack(HttpServletRequest request, BaseAliPayConfig aliPayConfig) throws Exception { - String appId = aliPayConfig.getAppId(); - Map params = chargeNotifyService.convertRequetsToMap(request); - log.info("{} AlipayCallBack,params={}", appId, JSON.toJSONString(params)); - AlipayNotifyParam alipayNotifyParam = chargeNotifyService.buildAlipayNotifyParam(params); - log.info("alipayNotifyParam={}", JSONObject.toJSONString(alipayNotifyParam)); - - if (PayConstant.AlipayTradeStatus.TRADE_SUCCESS.equals(alipayNotifyParam.getTrade_status()) || PayConstant.AlipayTradeStatus.TRADE_FINISHED - .equals(alipayNotifyParam.getTrade_status())) { - String outTradeNo = alipayNotifyParam.getOut_trade_no(); - String lockval = jedisLockService.lock(RedisKey.lock_alipay_notify.getKey(outTradeNo), CALLBACK_LOCK_MILLIS); - if (org.apache.commons.lang3.StringUtils.isEmpty(lockval)) { - throw new ServiceException(BusiStatus.BUSIERROR); - } - - try { - //参数校验 - ChargeRecord chargeRecord = chargeNotifyService.checkAliPayParams(params, alipayNotifyParam, aliPayConfig); - - //更新用户钱包数据 - chargeRecord.setPingxxChargeId(alipayNotifyParam.getTrade_no()); - chargeRecord.setUpdateTime(Calendar.getInstance().getTime()); - chargeService.updateAppPayData(chargeRecord); - - alipayNativeAgentChangeStrategy.postProcessAfterPay(chargeRecord); - } catch (Exception e) { - log.error("支付宝回调业务处理错误,error={}", e); - return "failure"; - } finally { - jedisLockService.unlock(RedisKey.lock_alipay_notify.getKey(outTradeNo), lockval); - } - } else { - log.info("支付宝未支付成功,status={}", alipayNotifyParam.getTrade_status()); - } - return "success"; - } - - private boolean isYinyouApp(DeviceInfo deviceInfo) { - if (deviceInfo == null || com.accompany.common.utils.StringUtils.isBlank(deviceInfo.getApp())) { - return false; - } - - if (deviceInfo.getApp().equalsIgnoreCase(AppEnum.yinyou.getValue()) || deviceInfo.getApp().equalsIgnoreCase(AppEnum.yinyouEnterprise.getValue())) { - return true; - } - - return false; - } - - @RequestMapping("/query") - public String query(String orderNo, String app, HttpServletRequest request) throws Exception { - DeviceInfo deviceInfo = getDeviceInfo(request); - BaseWxPayConfig usingWxPayConfig = wxPayConfig; - if (isYinyouApp(deviceInfo)) { - usingWxPayConfig = yinyouWxPayConfig; - } - //校验订单数据 - ChargeRecord record = this.chargeRecordUpdateService.getChargeRecordById(orderNo); - if (record == null) { - log.error("充值记录不存在, orderNo={}", orderNo); - return "订单记录不存在:" + orderNo; - } - if (record.getChargeStatus().equals(PaymentConstant.ChargeStatus.PAIED)) { - return "订单已处理:" + orderNo; - } - - String lockKey = RedisKey.lock_wx_notify.getKey(orderNo); - String lockVal = jedisLockService.lock(lockKey, CALLBACK_LOCK_MILLIS); - if (StringUtils.isEmpty(lockVal)) { - return "订单正在处理中,请稍后再试"; - } - try { - WeChatQueryResultParam resp = payCenterService.queryWeChatOrder(usingWxPayConfig, orderNo); - if(!resp.getReturn_code().equalsIgnoreCase("SUCCESS")) { - return "failed"; - } - String tradeStatus = resp.getTrade_state(); - if (TRADE_STATE_SUCCESS.equalsIgnoreCase(tradeStatus)) { - // 判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额), - long total_amount = new BigDecimal(resp.getTotal_fee()).longValue(); - if (total_amount != record.getAmount().longValue()) { - return "订单金额不一致:" + orderNo; - } - record.setPingxxChargeId(resp.getTransaction_id()); - record.setChargeStatusDesc(resp.getTrade_state_desc()); - chargeService.updateAppPayData(record); - } else if(TRADE_STATE_CLOSED.equalsIgnoreCase(tradeStatus)) { - ChargeRecord updateRecord = new ChargeRecord(); - updateRecord.setChargeRecordId(orderNo); - updateRecord.setChargeStatus(Constant.ChargeRecordStatus.error); - updateRecord.setChargeStatusDesc(resp.getTrade_state_desc()); - updateRecord.setUpdateTime(new Date()); - chargeRecordMapper.updateByPrimaryKeySelective(updateRecord); - } else { - ChargeRecord updateRecord = new ChargeRecord(); - updateRecord.setChargeRecordId(orderNo); - updateRecord.setChargeStatusDesc(resp.getTrade_state_desc()); - updateRecord.setUpdateTime(new Date()); - chargeRecordMapper.updateByPrimaryKeySelective(updateRecord); - } - return "success"; - } finally { - jedisLockService.unlock(lockKey, lockVal); - } - } - - @GetMapping("/joinpay") - @SuppressWarnings("unchecked") - public String callback(NotifyResponse notifyResponse) throws Exception { - notifyResponse.setRb_DealTime(URLDecoder.decode(notifyResponse.getRb_DealTime(), "utf-8")); - notifyResponse.setRa_PayTime(URLDecoder.decode(notifyResponse.getRa_PayTime(), "utf-8")); - Map requestMap = - Objects.requireNonNull( - JsonUtil.parseToClass(JsonUtil.parseToString(notifyResponse), Map.class)); - log.info("汇聚支付请求回调信息 {}", requestMap); - if (!huiJuService.md5Sign(requestMap).equalsIgnoreCase(notifyResponse.getHmac())) { - log.error("签名不匹配 {} vs {}", huiJuService.md5Sign(requestMap), notifyResponse.getHmac()); - throw new Exception("汇聚支付回调通知,签名不匹配"); - } - ChargeRecord chargeRecordById = - chargeRecordService.getChargeRecordById(notifyResponse.getR2_OrderNo()); - Double responseAmount = Double.parseDouble(notifyResponse.getR3_Amount()) * 100; - boolean validateAmount = chargeRecordById.getAmount().equals(responseAmount.longValue()); - if (!validateAmount) { - log.warn("订单 {} 金额 {} 校验失败", notifyResponse.getR2_OrderNo(), notifyResponse.getR3_Amount()); - return "fail"; - } - if (PAY_SUCCESS.equalsIgnoreCase(notifyResponse.getR6_Status())) { - chargeService.payCallbackDo( - notifyResponse.getR2_OrderNo(), notifyResponse.getR8_BankOrderNo()); - } - return "success"; - - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/FastpayController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/FastpayController.java deleted file mode 100644 index eb7884d73..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/FastpayController.java +++ /dev/null @@ -1,161 +0,0 @@ -package com.accompany.business.controller.apppay; - -import com.accompany.business.common.BaseController; -import com.accompany.business.model.payment.FastpayQueryReq; -import com.accompany.business.service.ChargeService; -import com.accompany.business.service.apppay.FastpayService; -import com.accompany.business.service.apppay.domain.AgreementQueryResp; -import com.accompany.common.constant.Constant; -import com.accompany.common.constant.PaymentConstant; -import com.accompany.common.redis.RedisKey; -import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.StringUtils; -import com.accompany.core.exception.ServiceException; -import com.accompany.payment.mapper.ChargeRecordMapper; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.service.ChargeRecordService; -import com.alibaba.fastjson.JSON; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import java.util.Date; -import java.util.Map; - -/** - * @Description 汇聚支付相关接口 - * @Author Vicente Yang - */ -@RestController -@RequestMapping("/payment/fastpay") -public class FastpayController extends BaseController { - - private static final Logger logger = LoggerFactory.getLogger(FastpayController.class); - - @Autowired - private ChargeService chargeService; - @Autowired - private ChargeRecordService chargeRecordService; - @Autowired - private FastpayService fastpayService; - @Autowired - private ChargeRecordMapper chargeRecordMapper; - - private final String TRADE_STATUS_KEY = "r6_Status"; - private final String TRADE_STATUS_SUCCESS = "100"; - private final String TRADE_STATUS_FAIL = "101"; - - /** 回调分布式锁时间,毫秒 */ - private static final Integer CALLBACK_LOCK_MILLIS = 60000; - - - @RequestMapping("/callback") - public String callback(HttpServletRequest request, String app) throws Exception { - Map requestMap = convertRequestToMap(request); - logger.info("fastpay callback: {}", requestMap); - - boolean isSignLegal = this.fastpayService.verifySign(JSON.toJSONString(requestMap), getPaymentDTO(app).getFastpayMerchantKey()); - if (!isSignLegal) { - logger.error("fastpay callback verify failed: {}", JSON.toJSONString(requestMap)); - return "failed"; - } - - String tradeStatus = requestMap.get(TRADE_STATUS_KEY); - if (TRADE_STATUS_SUCCESS.equals(tradeStatus) || TRADE_STATUS_FAIL.equals(tradeStatus)) { - String orderNo = requestMap.get("r2_OrderNo"); - String lockKey = RedisKey.lock_fastpay_notify.getKey(orderNo); - String lockVal = jedisLockService.lock(lockKey, CALLBACK_LOCK_MILLIS); - if (StringUtils.isEmpty(lockVal)) { - throw new ServiceException(BusiStatus.BUSIERROR); - } - try { - String fastpayTradeNo = requestMap.get("r7_TrxNo"); - String amount = requestMap.get("r3_Amount"); - String errMsg = requestMap.get("re_ErrMsg"); - if (StringUtils.isNotBlank(errMsg) && errMsg.length() > 64) { - errMsg = errMsg.substring(0, 64); - } - logger.info("fastpay, orderNo={}, tradeNo={}, amount={}, msg:{}", orderNo, fastpayTradeNo, amount, errMsg); - - ChargeRecord record = this.chargeRecordService.getChargeRecordById(orderNo); - if (record == null) { - return "failed"; - } - if (PaymentConstant.ChargeStatus.PAIED.equals(record.getChargeStatus())) { - logger.info("订单{}已处理完成", orderNo); - return "success"; - } - - if (TRADE_STATUS_SUCCESS.equals(tradeStatus)) { - record.setPingxxChargeId(fastpayTradeNo); - record.setChargeStatusDesc(errMsg); - chargeService.updateAppPayData(record); - } else if (TRADE_STATUS_FAIL.equals(tradeStatus)) { - ChargeRecord updateRecord = new ChargeRecord(); - updateRecord.setChargeRecordId(orderNo); - updateRecord.setChargeStatus(Constant.ChargeRecordStatus.error); - updateRecord.setUpdateTime(new Date()); - updateRecord.setChargeStatusDesc(errMsg); - chargeRecordMapper.insertSelective(updateRecord); - } - } finally { - jedisLockService.unlock(lockKey, lockVal); - } - } - - return "success"; - } - - @RequestMapping("/query") - public String query(String orderNo, String app) throws Exception { - String lockKey = RedisKey.lock_fastpay_notify.getKey(orderNo); - String lockVal = jedisLockService.lock(lockKey, CALLBACK_LOCK_MILLIS); - if (StringUtils.isEmpty(lockVal)) { - return "订单正在处理中,请稍后再试"; - } - try { - FastpayQueryReq req = new FastpayQueryReq(); - req.setOrderNo(orderNo); - AgreementQueryResp resp = fastpayService.query(req, getPaymentDTO(app)); - - String tradeStatus = resp.getRa_Status(); - if (TRADE_STATUS_SUCCESS.equals(tradeStatus) || TRADE_STATUS_FAIL.equals(tradeStatus)) { - String fastpayTradeNo = resp.getR5_TrxNo(); - String amount = resp.getR3_Amount(); - String errMsg = resp.getRc_CodeMsg(); - if (StringUtils.isNotBlank(errMsg) && errMsg.length() > 64) { - errMsg = errMsg.substring(0, 64); - } - logger.info("fastpay, orderNo={}, tradeNo={}, amount={}, msg:{}", orderNo, fastpayTradeNo, amount, errMsg); - - ChargeRecord record = this.chargeRecordService.getChargeRecordById(orderNo); - if (record == null) { - return "failed"; - } - if (PaymentConstant.ChargeStatus.PAIED.equals(record.getChargeStatus())) { - logger.info("订单{}已处理完成", orderNo); - return "success"; - } - if (TRADE_STATUS_SUCCESS.equals(tradeStatus)) { - record.setPingxxChargeId(fastpayTradeNo); - record.setChargeStatusDesc(errMsg); - chargeService.updateAppPayData(record); - } else if (TRADE_STATUS_FAIL.equals(tradeStatus)) { - ChargeRecord updateRecord = new ChargeRecord(); - updateRecord.setChargeRecordId(orderNo); - updateRecord.setChargeStatus(Constant.ChargeRecordStatus.error); - updateRecord.setChargeStatusDesc(errMsg); - updateRecord.setUpdateTime(new Date()); - chargeRecordMapper.insertSelective(updateRecord); - } - } - return "success"; - } finally { - jedisLockService.unlock(lockKey, lockVal); - } - } - -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/FufeitongPayController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/FufeitongPayController.java deleted file mode 100644 index ada33467a..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/FufeitongPayController.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.accompany.business.controller.apppay; - -import cn.hutool.core.util.StrUtil; -import com.accompany.business.service.ChargeService; -import com.accompany.payment.constant.PayConstant; -import com.accompany.payment.fufeitong.FufeitongPayService; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.service.ChargeRecordService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import java.math.BigDecimal; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; - -/** - * 付费通支付相关接口 - * - * @author Chenzhixiang - * @date 2021年01月29日 - */ -@RestController -@RequestMapping("/payment/fufeitong") -@Slf4j -public class FufeitongPayController { - - private final static String RES_SUCCESS = "success"; - - private final static String RES_ERROR = "ERROR"; - - @Autowired - private FufeitongPayService fufeitongPayService; - @Autowired - private ChargeRecordService chargeRecordService; - @Autowired - private ChargeService chargeService; - - @RequestMapping(value = "/callback", method = RequestMethod.POST) - public String callback(HttpServletRequest request) { - log.info("start handle fufeitong pay notification"); - - try { - Map resultMap = new HashMap<>(); - Enumeration enumer = request.getParameterNames(); - StringBuffer info = new StringBuffer(); - info.append("收到数据:\r\n"); - while (enumer.hasMoreElements()) { - String key = enumer.nextElement(); - - String value = String.valueOf(request.getParameter(key)); - info.append("\t参数名[" + key + "] >>>> 参数值[" + value + "]\r\n"); - if (StrUtil.isEmpty(value)) { - continue; - } - resultMap.put(key, value); - } - log.info("付费通接受回调参数为:{}",info.toString()); - - if (!fufeitongPayService.verifySign(resultMap)) { - log.error("【付费通支付回调】通知sign校验不通过"); - return RES_ERROR; - } - - String billId = resultMap.get("traceno"); - - ChargeRecord chargeRecordById = - chargeRecordService.getChargeRecordById(billId); - if (chargeRecordById == null) { - log.warn("【付费通支付回调】订单 {} 不存在", billId); - return RES_ERROR; - } - Long totalAmount = new BigDecimal(resultMap.get("amount")).multiply(PayConstant.HUNDRED).longValue(); - // 校验金额 - boolean validateAmount = totalAmount.equals(chargeRecordById.getAmount()); - if (!validateAmount) { - log.warn("【付费通支付回调】订单 {} 金额 {} 校验失败", billId, totalAmount.toString()); - return RES_ERROR; - } - chargeService.payCallbackDo(billId, resultMap.get("orderno")); - } catch (Exception e) { - log.error("【付费通支付回调】支付通知处理异常", e); - return RES_ERROR; - } - - log.info("end handle fufeitong pay notification"); - return RES_SUCCESS; - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/GooglePlayBillingChargeController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/GooglePlayBillingChargeController.java index 46795ad55..e163b7f7d 100644 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/GooglePlayBillingChargeController.java +++ b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/GooglePlayBillingChargeController.java @@ -26,8 +26,6 @@ import javax.servlet.http.HttpServletRequest; @Slf4j public class GooglePlayBillingChargeController extends BaseController { - @Autowired - private ChargeService chargeService; @Autowired private GooglePlayBillingService googlePlayBillingService; diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/GuotongPayController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/GuotongPayController.java deleted file mode 100644 index 8060a1b49..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/GuotongPayController.java +++ /dev/null @@ -1,148 +0,0 @@ -package com.accompany.business.controller.apppay; - -import com.accompany.business.service.ChargeService; -import com.accompany.common.redis.RedisKey; -import com.accompany.common.status.BusiStatus; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.service.common.JedisLockService; -import com.accompany.payment.constant.PayConstant; -import com.accompany.payment.guotongpay.*; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.sandpay.SandPayService; -import com.accompany.payment.service.ChargeRecordService; -import com.accompany.payment.utils.CommonPayUtils; -import com.accompany.payment.utils.SandpayUtils; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -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.InputStreamReader; -import java.math.BigDecimal; -import java.util.Map; - -@RestController -@RequestMapping("/payment/guotong") -@Slf4j -public class GuotongPayController { - - private final static String RES_SUCCESS = "SUCCESS"; - - private final static String RES_ERROR = "ERROR"; - - @Autowired - private GuotongPayService guotongPayService; - @Autowired - private ChargeRecordService chargeRecordService; - @Autowired - private ChargeService chargeService; - @Autowired - private JedisLockService jedisLockService; - @Autowired - GuotongPayConfig guotongPayForMangguoConfig; - @Autowired - GuotongForZjlxPayConfig guotongForZjlxPayConfig; - - - @PostMapping("/payCallback") - public String payCallback(HttpServletRequest request) { - BufferedReader br = null; - try { - br = new BufferedReader(new InputStreamReader(request.getInputStream(), "utf-8")); - } catch (IOException e) { - e.printStackTrace(); - } - String line = null; - StringBuffer sb = new StringBuffer(); - try { - while ((line = br.readLine()) != null) { - sb.append(line); - } - } catch (IOException e) { - e.printStackTrace(); - } - log.info("接受回调参数为:{}", sb.toString()); - - try { - Boolean result = handleCallback(sb.toString(), guotongPayForMangguoConfig); - return result ? RES_SUCCESS : RES_ERROR; - } catch (Exception e) { - log.error("国通支付通知处理异常", e); - } - return RES_ERROR; - } - - @PostMapping("/payCallbackForZjlx") - public String payCallbackForZjlx(HttpServletRequest request) { - BufferedReader br = null; - try { - br = new BufferedReader(new InputStreamReader(request.getInputStream(), "utf-8")); - } catch (IOException e) { - e.printStackTrace(); - } - String line = null; - StringBuffer sb = new StringBuffer(); - try { - while ((line = br.readLine()) != null) { - sb.append(line); - } - } catch (IOException e) { - e.printStackTrace(); - } - log.info("接受回调参数为:{}", sb.toString()); - - try { - Boolean result = handleCallback(sb.toString(), guotongForZjlxPayConfig); - return result ? RES_SUCCESS : RES_ERROR; - } catch (Exception e) { - log.error("国通支付通知处理异常", e); - } - return RES_ERROR; - } - - /** - * 处理支付结果回调,查询订单,如果支付成功到账 - */ - private Boolean handleCallback(String notifyStr, BaseGuotongPayConfig guotongPayConfig) throws Exception { - Map resultMap = CommonPayUtils.parseToMap(notifyStr); - if (!guotongPayService.checkSign(resultMap, guotongPayConfig)) { - return false; - } - - String orderNo = (String) resultMap.get("lowOrderId"); - ChargeRecord chargeRecord = chargeRecordService.getChargeRecordById(orderNo); - if (null == chargeRecord) { - log.error("国通回调校验失败,没有充值订单。订单号:{}", orderNo); - return false; - } - // 用户支付订单金额包含优惠 - int totalAmount = new BigDecimal((String) resultMap.get("payMoney")).multiply(PayConstant.HUNDRED).intValue(); - String lockval = jedisLockService.lock(RedisKey.lock_pay_callback_notify.getKey(orderNo), 5000); - try { - if (StringUtils.isEmpty(lockval)) { - throw new ServiceException(BusiStatus.BUSIERROR); - } - Integer orderStatus = Integer.parseInt((String) resultMap.get("state")); - if (orderStatus != GuotongPayConstant.PAY_STATUS_SUCCESS) { - log.error("国通回调校验失败,充值结果状态不是成功。订单号:{}", orderNo); - return false; - } - // 订单金额 - Integer orderAmount = chargeRecord.getAmount().intValue(); - if (!orderAmount.equals(totalAmount)) { - log.error("国通回调校验失败,订单金额不匹配。订单号:{},订单金额:{},回调金额:{}", orderNo, orderAmount, totalAmount); - throw new ServiceException(BusiStatus.CHARGE_AMOUNT_INCORRECT); - } - chargeService.updateAppPayData(chargeRecord); - return true; - } finally { - jedisLockService.unlock(RedisKey.lock_pay_callback_notify.getKey(orderNo), lockval); - } - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/HeePayController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/HeePayController.java deleted file mode 100644 index 90482ee77..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/HeePayController.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.accompany.business.controller.apppay; - -import com.accompany.business.service.ChargeService; -import com.accompany.common.redis.RedisKey; -import com.accompany.common.status.BusiStatus; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.service.common.JedisLockService; -import com.accompany.payment.heepay.HeePayService; -import com.accompany.payment.heepay.params.NotifyParams; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.service.ChargeRecordService; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -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 javax.servlet.http.HttpServletRequest; -import java.math.BigDecimal; - -import static com.accompany.payment.constant.PayConstant.HUNDRED; - -/** - * 汇付宝相关借口 - * - */ -@RestController -@RequestMapping("/payment/heepay") -@Slf4j -public class HeePayController { - @Autowired - private HeePayService heePayService; - @Autowired - private ChargeRecordService chargeRecordService; - @Autowired - private ChargeService chargeService; - @Autowired - private JedisLockService jedisLockService; - - private final static String RES_ERROR = "error"; - - private final static String RES_OK = "ok"; - - private final static short RESULT_SUCCESS = 1; - - /** - * 客户端支付环境:h5 - */ - private final static String PAY_ENV_TYPE_H5 = "h5"; - - /** - * 客户端支付环境:微信小程序或公众号 - */ - private final static String PAY_ENV_TYPE_WX = "wx"; - - @GetMapping("/callback") - public String callback(HttpServletRequest request) throws Exception { - return handleCallback(request, PAY_ENV_TYPE_H5); - } - - @GetMapping("/callbackForWxEnv") - public String callbackForWxEnv(HttpServletRequest request) { - return handleCallback(request, PAY_ENV_TYPE_WX); - } - - private String handleCallback(HttpServletRequest request, String payEnvType) { - String result = request.getParameter("result");//支付结果,1=成功(没有其他情况,因为之后支付成功才会下发异步通知) - String agent_id = request.getParameter("agent_id");//商户ID - String jnet_bill_no = request.getParameter("jnet_bill_no");//汇付宝订单号 - String agent_bill_id = request.getParameter("agent_bill_id");//商户系统订单号 - String pay_type = request.getParameter("pay_type");//支付类型 - String pay_amt = request.getParameter("pay_amt");//实际支付金额 - String remark = request.getParameter("remark");//商户自定义参数,透传参数 - String sign = request.getParameter("sign");//签名 - - NotifyParams params = new NotifyParams(); - params.setResult(Short.valueOf(result)); - params.setAgentId(agent_id); - params.setJnetBillNo(jnet_bill_no); - params.setAgentBillId(agent_bill_id); - params.setPayType(pay_type); - params.setPayAmt(new BigDecimal(pay_amt)); - params.setRemark(remark); - params.setSign(sign); - - log.info("huifubao notify content: {}", JSONObject.toJSONString(params)); - if (!verifyNotifySign(params, payEnvType)) { - log.error("汇付宝通知sign校验不通过"); - return RES_ERROR; - } - - if (!params.getResult().equals(RESULT_SUCCESS)) { - log.error("汇付宝通知支付结果不是成功,忽略"); - return RES_OK; - } - - ChargeRecord chargeRecord = chargeRecordService.getChargeRecordById(params.getAgentBillId()); - if (null == chargeRecord) { - return RES_ERROR; - } - // 由于ChargeRecord中金额单位是分,所以这里乘100 - long payAmt = params.getPayAmt().multiply(HUNDRED).longValue(); - boolean validateAmount = chargeRecord.getAmount().equals(payAmt); - if (!validateAmount) { - log.warn("订单 {} 金额 {} 校验失败", params.getAgentBillId(), params.getPayAmt().toString()); - return RES_ERROR; - } - String lockKey = RedisKey.lock_pay_callback_notify.getKey(chargeRecord.getChargeRecordId()); - String lockval = jedisLockService.lock(lockKey, 5000); - try { - if (StringUtils.isEmpty(lockval)) { - throw new ServiceException(BusiStatus.BUSIERROR); - } - chargeService.updateAppPayData(chargeRecord); - return RES_OK; - } finally { - jedisLockService.unlock(lockKey, lockval); - } - } - - /** - * 校验回调签名 - * - * @param params - * @param payEnvType 客户端支付环境,h5 或 wx - * @return - */ - private boolean verifyNotifySign(NotifyParams params, String payEnvType) { - switch (payEnvType) { - case PAY_ENV_TYPE_WX: - return heePayService.verifyNotifySignForWxEnv(params); - default: - return heePayService.verifyNotifySign(params); - } - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/JoinpayController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/JoinpayController.java deleted file mode 100644 index 9dbe651da..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/JoinpayController.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.accompany.business.controller.apppay; - -import com.accompany.business.common.BaseController; -import com.accompany.business.service.ChargeRecordUpdateService; -import com.accompany.business.service.ChargeService; -import com.accompany.payment.joinpay.JoinpayService; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.service.ChargeRecordService; -import com.alibaba.fastjson.JSON; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.util.Calendar; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * @Description 汇聚支付相关接口 - * @Author Vicente Yang - */ -@RestController -@RequestMapping("/payment/joinpay") -public class JoinpayController extends BaseController { - - private static final Logger logger = LoggerFactory.getLogger(JoinpayController.class); - - @Autowired - private ChargeService chargeService; - @Autowired - private ChargeRecordService chargeRecordService; - @Autowired - private ChargeRecordUpdateService chargeRecordUpdateService; - @Autowired - private JoinpayService joinpayService; - - @RequestMapping("/callback") - public String callback(HttpServletRequest request) throws Exception { - Map requestMap = this.convertRequetsToMap(request); - logger.info("joinpay callback: {}", requestMap); - - boolean isSignLegal = this.joinpayService.verifySign(JSON.toJSONString(requestMap)); - if (!isSignLegal) { - logger.error("joinpay callback verify failed: {}", JSON.toJSONString(requestMap)); - return "failed"; - } - - String tradeStatus = requestMap.get(JoinpayService.TRADE_STATUS_KEY); - if (JoinpayService.TRADE_STATUS_SUCCESS.equals(tradeStatus)) { - String orderNo = requestMap.get("r2_OrderNo"); - String joinpayTradeNo = requestMap.get("r7_TrxNo"); - String amount = requestMap.get("r3_Amount"); - logger.info("joinpay, orderNo={}, tradeNo={}, amount={}", orderNo, joinpayTradeNo, amount); - - ChargeRecord record = this.chargeRecordService.getChargeRecordById(orderNo); - if (record == null) { - return "failed"; - } - - // 校验金额是否一致 - /*String amountReplacement = "."; - if (!amount.replaceAll(amountReplacement, "").equals(record.getAmount())) { - logger.error("金额不一致:callBack={}, record={}", requestMap, JSON.toJSONString(record)); - return "failed"; - }*/ - - record.setPingxxChargeId(joinpayTradeNo); - chargeService.updateAppPayData(record); - } - - // XXX: 支付失败时是否需要更新订单状态? - - return "success"; - } - - public ChargeRecord updateOrderStatus(String chargeRecordId, String thirdTradeNo) { - ChargeRecord chargeRecord = chargeRecordUpdateService.getChargeRecordById(chargeRecordId); - chargeRecord.setPingxxChargeId(thirdTradeNo); - chargeRecord.setUpdateTime(Calendar.getInstance().getTime()); - return chargeRecord; - } - - private Map convertRequetsToMap(HttpServletRequest request) throws UnsupportedEncodingException { - Map retMap = new HashMap<>(); - String defaultCharset = "UTF-8"; - logger.info("request parameter = {}", JSON.toJSONString(request.getParameterMap())); - Set> entries = request.getParameterMap().entrySet(); - for (Map.Entry entry : entries) { - String name = entry.getKey(); - String[] values = entry.getValue(); - int valLen = values.length; - if (valLen == 1) { - retMap.put(name, URLDecoder.decode(values[0], defaultCharset)); - } else if (valLen > 1) { - StringBuilder sb = new StringBuilder(); - for (String val : values) { - sb.append(",").append(val); - } - - retMap.put(name, URLDecoder.decode(sb.toString().substring(1), defaultCharset)); - } else { - retMap.put(name, ""); - } - } - - return retMap; - } - -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/SandPayController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/SandPayController.java deleted file mode 100644 index 4985e06ac..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/SandPayController.java +++ /dev/null @@ -1,127 +0,0 @@ -package com.accompany.business.controller.apppay; - -import cn.hutool.core.util.StrUtil; -import com.accompany.business.service.ChargeService; -import com.accompany.common.redis.RedisKey; -import com.accompany.common.status.BusiStatus; -import com.accompany.core.exception.ServiceException; -import com.accompany.core.service.common.JedisLockService; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.sandpay.SandPayService; -import com.accompany.payment.service.ChargeRecordService; -import com.accompany.payment.utils.SandpayUtils; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -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.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; - -@RestController -@RequestMapping("/payment/sandpay") -@Slf4j -public class SandPayController { - - private final static String RES_SUCCESS = "respCode=000000"; - - private final static String SUCCESS_CODE = "000000"; - - private final static String RES_ERROR = "ERROR"; - - @Autowired - private SandPayService sandPayService; - @Autowired - private ChargeRecordService chargeRecordService; - @Autowired - private ChargeService chargeService; - @Autowired - private JedisLockService jedisLockService; - - @RequestMapping(value = "/alipayCallback", method = RequestMethod.POST, produces = {"text/plain"} ) - public String alipayCallback(HttpServletRequest request) { - log.info("start handle sand pay notification"); - - Map resultMap = new HashMap<>(); - Enumeration enumer = request.getParameterNames(); - StringBuffer info = new StringBuffer(); - info.append("收到数据:\r\n"); - while (enumer.hasMoreElements()) { - String key = enumer.nextElement(); - - String value = String.valueOf(request.getParameter(key)); - info.append("\t参数名[" + key + "] >>>> 参数值[" + value + "]\r\n"); - if (StrUtil.isEmpty(value)) { - continue; - } - resultMap.put(key, value); - } - log.info("衫德支付接受回调参数为:{}",info.toString()); - - try { - Boolean result = handleCallback(resultMap); - return result ? RES_SUCCESS : RES_ERROR; - } catch (Exception e) { - log.error("衫德支付通知处理异常", e); - } - return RES_ERROR; - } - - /** - * 处理支付结果回调,查询订单,如果支付成功到账 - * @param resultMap - */ - private Boolean handleCallback(Map resultMap) throws Exception { - if (!sandPayService.verifyAlipayNotifyData(resultMap)) { - log.error("[sandpay callback]verify sign fail"); - return false; - } - - String data = resultMap.get("data"); - JSONObject dataJSON = JSONObject.parseObject(data); - JSONObject headJSON = dataJSON.getJSONObject("head"); - if (!SUCCESS_CODE.equalsIgnoreCase(headJSON.getString("respCode"))) { - log.info("[sandpay callback]not success request. respCode: {}", headJSON.getString("respCode")); - return false; - } - - JSONObject bodyJSON = dataJSON.getJSONObject("body"); - String orderNo = bodyJSON.getString("orderCode"); - ChargeRecord chargeRecord = chargeRecordService.getChargeRecordById(orderNo); - if (null == chargeRecord) { - return false; - } - // 用户支付订单金额包含优惠 - Integer totalAmount = Integer.parseInt(bodyJSON.getString("totalAmount")); - // 应结订单金额 - Integer settleAmount = Integer.parseInt(bodyJSON.getString("settleAmount")); - String lockval = jedisLockService.lock(RedisKey.lock_pay_callback_notify.getKey(orderNo), 5000); - try { - if (StringUtils.isEmpty(lockval)) { - throw new ServiceException(BusiStatus.BUSIERROR); - } - Integer orderStatus = Integer.parseInt(bodyJSON.getString("orderStatus")); - if (orderStatus != 1) { - return false; - } - // 订单金额 - Integer orderAmount = chargeRecord.getAmount().intValue(); - if (!totalAmount.equals(orderAmount) || !settleAmount.equals(orderAmount)) { - throw new ServiceException(BusiStatus.CHARGE_AMOUNT_INCORRECT); - } - chargeService.payCallbackDo(orderNo, bodyJSON.getString("tradeNo")); - return true; - } finally { - jedisLockService.unlock(RedisKey.lock_pay_callback_notify.getKey(orderNo), lockval); - } - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/WanXiangPayController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/WanXiangPayController.java deleted file mode 100644 index de22ca919..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/apppay/WanXiangPayController.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.accompany.business.controller.apppay; - -import cn.hutool.core.util.StrUtil; -import com.accompany.business.service.ChargeService; -import com.accompany.payment.constant.PayConstant; -import com.accompany.payment.fufeitong.FufeitongPayService; -import com.accompany.payment.model.ChargeRecord; -import com.accompany.payment.service.ChargeRecordService; -import com.accompany.payment.wanxiang.WanXiangPayService; -import com.accompany.payment.wanxiang.utils.WanxiangPayConsts; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import java.math.BigDecimal; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; - -/** - * 万象支付相关接口 - * - * @author Chenzhixiang - * @date 2021年01月29日 - */ -@RestController -@RequestMapping("/payment/wanxiang") -@Slf4j -public class WanXiangPayController { - - private final static String RES_SUCCESS = "success"; - - private final static String RES_ERROR = "failed"; - - @Autowired - private WanXiangPayService wanXiangPayService; - @Autowired - private ChargeRecordService chargeRecordService; - @Autowired - private ChargeService chargeService; - - @RequestMapping(value = "/callback", method = RequestMethod.POST, produces = {"text/plain"} ) - public String callback(HttpServletRequest request) { - log.info("start handle wanxiang pay notification"); - - try { - Map resultMap = new HashMap<>(); - Enumeration enumer = request.getParameterNames(); - StringBuffer info = new StringBuffer(); - info.append("收到数据:\r\n"); - while (enumer.hasMoreElements()) { - String key = enumer.nextElement(); - - String value = String.valueOf(request.getParameter(key)); - info.append("\t参数名[" + key + "] >>>> 参数值[" + value + "]\r\n"); - if (StrUtil.isEmpty(value)) { - continue; - } - resultMap.put(key, value); - } - log.info("万象支付接受回调参数为:{}",info.toString()); - - if (!wanXiangPayService.verifySign(resultMap)) { - log.error("【万象支付回调】通知sign校验不通过"); - return RES_ERROR; - } - - String billId = resultMap.get("n_TradeNo"); - - // 校验订单状态 - int chargeStatus = Integer.parseInt(resultMap.get("n_Status")); - if (WanxiangPayConsts.OrderStatus.PAY_SUCCESS != chargeStatus) { - log.error("【万象支付回调】 订单 {} 未支付, 支付状态 {}", billId, chargeStatus); - return RES_ERROR; - } - - ChargeRecord chargeRecordById = - chargeRecordService.getChargeRecordById(billId); - if (chargeRecordById == null) { - log.warn("【万象支付回调】订单 {} 不存在", billId); - return RES_ERROR; - } - Long totalAmount = new BigDecimal(resultMap.get("n_OrderAmount")).longValue(); - // 校验金额 - boolean validateAmount = totalAmount.equals(chargeRecordById.getAmount()); - if (!validateAmount) { - log.warn("【万象支付回调】订单 {} 金额 {} 校验失败", billId, totalAmount.toString()); - return RES_ERROR; - } - chargeService.payCallbackDo(billId, resultMap.get("n_AllPayTradeNo")); - } catch (Exception e) { - log.error("【万象支付回调】支付通知处理异常", e); - return RES_ERROR; - } - - log.info("end handle wanxiang pay notification"); - return RES_SUCCESS; - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/auditaudio/ReceiveAuditAudioController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/auditaudio/ReceiveAuditAudioController.java deleted file mode 100644 index a8978deae..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/auditaudio/ReceiveAuditAudioController.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.accompany.business.controller.auditaudio; - -import com.beust.jcommander.internal.Maps; -import com.accompany.business.constant.RiskLevelEnum; -import com.accompany.business.mongodb.document.auditaudio.AuditAudio; -import com.accompany.business.service.auditaudio.AuditAudioService; -import com.accompany.business.common.BaseController; -import com.google.gson.Gson; -import com.google.gson.internal.LinkedTreeMap; -import com.accompany.common.utils.UUIDUitl; -import com.accompany.common.constant.ApplicationConstant; -import com.accompany.common.utils.DateTimeUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; -import java.util.Map; - -/** - * 2 * @Author: zhuct - * 3 * @Date: 2019/8/16 11:51 - * 4 - */ -@RestController -@RequestMapping(value = "/receive/audit/media") -public class ReceiveAuditAudioController extends BaseController { - @Autowired - private AuditAudioService auditAudioService; - - public static final Logger logger = LoggerFactory.getLogger(ReceiveAuditAudioController.class); - private Gson gson = new Gson(); - - - @RequestMapping(value = "/callback", method = {RequestMethod.POST}) - public Map auditAudioCallBack(HttpServletRequest request) throws Exception { - Map result = Maps.newHashMap(); - - // 获取请求体 - byte[] body = readBody(request); - if (body == null) { - logger.warn("auditAudioCallBack request wrong, empty body!"); - result.put("code", 414); - return result; - } - String requestBody = new String(body, ApplicationConstant.DEFAULT_CHARSET); - logger.info("auditAudioCallBack request body = {}", requestBody); - Map requestMap = gson.fromJson(requestBody, HashMap.class); - Double code = (Double) requestMap.get("code"); - String message = (String) requestMap.get("message"); - if (code.intValue() == 1100) {//成功 - AuditAudio auditAudio = this.buildAuditAudio(requestMap); - auditAudioService.handleAudio(auditAudio); - } else { - logger.warn("auditAudioCallBack request with code={},message={}", code, message); - } - result.put("code", 200); - return result; - } - - private AuditAudio buildAuditAudio(Map dataMap) { - AuditAudio auditAudio = new AuditAudio(); - LinkedTreeMap detailData = (LinkedTreeMap) dataMap.get("detail"); - //LinkedTreeMap requestParams = (LinkedTreeMap) detailData.get("requestParams"); 17 - auditAudio.setRecordId(UUIDUitl.get()); - String room = (String) detailData.get("room"); - auditAudio.setRoomUid(Long.valueOf(room)); - auditAudio.setRequestId((String) dataMap.get("requestId")); - Double score = (Double) dataMap.get("score"); - auditAudio.setScore(score.intValue()); - RiskLevelEnum riskLevel = RiskLevelEnum.get((String) dataMap.get("riskLevel")); - auditAudio.setRiskLevel(riskLevel == null ? null : riskLevel.getValue()); - auditAudio.setAudioUrl((String) detailData.get("audioUrl")); - auditAudio.setPreAudioUrl(detailData.get("preAudioUrl") == null ? null : (String) detailData.get("preAudioUrl")); - auditAudio.setAudioStartTime(DateTimeUtil.convertStrToDate((String) detailData.get("audio_starttime")).getTime()); - auditAudio.setAudioEndTime(DateTimeUtil.convertStrToDate((String) detailData.get("audio_endtime")).getTime()); - auditAudio.setContent(detailData.get("content") == null ? null : (String) detailData.get("content")); - auditAudio.setMatchedDetail(detailData.get("matchedDetail") == null ? null : (String) detailData.get("matchedDetail")); - auditAudio.setMatchedField(detailData.get("matchedField") == null ? null : "nickname".equals(detailData.get("matchedField")) ? (byte) 2 : (byte) 1); - auditAudio.setMatchedItem(detailData.get("matchedItem") == null ? null : (String) detailData.get("matchedItem")); - auditAudio.setMatchedList(detailData.get("matchedList") == null ? null : (String) detailData.get("matchedList")); - Double riskType = (Double) detailData.get("riskType"); - auditAudio.setRiskType(riskType == null ? null : riskType.intValue()); - auditAudio.setRiskTypeDesc(detailData.get("riskTypeDesc") == null ? null : (String) detailData.get("riskTypeDesc")); - auditAudio.setCreateTime(System.currentTimeMillis()); - return auditAudio; - } - -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/exchange/ExchangeDiamondGoldRecordController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/exchange/ExchangeDiamondGoldRecordController.java index eb7e7cacb..07f5b2d1a 100644 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/exchange/ExchangeDiamondGoldRecordController.java +++ b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/exchange/ExchangeDiamondGoldRecordController.java @@ -2,7 +2,6 @@ package com.accompany.business.controller.exchange; import com.accompany.business.common.BaseController; import com.accompany.business.service.record.ExchangeDiamondGoldRecordService; -import com.accompany.business.service.wx.WXPubService; import com.accompany.business.util.RSAUtils; import com.accompany.business.vo.UserPurseVo; import com.accompany.common.annotation.Authorization; @@ -17,7 +16,6 @@ import com.accompany.core.exception.ServiceException; import com.accompany.core.service.SysConfService; import com.accompany.core.service.common.JedisService; import com.accompany.core.util.KeyStore; -import com.accompany.payment.config.WxConfig; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -36,8 +34,8 @@ import java.util.Date; public class ExchangeDiamondGoldRecordController extends BaseController { @Autowired private ExchangeDiamondGoldRecordService exchangeDiamondGoldRecordService; - @Autowired - private WXPubService wxPubService; + //@Autowired + //private WXPubService wxPubService; @Autowired private JedisService jedisService; @Autowired @@ -122,11 +120,11 @@ public class ExchangeDiamondGoldRecordController extends BaseController { if(curCumulative <= secondLimitCumulative){ if(curCumulative >= firstLimitCumulative){ - this.wxPubService.sendAlertMsg(WxConfig.alertAdminUser,"警报警报!","兑换金币异常警报",curCumulative.toString(),DateTimeUtil.convertDate(new Date(),"yyyy-MM-dd hh:mm:ss"),"当前预报等级为一级,已超过一级异常值","业务正常处理,排查数据无误后请忽略该警报"); + //this.wxPubService.sendAlertMsg(WxConfig.alertAdminUser,"警报警报!","兑换金币异常警报",curCumulative.toString(),DateTimeUtil.convertDate(new Date(),"yyyy-MM-dd hh:mm:ss"),"当前预报等级为一级,已超过一级异常值","业务正常处理,排查数据无误后请忽略该警报"); } return true; }else{ - this.wxPubService.sendAlertMsg(WxConfig.alertAdminUser,"警报警报!","兑换金币异常警报",curCumulative.toString(),DateTimeUtil.convertDate(new Date(),"yyyy-MM-dd hh:mm:ss"),"当前预报等级为二级,已超过二级异常值,数据异常请马上排查","当天h5兑换金币业务已停止,请立即排查数据"); + //this.wxPubService.sendAlertMsg(WxConfig.alertAdminUser,"警报警报!","兑换金币异常警报",curCumulative.toString(),DateTimeUtil.convertDate(new Date(),"yyyy-MM-dd hh:mm:ss"),"当前预报等级为二级,已超过二级异常值,数据异常请马上排查","当天h5兑换金币业务已停止,请立即排查数据"); } } diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/game/DragonBallController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/game/DragonBallController.java deleted file mode 100644 index 1b54ba0a6..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/game/DragonBallController.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.accompany.business.controller.game; - - -import com.alibaba.fastjson.JSONObject; -import com.accompany.business.service.game.DragonBallService; -import com.accompany.common.result.BusiResult; -import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.CommonUtil; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.util.Arrays; - -/** - * Created by PaperCut on 2018/7/12. - */ -@RestController -@RequestMapping("/dragonBall") -public class DragonBallController { - @Autowired - DragonBallService dragonBallService; - - /** - * 生成或获取龙珠点数 - * @param roomUid - * @param uid - * @return - */ - @RequestMapping(value = "gen", method = RequestMethod.POST) - public BusiResult gen(@RequestParam("roomUid")Long roomUid, - @RequestParam("uid")Long uid) { - BusiResult result = new BusiResult(BusiStatus.SUCCESS); - String data = dragonBallService.get(roomUid, uid); - JSONObject obj = new JSONObject(); - boolean isGen = false; - if(StringUtils.isEmpty(data)) { - int[] arrs = new int[3]; - arrs[0] = CommonUtil.genRandom(0, 6); - arrs[1] = CommonUtil.genRandom(0, 6); - arrs[2] = CommonUtil.genRandom(0, 6); - data = StringUtils.strip(Arrays.toString(arrs), "[]"); - dragonBallService.put(roomUid, uid, data); - isGen = true; - } - obj.put("value", data); - obj.put("isGen", isGen); - result.setData(obj); - return result; - } - - /** - * 清空龙珠点数 - * @param roomUid - * @param uid - * @return - */ - @RequestMapping(value = "clear", method = RequestMethod.POST) - public BusiResult clear(@RequestParam("roomUid")Long roomUid, - @RequestParam("uid")Long uid) { - BusiResult result = new BusiResult(BusiStatus.SUCCESS); - dragonBallService.remove(roomUid, uid); - return result; - } - -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/game/doll/SingleDollController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/game/doll/SingleDollController.java deleted file mode 100644 index 7926a1292..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/game/doll/SingleDollController.java +++ /dev/null @@ -1,267 +0,0 @@ -package com.accompany.business.controller.game.doll; - -import com.accompany.business.service.game.doll.SingleDollService; -import com.accompany.business.service.wx.WXPubService; -import com.accompany.business.vo.user.UserInfo; -import com.accompany.business.common.BaseController; -import com.accompany.common.constant.GameConstant; -import com.accompany.common.result.BusiResult; -import com.accompany.common.status.BusiStatus; -import com.accompany.common.utils.BlankUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; - -/** - *单身娃娃请求接口 - */ -@RestController -@RequestMapping(value = "/doll") -public class SingleDollController extends BaseController{ - - private static final Logger logger = LoggerFactory.getLogger(SingleDollController.class); - - @Autowired - private SingleDollService singleDollService; - @Autowired - private WXPubService wxPubService; - - - - /** - *获取用户信息 - */ - @RequestMapping(value="/getUserInfo",method=RequestMethod.GET) - public BusiResult getUserInfo(Long uid, String code, @RequestParam(defaultValue="1") Byte platform, HttpServletRequest request) { - String ip = request.getRemoteAddr(); - try { - UserInfo userInfo = null; - if(!BlankUtil.isBlank(code) && GameConstant.PlatformType.WEIXIN.equals(platform)){ - userInfo = this.wxPubService.getUserInfoByCode(code); - if(userInfo == null){ - return new BusiResult(BusiStatus.WEIXIN_USER_NOT_EXITSTS); - } - } - BusiResult result = singleDollService.getUserInfo(uid,userInfo,platform,ip); - return result; - } catch (Exception e) { - logger.error("get user info failed,userId={},platform={}",uid,platform,e); - return new BusiResult<>(BusiStatus.ACCOUNT_INIT_FAILD); - } - - } - - - /** - *查询 娃娃的信息 - */ - @RequestMapping(value="/query",method=RequestMethod.GET) - public BusiResult getDollInfo(Long uid) { - if(uid == null){ - return new BusiResult(BusiStatus.PARAMERROR); - } - try { - BusiResult result = singleDollService.queryUserDoll(uid); - return result; - } catch (Exception e) { - logger.error("get user doll msg failed,uid={}",uid,e); - return new BusiResult(BusiStatus.BUSIERROR); - - } - } - - /** - *自定义设置娃娃信息 - */ - @RequestMapping(value="/customDoll",method=RequestMethod.POST) - public BusiResult customDoll(Long uid,Byte sex,String voiceUrl,Long inviterId,String nick,String avatar) { - if(sex == null || BlankUtil.isBlank(voiceUrl) || BlankUtil.isBlank(nick) || BlankUtil.isBlank(avatar) || uid == null){ - return new BusiResult(BusiStatus.PARAMERROR); - } - try { - BusiResult result = singleDollService.addUserDoll(uid,sex,voiceUrl,inviterId,nick,avatar); - return result; - } catch (Exception e) { - logger.error("customDoll failed,userId={},sex={},inviterId={}",uid,sex,inviterId,e); - return new BusiResult<>(BusiStatus.CUSTOM_DOLL_FAILD); - } - - - } - - - /** - *抓娃娃 - */ - @RequestMapping(value="/catchUserDoll",method=RequestMethod.POST) - public BusiResult catchUserDoll(Long uid,Byte goalStatus,@RequestParam(defaultValue="0") Byte sex) { - try { - BusiResult result = singleDollService.cacthUserDoll(uid,goalStatus,sex); - return result; - } catch (Exception e) { - logger.error("catchUserDoll failed,userId={},sex={},goalStatus={}",uid,sex,goalStatus,e); - return new BusiResult(BusiStatus.CATCH_DOLL_ERORR); - } - - } - - - /** - *抓中娃娃 处理 1是放弃 2是喜欢 - */ - @RequestMapping(value="/deal",method=RequestMethod.POST) - public BusiResult dealDoll(Long uid,Long recordId,Byte dealType,Long targetUid) { - try { - BusiResult result = singleDollService.dealDoll(uid,recordId,dealType,targetUid); - return result; - } catch (Exception e) { - logger.error("dealCatchedDoll failed,userId={},recordId={}",uid,recordId,e); - return new BusiResult<>(BusiStatus.CATCH_DOLL_ERORR); - } - - } - - /** - *点击普通分享和爱心链接回调函数 - */ - @RequestMapping(value="/click",method=RequestMethod.POST) - public BusiResult sharedCallBack(Long uid,Long inviterUid,Byte linkType) { - if(uid == null || linkType == null){ - return new BusiResult(BusiStatus.PARAMERROR); - } - try { - BusiResult busiResult = singleDollService.clickDollLink(uid,inviterUid,linkType); - return busiResult; - } catch (Exception e) { - logger.error("shareCallBack failed,uid={},inviterUid={},linkType={}",uid,inviterUid,linkType,e); - return new BusiResult<>(BusiStatus.BUSIERROR); - - } - } - - /** - *喜欢我的 - */ - @RequestMapping(value="/likeme",method=RequestMethod.POST) - public BusiResult likeMe(Long uid, @RequestParam(value="page", defaultValue="1") Integer page, @RequestParam(value="pageSize", defaultValue="10") Integer pageSize) { - try { - BusiResult result = singleDollService.queryLikedMeData(uid,page,pageSize); - return result; - } catch (Exception e) { - logger.error("getLikeMeList failed,userId={}",uid,e); - return new BusiResult<>(BusiStatus.BUSIERROR); - } - - } - - /** - *我喜欢的 排行榜 - */ - @RequestMapping(value="/ilike",method=RequestMethod.POST) - public BusiResult iLike(Long uid, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "20") Integer pageSize) { - page = page < 1 ? 1:page; - pageSize = pageSize < 10 ? 10 : pageSize; - - try { - BusiResult result = singleDollService.queryRecordList(uid,page,pageSize,1); - return result; - } catch (Exception e) { - logger.error("getILikeRank failed,userId={}",uid,e); - return new BusiResult<>(BusiStatus.QUERY_FAILD); - } - - } - - - /** - *我抓住的 排行榜 - */ - @RequestMapping(value="/iCatch",method=RequestMethod.POST) - public BusiResult iCatch(Long uid, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "20") Integer pageSize) { - page = page < 1 ? 1:page; - pageSize = pageSize < 10 ? 10 : pageSize; - - try { - BusiResult result = singleDollService.queryRecordList(uid,page,pageSize,2); - return result; - } catch (Exception e) { - logger.error("getICatchRank failed,userId={}",uid,e); - return new BusiResult<>(BusiStatus.QUERY_FAILD); - } - } - - -// /** -// *我邀请的 排行榜 -// */ -// @RequestMapping(value="/inviterank",method=RequestMethod.POST) -// public BusiResult iInvite(Long uid) { -// -// try { -// BusiResult result = singleDollService.queryInviteRank(uid); -// return result; -// } catch (Exception e) { -//// e.printStackTrace(); -// logger.error("getInviteRank failed,userId={}",uid,e); -// return new BusiResult<>(BusiStatus.QUERY_FAILD); -// } -// -// } - - - /** - *爱心链接记录 - */ - @RequestMapping(value="/loveLinkRecord",method=RequestMethod.POST) - public BusiResult loveLinkRecord(Long uid, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "20") Integer pageSize) { - page = page < 1 ? 1:page; - pageSize = pageSize < 10 ? 10 : pageSize; - try { - BusiResult result = singleDollService.queryRecordList(uid,page,pageSize,3); - return result; - } catch (Exception e) { - logger.error("getloveLinkRecord failed,userId={}",uid,e); - return new BusiResult<>(BusiStatus.QUERY_FAILD); - } - - } - - - @RequestMapping(value = "/reload",method = RequestMethod.GET) - public BusiResult reloadRank(){ - BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS); - try{ - singleDollService.reloadRank(); - return busiResult; - }catch (Exception e){ - logger.error("reload rankList failed",e); - return new BusiResult(BusiStatus.SERVERERROR); - } - } - - @RequestMapping(value = "/getLikeRank",method = RequestMethod.GET) - public BusiResult getLikeRank(Long uid){ - try{ - return singleDollService.queryLikeRank(uid); - }catch (Exception e){ - logger.error("getLikeRank failed,userId={}",uid,e); - return new BusiResult(BusiStatus.BUSIERROR); - } - } - - @RequestMapping(value = "test",method = RequestMethod.GET) - public void test(Long uid){ - try{ - singleDollService.updateSpecialTimeByShare(uid); - }catch (Exception e){ - logger.error("wewaefwa"); - } - - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/home/ClientController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/home/ClientController.java index bff687b09..06a504c55 100644 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/home/ClientController.java +++ b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/home/ClientController.java @@ -27,7 +27,6 @@ import com.accompany.common.status.BusiStatus; import com.accompany.common.utils.IPUitls; import com.accompany.core.model.Users; import com.accompany.core.service.SysConfService; -import com.accompany.core.vo.BaseRequestVO; import com.accompany.core.vo.SplashVo; import com.google.gson.reflect.TypeToken; import lombok.extern.slf4j.Slf4j; diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/kuaishou/KuaishouAdController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/kuaishou/KuaishouAdController.java deleted file mode 100644 index a82290283..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/kuaishou/KuaishouAdController.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.accompany.business.controller.kuaishou; - -import com.accompany.business.common.BaseController; -import com.accompany.business.dto.kuaishou.AdKuaishouTrackActiveReqDto; -import com.accompany.business.model.kuaishou.KuaishouAdCalBackRecord; -import com.accompany.business.param.kuaishou.AdKuaishouTrackActiveReqParams; -import com.accompany.business.service.ad.AdPlatformStrategyFactory; -import com.accompany.business.service.ad.IAdPlatformStrategy; -import com.accompany.business.service.kuaishou.KuaishouService; -import com.accompany.business.util.AdPlatformUtil; -import com.accompany.core.enumeration.BusinessStatusCodeEnum; -import com.accompany.core.enumeration.PublicHeaderParamEnum; -import com.accompany.core.vo.BaseResponseVO; -import com.alibaba.fastjson.JSON; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import java.io.IOException; -import java.util.Optional; - -@Slf4j -@RestController -@Api(tags = "快手广告",value = "快手广告") -@RequestMapping("/kuaishouAd") -public class KuaishouAdController extends BaseController { - - @Autowired - private AdPlatformStrategyFactory adPlatfromStategyFactory; - @Autowired - private KuaishouService kuaishouService; - - - @RequestMapping(value = "/click", method = RequestMethod.GET) - public BaseResponseVO click(KuaishouAdCalBackRecord kuaishouAdCalBackRecord) { - log.info("accept kuaishou callback , params {}", JSON.toJSONString(kuaishouAdCalBackRecord)); - kuaishouService.saveRecord(kuaishouAdCalBackRecord); - return new BaseResponseVO(BusinessStatusCodeEnum.SUCCESS); - } - - - /** - * activeReqDto.setIdfa("42BB4E8F-BBA3-4205-B787-8BB4B30980A7"); - * @param params - * @param request - * @return - * @throws IOException - */ - @ApiOperation("事件回传") - @RequestMapping(value = "/activeTrack", method = RequestMethod.POST) - public BaseResponseVO activeTrack(AdKuaishouTrackActiveReqParams params, HttpServletRequest request) throws IOException { - params = Optional.ofNullable(params).orElse(new AdKuaishouTrackActiveReqParams()); - log.info("kuaishou activeTrack , params {}", JSON.toJSONString(params)); - String os = request.getParameter(PublicHeaderParamEnum.OS.getValue()); - String channel = request.getParameter(PublicHeaderParamEnum.CHANNEL.getValue()); - String androidId = request.getParameter(PublicHeaderParamEnum.ANDROID_ID.getValue()); - String idfa = request.getParameter(PublicHeaderParamEnum.IDFA.getValue()); - String oaid = request.getParameter(PublicHeaderParamEnum.OAID.getValue()); - String iemi = request.getParameter(PublicHeaderParamEnum.IMEI.getValue()); - - Integer platformOs = AdPlatformUtil.turnToAdPlatformOs(os); - - - AdKuaishouTrackActiveReqDto activeReqDto = new AdKuaishouTrackActiveReqDto(); - BeanUtils.copyProperties(params, activeReqDto); - activeReqDto.setPlatOs(platformOs); - activeReqDto.setOaid(oaid); - activeReqDto.setAndroidId(androidId); - activeReqDto.setImei(iemi); - activeReqDto.setIdfa(idfa); - - log.info("kuaishou activeTrack , channel{},activeReqDto {}", channel, JSON.toJSONString(activeReqDto)); - IAdPlatformStrategy strategy = adPlatfromStategyFactory.getInstance(channel); - try { - strategy.activeTrack(activeReqDto); - }catch (Exception e) { - log.error("快手用户激活失败",e); - } - - return new BaseResponseVO(BusinessStatusCodeEnum.SUCCESS); - } -} \ No newline at end of file diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/observe/ObserveController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/observe/ObserveController.java deleted file mode 100644 index 6f7f288df..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/observe/ObserveController.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.accompany.business.controller.observe; - - -import com.accompany.business.model.BiliObserveRecord; -import com.accompany.business.service.observe.BiliObserveRecordService; -import com.accompany.common.constant.ObserveConstant; -import com.accompany.common.utils.IPUitls; -import com.accompany.common.utils.StringUtils; -import com.alibaba.fastjson.JSON; -import com.accompany.business.service.observe.ObserveService; -import com.accompany.business.common.BaseController; -import com.accompany.common.device.DeviceInfo; -import com.accompany.common.result.BusiResult; -import com.accompany.common.status.BusiStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * Created by yuanyi on 2019/3/5. - */ -@RestController -@RequestMapping("/observe") -public class ObserveController extends BaseController { - - @Autowired - private ObserveService observeService; - @Autowired - private BiliObserveRecordService biliObserveRecordService; - - private static final Logger logger = LoggerFactory.getLogger(ObserveController.class); - - /** - * B站请求 - * @param biliObserveRecord - * @return - */ - @RequestMapping("/bili/feedback") - public BusiResult feedbackFromBili(BiliObserveRecord biliObserveRecord) { - biliObserveRecordService.saveFeedback(biliObserveRecord); - return new BusiResult(BusiStatus.SUCCESS); - } - - /** - * android客户端回调 - * @param request - * @param imei - * @param oaid - * @param deviceInfo - * @return - */ - @RequestMapping(value = "/callback", method = RequestMethod.POST) - public BusiResult commonCallback(HttpServletRequest request, String imei, String oaid, DeviceInfo deviceInfo){ - if (deviceInfo.getChannel().equals(ObserveConstant.ObserveChannel.BILIBILI)) { - if (StringUtils.isNotBlank(imei) || StringUtils.isNotBlank(oaid)) { - biliObserveRecordService.saveCallback(deviceInfo.getDeviceId(), imei, oaid); - } - } - return new BusiResult(BusiStatus.SUCCESS); - } - - - /** - * 百度客户端用户点击广告时百度请求接口 - * @param request - */ - @RequestMapping("/baidu/feedback") - public void feedbackFromBaidu(HttpServletRequest request, HttpServletResponse response) throws Exception { - logger.info("baidu observe feedback request parameter = {}", JSON.toJSONString(request.getParameterMap())); - try{ - Map map = this.convertRequetsToMap(request); - this.observeService.baiduFeedBack(map); - response.setStatus(HttpServletResponse.SC_OK); - response.setCharacterEncoding("UTF-8"); - PrintWriter printWriter = response.getWriter(); - printWriter.write("{\n" + - "\"code\": " + 200 + ",\n" + - "\"message\": \"" + "success" + "\"\n" + - "}"); - printWriter.flush(); - printWriter.close(); - }catch (Exception e){ - logger.error("baidu observe feedback failed,param={}",JSON.toJSONString(request.getParameterMap()),e); - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - response.setCharacterEncoding("UTF-8"); - PrintWriter printWriter = response.getWriter(); - printWriter.write("{\n" + - "\"code\": " + 4000 + ",\n" + - "\"message\": \"" + e.getMessage() + "\"\n" + - "}"); - printWriter.flush(); - printWriter.close(); - } - } - - /** - * 百度信息流回调 - * @param request - * @param id - * @param uid - * @param deviceInfo - * @return - */ - @RequestMapping(value = "/baidu/callback",method = RequestMethod.POST) - public BusiResult baiduCallback(HttpServletRequest request, String id, Long uid, DeviceInfo deviceInfo){ - - String ip = IPUitls.getRealIpAddress(request); - logger.info("baidu observe callback id = {}, deviceInfo={}, ip={}",id, JSON.toJSONString(deviceInfo),ip); - if(!StringUtils.isEmpty(id)){ - try{ - this.observeService.baiduCallback(id,deviceInfo,ip); - }catch (Exception e){ - logger.error("baidu observe callback failed,id",id,e); - } - } - return new BusiResult(BusiStatus.SUCCESS); - } - - - - private Map convertRequetsToMap(HttpServletRequest request) throws UnsupportedEncodingException { - Map retMap = new HashMap<>(); - String defaultCharset = "UTF-8"; - logger.info("request parameter = {}", JSON.toJSONString(request.getParameterMap())); - Set> entries = request.getParameterMap().entrySet(); - for (Map.Entry entry : entries) { - String name = entry.getKey(); - String[] values = entry.getValue(); - int valLen = values.length; - if (valLen == 1) { - if(name.equals("callback_url")){ - retMap.put(name,values[0]); - }else{ - retMap.put(name, URLDecoder.decode(values[0], defaultCharset)); - } -// retMap.put(name, URLDecoder.decode(values[0], defaultCharset)); - } else if (valLen > 1) { - StringBuilder sb = new StringBuilder(); - for (String val : values) { - sb.append(",").append(val); - } - - retMap.put(name, URLDecoder.decode(sb.toString().substring(1), defaultCharset)); - } else { - retMap.put(name, ""); - } - } - - return retMap; - } - -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/room/RoomController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/room/RoomController.java index 69a82bda3..9c2419863 100644 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/room/RoomController.java +++ b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/room/RoomController.java @@ -8,19 +8,15 @@ import com.accompany.business.param.RoomAdminParam; import com.accompany.business.param.RoomParam; import com.accompany.business.sensitvienew.SensitiveFilterUtil; import com.accompany.business.service.box.BoxCommonService; -import com.accompany.business.service.broad.BroadRecordService; -import com.accompany.business.service.dfa.DfaService; import com.accompany.business.service.follow.FansRoomService; import com.accompany.business.service.live.LiveAttestationService; import com.accompany.business.service.miniGame.MiniGameService; import com.accompany.business.service.netease.YidunCheckUtil; import com.accompany.business.service.redenvelope.RedEnvelopeService; -import com.accompany.business.service.room.BlindDateRoundService; import com.accompany.business.service.room.CrossRoomPkRoundService; import com.accompany.business.service.room.RoomCleanService; import com.accompany.business.service.room.RoomService; import com.accompany.business.service.user.UserBlackRecordService; -import com.accompany.business.util.MD5; import com.accompany.business.util.ReplaceDomainUtil; import com.accompany.business.vo.KTVListRoomVo; import com.accompany.business.vo.RoomVo; @@ -35,6 +31,7 @@ import com.accompany.common.status.BusiStatus; import com.accompany.core.exception.ServiceException; import com.accompany.core.model.Room; import com.accompany.core.service.SysConfService; +import com.accompany.core.util.MD5; import com.accompany.core.util.StringUtils; import com.google.common.util.concurrent.RateLimiter; import io.swagger.annotations.Api; @@ -68,8 +65,6 @@ public class RoomController extends BaseController{ @Autowired private RoomCleanService roomCleanService; @Autowired - private DfaService dfaService; - @Autowired private BoxCommonService boxCommonService; @Autowired private RedEnvelopeService redEnvelopeService; @@ -77,10 +72,6 @@ public class RoomController extends BaseController{ private SysConfService sysConfService; @Autowired private FansRoomService fansRoomService; - @Autowired - private BlindDateRoundService blindDateRoundService; - @Autowired - private BroadRecordService broadRecordService; @Autowired private MiniGameService miniGameService; diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/sign/SignController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/sign/SignController.java index 2d4b0431f..7908cfb8d 100644 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/sign/SignController.java +++ b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/sign/SignController.java @@ -1,8 +1,6 @@ package com.accompany.business.controller.sign; -import com.accompany.business.config.WebPropertyConfig; import com.accompany.business.model.DrawGoldRecord; -import com.accompany.business.service.AppPictureService; import com.accompany.business.service.signweb.SignDrawGoldService; import com.accompany.business.service.signweb.SignGoldService; import com.accompany.business.service.user.UsersService; @@ -30,11 +28,7 @@ public class SignController { @Autowired SignDrawGoldService signDrawGoldService; @Autowired - private AppPictureService appPictureService; - @Autowired private UsersService usersService; - @Autowired - private WebPropertyConfig webPropertyConfig; /** @@ -176,7 +170,7 @@ public class SignController { * @param shareType :分享类型:1普通,2领取礼物,3瓜分金币 * @return */ - @RequestMapping(value = "/getShareImage",method = RequestMethod.GET) + /*@RequestMapping(value = "/getShareImage",method = RequestMethod.GET) @Authorization public BusiResult getShareImage(Long uid,String day,String reward,Integer shareType,String app){ if(uid == null || shareType == null){ @@ -188,7 +182,7 @@ public class SignController { } return new BusiResult(appPictureService.getSignShareImage(users.getErbanNo(),users.getAvatar(),users.getNick(), day,reward,shareType,app,webPropertyConfig.getQiNiuUnInterceptAccessUrl(),webPropertyConfig.getQiNiuUnInterceptBucket())); - } + }*/ /** diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/statis/StatBasicUsersController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/statis/StatBasicUsersController.java deleted file mode 100644 index b37fcec5c..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/statis/StatBasicUsersController.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.accompany.business.controller.statis; - -import com.accompany.business.service.statis.StatBasicUsersService; -import com.accompany.business.service.statis.StatUserStandTimeService; -import com.accompany.common.annotation.Authorization; -import com.accompany.common.result.BusiResult; -import com.accompany.common.status.BusiStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -@Deprecated -@RequestMapping("/basicusers") -@RestController -public class StatBasicUsersController { - - private static final Logger logger = LoggerFactory.getLogger(StatBasicUsersController.class); - - @Autowired - private StatBasicUsersService statBasicUsersService; - - @Autowired - private StatUserStandTimeService statUserStandTimeService; - - /** - * 用于统计用户在房间时长,已废弃,仅作旧版本兼容,所以没有直接移除 - * @param uid - * @param roomUid - * @param channel - * @param ispType - * @param model - * @param netType - * @param os - * @param osVersion - * @return - */ - @Authorization - @RequestMapping(value = "/record", method = RequestMethod.POST) - public BusiResult setBasicUser(Long uid, Long roomUid, String channel, String ispType, String model, String netType, String os, String osVersion) { - - return new BusiResult(BusiStatus.SUCCESS); - } - -} - diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/world/WorldController.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/world/WorldController.java index 0b51aa046..b69388761 100644 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/world/WorldController.java +++ b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/controller/world/WorldController.java @@ -9,7 +9,6 @@ import com.accompany.business.service.world.WorldService; import com.accompany.core.util.StringUtils; import com.accompany.business.vo.BannerVo; import com.accompany.core.vo.UserVo; -import com.accompany.business.config.WebPropertyConfig; import com.accompany.world.bo.WorldBo; import com.accompany.world.common.WorldException; import com.accompany.world.constant.WorldConstant; @@ -53,8 +52,6 @@ public class WorldController { private WorldService worldService; @Autowired private BannerService bannerService; - @Autowired - private WebPropertyConfig webPropertyConfig; /** * 话题首页 @@ -351,21 +348,6 @@ public class WorldController { return busiResult; } - /** - * 获取分享图片 - * @param worldId - * @param uid - * @return - */ - @Authorization - @ResponseBody - @RequestMapping(value = "/get/share/picture", method = RequestMethod.POST) - public BusiResult getSharePicture(Long worldId, Long uid,String app) { - logger.info("world getSharePicture worldId:{},uid:{}", worldId, uid); - return new BusiResult(BusiStatus.SUCCESS,worldService.getShareImgUrl(worldId,uid,app, - webPropertyConfig.getQiNiuUnInterceptAccessUrl(),webPropertyConfig.getQiNiuUnInterceptBucket())); - } - /** * 重建话题最热标签缓存 * @param key diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/filter/CustomHttpServletRequestWrapper.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/filter/CustomHttpServletRequestWrapper.java deleted file mode 100644 index 991bcc3b9..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/filter/CustomHttpServletRequestWrapper.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.accompany.business.filter; - -import lombok.extern.slf4j.Slf4j; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; -import java.util.Vector; - -/** - * 修改或者添加参数 - * - * @Author: fangchengyan - * @CreateDate: 2019-04-20 11:56 - * @Version: 1.0 - */ -@Slf4j -public class CustomHttpServletRequestWrapper extends HttpServletRequestWrapper { - - private Map params; - - public CustomHttpServletRequestWrapper(HttpServletRequest request) { - super(request); - this.params = new HashMap<>(request.getParameterMap()); - } - - @Override - public Map getParameterMap() { - return params; - } - - @Override - public Enumeration getParameterNames() { - return new Vector(params.keySet()).elements(); - } - - @Override - public String[] getParameterValues(String name) { - String[] result; - Object v = params.get(name); - if (v == null) { - result = null; - } else if (v instanceof String[]) { - result = (String[]) v; - } else if (v instanceof String) { - result = new String[]{(String) v}; - } else { - result = new String[]{v.toString()}; - } - return result; - } - -} \ No newline at end of file diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/filter/CustomParamFilter.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/filter/CustomParamFilter.java deleted file mode 100644 index 5c4321ac3..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/filter/CustomParamFilter.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.accompany.business.filter; - -import javax.servlet.*; -import javax.servlet.http.HttpServletRequest; -import java.io.IOException; - -/** - * {这里添加描述} - * - * @author fangchengyan - * @date 2020-01-16 6:42 下午 - */ -public class CustomParamFilter implements Filter { - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - - } - - @Override - public void doFilter(ServletRequest servletRequest, ServletResponse response, FilterChain chain) - throws IOException, ServletException { - //对请求进行拦截,防xss处理 - HttpServletRequest request = (HttpServletRequest) servletRequest; - chain.doFilter(new CustomHttpServletRequestWrapper(request), response); - } - - @Override - public void destroy() { - - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/interceptor/SecurityInterceptor.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/interceptor/SecurityInterceptor.java index 5a63c2544..f451ad693 100644 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/interceptor/SecurityInterceptor.java +++ b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/interceptor/SecurityInterceptor.java @@ -3,9 +3,9 @@ package com.accompany.business.interceptor; import com.accompany.common.constant.ApplicationConstant; import com.accompany.common.redis.RedisKey; import com.accompany.common.utils.IPUitls; -import com.accompany.common.wx.MD5; import com.accompany.core.service.common.JedisService; import com.accompany.core.util.KeyStore; +import com.accompany.core.util.MD5; import com.accompany.core.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -99,7 +99,7 @@ public class SecurityInterceptor extends BasicInterceptor { } builder.append("&key=").append(KeyStore.DES_ENCRYPT_KEY_SMS_PARAMS); - String serverSign = MD5.MD5Encode(builder.toString()); + String serverSign = MD5.getMD5(builder.toString()); Matcher matcher = pattern.matcher(serverSign); serverSign = matcher.replaceAll(""); diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/BatchTransferExample.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/BatchTransferExample.java deleted file mode 100644 index 598205b07..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/BatchTransferExample.java +++ /dev/null @@ -1,302 +0,0 @@ -/* * - * Ping++ Server SDK - * 说明: - * 以下代码只是为了方便商户测试而提供的样例代码,商户可根据自己网站需求按照技术文档编写, 并非一定要使用该代码。 - * 接入企业付款流程参考开发者中心:https://www.pingxx.com/docs/server/transfer ,文档可筛选后端语言和接入渠道。 - * 该代码仅供学习和研究 Ping++ SDK 使用,仅供参考。 -*/ -package com.accompany.business.pingplusplus; - -import com.pingplusplus.exception.*; -import com.pingplusplus.model.BatchTransfer; -import com.pingplusplus.model.BatchTransferCollection; - -import java.text.SimpleDateFormat; -import java.util.*; - -/** - * - * 该实例演示如何使用 Ping++ 进行批量转账。 - * - * 开发者需要填写 apiKey 和 appId , - * - * apiKey 有 TestKey 和 LiveKey 两种。 - * - * TestKey 模式下不会产生真实的交易。 - ** - */ -public class BatchTransferExample { - - private String appId; - - public static void runDemos(String appId) { - - BatchTransferExample batchTransferExample = new BatchTransferExample(appId); - System.out.println("------- 创建 BatchTransfer -------"); - BatchTransfer batchTransfer = batchTransferExample.create(); - System.out.println("------- 查询 BatchTransfer -------"); - batchTransferExample.retrieve(batchTransfer.getId()); - System.out.println("------- 查询 BatchTransfer 列表 -------"); - batchTransferExample.list(); - - } - - BatchTransferExample(String appId) { - this.appId = appId; - } - - /** - * 创建批量转账 - * - * 创建企业转账需要传递一个 map 给 BatchTransfer.create(); - * map 填写的具体介绍可以参考:https://www.pingxx.com/api - * - * @return - */ - public BatchTransfer create() { - String channel = "alipay"; - - BatchTransfer obj = null; - String batchNo = new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + Main.randomString(7); - Map params = new HashMap(); - params.put("app", appId); - params.put("channel", channel); // 目前支持 alipay、 unionpay、wx_pub、allinpay、jdpay - params.put("batch_no", batchNo); // 企业转账使用的商户内部订单号。 - params.put("amount", 5000); // 订单总金额, 人民币单位:分(如订单总金额为 1 元,此处请填 100) - params.put("type", "b2c"); // 付款类型,wx_pub 仅支持 b2c,alipay、 unionpay、allinpay、jdpay 支持 b2b - params.put("currency", "cny"); - params.put("description", "your description"); - List> recipients = new ArrayList>(); - - recipients.add(channelRecipient(channel)); - // recipients.add(channelRecipient(channel)); - // recipients.add(channelRecipient(channel)); - - params.put("recipients", recipients); - - - try { - obj = BatchTransfer.create(params); - System.out.println(obj); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } - return obj; - } - - /** - * 根据 ID 查询 - * - * 根据 ID 查询批量转账记录。 - * 参考文档:https://www.pingxx.com/api - * @param id - */ - public void retrieve(String id) { - try { - BatchTransfer obj = BatchTransfer.retrieve(id); - System.out.println(obj); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } - } - - /** - * 查询列表 - * - * 查询批量转账记录列表,默认一次查询 10 条,用户可以使用 per_page 自定义查询数目,但是最多不超过 20 条。 - */ - public void list() { - Map param = new HashMap(); - param.put("per_page", 3); - param.put("app", appId); - - try { - BatchTransferCollection objs = BatchTransfer.list(param); - System.out.println(objs); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } - } - - private Map channelRecipient(String channel) { - Map recipient = new HashMap(); - - switch (channel) { - case "alipay": - recipient = alipayRecipient(); - break; - case "wx_pub": - recipient = wxPubRecipient(); - break; - case "unionpay": - recipient = unionpayRecipient(); - break; - case "allinpay": - recipient = allinpayRecipient(); - break; - case "jdpay": - recipient = jdpayRecipient(); - break; - } - - return recipient; - } - - private Map alipayRecipient() { - Map extra = new HashMap<>(); - - // 必须,金额,单位为分。 - extra.put("amount", 5000); - - // 必须,接收者支付宝账号。 - extra.put("account", "alipayaccount@gmail.com"); - - // 必须,收款人姓名,1~50位。 - extra.put("name", "张三"); - - // 可选,收款方账户类型。可取值:1、 ALIPAY_USERID :支付宝账号对应的支付宝唯一用户号。以2088开头的16位纯数字组成。 2、 ALIPAY_LOGONID (默认值):支付宝登录号,支持邮箱和手机号格式。 - // extra.put("account_type", "ALIPAY_LOGONID"); - - // 可选,批量企业付款描述,最多 200 字节。 - // extra.put("description", "描述"); - - // 可选,订单号,1 ~ 64 位不能重复的数字字母组合。 - // extra.put("order_no", "1234567890123456"); - - return extra; - } - - private Map wxPubRecipient() { - Map extra = new HashMap<>(); - // 必须,金额,单位为分。 - extra.put("amount", 5000); - - // 必须,接收者 id,为用户在 wx_pub 下的 open_id。 - extra.put("open_id", "o7xEMsySBFG3MVHI-9VsAJX-j50W"); - - // 可选,收款人姓名。当该参数为空,则不校验收款人姓名。 - // extra.put("name", "张三"); - - // 可选,是否强制校验收款人姓名。仅当 user_name 参数不为空时该参数生效。 - // extra.put("force_check", true); - - // 可选,批量企业付款描述,最多 99 个英文和数字的组合或最多 33 个中文字符,不可以包含特殊字符。不填默认使用外层参数中的 description。 - // extra.put("description", "描述"); - - // 可选,订单号,1 ~ 32 位不能重复的数字字母组合。 - // extra.put("order_no", "1234567890123456"); - - return extra; - } - - private Map unionpayRecipient() { - Map extra = new HashMap<>(); - // 必须,金额,单位为分。 - extra.put("amount", 5000); - - // 必须,1~32位,收款人银行卡号或者存折号。 - extra.put("account", "6228480402564890011"); - - // 必须,1~100位,收款人姓名。 - extra.put("name", "张三"); - - /** - * open_bank_code 和 open_bank 两个参数必传一个,建议使用 open_bank_code ,若都传参则优先使用 open_bank_code 读取规则;prov 和 city 均为可选参数,如果不传参,则使用默认值 "上海" 给渠道接口。 - */ - // 条件可选,4位,开户银行编号,详情请参考 企业付款(银行卡)银行编号说明:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E。 - extra.put("open_bank_code", "0103"); - - // 条件可选,1~50位,开户银行,详情请参考 企业付款(银行卡)银行编号说明:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E。 - extra.put("open_bank", "农业银行"); - - // 可选,订单号,1 ~ 16 位数字。 - // extra.put("order_no", "1234567890123456"); - - // 可选,批量企业付款描述,最多 200 字节。 - // extra.put("description", "描述"); - - return extra; - } - - private Map allinpayRecipient() { - Map extra = new HashMap<>(); - // 必须,金额,单位为分。 - extra.put("amount", 5000); - - // 必须,接收者银行卡账号。 - extra.put("account", "6228480402564890011"); - - // 必须,收款人姓名。 - extra.put("name", "张三"); - - // 必须,4位,开户银行编号,详情请参考 企业付款(银行卡)银行编号说明:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E。 - extra.put("open_bank_code", "0103"); - - // 可选,5位,业务代码,根据通联业务人员提供,不填使用通联提供默认值09900。 - // extra.put("business_code", "09900"); - - // 可选,1位,银行卡号类型,0:银行卡、1:存折,不填默认使用银行卡。 - // extra.put("card_type", 0); - - // 可选,批量付款描述,最多 30 个 Unicode 字符。 - // extra.put("description", "描述"); - - // 可选,订单号, 20 ~ 40 位不能重复的数字字母组合(必须以通联的商户号开头,建议组合格式:通联商户号 + 时间戳 + 固定位数顺序流水号,不包含+号),这里不传的话程序会调用商户的通联商户号加上随机数自动生成 order_no。 - // extra.put("order_no", "331301234554321098765432112"); - - return extra; - } - - private Map jdpayRecipient() { - Map extra = new HashMap<>(); - // 必须,金额,单位为分。 - extra.put("amount", 5000); - - // 必须,1~32位,收款人银行卡号或者存折号。 - extra.put("account", "6228480402564890011"); - - // 必须,1~100位,收款人姓名。 - extra.put("name", "张三"); - - // 必须,4位,开户银行编号,详情请参考 企业付款(银行卡)银行编号说明:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E。 - extra.put("open_bank_code", "0103"); - - // 可选,批量付款描述,最多 100 个 Unicode 字符。 - // extra.put("description", "描述"); - - // 可选,订单号,jdpay 限长 1~64 位不能重复的数字字母组合。 - // extra.put("order_no", "1234567890123456"); - - return extra; - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/ChargeExample.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/ChargeExample.java deleted file mode 100644 index d6bd2b8b9..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/ChargeExample.java +++ /dev/null @@ -1,567 +0,0 @@ -/** - * Ping++ Server SDK - * 说明: - * 以下代码只是为了方便商户测试而提供的样例代码,商户可根据自己网站需求按照技术文档编写, 并非一定要使用该代码。 - * 接入支付流程参考开发者中心:https://www.pingxx.com/docs/server/charge ,文档可筛选后端语言和接入渠道。 - * 该代码仅供学习和研究 Ping++ SDK 使用,仅供参考。 - */ -package com.accompany.business.pingplusplus; - -import com.pingplusplus.exception.*; -import com.pingplusplus.model.Charge; -import com.pingplusplus.model.ChargeCollection; - -import java.util.*; - -/** - * Charge 对象相关示例 - * - * 该实例程序演示了如何从 Ping++ 服务器获得 charge ,查询 charge。 - * - * 开发者需要填写 apiKey 和 appId , - * - * apiKey 有 TestKey 和 LiveKey 两种。 - * - * TestKey 模式下不会产生真实的交易。 - */ -public class ChargeExample { - - private String appId; - - ChargeExample(String appId) { - this.appId = appId; - } - - public static void runDemos(String appId) { - - ChargeExample chargeExample = new ChargeExample(appId); - System.out.println("------- 创建 charge -------"); - Charge charge = chargeExample.createCharge(); - System.out.println("------- 查询 charge -------"); - chargeExample.retrieve(charge.getId()); - System.out.println("------- 查询 charge 列表 -------"); - chargeExample.list(); - System.out.println("------- 撤销 charge(仅支持线下渠道) -------"); - chargeExample.reverse(charge.getId()); - } - - /** - * 创建 Charge - * - * 创建 Charge 用户需要组装一个 map 对象作为参数传递给 Charge.create(); - * map 里面参数的具体说明请参考:https://www.pingxx.com/api#api-c-new - * @return Charge - */ - public Charge createCharge() { - Charge charge = null; - String channel = "alipay"; - - Map chargeMap = new HashMap(); - chargeMap.put("amount", 100);//订单总金额, 人民币单位:分(如订单总金额为 1 元,此处请填 100) - chargeMap.put("currency", "cny"); - chargeMap.put("subject", "Your Subject"); - chargeMap.put("body", "Your Body"); - String orderNo = System.currentTimeMillis() + Main.randomString(7); - chargeMap.put("order_no", orderNo);// 推荐使用 8-20 位,要求数字或字母,不允许其他字符 - chargeMap.put("channel", channel);// 支付使用的第三方支付渠道取值,请参考:https://www.pingxx.com/api#api-c-new - chargeMap.put("client_ip", "127.0.0.1"); // 发起支付请求客户端的 IP 地址,格式为 IPV4,如: 127.0.0.1 - Map app = new HashMap(); - app.put("id", appId); - chargeMap.put("app", app); - - // extra 取值请查看相应方法说明 - chargeMap.put("extra", channelExtra(channel)); - - try { - //发起交易请求 - charge = Charge.create(chargeMap); - // 传到客户端请先转成字符串 .toString(), 调该方法,会自动转成正确的 JSON 字符串 - String chargeString = charge.toString(); - System.out.println(chargeString); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } - return charge; - } - - /** - * 查询 Charge - * - * 该接口根据 charge Id 查询对应的 charge 。 - * 参考文档:https://www.pingxx.com/api#api-c-inquiry - * - * 参考文档: https://www.pingxx.com/api#api-expanding - * @param id - */ - public Charge retrieve(String id) { - Charge charge = null; - try { - Map params = new HashMap(); - charge = Charge.retrieve(id, params); - System.out.println(charge); - } catch (PingppException e) { - e.printStackTrace(); - } - - return charge; - } - - /** - * 撤销 Charge - * - * @param id - */ - public Charge reverse(String id) { - Charge charge = null; - try { - charge = Charge.reverse(id); - System.out.println(charge); - } catch (PingppException e) { - e.printStackTrace(); - } - - return charge; - } - - /** - * 分页查询 Charge - * - * 该接口为批量查询接口,默认一次查询10条。 - * 用户可以通过添加 limit 参数自行设置查询数目,最多一次不能超过 100 条。 - * - * 该接口同样可以使用 expand 参数。 - * @return chargeCollection - */ - public ChargeCollection list() { - ChargeCollection chargeCollection = null; - Map params = new HashMap(); - params.put("limit", 3); - Map app = new HashMap(); - app.put("id", appId); - params.put("app", app); // app 参数为必填参数。 - - try { - chargeCollection = Charge.list(params); - System.out.println(chargeCollection); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } - - return chargeCollection; - } - - private Map channelExtra(String channel) { - Map extra = new HashMap<>(); - - switch (channel) { - case "alipay": - extra = alipayExtra(); - break; - case "alipay_wap": - extra = alipayWapExtra(); - break; - case "alipay_pc_direct": - extra = alipayPcDirectExtra(); - break; - case "alipay_qr": - extra = alipayQrExtra(); - break; - case "com/accompany/common/wx": - extra = wxExtra(); - break; - case "wx_pub": - extra = wxPubExtra(); - break; - case "wx_pub_qr": - extra = wxPubQrDirectExtra(); - break; - case "wx_lite": - extra = wxLiteExtra(); - break; - case "wx_wap": - extra = wxWapExtra(); - break; - case "bfb": - extra = bfbExtra(); - break; - case "bfb_wap": - extra = bfbWapExtra(); - break; - case "upacp": - extra = upacpExtra(); - break; - case "upacp_wap": - extra = upacpWapExtra(); - break; - case "upacp_pc": - extra = upacpPcExtra(); - break; - case "jdpay_wap": - extra = jdpayWapExtra(); - break; - case "yeepay_wap": - extra = yeepayWapExtra(); - break; - case "applepay_upacp": - extra = applepayUpacpExtra(); - break; - case "qpay": - extra = qpayExtra(); - break; - case "cmb_wallet": - extra = cmbWalletExtra(); - break; - case "cp_b2b": - extra = cpB2bExtra(); - break; - case "isv_scan": - extra = isvScanExtra(); - break; - case "isv_qr": - extra = isvQrExtra(); - break; - case "isv_wap": - extra = isvWapExtra(); - break; - } - - return extra; - } - - // extra 根据渠道会有不同的参数 - - private Map alipayExtra() { - Map extra = new HashMap<>(); - - // 可选,开放平台返回的包含账户信息的 token(授权令牌,商户在一定时间内对支付宝某些服务的访问权限)。通过授权登录后获取的 alipay_open_id ,作为该参数的 value ,登录授权账户即会为支付账户,32 位字符串。 - // extra.put("extern_token", "TOKEN"); - - // 可选,是否发起实名校验,T 代表发起实名校验;F 代表不发起实名校验。 - extra.put("rn_check", "T"); - - return extra; - } - - private Map alipayWapExtra() { - Map extra = new HashMap<>(); - - // 必须,支付成功的回调地址,在本地测试不要写 localhost ,请写 127.0.0.1。URL 后面不要加自定义参数。 - extra.put("success_url", "https://example.com/success"); - // 可选,支付取消的回调地址, app_pay 为true时,该字段无效,在本地测试不要写 localhost ,请写 127.0.0.1。URL 后面不要加自定义参数。 - extra.put("cancel_url", "https://example.com/cancel"); - - // 可选,2016 年 6 月 16 日之前登录 Ping++ 管理平台填写支付宝手机网站的渠道参数的旧接口商户,需要更新接口时设置此参数值为true,6月16号后接入的新接口商户不需要设置该参数。 - // extra.put("new_version", true); - - // 可选,是否使用支付宝客户端支付,该参数为true时,调用客户端支付。 - // extra.put("app_pay", true); - - return extra; - } - - private Map alipayPcDirectExtra() { - Map extra = new HashMap<>(); - // 必须,支付成功的回调地址,在本地测试不要写 localhost ,请写 127.0.0.1。URL 后面不要加自定义参数。 - extra.put("success_url", "https://example.com/success"); - - // 可选,是否开启防钓鱼网站的验证参数(如果已申请开通防钓鱼时间戳验证,则此字段必填)。 - // extra.put("enable_anti_phishing_key", false); - - // 可选,客户端 IP ,用户在创建交易时,该用户当前所使用机器的IP(如果商户申请后台开通防钓鱼IP地址检查选项,此字段必填,校验用)。 - // extra.put("exter_invoke_ip", "192.168.100.8"); - - return extra; - } - - private Map alipayQrExtra() { - Map extra = new HashMap<>(); - - return extra; - } - - private Map wxExtra() { - Map extra = new HashMap<>(); - // 可选,指定支付方式,指定不能使用信用卡支付可设置为 no_credit 。 - extra.put("limit_pay", "no_credit"); - - // 可选,商品标记,代金券或立减优惠功能的参数。 - // extra.put("goods_tag", "YOUR_GOODS_TAG"); - - return extra; - } - - private Map wxPubExtra() { - Map extra = new HashMap<>(); - // 可选,指定支付方式,指定不能使用信用卡支付可设置为 no_credit 。 - extra.put("limit_pay", "no_credit"); - - // 可选,商品标记,代金券或立减优惠功能的参数。 - // extra.put("goods_tag", "YOUR_GOODS_TAG"); - - // 必须,用户在商户 appid 下的唯一标识。 - extra.put("open_id", "o7xEMsySBFG3MVHI-9VsAJX-j50W"); - - return extra; - } - - private Map wxPubQrDirectExtra() { - Map extra = new HashMap<>(); - // 可选,指定支付方式,指定不能使用信用卡支付可设置为 no_credit 。 - extra.put("limit_pay", "no_credit"); - - // 可选,商品标记,代金券或立减优惠功能的参数。 - // extra.put("goods_tag", "YOUR_GOODS_TAG"); - - // 必须,商品 ID,1-32 位字符串。此 id 为二维码中包含的商品 ID,商户可自定义。 - extra.put("product_id", "YOUR_PRODUCT_ID"); - - return extra; - } - - private Map wxLiteExtra() { - Map extra = new HashMap<>(); - // 可选,指定支付方式,指定不能使用信用卡支付可设置为 no_credit 。 - extra.put("limit_pay", "no_credit"); - - // 可选,商品标记,代金券或立减优惠功能的参数。 - // extra.put("goods_tag", "YOUR_GOODS_TAG"); - - // 必须,用户在商户 appid 下的唯一标识。 - extra.put("open_id", "o7xEMsySBFG3MVHI-9VsAJX-j50W"); - - return extra; - } - - private Map wxWapExtra() { - Map extra = new HashMap<>(); - // 可选,支付完成的回调地址。 - extra.put("result_url", "https://example.com/success"); - - // 可选,商品标记,代金券或立减优惠功能的参数。 - // extra.put("goods_tag", "YOUR_GOODS_TAG"); - - return extra; - } - - private Map bfbExtra() { - Map extra = new HashMap<>(); - - return extra; - } - - private Map bfbWapExtra() { - Map extra = new HashMap<>(); - // 必须,支付完成的回调地址,在本地测试不要写 localhost ,请写 127.0.0.1。URL 后面不要加自定义参数。 - extra.put("result_url", "https://example.com/success"); - - // 必须,是否需要登录百度钱包来进行支付。 - extra.put("bfb_login", true); - - return extra; - } - - private Map upacpExtra() { - Map extra = new HashMap<>(); - - return extra; - } - - private Map upacpWapExtra() { - Map extra = new HashMap<>(); - // 必须,支付完成的回调地址,在本地测试不要写 localhost ,请写 127.0.0.1。URL 后面不要加自定义参数。 - extra.put("result_url", "https://example.com/success"); - - return extra; - } - - private Map upacpPcExtra() { - Map extra = new HashMap<>(); - // 必须,支付完成的回调地址,在本地测试不要写 localhost ,请写 127.0.0.1。URL 后面不要加自定义参数。 - extra.put("result_url", "https://example.com/success"); - - return extra; - } - - private Map jdpayWapExtra() { - Map extra = new HashMap<>(); - // 必须,支付完成的回调地址。 - extra.put("success_url", "https://example.com/success"); - - // 必须,支付失败页面跳转路径。 - extra.put("fail_url", "https://example.com/fail"); - - // 可选,用户交易令牌,用于识别用户信息,支付成功后会调用 success_url 返回给商户。商户可以记录这个 token 值,当用户再次支付的时候传入该 token ,用户无需再次输入银行卡信息,直接输入短信验证码进行支付。32 位字符串。 - // extra.put("token", "TOKEN"); - - // 可选,订单类型,值为0表示实物商品订单,值为 1 代表虚拟商品订单,该参数默认值为 0 。 - // extra.put("order_type", 0); - - // 可选,设置是否通过手机端发起支付,值为 true 时调用手机 h5 支付页面,值为 false 时调用 PC 端支付页面,该参数默认值为 true 。 - extra.put("is_mobile", true); - - // 可选,用户账号类型,取值只能为:BIZ。传参存在问题请参考 帮助中心:https://help.pingxx.com/article/1012535/。 - // extra.put("user_type", "BIZ"); - - // 可选,商户的用户账号。传参存在问题请参考 帮助中心:https://help.pingxx.com/article/1012535/。 - // extra.put("user_id", "YOUR_USER_ID"); - - return extra; - } - - private Map yeepayWapExtra() { - Map extra = new HashMap<>(); - // 必须,商品类别码,商品类别码参考链接 :https://www.pingxx.com/api#%E6%98%93%E5%AE%9D%E6%94%AF%E4%BB%98%E5%95%86%E5%93%81%E7%B1%BB%E5%9E%8B%E7%A0%81 。 - extra.put("product_category", "1"); - - // 必须,用户标识,商户生成的用户账号唯一标识,最长 50 位字符串。 - extra.put("identity_id", "IDENTITY_ID"); - - // 必须,用户标识类型,用户标识类型参考链接:https://www.pingxx.com/api#%E6%98%93%E5%AE%9D%E6%94%AF%E4%BB%98%E7%94%A8%E6%88%B7%E6%A0%87%E8%AF%86%E7%B1%BB%E5%9E%8B%E7%A0%81 。 - extra.put("identity_type", 2); - - // 必须,终端类型,对应取值 0:IMEI, 1:MAC, 2:UUID, 3:other。 - extra.put("terminal_type", 2); - - // 必须,终端 ID。 - extra.put("terminal_id", "TERMINAL_ID"); - - // 必须,用户使用的移动终端的 UserAgent 信息。 - extra.put("user_ua", "USER_UA"); - - // 必须,前台通知地址。 - extra.put("result_url", "https://example.com/result"); - - return extra; - } - - private Map applepayUpacpExtra() { - Map extra = new HashMap<>(); - - return extra; - } - - private Map qpayExtra() { - Map extra = new HashMap<>(); - // 必须,客户端设备类型,取值范围: "iospay" ,"android"。 - extra.put("device", "iospay"); - - return extra; - } - - private Map cmbWalletExtra() { - Map extra = new HashMap<>(); - // 必须,交易完成跳转的地址。 - extra.put("result_url", "https://example.com/result"); - - /** - * 对于 p_no, seq , m_uid , mobile 这几个参数: - * 1. 这几个参数是用户自定义的。 - * 2. 对于同一个终端用户每次请求 charge 务必使用同一套参数(确保每个参数都不变), - * 任意参数变更都会导致用户重新签约,同一个用户和招行重新签约的次数有限制,超限制就会无法签约 ,导致用户无法使用。 - */ - - // 必须,客户协议号,不超过 30 位的纯数字字符串。 - extra.put("p_no", "201700100001"); - - // 必须,协议开通请求流水号,不超过 20 位的纯数字字符串,请保证系统内唯一。 - extra.put("seq", "201700200001"); - - // 必须,协议用户 ID,不超过 20 位的纯数字字符串。 - extra.put("m_uid", "201700300001"); - - // 必须,协议手机号,11 位数字。 - extra.put("mobile", "13523456789"); - - return extra; - } - - private Map cpB2bExtra() { - Map extra = new HashMap<>(); - - return extra; - } - - private Map isvScanExtra() { - Map extra = new HashMap<>(); - // 必须,终端号,1~8 位英文或数字,要求不同终端此号码不一样,会显示在对账单中。 - extra.put("terminal_id", "A0000007"); - - // 必须,客户端软件中展示的条码值,扫码设备扫描获取。1~32 位字符串。 - extra.put("scan_code", "280614577834623988"); - - // 可选,商品列表,上送格式参照下面示例。序列化后总字符串长度不超过 8000。 - List goodsList = goodsListForIsv(); - extra.put("goods_list", goodsList); - - return extra; - } - - private Map isvQrExtra() { - Map extra = new HashMap<>(); - // 必须,终端号,1~8 位英文或数字,要求不同终端此号码不一样,会显示在对账单中。 - extra.put("terminal_id", "A0000007"); - - // 必须,具体支付渠道,目前支持:alipay、com.accompany.common.wx、bfb。 - extra.put("pay_channel", "alipay"); - - // 可选,商品列表,上送格式参照下面示例。序列化后总字符串长度不超过 8000。 - List goodsList = goodsListForIsv(); - extra.put("goods_list", goodsList); - - return extra; - } - - private Map isvWapExtra() { - Map extra = new HashMap<>(); - // 必须,终端号,1~8 位英文或数字,要求不同终端此号码不一样,会显示在对账单中。 - extra.put("terminal_id", "A0000007"); - - // 必须,具体支付渠道,目前支持:alipay、com.accompany.common.wx、bfb。 - extra.put("pay_channel", "com/accompany/common/wx"); - - // 必须,前台通知地址,支付成功或失败后,跳转到的 URL。 - extra.put("result_url", "https://www.example.com/payment-result"); - - // 可选,商品列表,上送格式参照下面示例。 - List goodsList = goodsListForIsv(); - extra.put("goods_list", goodsList); - - return extra; - } - - private List goodsListForIsv() { - List goodsList = new ArrayList<>(); - Map goods = new HashMap<>(); - goods.put("goods_id", "iphone6s16G"); // 商户定义商品编号(一般为商品条码)。 - goods.put("unified_goods_id", "1001"); // 统一商品编号,可选。 - goods.put("goods_name", "iPhone 6s 16G"); // 商品名称。 - goods.put("goods_num", 1); // 商品数量。 - goods.put("price", 528800); // 商品价格,单位为分。 - goods.put("goods_category", "smartphone"); // 商品类目,可选。 - goods.put("body", "苹果手机 iPhone 6s 16G"); // 商品描述信息,可选。 - goods.put("show_url", "https://www.example.com"); // 商品的展示网址,可选。 - goodsList.add(goods); - - return goodsList; - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/CustomsExample.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/CustomsExample.java deleted file mode 100644 index 146fb41d9..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/CustomsExample.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Ping++ Server SDK - * 说明: - * 以下代码只是为了方便商户测试而提供的样例代码,商户可根据自己网站需求按照技术文档编写, 并非一定要使用该代码。 - * 接入支付流程参考开发者中心:https://www.pingxx.com/docs/server/charge ,文档可筛选后端语言和接入渠道。 - * 该代码仅供学习和研究 Ping++ SDK 使用,仅供参考。 - */ -package com.accompany.business.pingplusplus; - -import com.pingplusplus.exception.*; -import com.pingplusplus.model.Customs; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * Customs 对象相关示例 - * - * 该实例程序演示了如何从 Ping++ 服务器创建 customs ,查询 customs。 - * - * 开发者需要填写 apiKey 和 appId , - * - * apiKey 有 TestKey 和 LiveKey 两种。 - * - * 报关(customs)仅支持 Live 模式。 - */ -public class CustomsExample { - - private String appId; - - CustomsExample(String appId) { - this.appId = appId; - } - - public static void runDemos(String appId) { - CustomsExample example = new CustomsExample(appId); - System.out.println("------- 报关 customs 仅支持 live 模式 -------"); - -// System.out.println("------- 创建 customs -------"); -// Customs obj = example.createCustoms(); -// System.out.println("------- 查询 customs -------"); -// example.retrieve(obj.getId()); - } - - /** - * 创建 Customs - * - * 创建 Customs 用户需要组装一个 map 对象作为参数传递给 Customs.create(); - * map 里面参数的具体说明请参考:https://www.pingxx.com/api - * @return Charge - */ - public Customs createCustoms() { - Customs obj = null; - Map params = new HashMap(); - params.put("channel", "alipay"); - String orderNo = System.currentTimeMillis() + Main.randomString(7); - params.put("trade_no", orderNo); // 8-20 位,要求数字或字母,不允许其他字符 - params.put("customs_code", "SHANGHAI"); // https://www.pingxx.com/api#海关编号说明 - params.put("amount", 10000); // 报关金额, 人民币单位:分(如金额为 100 元,此处请填 10000) - params.put("charge", ""); - params.put("app", appId); - Map extra = new HashMap(); - // 根据不同渠道传不同参数 - // extra.put("pay_account", ""); - // extra.put("certif_type", "01"); // https://www.pingxx.com/api#报关接口 - // extra.put("customer_name", ""); - // extra.put("certif_id", ""); - params.put("extra", extra); - - try { - //发起交易请求 - obj = Customs.create(params); - System.out.println(obj); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } - return obj; - } - - /** - * 查询 Customs - * - * 参考文档:https://www.pingxx.com/api - * - * @param id - */ - public Customs retrieve(String id) { - Customs obj = null; - try { - obj = Customs.retrieve(id); - System.out.println(obj); - } catch (PingppException e) { - e.printStackTrace(); - } - - return obj; - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/EventExample.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/EventExample.java deleted file mode 100644 index 88b00f103..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/EventExample.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.accompany.business.pingplusplus; - -import com.pingplusplus.exception.*; -import com.pingplusplus.model.Event; - - -/** - * - * Event 事件参考文档:https://www.pingxx.com/api#api-event - * - * 该实例演示如何查询 Event - * - * apiKey 有 TestKey 和 LiveKey 两种。 - * - * TestKey 模式下不会产生真实的交易。 - * - */ -public class EventExample { - - public static void runDemos() { - EventExample eventExample = new EventExample(); - System.out.println("------- 查询 event -------"); - - String eventId = "evt_vTmGHwcHc842hWLRWNS4bwFM"; - eventExample.retrieve(eventId); - } - - /** - * 根据 ID 查询 Evnet - * - * 传递 Event 的 Id 查询 Event。 - * 参考文档:https://www.pingxx.com/api#api-event-inquiry - * @param id - */ - public void retrieve(String id) { - try { - Event event = Event.retrieve(id); - System.out.println(event); - - // 解析 webhooks 可以采用如下方法 -// Object obj = Webhooks.getObject(event.toString()); -// if (obj instanceof Charge) { -// System.out.println("webhooks 发送了 Charge"); -// } else if (obj instanceof Refund) { -// System.out.println("webhooks 发送了 Refund"); -// } else if (obj instanceof Summary) { -// System.out.println("webhooks 发送了 Summary"); -// } - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } - - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/IdentificationExample.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/IdentificationExample.java deleted file mode 100644 index 6b7d54a88..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/IdentificationExample.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.accompany.business.pingplusplus; - -import com.pingplusplus.exception.*; -import com.pingplusplus.model.Identification; - -import java.util.HashMap; -import java.util.Map; - -/** - * - * 身份证银行卡信息认证接口参考文档:https://www.pingxx.com/api#身份证银行卡信息认证接口 - * - * 该实例演示如何调用身份证银行卡信息认证接口 - * - */ -public class IdentificationExample { - - private String appId; - - IdentificationExample(String appId) { - this.appId = appId; - } - - public static void runDemos(String appId) { - IdentificationExample eventExample = new IdentificationExample(appId); - System.out.println("------- 认证身份证信息 -------"); - eventExample.identifyIdCard(); - - System.out.println("------- 认证银行卡信息 -------"); - eventExample.identifyBankCard(); - } - - /** - * 认证身份证信息 - * - * 参考文档:https://www.pingxx.com/api#请求认证接口 - */ - public void identifyIdCard() { - try { - Map params = new HashMap(); - params.put("app", appId); - params.put("type", "id_card"); // 身份证信息或者银行卡信息串,取值范围: "id_card"(身份证信息串);"bank_card"(银行卡信息串)。 - Map data = new HashMap(); - data.put("id_name", "张三"); - data.put("id_number", "320291198811110000"); - params.put("data", data); - Identification result = Identification.identify(params); - if (result.getResultCode() == 0) { - System.out.println("身份认证通过"); - } else { - System.out.println(result.getResultCode()); - System.out.println(result.getMessage()); - } - System.out.println(result); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } - } - - /** - * 认证银行卡信息 - * - * 参考文档:https://www.pingxx.com/api#请求认证接口 - */ - public void identifyBankCard() { - try { - Map params = new HashMap(); - params.put("app", appId); - params.put("type", "bank_card"); // 身份证信息或者银行卡信息串,取值范围: "id_card"(身份证信息串);"bank_card"(银行卡信息串)。 - Map data = new HashMap(); - data.put("id_name", "张三"); - data.put("id_number", "320291198811110000"); - data.put("card_number", "6201111122223333"); - params.put("data", data); - Identification result = Identification.identify(params); - if (result.getResultCode() == 0) { - System.out.println("银行卡信息认证通过"); - } else { - System.out.println(result.getResultCode()); - System.out.println(result.getMessage()); - } - System.out.println(result); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/Main.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/Main.java deleted file mode 100644 index 875dcaa58..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/Main.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.accompany.business.pingplusplus; - -import com.pingplusplus.Pingpp; - -import java.math.BigInteger; -import java.security.SecureRandom; - -/** - * Created by Afon on 16/4/26. - */ -public class Main { - - /** - * Pingpp 管理平台对应的 API Key,api_key 获取方式:登录 [Dashboard](https://dashboard.pingxx.com)->点击管理平台右上角公司名称->开发信息-> Secret Key - */ - private final static String apiKey = "sk_test_ibbTe5jLGCi5rzfH4OqPW9KC"; - - /** - * Pingpp 管理平台对应的应用 ID,app_id 获取方式:登录 [Dashboard](https://dashboard.pingxx.com)->点击你创建的应用->应用首页->应用 ID(App ID) - */ - private final static String appId = "app_1Gqj58ynP0mHeX1q"; - - /** - * 设置请求签名密钥,密钥对需要你自己用 openssl 工具生成,如何生成可以参考帮助中心:https://help.pingxx.com/article/123161; - * 生成密钥后,需要在代码中设置请求签名的私钥(rsa_private_key.pem); - * 然后登录 [Dashboard](https://dashboard.pingxx.com)->点击右上角公司名称->开发信息->商户公钥(用于商户身份验证) - * 将你的公钥复制粘贴进去并且保存->先启用 Test 模式进行测试->测试通过后启用 Live 模式 - */ - - // 你生成的私钥路径 - private final static String privateKeyFilePath = "res/your_rsa_private_key_pkcs8.pem"; - - public static void main(String[] args) throws Exception { - - // 设置 API Key - Pingpp.apiKey = apiKey; - - // 设置私钥路径,用于请求签名 - Pingpp.privateKeyPath = privateKeyFilePath; - - /** - * 或者直接设置私钥内容 - Pingpp.privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" + - "... 私钥内容字符串 ...\n" + - "-----END RSA PRIVATE KEY-----\n"; - */ - Pingpp.privateKey = "-----BEGIN PRIVATE KEY-----\n" + - "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHYyS3FwoESp1h\n" + - "GLYiBhy6k9Ag3lzGCIEvm50IIEkE0Ftc9qq44TWqyl+EHUpTMdcBOcI42JLO5stw\n" + - "FOfCLa3PQStEJ4llIRFEKlsrHh67pvWd5RNaSBrvGlnFY40S+SZmjk2WF/h9dE9R\n" + - "ic79t0YI0alD8dIl9Yu3OaEKo7VonBWFwOYMxjPhtORlq+EUF1XJd//yftQrKWTT\n" + - "d7KaUonWzBCl4VzFop/OyTWYlTuZz3eYJaNpH5VaQ1vDgBAcPIeBvMf7NgBHMKW6\n" + - "LLmFd2LEYQ/6I7hkGTjysSzWEpO8bPWT6OEsJ2R2kFGOrSkr+G2MDcJ7ykXYAmz5\n" + - "+A3plS6ZAgMBAAECggEAVrgwR9GlcahiOtDcpn+yDxQq+aC9CQS561LrQZWJLKbS\n" + - "leRS7IZHKTlLwdJbeUO8F7RfXQoVEBghc2YkRrhHWFUn1ES95VY0hElHzcET7Nn5\n" + - "CeuQNzwVOtljIg7iVNY4dXJ/HEDguu/Tb8tYU9FajItj60FJ/WiGk/JksJPzWsOC\n" + - "VPVniy9fTbTLy1e+dCpCI6OXirtm7hvbodRNDjree0wSEzm7vL0wVzEZFo6kX+AB\n" + - "GUwaoO7pPyH+hgyI5Iuhc65NHsHzTJpf8yNFl9QGhkxvm2Ff2oEtDt1idOTBrHB6\n" + - "tg+ti9Ctb2+2yzBnk14hsSYJnKitR7wM6ZCFPX4eYQKBgQD+JAREeFkodec/SC+G\n" + - "X+4Q4Y68uMPkfUPrMKXM4cyY5wgXk64RBvRVxIxX7x6Y3tIKn9v8tWAprbsyVr15\n" + - "eb4RcAFEVwjuoZixhd9sIPsRhfdNolKn/fSPIsHL4ywcJMSIt7KVKHuQeqBNHy0o\n" + - "0PxQjNej1ozsmrAWqV55cbKHswKBgQDI2JQRTPIEC/2y6LdmBVhGJW9OKWTYdVNj\n" + - "q7rX+Yw4uxOtfd5hBqpvgZEklKEk72aazFdEcERlAm9SqoX09qk6zK/wcq4Xn5Q/\n" + - "qy8ecmjuyf2AK9X+HUdMerMVxhK9RpeevKYP/RO2F/wIN64anlQVYygVkXXgdOvW\n" + - "hBE4YABKgwKBgDRtmbPGYB5ItHwJmERQZfx1i8zDESaB8RED6DBsJJkmkDTM8ovw\n" + - "s1c+RPWfDuDalto6QFfR0xTGEmhAHLaCtwNB6AEBM4aHL8jvpTfZVfI3gN0zL3oY\n" + - "mestcG1vYBouO504yE6dG2Ci6479b4OMGYFEjPfvuwLUpp8GMcc7/WihAoGANCp8\n" + - "mtm/ammq5VMof2kX+nAyrrx1ovsmQ5cRGpOIZhvBCqjMn6rZjci7aCLqj+tWXRKC\n" + - "ABagzROK0o/T50JBxjHv6KYArcYW/Up7HI9ezdbM7wNzu2LjZ+veo+MkbuDs9J/P\n" + - "CgwTmJI2NfQwVl2VPVDZ0nBLi5cSwk7fIiNdL/0CgYEAtECmC1QDs53Di2MIsa/F\n" + - "e4sWfJGSDqEWqhcA/aPwf1skM6VJJXBBMV1qFtwgO1AlLnu9dQYra6ylsUoubVYI\n" + - "XM9XK7EMhbqi57+Q75jHFTc0DnzOTyho5Gp4Ddi8dztmZGNWdWTGdeMqh+svqMXk\n" + - "D6VdJeddyGu/Zlgj7Wk6whU=\n" + - "-----END PRIVATE KEY-----\n"; - - - // Charge 示例 - ChargeExample.runDemos(appId); - - // Refund 示例 - RefundExample.runDemos(); - - // RedEnvelope 示例 - RedEnvelopeExample.runDemos(appId); - - // Transfer 示例 - TransferExample.runDemos(appId); - - // Event 示例 - EventExample.runDemos(); - - // Webhooks 验证示例 - WebhooksVerifyExample.runDemos(); - - // 微信公众号 openid 相关示例 - WxPubOAuthExample.runDemos(appId); - - // 身份证银行卡信息认证接口 - // 请使用 live key 调用该接口 - // IdentificationExample.runDemos(appId); - - // 批量付款示例 - BatchTransferExample.runDemos(appId); - - // 报关 - // 请使用 live key 调用该接口 - CustomsExample.runDemos(appId); - } - - private static SecureRandom random = new SecureRandom(); - - public static String randomString(int length) { - String str = new BigInteger(130, random).toString(32); - return str.substring(0, length); - } - - public static int currentTimeSeconds() { - return (int)(System.currentTimeMillis() / 1000); - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/RedEnvelopeExample.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/RedEnvelopeExample.java deleted file mode 100644 index 15a53dc06..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/RedEnvelopeExample.java +++ /dev/null @@ -1,153 +0,0 @@ -/* * - * Ping++ Server SDK - * 说明: - * 以下代码只是为了方便商户测试而提供的样例代码,商户可根据自己网站需求按照技术文档编写, 并非一定要使用该代码。 - * 接入红包流程参考开发者中心:https://www.pingxx.com/docs/server/red-envelope ,文档可筛选后端语言和接入渠道。 - * 该代码仅供学习和研究 Ping++ SDK 使用,仅供参考。 -*/ -package com.accompany.business.pingplusplus; - -import com.pingplusplus.exception.*; -import com.pingplusplus.model.RedEnvelope; -import com.pingplusplus.model.RedEnvelopeCollection; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * - * 该实例演示如何操作微信红包 - * - * 开发者需要填写 apiKey 、appId 和 openid , - * - * apiKey 有 TestKey 和 LiveKey 两种。 - * - * TestKey 模式下不会产生真实的交易。 - * - * openid 是发送红包的对象在公共平台下的 openid ,获得 openid 的方法可以参考微信文档:http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html - * - */ -public class RedEnvelopeExample { - - private String appId; - /** - * 微信用户在微信公共号的 openid - */ - public static String openid = "USER_OPENID";// 用户在商户微信公众号下的唯一标识,获取方式可参考 WxPubOAuthExample.java - - RedEnvelopeExample(String appId) { - this.appId = appId; - } - - public static void runDemos(String appId) { - - RedEnvelopeExample redEnvelopeExample = new RedEnvelopeExample(appId); - System.out.println("------- 创建 RedEnvelope -------"); - RedEnvelope redEnvelope = redEnvelopeExample.create(); - System.out.println("------- 查询 RedEnvelope -------"); - redEnvelopeExample.retrieve(redEnvelope.getId()); - System.out.println("------- 查询 RedEnvelope 列表 -------"); - redEnvelopeExample.list(); - } - - /** - * 创建红包 - * - * 创建红包需要传递一个 map 到 RedEnvelope.create(redenvelope) - * map 里面的具体参数参考:https://www.pingxx.com/api#api-e-new - * @return - */ - public RedEnvelope create() { - Map redenvelope = new HashMap(); - redenvelope.put("amount", 100);// 订单总金额, 人民币单位:分(如订单总金额为 1 元,此处请填 100,金额限制在 100 ~ 20000 之间,即 1 ~ 200 元) - redenvelope.put("currency", "cny"); - redenvelope.put("subject", "Your Subject"); - redenvelope.put("body", "Your Body"); - String orderNo = new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()); - redenvelope.put("order_no", orderNo);// 红包使用的商户订单号。wx_pub 规定为 1 ~ 28 位不能重复的数字 - redenvelope.put("channel", "wx_pub");// 目前支持 wx_pub - redenvelope.put("recipient", openid);// 接收者 id, 为用户在 wx_pub 下的 open_id - redenvelope.put("description", "Your Description"); - Map app = new HashMap(); - app.put("id", appId); - redenvelope.put("app", app); - Map extra = new HashMap(); - extra.put("send_name", "Send Name");// 商户名称,最多 32 个字节 - redenvelope.put("extra", extra); - RedEnvelope red = null; - try { - red = RedEnvelope.create(redenvelope); - System.out.println(red); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } - return red; - - } - - /** - * 查询红包 - * - * 根据红包的 ID 查询红包。 - * 参考文档:https://www.pingxx.com/api#api-e-inquiry - * @param id - */ - public void retrieve(String id) { - try { - RedEnvelope redEnvelope = RedEnvelope.retrieve(id); - System.out.println(redEnvelope); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } - } - - /** - * 批量查询红包 - * - * 批量查询接口,默认一次查询 10 条。用户可以通过 limit 自定义查询数目,最多不超过 100 条。 - */ - public void list() { - RedEnvelopeCollection redEnvelopeCollection = null; - Map chargeParams = new HashMap(); - chargeParams.put("limit", 3); - try { - redEnvelopeCollection = RedEnvelope.list(chargeParams); - System.out.println(redEnvelopeCollection); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } - - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/RefundExample.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/RefundExample.java deleted file mode 100644 index d6f1be923..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/RefundExample.java +++ /dev/null @@ -1,148 +0,0 @@ -/* * - * Ping++ Server SDK - * 说明: - * 以下代码只是为了方便商户测试而提供的样例代码,商户可根据自己网站需求按照技术文档编写, 并非一定要使用该代码。 - * 接入退款流程参考开发者中心:https://www.pingxx.com/docs/server/refund ,文档可筛选后端语言和接入渠道。 - * 该代码仅供学习和研究 Ping++ SDK 使用,仅供参考。 - */ -package com.accompany.business.pingplusplus; - -import com.pingplusplus.exception.*; -import com.pingplusplus.model.ChargeRefundCollection; -import com.pingplusplus.model.Refund; - -import java.util.HashMap; -import java.util.Map; - -/** - * 退款相关示例 - * - * 该实例程序演示了如何从 Ping++ 服务器进行退款操作。 - * - * 开发者需要填写 apiKey 和 chargeId , - * - * apiKey 有 TestKey 和 LiveKey 两种。 - * - * TestKey 模式下不会产生真实的交易。 - */ -public class RefundExample { - - private String charge; - - RefundExample(String chargeId) { - this.charge = chargeId; - } - - public static void runDemos() { - - String chargeId = "ch_5CWrz5rnz9GS84arXHLiPOqL"; - - RefundExample refundExample = new RefundExample(chargeId); -// System.out.println("------- 创建 refund -------"); -// Refund refund = refundExample.refund(1); -// System.out.println("------- 查询 refund -------"); -// refundExample.retrieve(refund.getId()); - System.out.println("------- 查询 refund 列表 -------"); - refundExample.all(); - } - - /** - * 退款 - * - * 创建退款,需要先获得 charge ,然后调用 charge.getRefunds().create(); - * 参数具体说明参考:https://www.pingxx.com/api#api-r-new - * - * 可以一次退款,也可以分批退款。 - * - * @param amount - * @return - */ - public Refund refund(Integer amount) { - if (charge == null) { - return null; - } - Refund refund = null; - Map params = new HashMap(); - params.put("description", "苹果被咬了一口。"); - params.put("amount", amount);// 退款的金额, 单位为对应币种的最小货币单位,例如:人民币为分(如退款金额为 1 元,此处请填 100)。必须小于等于可退款金额,默认为全额退款 - - try { - refund = Refund.create(this.charge, params); - System.out.println(refund); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } - return refund; - } - - /** - * 查询退款 - * - * 根据 Id 查询退款记录。需要传递 charge。 - * 参考文档:https://www.pingxx.com/api#api-r-inquiry - * - * @param id - */ - public void retrieve(String id) { - if (charge == null) { - return; - } - try { - Refund refund = Refund.retrieve(this.charge, id); - System.out.println(refund); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } - } - - /** - * 分页查询退款 - * - * 批量查询退款。默认一次 10 条,用户可以通过 limit 自定义查询数目,但是最多不超过 100 条。 - * 参考文档:https://www.pingxx.com/api#api-r-list - * - */ - public void all() { - if (charge == null) { - return; - } - Map refundParams = new HashMap(); - refundParams.put("limit", 3); - try { - ChargeRefundCollection refunds = Refund.list(this.charge, refundParams); - System.out.println(refunds); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/TransferExample.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/TransferExample.java deleted file mode 100644 index 2bafedfbc..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/TransferExample.java +++ /dev/null @@ -1,309 +0,0 @@ -/* * - * Ping++ Server SDK - * 说明: - * 以下代码只是为了方便商户测试而提供的样例代码,商户可根据自己网站需求按照技术文档编写, 并非一定要使用该代码。 - * 接入企业付款流程参考开发者中心:https://www.pingxx.com/docs/server/transfer ,文档可筛选后端语言和接入渠道。 - * 该代码仅供学习和研究 Ping++ SDK 使用,仅供参考。 -*/ -package com.accompany.business.pingplusplus; - -import com.pingplusplus.exception.*; -import com.pingplusplus.model.Transfer; -import com.pingplusplus.model.TransferCollection; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * - * 该实例演示如何使用 Ping++ 进行企业转账。 - * - * 开发者需要填写 apiKey ,openid 和 appId , - * - * apiKey 有 TestKey 和 LiveKey 两种。 - * - * TestKey 模式下不会产生真实的交易。 - * - * openid 是发送红包的对象在公共平台下的 openid ,获得 openid 的方法可以参考微信文档:http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html - * - */ -public class TransferExample { - - private String appId; - - /** - * 接收者的 openid - */ - public static String openid = "USER_OPENID"; // 用户在商户微信公众号下的唯一标识,获取方式可参考 WxPubOAuthExample.java - - public static void runDemos(String appId) { - - TransferExample transferExample = new TransferExample(appId); - System.out.println("------- 创建 Transfer -------"); - Transfer transfer = transferExample.create(); - System.out.println("------- 查询 Transfer -------"); - transferExample.retrieve(transfer.getId()); - System.out.println("------- 查询 Transfer 列表 -------"); - transferExample.list(); - - } - - TransferExample(String appId) { - this.appId = appId; - } - - /** - * 创建企业转账 - * - * 创建企业转账需要传递一个 map 给 Transfer.create(); - * map 填写的具体介绍可以参考:https://www.pingxx.com/api#api-t-new - * - * @return - */ - public Transfer create() { - Transfer transfer = null; - String channel = "alipay"; - - String orderNo = new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()); - Map transferMap = new HashMap(); - transferMap.put("channel", channel); // 目前支持 支付宝:alipay,银联:unionpay,微信公众号:wx_pub,通联:allinpay,京东:jdpay - - // 付款使用的商户内部订单号。 - // wx_pub 规定为 1 ~ 50 位不能重复的数字字母组合; - // alipay 为 1 ~ 64 位不能重复的数字字母组合; - // unionpay 为 1 ~ 16 位的纯数字; - // jdpay 限长 1 ~ 64 位不能重复的数字字母组合; - // allinpay 限长 20 ~ 40 位不能重复的数字字母组合,必须以签约的通联的商户号开头(建议组合格式:通联商户号 + 时间戳 + 固定位数顺序流水号,不包含+号) - - if (channel == "allinpay") { - orderNo += System.currentTimeMillis(); - } - - transferMap.put("order_no", orderNo); - transferMap.put("amount", 200); // 付款金额,相关渠道的限额,请查看 https://help.pingxx.com/article/133366/ 。单位为对应币种的最小货币单位,例如:人民币为分。 - transferMap.put("type", "b2c"); // 付款类型,转账到个人用户为 b2c,转账到企业用户为 b2b(微信公众号 wx_pub 的企业付款,仅支持 b2c)。 - transferMap.put("currency", "cny"); - transferMap.put("recipient", channelRecipient(channel)); // 接收者 - - // 备注信息。 - // 渠道为 unionpay 时,最多 99 个 Unicode 字符; - // 渠道为 wx_pub 时,最多 99 个英文和数字的组合或最多 33 个中文字符,不可以包含特殊字符; - // 渠道为 alipay 时,最多 100 个 Unicode 字符。 - // 渠道为 jdpay 最多100个 Unicode 字符。 - // 渠道为 allinpay 最多30个 Unicode 字符 - transferMap.put("description", "your description"); - - transferMap.put("extra", channelExtra(channel)); - - Map app = new HashMap(); - app.put("id", appId); - transferMap.put("app", app); - - try { - transfer = Transfer.create(transferMap); - System.out.println(transfer); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } - return transfer; - } - - /** - * 根据 ID 查询 - * - * 根据 ID 查询企业转账记录。 - * 参考文档:https://www.pingxx.com/api#api-t-inquiry - * @param id - */ - public void retrieve(String id) { - Map param = new HashMap(); - try { - Transfer transfer = Transfer.retrieve(id, param); - System.out.println(transfer); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } - - } - - /** - * 批量查询 - * - * 批量查询企业转账记录,默认一次查询 10 条,用户可以使用 limit 自定义查询数目,但是最多不超过 100 条。 - */ - public void list() { - Map param = new HashMap(); - param.put("limit", 3); - param.put("app[id]", appId); - - try { - TransferCollection transferCollection = Transfer.list(param); - System.out.println(transferCollection); - } catch (AuthenticationException e) { - e.printStackTrace(); - } catch (InvalidRequestException e) { - e.printStackTrace(); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIException e) { - e.printStackTrace(); - } catch (ChannelException e) { - e.printStackTrace(); - } catch (RateLimitException e) { - e.printStackTrace(); - } - } - - private String channelRecipient(String channel) { - String recipient = null; - - switch (channel) { - case "wx_pub": - // 渠道为 wx_pub 时,需要传 recipient 为用户在商户 appid 下的 open_id - recipient = "o7xEMsySBFG3MVHI-9VsAJX-j50W"; - break; - case "alipay": - // 渠道为 alipay 时,若 type 为 b2c,为个人支付宝账号,若 type 为 b2b,为企业支付宝账号。 - recipient = "alipayaccount@gmail.com"; - break; - case "unionpay": - case "allinpay": - case "jdpay": - break; - } - - return recipient; - } - - private Map channelExtra(String channel) { - Map extra = new HashMap<>(); - - switch (channel) { - case "alipay": - extra = alipayExtra(); - break; - case "wx_pub": - extra = wxPubExtra(); - break; - case "unionpay": - extra = unionpayExtra(); - break; - case "allinpay": - extra = allinpayExtra(); - break; - case "jdpay": - extra = jdpayExtra(); - break; - } - - return extra; - } - - private Map alipayExtra() { - Map extra = new HashMap<>(); - // 必须,收款人姓名,1~50位。 - extra.put("recipient_name", "张三"); - - // 可选,收款方账户类型。可取值:1、 ALIPAY_USERID :支付宝账号对应的支付宝唯一用户号。以2088开头的16位纯数字组成。 2、 ALIPAY_LOGONID (默认值):支付宝登录号,支持邮箱和手机号格式。 - // extra.put("recipient_account_type", "ALIPAY_LOGONID"); - - return extra; - } - - private Map wxPubExtra() { - Map extra = new HashMap<>(); - // 可选,收款人姓名。当该参数为空,则不校验收款人姓名。 - // extra.put("user_name", "张三"); - - // 可选,是否强制校验收款人姓名。仅当 user_name 参数不为空时该参数生效。 - // extra.put("force_check", true); - - return extra; - } - - private Map unionpayExtra() { - Map extra = new HashMap<>(); - // 必须,1~32位,收款人银行卡号或者存折号。 - extra.put("card_number", "6228480402564890011"); - - // 必须,1~100位,收款人姓名。 - extra.put("user_name", "张三"); - - /** - * open_bank_code 和 open_bank 两个参数必传一个,建议使用 open_bank_code ,若都传参则优先使用 open_bank_code 读取规则;prov 和 city 均为可选参数,如果不传参,则使用默认值 "上海" 给渠道接口。 - */ - - // 条件可选,4位,开户银行编号,详情请参考 企业付款(银行卡)银行编号说明:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E。 - extra.put("open_bank_code", "0103"); - - // 条件可选,1~50位,开户银行,详情请参考 企业付款(银行卡)银行编号说明:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E。 - extra.put("open_bank", "农业银行"); - - // 可选,1~20位,省份。 - // extra.put("prov", "上海"); - - // 可选,1~40位,城市。 - // extra.put("city", "上海"); - - // 可选,1~80位,开户支行名称。 - // extra.put("sub_bank", "上海陆家嘴支行"); - - return extra; - } - - private Map allinpayExtra() { - Map extra = new HashMap<>(); - // 必须,1~32位,收款人银行卡号或者存折号。 - extra.put("card_number", "6228480402564890011"); - - // 必须,1~100位,收款人姓名。 - extra.put("user_name", "张三"); - - // 必须,4位,开户银行编号,详情请参考 企业付款(银行卡)银行编号说明:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E。 - extra.put("open_bank_code", "0103"); - - // 可选,5位,业务代码,根据通联业务人员提供,不填使用通联提供默认值09900。 - // extra.put("business_code", "09900"); - - // 可选,1位,银行卡号类型,0:银行卡、1:存折,不填默认使用银行卡。 - // extra.put("card_type", 0); - - return extra; - } - - private Map jdpayExtra() { - Map extra = new HashMap<>(); - // 必须,1~32位,收款人银行卡号或者存折号。 - extra.put("card_number", "6228480402564890011"); - - // 必须,1~100位,收款人姓名。 - extra.put("user_name", "张三"); - - // 必须,4位,开户银行编号,详情请参考 企业付款(银行卡)银行编号说明:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E。 - extra.put("open_bank_code", "0103"); - - return extra; - } -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/WebhooksVerifyExample.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/WebhooksVerifyExample.java deleted file mode 100644 index 593905210..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/WebhooksVerifyExample.java +++ /dev/null @@ -1,128 +0,0 @@ -/* * - * Ping++ Server SDK - * 说明: - * 以下代码只是为了方便商户测试而提供的样例代码,商户可根据自己网站需求按照技术文档编写, 并非一定要使用该代码。 - * 接入 webhooks 流程参考开发者中心:https://www.pingxx.com/docs/webhooks/webhooks - * 该代码仅供学习和研究 Ping++ SDK 使用,仅供参考。 - */ -package com.accompany.business.pingplusplus; - -import org.apache.commons.codec.binary.Base64; - -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; -import java.security.*; -import java.security.spec.X509EncodedKeySpec; - -/** - * Created by sunkai on 15/5/19. webhooks 验证签名示例 - * - * 该实例演示如何对 Ping++ webhooks 通知进行验证。 - * 验证是为了让开发者确认该通知来自 Ping++ ,防止恶意伪造通知。用户如果有别的验证机制,可以不进行验证签名。 - * - * 验证签名需要 签名、公钥、验证信息,该实例采用文件存储方式进行演示。 - * 实际项目中,需要用户从异步通知的 HTTP header 中读取签名,从 HTTP body 中读取验证信息。公钥的存储方式也需要用户自行设定。 - * - * 该实例仅供演示如何验证签名,请务必不要直接 copy 到实际项目中使用。 - * - */ -public class WebhooksVerifyExample { - - private static String pubKeyPath = "res/pingpp_public_key.pem"; - private static String eventPath = "res/webhooks_raw_post_data.json"; - private static String signPath = "res/signature.txt"; - - /** - * 验证 webhooks 签名,仅供参考 - * @param args - * @throws Exception - */ - public static void main(String[] args) throws Exception { - runDemos(); - } -; - public static void runDemos() throws Exception { - String str="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzs8SiPoFQT9K0lWa6WSx0d6UnA391KM2aFwijY0AK7r+MiAe07ivenopzFL3dqIRhQjuP7d30V85kWydN5UZ\n" + - "cm/tZgm4K+8wttb988hOrzSjtPOMghHK+bnDwE8FIB+ZbHAZCEVhNfE6i9kLGbHH\n" + - "Q617+mxUTJ3yEZG9CIgke475o2Blxy4UMsRYjo2gl5aanzmOmoZcbiC/R5hXSQUH\n" + - "XV9/VzA7U//DIm8Xn7rerd1n8+KWCg4hrIIu/A0FKm8zyS4QwAwQO2wdzGB0h15t\n" + - "uFLhjVz1W5ZPXjmCRLzTUoAvH12C6YFStvS5kjPcA66P1nSKk5o3koSxOumOs0iC\n" + - "EQIDAQAB"; - System.out.println(str); - // 该数据请从 request 中获取原始 POST 请求数据, 以下仅作为示例 - String webhooksRawPostData = getStringFromFile(eventPath); - System.out.println("------- POST 原始数据 -------"); - System.out.println(webhooksRawPostData); - // 签名数据请从 request 的 header 中获取, key 为 X-Pingplusplus-Signature (请忽略大小写, 建议自己做格式化) - String signature = getStringFromFile(signPath); - System.out.println("------- 签名 -------"); - System.out.println(signature); - - boolean result = verifyData(webhooksRawPostData, signature, getPubKey()); - System.out.println("验签结果:" + (result ? "通过" : "失败")); - } - - /** - * 读取文件, 部署 web 程序的时候, 签名和验签内容需要从 request 中获得 - * @param filePath - * @return - * @throws Exception - */ - public static String getStringFromFile(String filePath) throws Exception { - FileInputStream in = new FileInputStream(filePath); - InputStreamReader inReader = new InputStreamReader(in, "UTF-8"); - BufferedReader bf = new BufferedReader(inReader); - StringBuilder sb = new StringBuilder(); - String line; - do { - line = bf.readLine(); - if (line != null) { - if (sb.length() != 0) { - sb.append("\n"); - } - sb.append(line); - } - } while (line != null); - - return sb.toString(); - } - - /** - * 获得公钥 - * @return - * @throws Exception - */ - public static PublicKey getPubKey() throws Exception { - String pubKeyString = getStringFromFile(pubKeyPath); - pubKeyString = pubKeyString.replaceAll("(-+BEGIN PUBLIC KEY-+\\r?\\n|-+END PUBLIC KEY-+\\r?\\n?)", ""); - byte[] keyBytes = Base64.decodeBase64(pubKeyString); - - // generate public key - X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes); - KeyFactory keyFactory = KeyFactory.getInstance("RSA"); - PublicKey publicKey = keyFactory.generatePublic(spec); - return publicKey; - } - - /** - * 验证签名 - * @param dataString - * @param signatureString - * @param publicKey - * @return - * @throws NoSuchAlgorithmException - * @throws InvalidKeyException - * @throws SignatureException - */ - public static boolean verifyData(String dataString, String signatureString, PublicKey publicKey) - throws NoSuchAlgorithmException, InvalidKeyException, SignatureException, UnsupportedEncodingException { - byte[] signatureBytes = Base64.decodeBase64(signatureString); - Signature signature = Signature.getInstance("SHA256withRSA"); - signature.initVerify(publicKey); - signature.update(dataString.getBytes("UTF-8")); - return signature.verify(signatureBytes); - } - -} diff --git a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/WxPubOAuthExample.java b/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/WxPubOAuthExample.java deleted file mode 100644 index 8e44b480f..000000000 --- a/accompany-business/accompany-business-web/src/main/java/com/accompany/business/pingplusplus/WxPubOAuthExample.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.accompany.business.pingplusplus; - -import com.pingplusplus.model.Charge; -import com.pingplusplus.util.WxpubOAuth; - -import java.io.UnsupportedEncodingException; - -/** - * 微信公共账号,付款签名示例 - * - * 开发者需要填写 apiKey 、appId 、url 和 openid 。 - * - * apiKey 有 TestKey 和 LiveKey 两种。 - * - * TestKey 模式下不会产生真实的交易。 - * - * openid 是发送红包的对象在公共平台下的 openid ,获得 openid 的方法可以参考微信文档:http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html - * - */ -public class WxPubOAuthExample { - - /** - * Ping++ 管理平台对应的应用 ID,app_id 获取方式:登录 [Dashboard](https://dashboard.pingxx.com)->点击你创建的应用->应用首页->应用 ID(App ID) - */ - private static String appId="app_KaPO844ej1G8T40a"; - - /** - * 微信公共号里面获取 openid 时的回跳 URL - */ - public static String redirectUrl = "http://www.daxiaomao.com/com.accompany.common.wx/config"; - /** - * 微信公共号的 appId,通常为 `com.accompany.common.wx` 开头的字符串 - */ - public static String wxAppId="wx009d793f92c24eec"; - /** - * 微信公共号的 secret - */ - public static String wxAppSecret ="d99ac5ed29071943d1654a40bb0adb68"; - - public static void runDemos(String appId) throws UnsupportedEncodingException { - WxPubOAuthExample.appId = appId; - System.out.println("------- 获取 openid -------"); - getOpenid(); - - System.out.println("------- 如果要是用微信的 jsapi 并且要启用签名, 请参考以下方法 -------"); - jsapiSignatureDemo(); - } - - public static void getOpenid() throws UnsupportedEncodingException { - System.out.println("1. 你需要有一个处理回跳的 URL"); - redirectUrl = "http://用于处理回跳的URL"; - - String url = WxpubOAuth.createOauthUrlForCode(wxAppId, redirectUrl, false); - System.out.println("2. 跳转到该 URL"); - System.out.println(url); - - getOpenidWithCode(); - } - - public static void getOpenidWithCode() throws UnsupportedEncodingException { - System.out.println("3. 微信内置浏览器会带上参数 code 跳转到你传的地址: " + redirectUrl + "?code=os823ndskelcncfyfms"); - // 获取 URL 中的 code 参数 - String code = "os823ndskelcncfyfms"; - String openid = WxpubOAuth.getOpenId(wxAppId, wxAppSecret, code); - System.out.println("4. 得到 openid 用于创建 charge"); -// ChargeExample chargeExample = new ChargeExample(appId); -// openid = "USER_OPENID"; -// chargeExample.createCharge(); - } - - public static void jsapiSignatureDemo() throws UnsupportedEncodingException { - // 获得 ticket - String ticket = WxpubOAuth.getJsapiTicket(wxAppId, wxAppSecret); - System.out.println("ticket " + ticket); - // 创建 Charge - ChargeExample chargeExample = new ChargeExample(appId); - Charge charge = chargeExample.createCharge(); // wx_pub - // 获得签名 - String signature = WxpubOAuth.getSignature(charge.toString(), ticket, redirectUrl); - System.out.println("------- JSAPI 签名 -------"); - System.out.println(signature); - } -} diff --git a/accompany-business/accompany-business-web/src/test/java/controllertest/ChargeNotifyControllerTest.java b/accompany-business/accompany-business-web/src/test/java/controllertest/ChargeNotifyControllerTest.java deleted file mode 100644 index 69b0f0860..000000000 --- a/accompany-business/accompany-business-web/src/test/java/controllertest/ChargeNotifyControllerTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package controllertest; - -import com.accompany.business.controller.apppay.ChargeNotifyController; -import com.alibaba.fastjson.JSONObject; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.mock.web.MockHttpServletRequest; -import servicetest.CommonTest; - -import javax.servlet.http.HttpServletRequest; - -public class ChargeNotifyControllerTest extends CommonTest { - - @Autowired - private ChargeNotifyController chargeNotifyController; - - @Test - public void alipayCallBackTest() { - String paramsStr = "{\"gmt_create\":\"2021-03-05 10:08:50\",\"charset\":\"UTF-8\",\"seller_email\":\"zhongjia168@qq.com\",\"subject\":\"10钻石充值\",\"sign\":\"BNoAKUqqW4v2nOhDs+34jTHzVckiGNf9MsX6qOOeA9QbnGsnFzev3btQe2ZSd88JGl+8WtAUSWZJy6mmT/BsOL4kpW9p4+HrTM0qgQHh0RwULYqjBFsrM8g/MB5eKKeIJWBJnt1o/+Z8+o0loQE0DcIF/H2oBZ9J9hUFxF1ZnWoVRQkaUmjYzIuBFDgqTWXww4uAZl9IkQPPdk42H+5xOnPgW6AFWR2MOKKLC1om9sEN+AtpWd/ZvcQYn53LJTFC2UDS/oKqmslSBO5A3DMxTu7TUnQ8T52/2VkJbppkI+ZbA5zGmHXf5lZz+bJUKOU7fCED7mMA2mjNnrmbYJNjKA==\",\"body\":\"10钻石充值\",\"buyer_id\":\"2088302096542384\",\"invoice_amount\":\"1.00\",\"notify_id\":\"2021030500222100851042381418200267\",\"fund_bill_list\":\"[{\\\"amount\\\":\\\"1.00\\\",\\\"fundChannel\\\":\\\"ALIPAYACCOUNT\\\"}]\",\"notify_type\":\"trade_status_sync\",\"trade_status\":\"TRADE_SUCCESS\",\"receipt_amount\":\"1.00\",\"app_id\":\"2021001156649197\",\"buyer_pay_amount\":\"1.00\",\"sign_type\":\"RSA2\",\"seller_id\":\"2088831215337254\",\"gmt_payment\":\"2021-03-05 10:08:50\",\"notify_time\":\"2021-03-05 10:08:51\",\"version\":\"1.0\",\"out_trade_no\":\"adb9e40915ab485f8324fd1fe4256665\",\"total_amount\":\"1.00\",\"trade_no\":\"2021030522001442381457408676\",\"auth_app_id\":\"2021001156649197\",\"buyer_logon_id\":\"wow***@163.com\",\"point_amount\":\"0.00\"}"; - - JSONObject paramJsonObj = JSONObject.parseObject(paramsStr); - MockHttpServletRequest request = new MockHttpServletRequest(); - - for (String key : paramJsonObj.keySet()) { - request.setParameter(key, paramJsonObj.getString(key)); - } - - try { - chargeNotifyController.AlipayCallBack(request); - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/accompany-business/accompany-business-web/src/test/java/servicetest/FufeitongPayServiceTest.java b/accompany-business/accompany-business-web/src/test/java/servicetest/FufeitongPayServiceTest.java deleted file mode 100644 index 416703b59..000000000 --- a/accompany-business/accompany-business-web/src/test/java/servicetest/FufeitongPayServiceTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package servicetest; - -import com.accompany.common.utils.RandomUtil; -import com.accompany.payment.fufeitong.FufeitongConstant; -import com.accompany.payment.fufeitong.FufeitongPayService; -import com.accompany.payment.fufeitong.params.FufeitongCreateOrderBaseReqParams; -import com.accompany.payment.fufeitong.params.FufeitongWxOrderReqParams; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import java.math.BigDecimal; - -public class FufeitongPayServiceTest extends CommonTest { - - @Autowired - private FufeitongPayService fufeitongPayService; - - @Test - public void createWxOpenOrderTest() { - FufeitongWxOrderReqParams params = new FufeitongWxOrderReqParams(); - params.setAmount(new BigDecimal("0.01")); - params.setCust1(FufeitongConstant.CUST1_MINIAPP); - params.setGoodsName("czx test"); - params.setTraceno(System.currentTimeMillis() + "" + RandomUtil.getFiveRandomNumber()); - params.setOpenId("oQFkO5KedQ683ZxT2uq5dv-RkUTw"); - - fufeitongPayService.createWxOpenOrder(params); - } - - @Test - public void createWapOrder() { - FufeitongCreateOrderBaseReqParams params = new FufeitongCreateOrderBaseReqParams(); - params.setAmount(new BigDecimal("0.01")); - params.setGoodsName("czx test"); - params.setTraceno(System.currentTimeMillis() + "" + RandomUtil.getFiveRandomNumber()); - params.setPayType(FufeitongConstant.PAY_TYPE_WX); - - fufeitongPayService.createWapOrder(params); - } - - @Test - public void createAlipayOrder() { - FufeitongCreateOrderBaseReqParams params = new FufeitongCreateOrderBaseReqParams(); - params.setAmount(new BigDecimal("0.01")); - params.setGoodsName("czx test"); - params.setTraceno(System.currentTimeMillis() + "" + RandomUtil.getFiveRandomNumber()); - - fufeitongPayService.createAlipayOrder(params); - } -} diff --git a/accompany-business/accompany-business-web/src/test/java/servicetest/GuotongPayServiceTest.java b/accompany-business/accompany-business-web/src/test/java/servicetest/GuotongPayServiceTest.java deleted file mode 100644 index 24ad056dd..000000000 --- a/accompany-business/accompany-business-web/src/test/java/servicetest/GuotongPayServiceTest.java +++ /dev/null @@ -1,84 +0,0 @@ -package servicetest; - -import com.accompany.business.BusinessApplication; -import com.accompany.common.utils.DateTimeUtil; -import com.accompany.common.utils.RandomUtil; -import com.accompany.core.util.DateUtil; -import com.accompany.payment.guotongpay.GuotongPayConstant; -import com.accompany.payment.guotongpay.GuotongPayService; -import com.accompany.payment.guotongpay.bo.GuotongPayResultBO; -import com.accompany.payment.guotongpay.bo.GuotongWxMiniPayResultBO; -import com.accompany.payment.guotongpay.params.GuoTongCreateOrderReqParams; -import com.accompany.payment.guotongpay.params.GuotongWxMiniPayReqParams; -import com.accompany.payment.vo.JsapiReturnVo; -import com.alibaba.fastjson.JSONObject; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.junit4.SpringRunner; - -import java.math.BigDecimal; -import java.util.Date; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringBootTest(classes = BusinessApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) -public class GuotongPayServiceTest { - - @Autowired - private GuotongPayService guotongPayService; - - @Test - public void createOrderTest() { - GuoTongCreateOrderReqParams params = new GuoTongCreateOrderReqParams(); - params.setPayMoney(new BigDecimal("0.01")); - params.setLowOrderId(DateTimeUtil.convertDate(new Date()) + RandomUtil.randomByRange(1, 10)); - params.setBody("czx test product"); - params.setPayType(GuotongPayConstant.PAY_TYPE_ZFB); - - GuotongPayResultBO order = guotongPayService.createOrder(params); - - System.out.println(JSONObject.toJSONString(order)); - } - - @Test - public void createWxMiniproOrderTest() { - GuotongWxMiniPayReqParams params = new GuotongWxMiniPayReqParams(); - params.setPayMoney(new BigDecimal("0.01")); - params.setLowOrderId(DateTimeUtil.convertDate(new Date()) + RandomUtil.randomByRange(1, 10)); - params.setBody("czx test product"); - params.setOpenId("o9j-S4p72wS11DpSavzELCYvH4hc"); - - GuotongWxMiniPayResultBO order = guotongPayService.createWxMiniproOrder(params); - - System.out.println(JSONObject.toJSONString(order)); - } - - @Test - public void createWxMiniproOrderTest_use_zhongjia() { - GuotongWxMiniPayReqParams params = new GuotongWxMiniPayReqParams(); - params.setPayMoney(new BigDecimal("0.01")); - params.setLowOrderId(DateTimeUtil.convertDate(new Date()) + RandomUtil.randomByRange(1, 10)); - params.setBody("czx test product"); - params.setOpenId("oAN585U_CyAx84T49TggIO0Gv6cQ"); - - GuotongWxMiniPayResultBO order = guotongPayService.createWxMiniproOrderForZjlx(params); - - System.out.println(JSONObject.toJSONString(order)); - } - - @Test - public void createWxPubOrderTest_use_zhongjia() { - GuotongWxMiniPayReqParams params = new GuotongWxMiniPayReqParams(); - params.setPayMoney(new BigDecimal("0.01")); - params.setLowOrderId(DateTimeUtil.convertDate(new Date()) + RandomUtil.randomByRange(1, 10)); - params.setBody("czx test product"); - params.setOpenId("oXBRywi2wSPwzB4Gzz23j4oqJy84"); - - JsapiReturnVo order = guotongPayService.createWxPubOrderForZjlx(params); - - System.out.println(JSONObject.toJSONString(order)); - } - -} diff --git a/accompany-business/accompany-business-web/src/test/java/servicetest/WXPub2ServiceTest.java b/accompany-business/accompany-business-web/src/test/java/servicetest/WXPub2ServiceTest.java deleted file mode 100644 index 43ad36086..000000000 --- a/accompany-business/accompany-business-web/src/test/java/servicetest/WXPub2ServiceTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package servicetest; - -import com.accompany.business.service.wx.WXPub2Service; -import com.accompany.business.vo.OpenIdInfoVo; -import com.alibaba.fastjson.JSONObject; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -public class WXPub2ServiceTest extends CommonTest { - - @Autowired - private WXPub2Service wxPub2Service; - - @Test - public void getOpenIdInfoTest() { - String code = "063cv9200VaKyN1j28400glNUu3cv92A"; - - OpenIdInfoVo openIdInfo = wxPub2Service.getOpenIdInfo(code); - - System.out.println(JSONObject.toJSONString(openIdInfo)); - } -} diff --git a/accompany-business/accompany-business-web/src/test/java/servicetest/WanXiangPayServiceTest.java b/accompany-business/accompany-business-web/src/test/java/servicetest/WanXiangPayServiceTest.java deleted file mode 100644 index 40d387e8c..000000000 --- a/accompany-business/accompany-business-web/src/test/java/servicetest/WanXiangPayServiceTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package servicetest; - -import com.accompany.payment.wanxiang.WanXiangPayService; -import com.accompany.payment.wanxiang.bo.WanXiangBaseRes; -import com.accompany.payment.wanxiang.params.WanXiangCreateOrderBaseReqParams; -import com.accompany.payment.wanxiang.params.WanXiangWxMiniproCreateOrderReqParams; -import com.alibaba.fastjson.JSONObject; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import java.math.BigDecimal; - -public class WanXiangPayServiceTest extends CommonTest { - - @Autowired - private WanXiangPayService wanXiangPayService; - - @Test - public void createAlipayH5OrderTest() throws InterruptedException { - Thread.sleep(10000); - WanXiangCreateOrderBaseReqParams params = new WanXiangCreateOrderBaseReqParams(); - params.setOrderNo("test"+System.currentTimeMillis()); - params.setSubject("测试商品"); - params.setAmount(new BigDecimal("0.01")); - params.setReturnUrl("http://www.baidu.com"); - params.setClientIp("127.0.0.1"); - - WanXiangBaseRes alipayH5Order = wanXiangPayService.createAlipayH5Order(params); - - System.out.println(JSONObject.toJSONString(alipayH5Order)); - } - - @Test - public void createWxMiniproOrderTest() throws InterruptedException { - Thread.sleep(10000); - WanXiangWxMiniproCreateOrderReqParams params = new WanXiangWxMiniproCreateOrderReqParams(); - params.setOrderNo("test"+System.currentTimeMillis()); - params.setSubject("测试商品"); - params.setAmount(new BigDecimal("0.01")); - params.setClientIp("127.0.0.1"); - params.setOpenId("oAN585cV2AyY9vfOMvb5DOWuuWKM"); - - WanXiangBaseRes alipayH5Order = wanXiangPayService.createWxMiniproOrder(params); - - System.out.println(JSONObject.toJSONString(alipayH5Order)); - } -} diff --git a/accompany-oauth2/accompany-oauth2-web/src/main/java/com/accompany/oauth2/interceptor/SecurityInterceptor.java b/accompany-oauth2/accompany-oauth2-web/src/main/java/com/accompany/oauth2/interceptor/SecurityInterceptor.java index 626774980..dcbde0855 100644 --- a/accompany-oauth2/accompany-oauth2-web/src/main/java/com/accompany/oauth2/interceptor/SecurityInterceptor.java +++ b/accompany-oauth2/accompany-oauth2-web/src/main/java/com/accompany/oauth2/interceptor/SecurityInterceptor.java @@ -6,7 +6,7 @@ import com.accompany.common.constant.ApplicationConstant; import com.accompany.common.redis.RedisKey; import com.accompany.common.utils.IPUitls; import com.accompany.common.utils.StringUtils; -import com.accompany.common.wx.MD5; +import com.accompany.core.util.MD5; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -98,7 +98,7 @@ public class SecurityInterceptor extends BasicInterceptor { } builder.append("&key=").append(KeyStore.DES_ENCRYPT_KEY_SMS_PARAMS); - String serverSign = MD5.MD5Encode(builder.toString()); + String serverSign = MD5.getMD5(builder.toString()); Matcher matcher = pattern.matcher(serverSign); serverSign = matcher.replaceAll(""); diff --git a/accompany-scheduler/accompany-scheduler-service/src/main/java/com/accompany/scheduler/task/AuditAudioRoomTask.java b/accompany-scheduler/accompany-scheduler-service/src/main/java/com/accompany/scheduler/task/AuditAudioRoomTask.java deleted file mode 100644 index 1e31781e9..000000000 --- a/accompany-scheduler/accompany-scheduler-service/src/main/java/com/accompany/scheduler/task/AuditAudioRoomTask.java +++ /dev/null @@ -1,183 +0,0 @@ -package com.accompany.scheduler.task; - -import com.accompany.business.model.AuditAudioRoom; -import com.accompany.core.model.Room; -import com.accompany.business.mybatismapper.AuditAudioRoomMapper; -import com.accompany.business.service.auditaudio.AuditAudioRoomService; -import com.accompany.business.service.room.RoomService; -import com.accompany.business.vo.RunningRoomVo; -import com.accompany.business.vo.auditaudio.AuditAudioBaseRetVo; -import com.accompany.business.vo.auditaudio.AuditAudioListRetVo; -import com.accompany.scheduler.base.BaseTask; -import com.accompany.common.constant.RoomMonitorTypeEnum; -import com.accompany.common.redis.RedisKey; -import com.accompany.common.utils.StringUtils; -import org.apache.commons.collections.CollectionUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.task.TaskExecutor; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.*; -import java.util.stream.Collectors; - -/** - * 2 * @Author: zhuct - * 3 * @Date: 2019/8/28 14:30 - * 4 - */ -//@Component -public class AuditAudioRoomTask extends BaseTask { - private static final Logger logger = LoggerFactory.getLogger(AuditAudioRoomTask.class); - @Autowired - private AuditAudioRoomService auditAudioRoomService; - @Autowired - private RoomService roomService; - @Autowired - private AuditAudioRoomMapper auditAudioRoomMapper; - - @Resource(name = "bizExecutor") - private TaskExecutor bizExecutor; - - /** - * 将需要监控的房间,向数美查询是否停止监控,若已经停止则重新发起请求 - */ - @Scheduled(cron = "0 */2 * * * ?") - public void checkRestartAuditAudioRoom() { - logger.info("checkRestartAuditAudioRoom start ================"); - Integer monitorType = auditAudioRoomService.getRoomMonitorType(); - if (monitorType == null) { - return; - } - if (monitorType == RoomMonitorTypeEnum.GIVEN_ROOM.getValue()) { - sendAuditRoom(this.getAllGivenRoom(), RoomMonitorTypeEnum.GIVEN_ROOM.getValue()); - - } else if (monitorType == RoomMonitorTypeEnum.ALL_ROOM.getValue()) { - sendAuditRoom(this.getAllOnlineRoom(), RoomMonitorTypeEnum.ALL_ROOM.getValue()); - } - - Map map = jedisService.hgetAll(RedisKey.audit_audio_room.getKey()); - if (map == null || map.size() == 0) { - return; - } - List requestIds = this.getAuditingRequestIds(); - for (String key : map.keySet()) { - Long roomUid = Long.valueOf(key); - AuditAudioRoom audioRoom = gson.fromJson(map.get(key), AuditAudioRoom.class); - String runningRoomStr = jedisService.hget(RedisKey.room_running.getKey(), roomUid.toString()); - RunningRoomVo runningRoomVo = gson.fromJson(runningRoomStr, RunningRoomVo.class); - //如果房间在线人数不为0,并且数美已经没有在监控,则重新发起监控请求 - if (runningRoomVo != null && runningRoomVo.getOnlineNum() != 0 && !requestIds.contains(audioRoom.getRequestId())) { - logger.info("need to restart audit room,roomUid={}", roomUid); - this.restartAuditAudioRoom(roomUid, audioRoom); - } - } - logger.info("checkRestartAuditAudioRoom end ================="); - } - - private void sendAuditRoom(List roomUids, Byte monitorType) { - for (String roomUid : roomUids) { - Boolean hexists = jedisService.hexists(RedisKey.audit_audio_room.getKey(), roomUid); - if (!hexists) {//如果需要送审的房间不在audit_audio_room缓存中,则送审 - logger.info("send audit room,roomUid={}", roomUid); - Room room = roomService.getRoomByUid(Long.valueOf(roomUid)); - auditAudioRoomService.sendAuditRoom(room, monitorType); - } - } - } - - /** - * 获取所有指定房间,在线并且有人房间列表 - * - * @return - */ - private List getAllGivenRoom() { - List roomUids = new ArrayList<>(); - Set smembers = jedisService.smembers(RedisKey.given_audit_audio_room.getKey()); - if (CollectionUtils.isNotEmpty(smembers)) { - smembers.forEach(smember -> { - String runningRoomStr = jedisService.hget(RedisKey.room_running.getKey(), smember); - if (StringUtils.isNotBlank(runningRoomStr)) { - RunningRoomVo runningRoomVo = gson.fromJson(runningRoomStr, RunningRoomVo.class); - if (runningRoomVo != null && runningRoomVo.getOnlineNum() != 0) { - roomUids.add(smember); - } - } - }); - } - return roomUids; - } - - /** - * 获取所有在线并且有人房间列表 - * - * @return - */ - private List getAllOnlineRoom() { - List roomUids = new ArrayList<>(); - Map map = jedisService.hgetAll(RedisKey.room_running.getKey()); - if (map != null && map.size() > 0) { - for (String key : map.keySet()) { - RunningRoomVo runningRoomVo = gson.fromJson(map.get(key), RunningRoomVo.class); - if (runningRoomVo != null && runningRoomVo.getOnlineNum() != 0) { - roomUids.add(key); - } - - } - } - return roomUids; - } - - /** - * 获取所有数美现在正在审核的requestId集合 - *

- * { - * "code": 1100, - * "message": "成功", - * "requestId": "b0fe038a9fa8195b129012af2dba619e", - * "detail": [ - * { - * "audioStarttime": "2019-08-28 16:33:17", - * "audioUrl": "", - * "requestId": "832b7fa23b8b3e424b58da8b6cb37f87" - * } - * ] - * } - * - * @return - */ - private List getAuditingRequestIds() { - List requestIds = new ArrayList<>(); - try { - AuditAudioListRetVo mediaRetVo = auditAudioRoomService.getAuditMedia(); - if (mediaRetVo.getCode() == 1100 && CollectionUtils.isNotEmpty(mediaRetVo.getDetail())) { - requestIds = mediaRetVo.getDetail().stream().map(item -> item.get("requestId").toString()).collect(Collectors.toList()); - } - } catch (Exception e) { - logger.error("getAuditingRequestIds error cause by:", e.getMessage()); - - } - return requestIds; - } - - private void restartAuditAudioRoom(Long roomUid, AuditAudioRoom audioRoom) { - bizExecutor.execute(() -> { - Room room = roomService.getRoomByUid(roomUid); - try { - AuditAudioBaseRetVo mediaRetVo = auditAudioRoomService.sendAuditMediaRoom(roomUid, room.getRoomId()); - if (mediaRetVo.getCode() == 1100) { - audioRoom.setRequestId(mediaRetVo.getRequestId()); - audioRoom.setUpdateTime(new Date()); - auditAudioRoomMapper.updateByPrimaryKeySelective(audioRoom); - jedisService.hset(RedisKey.audit_audio_room.getKey(), room.getUid().toString(), gson.toJson(audioRoom)); - } - } catch (Exception e) { - logger.error("sendAuditMediaRoom error cause by:", e.getMessage()); - } - }); - } - -} diff --git a/pom.xml b/pom.xml index 4adfea415..5910d0d0c 100644 --- a/pom.xml +++ b/pom.xml @@ -75,7 +75,6 @@ portable-1.6.8 1.1.6 1.0.2 - 3.0.9 0.9.1 3.4.0 1.2.1 @@ -86,7 +85,6 @@ 5.1.8 3.15 1.10.2 - 2.2.4 2.0.1.Final 1.1.0 1.1.8 @@ -99,7 +97,6 @@ 1.5.4 2.0.1.RELEASE 1.2.0 - 3.7.110.ALL 2.1.1 2.10.5 3.1.2 @@ -381,11 +378,6 @@ ${guava.version} - - com.github.wxpay - wxpay-sdk - ${wxpay-sdk.version} - io.jsonwebtoken @@ -448,11 +440,6 @@ jsoup ${jsoup.version} - - Pingplusplus - pingpp-java - ${pingpp-java.version} - javax.validation validation-api @@ -515,11 +502,6 @@ aliyun-java-sdk-cloudauth ${aliyun-java-sdk-cloudauth.version} - - com.alipay.sdk - alipay-sdk-java - ${alipay-sdk-java.version} - com.fasterxml.jackson.datatype jackson-datatype-joda @@ -757,16 +739,6 @@ - - com.github.wxpay - wxpay-sdk - - - org.slf4j - slf4j-simple - - - io.jsonwebtoken @@ -895,10 +867,6 @@ org.jsoup jsoup - - Pingplusplus - pingpp-java - javax.validation validation-api @@ -986,16 +954,6 @@ jedis - - com.thoughtworks.xstream - xstream - - - org.aspectj - aspectjweaver - - - com.qiniu qiniu-java-sdk @@ -1035,14 +993,6 @@ springfox-bean-validators - - com.alipay.sdk - alipay-sdk-java - - - - - org.springframework.boot spring-boot-configuration-processor diff --git a/xuanyin-game-match/src/main/java/com/xuanyin/gamematch/handler/rewardstategy/AbstractRewardStategy.java b/xuanyin-game-match/src/main/java/com/xuanyin/gamematch/handler/rewardstategy/AbstractRewardStategy.java index e352f154f..0ed66af3f 100644 --- a/xuanyin-game-match/src/main/java/com/xuanyin/gamematch/handler/rewardstategy/AbstractRewardStategy.java +++ b/xuanyin-game-match/src/main/java/com/xuanyin/gamematch/handler/rewardstategy/AbstractRewardStategy.java @@ -1,11 +1,8 @@ package com.xuanyin.gamematch.handler.rewardstategy; -import cn.hutool.core.collection.CollectionUtil; import com.accompany.common.status.BusiStatus; import com.accompany.core.exception.ServiceException; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.xuanyin.gamematch.constants.GameBillObjTypeEnum; -import com.xuanyin.gamematch.constants.GameBillTypeEnum; import com.xuanyin.gamematch.constants.GameManageConstants; import com.xuanyin.gamematch.constants.GameManageInfoStatusEnum; import com.xuanyin.gamematch.model.GameManageInfo; @@ -14,7 +11,6 @@ import com.xuanyin.gamematch.service.GameManageInfoService; import com.xuanyin.gamematch.service.GameManageJoinRecordService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; -import org.apache.tomcat.jni.Proc; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; diff --git a/xuanyin-game-match/src/main/java/com/xuanyin/gamematch/handler/rewardstategy/EliminateNumRewardStategy.java b/xuanyin-game-match/src/main/java/com/xuanyin/gamematch/handler/rewardstategy/EliminateNumRewardStategy.java index f1eb1e9fd..0e0f7a1cb 100644 --- a/xuanyin-game-match/src/main/java/com/xuanyin/gamematch/handler/rewardstategy/EliminateNumRewardStategy.java +++ b/xuanyin-game-match/src/main/java/com/xuanyin/gamematch/handler/rewardstategy/EliminateNumRewardStategy.java @@ -15,7 +15,6 @@ import com.xuanyin.gamematch.service.GameManageUserPurseService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.Arrays;