From bac0878349a1db23e7b420ea164e22fb9db73a99 Mon Sep 17 00:00:00 2001 From: xuekang <914468783@qq.com> Date: 星期六, 11 五月 2024 16:00:59 +0800 Subject: [PATCH] ecosphere-common 初始化 --- ecosphere/ecosphere-common/src/test/java/com/nuvole/util/MapTest.java | 23 ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyRegistryImpl.java | 62 ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/result/CommonResult.java | 56 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sms/SMSCallUtil.java | 67 ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/qdl/QdlLedgerAccount.java | 31 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/PageUtils.java | 41 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/DistanceUtil.java | 44 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/系统对接云商通接口流程.txt | 24 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/FileTypeJudge.java | 117 ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/PoscomVoice.java | 101 ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/result/SMSResult.java | 32 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/DesensitizationUtil.java | 58 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/syb/SybPayUrl.java | 164 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ResultHandler.java | 151 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/ConsumeApply.java | 60 ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/result/PageBean.java | 81 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/payment/PaymentOrder.java | 52 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/TencentMapUtil.java | 99 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/QdlTradeType.java | 35 ecosphere/ecosphere-common/src/test/java/com/nuvole/util/MixPdTest.java | 20 ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/StringToGB18030.java | 29 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/payment/PaymentSubOrder.java | 31 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/BeanUtil.java | 80 ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/SystemConstants.java | 206 ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/config/PoscomPrintData.java | 62 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/HttpUtilExtra.java | 49 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/CallBackUrl.java | 64 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/LaPushEnum.java | 41 ecosphere/pom.xml | 293 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/CryptoUtil.java | 55 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/syb/SybPayUtil.java | 1628 ++++ ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/PayBackChild.java | 32 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/MerchantApply.java | 61 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/YunStParam.java | 26 ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/user/SysUser.java | 19 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/XssUtil.java | 37 ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/dataFile/DataFile.java | 53 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/PayBack.java | 61 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/payment/PaymentSplitRule.java | 32 ecosphere/ecosphere-common/src/test/java/com/nuvole/util/JsonTest.java | 19 ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/wx/PushMsg.java | 25 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ImageUtil.java | 96 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/WxUtil.java | 284 ecosphere/ecosphere-common/src/test/java/com/nuvole/util/FileUtilTest.java | 19 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ComputeUtil.java | 102 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/IdGenerator.java | 30 ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/NXPayService.java | 524 + ecosphere/ecosphere-common/src/test/java/com/nuvole/util/IdTest.java | 106 ecosphere/ecosphere-common/src/main/java/com/nuvole/rateLimit/ApiRateLimitAop.java | 81 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sms/SMSHistory.java | 29 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/YunStUtilNew.java | 168 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/OSSUtil.java | 252 ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/PropertiesConstants.java | 163 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/AESUtil.java | 57 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/SplitRule.java | 32 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/QdlPayScene.java | 37 ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/api/PoscomService.java | 197 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sms/SMSTemplate.java | 84 ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryTrigger.java | 70 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/PropertyUtil.java | 35 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/JGPushCallUtil.java | 31 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/QdlTradeStatus.java | 49 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/SubOrder.java | 40 ecosphere/ecosphere-common/pom.xml | 226 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/CreateMember.java | 18 ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/emnu/SMSResultEmnu.java | 33 ecosphere/ecosphere-common/src/main/resources/antisamy.xml | 2789 +++++++ ecosphere/ecosphere-common/src/main/java/com/nuvole/util/TypeConvertUtil.java | 36 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sms/YpSMSUtil.java | 63 ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/config/TempletParams.java | 33 ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyRegistry.java | 13 ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryTask.java | 152 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/CncpUtil.java | 832 ++ ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/query/PageQuery.java | 28 ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyMetadata.java | 52 ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/config/PoscomConfig.java | 27 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/AesCbcUtil.java | 61 ecosphere/ecosphere-common/src/test/java/com/nuvole/util/XssUtilTest.java | 31 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/VerifyImgUtil.java | 153 ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/PoscomUtil.java | 36 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/syb/SybPayCode.java | 89 ecosphere/ecosphere-common/src/main/resources/yunsdk.properties | 11 ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryMessageEntity.java | 58 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/YunStUtil.java | 1092 +++ ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/PushTemplateConstants.java | 42 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/TreeUtil.java | 105 ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/emnu/CommonResultEmnu.java | 52 ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/QdlConstant.java | 64 ecosphere/ecosphere-common/src/main/java/com/nuvole/rateLimit/ApiRateLimit.java | 35 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/GeTuiPush.java | 273 ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/SignatureSigner.java | 130 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/oss/YiDongOss.java | 126 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/JGPushUtil.java | 84 ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyProvider.java | 14 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/WxCallUtil.java | 185 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sc/client/domain/ScGroup.java | 25 ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/token/UserToken.java | 26 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/Pinyin.java | 80 ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/ServiceConstants.java | 136 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/CodeUtil.java | 56 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/OrderPay.java | 73 ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/conf/NxPayConfig.java | 199 ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/HnnxConstant.java | 85 ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyProviderImpl.java | 173 ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/StringToAscii.java | 49 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ExportExcel.java | 79 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/SftpUtil.java | 124 ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/result/ExpressResult.java | 36 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/CommonUtil.java | 294 ecosphere/ecosphere-common/src/test/java/com/nuvole/util/JWTUtilTest.java | 28 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/BaiduUtil.java | 65 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/YunStResult.java | 33 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/LaBaPushUtil.java | 104 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/ResultVo.java | 15 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sc/client/domain/ScClient.java | 36 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/syb/param/MerchantAddParam.java | 375 + ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/YstPayUrl.java | 35 ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryUtil.java | 61 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ApplicationContextUtil.java | 35 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/IPUtil.java | 80 ecosphere/ecosphere-common/src/main/java/com/nuvole/laba/LabaPushUtil.java | 31 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/SignContractApply.java | 30 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/GeTuiPushCall.java | 62 ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/PoscomRequest.java | 176 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/ApiPost.java | 82 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/PayUtil.java | 149 ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/dto/AppDTO.java | 56 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sc/sms/ScSMSUtil.java | 57 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ResourceUtil.java | 164 ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/NXHttpClientUtils.java | 778 ++ ecosphere/ecosphere-common/src/main/java/com/nuvole/util/DiscountUtil.java | 51 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ExpressUtil.java | 84 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/JWTUtil.java | 187 ecosphere/ecosphere-common/src/main/resources/poscom.properties | 6 ecosphere/ecosphere-common/src/test/resources/antisamy.xml | 2789 +++++++ ecosphere/ecosphere-common/src/main/java/com/nuvole/util/FtpUtil.java | 88 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/TableExportCallUtil.java | 35 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sc/client/四川客管系统接口文档.docx | 0 ecosphere/ecosphere-common/src/test/java/com/nuvole/util/TreeUtilTest.java | 82 ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryEvent.java | 23 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/WriterUtil.java | 130 ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/FileType.java | 187 142 files changed, 21,199 insertions(+), 0 deletions(-) diff --git a/ecosphere/ecosphere-common/pom.xml b/ecosphere/ecosphere-common/pom.xml new file mode 100644 index 0000000..cc0e464 --- /dev/null +++ b/ecosphere/ecosphere-common/pom.xml @@ -0,0 +1,226 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.dromara</groupId> + <artifactId>ecosphere</artifactId> + <version>${revision}</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>ecosphere-common</artifactId> + + <description> + ecosphere-common 渚濊禆椤� + </description> + <dependencies> + <dependency> + <groupId>io.springfox</groupId> + <artifactId>springfox-swagger2</artifactId> + </dependency> + + <dependency> + <groupId>commons-beanutils</groupId> + <artifactId>commons-beanutils</artifactId> + </dependency> + + <dependency> + <groupId>cglib</groupId> + <artifactId>cglib</artifactId> + </dependency> + + <dependency> + <groupId>com.belerweb</groupId> + <artifactId>pinyin4j</artifactId> + </dependency> + + <!--MD5鎾掔洂--> + <dependency> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + <version>1.2</version> + </dependency> + + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <scope>test</scope> + </dependency> + <!--鏋佸厜鎺ㄩ��--> + <dependency> + <groupId>cn.jpush.api</groupId> + <artifactId>jpush-client</artifactId> + <version>3.3.10</version> + </dependency> + + <dependency> + <groupId>org.owasp.antisamy</groupId> + <artifactId>antisamy</artifactId> + <version>1.5.8</version> + </dependency> + + <dependency> + <groupId>org.owasp.encoder</groupId> + <artifactId>encoder</artifactId> + <version>1.2.2</version> + </dependency> + + + <!--灏忕▼搴� session_key鍔犺В瀵嗙敤鍒扮殑jar--> + <!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15 --> + <dependency> + <groupId>org.bouncycastle</groupId> + <artifactId>bcprov-jdk15</artifactId> + <version>1.45</version> + </dependency> + + <!--寰俊灏忕▼搴忔ā鐗堟帹閫�--> + <dependency> + <groupId>com.github.binarywang</groupId> + <artifactId>weixin-java-miniapp</artifactId> + <version>3.4.0</version> + </dependency> + + <dependency> + <groupId>commons-httpclient</groupId> + <artifactId>commons-httpclient</artifactId> + <version>3.1</version> + </dependency> + + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-text</artifactId> + <version>1.1</version> + </dependency> + + <!--鍥涘窛鐭俊--> + <dependency> + <groupId>com.wisentsoft</groupId> + <artifactId>gsmpclient</artifactId> + <version>1.3.5</version> + <scope>system</scope> + <systemPath>${basedir}/../libs/gsmpclient-1.0.4.jar</systemPath> + </dependency> + + <!--閫氳仈锛堜簯鍟嗛�氾級--> + <dependency> + <groupId>com.allinpay</groupId> + <artifactId>yunst-sdk</artifactId> + <version>0.0.1-SNAPSHOT</version> + <scope>system</scope> + <systemPath>${basedir}/../libs/yunst-sdk-0.0.1-SNAPSHOT.jar</systemPath> + </dependency> + + <!--杩囨护dto--> + <dependency> + <groupId>org.mapstruct</groupId> + <artifactId>mapstruct-jdk8</artifactId> + <version>1.2.0.Final</version> + </dependency> + <dependency> + <groupId>org.mapstruct</groupId> + <artifactId>mapstruct-processor</artifactId> + <version>1.2.0.Final</version> + </dependency> + + + <!--涓帹鎺ㄩ��--> + <dependency> + <groupId>com.gexin.platform</groupId> + <artifactId>gexin-rp-sdk-http</artifactId> + <version>4.1.0.5</version> + <scope>system</scope> + <systemPath>${basedir}/../libs/gexin-rp-sdk-http-4.1.0.5.jar</systemPath> + </dependency> + <dependency> + <groupId>com.gexin.platform</groupId> + <artifactId>gexin-rp-sdk-template</artifactId> + <version>4.0.0.24</version> + <scope>system</scope> + <systemPath>${basedir}/../libs/gexin-rp-sdk-template-4.0.0.24.jar</systemPath> + </dependency> + <dependency> + <groupId>com.gexin.platform</groupId> + <artifactId>gexin-rp-sdk-base</artifactId> + <version>4.0.0.30</version> + <scope>system</scope> + <systemPath>${basedir}/../libs/gexin-rp-sdk-base-4.0.0.30.jar</systemPath> + </dependency> + <dependency> + <groupId>com.gexin.platform</groupId> + <artifactId>gexin-rp-fastjson</artifactId> + <version>1.0.0.3</version> + <scope>system</scope> + <systemPath>${basedir}/../libs/gexin-rp-fastjson-1.0.0.3.jar</systemPath> + </dependency> + + <!--鐧惧害ocr--> + <dependency> + <groupId>com.baidu.aip</groupId> + <artifactId>java-sdk</artifactId> + <version>4.11.0</version> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </exclusion> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>cpcn.institution</groupId> + <artifactId>API</artifactId> + <version>2.5.0.0-SNAPSHOT</version> + <scope>system</scope> + <systemPath>${basedir}/../libs/cpcn-payment-api-2.6.0.9.jar</systemPath> + </dependency> + <dependency> + <groupId>cpcn.institution</groupId> + <artifactId>InstitutionTools</artifactId> + <version>v1.0.1.4-RELEASE</version> + <scope>system</scope> + <systemPath>${basedir}/../libs/InstitutionTools-v1.0.1.4-RELEASE.jar</systemPath> + </dependency> + + + <dependency> + <groupId>com.csii</groupId> + <artifactId>sg</artifactId> + <scope>system</scope> + <version>1.0.3</version> + <systemPath>${basedir}/../libs/jinYanEPay-1.0.3.jar</systemPath> + </dependency> + + <!--鎻愪緵 EOS S3 鐩稿叧鍔熻兘锛屽繀椤�--> + <dependency> + <groupId>com.chinamobile.cmss.eos</groupId> + <artifactId>eos-java-s3-sdk</artifactId> + <version>1.11.820</version> + <scope>system</scope> + <systemPath>${project.basedir}/../libs/eos-java-s3-sdk-1.11.820.jar</systemPath> + </dependency> + <!--鎻愪緵 EOS 涓存椂璁よ瘉鍔熻兘锛屽彲閫�--> + <dependency> + <groupId>com.chinamobile.cmss.eos</groupId> + <artifactId>eos-java-s3-sdk-sts</artifactId> + <version>1.11.820</version> + <scope>system</scope> + <systemPath>${project.basedir}/../libs/eos-java-s3-sdk-sts-1.11.820.jar</systemPath> + </dependency> + <dependency> + <groupId>joda-time</groupId> + <artifactId>joda-time</artifactId> + <version>2.8.1</version> + </dependency> + + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>30.1-jre</version> + </dependency> + </dependencies> +</project> diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/dataFile/DataFile.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/dataFile/DataFile.java new file mode 100644 index 0000000..9b6de30 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/dataFile/DataFile.java @@ -0,0 +1,53 @@ +package com.nuvole.common.domain.dataFile; + +import lombok.AllArgsConstructor; +import lombok.Data; + +/** + * [{"uid":1562829586751,"path":"","name":"","url":""}] + */ + +@Data +@AllArgsConstructor +public class DataFile { + + private Long uid; + + private String path; + + private String name; + + private String url; + + public Long getUid() { + return uid; + } + + public void setUid(Long uid) { + this.uid = uid; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/dto/AppDTO.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/dto/AppDTO.java new file mode 100644 index 0000000..ab1b2c2 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/dto/AppDTO.java @@ -0,0 +1,56 @@ +package com.nuvole.common.domain.dto; +import lombok.Data; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @Description: + * @Company: TOO (ps锛氬叕鍙稿悕绉�) + * @author: 鍞� + * @date: 2019/10/31 涓嬪崍6:59 + * @version: V1.0.0 + */ + + +@Data +public class AppDTO<T> { + + private Long attr; + + private Long attr2; + + private Long attr3; + + private Long attr4; + + private String pro; + + private String pro2; + + private String pro3; + + private String pro4; + + private Short small; + + private Short small2; + + private Integer integer; + + private Integer integer2; + + private Object object; + + private Map map; + + private Map map2; + + private Date date; + + private List<T> list; + + +} + diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/emnu/CommonResultEmnu.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/emnu/CommonResultEmnu.java new file mode 100644 index 0000000..13bce68 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/emnu/CommonResultEmnu.java @@ -0,0 +1,52 @@ +package com.nuvole.common.domain.emnu; + +public enum CommonResultEmnu { + + OK(10000,"OK"),//璇锋眰鎴愬姛 + ERROR(50000,"ERROR"),//鎿嶄綔澶辫触 + INVALID_PARAMS(20000,"INVALID_PARAMS"),//闈炴硶鍙傛暟 + AUTHENTICATION_ERR(20001,"AUTHENTICATION_ERR"),//韬唤鏍¢獙閿欒 + TOKEN_ERR(20002,"TOKEN_ERR"),//token error + NO_PERMISSION_ERR(20006,"NO_PERMISSION_ERR"),//鏃犺闂潈闄� + CRYPTO_ERR(20003,"CRYPTO_ERR"),//鍔犲瘑/瑙e瘑閿欒 + DATA_EMPTY(20004,"EMPTY_ERR"),//绌烘暟鎹� + SIGN_ERR(20005,"SIGN_ERR"),//绛惧悕閿欒 + RENCAI_ERR(20006,"RENCAI_ERR"),//浜烘墠淇℃伅閿欒 鏃犳晥 + SERVER_ERR(10001,"SERVER_ERR"),//鏈嶅姟寮傚父 + REQUEST_LIMIT_ERR(20007,"REQUEST_LIMIT_ERR");//璇锋眰澶绻� + + private Integer code; + private String info; + + private CommonResultEmnu(Integer code, String info) { + this.code = code; + this.info = info; + } + + public static String getInfo(Integer code) { + for (CommonResultEmnu item : CommonResultEmnu.values()) { + if (item.getCode().equals(code)) { + return item.getInfo(); + } + } + return ""; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public String getInfo() { + return info; + } + + public void setInfo(String info) { + this.info = info; + } + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/emnu/SMSResultEmnu.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/emnu/SMSResultEmnu.java new file mode 100644 index 0000000..f7f33ea --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/emnu/SMSResultEmnu.java @@ -0,0 +1,33 @@ +package com.nuvole.common.domain.emnu; + +public enum SMSResultEmnu { + + OK("0", "OK"), //璇锋眰鎴愬姛 + ERROR("-10000", "ERROR");//鎿嶄綔澶辫触 + + private String code; + private String msg; + + private SMSResultEmnu(String code, String msg) { + this.code = code; + this.msg = msg; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/qdl/QdlLedgerAccount.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/qdl/QdlLedgerAccount.java new file mode 100644 index 0000000..dcda782 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/qdl/QdlLedgerAccount.java @@ -0,0 +1,31 @@ +package com.nuvole.common.domain.qdl; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @ClassName QdlLedgerAccount + * @Author cy + * @Date 2023/9/1 + * @Description 缈兼敮浠樺垎璐﹀垪琛� + * @Version 1.0 + **/ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class QdlLedgerAccount { + + /** + * 鍟嗘埛鍙� + */ + private String merchantNo; + /** + * 鍗曚綅锛氬垎 + */ + private Long amount; + /** + * 澶囨敞 + */ + private String memo; +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/query/PageQuery.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/query/PageQuery.java new file mode 100644 index 0000000..4a7e6a0 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/query/PageQuery.java @@ -0,0 +1,28 @@ +package com.nuvole.common.domain.query; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 鍒嗛〉鏌ヨ瀹炰綋灏佽 + * + * @author liujun + * @Date 2019/6/17 10:35 + */ +@Data +@ApiModel(value = "鍒嗛〉鏌ヨ灏佽") +public class PageQuery { + + @ApiModelProperty("椤电爜") + private Integer pageNumber = 1; + + @ApiModelProperty("鏉℃暟") + private Integer pageSize = 10; + + @ApiModelProperty("鎺掑簭鍚嶇О") + private String sortName; + + @ApiModelProperty("鎺掑簭鏂瑰紡") + private String sortOrder; +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/result/CommonResult.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/result/CommonResult.java new file mode 100644 index 0000000..f58d260 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/result/CommonResult.java @@ -0,0 +1,56 @@ +package com.nuvole.common.domain.result; + +import cn.hutool.core.util.ObjectUtil; +import com.nuvole.common.domain.emnu.CommonResultEmnu; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class CommonResult<T> { + + public static final String STATUS_OK = "1";//鎴愬姛 + public static final String STATUS_ERR = "0";//澶辫触 + + public static final Integer CODE_OK = 10000;//璇锋眰鎴愬姛杩斿洖鐮� + + @ApiModelProperty("鐘舵�佸�� 0:澶辫触 1:鎴愬姛 ") + private String status = STATUS_OK; + + @ApiModelProperty("鎺ュ彛杩斿洖淇℃伅") + private String info = CommonResultEmnu.OK.getInfo(); + + @ApiModelProperty("鎺ュ彛杩斿洖淇℃伅 code ") + private Integer code = CommonResultEmnu.OK.getCode(); + + @ApiModelProperty("鎺ュ彛杩斿洖淇℃伅鎻忚堪 ") + private String description = ""; + + @ApiModelProperty("鎺ュ彛杩斿洖鍊� ") + private T data; + + public CommonResult() { + + } + + public CommonResult(T data) { + this.data = ObjectUtil.cloneIfPossible(data); + } + + public CommonResult(CommonResultEmnu resultEmnu) { + if (!resultEmnu.getCode().equals(CODE_OK)) { + this.status = STATUS_ERR; + } + this.code = resultEmnu.getCode(); + this.info = resultEmnu.getInfo(); + } + + public CommonResult(CommonResultEmnu resultEmnu, String description) { + if (!resultEmnu.getCode().equals(CODE_OK)) { + this.status = STATUS_ERR; + } + this.code = resultEmnu.getCode(); + this.info = resultEmnu.getInfo(); + this.description = description; + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/result/ExpressResult.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/result/ExpressResult.java new file mode 100644 index 0000000..448a013 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/result/ExpressResult.java @@ -0,0 +1,36 @@ +package com.nuvole.common.domain.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * 蹇�掗笩鏌ヨ鐗╂祦杩斿洖鍙傛暟 + * + * @Author: lc + * @Date: 2019/6/17 18:46 + */ +@Data +public class ExpressResult { + + @ApiModelProperty("鐢ㄦ埛ID ") + private String EBusinessID; + @ApiModelProperty("璁㈠崟缂栧彿 ") + private String OrderCode; + @ApiModelProperty("蹇�掑叕鍙哥紪鐮� ") + private String ShipperCode; + @ApiModelProperty("鐗╂祦杩愬崟鍙� ") + private String LogisticCode; + @ApiModelProperty("鎴愬姛涓庡惁銆恡rue锛氭垚鍔� false锛氬け璐ャ�� ") + private String Success; + @ApiModelProperty("澶辫触鍘熷洜 ") + private String Reason; + @ApiModelProperty("鐗╂祦鐘舵�侊細1-宸叉徑鏀� 2-鍦ㄩ�斾腑,3-绛炬敹,4-闂浠� ") + private String State; + @ApiModelProperty("鐗╂祦淇℃伅銆怉cceptStation锛氭弿杩帮紝AcceptTime锛氭椂闂淬�� ") + private List<Map> Traces; + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/result/PageBean.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/result/PageBean.java new file mode 100644 index 0000000..c68c063 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/result/PageBean.java @@ -0,0 +1,81 @@ +package com.nuvole.common.domain.result; + +import cn.hutool.core.convert.Convert; +import cn.hutool.core.util.NumberUtil; +import com.nuvole.util.BeanUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +// @formatter:off +/** + * .-~~~~~~~~~-._ _.-~~~~~~~~~-. + * __.' @Author ~. .~ 浠g爜鏃燘ug `.__ + * .'// liu.q \./ (绉樼睄) \\`. + * .'// [916000612@qq.com] | 娆茬粌绁炲姛 寮曞垁鑷 \\`. + * .'// .-~"""""""~~~~-._ | _,-~~~~"""""""~-. \\`. + * .'//.-" 2019-04-09 `-. | .-' 11:35 "-.\\`. + * .'//______.============-.. \ | / ..-============.______\\`. + *.'______________________________\|/______________________________`. + * + * @Description : + */ +// @formatter:on + +@Data +@NoArgsConstructor +@ApiModel("鍒楄〃 杩斿洖缁撴灉鍒楄〃灏佽") +public class PageBean<T> implements Serializable { + private static final long serialVersionUID = 1000L; + + @ApiModelProperty("鎬昏褰曟暟") + private Integer total; //鎬昏褰曟暟 + @ApiModelProperty("缁撴灉闆�") + private List<T> rows; //缁撴灉闆� + @ApiModelProperty("绗嚑椤�") + private int pageNumber; //绗嚑椤� + @ApiModelProperty("姣忛〉璁板綍鏁�") + private int pageSize; //姣忛〉璁板綍鏁� + @ApiModelProperty("鎬婚〉鏁�") + private int pages; // 鎬婚〉鏁� + @ApiModelProperty("褰撳墠椤电殑鏁伴噺<=pageSize") + private int size; //褰撳墠椤电殑鏁伴噺<=pageSize + + public PageBean(Object obj) { + Map map = BeanUtil.obj2Map(obj); + if(map!=null){ + this.pageNumber = Convert.toInt(map.get("pageNum")); + this.pageSize = Convert.toInt(map.get("pageSize")); + this.total = Convert.toInt(map.get("total")); + this.pages = Convert.toInt(map.get("pages")); + this.rows = obj == null ? new ArrayList<>() : (List<T>)obj; + this.size = this.rows.size(); + } + } + + public void setData(List list){ + if(list != null && list.size() >0){ + this.total = list.size(); + //鍒嗛〉 + if (this.total > 0) { + int start = Convert.toInt(NumberUtil.mul(pageNumber-1, pageSize)); + int end = Convert.toInt(NumberUtil.mul(pageNumber,pageSize)); + if (start <= total) { + if (end > total) { + end = total; + } + this.rows = list.subList(start, end); + } else { + this.rows = new ArrayList<>(); + } + } + } + } + +} \ No newline at end of file diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/result/SMSResult.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/result/SMSResult.java new file mode 100644 index 0000000..4b8e3f5 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/result/SMSResult.java @@ -0,0 +1,32 @@ +package com.nuvole.common.domain.result; + +import com.nuvole.common.domain.emnu.SMSResultEmnu; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 鐭俊杩斿洖缁撴灉 + * + * @Author: lc + * @Date: 2019/8/5 11:48 + */ +@Data +public class SMSResult { + + @ApiModelProperty("鐘舵�佺爜") + private String code; + + @ApiModelProperty("鎻忚堪") + private String msg; + + public SMSResult(SMSResultEmnu resultEmnu, String msg) { + this.code = resultEmnu.getCode(); + this.msg = msg; + } + + public SMSResult(SMSResultEmnu resultEmnu) { + this.code = resultEmnu.getCode(); + this.msg = resultEmnu.getMsg(); + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/token/UserToken.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/token/UserToken.java new file mode 100644 index 0000000..71e75b4 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/token/UserToken.java @@ -0,0 +1,26 @@ +package com.nuvole.common.domain.token; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.ToString; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName UserToken + * @date 2019/5/6 18:45 + * @Description 鐧诲綍鐢ㄦ埛token + */ +@Data +@ToString +@ApiModel(value = "鐧诲綍鐢ㄦ埛token") +public class UserToken { + + @ApiModelProperty("鐧诲綍鏍囪瘑锛岃皟鐢ㄤ笟鍔℃帴鍙f椂闇�鏀剧疆鍒癶eader涓�") + String accessToken; + + @ApiModelProperty("杩囨湡鏃堕棿 绉�") + Long expiresIn; + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/user/SysUser.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/user/SysUser.java new file mode 100644 index 0000000..8a4ffc3 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/user/SysUser.java @@ -0,0 +1,19 @@ +package com.nuvole.common.domain.user; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.ToString; + +@Data +@ToString +@ApiModel(value = "鍚庡彴鐢ㄦ埛淇℃伅") +public class SysUser { + + @ApiModelProperty("id") + private Long id; + + @ApiModelProperty("鐢ㄦ埛鍚�") + private String userName; + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/wx/PushMsg.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/wx/PushMsg.java new file mode 100644 index 0000000..0e9d09f --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/common/domain/wx/PushMsg.java @@ -0,0 +1,25 @@ +package com.nuvole.common.domain.wx; + +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(value = "寰俊灏忕▼搴�-璁㈤槄娑堟伅") +public class PushMsg { + + @ApiModelProperty("鎺ュ彈鐨勭敤鎴穙penId") + private String touser; + + @ApiModelProperty("璁㈤槄鐨勬ā鏉縤d") + private String template_id; + + @ApiModelProperty("妯℃澘璺宠浆鐨勮鎯呴〉闈紝鍙甫鍙傛暟锛屼笉浼犱笉璺宠浆") + private String page; + private String url; + + @ApiModelProperty("妯℃澘鍐呭") + private JSONObject data; + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/PropertiesConstants.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/PropertiesConstants.java new file mode 100644 index 0000000..a0b9d4e --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/PropertiesConstants.java @@ -0,0 +1,163 @@ +package com.nuvole.constants; + +/** + * 绯荤粺閰嶇疆甯搁噺 + * + * @Author: lc + * @Date: 2019/7/30 19:22 + */ +public class PropertiesConstants { + + //鏈嶅姟鍦板潃閰嶇疆 + /** + * 鍚庡彴鎺ュ彛鏈嶅姟鍦板潃 + */ + public static final String STQ_SERVER = "https://yqzx.jinmingyuan.com"; +// public static final String STQ_SERVER = "https://daguogongjiang.top"; + /** + * h5鏈嶅姟鍦板潃 + */ + public static final String STQ_SERVER_WECHAT = "https://yqzx.jinmingyuan.com"; +// public static final String STQ_SERVER_WECHAT = "https://daguogongjiang.top"; + /** + * 鍟嗘埛妯″潡鏈嶅姟鍦板潃 + */ + public static final String STQ_SERVER_MERCHANT = STQ_SERVER + "/service-merchant"; + /** + * 鍟嗗煄妯″潡鏈嶅姟鍦板潃 + */ + public static final String STQ_SERVER_SHOP = STQ_SERVER + "/service-shop"; + + /** + * 1 浣跨敤sftp + * 2 浣跨敤绉诲姩浜憃ss + */ + public static final int UPLOAD_MODEL = 1; + public static final int KJ_PAY_WAY = 1; //蹇嵎鏀粯娓犻亾銆�1:閫氳仈浜戝晢閫� 2:鍐滆蹇嵎鏀粯銆� + /** + * 闈欐�佽祫婧愭湇鍔″湴鍧�锛坒tp锛� + */ + public static String FILE_SERVER = null; + + +// public static final String FILE_SERVER = "https://daguogongjiang.top/sftp"; //鍏徃鍦板潃 +// public static final String FILE_SERVER = "http://172.16.2.77/f-static"; //姝e紡鐜 + + //鍏紬骞冲彴閰嶇疆 + /** + * 灏忕▼搴廰ppId + */ +// public static final String WX_APP_APPID = "wx044ba657d536fa6a"; + // 鎸叴娑堣垂-灏忕▼搴� +// public static final String WX_APP_APPID = "wx22159c42a5805166"; + //鏁板瓧鍖栫敓鎬佸湀 + public static final String WX_APP_APPID = "wxfc579973fbdde096"; + //浜簮浜� AppSecret +// public static final String WX_APP_APPID = "wxf6818b61cdbb80e4"; + + /** + * 灏忕▼搴弒ecret 鎸叴娑堣垂 + */ +// public static final String WX_APP_SECRET = "2635f74b77b0cd1057cb8266e5c2606d"; + // 灏忕▼搴弒ecret 鏁板瓧鍖栫敓鎬佸湀 + public static final String WX_APP_SECRET = "d5d7d0438028b8c29890784344df8216"; + //灏忕▼搴弒ecret 浜簮浜� +// public static final String WX_APP_SECRET = "d54f086bce09d291605dc57441fa4908"; + + + /** + * 寰俊鏈嶅姟鍙穉ppId + */ +// public static final String WX_WECHAT_APPID = "wx4e2cf88d5ffa708e"; + // 鍏徃H5鍏紬鍙� + public static final String WX_WECHAT_APPID = "wxad8cc511da676bd4"; + //H5鍏紬鍙� 浜簮浜� +// public static final String WX_WECHAT_APPID = "wxd163440fc91fd9af"; + //鏃跺伐 灏忕▼搴� +// public static final String WX_WECHAT_APPID = "wx22159c42a5805166"; + + /** + * 寰俊鏈嶅姟鍙穝ecret + */ +// public static final String WX_WECHAT_SECRET = "dc3594f91ab86def1277133c45bd2584"; + // 鍏徃H5鍏紬鍙� + public static final String WX_WECHAT_SECRET = "d4f742cf77b1534055932a1d970cb8ce"; + //H5鍏紬鍙� 浜簮浜� +// public static final String WX_WECHAT_SECRET = "d54f086bce09d291605dc57441fa4908"; + + /** + * 寰俊鏈嶅姟鍟嗗晢鎴峰彿 + */ + + public static final String WX_SERVER_MCHID = "1633049026"; + // 浜簮浜� 鍟嗘埛鍙� +// public static final String WX_SERVER_MCHID = "1648271607"; + /** + * 寰俊灏忕▼搴忔敮浠樺钩鍙扮殑瀛愬晢鎴穒d + */ + public static final String WX_MINIPAY_PLATFORM_SUB_APPID = "1633682244"; + // 浜簮浜� +// public static final String WX_MINIPAY_PLATFORM_SUB_APPID = null; + + /** + * 寰俊鏈嶅姟鍟� secret + */ + public static final String WX_SERVER_SECRET = "SKC2E1QGBRVFL7T35MYUN49IA06PZXOH"; + // // 浜簮浜� secret +// public static final String WX_SERVER_SECRET = "6Lk7s4QWqXr9Dv1OzIJlEM2aA5YbupKS"; + + + //鏀粯閰嶇疆 + public static final int PAY_WAY = 3; //鍟嗗煄鏀粯娓犻亾銆�1:閫氳仈鏀堕摱瀹� 2:閫氳仈浜戝晢閫� 鏂板3 绾井淇℃敮浠� 4 涓噾鏀粯銆� + + static { + if (UPLOAD_MODEL == 1) { + FILE_SERVER = "https://yqzx.jinmingyuan.com/file"; //鍏徃鍦板潃 + } else if (PropertiesConstants.UPLOAD_MODEL == 2) { + FILE_SERVER = "https://ecosphere.eos.zhengzhou-4.cmecloud.cn"; + } + } + public static final int PAY_TYPE = 2; //鏀粯璇诲彇鍙傛暟銆�1.閰嶇疆鏂囦欢璇诲彇锛堝浐瀹氫竴涓級 2.琛ㄩ噷鍔犺浇锛堟寜鏈烘瀯鏌ヨ锛夈�� + public static final String TL_PAY_APPID = "00143623"; //appid + public static final String TL_PAY_K = "123456"; //绉橀挜 + public static final String TL_PAY_ORGCODE = "55165106012TWGR"; //鏈烘瀯鍙凤紙骞冲彴鍞竴鏍囪瘑锛� + + //瀹㈢绯荤粺 + /** + * 浼氬憳淇℃伅璇诲彇绫诲瀷銆�1.瀹㈢绯荤粺 2.鏈郴缁燂紙瀵煎叆鏂瑰紡锛夈�� + */ + public static final int MEMBER_READ_TYPE = 2; + + /** + * h5鏈嶅姟鍦板潃 + */ + public static final String WX_SERVER_WECHAT = "https://api.mch.weixin.qq.com/pay/unifiedorder"; + /** + * 寰俊 浠樻鐮佹敮浠� + */ + public static final String WX_SERVER_MICROPAY = "https://api.mch.weixin.qq.com/pay/micropay"; + + /** + * 寰俊 璁㈠崟鏌ヨ + */ + public static final String WX_SERVER_ORDERQUERY = "https://api.mch.weixin.qq.com/pay/orderquery"; + + /** + * 浠樻鐮佹煡璇penid + */ + public static final String WX_SERVER_AUTHCODE2OPENID = "https://api.mch.weixin.qq.com/tools/authcodetoopenid"; + + /** + * 閫氳仈鏀堕摱瀹濋�氶亾code + */ + public static final String CHANNEL_CODE_SYB = "allinPay"; + /** + * 鏀粯瀹濆井淇$洿杩為�氶亾code + */ + public static final String CHANNEL_CODE_DIRECTPAY = "directPay"; + + /** + * 杩涘叆搴楅摵绾夸笅鎵爜浠樻眹鎬昏绠桲ey + */ + public static String JOB_SHOP_STATIS_SCANORDER_KEY = "JOB_SHOP_STATIS_SCANORDER_KEY"; +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/PushTemplateConstants.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/PushTemplateConstants.java new file mode 100644 index 0000000..e40211e --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/PushTemplateConstants.java @@ -0,0 +1,42 @@ +package com.nuvole.constants; + +/** + * @Description: 鎺ㄩ�佹ā鏉縄D甯搁噺 + * @Author: liujun + * @Date: 2019-07-23 14:57 + **/ +public class PushTemplateConstants { + + /** + * 寮�鍥㈡帹閫佹ā鏉� + */ +// public static final String GROUP_START = "CI5XGGJdQb6IKok0tSrd8HpJHlqyChPc3U58yzAz4Y8"; + + /** + * 鍙傚洟鎺ㄩ�佹ā鏉� + */ +// public static final String GROUP_JOIN = "mnGXLJBcwk3vRlaBMowRe51zDpGLtGRDaBh4PIysCOs"; + + /** + * 鍥㈣喘鎴愬姛鎺ㄩ�佽闃呮ā鏉挎秷鎭痠d + */ + public static final String GROUP_SUCCESS = "a_ojaiKU0OFR3ihu5taT-F5PuZ3vCI4fxXsybLLdy1Q"; + + /** + * 鍥㈣喘澶辫触鎺ㄩ�佽闃呮ā鏉挎秷鎭痠d + */ + public static final String GROUP_FAIL = "Fe9IW6n-j7d1F7L-S3CTNfIS8mrxFDLVbYHivnPnvC8"; + + /** + * 鍥㈣喘閫炬湡鏈敮浠樻帹閫佽闃呮ā鏉挎秷鎭痠d + */ + public static final String GROUP_NO_PAY = "MAryTGFLOO9X6Pr15Z3iJ0j71boGBKcCMwFEHNHeAes"; + + /** + * 璁㈠崟鏀粯鎴愬姛 + */ + public static final String PAY_SUCCESS= "fWkckzC4AtkJfJVQhX6r2PTz0YKNdXUV9yDXQ6r-svI"; + + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/QdlConstant.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/QdlConstant.java new file mode 100644 index 0000000..0896229 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/QdlConstant.java @@ -0,0 +1,64 @@ +package com.nuvole.constants; + +/** + * @ClassName QdlConstant + * @Author cy + * @Date 2023/8/28 + * @Description + * @Version 1.0 + **/ +public class QdlConstant { + + /** + * 鐢熶骇鐜鍦板潃 + */ + private static final String PROD_URL = "https://openapi.qdlpay.com"; + + /** + * 绾夸笂鑱氬悎涓嬪崟鎺ュ彛 + * 寰俊灏忕▼搴忋�佸井淇″叕浼楀彿鏀粯銆丄PP 鎷夎捣鏀粯瀹濄�丄PP 鎷夎捣缈兼敮浠� + */ + public static String ONLINEPAYURL = PROD_URL + "/gapi/aggregate/aggregatepay/online/payOrder"; + + /** + * 鑱氬悎鏀舵鐮侊紙C 鎵� B锛変笅鍗� + * 澶栭儴鍟嗘埛閫氳繃璇ユ帴鍙h繘琛岃仛鍚堟敮浠樹笅鍗曪紝骞舵媺璧风浉搴旂涓夋柟 APP 杩涜鏀粯 + */ + public static String OFFLINEC2BPAYURL = PROD_URL + "/gapi/aggregate/aggregatepay/offline/c2b/payOrder"; + + /** + * 鍗忚鍙� + * 娴嬭瘯鐜 20200814030100033652190094557249 + * 鐢熶骇鐜 20200825030100037665282868641830 + */ + public static final String AGREE_ID = "20200825030100037665282868641830"; + + /** + * 鏉$爜鏌ヨ鐢ㄦ埛鏍囪瘑 + * 鐢ㄤ簬浠樻鐮佹敮浠樺墠鏍规嵁鏉$爜鏌ヨ鐢ㄦ埛鏍囪瘑 + */ + public static String CODE2IDENURL = PROD_URL + "/gapi/o2o/aggregatePay/services/barCodeIdentification"; + /** + * 璁㈠崟瓒呮椂鏃堕棿 + */ + public static final String TIME_OUT = "86400"; + /** + * 绛惧悕绫诲瀷 + */ + public static final String SIGN_TYPE = "S002"; + /** + * 鑱氬悎浠樻鐮侊紙B 鎵� C锛変笅鍗� + * 鍟嗘埛绔壂鐢ㄦ埛鏀粯鏉$爜骞跺彂璧锋墸娆� + */ + public static String OFFLINEB2CPAYURL = PROD_URL + "/gapi/aggregate/aggregatepay/offline/b2c/pay"; + /** + * 涓嬪崟缁撴灉鏌ヨ + * 鐢ㄤ簬涓嬪崟缁撴灉鐨勭姸鎬佺‘璁や笌璁㈠崟淇℃伅鏌ヨ + */ + public static String TRADE_QUERY_URL = PROD_URL + "/gapi/aggregate/aggregatepay/tradeQuery"; + /** + * 閫�娆� + * 澶栭儴鍟嗘埛骞冲彴鍙戣捣鐨勮鍗曢��娆� + */ + public static String OFFLINE_REFUND_URL = PROD_URL + "/gapi/o2o/aggregatePay/services/offlineRefund"; +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/ServiceConstants.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/ServiceConstants.java new file mode 100644 index 0000000..97d226b --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/ServiceConstants.java @@ -0,0 +1,136 @@ +package com.nuvole.constants; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * 澶栫綉鏈嶅姟璋冪敤 + * + * @Author: lc + * @Date: 2019/7/25 14:44 + */ +@Component +public class ServiceConstants { + + /** + * 瀵瑰鏄惁璧板缃戞湇鍔¤皟鐢ㄣ�恡rue 鏄� false 鍚︺�� + */ + public static Boolean SERVICE_TYPE; + + + @Value("${service-type}") + public void setType(Boolean type) { + SERVICE_TYPE = type; + } + + + /** + * 璋冪敤缁熶竴url + */ + public static final String SERVICE_URL = "http://localhost:9080"; + + /** + * 鍟嗘埛璁㈠崟鏌ヨ鎺ュ彛 + */ + public static final String MERCHANT_PAY_RESULT = SERVICE_URL + "/v1/web/pay/queryorder"; + + /** + * 鏌ヨ鐗╂祦鍦板潃 + */ + public static final String SERVICE_EXPRESS_URL = SERVICE_URL + "/v1/shop/web/express/queryExpress"; + + /** + * 閫嗗湴鍧�瑙f瀽锛堣吘璁湴鍥撅級 + */ + public static final String SERVICE_TENCENT_LOCATION_URL = SERVICE_URL + "/v1/shop/web/map/tencent/location"; + + /** + * 灏忕▼搴忔敮浠樺湴鍧� + */ + public static final String SERVICE_UNIFIED_URL = SERVICE_URL + "/v1/web/pay/miniProgramPay"; + + /** + * B鎵獵鏀粯鍦板潃 + */ + public static final String SERVICE_B_SWEEP_C_URL = SERVICE_URL + "/v1/web/pay/bSweepCPay"; + /** + * 鏍规嵁鎺堟潈鐮�(浠樻鐮�)鑾峰彇鐢ㄦ埛ID 鍦板潃 + */ + public static final String SERVICE_AUTHCODE2USERID_URL = SERVICE_URL + "/apiweb/unitorder/authcodetouserid"; + + /** + * b鎵玞鏀粯缁撴灉鏌ヨ鍦板潃 + */ + public static final String SERVICE_PAY_RESULT_URL = SERVICE_URL + "/v1/web/pay/bSweepCPayResult"; + + /** + * 鐭俊鍦板潃 + */ + public static final String SERVICE_SMS_URL = SERVICE_URL + "/v1/sms/sendSMS"; + + /** + * 寰俊jscode杞琒essionKey鍦板潃 + */ + public static final String SERVICE_JSCODE2SESSION_URL = SERVICE_URL + "/v1/sns/jscode2session"; + + /** + * 寰俊鑾峰彇AccessToken + */ + public static final String SERVICE_TOKEN_URL = SERVICE_URL + "/v1/cgi-bin/token"; + /** + * 寰俊鑾峰彇 jsapiTicket + */ + public static final String SERVICE_JSAPITICKET_URL = SERVICE_URL + "/v1/cgi-bin/jsapiTicket"; + + /** + * 寰俊鍏紬鍙疯幏鍙朼ccess_token + */ + public static final String SERVICE_ACCESS_TOKEN_URL = SERVICE_URL + "/v1/sns/oauth2/access_token"; + + /** + * 寰俊鍏紬鍙疯幏鍙栫敤鎴蜂俊鎭� + */ + public static final String SERVICE_USERINFO_URL = SERVICE_URL + "/v1/sns/userinfo"; + + /** + * 寰俊鑾峰彇灏忕▼搴忕爜锛堝墠鎻愭槸宸插彂甯冿級 + */ + public static final String SERVICE_WXACODEUNLIMIT_URL = SERVICE_URL + "/v1/wxa/getwxacodeunlimit"; + + /** + * 寰俊鎺ㄩ�佹秷鎭� + */ + public static final String SERVICE_TEMPLATE_SEND_URL = SERVICE_URL + "/v1/cgi-bin/message/wxopen/template/send"; + + /** + * 寰俊璁㈤槄娑堟伅-鎺ㄩ�� + */ + public static final String SERVICE_SUBSCRIBER_SEND_URL = SERVICE_URL + "/v1/cgi-bin/message/wxopen/subscribe/send"; + + /** + * 鍒楄〃瀵煎嚭 + */ + public static final String SERVICE_EXPORT_TABLE_URL = SERVICE_URL + "/v1/export/table"; + + /** + * 鏋佸厜鎺ㄩ�� + */ + public static final String SERVICE_JG_PUSH_URL = SERVICE_URL + "/v1/jg/push"; + + /** + * 鐧惧害璇煶 + */ + public static final String SERVICE_BAI_DU_API = SERVICE_URL + "/v1/merchant/app/baidu/api/speech"; + + /** + * 涓帹锛堝崟鎺級 + */ + public static final String SERVICE_GE_TUI_URL = SERVICE_URL + "/v1/gt/push"; + + /** + * 涓帹锛堟帹閫佷竴涓垪琛級 + */ + public static final String SERVICE_GE_TUI_LIST_URL = SERVICE_URL + "/v1/gt/pushList"; + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/SystemConstants.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/SystemConstants.java new file mode 100644 index 0000000..79f6a21 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/constants/SystemConstants.java @@ -0,0 +1,206 @@ +package com.nuvole.constants; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName SystemConstants + * @date 2019/4/24 17:07 + * @Description 绯荤粺鍏敤甯搁噺 + */ +public class SystemConstants { + + /** + * 缁煎悎鍚庡彴鐢ㄦ埛榛樿瀵嗙爜 + */ + public static final String USER_KEY = "Adu_8097"; + + /** + * 鍟嗘埛鍚庡彴鐢ㄦ埛榛樿瀵嗙爜 + */ + public static final String MERCHANT_USER_K = "Sel_8099"; + + /** + * 绉垎鎶垫墸榛樿鍊硷紙鍒嗭級 + */ + public static final Long INTEGRAL_DEDUCTION_VAL = 100L; + + /** + * 绉垎鎶垫墸浠峰�糼ey + */ + public static final String INTEGRAL_DEDUCATION = "deducation"; + + /********************************************** 鐧诲綍鏍囪瘑 ************************************/ + /** + * 缁熶竴鍚庡彴pc瑙掕壊api + */ + public static final String BASE_PC_ROLE_API_PREFIX = "basePcRoleApi:"; + /** + * 缁熶竴鍚庡彴pc瑙掕壊 rest api + */ + public static final String BASE_PC_ROLE_RESTAPI_PREFIX = "basePcRoleRestApi:"; + /** + * 鍟嗘埛pc瑙掕壊api + */ + public static final String MERCHANT_PC_ROLE_API_PREFIX = "merchantPcRoleApi:"; + /** + * 鍟嗘埛pc瑙掕壊 rest api + */ + public static final String MERCHANT_PC_ROLE_RESTAPI_PREFIX = "merchantPcRoleRestApi:"; + /** + * 缁熶竴鍚庡彴pc鐧诲綍鏍囪瘑 + */ + public static final String BASE_PC_USER_PREFIX = "basePcUser:"; + + /** + * 鍟嗘埛pc鐧诲綍鏍囪瘑 + */ + public static final String MERCHANT_PC_USER_PREFIX = "merchantPcUser:"; + public static final String SUPPLIER_PC_USER_PREFIX = "supplierPcUser:"; + + /** + * 鍟嗘埛app鐧诲綍鏍囪瘑 + */ + public static final String MERCHANT_APP_USER_PREFIX = "merchantAppUser:"; + + /** + * 鍟嗗煄寰俊鐧诲綍鏍囪瘑锛堝寘鍚晢鎴稨5锛� + */ + public static final String SHOP_WECHAT_USER_PREFIX = "shopWechatUser:"; + + /** + * 瀹㈡埛缁忕悊app鐧诲綍鏍囪瘑 + */ + public static final String MANAGER_APP_USER_PREFIX = "managerAppUser:"; + + /** + * 鎵爜浠樻巿鏉冪櫥褰曟爣璇� + */ + public static final String SCAN_WECHAT_USER_PREFIX = "scanWechatUser:"; + + + /********************************************** token header鏍囪瘑 ************************************/ + + /** + * 缁煎悎pc token header 鏍囪瘑 + */ + public static final String BASE_PC_TOKEN_HEADER = "BASE-PC-TOKEN-HEADER"; + + /** + * 鍟嗘埛pc token header 鏍囪瘑 + */ + public static final String MERCHANT_PC_TOKEN_HEADER = "MERCHANT-PC-TOKEN-HEADER"; + + /** + * 渚涜揣鍟� + */ + public static final String SUPPLIER_PC_TOKEN_HEADER = "SUPPLIER-PC-TOKEN-HEADER"; + + /** + * 鍟嗘埛app token header 鏍囪瘑 + */ + public static final String MERCHANT_APP_TOKEN_HEADER = "MERCHANT-APP-TOKEN-HEADER"; + + /** + * 鍟嗗煄寰俊 token header 鏍囪瘑锛堝寘鍚晢鎴稨5锛� + */ + public static final String SHOP_WECHAT_TOKEN_HEADER = "SHOP-WECHAT-TOKEN-HEADER"; + + /** + * 瀹㈡埛缁忕悊app token header 鏍囪瘑 + */ + public static final String MANAGER_APP_TOKEN_HEADER = "MANAGER-APP-TOKEN-HEADER"; + + /** + * 鍟嗘埛鎵爜浠樺井淇� token header 鏍囪瘑锛堝寘鍚晢鎴稨5锛� + */ + public static final String SCAN_WECHAT_TOKEN_HEADER = "SCAN-WECHAT-TOKEN-HEADER"; + + + /********************************************** 瀵煎嚭鏍囪瘑 ************************************/ + + /* + * @Author : liu.q [916000612@qq.com] + * @Date : 2019-07-18 15:11 + * @Description : 瀵煎嚭鍔犲瘑绛惧悕-鏍囪瘑 + */ + public static final String EXPORT_SIGN_K = "bc29ru982ur8923jr923hr9y2389"; + /* + * @Author : liu.q [916000612@qq.com] + * @Date : 2019-07-18 15:11 + * @Description : 瀵煎嚭鏁版嵁缂撳瓨key 寮�澶� + */ + public static final String EXPORT_DATA_K = "exportDataK:"; + + /********************************************** 閭嫾鍥㈡爣璇� ************************************/ + + /** + * 鍥㈣喘鏀粯瓒呮椂鏃堕棿key + */ + public static final String GROUP_PAY_TIMEOUT = "groupPayTimeout"; + + /** + * 鍥㈣喘鎴愬洟瓒呮椂鏃堕棿key + */ + public static final String GROUP_COMPLETE_TIMEOUT = "groupCompleteTimeout"; + + /** + * 鍥㈣喘瑙勬牸key + */ + public static final String GROUP_RULE = "groupRule"; + + /********************************************** 鍟嗗煄璁剧疆鏍囪瘑 ************************************/ + + /** + * 鍟嗗搧鏀粯鏃堕棿璁剧疆key + */ + public static final String PAY_TIMEOUT = "pay_timeout"; + + /** + * 鏀惰揣鏃堕棿璁剧疆key + */ + public static final String RECEIVING_TIMEOUT = "receiving_timeout"; + /** + * 鏃ュ織瀹氭椂娓呯悊璁剧疆 + */ + public static final String LOG_CLEAN_TIME = "logCleanTime"; + /** + * 瀹㈡埛鑺傝鍒欒缃甼ey + */ + public static final String MEMBER_DAY_RULE = "member_day_rule"; + + /** + * 鍗曟鎻愮幇閲戦涓嶄綆浜� + */ + public static final String DRAW_CASH_EACH_MIN_RULE = "draw_cash_each_min"; + /** + * 姣忓ぉ鎻愮幇閲戦涓嶈秴杩� + */ + public static final String DRAW_CASH_DAY_MAX_RULE = "draw_cash_day_max"; + /** + * 浼氬憳鏃ユ椿鍔ㄨ鍒� + */ + public static final String MEMBER_FLASH_ACT_RULE = "member_flash_act_rule"; + /** + * 浼氬憳鏃ユ椿鍔ㄥ弬涓庡璞� + */ + public static final String MEMBER_FLASH_ACT_JOIN_OBJ = "MEMBER_FLASH_ACT_JOIN_OBJ"; + /** + * 鏄熺骇鏉冪泭娲诲姩瑙勫垯 + */ + public static final String STAR_POWER_ACT_RULE = "star_power_act_rule"; + public static final String STAR_POWER_ACT_JOIN_OBJ = "star_power_act_join_obj"; + + /* + 搴旂敤骞冲彴绫诲瀷(涓夋柟骞冲彴缁戝畾鐢ㄦ埛浣跨敤) + appType 1.鏀粯瀹�-灏忕▼搴�, 2.鏀粯瀹�-鐢熸椿鍙�, 3.寰俊-灏忕▼搴�, 4.寰俊-鍏紬鍙� + */ + /** 搴旂敤骞冲彴绫诲瀷-鏀粯瀹�-灏忕▼搴� */ + public static final String APP_TYPE_ALI_MINI = "1"; + /** 搴旂敤骞冲彴绫诲瀷-鏀粯瀹�-鐢熸椿鍙� */ + public static final String APP_TYPE_ALI_SHH = "2"; + /** 搴旂敤骞冲彴绫诲瀷-寰俊-灏忕▼搴� */ + public static final String APP_TYPE_WECHAT_MINI = "3"; + /** 搴旂敤骞冲彴绫诲瀷-寰俊-鍏紬鍙� */ + public static final String APP_TYPE_WECHAT_GZH = "4"; + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/conf/NxPayConfig.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/conf/NxPayConfig.java new file mode 100644 index 0000000..3eef6a1 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/conf/NxPayConfig.java @@ -0,0 +1,199 @@ +package com.nuvole.hnnx.conf; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.date.format.FastDateFormat; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.Method; +import com.nuvole.hnnx.hnnxPay.HnnxConstant; +import com.nuvole.hnnx.hnnxPay.KeyMetadata; +import com.nuvole.hnnx.hnnxPay.KeyRegistry; +import com.nuvole.hnnx.hnnxPay.KeyRegistryImpl; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Component; + +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.security.Key; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * @ClassName NxPayConfig + * @Author cy + * @Date 2023/10/5 + * @Description + * @Version 1.0 + **/ +//@ConditionalOnProperty(name = "offLinePay.hnnx", havingValue = "true") +@Data +@PropertySource("classpath:hnnx.properties") +@ConfigurationProperties(prefix = "hnnx") +@Component +public class NxPayConfig { + private String merNbr; + private String url; + private String appCode; + private String certPath; + private String certPwd; + private String pubKey; + private String platSubMerchantId; + private String branchId; + public static final String KEYSTORE_TYPE = "PKCS12"; // 绉侀挜绫诲瀷 +// private static String keyPath = "C:\\Users\\cy\\Desktop\\merchant-rsa.pfx"; // 绉侀挜瀹瑰櫒璺緞 +// private static String cardPwdAlias = "HNNX"; // 绉侀挜璇佷功鍒悕 + /** + * 蹇嵎鏀粯鍏挜 + */ + private String kjUrl; + private String kjMerNbr; + + @Bean(name = "nxPayPrivateKey") + public PrivateKey payPrivateKey() { + KeyRegistry keyRegistry = new KeyRegistryImpl(); + KeyMetadata keyMetadata = new KeyMetadata("nxPay", certPath, certPwd, null, certPwd); + System.out.println(keyMetadata); + Key privatekey = keyRegistry.getKey(keyMetadata); + System.out.println(privatekey); + return (PrivateKey) privatekey; + } + + @Bean(name = "nxPayPublicKey") + public PublicKey payPublicKey() { + BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(("-----BEGIN CERTIFICATE-----\n" + pubKey + "\n-----END CERTIFICATE-----\n").getBytes())); + Certificate certificate = null; + CertificateFactory cf = null; + try { + cf = CertificateFactory.getInstance("X.509"); + certificate = cf.generateCertificate(bis); + return certificate.getPublicKey(); + } catch (CertificateException e) { + e.printStackTrace(); + } + return null; + } + private String kjPubKey; + private String kjCertPath; + private String kjCertPwd; + private String kjPlatSubMerchantId; + +// public static void main(String[] args) throws Exception { +// InputStream key = new FileInputStream(keyPath); +// KeyStore ks = KeyStore.getInstance(KEYSTORE_TYPE); +// ks.load(key, cardPwdAlias.toCharArray()); +// Enumeration<String> keyAlias = ks.aliases(); +// PrivateKey privateKey = null; +// while (keyAlias.hasMoreElements()) { +// String nextElement = keyAlias.nextElement(); +// boolean keyEntryFlag = ks.isKeyEntry(nextElement); +// if (keyEntryFlag) { +// privateKey = (PrivateKey) ks.getKey(nextElement, cardPwdAlias.toCharArray()); +// break; +// } +// } +// +// +// } + + @Bean(name = "nxKjPayPrivateKey") + public PrivateKey nxKjPayPrivateKey() throws Exception { + KeyRegistry keyRegistry = new KeyRegistryImpl(); + KeyMetadata keyMetadata = new KeyMetadata("nxKjPay", kjCertPath, kjCertPwd, null, kjCertPwd); + Key privatekey = keyRegistry.getKey(keyMetadata); + return (PrivateKey) privatekey; +// InputStream key = new FileInputStream(keyPath); +// KeyStore ks = KeyStore.getInstance(KEYSTORE_TYPE); +// ks.load(key, cardPwdAlias.toCharArray()); +// Enumeration<String> keyAlias = ks.aliases(); +// PrivateKey privateKey = null; +// while (keyAlias.hasMoreElements()) { +// String nextElement = keyAlias.nextElement(); +// boolean keyEntryFlag = ks.isKeyEntry(nextElement); +// if (keyEntryFlag) { +// privateKey = (PrivateKey) ks.getKey(nextElement, cardPwdAlias.toCharArray()); +// break; +// } +// } +// return privateKey; + + } + + @Bean(name = "nxKjPayPublicKey") + public PublicKey nxKjPayPublicKey() { + BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(("-----BEGIN CERTIFICATE-----\n" + kjPubKey + "\n-----END CERTIFICATE-----\n").getBytes())); + Certificate certificate = null; + CertificateFactory cf = null; + try { + cf = CertificateFactory.getInstance("X.509"); + certificate = cf.generateCertificate(bis); + return certificate.getPublicKey(); + } catch (CertificateException e) { + e.printStackTrace(); + } + return null; + } + + + // @Bean(name = "nxPayHttpClient") + public HttpRequest getPayCloseableHttpClient() { + HttpRequest postRequest = new HttpRequest(url).method(Method.POST); + String charset = CharsetUtil.CHARSET_UTF_8.toString(); + postRequest.header("appCode", appCode); + postRequest.header("version", "1.0"); + postRequest.header("charset", charset); + postRequest.header("algorithm", HnnxConstant.ALGORITHM); + postRequest.header("deviceId", HnnxConstant.DEVICEID); + postRequest.header("channelId", HnnxConstant.CHANNELID); + postRequest.header("sequenceId", getSequenceId()); + return postRequest; + } + + /** + * 璇锋眰搴忓垪鍙枫�愭笭閬撶浜х敓锛屼竴绗斾笟鍔$殑鍞竴鏍囪瘑锛岃疮绌挎暣涓氦鏄撳缁堛�戞笭閬撲唬鐮侊紙2浣嶏級+鏃ユ湡锛坹yMMdd 6浣嶏級+娴佹按鍙凤紙24浣嶏紝appCode+鍓╀綑浣嶆暟娴佹按鍙凤級 + * + * @return + */ + private String getSequenceId() { + StringBuilder sequenceIdSb = new StringBuilder(); + sequenceIdSb.append(HnnxConstant.CHANNELID) + .append(DateUtil.format(new Date(), FastDateFormat.getInstance("yyMMdd"))) + .append(appCode); + int length = 32 - sequenceIdSb.length(); + + String timeTemp = System.currentTimeMillis() + ""; + while (length > 0) { + if (length > timeTemp.length()) { + sequenceIdSb.append(timeTemp); + } else { + sequenceIdSb.append(timeTemp.substring(0, length)); + } + length = 32 - sequenceIdSb.length(); + } + return sequenceIdSb.toString(); + } + + public Map getHeadMap(String sequenceId, String timestamp, String branchId) { + Map headMap = new HashMap<>(); + String charset = CharsetUtil.CHARSET_UTF_8.toString(); + headMap.put("appCode", appCode); + headMap.put("version", "1.0"); + headMap.put("charset", charset); + headMap.put("algorithm", HnnxConstant.ALGORITHM); + headMap.put("deviceId", HnnxConstant.DEVICEID); + headMap.put("channelId", HnnxConstant.CHANNELID); + headMap.put("sequenceId", sequenceId); + headMap.put("timestamp", timestamp); +// headMap.put("transCode", transCode); + headMap.put("branchId", branchId); + return headMap; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/HnnxConstant.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/HnnxConstant.java new file mode 100644 index 0000000..a12e0e4 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/HnnxConstant.java @@ -0,0 +1,85 @@ +package com.nuvole.hnnx.hnnxPay; + +/** + * @ClassName HnnxConstant + * @Author cy + * @Date 2023/10/5 + * @Description + * @Version 1.0 + **/ +public class HnnxConstant { + + /** + * 鍐滀俊鍙兘璁剧疆涓�涓洖璋� + */ + public static String ALL_CALL_BACK = "/v1/web/payBack/nx/allBack"; + /** + * 鐢ㄦ埛琚壂鏀粯 + */ + public static String TRANS_CODE_CORETOALL_PAY = "hnnx.trade.sandbox.upp.coretoall"; + + /** + * 閫氱敤閫�璐� + */ + public static String TRANS_CODE_RETURNTRANS_PAY = "hnnx.trade.sandbox.upp.returntrans"; + + /** + * 棰勬敮浠� + */ + public static String TRANS_CODE_QRCODEPREPAY_PAY = "hnnx.trade.sandbox.upp.qrCodePrePay"; + + /** + * 鐢ㄦ埛涓诲姩鎵爜鐢熸垚 + */ + public static String TRANS_CODE_DYACTIVEQRCODE_PAY = "hnnx.trade.sandbox.upp.dyActiveQrCode"; + /** + * 璁㈠崟浜ゆ槗鐘舵�佹煡璇� + */ + public static String TRANS_CODE_QRYQRORDERSTATUS_PAY = "hnnx.trade.sandbox.upp.qryQrOrderStatus"; + + /** + * 瀵硅处鏌ヨ + */ + public static String TRANS_CODE_ACCOUNTQRY_PAY = "hnnx.trade.sandbox.upp.accountqry"; + /** + * 甯佺 + */ + public static String CURRENCYCD = "CNY"; + + /** + * 鍔犲瘑绠楁硶 + */ + public static String ALGORITHM = "SHA256withRSA"; + /** + * 鍐滀俊蹇嵎鍙兘璁剧疆涓�涓洖璋� + */ + public static String NX_KJ_ALL_CALL_BACK = "/v1/web/payBack/nxKj/allBack"; + /** + * 鍐滀俊蹇嵎鏀粯鍓嶇鍥炶皟URL + */ + public static String NX_KJ_FRONT_URL ="https://jmy.jinmingyuan.com/payTest/pages/pay/paySuccess?orderId=${ORDERID}&youHuiInfo=${YOUHUIINFO}"; + /** + * 鍐滀俊蹇嵎鏀粯鍔犲瘑绠楁硶 + */ + public static String KJ_ALGORITHM = "SHA1WithRSA"; + //浜ゆ槗娓犻亾鍙�:45 + public static String CHANNELID = "45"; + //閫佷釜瀹氬�煎嵆鍙� + public static String DEVICEID = "JMY"; + //鍦板尯淇℃伅 + public static String AREAINFO = "1564960"; + + + /** + * 鍐滀俊蹇嵎鏀粯url + */ + public static String QUICK_PAY_URL = "/pmPay/quickPayRequest.do"; + /** + * 璁㈠崟鏌ヨ + */ + public static String QUICK_PAY_QUERY_URL = "/common/orderQuery.do"; + /** + * 閫�娆� + */ + public static String QUICK_PAY_RETURN_URL = "/common/returnTrans.do"; +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyMetadata.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyMetadata.java new file mode 100644 index 0000000..3c4f5f3 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyMetadata.java @@ -0,0 +1,52 @@ +package com.nuvole.hnnx.hnnxPay; + +/** + * @author awlwen + * @since 2017/11/30 + */ +public class KeyMetadata { + private String id; + private String file; + private String keyStorePassword; + private String keyAlias; + private String keyPassword; + public KeyMetadata() { + } + public KeyMetadata(String id, String file, String keyStorePassword, String keyAlias, String keyPassword) { + this.id = id; + this.file = file; + this.keyStorePassword = keyStorePassword; + this.keyAlias = keyAlias; + this.keyPassword = keyPassword; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getFile() { + return file; + } + public void setFile(String file) { + this.file = file; + } + public String getKeyStorePassword() { + return keyStorePassword; + } + public void setKeyStorePassword(String keyStorePassword) { + this.keyStorePassword = keyStorePassword; + } + public String getKeyAlias() { + return keyAlias; + } + public void setKeyAlias(String keyAlias) { + this.keyAlias = keyAlias; + } + public String getKeyPassword() { + return keyPassword; + } + public void setKeyPassword(String keyPassword) { + this.keyPassword = keyPassword; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyProvider.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyProvider.java new file mode 100644 index 0000000..b766157 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyProvider.java @@ -0,0 +1,14 @@ +package com.nuvole.hnnx.hnnxPay; + +import java.security.Key; +import java.security.cert.Certificate; + +/** + * @author awlwen + * @since 2017/11/30 + */ +public interface KeyProvider { + Key getKey(String id, String password); + Certificate getCertificate(String id); + Certificate[] getCertificateChain(String id); +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyProviderImpl.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyProviderImpl.java new file mode 100644 index 0000000..0511bf7 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyProviderImpl.java @@ -0,0 +1,173 @@ +package com.nuvole.hnnx.hnnxPay; + +import org.springframework.core.io.ClassPathResource; +import org.springframework.util.Assert; + +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.security.Key; +import java.security.KeyStore; +import java.security.cert.Certificate; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +/** + * @author awlwen + * @since 2017/11/30 + */ +public class KeyProviderImpl implements KeyProvider { + private static final Map<String, String> SUPPORTED_KEY_TYPE = new HashMap<String, String>(); + + static { + SUPPORTED_KEY_TYPE.put("ks", "jks"); + SUPPORTED_KEY_TYPE.put("jks", "jks"); + SUPPORTED_KEY_TYPE.put("pfx", "pkcs12"); + SUPPORTED_KEY_TYPE.put("p12", "pkcs12"); + } + + /** + * 瀵嗛挜瀹瑰櫒鏂囦欢璺緞 + */ + private String file; + /** + * 瀵嗛挜瀹瑰櫒瀵嗙爜 + */ + private String password; + /** + * 瀵嗛挜瀹瑰櫒 + */ + private KeyStore keystore; + /** + * 鍒濆鍖栨爣蹇� + */ + private boolean initialized = false; + + /** + * 鏋勯�犲櫒 + * + * @param file 瀵嗛挜瀹瑰櫒鏂囦欢璺緞 + * @param password 瀵嗛挜瀹瑰櫒瀵嗙爜 + */ + public KeyProviderImpl(String file, String password) { + super(); + Assert.notNull(file, "file is required; it must not be null"); + init(file, password); + } + + /** + * 鏍规嵁鏂囦欢鎵╁睍鍚嶈幏鍙栧瘑閽ュ鍣ㄧ被鍨� + * + * @param file + * @return + */ + private String resolveType(String file) { + Assert.notNull(file, "file is required; it must not be null"); + String suffix = file.substring(file.lastIndexOf(".") + 1); + Assert.notNull(suffix, "suffix could not be resolved"); + String supportedType = SUPPORTED_KEY_TYPE.get(suffix.toLowerCase()); + Assert.notNull(supportedType, "unsupported key type"); + return supportedType; + } + + /** + * 鍒濆鍖栵紝鍔犺浇瀵嗛挜瀹瑰櫒 + * + * @param file 瀵嗛挜瀹瑰櫒鏂囦欢璺緞 + * @param password 瀵嗛挜瀹瑰櫒瀵嗙爜 + */ + private void init(String file, String password) { + InputStream is = null; + try { + //寤虹珛鏂囦欢杈撳叆娴佽鍙栧瘑閽ュ鍣� + if (file.startsWith("classpath:")) { + is = new ClassPathResource(file.replace("classpath:", "")).getInputStream(); + } else { + is = new BufferedInputStream(new FileInputStream(file)); + } + + //鏍规嵁鏂囦欢鎵╁睍鍚嶅缓绔嬬浉搴旂殑瀵嗛挜瀹瑰櫒绫诲瀷 + keystore = KeyStore.getInstance(resolveType(file)); + //灏嗗瘑閽ュ鍣ㄥ瘑鐮佽浆鎹负char鏁扮粍 + char[] pwd = password == null ? null : password.toCharArray(); + //浠庢寚瀹氱殑杈撳叆娴佷腑鍔犺浇瀵嗛挜瀹瑰櫒 + keystore.load(is, pwd); + initialized = true; + } catch (Exception ex) { + throw new RuntimeException(ex); + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } + } + } + + /* (non-Javadoc) + * @see com.csii.sg.security.KeyProvider#getKey(java.lang.String, java.lang.String) + */ + public Key getKey(String id, String password) { + Assert.isTrue(initialized, "keyProvider not been initialized"); + try { + if (id == null) { + Enumeration<String> aliases = keystore.aliases(); + for (int count = 0; aliases.hasMoreElements(); count++) { + if (count > 1) { + throw new IllegalArgumentException("key id not specified"); + } + String alias = aliases.nextElement(); + if (keystore.isKeyEntry(alias)) { + id = alias; + } + } + } + char[] pwd = password == null ? null : password.toCharArray(); + return keystore.getKey(id, pwd); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + /* (non-Javadoc) + * @see com.csii.sg.security.KeyProvider#getCertificate(java.lang.String) + */ + public Certificate getCertificate(String id) { + Assert.isTrue(initialized, "keyProvider not been initialized"); + try { + return keystore.getCertificate(id); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + /* (non-Javadoc) + * @see com.csii.sg.security.KeyProvider#getCertificateChain(java.lang.String) + */ + public Certificate[] getCertificateChain(String id) { + Assert.isTrue(initialized, "keyProvider not been initialized"); + try { + return keystore.getCertificateChain(id); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + /** + * @param file the file to set + */ + public void setFile(String file) { + this.file = file; + } + + /** + * @param password the password to set + */ + public void setPassword(String password) { + this.password = password; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyRegistry.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyRegistry.java new file mode 100644 index 0000000..63dedbd --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyRegistry.java @@ -0,0 +1,13 @@ +package com.nuvole.hnnx.hnnxPay; + +import java.security.Key; +import java.security.cert.Certificate; + +/** + * @author awlwen + * @since 2017/11/30 + */ +public interface KeyRegistry { + Key getKey(KeyMetadata metadata); + Certificate getCertificate(String base64); +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyRegistryImpl.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyRegistryImpl.java new file mode 100644 index 0000000..27d75d8 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/KeyRegistryImpl.java @@ -0,0 +1,62 @@ +package com.nuvole.hnnx.hnnxPay; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.Assert; + +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.security.Key; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * @author awlwen + * @since 2017/11/30 + */ +public class KeyRegistryImpl implements KeyRegistry { + private Map<String, Key> cache = new ConcurrentHashMap<>(); + private Logger logger = LoggerFactory.getLogger(this.getClass()); + private volatile boolean sync = false; + @Override + public Key getKey(KeyMetadata metadata) { + Assert.notNull(metadata, "[Assertion failed] - metadata is required; it must not be null"); + Key key = cache.get(metadata.getId()); + if (key == null || sync) { + key = getKeyInternal(metadata); + cache.put(metadata.getId(), key); + } + return key; + } + @Override + public Certificate getCertificate(String base64) { + Assert.hasText(base64, "[Assertion failed] - base64 must have text; it must not be null, empty, or blank"); + BufferedInputStream is = null; + try { + is = new BufferedInputStream(new ByteArrayInputStream(base64.trim().getBytes())); + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + Certificate cert = cf.generateCertificate(is); + return cert; + } catch (CertificateException ex) { + throw new RuntimeException(ex); + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException ex) { + logger.error("close stream error.", ex); + } + } + } + } + private Key getKeyInternal(KeyMetadata metadata) { + KeyProvider provider = new KeyProviderImpl(metadata.getFile(), metadata.getKeyStorePassword()); + Key key = provider.getKey(metadata.getKeyAlias(), metadata.getKeyPassword()); + Assert.notNull(key, "[Assertion failed] - key must not be null"); + return key; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/NXHttpClientUtils.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/NXHttpClientUtils.java new file mode 100644 index 0000000..0df872b --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/NXHttpClientUtils.java @@ -0,0 +1,778 @@ +package com.nuvole.hnnx.hnnxPay; + +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.parser.Feature; +import com.csii.sg.codec.Hex; +import com.csii.sg.security.ValidationException; +import com.csii.sg.security.impl.Permutation; +import com.csii.sg.security.impl.SignatureVerifier; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.nuvole.hnnx.conf.NxPayConfig; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.util.Base64; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * @ClassName HttpClientUtils + * @Author cy + * @Date 2023/9/27 + * @Description + * @Version 1.0 + **/ + +@Component +@Slf4j +//@ConditionalOnClass(name = "com.nuvole.hnnx.conf.NxPayConfig") +public class NXHttpClientUtils { + @Autowired + private PrivateKey nxPayPrivateKey; + @Autowired + private PrivateKey nxKjPayPrivateKey; + + @Autowired + private PublicKey nxPayPublicKey; + @Autowired + private PublicKey nxKjPayPublicKey; + + @Autowired + private NxPayConfig nxPayConfig; + + private static SignatureSigner signable = new SignatureSigner(); + + private static SignatureVerifier verifier = new SignatureVerifier(); + + public String getPlatSubMerchantId() { + return nxPayConfig.getPlatSubMerchantId(); + } + + public String getKjPlatSubMerchantId() { + return nxPayConfig.getKjPlatSubMerchantId(); + } + + public String getBranchId() { + return nxPayConfig.getBranchId(); + } + + + /** + * 鍒嗚浆涓哄厓 + * + * @param payMoney + * @return + */ + public static BigDecimal convertToYuan(long payMoney) { + BigDecimal totalAmount = new BigDecimal("" + payMoney).divide(new BigDecimal("100")); + return totalAmount; + } + + public static void writeToFile(String sign, String plainStr) { + File file = new File("D:\\dev_nginx-1.18.0\\html\\testNetPay4.html"); + + String content = "<!DOCTYPE html>\n" + + "<html lang=\"en\">\n" + + "<head>\n" + + " <meta charset=\"UTF-8\">\n" + + " <title>Title</title>\n" + + "\n" + + "</head>\n" + + "<body>\n" + + "\n" + + "</body>\n" + + "<script>\n" + +// " var url = \"http://221.176.112.3:8006/pmPay/pmPay/quickPayRequest.do\";\n" + + " var url = \"http://https://pay.hnnx.com/pmPay/pmPay/quickPayRequest.do\";\n" + + " var data ={\n" + + " \"deviceType\":\"5\",\n" + + " \"signature\": \"" + sign + "\",\n" + + " \"plain\": JSON.stringify(" + plainStr + ")\n" + + " }\n" + + " post(url, data);\n" + + " var myForm;\n" + + "\n" + + " function post(URL, pram) {\n" + + " var temp = document.createElement(\"form\");\n" + + " temp.action = URL;\n" + + " temp.method = \"post\";\n" + + " temp.style.display = \"none\";\n" + + " for (var x in pram) {\n" + + " var opt = document.createElement(\"textarea\");\n" + + " opt.name = x;\n" + + " opt.value = pram[x];\n" + + " // alert(opt.name)\n" + + " temp.appendChild(opt);\n" + + " }\n" + + " document.body.appendChild(temp);\n" + + " temp.submit();\n" + + "// myForm=temp;\n" + + " }\n" + + "</script>\n" + + "</html>\n"; + + try (FileWriter writer = new FileWriter(file)) { + writer.write(content); + System.out.println("鍐呭鎴愬姛鍐欏叆鏂囦欢銆�"); + } catch (IOException e) { + System.err.println("鍐欏叆鏂囦欢鏃跺彂鐢熼敊璇細" + e.getMessage()); + } + } + + public static void writeToFile(String url) { + File file = new File("D:\\dev_nginx-1.18.0\\html\\redirect1.html"); + + String content = "<!DOCTYPE html>\n" + + "<html>\n" + + "<head>\n" + + " <meta http-equiv=\"refresh\" content=\"0; URL='" + url + + "'\" />\n" + + "</head>\n" + + "<body>\n" + + " <h1>姝e湪璺宠浆锛岃绋嶇瓑...</h1>\n" + + "</body>\n" + + "</html>\n"; + + try (FileWriter writer = new FileWriter(file)) { + writer.write(content); + System.out.println("鍐呭鎴愬姛鍐欏叆鏂囦欢銆�"); + } catch (IOException e) { + System.err.println("鍐欏叆鏂囦欢鏃跺彂鐢熼敊璇細" + e.getMessage()); + } + } + + /** + * 鍔犵鏂规硶 + * + * @param headerMap 鍔犲瘑鎶ユ枃澶� + * @param payloadJson 鍔犲瘑鎶ユ枃浣� + * @return + */ + public String sign(Map headerMap, String payloadJson) { + log.info("----------- 绛惧悕寮�濮� ----------- "); + log.info("璇锋眰鍙傛暟payloadJson:{}", payloadJson); + ObjectMapper objectMapper = new ObjectMapper(); + String palin = null; + try { + if (payloadJson != null) { + Map payloadMap = objectMapper.readValue(payloadJson, Map.class); + headerMap.putAll(payloadMap); + } + palin = Permutation.sort(headerMap, "UTF-8"); + log.info("寰呯鍚嶅瓧绗︿覆锛歿}", palin); + } catch (Exception e) { + e.printStackTrace(); + } + String sign = signable.sign(palin, nxPayPrivateKey); + log.info("绛惧悕缁撴灉:{}", sign); + log.info("----------- 绛惧悕缁撴潫 ----------- "); + return sign; + } + + public String kjSign(String palin) { + log.info("----------- 绛惧悕寮�濮� ----------- "); + log.info("璇锋眰鍙傛暟 palin:{}", palin); + String sign = signable.kjSign(palin, nxKjPayPrivateKey).replaceAll("\\s", ""); + log.info("绛惧悕缁撴灉:{}", sign); + log.info("----------- 绛惧悕缁撴潫 ----------- "); + return sign; + } + + // 鍥炶皟閫氱煡鏍¢獙 + public boolean notifyRespVerify(String notifyParam) { + log.info("鍥炶皟閫氱煡楠岀 body 涓�: {}", notifyParam); + int signIndex = notifyParam.lastIndexOf("&signature="); + + if (signIndex == -1) { + return false; + } + + String palin = notifyParam.substring(0, signIndex); + String sign = notifyParam.substring(signIndex).replace("&signature=", ""); + + boolean verfiy = false; + try { + verfiy = verifier.verify(HnnxConstant.ALGORITHM, palin.getBytes(), Hex.toByte(sign), nxPayPublicKey); + } catch (ValidationException e) { + e.printStackTrace(); + } + + if (verfiy) { + log.info("杩斿洖鍊奸獙绛� 缁撴灉锛歿}", verfiy); + } else { + log.error("杩斿洖鍊奸獙绛� 缁撴灉锛歿}", verfiy); + } + log.info("----------- 杩斿洖鍊奸獙绛� 缁撴潫 ----------- "); + return verfiy; + } + + public String sendForm(HttpRequest nxPayHttpClient, HashMap<String, Object> payLoadMap) { + log.info("transCode : {}", nxPayHttpClient.header("transCode")); + Map headerMap = nxPayConfig.getHeadMap(nxPayHttpClient.header("sequenceId"), nxPayHttpClient.header("timestamp"), nxPayHttpClient.header("branchId")); + HashMap<String, Object> formData = new HashMap<>(); + formData.put("payload", JSONObject.toJSONString(payLoadMap)); + // 鍙婂叿浣撴帴鍙g殑璇锋眰鎶ユ枃鏋勬垚銆� + log.info("璇锋眰澶�: {}", JSONObject.toJSONString(headerMap)); + formData.put("signature", sign(headerMap, (String) formData.get("payload"))); + log.info("璇锋眰鍙傛暟: {}", JSONObject.toJSONString(formData)); + HttpResponse httpResponse = nxPayHttpClient.form(formData).execute(); + String body = httpResponse.body(); + verify(body); + return body; + } + + /** + * 棰勬敮浠� + * 鍙互瀹炵幇鐢ㄦ埛鍒版敮浠樺疂鎴栧井淇$殑棰勬敮浠樺姛鑳姐�� + * + * @param subMerchantId 浜岀骇鍟嗘埛鍙� + * @param branchId 浜ゆ槗鏈烘瀯鍙� + * @param merSeqNbr 鍟嗘埛鎬讳氦鏄撴祦姘村彿 + * @param transAmt 浜ゆ槗鎬婚噾棰� + * @param timeStamp 鍟嗘埛浜ゆ槗鏃堕棿 + * @param channelNbr 娓犻亾缂栧彿 01-O2O 02-B2C 03-鎵爜 + * @param payTypCd B-鏀粯瀹濇壂鐮佹敮浠橈�燙-寰俊鎵爜鏀粯飥燚-閾惰仈鎵爜鏀粯 + * @param orderTitle 璁㈠崟鏍囬 + */ + public String qrCodePrePay(String subMerchantId, String branchId, String operatorId, String merSeqNbr, String authCode, long transAmt, String timeStamp, String channelNbr, char payTypCd, + String merUrl, String orderTitle) { + log.info("----------------- 棰勬敮浠� 寮�濮� 璁㈠崟鍙蜂负: {}锛岃鍗曢噾棰濅负:{}----------------- ", merSeqNbr, transAmt); + HttpRequest nxPayHttpClient = nxPayConfig.getPayCloseableHttpClient(); + //璇锋眰搴忓垪鍙枫�愭笭閬撶浜х敓锛屼竴绗斾笟鍔$殑鍞竴鏍囪瘑锛岃疮绌挎暣涓氦鏄撳缁堛�戞笭閬撲唬鐮侊紙2浣嶏級+鏃ユ湡锛坹yMMdd 6浣嶏級+娴佹按鍙凤紙24浣嶏紝appCode+鍓╀綑浣嶆暟娴佹按鍙凤級 +// String sequenceId = getSequenceId(timeStamp, nxPayConfig.getAppCode()); +// nxPayHttpClient.header("sequenceId", sequenceId); + nxPayHttpClient.header("timestamp", timeStamp); + nxPayHttpClient.header("transCode", HnnxConstant.TRANS_CODE_QRCODEPREPAY_PAY); + nxPayHttpClient.header("branchId", branchId); + + // 鎷兼帴涓氬姟鏁版嵁 + HashMap<String, Object> formData = new HashMap<>(); + // 涓�绾у晢鎴峰彿 + formData.put("MerNbr", nxPayConfig.getMerNbr()); + // 浜岀骇鍟嗘埛缂栧彿 + formData.put("SubMerchantId", subMerchantId); + //鍟嗘埛浜ゆ槗鏃堕棿 + formData.put("MerTransDateTime", timeStamp); + //浜ゆ槗鎬婚噾棰� + formData.put("TransAmt", convertToYuan(transAmt)); + formData.put("AuthCode", authCode); + + //娓犻亾缂栧彿 01-O2O 02-B2C 03-鎵爜 + formData.put("ChannelNbr", channelNbr); + //鏀粯鏂瑰紡 8-绾夸笂鏀粯瀹濇壂鐮佹敮浠橈��9-绾夸笂寰俊鎵爜鏀粯飥燗-绾夸笂閾惰仈鎵爜鏀粯飥燘-绾夸笅鏀粯瀹濇壂鐮佹敮浠橈�燙-绾夸笅寰俊鎵爜鏀粯飥燚-绾夸笅閾惰仈鎵爜鏀粯 + formData.put("PayTypCd", payTypCd); + formData.put("OrderTitle", orderTitle); + formData.put("CurrencyCd", "CNY"); + //寮傛閫氱煡Url + formData.put("MerUrl", merUrl); + //鎿嶄綔鍛� + formData.put("OperatorId", operatorId); + + //鏀粯璁㈠崟鍙� + formData.put("MerSeqNbr", merSeqNbr); + String body = sendForm(nxPayHttpClient, formData); + log.info("----------------- 棰勬敮浠� 缁撴潫 ----------------- "); + return body; + } + + /** + * 鐢ㄦ埛涓诲姩鎵爜鐢熸垚 + * 鐢ㄦ埛闇�瑕佹壂鎻忓晢鎴锋敹娆剧爜鍔ㄧ爜杩涜鏀粯鏃讹紝閫氳繃姝ゆ帴鍙g敓鎴愬晢鎴锋敹娆剧爜鍔ㄧ爜锛岀敓浜т笂鐜板湪寰俊涓绘壂鍔ㄧ爜宸茬粡鍋滄浣跨敤銆� + * + * @param subMerchantId 浜岀骇鍟嗘埛鍙� + * @param branchId 浜ゆ槗鏈烘瀯鍙� + * @param merSeqNbr 鍟嗘埛鎬讳氦鏄撴祦姘村彿 + * @param transAmt 浜ゆ槗鎬婚噾棰� + * @param timeStamp 鍟嗘埛浜ゆ槗鏃堕棿 + * @param channelNbr 娓犻亾缂栧彿 01-O2O 02-B2C 03-鎵爜 + * @param payTypCd B 鏀粯瀹濇壂鐮佹敮浠� C 寰俊鎵爜鏀粯 D 閾惰仈鎵爜鏀粯 + * @param orderTitle 璁㈠崟鏍囬 + */ + public String dyActiveQrCode(String subMerchantId, String branchId, String merSeqNbr, long transAmt, String timeStamp, String channelNbr, char payTypCd, + String merUrl, String orderTitle) { + log.info("----------------- 鐢ㄦ埛涓诲姩鎵爜鐢熸垚 寮�濮� 璁㈠崟鍙蜂负: {}锛岃鍗曢噾棰濅负:{}----------------- ", merSeqNbr, transAmt); + HttpRequest nxPayHttpClient = nxPayConfig.getPayCloseableHttpClient(); + //璇锋眰搴忓垪鍙枫�愭笭閬撶浜х敓锛屼竴绗斾笟鍔$殑鍞竴鏍囪瘑锛岃疮绌挎暣涓氦鏄撳缁堛�戞笭閬撲唬鐮侊紙2浣嶏級+鏃ユ湡锛坹yMMdd 6浣嶏級+娴佹按鍙凤紙24浣嶏紝appCode+鍓╀綑浣嶆暟娴佹按鍙凤級 +// String sequenceId = getSequenceId(timeStamp, nxPayConfig.getAppCode()); +// nxPayHttpClient.header("sequenceId", sequenceId); + nxPayHttpClient.header("timestamp", timeStamp); + nxPayHttpClient.header("transCode", HnnxConstant.TRANS_CODE_DYACTIVEQRCODE_PAY); + nxPayHttpClient.header("branchId", branchId); + + // 鎷兼帴涓氬姟鏁版嵁 + HashMap<String, Object> formData = new HashMap<>(); + // 涓�绾у晢鎴峰彿 + formData.put("MerNbr", nxPayConfig.getMerNbr()); + //鍟嗘埛鎬讳氦鏄撴祦姘村彿 + formData.put("MerSeqNbr", merSeqNbr); + //浜ゆ槗鎬婚噾棰� + formData.put("TransAmt", convertToYuan(transAmt)); + //鍟嗘埛浜ゆ槗鏃堕棿 + formData.put("MerTransDateTime", timeStamp); + //娓犻亾缂栧彿 01-O2O 02-B2C 03-鎵爜 + formData.put("ChannelNbr", channelNbr); + formData.put("CurrencyCd", "CNY"); + //鏀粯鏂瑰紡 B 鏀粯瀹濇壂鐮佹敮浠� C 寰俊鎵爜鏀粯 D 閾惰仈鎵爜鏀粯 + formData.put("PayTypCd", payTypCd); + // 浜岀骇鍟嗘埛缂栧彿 + formData.put("SubMerchantId", subMerchantId); + //寮傛閫氱煡Url + formData.put("MerUrl", merUrl); + formData.put("OrderTitle", orderTitle); + + String body = sendForm(nxPayHttpClient, formData); + log.info("----------------- 鐢ㄦ埛涓诲姩鎵爜鐢熸垚 缁撴潫 ----------------- "); + return body; + } + + /** + * 鐢ㄦ埛琚壂鏀粯 + * 绗笁鏂瑰钩鍙版壂鎻忕敤鎴蜂粯娆剧爜锛岄�氳繃姝ゆ帴鍙f彁浜ゆ敮浠� + */ + public String coretoall(String subMerchantId, String branchId, String merSeqNbr, long transAmt, String payAuthCode, String timeStamp, String channelNbr, + String merUrl, String orderTitle, String terminalCode) { + log.info("----------------- 鐢ㄦ埛琚壂鏀粯 寮�濮�, 璁㈠崟缂栧彿= {} 锛岃鍗曢噾棰濅负:{}----------------- ", merSeqNbr, transAmt); + HttpRequest nxPayHttpClient = nxPayConfig.getPayCloseableHttpClient(); + + nxPayHttpClient.header("timestamp", timeStamp); + nxPayHttpClient.header("transCode", HnnxConstant.TRANS_CODE_CORETOALL_PAY); + nxPayHttpClient.header("branchId", branchId); + + // 鎷兼帴涓氬姟鏁版嵁 + HashMap<String, Object> formData = new HashMap<>(); + // 涓�绾у晢鎴峰彿 + formData.put("MerNbr", nxPayConfig.getMerNbr()); + //鍟嗘埛鎬讳氦鏄撴祦姘村彿 + formData.put("MerSeqNbr", merSeqNbr); + //浜ゆ槗鎬婚噾棰� + formData.put("TransAmt", convertToYuan(transAmt)); + //鍟嗘埛浜ゆ槗鏃堕棿 + formData.put("MerTransDateTime", timeStamp); + //浜岀淮鐮� + formData.put("QrCodeInfo", payAuthCode); + //娓犻亾缂栧彿 01-O2O 02-B2C 03-鎵爜 + formData.put("ChannelNbr", channelNbr); + formData.put("CurrencyCd", HnnxConstant.CURRENCYCD); + formData.put("AreaInfo", HnnxConstant.AREAINFO); + + // 浜岀骇鍟嗘埛缂栧彿 + formData.put("SubMerchantId", subMerchantId); + //璁㈠崟璇︽儏 + formData.put("OrderTitle", orderTitle); + //寮傛閫氱煡Url + formData.put("MerUrl", merUrl); + //鍟嗘埛缁堢璁惧绫诲瀷 + formData.put("TerminalType", "04"); + //缁堢缂栧彿 鐢辨煖鍛樺湪鍚庣娣诲姞缁堢鏃剁敓鎴� + formData.put("Equipid", "002000156"); + //缁堢搴忓垪鍙� + formData.put("Equipseqnbr", "000002041170132246"); + formData.put("Lgtude", "113.988007"); + formData.put("Lttude", "34.819642"); + formData.put("AppVersion", "01234567"); + String body = sendForm(nxPayHttpClient, formData); + log.info("----------------- 鐢ㄦ埛琚壂鏀粯 缁撴潫 ----------------- "); + return body; + } + + /** + * 璁㈠崟浜ゆ槗鐘舵�佹煡璇� + * 飦帴鍙h鏄� + * 璇ユ帴鍙f彁渚涙敮浠樸�侀��娆句氦鏄撶殑浜ゆ槗鐘舵�佹煡璇€�� + * 鏍规嵁浜ゆ槗鐘舵�乀ransStatus纭畾浜ゆ槗缁撴灉锛� + * 寰俊閫�娆句氦鏄撶姸鎬佹煡璇紝闈為摱琛屽崱浜ゆ槗涓�鑸湪15绉掑唴鍙煡璇氦鏄撴垚鍔燂紝閾惰鍗′氦鏄撻��娆鹃渶鍦ㄤ袱鍒嗛挓鍚庡彲鏌ヨ鍒颁氦鏄撴垚鍔熴�� + * + * @param merSeqNbr 璁㈠崟娴佹按鍙� + * @return + * @throws Exception + */ + public String qryQrOrderStatus(String merSeqNbr, String branchId) { + log.info("----------------- 璁㈠崟浜ゆ槗鐘舵�佹煡璇� 寮�濮�----------------- "); + HttpRequest nxPayHttpClient = nxPayConfig.getPayCloseableHttpClient(); + String timeStamp = DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN); + //璇锋眰搴忓垪鍙枫�愭笭閬撶浜х敓锛屼竴绗斾笟鍔$殑鍞竴鏍囪瘑锛岃疮绌挎暣涓氦鏄撳缁堛�戞笭閬撲唬鐮侊紙2浣嶏級+鏃ユ湡锛坹yMMdd 6浣嶏級+娴佹按鍙凤紙24浣嶏紝appCode+鍓╀綑浣嶆暟娴佹按鍙凤級 +// String sequenceId = getSequenceId(timeStamp, nxPayConfig.getAppCode()); +// nxPayHttpClient.header("sequenceId", sequenceId); + nxPayHttpClient.header("timestamp", timeStamp); + nxPayHttpClient.header("transCode", HnnxConstant.TRANS_CODE_QRYQRORDERSTATUS_PAY); + nxPayHttpClient.header("branchId", branchId); + + // 鎷兼帴涓氬姟鏁版嵁 + HashMap<String, Object> formData = new HashMap<>(); + // 涓�绾у晢鎴峰彿 + formData.put("MerNbr", nxPayConfig.getMerNbr()); + //鍟嗘埛鎬讳氦鏄撴祦姘村彿 + formData.put("MerSeqNbr", merSeqNbr); + + String body = sendForm(nxPayHttpClient, formData); + log.info("----------------- 璁㈠崟浜ゆ槗鐘舵�佹煡璇� 缁撴潫 ----------------- "); + return body; + } + + /** + * 閫�娆� + * + * @param subMerchantId 鍘熸敮浠樹氦鏄撲簩绾у晢鎴峰彿 + * @param branchId + * @param merSeqNbr 瑕侀��娆剧殑璁㈠崟鍙� + * @param merSeqDate 瑕侀��娆剧殑璁㈠崟浜ゆ槗鏃ユ湡 渚嬶細20190810 + * @param origTransAmt 瑕侀��娆剧殑璁㈠崟鐨勪氦鏄撻噾棰� + * @param transAmt 閫�娆鹃噾棰� + * @param timeStamp 褰撳墠鏃ユ湡 渚嬶細yyyyMMddHHmmss + * @return + */ + public String returntrans(String subMerchantId, String branchId, String merSeqNbr, String merSeqDate, long origTransAmt, + long transAmt, String timeStamp) { + log.info("----------------- 閫�娆� 寮�濮�----------------- "); + HttpRequest nxPayHttpClient = nxPayConfig.getPayCloseableHttpClient(); + nxPayHttpClient.header("timestamp", timeStamp); + nxPayHttpClient.header("transCode", HnnxConstant.TRANS_CODE_RETURNTRANS_PAY); + nxPayHttpClient.header("branchId", branchId); + + // 鎷兼帴涓氬姟鏁版嵁 + HashMap<String, Object> formData = new HashMap<>(); + // 涓�绾у晢鎴峰彿 + formData.put("MerNbr", nxPayConfig.getMerNbr()); + //鍟嗘埛鎬讳氦鏄撴祦姘村彿 + formData.put("MerSeqNbr", "TK_" + merSeqNbr); + //閫�璐т氦鏄撴椂闂� + formData.put("MerTransDateTime", timeStamp); + + //鍘熷晢鎴锋祦姘� + formData.put("OrigMerSeqNbr", merSeqNbr); + //鍘熷晢鎴锋棩鏈� + formData.put("OrigMerDate", merSeqDate); + //鍘熸敮浠樹氦鏄撻噾棰� + formData.put("OrigTransAmt", convertToYuan(origTransAmt)); + //浜岀骇鍟嗘埛鍙� + formData.put("SubMerchantId", subMerchantId); + + //閫�璐т簩绾у晢鎴锋祦姘村彿锛堥殢鏈虹敓鎴愶紝涓嶅厑璁稿嚭鐜伴噸澶嶏紝鍙互鍜屼竴绾у晢鎴蜂氦鏄撴祦姘村彿淇濇寔涓�鑷达級 + formData.put("SubMerSeqNo", "TK_" + merSeqNbr); + //浜岀骇鍟嗘埛鏃堕棿 + formData.put("SubMerDateTime", timeStamp); + //浜岀骇鍟嗘埛閫�璐т氦鏄撻��璐ч噾棰� + formData.put("SubTransAmt", convertToYuan(transAmt)); + //鍘熶簩绾у晢鎴锋敮浠樻祦姘村彿锛堜笌鍘熸敮浠樹氦鏄撲竴绾у晢鎴峰彿娴佹按鍙蜂竴鑷达級 + formData.put("OrigSubMerSeqNo", merSeqNbr); + //鍘熶簩绾у晢鎴锋敮浠樹氦鏄撴棩鏈燂紙渚嬶細20190810锛� + formData.put("OrigSubMerDate", merSeqDate); + //璁㈠崟鍙� 涓庝簩绾у晢鎴锋祦姘村彿淇濇寔涓�鑷� + formData.put("OrderNbr", merSeqNbr); + String body = sendForm(nxPayHttpClient, formData); + log.info("----------------- 閫�娆� 缁撴潫----------------- "); + return body; + } + + /** + * 瀵硅处鏌ヨ + * String subMerchantId, String branchId, + * + * @param clearDate 瀵硅处鏃ユ湡 YYYY-MM-DD + * @param branchId 浜ゆ槗鏈烘瀯鍙� + * @return + */ + public String accountqry(String clearDate, String branchId) { + log.info("----------------- 瀵瑰笎 寮�濮�----------------- "); + HttpRequest nxPayHttpClient = nxPayConfig.getPayCloseableHttpClient(); + nxPayHttpClient.header("timestamp", DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN)); + nxPayHttpClient.header("transCode", HnnxConstant.TRANS_CODE_ACCOUNTQRY_PAY); + nxPayHttpClient.header("branchId", branchId); + + // 鎷兼帴涓氬姟鏁版嵁 + HashMap<String, Object> formData = new HashMap<>(); + formData.put("ClearDate", clearDate); + + String body = sendForm(nxPayHttpClient, formData); + log.info("----------------- 瀵瑰笎 缁撴潫----------------- "); + return body; + } + + // 璁㈠崟鍙风敓鎴愯鍒� 鈥滄笭閬撶畝绉�-璁㈠崟鍙�-涓�/浼樻儬-鍙戣捣鏀粯娆℃暟鈥濇瀯鎴� + // 渚嬪鍟嗗湀鐨勪富璁㈠崟绗竴娆″彂璧锋敮浠橈紝璁㈠崟鍙峰氨鏄�淪Q-鍟嗗湀璁㈠崟id-Z-1鈥� + // 濡傛灉杩欎釜璁㈠崟鍏宠仈鏈変紭鎯犻噾锛屼紭鎯犻噾璁㈠崟鍙峰氨鏄�"SQ-鍟嗗湀璁㈠崟id-Y-1" + public static String getNxPayOrderId(String prefix, long orderId, char orderType, short tryNum) { + return new StringBuilder(prefix).append("-").append(orderId).append("-").append(orderType).append("-").append(tryNum).toString(); + } + + /** + * 楠岀 + * + * @return + */ + public boolean verify(String body) { + log.info("杩斿洖鍊奸獙绛� body 涓�: {}", body); + log.info("----------- 杩斿洖鍊奸獙绛� 寮�濮� ----------- "); + boolean verfiy = false; + try { + Map<String, Object> bodyMap = JSON.parseObject(body, Feature.OrderedField); + String sign = (String) bodyMap.remove("signature"); + String payload = (String) bodyMap.remove("payload"); + + ObjectMapper objectMapper = new ObjectMapper(); + if (payload != null) { + Map payloadMap = objectMapper.readValue(payload, Map.class); + bodyMap.putAll(payloadMap); + } + String palin = null; + palin = Permutation.sort(bodyMap, "UTF-8"); + log.info("鎺掑簭鍚庣殑瀛楃涓诧細{}", palin); + if (StringUtils.isNotEmpty(sign)) { + verfiy = verifier.verify(HnnxConstant.ALGORITHM, palin.getBytes(), Hex.toByte(sign), nxPayPublicKey); + } + } catch (Exception e) { + e.printStackTrace(); + } + log.error("杩斿洖鍊奸獙绛� 缁撴灉锛歿}", verfiy); + log.info("----------- 杩斿洖鍊奸獙绛� 缁撴潫 ----------- "); + return verfiy; + } + + public boolean kjVerify(String sign, String palin) { + log.info("杩斿洖鍊奸獙绛� palin 涓�: {}", palin); + log.info("杩斿洖鍊奸獙绛� sign 涓�: {}", sign); + log.info("----------- 杩斿洖鍊奸獙绛� 寮�濮� ----------- "); + boolean verfiy = false; + try { + if (StringUtils.isNotEmpty(sign)) { + verfiy = verifier.verify(HnnxConstant.KJ_ALGORITHM, palin.getBytes(), Base64.getDecoder().decode(sign), nxKjPayPublicKey); + } + } catch (Exception e) { + e.printStackTrace(); + } + log.error("杩斿洖鍊奸獙绛� 缁撴灉锛歿}", verfiy); + log.info("----------- 杩斿洖鍊奸獙绛� 缁撴潫 ----------- "); + return verfiy; + } + + /** + * 閫氱敤蹇嵎鏀粯 + * + * @param merSeqNbr 鍟嗘埛娴佹按鍙� + * @param subMerchantId 浜岀骇鍟嗘埛鍙� + * @param backURL 鍚庡彴閫氱煡URL + * @param frontURL 杩斿洖鍓嶇URL + */ + public String quickPayRequest(String subMerchantId, String merSeqNbr, long transAmt, String nowTime, + String frontURL, String backURL, String orderTitle) { + log.info("----------------- 閫氱敤蹇嵎鏀粯 寮�濮�, 璁㈠崟缂栧彿= {} 锛岃鍗曢噾棰濅负:{}----------------- ", merSeqNbr, transAmt); + + + // 鎷兼帴涓氬姟鏁版嵁 + JSONObject formData = new JSONObject(); + formData.put("deviceType", "5"); + + HashMap<String, Object> plainData = new HashMap<>(); + // plain 寮�濮� + //涓�绾у晢鎴穒d +// plainData.put("merchId", "010020170801000001"); + plainData.put("merchId", nxPayConfig.getKjMerNbr()); + //浼樻儬鍓嶉噾棰� disCountAmt + //璁㈠崟鍚嶇О orderName + plainData.put("orderName", orderTitle); + //甯佺 ccy + plainData.put("ccy", "01"); + //杩斿洖鍓嶇URL frontURL + plainData.put("frontURL", frontURL); + //鍚庡彴閫氱煡URL backURL + plainData.put("backURL", backURL); + //璁㈠崟澶囨敞 orderRemark + plainData.put("orderRemark", ""); + //娓犻亾鍙� channelNbr + plainData.put("channelNbr", "02"); + //浜ゆ槗鎬婚噾棰� txnAmt + plainData.put("txnAmt", convertToYuan(transAmt)); + //鍟嗘埛娴佹按鍙� merSeqNbr + plainData.put("merSeqNbr", merSeqNbr); + //浜ゆ槗鏃堕棿 orderTime + plainData.put("orderTime", nowTime); + //鏀舵鏂瑰悕绉� payee + //浼樻儬娲诲姩鍚嶇О specialOffers + + //鍟嗘埛璁㈠崟鍙� merchOrderId + plainData.put("merchOrderId", merSeqNbr); + + JSONArray plainMerTrans = new JSONArray(); + JSONObject plainMerTransData1 = new JSONObject(); + //瀛愪氦鏄撻噾棰� + plainMerTransData1.put("subTransAmt", convertToYuan(transAmt)); + //浜岀骇鍟嗘埛鍙� + plainMerTransData1.put("subMerchantId", subMerchantId); + //浜岀骇鍟嗘埛浜ゆ槗鏃堕棿 subMerDateTime + plainMerTransData1.put("subMerDateTime", nowTime); + //瀛愭祦姘村彿 subMerSeqNo + plainMerTransData1.put("subMerSeqNo", merSeqNbr); + //浜岀骇鍟嗘埛鍚嶇О subMerchantName + plainMerTransData1.put("subMerchantName", ""); + //浜岀骇鍟嗘埛鍟嗗搧淇℃伅 productInfo + plainMerTransData1.put("productInfo", ""); + //浜岀骇鍟嗘埛淇℃伅 subMerImport +// plainMerTransData1.put("subMerImport", "瀛﹁垂"); +// plainMerTransData1.put("subMerImport", orderTitle); + //鍗″埜鍙� platCouponId + plainMerTransData1.put("platCouponId", ""); + //瀛愬崱鍒镐氦鏄撻噾棰� platCouponAmount + plainMerTransData1.put("platCouponAmount", ""); + //瀛愮Н鍒嗘暟 bonusPoint + plainMerTransData1.put("bonusPoint", ""); + //瀛愮Н鍒嗕氦鏄撻噾棰� bonusPointAmount + plainMerTransData1.put("bonusPointAmount", ""); + +// plainMerTransData1.put("subInteralAmt", "0.01"); +// plainMerTransData1.put("subCouponAmt", ""); + + plainMerTrans.add(plainMerTransData1); + plainData.put("MerTransList", plainMerTrans); + + String plainStr = JSONObject.toJSONString(plainData); + log.info("璇锋眰鍙傛暟锛歿}", plainStr); +// formData.put("plain", plainData); + formData.put("plain", plainStr); + // plain 缁撴潫 + + // 寮�濮嬬鍚� + String signature = kjSign(plainStr); + formData.put("signature", signature); +// writeToFile(signature, plainStr); + + HttpResponse httpResponse = HttpRequest.post(nxPayConfig.getKjUrl() + HnnxConstant.QUICK_PAY_URL) + .contentType("application/x-www-form-urlencoded;") + .form(formData.getInnerMap()) + .timeout(20000)//瓒呮椂锛屾绉� + .execute(); + String location = null; + log.info("----------------- 閫氱敤蹇嵎鏀粯 缁撴潫 ----------------- "); + if (httpResponse.getStatus() == 302) { + location = httpResponse.header("Location"); +// writeToFile(location); + return location; + }else { + throw new RuntimeException(httpResponse.body()); + } + + } + + /** + * 蹇嵎鏀粯 璁㈠崟鐘舵�佹煡璇� + * + * @param orderNbr 璁㈠崟缂栧彿 + * @param startDate 璧峰鏃ユ湡 yyyyMMdd + * @param endDate 缁撴潫鏃ユ湡 yyyyMMdd + * @param pageSize 姣忛〉璁板綍鏁� + * @param pageNum 褰撳墠绗嚑椤� + * @return + */ + + public String quickPayOrderQueryRequest(String orderNbr, String startDate, String endDate, int pageSize, int pageNum) { + log.info("----------------- 蹇嵎鏀粯璁㈠崟浜ゆ槗鐘舵�佹煡璇� 寮�濮�----------------- "); + String body = null; + JSONObject formData = new JSONObject(); + formData.put("MerNbr", nxPayConfig.getKjMerNbr()); + //璁㈠崟缂栧彿 + if (StringUtils.isNotEmpty(orderNbr)) { + formData.put("OrderNbr", orderNbr); + } + //璧峰鏃ユ湡 + if (StringUtils.isNotEmpty(orderNbr)) { + formData.put("StartDate", startDate); + } + //缁撴潫鏃ユ湡 + if (StringUtils.isNotEmpty(orderNbr)) { + formData.put("EndDate", endDate); + } + //姣忛〉璁板綍鏁� + formData.put("PageSize", pageSize); + //褰撳墠绗嚑椤� + formData.put("PageNum", pageNum); + log.info("蹇嵎鏀粯璁㈠崟鏌ヨ鍙傛暟:{}", formData); + body = HttpRequest.post(nxPayConfig.getKjUrl() + HnnxConstant.QUICK_PAY_QUERY_URL) + .contentType("application/x-www-form-urlencoded;") + .form(formData.getInnerMap()) + .timeout(20000)//瓒呮椂锛屾绉� + .execute().body(); + log.info("蹇嵎鏀粯璁㈠崟鏌ヨ璇锋眰缁撴灉:{}", body); + log.info("----------------- 蹇嵎鏀粯璁㈠崟浜ゆ槗鐘舵�佹煡璇� 缁撴潫 ----------------- "); + return body; + } + + /** + * 閫�娆� + * + * @param subMerchantId 鍘熸敮浠樹氦鏄撲簩绾у晢鎴峰彿 + * @param merSeqNbr 瑕侀��娆剧殑璁㈠崟鍙� + * @param merSeqDate 瑕侀��娆剧殑璁㈠崟浜ゆ槗鏃ユ湡 yyyyMMdd 渚嬶細20190810 + * @param origTransAmt 瑕侀��娆剧殑璁㈠崟鐨勪氦鏄撻噾棰� + * @param transAmt 閫�娆鹃噾棰� + * @param timeStamp 褰撳墠鏃ユ湡 渚嬶細yyyyMMddHHmmss + * @return + */ + public String quickPayReturntrans(String subMerchantId, String merSeqNbr, String merSeqDate, long origTransAmt, + long transAmt, String timeStamp) { + log.info("----------------- 閫�娆� 寮�濮�----------------- "); + String timeStampWithSpace = timeStamp.substring(0, 8) + " " + timeStamp.substring(8); + // 鎷兼帴涓氬姟鏁版嵁 + HashMap<String, Object> formData = new HashMap<>(); + // 涓�绾у晢鎴峰彿 + formData.put("MerNbr", nxPayConfig.getKjMerNbr()); + //鍟嗘埛鎬讳氦鏄撴祦姘村彿 + formData.put("MerSeqNbr", "TK_" + merSeqNbr); + //閫�璐т氦鏄撴椂闂� yyyyMMdd HHmmss 宸紓!!!! + formData.put("MerTransDateTime", timeStampWithSpace); +// formData.put("MerTransDateTime", timeStamp); + + //鍘熷晢鎴锋祦姘� + formData.put("OrigMerSeqNbr", merSeqNbr); + //鍘熷晢鎴锋棩鏈� + formData.put("OrigMerDate", merSeqDate); + //鍘熸敮浠樹氦鏄撻噾棰� + formData.put("OrigTransAmt", convertToYuan(origTransAmt)); + + //浜岀骇鍟嗘埛鍙� + formData.put("SubMerchantId", subMerchantId); + //閫�璐т簩绾у晢鎴锋祦姘村彿锛堥殢鏈虹敓鎴愶紝涓嶅厑璁稿嚭鐜伴噸澶嶏紝鍙互鍜屼竴绾у晢鎴蜂氦鏄撴祦姘村彿淇濇寔涓�鑷达級 + formData.put("SubMerSeqNo", "TK_" + merSeqNbr); + //浜岀骇鍟嗘埛鏃堕棿 + formData.put("SubMerDateTime", timeStampWithSpace); +// formData.put("SubMerDateTime", timeStamp); + //浜岀骇鍟嗘埛閫�璐т氦鏄撻��璐ч噾棰� + formData.put("SubTransAmt", convertToYuan(transAmt)); + + + //鍘熶簩绾у晢鎴锋敮浠樻祦姘村彿锛堜笌鍘熸敮浠樹氦鏄撲竴绾у晢鎴峰彿娴佹按鍙蜂竴鑷达級 + formData.put("OrigSubMerSeqNo", merSeqNbr); + //鍘熶簩绾у晢鎴锋敮浠樹氦鏄撴棩鏈燂紙渚嬶細20190810锛� + formData.put("OrigSubMerDate", merSeqDate); + //璁㈠崟鍙� 涓庝簩绾у晢鎴锋祦姘村彿淇濇寔涓�鑷� + formData.put("OrderNbr", merSeqNbr); + log.info("蹇嵎鏀粯璁㈠崟閫�娆惧弬鏁帮細{}", formData); + + String body = null; + HttpResponse httpResponse = HttpRequest.post(nxPayConfig.getKjUrl() + HnnxConstant.QUICK_PAY_RETURN_URL) + .contentType("application/x-www-form-urlencoded;") + .form(formData) + .timeout(20000)//瓒呮椂锛屾绉� + .execute(); + body = httpResponse.body(); + log.info(" 蹇嵎鏀粯閫�娆剧粨鏋滐細{}", body); + log.info("----------------- 閫�娆� 缁撴潫----------------- "); + return body; + } + + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/NXPayService.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/NXPayService.java new file mode 100644 index 0000000..3687291 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/NXPayService.java @@ -0,0 +1,524 @@ +package com.nuvole.hnnx.hnnxPay; + +import cn.hutool.core.convert.Convert; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.fasterxml.jackson.databind.node.ContainerNode; +import com.nuvole.common.domain.emnu.CommonResultEmnu; +import com.nuvole.common.domain.result.CommonResult; +import com.nuvole.constants.PropertiesConstants; +import com.nuvole.hnnx.conf.NxPayConfig; +import com.nuvole.hnnx.orderQueryTask.OrderQueryTask; +import com.nuvole.hnnx.orderQueryTask.OrderQueryUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.Map; + +/** + * @ClassName NXPayService + * @Author cy + * @Date 2023/10/6 + * @Description + * @Version 1.0 + **/ +@Service +@Slf4j +//@ConditionalOnClass(name = "com.nuvole.hnnx.conf.NxPayConfig") +public class NXPayService { + + @Autowired(required = false) + private NXHttpClientUtils nxHttpClientUtils; + @Autowired + private NxPayConfig nxPayConfig; + @Autowired + private ApplicationEventPublisher eventPublisher; + + public String getPlatSubMerchantId() { + return nxHttpClientUtils.getPlatSubMerchantId(); + } + public String getKjPlatSubMerchantId() { + return nxHttpClientUtils.getKjPlatSubMerchantId(); + } + public String getBranchId() { + return nxHttpClientUtils.getBranchId(); + } + + + /** + * C 鎵� B 缁熶竴涓嬪崟 + * + * @param payConfig 鏀粯鍙傛暟鑱氬悎瀵硅薄 + * @param orderId 鍟嗘埛璁㈠崟鍙� + * @param payMoney 璁㈠崟鎬婚噾棰濓紝鍙兘涓烘暣鏁� + * @param title 璁㈠崟鏍囬 + * @param authCode 寰俊/鏀粯瀹濓紝杩斿洖鐨勬巿鏉冪爜锛屾敮浠樹腑蹇冮�氳繃鎺堟潈鐮佽幏鍙栫敤鎴穙penId,浠ヤ究杩涜鍚庣画涓嬪崟浜ゆ槗銆� + * @param timeStamp 鏃堕棿鎴� + * @return + * @throws Exception + */ + public CommonResult<JSONObject> wxScanUnifiedorder(JSONObject payConfig, String orderId, Long payMoney, String title, String goodsInfo, String authCode, String notifyUrl, + String timeStamp) { + log.info("銆愭渤鍗楀啘淇�-C鎵獴寰俊鏀粯銆� 缁熶竴涓嬪崟寮�濮�, 璁㈠崟缂栧彿=" + orderId); + //楠岃瘉閲戦 + if (payMoney <= 0 && payMoney <= 0) { + return new CommonResult<>(CommonResultEmnu.ERROR, "鏀粯澶辫触,涓嶈兘0鍏冩敮浠橈紒"); + } + // 浜岀骇鍟嗘埛鍙� + String subMerchantId = payConfig.getString("subMerchantId"); + //浜ゆ槗鏈烘瀯鍙� + String branchId = payConfig.getString("branchId"); + String operatorId = payConfig.getString("operatorId"); + + // 鍐滀俊 寰俊鏀粯 + String onlinePayResp = null; + + onlinePayResp = nxHttpClientUtils.qrCodePrePay(subMerchantId, branchId, operatorId, orderId, authCode, payMoney, timeStamp, "03", 'C', notifyUrl, title); + + JSONObject onlinePayRespObj = JSONObject.parseObject(onlinePayResp); + String respCode = onlinePayRespObj.getString("code"); + if (!"000000".equals(respCode)) { + log.error("娌冲崡鍐滀俊-C鎵獴鏀粯涓嬪崟澶辫触锛侀敊璇粨鏋滅爜:{},閿欒缁撴灉鎻忚堪:{}", respCode, onlinePayRespObj.getString("message")); + return new CommonResult<>(CommonResultEmnu.ERROR, onlinePayRespObj.getString("message")); + } + JSONObject onlinePayResult = onlinePayRespObj.getJSONObject("payload"); + onlinePayRespObj.put("toPayMethod", "2"); + JSONObject resultMap = nxPreConvertWxParam(onlinePayResult); + onlinePayRespObj.put("paymentData", resultMap); + onlinePayRespObj.remove("payload"); +// OrderQueryTask orderQueryTask = ApplicationContextUtil.getBean(OrderQueryTask.class); +// orderQueryTask.setOrderId(orderId); +// orderQueryTask.setPayService((short) 7); +// orderQueryTask.setPayType((short) 1); +// orderQueryTask.setOrderPayTime(new Date()); + OrderQueryTask orderQueryTask = new OrderQueryTask(eventPublisher, this,nxPayConfig,orderId,(short)7,(short)1,new Date()); + OrderQueryUtil.addTask(orderQueryTask); + return new CommonResult(onlinePayRespObj); + } + + public static String getFrontUrl(String orderId, Map youHuiInfo){ + return HnnxConstant.NX_KJ_FRONT_URL.substring(0,56); +// String frontUrl = HnnxConstant.NX_KJ_FRONT_URL.replace("${ORDERID}", orderId + ""); +// if (youHuiInfo == null){ +// return URLEncoder.encode(frontUrl.replace("${YOUHUIINFO}", "")); +// } +// return URLEncoder.encode(frontUrl.replace("${YOUHUIINFO}", JSONObject.toJSONString(youHuiInfo))); + } + + private JSONObject nxPreConvertWxParam(JSONObject payload) { + if (payload == null) { + return payload; + } + payload.put("appId", payload.remove("AppId")); + payload.put("timeStamp", payload.remove("TimeStamp")); + payload.put("nonceStr", payload.remove("Charset")); + payload.put("package", payload.remove("Subject")); + payload.put("signType", payload.remove("SignType")); + payload.put("paySign", payload.remove("Sign")); + payload.put("orderNo", payload.remove("MerSeqNbr")); + return payload; + } + + /** + * C 鎵� B 缁熶竴涓嬪崟 + * + * @param payConfig 鏀粯鍙傛暟鑱氬悎瀵硅薄 + * @param orderId 鍟嗘埛璁㈠崟鍙� + * @param payMoney 璁㈠崟鎬婚噾棰濓紝鍙兘涓烘暣鏁� + * @param title 璁㈠崟鏍囬 + * @param authCode 寰俊/鏀粯瀹濓紝杩斿洖鐨勬巿鏉冪爜锛屾敮浠樹腑蹇冮�氳繃鎺堟潈鐮佽幏鍙栫敤鎴穙penId,浠ヤ究杩涜鍚庣画涓嬪崟浜ゆ槗銆� + * @param timeStamp 鏃堕棿鎴� + * @return + * @throws Exception + */ + public CommonResult<JSONObject> zfbScanUnifiedorder(JSONObject payConfig, String orderId, Long payMoney, String title, String goodsInfo, String authCode, String notifyUrl, + String timeStamp) { + log.info("銆愭渤鍗楀啘淇�-C鎵獴鏀粯-鏀粯瀹濄�� 缁熶竴涓嬪崟寮�濮�, 璁㈠崟缂栧彿=" + orderId); + //楠岃瘉閲戦 + if (payMoney <= 0 && payMoney <= 0) { + return new CommonResult<>(CommonResultEmnu.ERROR, "鏀粯澶辫触,涓嶈兘0鍏冩敮浠橈紒"); + } + // 浜岀骇鍟嗘埛鍙� + String subMerchantId = payConfig.getString("subMerchantId"); + //浜ゆ槗鏈烘瀯鍙� + String branchId = payConfig.getString("branchId"); + String operatorId = payConfig.getString("operatorId"); + + // 鍐滀俊 寰俊鏀粯 + String onlinePayResp = null; + onlinePayResp = nxHttpClientUtils.qrCodePrePay(subMerchantId, branchId, operatorId, orderId, authCode, payMoney, timeStamp, "03", 'B', notifyUrl, title); + JSONObject onlinePayRespObj = JSONObject.parseObject(onlinePayResp); + String respCode = onlinePayRespObj.getString("code"); + if (!"000000".equals(respCode)) { + log.error("娌冲崡鍐滀俊-C鎵獴鏀粯鏀粯瀹濅笅鍗曞け璐ワ紒閿欒缁撴灉鐮�:{},閿欒缁撴灉鎻忚堪:{}", respCode, onlinePayRespObj.getString("message")); + return new CommonResult<>(CommonResultEmnu.ERROR, onlinePayRespObj.getString("message")); + } + JSONObject onlinePayResult = onlinePayRespObj.getJSONObject("payload"); + onlinePayResult.put("toPayMethod", "2"); + JSONObject paymentData = new JSONObject(); + paymentData.put("tradeNO", onlinePayResult.remove("TradeNo")); + onlinePayResult.put("paymentData", paymentData); +// OrderQueryTask orderQueryTask = ApplicationContextUtil.getBean(OrderQueryTask.class); +// orderQueryTask.setOrderId(orderId); +// orderQueryTask.setPayService((short) 7); +// orderQueryTask.setPayType((short) 1); +// orderQueryTask.setOrderPayTime(new Date()); + OrderQueryTask orderQueryTask = new OrderQueryTask(eventPublisher, this,nxPayConfig,orderId,(short)7,(short)1,new Date()); + OrderQueryUtil.addTask(orderQueryTask); + return new CommonResult(onlinePayResult); + } + + /** + * 鍔ㄦ�丆 鎵� B 缁熶竴涓嬪崟 + * + * @param payConfig 鏀粯鍙傛暟鑱氬悎瀵硅薄 + * @param orderId 鍟嗘埛璁㈠崟鍙� + * @param payMoney 璁㈠崟鎬婚噾棰濓紝鍙兘涓烘暣鏁� + * @param title 璁㈠崟鏍囬 + * @param authCode 寰俊/鏀粯瀹濓紝杩斿洖鐨勬巿鏉冪爜锛屾敮浠樹腑蹇冮�氳繃鎺堟潈鐮佽幏鍙栫敤鎴穙penId,浠ヤ究杩涜鍚庣画涓嬪崟浜ゆ槗銆� + * @param timeStamp 鏃堕棿鎴� + * @return + * @throws Exception + */ + public CommonResult<JSONObject> zfbActiveScanUnifiedorder(JSONObject payConfig, String orderId, Long payMoney, String title, String goodsInfo, String authCode, String notifyUrl, + String timeStamp) { + log.info("銆愭渤鍗楀啘淇�-鍔ㄦ�丆鎵獴鏀粯-鏀粯瀹濄�� 缁熶竴涓嬪崟寮�濮�, 璁㈠崟缂栧彿=" + orderId); + return wxAliActiveScanUnifiedorder(payConfig, orderId, payMoney, title, goodsInfo, authCode, notifyUrl, timeStamp, "03", 'B'); + } + + /** + * 鍔ㄦ�丆 鎵� B 缁熶竴涓嬪崟 + * + * @param payConfig 鏀粯鍙傛暟鑱氬悎瀵硅薄 + * @param orderId 鍟嗘埛璁㈠崟鍙� + * @param payMoney 璁㈠崟鎬婚噾棰濓紝鍙兘涓烘暣鏁� + * @param title 璁㈠崟鏍囬 + * @param authCode 寰俊/鏀粯瀹濓紝杩斿洖鐨勬巿鏉冪爜锛屾敮浠樹腑蹇冮�氳繃鎺堟潈鐮佽幏鍙栫敤鎴穙penId,浠ヤ究杩涜鍚庣画涓嬪崟浜ゆ槗銆� + * @param timeStamp 鏃堕棿鎴� + * @return + * @throws Exception + */ + public CommonResult<JSONObject> wxActiveScanUnifiedorder(JSONObject payConfig, String orderId, Long payMoney, String title, String goodsInfo, String authCode, String notifyUrl, + String timeStamp) { + log.info("銆愭渤鍗楀啘淇�-鍔ㄦ�丆鎵獴鏀粯-寰俊銆� 缁熶竴涓嬪崟寮�濮�, 璁㈠崟缂栧彿=" + orderId); + return wxAliActiveScanUnifiedorder(payConfig, orderId, payMoney, title, goodsInfo, authCode, notifyUrl, timeStamp, "03", 'C'); + } + + + /** + * 鏀粯瀹濄�佸井淇� 鍔ㄦ�乧鎵獴 + * + * @param payConfig + * @param orderId + * @param payMoney + * @param title + * @param goodsInfo + * @param authCode + * @param notifyUrl + * @param timeStamp + * @param channelNbr + * @param payTypCd + * @return + */ + private CommonResult<JSONObject> wxAliActiveScanUnifiedorder(JSONObject payConfig, String orderId, Long payMoney, String title, String goodsInfo, String authCode, String notifyUrl, + String timeStamp, String channelNbr, char payTypCd) { + //楠岃瘉閲戦 + if (payMoney <= 0 && payMoney <= 0) { + return new CommonResult<>(CommonResultEmnu.ERROR, "鏀粯澶辫触,涓嶈兘0鍏冩敮浠橈紒"); + } + // 浜岀骇鍟嗘埛鍙� + String subMerchantId = payConfig.getString("subMerchantId"); + //浜ゆ槗鏈烘瀯鍙� + String branchId = payConfig.getString("branchId"); + + // 鍐滀俊 寰俊鏀粯 + String onlinePayResp = null; + + onlinePayResp = nxHttpClientUtils.dyActiveQrCode(subMerchantId, branchId, orderId, payMoney, timeStamp, channelNbr, payTypCd, notifyUrl, title); + JSONObject onlinePayRespObj = JSONObject.parseObject(onlinePayResp); + String respCode = onlinePayRespObj.getString("code"); + if (!"000000".equals(respCode)) { + log.error("娌冲崡鍐滀俊-鍔ㄦ�丆鎵獴鏀粯 涓嬪崟澶辫触锛侀敊璇粨鏋滅爜:{},閿欒缁撴灉鎻忚堪:{}", respCode, onlinePayRespObj.getString("message")); + return new CommonResult<>(CommonResultEmnu.ERROR, onlinePayRespObj.getString("message")); + } + JSONObject onlinePayResult = onlinePayRespObj.getJSONObject("payload"); + onlinePayResult.put("paymentUrl", onlinePayResult.remove("QrCodeInfo")); + onlinePayResult.put("codeUrl", onlinePayResult.get("paymentUrl")); +// OrderQueryTask orderQueryTask = ApplicationContextUtil.getBean(OrderQueryTask.class); +// orderQueryTask.setOrderId(orderId); +// orderQueryTask.setPayService((short) 7); +// orderQueryTask.setPayType((short) 1); +// orderQueryTask.setOrderPayTime(new Date()); + OrderQueryTask orderQueryTask = new OrderQueryTask(eventPublisher, this,nxPayConfig,orderId,(short)7,(short)1,new Date()); + OrderQueryUtil.addTask(orderQueryTask); + return new CommonResult(onlinePayResult); + } + + + public CommonResult<JSONObject> offlinePayB2COrder(JSONObject payConfig, String orderNum, String timeStamp, String title, String goodsInfo, + ContainerNode detail, String notifyUrl, Long money, String authPayCode, String terminalCode) { + // 浜岀骇鍟嗘埛鍙� + String subMerchantId = payConfig.getString("subMerchantId"); + //浜ゆ槗鏈烘瀯鍙� + String branchId = payConfig.getString("branchId"); + + String offlineB2CPayResp = null; + try { + offlineB2CPayResp = nxHttpClientUtils.coretoall(subMerchantId, branchId, orderNum, money, authPayCode, timeStamp, "03", notifyUrl, title, terminalCode); + } catch (Exception e) { + e.printStackTrace(); + return new CommonResult<>(CommonResultEmnu.ERROR, e.getMessage()); + } + JSONObject offlineB2CPayRespObj = JSONObject.parseObject(offlineB2CPayResp); + String respCode = offlineB2CPayRespObj.getString("code"); + + if (!"000000".equals(respCode)) { + log.error("娌冲崡鍐滀俊-浠樻鐮侊紙B 鎵� C锛変笅鍗曞け璐ワ紒閿欒缁撴灉鐮�:{},閿欒缁撴灉鎻忚堪:{}", respCode, offlineB2CPayRespObj.getString("message")); + return new CommonResult<>(CommonResultEmnu.ERROR, offlineB2CPayRespObj.getString("message")); + } + + //0 浜ゆ槗鎴愬姛 1 浜ゆ槗澶辫触 2 鎾ら攢 3 閮ㄥ垎閫�璐� 4 鍏ㄩ儴閫�璐� 5 澶勭悊涓� 9 浜ゆ槗瓒呮椂 + JSONObject payloadJson = offlineB2CPayRespObj.getJSONObject("payload"); + String tradeStatus = payloadJson.getString("TransStatus"); + if ("0".equals(tradeStatus)) { + payloadJson.put("waterNo", payloadJson.getString("TransSeqNbr")); + // 鏀粯鎴愬姛 + return new CommonResult<>(payloadJson); + } else { + int count = 4; + for (int index = 0; index < count; index++) { + try { + Thread.sleep(10 * 1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + CommonResult<JSONObject> tradeQueryResult = tradeQuery(payConfig, orderNum); + if (!tradeQueryResult.getCode().equals(CommonResultEmnu.OK.getCode())) { + return new CommonResult<>(CommonResultEmnu.ERROR, tradeQueryResult.getDescription()); + } + payloadJson = tradeQueryResult.getData().getJSONObject("payload"); + tradeStatus = payloadJson.getString("TransStatus"); + if ("0".equals(tradeStatus)) { + payloadJson.put("waterNo", payloadJson.getString("TransSeqNbr")); + // 鏀粯鎴愬姛 + return new CommonResult<>(payloadJson); + } else if ("1".equals(tradeStatus)) { + return new CommonResult<>(CommonResultEmnu.ERROR, "浜ゆ槗澶辫触锛岃鍗曞凡鍏抽棴"); + } else if ("2".equals(tradeStatus)) { + return new CommonResult<>(CommonResultEmnu.ERROR, "浜ゆ槗澶辫触锛岃鍗曞凡琚挙閿�"); + } else if ("3,4".contains(tradeStatus)) { + return new CommonResult<>(CommonResultEmnu.ERROR, "浜ゆ槗澶辫触锛岃鍗曞凡琚��璐�"); + } else if ("9".equals(tradeStatus)) { + return new CommonResult<>(CommonResultEmnu.ERROR, "浜ゆ槗瓒呮椂"); + } else if ("5".equals(tradeStatus)) { + log.info("浜ゆ槗涓紝缁х画鏌ヨ"); + count++; + } else { + return new CommonResult<>(CommonResultEmnu.ERROR, tradeQueryResult.getDescription()); + } + } + } + return new CommonResult(payloadJson); + } + + /** + * 璁㈠崟浜ゆ槗鐘舵�佹煡璇� + * + * @return + */ + public CommonResult<JSONObject> tradeQuery(JSONObject payConfig, String orderNum) { + //浜ゆ槗鏈烘瀯鍙� + String branchId = payConfig.getString("branchId"); + String tradeQueryResp = nxHttpClientUtils.qryQrOrderStatus(orderNum, branchId); + JSONObject tradeQueryRespObj = JSONObject.parseObject(tradeQueryResp); + String respCode = tradeQueryRespObj.getString("code"); + if (!"000000".equals(respCode)) { + log.error("娌冲崡鍐滀俊-璁㈠崟浜ゆ槗鐘舵�佹煡璇㈠け璐ワ紒閿欒缁撴灉鐮�:{},閿欒缁撴灉鎻忚堪:{}", respCode, tradeQueryRespObj.getString("message")); + return new CommonResult<>(CommonResultEmnu.ERROR, tradeQueryRespObj.getString("message")); + } + return new CommonResult(tradeQueryRespObj); + } + + /** + * 閫�娆� + * + * @param orderNum 瑕侀��娆剧殑璁㈠崟鍙� + * @param merSeqDate 瑕侀��娆剧殑璁㈠崟浜ゆ槗鏃ユ湡 渚嬶細20190810 + * @param origTransAmt 瑕侀��娆剧殑璁㈠崟鐨勪氦鏄撻噾棰� + * @param transAmt 閫�娆鹃噾棰� + * @param timeStamp 褰撳墠鏃ユ湡 渚嬶細yyyyMMddHHmmss + * @return + */ + public CommonResult<JSONObject> returntrans(JSONObject payConfig, String orderNum, String merSeqDate, long origTransAmt, + long transAmt, String timeStamp) { + // 浜岀骇鍟嗘埛鍙� + String subMerchantId = payConfig.getString("subMerchantId"); + //浜ゆ槗鏈烘瀯鍙� + String branchId = payConfig.getString("branchId"); + String tradeQueryResp = nxHttpClientUtils.returntrans(subMerchantId, branchId, orderNum, merSeqDate, origTransAmt, transAmt, timeStamp); + JSONObject tradeQueryRespObj = JSONObject.parseObject(tradeQueryResp); + String respCode = tradeQueryRespObj.getString("code"); + if (!"000000".equals(respCode)) { + log.error("娌冲崡鍐滀俊-閫�娆惧け璐ワ紒閿欒缁撴灉鐮�:{},閿欒缁撴灉鎻忚堪:{}", respCode, tradeQueryRespObj.getString("message")); + return new CommonResult<>(CommonResultEmnu.ERROR, tradeQueryRespObj.getString("message")); + } + return new CommonResult(tradeQueryRespObj); + } + + /*** 瀵硅处鏌ヨ + * String subMerchantId, String branchId, + * + * @param clearDate 瀵硅处鏃ユ湡 YYYY-MM-DD + * @param branchId 浜ゆ槗鏈烘瀯鍙� + * @return + */ + public CommonResult<JSONObject> accountqry(String clearDate, String branchId) { + String tradeQueryResp = nxHttpClientUtils.accountqry(clearDate, branchId); + JSONObject tradeQueryRespObj = JSONObject.parseObject(tradeQueryResp); + String respCode = tradeQueryRespObj.getString("code"); + if (!"000000".equals(respCode)) { + log.error("娌冲崡鍐滀俊-璁㈠崟浜ゆ槗鐘舵�佹煡璇㈠け璐ワ紒閿欒缁撴灉鐮�:{},閿欒缁撴灉鎻忚堪:{}", respCode, tradeQueryRespObj.getString("message")); + return new CommonResult<>(CommonResultEmnu.ERROR, tradeQueryRespObj.getString("message")); + } + return new CommonResult(tradeQueryRespObj); + } + + /** + * 寰俊灏忕▼搴忔敮浠� + * + * @param payConfig + * @param orderId + * @param payMoney + * @param title + * @param goodsInfo + * @param authCode + * @param notifyUrl + * @param timeStamp + * @return + */ + public CommonResult<JSONObject> wechatMiniPay(JSONObject payConfig, String orderId, Long payMoney, String title, String goodsInfo, String authCode, String notifyUrl, + String timeStamp) { + log.info("銆愭渤鍗楀啘淇�-C鎵獴寰俊鏀粯銆� 缁熶竴涓嬪崟寮�濮�, 璁㈠崟缂栧彿=" + orderId); + //楠岃瘉閲戦 + if (payMoney <= 0 && payMoney <= 0) { + return new CommonResult<>(CommonResultEmnu.ERROR, "鏀粯澶辫触,涓嶈兘0鍏冩敮浠橈紒"); + } + // 浜岀骇鍟嗘埛鍙� + String subMerchantId = payConfig.getString("subMerchantId"); + //浜ゆ槗鏈烘瀯鍙� + String branchId = payConfig.getString("branchId"); + String operatorId = payConfig.getString("operatorId"); + + // 鍐滀俊 寰俊鏀粯 + String onlinePayResp = null; + + onlinePayResp = nxHttpClientUtils.qrCodePrePay(subMerchantId, branchId, operatorId, orderId, authCode, payMoney, timeStamp, "03", 'C', notifyUrl, title); + + JSONObject onlinePayRespObj = JSONObject.parseObject(onlinePayResp); + String respCode = onlinePayRespObj.getString("code"); + if (!"000000".equals(respCode)) { + log.error("娌冲崡鍐滀俊-C鎵獴鏀粯涓嬪崟澶辫触锛侀敊璇粨鏋滅爜:{},閿欒缁撴灉鎻忚堪:{}", respCode, onlinePayRespObj.getString("message")); + return new CommonResult<>(CommonResultEmnu.ERROR, onlinePayRespObj.getString("message")); + } + JSONObject onlinePayResult = onlinePayRespObj.getJSONObject("payload"); + onlinePayRespObj.put("toPayMethod", "2"); + JSONObject resultMap = nxPreConvertWxParam(onlinePayResult); + onlinePayRespObj.put("paymentData", resultMap); + onlinePayRespObj.remove("payload"); +// OrderQueryTask orderQueryTask = ApplicationContextUtil.getBean(OrderQueryTask.class); +// orderQueryTask.setOrderId(orderId); +// orderQueryTask.setPayService((short) 7); +// orderQueryTask.setPayType((short) 1); +// orderQueryTask.setOrderPayTime(new Date()); + OrderQueryTask orderQueryTask = new OrderQueryTask(eventPublisher, this,nxPayConfig,orderId,(short)7,(short)1,new Date()); + OrderQueryUtil.addTask(orderQueryTask); + return new CommonResult(resultMap); + } + + /** + * + * @param payConfig + * @param orderId + * @param payMoney + * @param title + * @param goodsInfo + * @param timeStamp yyyyMMddHHmmssSSS鏍煎紡 + * @return + */ + public CommonResult<JSONObject> kjTrade(JSONObject payConfig, String orderId, Long payMoney, String title, String goodsInfo, + String timeStamp, String frontUrl) { + String kjSubMerchantId = payConfig.getString("kjSubMerchantId"); + String location = null; + try { + location = nxHttpClientUtils.quickPayRequest(kjSubMerchantId, orderId, payMoney, + timeStamp, frontUrl, + PropertiesConstants.STQ_SERVER + HnnxConstant.NX_KJ_ALL_CALL_BACK, +// "http://1.14.252.104:7101/service-merchant" + HnnxConstant.NX_KJ_ALL_CALL_BACK, + title); + } catch (Exception e) { + log.error("娌冲崡鍐滀俊-蹇嵎鏀粯 涓嬪崟澶辫触锛侀敊璇粨鏋滄弿杩�:{}", e.getMessage()); + return new CommonResult<>(CommonResultEmnu.ERROR, e.getMessage()); + } + + JSONObject onlinePayResult = new JSONObject(); + onlinePayResult.put("paymentUrl", location); + onlinePayResult.put("codeUrl", location); + onlinePayResult.put("toPayMethod", "3"); +// OrderQueryTask orderQueryTask = ApplicationContextUtil.getBean(OrderQueryTask.class); +// orderQueryTask.setOrderId(orderId); +// orderQueryTask.setPayService((short) 7); +// orderQueryTask.setPayType((short) 1); +// orderQueryTask.setOrderPayTime(new Date()); + OrderQueryTask orderQueryTask = new OrderQueryTask(eventPublisher, this,nxPayConfig,orderId,(short)7,(short)1,new Date()); + OrderQueryUtil.addTask(orderQueryTask); + return new CommonResult(onlinePayResult); + } + + /** + * 璁㈠崟浜ゆ槗鐘舵�佹煡璇� + * + * @return + */ + public CommonResult<JSONArray> kjTradeQuery(String orderNum, String startDate, String endDate, Integer pageSize, Integer pageNum) { + String tradeQueryResp = nxHttpClientUtils.quickPayOrderQueryRequest(orderNum, startDate, endDate, Convert.toInt(pageSize, 1), Convert.toInt(pageNum, 1)); + if (StringUtils.isEmpty(tradeQueryResp)) { + return new CommonResult<>(CommonResultEmnu.ERROR, "鏈煡璇㈠埌鏁版嵁"); + } + JSONObject tradeQueryRespObj = JSONObject.parseObject(tradeQueryResp); + Integer totalNum = tradeQueryRespObj.getInteger("TotalNum"); + if (totalNum == null || totalNum == 0) { + return new CommonResult<>(CommonResultEmnu.ERROR, "鏈煡璇㈠埌鏁版嵁"); + } + JSONArray orderList = tradeQueryRespObj.getJSONArray("OrderList"); + return new CommonResult(orderList); + } + + /** + * 閫�娆� + * + * @param orderNum 瑕侀��娆剧殑璁㈠崟鍙� + * @param merSeqDate 瑕侀��娆剧殑璁㈠崟浜ゆ槗鏃ユ湡 渚嬶細20190810 + * @param origTransAmt 瑕侀��娆剧殑璁㈠崟鐨勪氦鏄撻噾棰� + * @param transAmt 閫�娆鹃噾棰� + * @param timeStamp 褰撳墠鏃ユ湡 渚嬶細yyyyMMddHHmmss + * @return + */ + public CommonResult<JSONObject> kjReturntrans(JSONObject payConfig, String orderNum, String merSeqDate, long origTransAmt, + long transAmt, String timeStamp) { + // 浜岀骇鍟嗘埛鍙� + String subMerchantId = payConfig.getString("kjSubMerchantId"); + //浜ゆ槗鏈烘瀯鍙� + String tradeQueryResp = nxHttpClientUtils.quickPayReturntrans(subMerchantId, orderNum, merSeqDate, origTransAmt, transAmt, timeStamp); + JSONObject tradeQueryRespObj = JSONObject.parseObject(tradeQueryResp); + String respCode = tradeQueryRespObj.getString("ReturnCode"); + if (!"000000".equals(respCode)) { + log.error("娌冲崡鍐滀俊-閫�娆惧け璐ワ紒閿欒缁撴灉鐮�:{},閿欒缁撴灉鎻忚堪:{}", respCode, tradeQueryRespObj.getString("ReturnMsg")); + return new CommonResult<>(CommonResultEmnu.ERROR, tradeQueryRespObj.getString("ReturnMsg")); + } + return new CommonResult(tradeQueryRespObj); + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/SignatureSigner.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/SignatureSigner.java new file mode 100644 index 0000000..4fd678a --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/hnnxPay/SignatureSigner.java @@ -0,0 +1,130 @@ +package com.nuvole.hnnx.hnnxPay; + +import com.csii.sg.codec.Hex; +import org.springframework.util.Assert; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; +import java.security.PrivateKey; +import java.security.Signature; +import java.util.*; + +/** + * @author awlwen + * @since 2017/11/30 + */ +public class SignatureSigner { + /** + * 灏嗗瓧鑺傛暟缁勮浆鎹负16杩涘埗瀛楃涓� + * 绠楁硶锛� + * 灏嗗瓧鑺傛暟缁勪腑姣忎釜瀛楄妭鍙栧嚭鍚庤浆鎹负16杩涘埗锛屾埅鍙栦綆鍏綅 + * 灏嗕笉瓒�2浣嶇殑瀛楃鍓嶈ˉ0锛岃В鏋愭椂鍙寜2浣嶅垎闅� + * + * @param byteArray 瀛楄妭鏁扮粍 + * @return 16杩涘埗瀛楃 + */ + private String byteToHex(byte[] byteArray) { + if (byteArray == null) { + return ""; + } + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < byteArray.length; i++) { + String hexString = Integer.toHexString(byteArray[i] & 0x00ff); + if (hexString.length() != 2) { + //濡傛灉瀛楃闀垮害涓嶄负2浣嶏紝鍓嶈ˉ0鍗犱綅 + sb.append("0"); + } + sb.append(hexString); + } + return sb.toString(); + } + +private static byte[] signLow(String plain, String algorithm, PrivateKey privateKey) { + Assert.notNull(plain, "plain is null."); + Assert.notNull(algorithm, "algorithm is null."); + Assert.notNull(privateKey, "private key is null."); + try { + Signature sign = Signature.getInstance(algorithm); + sign.initSign(privateKey); + sign.update(plain.getBytes()); + return sign.sign(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + +private static byte[] signLowByte(byte[] plain, String algorithm, PrivateKey privateKey) { + Assert.notNull(plain, "plain is null."); + Assert.notNull(algorithm, "algorithm is null."); + Assert.notNull(privateKey, "private key is null."); + try { + Signature sign = Signature.getInstance(algorithm); + sign.initSign(privateKey); + sign.update(plain); + return sign.sign(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + public static String laBaSign(Map<String, String> parameters, String accessKeySecret) { + // Step 1: Sort the parameters by key in ascending order + List<Map.Entry<String, String>> sortedParams = new ArrayList<>(parameters.entrySet()); + Collections.sort(sortedParams, Comparator.comparing(Map.Entry::getKey)); + + // Step 2: Generate the string to sign + StringBuilder stringToSign = new StringBuilder(); + for (Map.Entry<String, String> param : sortedParams) { + if (param.getValue() != null && !param.getValue().isEmpty()) { + stringToSign.append(param.getKey()).append("=").append(param.getValue()).append("&"); + } + } + stringToSign.deleteCharAt(stringToSign.length() - 1); // Remove the last '&' + + // Step 3: Generate the signature + try { + Mac hmacSha256 = Mac.getInstance("HmacSHA256"); + SecretKeySpec keySpec = new SecretKeySpec(accessKeySecret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"); + hmacSha256.init(keySpec); + byte[] signData = hmacSha256.doFinal(stringToSign.toString().getBytes(StandardCharsets.UTF_8)); + + // Step 4: Base64 encode the signature + return Base64.getEncoder().encodeToString(signData); + } catch (Exception e) { + e.printStackTrace(); + } + + return null; + } + /** + * 浣跨敤鎻愪緵鐨勭畻娉曚笌绉侀挜瀵逛氦鏄撴暟鎹鍚� + * + * @param plain 浜ゆ槗鏁版嵁鏄庢枃 + * @param privateKey java.security.PrivateKey 绉侀挜 + * @return 绛惧悕 + */ + public String sign(String plain, PrivateKey privateKey) { + byte[] bytes = signLow(plain, HnnxConstant.ALGORITHM, privateKey); + return Hex.toHex(bytes); + } + + /** + * 蹇嵎鏀粯sign + * + * @param plain + * @param privateKey + * @return + */ + public String kjSign(String plain, PrivateKey privateKey) { + byte[] bytes = new byte[0]; + try { + bytes = signLowByte(plain.getBytes("utf-8"), HnnxConstant.KJ_ALGORITHM, privateKey); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return Base64.getEncoder().encodeToString(bytes); + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryEvent.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryEvent.java new file mode 100644 index 0000000..dbb841c --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryEvent.java @@ -0,0 +1,23 @@ +package com.nuvole.hnnx.orderQueryTask; + +import org.springframework.context.ApplicationEvent; + +/** + * @ClassName OrderQueryEvent + * @Author cy + * @Date 2024/1/2 + * @Description + * @Version 1.0 + **/ +public class OrderQueryEvent extends ApplicationEvent { + private OrderQueryMessageEntity messageEntity; + + public OrderQueryEvent(Object source, OrderQueryMessageEntity messageEntity) { + super(source); + this.messageEntity = messageEntity; + } + + public OrderQueryMessageEntity getMessageEntity() { + return this.messageEntity; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryMessageEntity.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryMessageEntity.java new file mode 100644 index 0000000..3c1250f --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryMessageEntity.java @@ -0,0 +1,58 @@ +package com.nuvole.hnnx.orderQueryTask; + +/** + * @ClassName OrderQueryMessageEntity + * @Author cy + * @Date 2024/1/2 + * @Description + * @Version 1.0 + **/ + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description 娑堟伅瀹炰綋绫� + **/ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class OrderQueryMessageEntity { + /** + * 10000 璁㈠崟鏌ヨ,鍚庣画鍙坊鍔犲叾浠� + */ + String code; + /** + * SQ 鍟嗗湀璁㈠崟 + * SC 鍟嗗煄璁㈠崟 + * SM H5鎵爜浠樿鍗� + * DTCSB 鍟嗗APP鍔ㄦ�佷富鎵紙C鎵獴锛� + * BSC 鐢ㄦ埛鍑虹ず浠樻鐮� B鎵獵 + */ + String orderChannel; + /** + * 绯荤粺璁㈠崟鍙� + */ + String orderId; + /** + * 鍐滀俊绛変笁鏂规敮浠樼郴缁熺殑璁㈠崟鍙� + */ + String outTradeNo; + /** + * 1.寰俊鏀粯 2.蹇嵎鏀粯 + */ + Short orderType; + + /** + * 鏀粯鏈嶅姟鎻愪緵鍟� + */ + Short payService; + + /** + * 灏濊瘯鏀粯鐨勬鏁帮紝鐢ㄤ簬鐢熸垚閫氳仈鍗曞彿 + */ + Short tryPayNum; +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryTask.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryTask.java new file mode 100644 index 0000000..caafdb7 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryTask.java @@ -0,0 +1,152 @@ +package com.nuvole.hnnx.orderQueryTask; + +import cn.hutool.core.convert.Convert; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.nuvole.common.domain.emnu.CommonResultEmnu; +import com.nuvole.common.domain.result.CommonResult; +import com.nuvole.hnnx.conf.NxPayConfig; +import com.nuvole.hnnx.hnnxPay.NXPayService; +import io.swagger.annotations.ApiModelProperty; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.ApplicationEventPublisher; + +import java.util.Date; + +/** + * @ClassName OrderQueryTask + * @Author cy + * @Date 2024/1/2 + * @Description + * @Version 1.0 + **/ +@Slf4j +//@Component +//@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class OrderQueryTask implements Runnable { +// @Autowired + private ApplicationEventPublisher eventPublisher; +// @Autowired + private NXPayService nxPayService; +// @Autowired + private NxPayConfig nxPayConfig; + + @ApiModelProperty("璁㈠崟ID") + private String orderId; + + @ApiModelProperty("鏀粯鏈嶅姟鍟�") + private Short payService; + + @ApiModelProperty("鍐滀俊闇�瑕佸尯鍒嗘槸鍚︿负蹇嵎鏀粯 1 鏅�氭敮浠� 2蹇嵎鏀粯") + private Short payType; + + @ApiModelProperty("璁㈠崟灏濊瘯鏀粯鏃堕棿") + private Date orderPayTime; + + + @Override + public void run() { + Date nowTime = new Date(); + long lastDuration = nowTime.getTime() - orderPayTime.getTime(); + if (lastDuration > 10 * 60 * 1000) { + log.error("10閽熷墠鐨勮鍗曪紝鍙栨秷浠诲姟:{}", orderId); + OrderQueryUtil.cancelTask(orderId); + return; + } + log.info("鏌ヨ璁㈠崟涓簕}, 璁㈠崟鍒濆鏀粯鏃堕棿涓簕}", orderId, orderPayTime); + boolean isPaySuccess = false; + + String[] orderInfoArr = orderId.split("-"); + String orderChannel = orderInfoArr[0]; + String myOrderId = orderInfoArr[1]; + Short tryPayNum = Convert.toShort(orderInfoArr[3],null); + String outTradeNo = null; + + if (payService == 7) { + if (payType == 1) { + JSONObject payConfig = new JSONObject(); + payConfig.put("branchId", nxPayConfig.getBranchId()); + CommonResult<JSONObject> tradeQueryResult = nxPayService.tradeQuery(payConfig, orderId); + // TransStatus 0 浜ゆ槗鎴愬姛 1 浜ゆ槗澶辫触 2 鎾ら攢 3 閮ㄥ垎閫�璐� 4 鍏ㄩ儴閫�璐� 5 澶勭悊涓� 9 浜ゆ槗瓒呮椂 + if (!tradeQueryResult.getCode().equals(CommonResultEmnu.OK.getCode())) { + OrderQueryUtil.cancelTask(orderId); + return; + } + JSONObject tradeQueryResultJson = tradeQueryResult.getData(); + JSONObject payload = tradeQueryResultJson.getJSONObject("payload"); + Integer transStatus = payload.getInteger("TransStatus"); + if (transStatus != null) { + if (transStatus == 0) { + isPaySuccess = true; + outTradeNo = payload.getString("TransSeqNbr"); + } else if (transStatus == 1 || transStatus == 9) { + log.error("浜ゆ槗澶辫触 鎴� 浜ゆ槗瓒呮椂锛屽彇娑堜换鍔�.{}", orderId); + OrderQueryUtil.cancelTask(orderId); + } + } + } else if (payType == 2) { + //orderStatus 0-寰呮敮浠� 1-鎴愬姛 2-澶辫触 3-澶勭悊涓� 4-璁㈠崟鍙栨秷 + CommonResult<JSONArray> tradeQueryResult = nxPayService.kjTradeQuery(orderId, null, null, 1, 1); + if (!tradeQueryResult.getCode().equals(CommonResultEmnu.OK.getCode())) { + OrderQueryUtil.cancelTask(orderId); + return; + } + JSONArray tradeQueryResultJsonArr = tradeQueryResult.getData(); + if (tradeQueryResultJsonArr != null && tradeQueryResultJsonArr.size() > 0){ + JSONObject tradeQueryResultJson = (JSONObject) tradeQueryResultJsonArr.get(0); + Integer transStatus = tradeQueryResultJson.getInteger("orderStatus"); + if (transStatus != null) { + if (transStatus == 1) { + isPaySuccess = true; + outTradeNo = tradeQueryResultJson.getString("TransSeqNbr"); + } else if (transStatus == 2 || transStatus == 4) { + log.error("浜ゆ槗澶辫触 鎴� 璁㈠崟鍙栨秷锛屽彇娑堜换鍔�.{}", orderId); + OrderQueryUtil.cancelTask(orderId); + } + } + } + + + } else { + log.error("鏀粯鏂瑰紡閿欒锛屽彇娑堜换鍔�.{}", orderId); + OrderQueryUtil.cancelTask(orderId); + } + } else { + log.error("鐩墠闄ゅ啘淇″锛屽叾浠栨殏涓嶆煡璇�"); + OrderQueryUtil.cancelTask(orderId); + } + // 鍒ゆ柇鏀粯鐘舵�侊紝纭畾鏄惁鍙戦�侀�氱煡 + if (isPaySuccess) { + eventPublisher.publishEvent(new OrderQueryEvent(this, + OrderQueryMessageEntity.builder().code("10000").orderChannel(orderChannel).orderId(myOrderId).outTradeNo(outTradeNo).payService(payService).tryPayNum(tryPayNum).build())); + OrderQueryUtil.cancelTask(orderId); + } + + } + + public OrderQueryTask(ApplicationEventPublisher eventPublisher, NXPayService nxPayService, NxPayConfig nxPayConfig, String orderId, Short payService, Short payType, Date orderPayTime) { + this.eventPublisher = eventPublisher; + this.nxPayService = nxPayService; + this.nxPayConfig = nxPayConfig; + this.orderId = orderId; + this.payService = payService; + this.payType = payType; + this.orderPayTime = orderPayTime; + } + + public String getOrderId() { + return orderId; + } + + public Short getPayService() { + return payService; + } + + public Short getPayType() { + return payType; + } + + public Date getOrderPayTime() { + return orderPayTime; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryTrigger.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryTrigger.java new file mode 100644 index 0000000..01e383a --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryTrigger.java @@ -0,0 +1,70 @@ +package com.nuvole.hnnx.orderQueryTask; + +import io.swagger.annotations.ApiModelProperty; +import org.springframework.scheduling.Trigger; +import org.springframework.scheduling.TriggerContext; + +import java.time.Instant; +import java.util.Date; + +/** + * @ClassName OrderQueryTrigger + * @Author cy + * @Date 2024/1/2 + * @Description + * @Version 1.0 + **/ +public class OrderQueryTrigger implements Trigger { + @ApiModelProperty("璁㈠崟灏濊瘯鏀粯鏃堕棿") + private Date orderPayTime; + +// @Override +// public Date nextExecutionTime(TriggerContext triggerContext) { +// // 鏍规嵁涓嶅悓鐨勬椂闂存杩斿洖涓嬩竴娆℃墽琛屼换鍔$殑鏃堕棿 +// Date nowTime = new Date(); +// +// long lastDuration = nowTime.getTime() - orderPayTime.getTime(); +// +// // 鏍规嵁鏃堕棿娈佃缃笉鍚岀殑鎵ц闂撮殧 +// //闂撮殧鏃堕棿 鏌ヨ棰戠巼 +// //(0~10] 2s +// //(10~30] 5s +// //(30~60] 15s +// //(60~180] 60s +// if (lastDuration <= 10000) { +// return new Date(System.currentTimeMillis() + 2000); +// } else if (lastDuration <= 30000) { +// return new Date(System.currentTimeMillis() + 5000); +// } else if (lastDuration <= 60000) { +// return new Date(System.currentTimeMillis() + 15000); +// } else { +// return new Date(System.currentTimeMillis() + 60000); +// } +// } + + @Override + public Instant nextExecution(TriggerContext triggerContext) { + + // 鏍规嵁涓嶅悓鐨勬椂闂存杩斿洖涓嬩竴娆℃墽琛屼换鍔$殑鏃堕棿 + long lastDuration = System.currentTimeMillis() - orderPayTime.getTime(); + + // 鏍规嵁鏃堕棿娈佃缃笉鍚岀殑鎵ц闂撮殧 + //闂撮殧鏃堕棿 鏌ヨ棰戠巼 + //(0~10] 2s + //(10~30] 5s + //(30~60] 15s + //(60~180] 60s + if (lastDuration <= 10000) { + return Instant.ofEpochMilli(System.currentTimeMillis() + 2000); + } else if (lastDuration <= 30000) { + return Instant.ofEpochMilli(System.currentTimeMillis() + 5000); + } else if (lastDuration <= 60000) { + return Instant.ofEpochMilli(System.currentTimeMillis() + 15000); + } else { + return Instant.ofEpochMilli(System.currentTimeMillis() + 60000); + } + } + public OrderQueryTrigger(Date orderPayTime) { + this.orderPayTime = orderPayTime; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryUtil.java new file mode 100644 index 0000000..0731701 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/hnnx/orderQueryTask/OrderQueryUtil.java @@ -0,0 +1,61 @@ +package com.nuvole.hnnx.orderQueryTask; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.TaskScheduler; +import org.springframework.scheduling.concurrent.DefaultManagedTaskScheduler; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ScheduledFuture; + +/** + * @ClassName OrderQueryUtil + * @Author cy + * @Date 2024/1/2 + * @Description + * @Version 1.0 + **/ +@Slf4j +//@Component +public class OrderQueryUtil { + + private static TaskScheduler taskScheduler = new DefaultManagedTaskScheduler(); + +// @Autowired +// public void setTaskScheduler(TaskScheduler taskScheduler) { +// OrderQueryUtil.taskScheduler = taskScheduler; +// } + + // 鐢ㄤ簬鍙栨秷浠诲姟 + private static Map<String, ScheduledFuture> taskMap = new ConcurrentHashMap<>(); + + public static Map<String, ScheduledFuture> getTaskMap() { + return taskMap; + } + + private static TaskScheduler getExecutor() { + return taskScheduler; + } + + + public static ScheduledFuture addTask(OrderQueryTask task) { + + ScheduledFuture scheduledFuture = getExecutor().schedule(task, new OrderQueryTrigger(task.getOrderPayTime())); + taskMap.put(task.getOrderId(), scheduledFuture); + log.info("鏂板璁㈠崟鍙蜂负{}, 璁㈠崟鍒濆鏀粯鏃堕棿涓簕}", task.getOrderId(), task.getOrderPayTime()); + return scheduledFuture; + } + + public static void cancelTask(ScheduledFuture future) { + future.cancel(true); + } + + public static void cancelTask(String taskId) { + log.info("鍙栨秷璁㈠崟鍙蜂负{}", taskId); + ScheduledFuture future = taskMap.remove(taskId); + if (future != null) { + future.cancel(true); + } + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/laba/LabaPushUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/laba/LabaPushUtil.java new file mode 100644 index 0000000..09327eb --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/laba/LabaPushUtil.java @@ -0,0 +1,31 @@ +//package com.nuvole.laba; +// +//import com.nuvole.laba.conf.LaBaPushConfig; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Component; +// +///** +// * @ClassName laba +// * @Author cy +// * @Date 2023/12/4 +// * @Description +// * @Version 1.0 +// **/ +//@Component +//public class LabaPushUtil { +// private static LaBaPushConfig laBaPushConfig; +// +// @Autowired +// public void setLaBaPushConfig(LaBaPushConfig laBaPushConfig) { +// LabaPushUtil.laBaPushConfig = laBaPushConfig; +// } +// +// public static void sendMsg(String message) { +// // 浣跨敤apiProperties涓殑key鍜宻ecret鏉ュ彂閫佹秷鎭� +// String serverUrl = laBaPushConfig.getServerUrl(); +// String key = laBaPushConfig.getAccessKeyId(); +// String secret = laBaPushConfig.getAccessKeySecret(); +// +// // 瀹炵幇娑堟伅鍙戦�侀�昏緫... +// } +//} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/api/PoscomService.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/api/PoscomService.java new file mode 100644 index 0000000..5ee09d5 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/api/PoscomService.java @@ -0,0 +1,197 @@ +package com.nuvole.poscom.api; + +import com.alibaba.fastjson.JSONObject; +import com.nuvole.common.domain.result.CommonResult; +import com.nuvole.poscom.config.PoscomConfig; +import com.nuvole.poscom.config.PoscomPrintData; +import com.nuvole.poscom.config.TempletParams; +import com.nuvole.poscom.util.PoscomRequest; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.codec.digest.DigestUtils; + +import java.util.Calendar; +import java.util.HashMap; +import java.util.Map; + +/** + * @Description 浣冲崥浜戞墦鍗版満鎺ュ彛 + * @Author ZHAOXL + * @Date 2024/3/6 16:24 + * @Version 1.0 + */ +@Slf4j +public class PoscomService { + + /** + * 娣诲姞鎵撳嵃鏈� + * @param deviceID* 缁堢缂栧彿銆� + * @param deviceName* 璁惧鍚嶇О锛屾渶澶�64浣嶆暟鎹暱搴︺�� + * @param grpID 鍒嗙粍 ID 銆� + * @return CommonResult + * @Author ZHAOXL + * @Date 2024/3/6 16:53 + * @Version 1.0 + */ + public static CommonResult<JSONObject> addDev(String deviceID, String deviceName, Integer grpID) { + Map<String, String> params = new HashMap<String, String>(); + String reqTime = String.valueOf(Calendar.getInstance().getTimeInMillis()); + params.put("reqTime", reqTime); + String securityCode = DigestUtils.md5Hex(PoscomConfig.memberCode + reqTime + PoscomConfig.apiKey + deviceID); + params.put("securityCode", securityCode); + params.put("memberCode", PoscomConfig.memberCode); + params.put("deviceID", deviceID); + params.put("devName", deviceName); + if (grpID != null) { + params.put("grpID", grpID + ""); + } + log.debug("=====璇锋眰鍙傛暟 START=====\r\n" + "---> adddev <---\r\n" + params + "\r\n=====璇锋眰鍙傛暟 END====="); + String result = PoscomRequest.sendPost("http://api.poscom.cn/apisc/adddev", params); + log.debug("=====璇锋眰杩斿洖 START=====\r\n" + result + "\r\n=====璇锋眰杩斿洖 END====="); + JSONObject resultObject = JSONObject.parseObject(result); + return new CommonResult(resultObject); + } + + /** + * 鎵撳嵃鏈哄垏鎹㈡挱鎶ョ被鍨� + * @param deviceID* 缁堢缂栧彿銆� + * @param voiceType* 璇煶绫诲瀷銆�0 鐪熶汉璇煶锛�1 婊存淮璇煶锛�2 涓嶈嚜鍔ㄦ挱鏀炬柊璁㈠崟锛岀湡浜鸿闊筹紝3 涓嶈嚜鍔ㄦ挱鏀炬柊璁㈠崟锛屾淮婊磋闊炽�� + * @return + * @Author ZHAOXL + * @Date 2024/3/7 15:48 + * @Version 1.0 + */ + public static CommonResult<JSONObject> setVoiceType(String deviceID, String voiceType) { + Map<String, String> params = new HashMap<String, String>(); + String reqTime = String.valueOf(Calendar.getInstance().getTimeInMillis()); + params.put("reqTime", reqTime); + String securityCode = DigestUtils.md5Hex(PoscomConfig.memberCode + reqTime + PoscomConfig.apiKey + deviceID); + params.put("securityCode", securityCode); + params.put("memberCode", PoscomConfig.memberCode); + params.put("deviceID", deviceID); + params.put("voiceType", voiceType); + log.debug("=====璇锋眰鍙傛暟 START=====\r\n" + "---> setVoiceType <---\r\n" + params + "\r\n=====璇锋眰鍙傛暟 END====="); + String result = PoscomRequest.sendPost("http://api.poscom.cn/apisc/setVoiceType", params); + log.debug("=====璇锋眰杩斿洖 START=====\r\n" + result + "\r\n=====璇锋眰杩斿洖 END====="); + JSONObject resultObject = JSONObject.parseObject(result); + return new CommonResult(resultObject); + } + + /** + * 鍒犻櫎鎵撳嵃鏈� + * @param deviceID* 缁堢缂栧彿銆� + * @return CommonResult + * @Author ZHAOXL + * @Date 2024/3/7 9:47 + * @Version 1.0 + */ + public static CommonResult<JSONObject> delDev(String deviceID) { + Map<String, String> params = new HashMap<String, String>(); + String reqTime = String.valueOf(Calendar.getInstance().getTimeInMillis()); + params.put("reqTime", reqTime); + String securityCode = DigestUtils.md5Hex(PoscomConfig.memberCode + reqTime + PoscomConfig.apiKey + deviceID); + params.put("securityCode", securityCode); + params.put("memberCode", PoscomConfig.memberCode); + params.put("deviceID", deviceID); + log.debug("=====璇锋眰鍙傛暟 START=====\r\n" + "---> deldev <---\r\n" + params + "\r\n=====璇锋眰鍙傛暟 END====="); + String result = PoscomRequest.sendPost("http://api.poscom.cn/apisc/deldev", params); + log.debug("=====璇锋眰杩斿洖 START=====\r\n" + result + "\r\n=====璇锋眰杩斿洖 END====="); + JSONObject resultObject = JSONObject.parseObject(result); + return new CommonResult(resultObject); + } + + /** + * 鎸囧畾妯℃澘鎵撳嵃 + * @param deviceID* 缁堢缂栧彿銆� + * @param templetParams* 妯℃澘鍙傛暟 + * @return CommonResult + * @Author ZHAOXL + * @Date 2024/3/7 10:19 + * @Version 1.0 + */ + public static CommonResult<JSONObject> templetPrint(String deviceID, TempletParams templetParams) { + Map<String, String> params = new HashMap<String, String>(); + String reqTime = String.valueOf(Calendar.getInstance().getTimeInMillis()); + params.put("reqTime", reqTime); + String securityCode = DigestUtils.md5Hex(PoscomConfig.memberCode + deviceID + reqTime + PoscomConfig.apiKey); + params.put("securityCode", securityCode); + params.put("memberCode", PoscomConfig.memberCode); + params.put("deviceID", deviceID); + params.put("templetID", PoscomConfig.templetId); + String tData = JSONObject.toJSONString(templetParams); + params.put("tData", tData); + params.put("charset","1"); //Default:1, 1:GB18030, 2:GB2312, 3:GBK, 4:UTF-8, 5:Unicode, 6:ISO8859-1, 7:BIG5 + params.put("msgNo",""); + params.put("reprint","0"); + params.put("multi","0"); + params.put("times",""); + params.put("token", ""); + log.debug("=====璇锋眰鍙傛暟 START=====\r\n" + "---> templetPrint <---\r\n" + params + "\r\n=====璇锋眰鍙傛暟 END====="); + String result = PoscomRequest.sendPost("http://api.poscom.cn/apisc/templetPrint", params); + log.debug("=====璇锋眰杩斿洖 START=====\r\n" + result + "\r\n=====璇锋眰杩斿洖 END====="); + JSONObject resultObject = JSONObject.parseObject(result); + return new CommonResult(resultObject); + } + + /** + * 鍙戦�佽闊冲埌鎵撳嵃鏈� + * @param* 缁堢缂栧彿銆� + * @param* 璇煶鍐呭銆� + * @return + * @Author ZHAOXL + * @Date 2024/3/7 10:29 + * @Version 1.0 + */ + public static CommonResult<JSONObject> sendVoice(String deviceID, String voice) { + Map<String, String> params = new HashMap<String, String>(); + String reqTime = String.valueOf(Calendar.getInstance().getTimeInMillis()); + params.put("reqTime", reqTime); + String securityCode = DigestUtils.md5Hex(PoscomConfig.memberCode + deviceID + reqTime + PoscomConfig.apiKey); + params.put("securityCode", securityCode); + params.put("memberCode", PoscomConfig.memberCode); + params.put("deviceID", deviceID); + params.put("voice", voice); + params.put("token", ""); + log.debug("=====璇锋眰鍙傛暟 START=====\r\n" + "---> sendVoice <---\r\n" + params + "\r\n=====璇锋眰鍙傛暟 END====="); + String result = PoscomRequest.sendPost("http://api.poscom.cn/apisc/sendVoice", params); + log.debug("=====璇锋眰杩斿洖 START=====\r\n" + result + "\r\n=====璇锋眰杩斿洖 END====="); + JSONObject resultObject = JSONObject.parseObject(result); + return new CommonResult(resultObject); + } + + public static CommonResult<JSONObject> sendMsg(String deviceID) { + Map<String, String> params = new HashMap<String, String>(); + String reqTime = String.valueOf(Calendar.getInstance().getTimeInMillis()); + params.put("reqTime", reqTime); + String securityCode = DigestUtils.md5Hex(PoscomConfig.memberCode + deviceID + reqTime + reqTime + PoscomConfig.apiKey); + params.put("securityCode", securityCode); + params.put("memberCode", PoscomConfig.memberCode); + params.put("deviceID", deviceID); + //-----绁ㄦ嵁鎵撳嵃鏈� 鏍煎紡绫诲瀷:2 + params.put("mode", "2"); + params.put("msgDetail", PoscomPrintData.ReceiptData2); + //-----绁ㄦ嵁鎵撳嵃鏈� 鏍煎紡绫诲瀷:2 + params.put("charset","1"); //Default:1, 1:GB18030, 2:GB2312, 3:GBK, 4:UTF-8, 5:Unicode, 6:ISO8859-1, 7:BIG5 + params.put("msgNo", reqTime); + log.debug("=====璇锋眰鍙傛暟 START=====\r\n" + "---> sendMsg <---\r\n" + params + "\r\n=====璇锋眰鍙傛暟 END====="); + String result = PoscomRequest.sendPost("http://api.poscom.cn/apisc/sendMsg", params); + log.debug("=====璇锋眰杩斿洖 START=====\r\n" + result + "\r\n=====璇锋眰杩斿洖 END====="); + JSONObject resultObject = JSONObject.parseObject(result); + return new CommonResult(resultObject); + } + + public static CommonResult<JSONObject> queryState(String deviceID) { + Map<String, String> params = new HashMap<String, String>(); + String reqTime = String.valueOf(Calendar.getInstance().getTimeInMillis()); + params.put("reqTime", reqTime); + String securityCode = DigestUtils.md5Hex(PoscomConfig.memberCode + reqTime + PoscomConfig.apiKey + reqTime); + params.put("securityCode", securityCode); + params.put("memberCode", PoscomConfig.memberCode); + params.put("msgNo", reqTime); + log.debug("=====璇锋眰鍙傛暟 START=====\r\n" + "---> sendMsg <---\r\n" + params + "\r\n=====璇锋眰鍙傛暟 END====="); + String result = PoscomRequest.sendPost("http://api.poscom.cn/apisc/queryState", params); + log.debug("=====璇锋眰杩斿洖 START=====\r\n" + result + "\r\n=====璇锋眰杩斿洖 END====="); + JSONObject resultObject = JSONObject.parseObject(result); + return new CommonResult(resultObject); + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/config/PoscomConfig.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/config/PoscomConfig.java new file mode 100644 index 0000000..d5a8d49 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/config/PoscomConfig.java @@ -0,0 +1,27 @@ +package com.nuvole.poscom.config; + +import com.nuvole.util.PropertyUtil; + +/** + * @Description 浣冲崥浜戞墦鍗版満閰嶇疆 + * @Author ZHAOXL + * @Date 2024/3/6 16:23 + * @Version 1.0 + */ +public class PoscomConfig { + + private static String fileName = "poscom.properties"; + + // 鍟嗘埛缂栫爜 + public static String memberCode; + // 璇锋眰APIKEY + public static String apiKey; + // 妯℃澘缂栧彿 + public static String templetId; + + static { + memberCode = PropertyUtil.getProp(fileName, "memberCode"); + apiKey = PropertyUtil.getProp(fileName, "apiKey"); + templetId = PropertyUtil.getProp(fileName, "templetId"); + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/config/PoscomPrintData.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/config/PoscomPrintData.java new file mode 100644 index 0000000..69f0e3a --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/config/PoscomPrintData.java @@ -0,0 +1,62 @@ +package com.nuvole.poscom.config; + +/** + * @Description 浣冲崥浜戞墦鍗版満鎵撳嵃淇℃伅鐨勫唴瀹� + * @Author ZHAOXL + * @Date 2024/3/6 17:28 + * @Version 1.0 + */ +public interface PoscomPrintData { + + //绁ㄦ嵁 mode:1 + String ReceiptData1 = "浣冲崥浜戞墦鍗帮紝鏃犵嚎鑱氬晢鏈轰簰鑱旂綉+鏃朵唬锛屼匠鍗氫簯鎵撳嵃缁堢鑳藉府鎮ㄨ交鏉惧疄鐜拌繙绋嬫墦鍗帮紝璁╂偍闅忔椂闅忓湴鎺ュ崟鐩堝埄銆傜粓绔紪鍙凤細864031028000000!@#$%^&*()_+~{};'\\,../<>?鑱旂郴閭锛歴ervice@poscom.cn 缃戝潃:http://cloud.poscom.cn"; + + //绁ㄦ嵁 mode:2 + String ReceiptData2 = "浣冲崥浜戞墦鍗帮紝鏃犵嚎鑱氬晢鏈篭r\n" + + "浜掕仈缃�+鏃朵唬锛屼匠鍗氫簯鎵撳嵃缁堢鑳藉府鎮ㄨ交鏉惧疄鐜拌繙绋嬫墦鍗帮紝璁╂偍闅忔椂闅忓湴鎺ュ崟鐩堝埄銆俓r\n" + + "<gpBarCode Type=2 Height=20 Position=2>123456789012</gpBarCode>缁堢缂栧彿锛�864031028000000\r\n" + + "1: UPC-A:\r\n" + + "<gpBarCode Type=1 Height=40 Position=0>11111111111</gpBarCode>" + + "2: JAN13(EAN13):\r\n" + + "<gpBarCode Type=2 Height=45 Position=1>222222222222</gpBarCode>" + + "3: JAN8(EAN8):\r\n" + + "<gpBarCode Type=3 Height=50 Position=2>3333333</gpBarCode>" + + "4: CODE39:\r\n" + + "<gpBarCode Type=4 Height=55 Position=3>33333</gpBarCode>" + + "5: ITF:\r\n" + + "<gpBarCode Type=5 Height=40 Position=2>444444</gpBarCode>" + + "6: CODABAR:\r\n" + + "<gpBarCode Type=6 Height=45 Position=1>A52$1+2-23C</gpBarCode>" + + "abcdefghijklmnopqrstuvwxyz\r\n" + + "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n" + + "1234567890\r\n" + + "!@#$%^&*()_+~{};'\\,../<>?\r\n" + + "<gpQRCode>http://cloud.poscom.cn</gpQRCode>"; + + //绁ㄦ嵁 mode:3 + String ReceiptData3 = "1D21221B61010D0A4120434146450D0A1B401B6101382F462C204E6F2E382C204A696E677975616E20526F61640D0A4A6964612C205A68756861692C204775616E67646F6E670D0A353139303135204368696E610D0A303735362D3838383838380D0A1B402D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0D0A494E56204E6F20B5A5BAC5C2EB3A2030312D3130303030310D0A44617465202020C8D5C6DA20203A2030362F31392F3230313720383A33353A323920414D0D0A53616C65736D616E20BEADCAD6C8CB3A20416E64790D0A437573746F6D657220B9CBBFCD20203A20434153480D0A20200D0A1B61011B2108494E564F49434520CAD5BEDD0D0A1B40200D0A4974656D0920202020205174792020202020205072696365202020202020202020202020546F74616C0D0AC6B7C3FB092020202020CAFDC1BF2020202020BCDBC7AE20202020202020202020202020D7DCCAFD0D0A2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0D0A43617070756363696E6F20202020203120202020202032382E303020202020202020202020202032382E30300D0A4C61747465202020202020202020203120202020202032382E303020202020202020202020202032382E30300D0A0D0A0D0A2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0D0A20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201B6102546F74616C3A35362E30300D0A0909090920202020202020202020202020202020202020202020202D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0D0A4772616E6420546F74616C20D7DCCAFD3A35362E30300D0A0D0A0D0A1B401B61015468616E6B20596F752E20506C6561736520436F6D6520416761696E2E0D0A0D0A200D0A1D564200"; + + //鏍囩 mode:2 + String LabelData2 = "^XA^MNN^PW480^LL0400^LH0,0^CW1,E:MSUNG.FNT^FS" + + "^CI28" + + "^FO30,20 ^A0,30,30 ^FD[190]^FS" + + "^FO20,50 ^A1,30,30 ^FD鐩殑鍦癪FS" + + "^FO120,50 ^A1,30,30 ^FD鐩殑鍦颁唬鐮乛FS" + + "^FO20,85 ^A1,30,30 ^FD濮嬪彂鍦癪FS" + + "^FO120,85 ^A1,30,30 ^FD濮嬪彂鍦颁唬鐮乛FS" + + "^FO300,60 ^A1,36,36 ^FD鏍峰紶娴嬭瘯^FS" + + "^FO20,120 ^A1,35,35 ^FD浠舵暟^FS" + + "^FO100,122 ^A0,30,30 ^FD0^FS" + + "^FO120,122 ^A0,30,30 ^FD0325^FS" + + "^FO190,122 ^A0,30,30 ^FD16:08^FS" + + "^FO 330,110 ^A0,50,50 ^FD0-0^FS" + + "^FO28,200^BY4^BCN,110,Y,N,N,N ^FD>;160637000020^FS" + + "^FO0,170^GB480,0,4^FS" + + "^FO280,0^GB,170,4^FS" + + "^FO0,0^GB480,400,4^FS" + + "^XZ"; + + //鏍囩 mode:3 + String LabelData3 = "EFBBBF5E58415E4D4E4E5E50573438305E4C4C303430305E4C48302C305E4357312C453A4D53554E472E464E545E46530D0A5E434932380D0A5E464F33302C3230205E41302C33302C3330205E46445B3139305D5E46530D0A5E464F32302C3530205E41312C33302C3330205E4644E79BAEE79A84E59CB05E46530D0A5E464F3132302C3530205E41312C33302C3330205E4644E79BAEE79A84E59CB0E4BBA3E7A0815E46530D0A5E464F32302C3835205E41312C33302C3330205E4644E5A78BE58F91E59CB05E4653220D0A5E464F3132302C3835205E41312C33302C3330205E4644E5A78BE58F91E59CB0E4BBA3E7A0815E46530D0A5E464F3330302C3630205E41312C33362C3336205E4644E6A0B7E5BCA0E6B58BE8AF955E46530D0A5E464F32302C313230205E41312C33352C3335205E4644E4BBB6E695B05E46530D0A5E464F3130302C313232205E41302C33302C3330205E4644305E46530D0A5E464F3132302C313232205E41302C33302C3330205E4644303332355E46530D0A5E464F3139302C313232205E41302C33302C3330205E464431363A30385E46530D0A5E464F203333302C313130205E41302C35302C3530205E4644302D305E46530D0A5E464F32382C3230305E4259345E42434E2C3131302C592C4E2C4E2C4E205E46443E3B3136303633373030303032305E46530D0A5E464F302C3137305E47423438302C302C345E46530D0A5E464F3238302C305E47422C3137302C345E46530D0A5E464F302C305E47423438302C3430302C345E46530D0A5E585A"; + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/config/TempletParams.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/config/TempletParams.java new file mode 100644 index 0000000..1bfcbda --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/config/TempletParams.java @@ -0,0 +1,33 @@ +package com.nuvole.poscom.config; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +/** + * @Description 妯℃澘鍙傛暟 + * @Author ZHAOXL + * @Date 2024/3/7 10:11 + * @Version 1.0 + */ +@Data +@ApiModel(value ="妯℃澘鍙傛暟") +public class TempletParams { + + // 鍟嗗簵鍚嶇О + private String shopName; + // 浜ゆ槗娴佹按 + private String payWater; + // 璁㈠崟浠锋牸 + private String orderPrice; + // 浼樻儬鍒告姷鎵� + private String couponFace; + // 绉垎鎶垫墸 + private String payIntegral; + // 鏀舵浜� + private String cashier; + // 鏀舵鏃堕棿 + private String createTime; + // 瀹炴敹閲戦 + private String payMoney; + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/PoscomRequest.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/PoscomRequest.java new file mode 100644 index 0000000..6895ad7 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/PoscomRequest.java @@ -0,0 +1,176 @@ +package com.nuvole.poscom.util; + +import com.alibaba.fastjson.JSONObject; + +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Iterator; +import java.util.Map; + +/** + * @Description 浣冲崥浜戞墦鍗版満璇锋眰绫� + * @Author ZHAOXL + * @Date 2024/3/6 16:26 + * @Version 1.0 + */ +public class PoscomRequest { + + /** + * Http Request POST Method + * + * @param urlStr 璇锋眰URL + * @param params 璇锋眰鍙傛暟 + * @return + */ + public static String sendPost(String urlStr, Map<String, String> params){ + String result = ""; + HttpURLConnection conn = null; + String BOUNDARY = "----------------------------------------------"; + int retry = 0; + while (retry < 3) { + result = ""; + try { + URL url = new URL(urlStr); + conn = (HttpURLConnection) url.openConnection(); + conn.setConnectTimeout(5000); + conn.setReadTimeout(30000); + conn.setDoOutput(true); + conn.setDoInput(true); + conn.setUseCaches(false); + conn.setRequestMethod("POST"); + + conn.setRequestProperty("Connection", "Keep-Alive"); + conn.setRequestProperty("User-Agent", + "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.6)"); + conn.setRequestProperty("Content-Type", + "multipart/form-data; boundary=" + BOUNDARY); + + DataOutputStream out = new DataOutputStream(conn.getOutputStream()); + + if (params != null) { + StringBuffer strBuf = new StringBuffer(); + Iterator iter = params.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry) iter.next(); + String inputName = (String) entry.getKey(); + String inputValue = (String) entry.getValue(); + if (inputValue == null) { + continue; + } + strBuf.append("\r\n").append("--").append(BOUNDARY) + .append("\r\n"); + strBuf.append("Content-Disposition: form-data; name=\"" + + inputName + "\"\r\n\r\n"); + strBuf.append(inputValue); + } + out.write(strBuf.toString().getBytes("UTF-8")); + } + String endData = "\r\n--" + BOUNDARY + "--\r\n"; + out.write(endData.getBytes()); + out.flush(); + out.close(); + // 瀹氫箟 BufferedReader杈撳叆娴佹潵璇诲彇URL鐨勫搷搴� + BufferedReader reader = new BufferedReader(new InputStreamReader( + conn.getInputStream(),"UTF-8")); + String line; + while ((line = reader.readLine()) != null) { + result += line; + } + reader.close(); + reader = null; + JSONObject resultObject = JSONObject.parseObject(result); + int code = (int) resultObject.get("code"); + if (code > 1) { + throw new RuntimeException((String) resultObject.get("msg")); + } + break; + } catch (Exception e) { + retry++; + System.out.println("=====璇锋眰寮傚父 START=====\r\n" + urlStr + "\r\n=====璇锋眰寮傚父 END====="); + e.printStackTrace(); + } finally { + if (conn != null) { + conn.disconnect(); + conn = null; + } + } + } + return result; + } + + /** + * Http Request GET Method + * + * @param urlStr 璇锋眰URL + * @param params 璇锋眰鍙傛暟 + * @return + */ + public static String sendGet(String urlStr, Map<String, String> params) { + String result = "", paramsString = ""; + HttpURLConnection conn = null; + try { + if (params != null) { + Iterator iter = params.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry) iter.next(); + String inputName = (String) entry.getKey(); + String inputValue = (String) entry.getValue(); + if (inputValue == null) { + continue; + } + paramsString += inputName + "=" + inputValue + "&"; + } + } + + URL url = new URL(urlStr + "?" + paramsString); + conn = (HttpURLConnection) url.openConnection(); + conn.setConnectTimeout(5000); + conn.setReadTimeout(30000); + conn.setRequestProperty("Connection", "Keep-Alive"); + conn.setRequestProperty("User-Agent", + "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.6)"); + + // 寤虹珛瀹為檯鐨勮繛鎺� + conn.connect(); + // 瀹氫箟 BufferedReader杈撳叆娴佹潵璇诲彇URL鐨勫搷搴� + BufferedReader reader = new BufferedReader(new InputStreamReader( + conn.getInputStream())); + String line; + while ((line = reader.readLine()) != null) { + result += line; + } + reader.close(); + reader = null; + } catch (Exception e) { + System.out.println("=====璇锋眰寮傚父 START=====\r\n" + urlStr + "\r\n=====璇锋眰寮傚父 END====="); + e.printStackTrace(); + } finally { + if (conn != null) { + conn.disconnect(); + conn = null; + } + } + return result; + } + + /** + * 鑾峰彇杩囧幓绗嚑澶╃殑鏃ユ湡 + * + * @param past 涓庡綋澶╁樊寮傚ぉ鏁� + * @return + */ + public static String getPastDate(int past) { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - past); + Date today = calendar.getTime(); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + String result = format.format(today); + return result; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/PoscomUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/PoscomUtil.java new file mode 100644 index 0000000..50716b6 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/PoscomUtil.java @@ -0,0 +1,36 @@ +package com.nuvole.poscom.util; + +import java.math.BigDecimal; + +/** + * @Description 浜戞墦鍗版満宸ュ叿绫� + * @Author ZHAOXL + * @Date 2024/3/8 16:36 + * @Version 1.0 + */ +public class PoscomUtil { + + /** + * 鍒嗚浆涓哄厓 + * @Author ZHAOXL + * @Date 2024/3/8 16:48 + * @Version 1.0 + */ + public static String convertToYuan(Long payMoney) { + if (payMoney == null) { + return "0"; + } + BigDecimal totalAmount = new BigDecimal("" + payMoney).divide(new BigDecimal("100")); + return totalAmount + ""; + } + + /** + * long杞琒tring + * @Author ZHAOXL + * @Date 2024/3/8 16:39 + * @Version 1.0 + */ + public static String longToString(Long param) { + return param == null ? "0" : Long.toString(param); + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/PoscomVoice.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/PoscomVoice.java new file mode 100644 index 0000000..8f3d7e2 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/PoscomVoice.java @@ -0,0 +1,101 @@ +package com.nuvole.poscom.util; + +import java.math.BigDecimal; + +/** + * @Description 璇煶鍐呭鏍煎紡鍖� + * @Author ZHAOXL + * @Date 2024/3/7 13:15 + * @Version 1.0 + */ +public class PoscomVoice { + + /** + * 鏀粯瀹� + */ + public final static String ZFB = "2007"; + /** + * 寰俊 + */ + public final static String WX = "2008"; + + /** + * 浜戦棯浠� + */ + public final static String YSF = "2011"; + + /** + * 鐜伴噾 + */ + public final static String XJ = "2014"; + + /** + * 璇煶绫诲瀷銆� + * 2 涓嶈嚜鍔ㄦ挱鏀炬柊璁㈠崟锛岀湡浜鸿闊� + */ + public final static String VOICE_TYPE_2 = "2"; + + /** + * 璇煶涓儴鍐呭 + */ + public final static String VOICE_MIDDLE = "宸叉敹娆�"; + + /** + * 鍒嗛殧绗� + */ + public final static String SPLIT = "|"; + + private final static String unit[][] = {{"", "涓�", "浜�"}, {"", "鍗�", "鐧�", "鍗�"}}; + + /** + * 鏍煎紡鍖栬闊冲瓧绗︿覆 + * @param strs 鍙傛暟 + * @return String + * @Author ZHAOXL + * @Date 2024/3/7 13:57 + * @Version 1.0 + */ + public static String format(String strs) { + StringBuilder sb=new StringBuilder(); + for (char c : strs.toCharArray()) { + sb.append(c); + sb.append(SPLIT); + } + return sb.toString(); + } + + /** + * 鏍煎紡鍖栭噾棰� + * @param price 閲戦 + * @return String + * @Author ZHAOXL + * @Date 2024/3/7 16:07 + * @Version 1.0 + */ + public static String priceFormat(Long price) { + BigDecimal decimal = new BigDecimal("" + price).divide(new BigDecimal("100")); + Double n = decimal.doubleValue(); + StringBuilder sb = new StringBuilder(); + String numStr = String.valueOf(n); + int dotIndex = numStr.indexOf("."); + String decimalPart = numStr.substring(dotIndex); + if (".0".equals(decimalPart)) { + decimalPart = ""; + } + int integerPart = (int) Math.floor(n); + if (integerPart == 0) { + sb.append("0"); + }; + for (int i = 0; i < unit[0].length && integerPart > 0; i++) { + sb.insert(0, unit[0][i]); + for (int j = 0; j < unit[1].length && n > 0; j++) { + if (integerPart % 10 > 0) { + sb.insert(0, integerPart % 10 + unit[1][j]); + } + integerPart = integerPart / 10; + } + } + sb.append(decimalPart + "鍏�"); + return sb.toString(); + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/StringToAscii.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/StringToAscii.java new file mode 100644 index 0000000..824ff88 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/StringToAscii.java @@ -0,0 +1,49 @@ +package com.nuvole.poscom.util; + +import java.io.UnsupportedEncodingException; + +public class StringToAscii { + + private static String toHexUtil(int n){ + String rt=""; + switch(n){ + case 10:rt+="A";break; + case 11:rt+="B";break; + case 12:rt+="C";break; + case 13:rt+="D";break; + case 14:rt+="E";break; + case 15:rt+="F";break; + default: + rt+=n; + } + return rt; + } + + public static String toHex(int n){ + StringBuilder sb=new StringBuilder(); + if(n/16==0){ + return toHexUtil(n); + }else{ + String t=toHex(n/16); + int nn=n%16; + sb.append(t).append(toHexUtil(nn)); + } + return sb.toString(); + } + + public static String parseAscii(String str){ + StringBuilder sb=new StringBuilder(); + byte[] bs=str.getBytes(); + for(int i=0;i<bs.length;i++) { + sb.append("0x"); + sb.append(toHex(bs[i])); + } + return sb.toString(); + } + + public static void main(String[] args) throws UnsupportedEncodingException { + String s="10.5"; + System.out.println("杞崲鍚庣殑瀛楃涓叉槸锛�"+ StringToAscii.parseAscii(s)); + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/StringToGB18030.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/StringToGB18030.java new file mode 100644 index 0000000..63b9f2a --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/poscom/util/StringToGB18030.java @@ -0,0 +1,29 @@ +package com.nuvole.poscom.util; + +import java.nio.charset.Charset; + +public class StringToGB18030 { + + public static String toGB18030(String str) { + StringBuilder sb=new StringBuilder("0x"); + Charset gb18030 = Charset.forName("GB18030"); + byte[] bytes = str.getBytes(gb18030); + for (byte b : bytes) { + sb.append(Integer.toHexString(b & 0xFF).toUpperCase()); + } + return sb.toString(); + } + + public static String parseGB18030(String strs) { + StringBuilder sb=new StringBuilder(); + for (char c : strs.toCharArray()) { + sb.append(toGB18030(Character.toString(c))); + } + return sb.toString(); + } + + public static void main(String[] args) { + String s = "宸叉敹鍒�"; + System.out.println("杞崲鍚庣殑瀛楃涓叉槸锛�"+ StringToGB18030.parseGB18030(s)); + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/rateLimit/ApiRateLimit.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/rateLimit/ApiRateLimit.java new file mode 100644 index 0000000..78b696e --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/rateLimit/ApiRateLimit.java @@ -0,0 +1,35 @@ +package com.nuvole.rateLimit; + +import java.lang.annotation.*; +import java.util.concurrent.TimeUnit; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD}) +@Documented +public @interface ApiRateLimit { + /** + * 璧勬簮鐨刱ey,鍞竴 + * 浣滅敤锛氫笉鍚岀殑鎺ュ彛锛屼笉鍚岀殑娴侀噺鎺у埗 + */ + String key() default ""; + + /** + * 鏈�澶氱殑璁块棶闄愬埗娆℃暟 + */ + double permitsPerSecond(); + + /** + * 鑾峰彇浠ょ墝鏈�澶х瓑寰呮椂闂� + */ + long timeout(); + + /** + * 鑾峰彇浠ょ墝鏈�澶х瓑寰呮椂闂�,鍗曚綅(渚�:鍒嗛挓/绉�/姣) 榛樿:姣 + */ + TimeUnit timeunit() default TimeUnit.MILLISECONDS; + + /** + * 寰椾笉鍒颁护鐗岀殑鎻愮ず璇� + */ + String msg() default "绯荤粺绻佸繖,璇风◢鍚庡啀璇�."; +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/rateLimit/ApiRateLimitAop.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/rateLimit/ApiRateLimitAop.java new file mode 100644 index 0000000..18632a5 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/rateLimit/ApiRateLimitAop.java @@ -0,0 +1,81 @@ +package com.nuvole.rateLimit; + +import com.alibaba.fastjson.JSONObject; +import com.google.common.collect.Maps; +import com.google.common.util.concurrent.RateLimiter; +import com.nuvole.common.domain.emnu.CommonResultEmnu; +import com.nuvole.common.domain.result.CommonResult; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import java.io.IOException; +import java.io.PrintWriter; +import java.lang.reflect.Method; +import java.util.Map; + + +@Slf4j +@Aspect +@Component +public class ApiRateLimitAop { + /** + * 涓嶅悓鐨勬帴鍙o紝涓嶅悓鐨勬祦閲忔帶鍒� + * map鐨刱ey涓� Limiter.key + */ + private final Map<String, RateLimiter> limitMap = Maps.newConcurrentMap(); + + @Around("@annotation(com.nuvole.rateLimit.ApiRateLimit)") + public Object around(ProceedingJoinPoint joinPoint) throws Throwable { + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); + //鎷縧imit鐨勬敞瑙� + ApiRateLimit limit = method.getAnnotation(ApiRateLimit.class); + if (limit != null) { + //key浣滅敤锛氫笉鍚岀殑鎺ュ彛锛屼笉鍚岀殑娴侀噺鎺у埗 + String key = limit.key(); + RateLimiter rateLimiter = null; + //楠岃瘉缂撳瓨鏄惁鏈夊懡涓璳ey + if (!limitMap.containsKey(key)) { + // 鍒涘缓浠ょ墝妗� + rateLimiter = RateLimiter.create(limit.permitsPerSecond()); + limitMap.put(key, rateLimiter); + log.info("鏂板缓浜嗕护鐗屾《={}锛屽閲�={}", key, limit.permitsPerSecond()); + } + rateLimiter = limitMap.get(key); + // 鎷夸护鐗� + boolean acquire = rateLimiter.tryAcquire(limit.timeout(), limit.timeunit()); + // 鎷夸笉鍒板懡浠わ紝鐩存帴杩斿洖寮傚父鎻愮ず + if (!acquire) { + log.debug("浠ょ墝妗�={}锛岃幏鍙栦护鐗屽け璐�", key); + this.responseFail(limit.msg()); + return null; + } + } + return joinPoint.proceed(); + } + + /** + * @param msg 鎻愮ず淇℃伅 + */ + private void responseFail(String msg) { + HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse(); + CommonResult resultData = new CommonResult(CommonResultEmnu.REQUEST_LIMIT_ERR, msg); + response.setContentType("application/json;charset=UTF-8"); + PrintWriter out = null; + try { + out = response.getWriter(); + } catch (IOException e) { + e.printStackTrace(); + } + out.print(JSONObject.toJSONString(resultData)); + out.flush(); + out.close(); + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/AESUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/AESUtil.java new file mode 100644 index 0000000..cf70e2e --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/AESUtil.java @@ -0,0 +1,57 @@ +package com.nuvole.util; +// @formatter:off + +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.SecureUtil; +import cn.hutool.crypto.symmetric.AES; + +/** + * .-~~~~~~~~~-._ _.-~~~~~~~~~-. + * __.' @Author ~. .~ 浠g爜鏃燘ug `.__ + * .'// liu.q \./ (绉樼睄) \\`. + * .'// [916000612@qq.com] | 娆茬粌绁炲姛 寮曞垁鑷 \\`. + * .'// .-~"""""""~~~~-._ | _,-~~~~"""""""~-. \\`. + * .'//.-" 2019-04-24 `-. | .-' 14:58 "-.\\`. + * .'//______.============-.. \ | / ..-============.______\\`. + *.'______________________________\|/______________________________`. + * + * @Description : + */ +// @formatter:on + +public class AESUtil { + + public static String k = "lNQqkL1BfSwt2MKw"; + + /* + * @Author : liu.q [916000612@qq.com] + * @Date : 2019-04-24 15:01 + * @param mixpd : 瀵嗙爜 + * @return : java.lang.String 鍔犲瘑鍚庣殑瀵嗙爜 + * @Description : AES鍔犲瘑 + */ + public static String encode(String s){ + if (StrUtil.isBlank(s)) { + return ""; + } + AES aes = SecureUtil.aes(k.getBytes()); + return aes.encryptHex(s); + } + + /* + * @Author : liu.q [916000612@qq.com] + * @Date : 2019-04-24 15:01 + * @param mixpd : 鍔犲瘑鐨勫瘑鐮� + * @return : java.lang.String 瑙e瘑鍚庣殑瀵嗙爜 + * @Description :AES瑙e瘑 + */ + public static String decode(String s){ + if (StrUtil.isBlank(s)) { + return ""; + } + AES aes = SecureUtil.aes(k.getBytes()); + return aes.decryptStr(s, CharsetUtil.CHARSET_UTF_8); + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/AesCbcUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/AesCbcUtil.java new file mode 100644 index 0000000..fb0f9c8 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/AesCbcUtil.java @@ -0,0 +1,61 @@ +package com.nuvole.util; + +import java.security.AlgorithmParameters; +import java.security.Security; + +import javax.crypto.Cipher; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; + +import org.apache.commons.codec.binary.Base64; +import org.bouncycastle.jce.provider.BouncyCastleProvider; + +/** + * 寰俊鍔犺В瀵嗗伐鍏风被 + * + * @author liujun + * @Date 2019/5/27 17:36 + */ +public class AesCbcUtil { + + static { + // BouncyCastle鏄竴涓紑婧愮殑鍔犺В瀵嗚В鍐虫柟妗堬紝涓婚〉鍦╤ttp://www.bouncycastle.org/ + Security.addProvider(new BouncyCastleProvider()); + } + + /** + * AES瑙e瘑 + * + * @param data + * //瀵嗘枃锛岃鍔犲瘑鐨勬暟鎹� + * @param key + * //绉橀挜 + * @param iv + * //鍋忕Щ閲� + * @param encodingFormat + * //瑙e瘑鍚庣殑缁撴灉闇�瑕佽繘琛岀殑缂栫爜 + * @return + * @throws Exception + */ + public static String decrypt(String data, String key, String iv, String encodingFormat) throws Exception { + // initialize(); + // 琚姞瀵嗙殑鏁版嵁 + byte[] dataByte = Base64.decodeBase64(data.getBytes()); + // 鍔犲瘑绉橀挜 + byte[] keyByte = Base64.decodeBase64(key.getBytes()); + // 鍋忕Щ閲� + byte[] ivByte = Base64.decodeBase64(iv.getBytes()); + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding"); + SecretKeySpec spec = new SecretKeySpec(keyByte, "AES"); + AlgorithmParameters parameters = AlgorithmParameters.getInstance("AES"); + parameters.init(new IvParameterSpec(ivByte)); + // 鍒濆鍖� + cipher.init(Cipher.DECRYPT_MODE, spec, parameters); + byte[] resultByte = cipher.doFinal(dataByte); + if (null != resultByte && resultByte.length > 0) { + String result = new String(resultByte, encodingFormat); + return result; + } + return null; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ApplicationContextUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ApplicationContextUtil.java new file mode 100644 index 0000000..22aff71 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ApplicationContextUtil.java @@ -0,0 +1,35 @@ +package com.nuvole.util; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +/** + * @ClassName ApplicationContextUtil + * @Author cy + * @Date 2023/6/20 + * @Description + * @Version 1.0 + **/ +@Component +public class ApplicationContextUtil implements ApplicationContextAware { + private static ApplicationContext applicationContext; + + public static Object getBean(String beanName){ + return applicationContext.getBean(beanName); + } + + public static <T> T getBean(Class<T> clazz){ + return (T)applicationContext.getBean(clazz); + } + + public ApplicationContext getApplicationContext(){ + return applicationContext; + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + ApplicationContextUtil.applicationContext = applicationContext; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/BaiduUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/BaiduUtil.java new file mode 100644 index 0000000..9291180 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/BaiduUtil.java @@ -0,0 +1,65 @@ +package com.nuvole.util; + +import com.baidu.aip.speech.AipSpeech; +import com.baidu.aip.speech.TtsResponse; +import lombok.extern.slf4j.Slf4j; +import org.json.JSONObject; + +import java.util.HashMap; + +/** + * 鐧惧害鏅鸿兘浜戝伐鍏风被 + * + * @Author: lc + * @Date: 2020/4/27 17:02 + */ +@Slf4j +public class BaiduUtil { + + //璇︾粏璇锋悳绱㈢櫨搴︽櫤鑳戒簯鏌ョ湅 + + //璁剧疆APPID/AK/SK + private static final String APP_ID = "19624255"; + private static final String API_KEY = "NqUfTfQUi31Gu5L0fD8YXRWZ"; + private static final String SECRET_KEY = "DrFxoeyOEz23x3NUVb6GMo2PsZTiXk1a"; + + /** + * 鍒濆鍖栦竴涓狝ipSpeech + */ + private static AipSpeech aipSpeech = new AipSpeech(APP_ID, API_KEY, SECRET_KEY); + + /** + * 璇煶鍚堟垚 - 閫氳繃鏂囧瓧杞寲涓簃p3 + * + * @Author: lc + * @Date: 2020/4/27 17:03 + */ + public static byte[] speech(String text) { + // 鍙�夛細璁剧疆缃戠粶杩炴帴鍙傛暟 + aipSpeech.setConnectionTimeoutInMillis(2000); + aipSpeech.setSocketTimeoutInMillis(60000); + + // 璋冪敤鎺ュ彛 + HashMap<String, Object> options = new HashMap<>(16); + /*璇�燂紝鍙栧��0-15锛岄粯璁や负5涓閫�*/ + options.put("spd", 5); + /*闊宠皟锛屽彇鍊�0-15锛岄粯璁や负5涓璋�*/ + options.put("pit", 5); + /*闊抽噺锛屽彇鍊�0-15锛岄粯璁や负5涓煶閲�*/ + options.put("vol", 10); + // 鍙戦煶浜洪�夋嫨, 鍩虹闊冲簱锛�0涓哄害灏忕編锛�1涓哄害灏忓畤锛�3涓哄害閫嶉仴锛�4涓哄害涓斧锛� + // 绮惧搧闊冲簱锛�5涓哄害灏忓▏锛�103涓哄害绫虫湹锛�106涓哄害鍗氭枃锛�110涓哄害灏忕锛�111涓哄害灏忚悓锛岄粯璁や负搴﹀皬缇� + options.put("per", 0); + + TtsResponse res = aipSpeech.synthesis(text, "zh", 1, options); + byte[] data = res.getData(); + JSONObject res1 = res.getResult(); + if (data != null) { + return data; + } + if (res1 != null) { + log.info(res1.toString(2)); + } + return null; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/BeanUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/BeanUtil.java new file mode 100644 index 0000000..760ad57 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/BeanUtil.java @@ -0,0 +1,80 @@ +package com.nuvole.util; + +import org.apache.commons.beanutils.BeanMap; + +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Map; +// @formatter:off + /** + * .-~~~~~~~~~-._ _.-~~~~~~~~~-. + * __.' @Author ~. .~ 浠g爜鏃燘ug `.__ + * .'// liu.q \./ (绉樼睄) \\`. + * .'// [916000612@qq.com] | 娆茬粌绁炲姛 寮曞垁鑷 \\`. + * .'// .-~"""""""~~~~-._ | _,-~~~~"""""""~-. \\`. + * .'//.-" 2019-04-07 `-. | .-' 19:44 "-.\\`. + * .'//______.============-.. \ | / ..-============.______\\`. + *.'______________________________\|/______________________________`. + * + * @Description : bean map 浜掔浉杞崲宸ュ叿绫� + */ +// @formatter:on + public class BeanUtil { + + public static <T> Map<String, Object> bean2Map(T bean, Map<String, Object> mp) { + if (bean == null) { + return mp; + } + try { + BeanInfo beanInfo = Introspector.getBeanInfo(bean.getClass()); + PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); + for (PropertyDescriptor property : propertyDescriptors) { + String k = property.getName(); + + if (!k.equals("class")) { + Method getter = property.getReadMethod();// Java涓彁渚涗簡鐢ㄦ潵璁块棶鏌愪釜灞炴�х殑 + // getter/setter鏂规硶 + Object value; + value = getter.invoke(bean); + mp.put(k, value); + } + } + } catch (IntrospectionException e) { + e.printStackTrace(); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + return mp; + + } + + + public static <T> T map2Bean(Map<String, Object> mp, Class<T> beanCls) throws IllegalAccessException, InstantiationException, InvocationTargetException, IntrospectionException { + T t = null; + BeanInfo beanInfo = Introspector.getBeanInfo(beanCls); + PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); + t = beanCls.newInstance(); + for (PropertyDescriptor property : propertyDescriptors) { + String k = property.getName(); + + if (mp.containsKey(k)) { + Object value = mp.get(k); + Method setter = property.getWriteMethod();// Java涓彁渚涗簡鐢ㄦ潵璁块棶鏌愪釜灞炴�х殑 + // getter/setter鏂规硶 + setter.invoke(t, value); + } + } + return t; + } + + public static Map obj2Map(Object obj) { + if (obj == null) { + return new BeanMap(); + } + return new BeanMap(obj); + } + } diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/CncpUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/CncpUtil.java new file mode 100644 index 0000000..c5191a2 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/CncpUtil.java @@ -0,0 +1,832 @@ +package com.nuvole.util; + +import cn.hutool.core.convert.Convert; +import com.alibaba.fastjson.JSONObject; +import com.nuvole.common.domain.emnu.CommonResultEmnu; +import com.nuvole.common.domain.result.CommonResult; +import cpcn.institution.tools.net.RequestDgtEnvlp; +import cpcn.institution.tools.util.DigitalEnvelopeUtil; +import cpcn.institution.tools.util.StringUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import payment.api.system.AggregateEnvironment; +import payment.api.system.Gateway4FileEnvironment; +import payment.api.system.PaymentEnvironment; +import payment.api.system.TxMessenger; +import payment.api.tx.TxBaseRequest; +import payment.api.tx.TxBaseResponse; +import payment.api.tx.aggregate.Tx5011Request; +import payment.api.tx.aggregate.Tx5011Response; +import payment.api.tx.foundationaccount.*; +import payment.api.tx.gatheringaccredit.Tx2751Request; +import payment.api.tx.gatheringaccredit.Tx2751Response; +import payment.api.tx.payroll.Tx4600Request; +import payment.api.tx.payroll.Tx4600Response; +import payment.api.tx.statement.Tx1850Request; +import payment.api.tx.statement.Tx1850Response; +import payment.api.util.GUIDGenerator; +import payment.api.vo.ImageInfo; +import payment.api.vo.SplitItem; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.HashMap; + +/** + * @ClassName CncpUtil + * @Author cy + * @Date 2023/7/13 + * @Description + * @Version 1.0 + **/ +@Slf4j +public class CncpUtil { + public static void initUtil(String configPath) { + try { + PaymentEnvironment.initialize(configPath); + } catch (Exception e) { + e.printStackTrace(); + } + CncpUtil.paymentConfigPath = configPath; + } + + private static String paymentConfigPath; + + public static String getPaymentConfigPath() { + return paymentConfigPath; + } + + /** + * 褰卞嵃浠堕噰闆� + * + * @param businessType 涓氬姟绫诲瀷锛� 10-澹逛紒浠�-寮�鎴蜂笂浼犺韩浠藉奖鍗板浘鐗囷紙榛樿锛� 11-澹逛紒浠�-瀹炲悕鐢ㄦ埛琛ュ厖褰卞嵃浠� 12-澹逛紒浠�-寮�鎴蜂俊鎭慨鏀瑰奖鍗颁欢 20-钖韩浠�-绛剧害涓婁紶韬唤褰卞嵃鍥剧墖 30-淇$敤鏀粯-鍑嗗叆鎺堟潈褰卞儚浠� 40-淇$敤鏀粯-鐢ㄤ俊鐢宠鍑瘉 + * @return + */ + public static Tx4600Response tx4600(short businessType, String userId, ArrayList<ImageInfo> imageTypes) { + Tx4600Request txRequest = new Tx4600Request(); + txRequest.setInstitutionID(PaymentEnvironment.institutionID); + txRequest.setTxSN(IdGenerator.getUUID()); + txRequest.setBusinessType(businessType + ""); + txRequest.setUserID(userId); + + txRequest.setImageInfoList(imageTypes); + // 3.鎵ц鎶ユ枃澶勭悊 + try { + txRequest.process(); + } catch (Exception e) { + e.printStackTrace(); + } + HashMap<String, String> map = new HashMap<String, String>(); + map.put("Flag", "50"); + putCommonParam(map, txRequest); + return dealRequestResult(map, Tx4600Response.class); + } + + /** + * 寮�鎴锋帴鍙g敤浜庝釜浜恒�佷紒涓氱敤鎴锋垨涓綋宸ュ晢鎴峰湪鏈烘瀯绯荤粺寮�绔嬮摱琛岀數瀛愯处鎴风幆鑺傘�� + * + * @return + * @throws Exception + */ + public static Tx4601Response tx4601(String userId) throws Exception { + + // 1.鍙栧緱鍙傛暟 + String institutionID = PaymentEnvironment.institutionID; + String txSN = GUIDGenerator.genGUID(); +// String userID = null; + String userID = "cy88888888"; + String userType = "11"; + String parentUserID = null; + + String phoneNumber = "17721229769"; + String userName = "甯歌繙"; + String credentialType = "0"; + String credentialNumber = "410105199603076114"; + String issDate = "20230130"; + String expiryDate = "20231230"; + String indAddress = "涓浗娌冲崡鐪侀儜宸炲競閲戞按鍖哄寳鏋楄矾琛楅亾"; + String indEmail = "166459@qq.com"; + + String province = "41"; + String city = "410100"; + String district = "410105"; + +// String credentialAddress = request.getParameter("CredentialAddress"); +// String occupation = request.getParameter("Occupation"); + +// String corporationName = "CorporationName"; +// String corporationShort = "CorporationShort"; +// String categoryType = "CategoryType"; +// String corEmail = "CorEmail"; +// String corAddress = "CorAddress"; + +// String industryBelongType = "IndustryBelongType"; +// String industry = "Industry"; +// String scale = "Scale"; +// String basicAcctNo = "BasicAcctNo"; +// String approvalNo = "ApprovalNo"; +// String authCapital = "AuthCapital"; +// String businessScope = "BusinessScope"; +// String corType = "CorType"; +// String unifiedSocialCreditCode = "UnifiedSocialCreditCode"; +// String AllLicenceIssDate = "AllLicenceIssDate"; +// String allLicenceExpiryDate = "AllLicenceExpiryDate"; +// String legalPersonName = "LegalPersonName"; +// String legalCredentialType = "LegalCredentialType"; +// String legalCredentialNumber = "LegalCredentialNumber"; +// String legalPersonIssDate = "LegalPersonIssDate"; +// String legalPersonExpiryDate = "LegalPersonExpiryDate"; +// String legalPersonContactNumber = "LegalPersonContactNumber"; +// String legalPersonEmail = "LegalPersonEmail"; +// String shareholder = "Shareholder"; +// String controller = "Controller"; +// String beneficiary = "Beneficiary"; +// String consigneeName = "ConsigneeName"; +// String consigneeCredentialType = "ConsigneeCredentialType"; +// String consigneeCredentialNumber = "ConsigneeCredentialNumber"; +// String consigneeIssDate = "ConsigneeIssDate"; +// String consigneeExpiryDate = "ConsigneeExpiryDate"; +// String consigneeContactNumber = "ConsigneeContactNumber"; +//// +// String[] shareholderNames = "ShareholderName"; +// String[] shCredentialTypes = "ShCredentialType"; +// String[] shCredentialNumbers = "ShCredentialNumber"; +// String[] shPersonIssDates = "ShPersonIssDate"; +// String[] shPersonExpiryDates = "ShPersonExpiryDate"; + +// +// String managerName = "ManagerName"; +// String managerCredentialType = "ManagerCredentialType"; +// String managerCredentialNumber = "ManagerCredentialNumber"; +// String managerIssDate = "ManagerIssDate"; +// String managerExpiryDate = "ManagerExpiryDate"; +// String managerContactNumber = "ManagerContactNumber"; +// String managerEmail = "ManagerEmail"; +// String managerCredentialAddress = "ManagerCredentialAddress"; +// String managerOccupation = "ManagerOccupation"; +// String retailerRegNumber = "RetailerRegNumber"; +// String retailerName = "RetailerName"; +// String retailerLicenseIssDate = "RetailerLicenseIssDate"; +// String retailerLicenseExpiryDate = "RetailerLicenseExpiryDate"; +// String retailerFormation = "RetailerFormation"; +// String retailerAddress = "RetailerAddress"; +// String retailerProvince = "RetailerProvince"; +// String retailerCity = "RetailerCity"; +// String retailerDistrict = "RetailerDistrict"; +// String retailerBusinessScope = "RetailerBusinessScope"; +// +// String bankAbilityFlag = "BankAbilityFlag"; +// String bindingTxSN = "BindingTxSN"; +// String bankID = "BankID"; +// String bankAccountNumber = "BankAccountNumber"; +// String bankPhoneNumber = "BankPhoneNumber"; +// String cNAPSCode = "CNAPSCode"; +// String branchName = "BranchName"; +// String bankProvince = "BankProvince"; +// String bankCity = "BankCity"; + + + // 2.鍒涘缓浜ゆ槗璇锋眰瀵硅薄 + Tx4601Request tx4601Request = new Tx4601Request(); + tx4601Request.setInstitutionID(institutionID); + tx4601Request.setTxSN(txSN); + tx4601Request.setUserID(userID); + tx4601Request.setParentUserID(parentUserID); + tx4601Request.setUserType(userType); +// tx4601Request.setAcceptanceConfirmType(acceptanceConfirmType); +// tx4601Request.setAccountLevel(accountLevel); +// tx4601Request.setImageCollectionTxSN(imageCollectionTxSN); +// tx4601Request.setNoticeURL(noticeURL); + tx4601Request.setBusinessType("10"); + + tx4601Request.setPhoneNumber(phoneNumber); + tx4601Request.setUserName(userName); + tx4601Request.setCredentialType(credentialType); + tx4601Request.setCredentialNumber(credentialNumber); + tx4601Request.setIssDate(issDate); + tx4601Request.setExpiryDate(expiryDate); + tx4601Request.setIndAddress(indAddress); + tx4601Request.setIndEmail(indEmail); +// tx4601Request.setCredentialAddress(credentialAddress); +// tx4601Request.setOccupation(occupation); + +// tx4601Request.setCorporationName(corporationName); +// tx4601Request.setCorporationShort(corporationShort); +// tx4601Request.setCategoryType(categoryType); +// tx4601Request.setCorEmail(corEmail); +// tx4601Request.setCorAddress(corAddress); + tx4601Request.setProvince(province); + tx4601Request.setCity(city); + tx4601Request.setDistrict(district); +// tx4601Request.setIndustryBelongType(industryBelongType); +// tx4601Request.setIndustry(industry); +// tx4601Request.setScale(scale); +// tx4601Request.setBasicAcctNo(basicAcctNo); +// tx4601Request.setApprovalNo(approvalNo); +// tx4601Request.setAuthCapital(authCapital); +// tx4601Request.setBusinessScope(businessScope); +// tx4601Request.setCorType(corType); +// tx4601Request.setUnifiedSocialCreditCode(unifiedSocialCreditCode); +// tx4601Request.setAllLicenceIssDate(AllLicenceIssDate); +// tx4601Request.setAllLicenceExpiryDate(allLicenceExpiryDate); +// tx4601Request.setLegalPersonName(legalPersonName); +// tx4601Request.setLegalCredentialType(legalCredentialType); +// tx4601Request.setLegalCredentialNumber(legalCredentialNumber); +// tx4601Request.setLegalPersonIssDate(legalPersonIssDate); +// tx4601Request.setLegalPersonExpiryDate(legalPersonExpiryDate); +// tx4601Request.setLegalPersonContactNumber(legalPersonContactNumber); +// tx4601Request.setLegalPersonEmail(legalPersonEmail); +// tx4601Request.setShareholder(shareholder); +// tx4601Request.setController(controller); +// tx4601Request.setBeneficiary(beneficiary); +// tx4601Request.setConsigneeName(consigneeName); +// tx4601Request.setConsigneeCredentialType(consigneeCredentialType); +// tx4601Request.setConsigneeCredentialNumber(consigneeCredentialNumber); +// tx4601Request.setConsigneeIssDate(consigneeIssDate); +// tx4601Request.setConsigneeExpiryDate(consigneeExpiryDate); +// tx4601Request.setConsigneeContactNumber(consigneeContactNumber); +// +// ArrayList<ShareholderPart> shareholderPartsList = null; +// if(shareholderNames != null && shareholderNames.length > 0){ +// shareholderPartsList = new ArrayList<ShareholderPart>(); +// for(int i = 0; i < shareholderNames.length; i ++){ +// ShareholderPart shareholderPart = new ShareholderPart(); +// shareholderPart.setShareholderName(shareholderNames[i]); +// shareholderPart.setShCredentialType(shCredentialTypes[i]); +// shareholderPart.setShCredentialNumber(shCredentialNumbers[i]); +// shareholderPart.setShPersonIssDate(shPersonIssDates[i]); +// shareholderPart.setShPersonExpiryDate(shPersonExpiryDates[i]); +// +// shareholderPartsList.add(shareholderPart); +// } +// } +// tx4601Request.setShareholderPartsList(shareholderPartsList); +// +// tx4601Request.setManagerName(managerName); +// tx4601Request.setManagerCredentialType(managerCredentialType); +// tx4601Request.setManagerCredentialNumber(managerCredentialNumber); +// tx4601Request.setManagerIssDate(managerIssDate); +// tx4601Request.setManagerExpiryDate(managerExpiryDate); +// tx4601Request.setManagerContactNumber(managerContactNumber); +// tx4601Request.setManagerEmail(managerEmail); +// tx4601Request.setManagerCredentialAddress(managerCredentialAddress); +// tx4601Request.setManagerOccupation(managerOccupation); +// tx4601Request.setRetailerRegNumber(retailerRegNumber); +// tx4601Request.setRetailerName(retailerName); +// tx4601Request.setRetailerLicenseIssDate(retailerLicenseIssDate); +// tx4601Request.setRetailerLicenseExpiryDate(retailerLicenseExpiryDate); +// tx4601Request.setRetailerFormation(retailerFormation); +// tx4601Request.setRetailerAddress(retailerAddress); +// tx4601Request.setRetailerProvince(retailerProvince); +// tx4601Request.setRetailerCity(retailerCity); +// tx4601Request.setRetailerDistrict(retailerDistrict); +// tx4601Request.setRetailerBusinessScope(retailerBusinessScope); + +// tx4601Request.setBankAbilityFlag(bankAbilityFlag); +// tx4601Request.setBindingTxSN(bindingTxSN); +// tx4601Request.setBankID(bankID); +// tx4601Request.setBankAccountNumber(bankAccountNumber); +// tx4601Request.setBankPhoneNumber(bankPhoneNumber); +// tx4601Request.setCNAPSCode(cNAPSCode); +// tx4601Request.setBranchName(branchName); +// tx4601Request.setBankProvince(bankProvince); +// tx4601Request.setBankCity(bankCity); + + // 3.鎵ц鎶ユ枃澶勭悊 + tx4601Request.process(); + + // 4.灏嗗弬鏁版斁缃埌request瀵硅薄 + /* map.put("plainText", tx4601Request.getRequestPlainText()); + map.put("message", tx4601Request.getRequestMessage()); + map.put("signature", tx4601Request.getRequestSignature()); + map.put("txCode", "4601"); + map.put("txName", "寮�鎴�");*/ + HashMap<String, String> map = new HashMap<String, String>(); + putCommonParam(map, tx4601Request); + // 5.杞悜Request.jsp椤甸潰 + return dealRequestResult(map, Tx4601Response.class); + } + + /** + * 鐢ㄦ埛淇℃伅鏌ヨ + * + * @return + */ + public static Tx4691Response tx4691(String userId) { + Tx4691Request txRequest = new Tx4691Request(); + txRequest.setInstitutionID(PaymentEnvironment.institutionID); + txRequest.setUserID(userId); + // 3.鎵ц鎶ユ枃澶勭悊 + try { + txRequest.process(); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + return dealRequestResult(putCommonParam(null, txRequest), Tx4691Response.class); + } + + public static Tx4691Response tx4691QueryUserInfo(Long businessId, char businessType) { + return tx4691(getUserId(businessId, businessType)); + } + + /** + * 缁戝畾閾惰鍗★紝瑙g粦閾惰鍗� + * + * @param operationFlag 鎿嶄綔鏍囪瘑: 10=缁戝崱 20=瑙g粦 30=鍗囩骇 + * @param bankAccountType 璐︽埛绫诲瀷锛� 11=涓汉璐︽埛 12=浼佷笟璐� 鎴� + * @param credentialNumber 韬唤璇佸彿 + * @return + */ + public static Tx4611Response tx4611(short operationFlag, String userId, short bankAccountType, + String credentialNumber + , String bankAccountName, String bankAccountNumber, String bankPhoneNumber, String + validDate, String cvn2) { + // 鏌ヨ 閾惰鍗� + //缁戝畾閾惰 ID 鍙傝�冦�婇摱琛岀紪鐮佽〃銆� + String bankID = null; + //鍗$被鍨� 10鍊熻璐︽埛 20璐疯璐︽埛 + String bankCardType = null; + Tx2751Response tx2751Response = tx2751(bankAccountNumber); + if (tx2751Response != null && "2000".equals(tx2751Response.getCode())) { + bankCardType = tx2751Response.getCardMediaType(); + bankID = tx2751Response.getBankID(); + } + + Tx4611Request txRequest = new Tx4611Request(); + txRequest.setInstitutionID(PaymentEnvironment.institutionID); + txRequest.setOperationFlag(operationFlag + ""); + txRequest.setBindingTxSN(IdGenerator.getUUID()); + txRequest.setUserID(userId); + txRequest.setBindingWay("10"); + //璐︽埛绫诲瀷锛� 11=涓汉璐︽埛 12=浼佷笟璐� 鎴� + txRequest.setBankAccountType(bankAccountType + ""); + txRequest.setBankCardType(bankCardType + ""); + txRequest.setCredentialType("0"); + txRequest.setCredentialNumber(credentialNumber); + txRequest.setBankID(bankID); + txRequest.setBankAccountName(bankAccountName); + txRequest.setBankAccountNumber(bankAccountNumber); + txRequest.setBankPhoneNumber(bankPhoneNumber); + txRequest.setValidDate(validDate); + txRequest.setCVN2(cvn2); + // 3.鎵ц鎶ユ枃澶勭悊 + try { + txRequest.process(); + } catch (Exception e) { + return null; + } + // 4.灏嗗弬鏁版斁缃埌request瀵硅薄 + /*map.put("txCode", "4611"); + map.put("txName", "缁戝崱&瑙g粦锛圓PI锛�");*/ + Tx4611Response tx4611Response = dealRequestResult(putCommonParam(null, txRequest), Tx4611Response.class); + return tx4611Response; + } + + public static Tx2751Response tx2751(String accountNumber) { + // 2.鍒涘缓浜ゆ槗璇锋眰瀵硅薄 + Tx2751Request txRequest = new Tx2751Request(); + txRequest.setInstitutionID(PaymentEnvironment.institutionID); + txRequest.setTxSN(IdGenerator.getUUID()); + txRequest.setAccountNumber(accountNumber); + + // 3.鎵ц鎶ユ枃澶勭悊 + try { + txRequest.process(); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + Tx2751Response tx4613Response = dealRequestResult(putCommonParam(null, txRequest), Tx2751Response.class); + return tx4613Response; + } + + /** + * 缁戝崱纭 + * + * @param bindingTxSN tx4611杩斿洖鍊间腑 閾惰璐︽埛缁戝畾娴佹按鍙� + * @param businessType 涓氬姟绫诲瀷锛� 10=缁戝崱 20=寮�鎴� + * @param verifyWay 楠岃瘉鏂瑰紡锛�10 鐭俊楠岃瘉 20 灏忛鎵撴楠岃瘉 + * @return + */ + public static Tx4613Response tx4613(String bindingTxSN, short businessType, short verifyWay, String smsCode, Long amount) { + Tx4613Request txRequest = new Tx4613Request(); + txRequest.setInstitutionID(PaymentEnvironment.institutionID); + txRequest.setBusinessType(businessType + ""); + txRequest.setVerifyWay(verifyWay + ""); + txRequest.setSMSCode(smsCode); + txRequest.setAmount(Convert.toStr(amount)); + txRequest.setTxSN(bindingTxSN); + // 3.鎵ц鎶ユ枃澶勭悊 + try { + txRequest.process(); + } catch (Exception e) { + return null; + } + Tx4613Response tx4613Response = dealRequestResult(putCommonParam(null, txRequest), Tx4613Response.class); + return tx4613Response; + } + + /** + * 鏀粯API + * + * @param orderId 璁㈠崟id + * @param payerUserID 浠樻鐢ㄦ埛 ID + * @param payeeUserID 鏀舵鐢ㄦ埛 ID + * @param paymentWay 鏀粯鏂瑰紡: 00=浣欓鏀粯 02=淇$敤鏀粯 10=蹇嵎鏀粯 12-閽卞寘鏀粯 20=缃戦摱鏀粯 30=浠f敹鏀粯 40=鑱氬悎鏀粯(鍋滄鎺ュ叆鏂板晢鎴�) + * 42=鏉$爜鏀粯 43-鎵爜棰勬巿鏉� 50=O2O 60=POS锛堟殏涓嶆敮鎸侊級 70=淇$敤鏀粯 80-璺宠浆鏀粯 + * @param amount 鍗曚綅锛氬垎, + * PaymentWay=42,ScanPaymentType =40 鏃�,閲戦鍙负 0 + * PaymentWay=42,InstallmentType=20,ScanPaymentType=20 鏃�,Amount 蹇呴』澶т簬绛変簬 100 鍏� + * PaymentWay=80,InstallmentType=20,PayType=32 鏃�,Amount 蹇呴』澶т簬绛変簬 100 鍏� + * @param pageURL 鍥炶皟 URL 鍦板潃 + * @param goodsName 鍟嗗搧鍚嶇О PaymentWay=02/12/40/42/80 蹇呭~ + * @param platformName 骞冲彴鍚嶇О PaymentWay=80 蹇呭~ + * @param clientIP 鐢ㄦ埛 IP PaymentWay=12,80 蹇呭~ + * @param hasSubsequentSplit 鏄惁鏈夊悗缁垎璐�:1-鍚� 2-鏄� 榛樿涓哄惁 + * @param hasSubsequentSplit 鏄惁鏈夊悗缁垎璐�:1-鍚� 2-鏄� 榛樿涓哄惁 + * @param remark 澶囨敞 Payment=30 涓旀槸瀵瑰叕鏀粯涓氬姟鏃�,蹇呬紶 + * @param payWay 鏀粯鏂瑰紡 45=H5鏀粯锛圥ayType=30銆�31銆�32銆�33锛� + * 46=APP 鏀粯锛圥ayType=30銆�31銆�32銆�33锛� + * 47=鎵嬫満杩蜂綘浠橈紙PayType=33锛� + * 48=鎵嬫満 Pay 锛圥ayType=34銆�35锛� + * 50=JSAPI锛圥ayType=31銆�32锛� + * 51=灏忕▼搴忔敮浠橈紙PayType=31銆�32锛� + * @param payType 鏀粯绫诲瀷 30=鎵嬫満缃戦摱 31=寰俊 32=鏀粯瀹� 33=閾惰仈 34=Apple Pay 35=Android Pay + * @param subAppID AppID锛堝晢鎴疯繘浠跺綍鍏ワ級寰俊蹇呭~PayType=31 鏀粯瀹濋�夊~锛堟敮浠樺疂鐩磋繛銆佹敮浠樺疂灏忕▼搴忓繀濉級 + * @param subOpenID 鐢ㄦ埛 ID 寰俊锛歰penid 鏀粯瀹濓細 buyer_user_id 锛圥ayWay=50/51 蹇呭~锛� + * @param redirectSource 璺宠浆鍓嶆潵婧� 10=App,20=H5, 30=鍏紬鍙�,40=灏忕▼搴� + * @param scanPaymentType 鏉$爜鏀粯绫诲瀷: 10=寰俊 20=鏀粯瀹� 30=閾惰仈 40=鑱氬悎鐮� 50=鏁板瓧浜烘皯甯佹敮浠� + * @param scanPaymentWay 鏉$爜鏀粯鏂瑰紡: 41=姝f壂 42=鍙嶆壂 + * @param scanPaymentCode 鏉″弽鎵敮浠樻巿鏉冪爜 ScanPaymentWay=42 鏃跺繀濉� + * @param scanPageUrlType 椤甸潰璺宠浆鏂瑰紡 10=鍏紬鍙� 20=灏忕▼搴� ScanPaymentType=10-寰俊鎵爜鏃舵瀛楁涓哄繀濉」锛岄粯璁や负鍏紬鍙枫�� + * @param splitItemsList 鍒嗚处缁撶畻鍩� + * @return + */ + public static Tx5011Response tx5011(String orderId, String payerUserID, String payeeUserID, String paymentWay, Long amount, String pageURL + , String goodsName, String platformName, String clientIP, Short hasSubsequentSplit, String remark, JSONObject extension + , String agreeId, String payWay, String payType, String subAppID, String subOpenID, String redirectSource + // 鏉$爜鍙傛暟 + , String scanPaymentType, String scanPaymentWay, String scanPaymentCode, String scanPageUrlType + //鍒嗚处缁撶畻鍙傛暟 + , ArrayList<SplitItem> splitItemsList + ) { + Tx5011Request txRequest = new Tx5011Request(); + txRequest.setInstitutionID(PaymentEnvironment.institutionID); + txRequest.setTxSN(orderId); + txRequest.setOrderNo(orderId); + txRequest.setPayerUserID(payerUserID); + txRequest.setPayeeUserID(payeeUserID); + txRequest.setPaymentWay(paymentWay); + txRequest.setAmount(Convert.toStr(amount, "0")); + txRequest.setPageURL(pageURL); + txRequest.setGoodsName(goodsName); + txRequest.setPlatformName(platformName); + txRequest.setClientIP(clientIP); + txRequest.setHasSubsequentSplit(Convert.toStr(hasSubsequentSplit, "1")); + txRequest.setRemark(remark); + txRequest.setExtension(extension == null ? null : extension.toJSONString()); + //10=蹇嵎鏀粯 + if ("10".equals(paymentWay)) { + txRequest.setBindingTxSN(agreeId); + } else if ("80".equals(paymentWay)) { + // 璺宠浆鏀粯 + txRequest.setPayWay(payWay); + txRequest.setPayType(payType); + //鏀粯鏂瑰紡闄愬埗锛�10=涓嶉檺瀹� + txRequest.setLimitPay("10"); + txRequest.setSubAppID(subAppID); + txRequest.setSubOpenID(subOpenID); + //installmentType 鍒嗘湡鎺у埗鏍囪瘑 10-涓嶆寚瀹氬垎鏈� 20-鎸囧畾鍒嗘湡 PayType=32銆�33锛孭ayWay=45-H5鏀粯鏃跺繀濉� + txRequest.setInstallmentType("10"); + txRequest.setRedirectSource(redirectSource); + } else if ("42".equals(paymentWay)) { + //鏉$爜鏀粯鏂瑰紡閫夋嫨鍩� + txRequest.setScanPaymentType(scanPaymentType); + txRequest.setScanPaymentWay(scanPaymentWay); + txRequest.setScanPaymentCode(scanPaymentCode); + txRequest.setScanPageUrlType(scanPageUrlType); + } + txRequest.setSplitItemsList(splitItemsList); + + // 3.鎵ц鎶ユ枃澶勭悊 + try { + txRequest.process(); + } catch (Exception e) { + e.printStackTrace(); + } + Tx5011Response tx5011Response = dealRequestResult(putCommonParam(null, txRequest), Tx5011Response.class); + return tx5011Response; + } + + /** + * 寰俊h5 jsapi鏀粯 + * + * @return + */ + public static Tx5011Response tx5011WxH5Pay(String orderId, String payerUserID, String payeeUserID, Long amount, String pageURL + , String goodsName, String shopName, String clientIP, Short hasSubsequentSplit, String remark, JSONObject extension + , String subAppID, String subOpenID, String redirectSource + //鍒嗚处缁撶畻鍙傛暟 + , ArrayList<SplitItem> splitItemsList + ) { + return tx5011(orderId, payerUserID, payeeUserID, "80", amount, pageURL, goodsName, shopName, clientIP, hasSubsequentSplit, remark, extension + , null, "50", "31", subAppID, subOpenID, redirectSource, + null, null, null, null + , splitItemsList); + } + + /** + * 寰俊灏忕▼搴忔敮浠� + * + * @return + */ + public static Tx5011Response tx5011WxMiniPay(String orderId, String payerUserID, String payeeUserID, Long amount, String pageURL + , String goodsName, String shopName, String clientIP, Short hasSubsequentSplit, String remark, JSONObject extension + , String subAppID, String subOpenID, String redirectSource + //鍒嗚处缁撶畻鍙傛暟 + , ArrayList<SplitItem> splitItemsList + ) { + return tx5011(orderId, payerUserID, payeeUserID, "80", amount, pageURL, goodsName, shopName, clientIP, hasSubsequentSplit, remark, extension + , null, "51", "31", subAppID, subOpenID, redirectSource, + null, null, null, null + , splitItemsList); + } + + + /** + * 閾惰鍗″揩鎹锋敮浠� + * + * @return + */ + public static Tx5011Response tx5011BankCardKjPay(String orderId, String payerUserID, String payeeUserID, Long amount, String pageURL + , String goodsName, String shopName, String clientIP, Short hasSubsequentSplit, String remark, JSONObject extension + , String agreeId + //鍒嗚处缁撶畻鍙傛暟 + , ArrayList<SplitItem> splitItemsList) { + return tx5011(orderId, payerUserID, payeeUserID, "10", amount, pageURL, goodsName, shopName, null, hasSubsequentSplit, remark, extension + , agreeId, null, null, null, null, null, + null, null, null, null + , splitItemsList); + } + + + public static Tx1850Response tx1850(LocalDate billDate) throws Exception { + // 1.鍙栧緱鍙傛暟 +// String batchNO = request.getParameter("BatchNO"); +// String payeeUserID = request.getParameter("PayeeUserID"); + // 2.鍒涘缓浜ゆ槗璇锋眰瀵硅薄 + Tx1850Request txRequest = new Tx1850Request(); + txRequest.setInstitutionID(PaymentEnvironment.institutionID); +// txRequest.setBatchNO(batchNO); + txRequest.setBillDate(billDate.toString().replace("-", "")); +// txRequest.setPayeeUserID(payeeUserID); + + // 3.鎵ц鎶ユ枃澶勭悊 + txRequest.process(); + + // 4.灏嗗弬鏁版斁缃埌request瀵硅薄 + HashMap<String, String> map = new HashMap<String, String>(); + /* map.put("plainText", txRequest.getRequestPlainText()); + map.put("message", txRequest.getRequestMessage()); + map.put("signature", txRequest.getRequestSignature()); + map.put("txCode", "1850"); + map.put("txName", "瀵硅处鏂囦欢涓嬭浇");*/ + map.put("Flag", "50"); + + putCommonParam(map, txRequest); + return dealRequestResult(map, Tx1850Response.class); + } + + /** + * 鐢ㄤ簬鏌ヨ璐︽埛涓彲瑙e喕鐨勯噾棰濅俊鎭� + * + * @param businessId + * @return + */ + public static Tx4660Response tx4660QueryDjBalance(Long businessId, char businessType) { + return tx4660(getUserId(businessId, businessType)); + } + + private static Tx4660Response tx4660(String userId) { + Tx4660Request txRequest = new Tx4660Request(); + txRequest.setInstitutionID(PaymentEnvironment.institutionID); + txRequest.setUserID(userId); + // 3.鎵ц鎶ユ枃澶勭悊 + try { + txRequest.process(); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + return dealRequestResult(putCommonParam(null, txRequest), Tx4660Response.class); + } + + /** + * 涓氬姟ID 鐢熸垚瑙勫垯 + * + * @param businessId + * @param businessType + * @return + */ + public static String getUserId(Long businessId, char businessType) { + return businessType + "" + businessId; + } + + /** + * 鏀惧叆鍏叡鍙傛暟 + * + * @param map + * @param baseRequest + */ + public static HashMap<String, String> putCommonParam(HashMap<String, String> map, TxBaseRequest baseRequest) { + if (map == null) { + map = new HashMap<>(); + } + map.put("plainText", baseRequest.getRequestPlainText()); + map.put("message", baseRequest.getRequestMessage()); + map.put("signature", baseRequest.getRequestSignature()); + map.put("txCode", baseRequest.getTxCode()); + + map.put("isDgEnv", PaymentEnvironment.isDgEnv); + map.put("dgtlEnvlp", baseRequest.getDgtlEnvlp()); + map.put("signAlgorithm", baseRequest.getSignAlgorithm()); + map.put("signSN", baseRequest.getSignSN()); + map.put("encryptSN", baseRequest.getEncryptSN()); + map.put("institutionID", PaymentEnvironment.institutionID); + return map; + } + + /** + * 鍙戦�佽姹傦紝瑙f瀽璇锋眰 + * + * @param map + * @return + */ + public static <T extends TxBaseResponse> T + dealRequestResult(HashMap<String, String> map, Class<T> responseType) { + try { + // 鑾峰緱鍙傛暟message鍜宻ignature + String message = map.get("message"); + String signature = map.get("signature"); + String txCode = map.get("txCode"); + String flag = map.get("Flag"); + // 涓庢敮浠樺钩鍙拌繘琛岄�氳 + TxMessenger txMessenger = new TxMessenger(); + String[] respMsg = null; + // Flag=10:cmb, 20:paymentAccount + RequestDgtEnvlp requestDgtEnvlp = new RequestDgtEnvlp(); + if ("YES".equals(map.get("isDgEnv"))) { + requestDgtEnvlp.setIsDgEnv(map.get("isDgEnv")); + } else { + requestDgtEnvlp.setIsDgEnv("NO"); + } + requestDgtEnvlp.setDgtlEnvlp(map.get("dgtlEnvlp")); + requestDgtEnvlp.setSignAlgorithm(map.get("signAlgorithm")); + requestDgtEnvlp.setSignSN(map.get("signSN")); + requestDgtEnvlp.setEncryptSN(map.get("encryptSN")); + requestDgtEnvlp.setInstitutionID(map.get("institutionID")); + + if ("50".equals(flag)) { + respMsg = txMessenger.send(message, signature, requestDgtEnvlp, Gateway4FileEnvironment.GATEWAY4FILE_URL); + } else if ("90".equals(flag)) { + respMsg = txMessenger.send(message, signature, requestDgtEnvlp, AggregateEnvironment.aggregateTxURL);// 0:message; + } else { + respMsg = txMessenger.send(message, signature, requestDgtEnvlp);// 0:message; + } + + String plainText; + if ("YES".equals(respMsg[2])) { + //濡傛灉鍝嶅簲鏄暟瀛椾俊灏侊紝瀵规秷鎭繘琛屽绉拌В瀵� + try { + log.info("寮�濮嬪鍝嶅簲娑堟伅鍋氬绉拌В瀵嗐�傘�傘�傘�傘�傘��"); + if ("YES".equals(PaymentEnvironment.isDoubleCert)) { + log.info("鍙岃瘉瑙e瘑銆傘�傘�傘�傘�傘��"); + respMsg[0] = DigitalEnvelopeUtil.doubleDecryptResponse(respMsg[0], respMsg[3], respMsg[5], respMsg[6]); + } else { + respMsg[0] = DigitalEnvelopeUtil.decryptResponse(respMsg[0], respMsg[3], respMsg[5], respMsg[6]); + } + plainText = respMsg[0]; + respMsg[0] = cpcn.institution.tools.util.Base64.encode(respMsg[0], "UTF-8"); + respMsg[0] = respMsg[0] + "," + respMsg[5] + "," + respMsg[4] + "," + respMsg[2]; + log.info("鍝嶅簲娑堟伅鍋氬绉拌В瀵嗗畬鎴愩�傘�傘�傘�傘�傘��"); + log.info("鍝嶅簲娑堟伅鎶ユ枃锛歔" + plainText + "]"); + } catch (Exception e) { + System.out.println("寮傚父鍐呭锛�" + e); + throw new Exception(e + "瀵圭О瑙e瘑寮傚父锛�"); + } + } else { + // 1:signature + plainText = new String(cpcn.institution.tools.util.Base64.decode(respMsg[0]), "UTF-8"); + if (StringUtil.isNotEmpty(respMsg[5])) { + respMsg[0] = respMsg[0] + "," + respMsg[5] + "," + respMsg[4] + "," + respMsg[2]; + } + } + + log.debug("[message]=[" + respMsg[0] + "]"); + log.debug("[signature]=[" + respMsg[1] + "]"); + log.debug("[plainText]=[" + plainText + "]"); + + // 灏嗙粨鏋滀繚瀛樺湪request涓紝浠ュ鍦≧esponse.jsp椤甸潰鏄剧ず + return getResponse(respMsg[0], respMsg[1], responseType); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 鍙嶅皠鍒涘缓杩斿洖鍊煎璞� + * + * @param responseMessage + * @param responseSignature + * @param responseType + * @param <T> + * @return + */ + private static <T extends TxBaseResponse> T + getResponse(String responseMessage, String responseSignature, Class<T> responseType) { + // 鍒涘缓骞惰繑鍥炲搴旂殑瀛愮被瀵硅薄 + T response = null; + try { + Constructor<T> constructor = responseType.getDeclaredConstructor(String.class, String.class); + response = constructor.newInstance(responseMessage, responseSignature); + } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { + e.printStackTrace(); + } + return response; + } + + + //```````````````````````````````````````````````````````````` + public static CommonResult<Tx4611Response> testTx4611() { + String userId = "cy88888888"; + Tx4611Response tx4611Response = tx4611((short) 10, userId, (short) 11, "410105199603076114", + "甯歌繙", "6255861234567897910", "17721229769", null, null); + if ("2000".equals(tx4611Response.getCode())) { + String status = tx4611Response.getStatus(); + if ("40".equals(status)) { + return new CommonResult(CommonResultEmnu.ERROR, tx4611Response.getResponseMessage()); + } else { + return new CommonResult(tx4611Response); + } +// if ("15".equals(status)) { +// log.info("寰呯煭淇¢獙璇侊紝姝ょ姸鎬佹椂鏀粯骞冲彴宸茬粡缁欑敤鎴锋墜鏈哄彿鍙戦�佺煭淇¢獙璇佺爜锛屾満鏋勭郴缁熼渶瑕佽皟鐢�4613-缁戝崱纭鎺ュ彛鍥炲~鐭俊楠岃瘉鐮侊紝鏀粯骞冲彴楠岃瘉鍚庤繑鍥炵粦鍗$粨鏋�"); +// } else if ("17".equals(status)) { +// log.info("寰呰鍔ㄦ墦娆鹃獙璇侊紝琛ㄧず鏀粯骞冲彴娌℃湁鍚戜紒涓氳处鎴疯繘琛屾墦娆撅紝鏈烘瀯绯荤粺鍙�氳繃 4616-缁戝崱鏌ヨ鎺ュ彛鏌ヨ浼佷笟璐︽埛缁戝崱鐘舵��"); +// } else if ("18".equals(status)) { +// log.info("琚姩宸叉墦娆惧緟楠岃瘉锛岃〃绀烘敮浠樺钩鍙板凡鍚戜紒涓氳处鎴疯繘琛屾墦娆撅紝鏈烘瀯绯荤粺鍙互璋冪敤 4613-缁戝崱纭鎺ュ彛鍥炲~鎵撴閲戦锛屾敮浠樺钩鍙伴獙璇佸悗杩斿洖缁戝崱缁撴灉銆�"); +// } else if ("40".equals(status)) { +// log.info("澶辫触锛岃〃绀虹敤鎴锋彁浜ょ殑韬唤淇℃伅鏈夎锛岄渶瑕佹牳瀹炲悗閲嶆柊鍙戣捣缁戝崱璇锋眰"); +// } + } else { + return new CommonResult(CommonResultEmnu.ERROR, tx4611Response.getMessage()); + } + + } + + /** + * 缁戝崱娴嬭瘯 + */ + public static CommonResult testTx4613(String bindingTxSN) { + Tx4613Response tx4613Response = tx4613(bindingTxSN, (short) 10, (short) 10, "134679", null); + if (!"2000".equals(tx4613Response.getCode())) { + return new CommonResult(CommonResultEmnu.ERROR, tx4613Response.getMessage()); + } + return new CommonResult(); + } + + /** + * 缁戝崱娴嬭瘯 + */ + public static CommonResult testTx2751() { + Tx2751Response response = tx2751("6255861234567897910"); + if (!"2000".equals(response.getCode())) { + return new CommonResult(CommonResultEmnu.ERROR, response.getMessage()); + } + return new CommonResult(); + } + + public static CommonResult test4660() { + Tx4660Response response = tx4660("cy88888888"); + if (!"2000".equals(response.getCode())) { + return new CommonResult(CommonResultEmnu.ERROR, response.getMessage()); + } + return new CommonResult(); + } + + public static void main(String[] args) { + // 鍒濆鍖栨敮浠樼幆澧� + try { + PaymentEnvironment.initialize("D:\\MyProjects\\jmy\\ecosphere\\ecosphere-merchant\\src\\main\\resources\\cncpConfig\\payment"); + } catch (Exception e) { + e.printStackTrace(); + } + + String userId = "cy88888888"; + tx4691(userId); + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/CodeUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/CodeUtil.java new file mode 100644 index 0000000..2ef1f24 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/CodeUtil.java @@ -0,0 +1,56 @@ +package com.nuvole.util; + +import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.RandomUtil; +import cn.hutool.core.util.StrUtil; + +/** + * 鐮佺敓鎴愮被 + * + * @Author: lc + * @Date: 2019/6/13 10:29 + */ +public class CodeUtil { + + /** + * 鑷畾涔塩ode++ + * + * @param maxCode 鏈骇鏈�澶ode + * @param parentCode 鐖剁骇code + * @Author: lc + * @Date: 2019/6/13 10:32 + */ + public static String getCode(String maxCode, String parentCode) { + if (StrUtil.isBlank(parentCode)) { + parentCode = ""; + } + if (StrUtil.isBlank(maxCode)) { + return parentCode + "001"; + } else { + maxCode = Convert.toStr(Convert.toLong(maxCode) + 1); + for (int i = 0; i < maxCode.length() % 3; i++) { + maxCode = "0" + maxCode; + } + return maxCode; + } + } + + /** + * 鐢熸垚鏃ユ湡鏍煎紡鐨勭紪鍙� + * + * @Author: lc + * @Date: 2019/7/2 15:19 + */ + public static String getTimeCode() { + String time = DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss"); + return time + RandomUtil.randomNumbers(4); + } + + public static void main(String[] args) { + System.out.println(getCode("002001", "002")); + System.out.println(getTimeCode()); + } + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/CommonUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/CommonUtil.java new file mode 100644 index 0000000..f10579c --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/CommonUtil.java @@ -0,0 +1,294 @@ +package com.nuvole.util; +// @formatter:off + +import cn.hutool.core.convert.Convert; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.URLUtil; +import cn.hutool.crypto.SecureUtil; +import com.alibaba.fastjson.JSON; +import com.nuvole.constants.SystemConstants; +import jakarta.servlet.ServletInputStream;import jakarta.servlet.http.HttpServletRequest;import jakarta.servlet.http.HttpServletResponse;import org.apache.commons.text.StringEscapeUtils; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * .-~~~~~~~~~-._ _.-~~~~~~~~~-. + * __.' @Author ~. .~ 浠g爜鏃燘ug `.__ + * .'// liu.q \./ (绉樼睄) \\`. + * .'// [916000612@qq.com] | 娆茬粌绁炲姛 寮曞垁鑷 \\`. + * .'// .-~"""""""~~~~-._ | _,-~~~~"""""""~-. \\`. + * .'//.-" 2019-04-09 `-. | .-' 10:48 "-.\\`. + * .'//______.============-.. \ | / ..-============.______\\`. + * .'______________________________\|/______________________________`. + * + * @Description : + */ +// @formatter:on +public class CommonUtil { + + /** + * @Author : liuq + * @Date : Create in 2018/7/1 涓婂崍1:20 + * @Description : 椹煎嘲杞笅鍒掔嚎 + */ + public static String camel2Underline(String line) { + return StrUtil.toUnderlineCase(line); + } + + /* + * @Author : liu.q [916000612@qq.com] + * + * @Date : 2019-04-29 16:45 + * + * @Description : 涓嬪垝绾胯浆椹煎嘲 + */ + public static String Underline2camel(String para) { + return StrUtil.toCamelCase(para); + } + + /** + * @Author : liu.q + * @Date : 2019-03-01 09:49 + * @Description : 鑾峰彇request + */ + public static HttpServletRequest getRequest() { + ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder + .getRequestAttributes(); + HttpServletRequest request = requestAttributes.getRequest(); + return request; + } + + /** + * @Author : liu.q + * @Date : 2019-03-01 09:49 + * @Description : response + */ + public static HttpServletResponse getResponse() { + ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder + .getRequestAttributes(); + HttpServletResponse response = requestAttributes.getResponse(); + return response; + } + + /** + * @Author : liu.q + * @Date : 2019-03-01 09:51 + * @Description : 鑾峰彇璁块棶鍦板潃 + */ + public static String getHost() { + HttpServletRequest request = getRequest(); + String scheme = request.getHeader("X-Forwarded-Scheme"); + if (scheme == null) { + scheme = request.getScheme(); + } + String port = request.getHeader("X-Forwarded-port"); + if (port == null) { + port = request.getServerPort() + ""; + } + if ("443".equals(port) || "80".equals(port)) { + return scheme + "://" + request.getServerName(); + } + return scheme + "://" + request.getServerName() + ":" + port;// +request.getRequestURI(); + } + + /** + * 鑾峰彇璇锋眰鍙傛暟 + * + * @return + */ + public static Map getParameterMap() { + // 鍙傛暟Map + Map properties = CommonUtil.getRequest().getParameterMap(); + // 杩斿洖鍊糓ap + Map returnMap = new HashMap(); + Iterator entries = properties.entrySet().iterator(); + Map.Entry entry; + String name = ""; + String value = ""; + while (entries.hasNext()) { + entry = (Map.Entry) entries.next(); + name = (String) entry.getKey(); + Object valueObj = entry.getValue(); + if (null == valueObj) { + continue; + } else if (valueObj instanceof String[]) { + String[] values = (String[]) valueObj; + for (int i = 0; i < values.length; i++) { + value = values[i] + ","; + } + value = value.substring(0, value.length() - 1); + } else { + value = valueObj.toString(); + // 褰搗alue涓簊tring empty涓烘湁鏁堝�� by zxc on 2020/5/11 15:00 + if ("".equals(value)) { + continue; + } + } + returnMap.put(name, value); + } + return returnMap; + } + + public static String getExportSign(String url, String timestamp) { + System.out.println("is url:" + URLUtil.getPath(url)); + return Convert + .toStr(SecureUtil.md5(SecureUtil.md5(URLUtil.getPath(url) + timestamp) + SystemConstants.EXPORT_SIGN_K).hashCode()); + } + + public static String listToString(List<String> items) { + String result = ""; + if (items != null && items.size() > 0) { + for (int i = 0; i < items.size(); i++) { + if (i == 0) { + result += items.get(i); + } else { + result += "," + items.get(i); + } + } + } + return result; + } + + public static <T> T getObjFromReq(Class<T> clazz) { + String s = JSON.toJSONString(getParameterMap()); + return JSON.parseObject(StringEscapeUtils.unescapeHtml4(s), clazz); + } + + public static <T> T getObjFromReqBody(Class<T> clazz) { + String jsonStr = getRequestBody(); + return JSON.parseObject(StringEscapeUtils.unescapeHtml4(jsonStr), clazz); + } + + /** + * 鑾峰彇request body鍊� + * + * @param + * @return + */ + private static String getRequestBody() { + HttpServletRequest request = getRequest(); + try { + return getStringFromInputStream(request.getInputStream()); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + + public static String getStringFromInputStream(ServletInputStream stream) throws IOException { + StringBuilder sb = new StringBuilder(); + BufferedReader reader = null; + try { + reader = new BufferedReader(new InputStreamReader(stream, "UTF-8")); + char[] ch = new char[1024]; + int bytesRead; + while ((bytesRead = reader.read(ch)) != -1) { + sb.append(ch, 0, bytesRead); + } + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return sb.toString(); + } + + /** + * 鑾峰彇鐢ㄦ埛鏍囪瘑 + * + * @return + */ + public static String getUserAgent() { + HttpServletRequest request = getRequest(); + return request.getHeader("User-Agent"); + } + + /** + * 鑾峰彇瀹㈡埛绔爣璇� + * + * @return 1.鏀粯瀹�-灏忕▼搴�, 2.鏀粯瀹�-鐢熸椿鍙�, 3.寰俊-灏忕▼搴�, 4.寰俊-鍏紬鍙� + */ + public static String getClientType() { + HttpServletRequest request = getRequest(); + return request.getHeader("CLIENT-TYPE"); + } + + /** + * 鏄惁涓哄井淇″皬绋嬪簭 + * + * @return + */ + public static boolean isWxMin() { + String userAgent = getUserAgent(); + return userAgent.contains("MiniProgram"); + } + + /** + * 鏄惁涓哄井淇″唴缃祻瑙堝櫒 + * + * @return + */ + public static boolean isWxBro() { + String userAgent = getUserAgent(); + return userAgent.contains("MicroMessenger"); + } + + /** + * 鏄惁涓烘敮浠樺疂鍐呯疆娴忚鍣� + * + * @return + */ + public static boolean isAliBro() { + String userAgent = getUserAgent(); + return userAgent.contains("Alipay"); + } + + /** + * 鏄惁涓烘敮浠樺疂灏忕▼搴忓鎴风 + * + * @return + */ + public static boolean isAliMin() { + String userAgent = getUserAgent(); + String clientType = getClientType(); + return userAgent.contains("Alipay") && SystemConstants.APP_TYPE_ALI_MINI.equals(clientType); + } + + /** + * 鏄惁涓虹考鏀粯 + * + * @return + */ + public static boolean isBestPayBro() { + String userAgent = getUserAgent(); + return userAgent.contains("Bestpay"); + } + + /** + * 鏄惁涓轰簯闂粯 + * + * @return + */ + public static boolean isCloudPayBro() { + String userAgent = getUserAgent(); + return userAgent.contains("CloudPay"); + } + + public static boolean isUnionPayBro() { + String userAgent = getUserAgent(); + return userAgent.contains("UnionPay"); + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ComputeUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ComputeUtil.java new file mode 100644 index 0000000..6802380 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ComputeUtil.java @@ -0,0 +1,102 @@ +package com.nuvole.util; + +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +/** + * 璁$畻宸ュ叿绫� + * + * @Author: lc + * @Date: 2019/5/23 19:10 + */ +public class ComputeUtil { + + /** + * 璁$畻鐧惧垎姣� + * + * @param num 鍗犳瘮鍊� + * @param total 鎬绘暟 + * @param scale 灏忔暟 + * @Author: lc + * @Date: 2019/8/22 10:32 + */ + public static String percentum(double num, double total, int scale) { + if (num == 0 || total == 0) { + return "0"; + } + DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(); + //鍙互璁剧疆绮剧‘鍑犱綅灏忔暟 + df.setMaximumFractionDigits(scale); + //妯″紡 渚嬪鍥涜垗浜斿叆 + df.setRoundingMode(RoundingMode.HALF_UP); + double accuracy_num = num / total * 100; + return df.format(accuracy_num); + } + + + /** + * 鑾峰彇涓や釜鏃ユ湡涔嬮棿鎵�鏈夋棩鏈燂紙骞存湀鏃ワ級 + * + * @Author: lc + * @Date: 2019/8/23 13:41 + */ + public static List<String> getBetweenDates(String begin, String end, String formatString) { + SimpleDateFormat format = new SimpleDateFormat(formatString); + List<String> result = new ArrayList<String>(); + try { + Calendar tempStart = Calendar.getInstance(); + tempStart.setTime(format.parse(begin)); + tempStart.add(Calendar.DAY_OF_YEAR, 1); + + Calendar tempEnd = Calendar.getInstance(); + tempEnd.setTime(format.parse(end)); + result.add(format.format(format.parse(begin))); + while (tempStart.before(tempEnd)) { + result.add(format.format(tempStart.getTime())); + tempStart.add(Calendar.DAY_OF_YEAR, 1); + } + result.add(format.format(format.parse(end))); + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } + + /** + * 鑾峰彇淇╀釜鏃ユ湡闂寸殑鎵�鏈夋棩鏈燂紙骞存湀锛� + * + * @Author: lc + * @Date: 2019/8/24 16:31 + */ + public static List<String> getBetweenMonths(String minDate, String maxDate, String formatString) { + ArrayList<String> result = new ArrayList<String>(); + try { + SimpleDateFormat sdf = new SimpleDateFormat(formatString);//鏍煎紡鍖栦负骞存湀 + + Calendar min = Calendar.getInstance(); + Calendar max = Calendar.getInstance(); + min.setTime(sdf.parse(minDate)); + min.set(min.get(Calendar.YEAR), min.get(Calendar.MONTH), 1); + + max.setTime(sdf.parse(maxDate)); + max.set(max.get(Calendar.YEAR), max.get(Calendar.MONTH), 2); + + Calendar curr = min; + while (curr.before(max)) { + result.add(sdf.format(curr.getTime())); + curr.add(Calendar.MONTH, 1); + } + } catch (ParseException e) { + e.printStackTrace(); + } + + return result; + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/CryptoUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/CryptoUtil.java new file mode 100644 index 0000000..fa31de7 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/CryptoUtil.java @@ -0,0 +1,55 @@ +package com.nuvole.util; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.SecureUtil; +import cn.hutool.crypto.asymmetric.KeyType; +import cn.hutool.crypto.asymmetric.RSA; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName CryptoUtil + * @date 2019/5/6 11:47 + * @Description 鍔犲瘑锛岃В瀵嗗伐鍏风被 + */ +public class CryptoUtil { + // 绯荤粺鍐呴儴浣跨敤 + private static final String PUBK = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCTREknOkrusbeH7kBe3mSw4AwVT438IWmX/jKmcvYxaAWRrBJiMl7gk37L78HBG/ZstLLcdKBYYdj/5cvVWDQfv+uxbv/piZhOmQej98jWIXEA8aFEk724nFRJ7nfcEhHSWfzbTfgZw0KDO1mWdjWHnHIx/MtD0HIFFIyzg3aO7wIDAQAB"; + private static final String PRIK = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAJNESSc6Su6xt4fuQF7eZLDgDBVPjfwhaZf+MqZy9jFoBZGsEmIyXuCTfsvvwcEb9my0stx0oFhh2P/ly9VYNB+/67Fu/+mJmE6ZB6P3yNYhcQDxoUSTvbicVEnud9wSEdJZ/NtN+BnDQoM7WZZ2NYeccjH8y0PQcgUUjLODdo7vAgMBAAECgYBVu5Y+0Q/Yf/uRleFBmYTS98vxCBxnoOgBRUolXp32y1EaqisVoa9cXGGfxhdtHaNLS7Mo5niGm4giCZytuii1RO8kVXDAgMM2KRVIkOj2yTKJPRxgh9u0ja18MrpkCGnWYBYiU6irq+Ugu9+srkQSefPFX47U2QbLtxV5XF4iuQJBAMgh3FvAwV99tqGe+z+JtySRdtqEfK0M3Z4vpyqSH6miT1CbEqT942rPHbIUUqLwf6VMjxTYACwcLpVy/k3xrg0CQQC8YHkLxzE52o/wg817Rwwh0LpXz6dghQK7g6eMQyUi4C2PiOmqxpCFk2DOR0R4Rcw6SKxB4XQgyqM2zrdBsa3rAkEAtQcz/WbpQ8hCOAXHvNyEZjaSbOzkneACY0E1k+Njcp0X45CyF750RLweX2PUsACdZddPoYoU9dF0Lck70SNozQJBAIPBPiicw7NhSTfCGCBXSwcDxLHSTZFWttiMds3F0N2ZyoQQEM8fXsnukND2S8+LkhJZ7hGOLPkaghm9b7OFIM0CQEDvsXNcmF2+SWfFJDR57tblAIsOSLGeODWnlzaaFUFDHlbrCkexLJ+o1+C4xHMzUMHHMjHDJVpKt2EJdkfh4xU="; + // 绗笁鏂� 浜烘墠鎺ュ彛 + private static final String RCMPUBK = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqmYlQIg1eA6bavzgUx6CjlPcJpoTmqY/lBph8VRYH2G0ez/7Yl/Ooc5J9/1nhJ7Ql4u7TRjYZrgw8z3Ul1/kQtel4GQdGOEadb1mmzHRlp5xeqiwj5/fJV+8CbqMNj+mobIJVbdV/oRpxTQMck3NRH1X52LsVFBixp079eGoSawIDAQAB"; + private static final String RCMPRIK = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKqZiVAiDV4Dptq/OBTHoKOU9wmmhOapj+UGmHxVFgfYbR7P/tiX86hzkn3/WeEntCXi7tNGNhmuDDzPdSXX+RC16XgZB0Y4Rp1vWabMdGWnnF6qLCPn98lX7wJuow2P6ahsglVt1X+hGnFNAxyTc1EfVfnYuxUUGLGnTv14ahJrAgMBAAECgYEAo/7kWPvjDbVE+JNJPfCJI7dXoxdIOtRVVzx36U2B2BjdDPm1alDoEc7HzAdkR2T7cFAudTrRVu5RJUPowXBUI4H/m19JrJiYKqlmhUUrlf+TxFajkUPC1fUSGKzj+Oh/H76/unZbOmhp+TMkopyeI0tU7xmXHuEZk9i2Zq1z+oECQQDbDPa9PpOFLdc0iONfMlYSh4wXUVfhiH2gQ6G10Mf3K6KN6ESnwULWuhrE/N7Zw6zuZBdEqveanJ6NVcaIR8Y5AkEAx2BeQSO0WSkUgKNB9xaVutDddDuKferRpomcecUEf2LN/z3u4DE7P3O9Gwi4iQTHrxMhfLq/VKa8yJjUv5a9wwJAYTk/yn8buuC9w/N996K/0TmYVEEmYFPUbm2WOLySBIK5g4Kz9kExCV1QxF34C29uMeD68t9vRpB9Tv3jQFmbAQJAKu2t/bqRV21H89azGl+rh5j3RdKYJDqOP5x7q6BnMoJ0tlOAfpc7GZNzEUIUcbQsxp6I5FFVZwWrukll7YaofwJBALRdRoP+FOkJv+MMP8Dytxe8c3Cy1OIEkRglPDydmwDoAp+sObm80vKgmfR/llsK2Z1DppvDRkpVHwWtHwZfqZQ="; + + public static String rsaEncode(String s, Short flag) { + RSA rsa = null; + if (flag == null || flag == 1) { + rsa = SecureUtil.rsa(PRIK, PUBK); + } else if (flag != null && flag == 2) { + rsa = SecureUtil.rsa(RCMPRIK, RCMPUBK); + } + return Base64.encode( + rsa.encrypt(StrUtil.bytes(s, CharsetUtil.CHARSET_UTF_8), KeyType.PublicKey)); + } + + public static String rsaDecode(String s, Short flag) { + RSA rsa = null; + if (flag == null || flag == 1) { + rsa = SecureUtil.rsa(PRIK, PUBK); + } else if (flag != null && flag == 2) { + rsa = SecureUtil.rsa(RCMPRIK, RCMPUBK); + } + return new String(rsa.decrypt(Base64.decode(s), KeyType.PrivateKey)); + } + + public static void main(String[] args) { + String str = "zhangsan"; + System.out.println(rsaEncode(str, (short) 2)); + + str = "JyfPzIktNeH4VWkGIUzMpaJiOcCvlZQkE5q1tKnxH0xK/FNAcPgrLJYBscp6oHDCd7+FTkjkOicQepkE7UiceEY0zqvQrutVE1kjy4TNH0V4NIAoCk7y5qzo19m/247vh+GbZEW/C4qTRbtrFNoolO4hfMxuH7kqNB5VS8OdIRQ="; + System.out.println(rsaDecode(str, (short) 2)); + } + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/DesensitizationUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/DesensitizationUtil.java new file mode 100644 index 0000000..ae6ba5e --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/DesensitizationUtil.java @@ -0,0 +1,58 @@ +package com.nuvole.util; + +import cn.hutool.core.util.StrUtil; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName DesensitizationUtil + * @date 2019/4/28 19:37 + * @Description 鑴辨晱宸ュ叿绫� + */ +public class DesensitizationUtil { + + public static String esensitizationdName(String str) { + if (StrUtil.isBlank(str)) { + return ""; + } + String res = str.substring(0, 1); + for (int i = 1; i < str.length(); i++) { + res += "*"; + } + return res; + } + + /** + * Createed by PKZ + * Date 2019/6/4 13:35 + * Description锛氭墜鏈哄彿鑴辨晱 + **/ + public static String esensitizationdMobile(String mobile) { + if (StrUtil.isBlank(mobile)) { + return ""; + } + if (mobile.length() != 11) { + return ""; + } + String start = mobile.substring(0, 3); + String end = mobile.substring(mobile.length() - 4, mobile.length()); + return start + "****" + end; + } + + /** + * Createed by PKZ + * Date 2019/6/4 13:35 + * Description锛氳韩浠借瘉鍙疯劚鏁� + **/ + public static String esensitizationdIdcard(String idcard) { + if (StrUtil.isBlank(idcard)) { + return ""; + } + if (idcard.length() != 18) { + return ""; + } + String start = idcard.substring(0, 4); + String end = idcard.substring(idcard.length() - 4, idcard.length()); + return start + "******" + end; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/DiscountUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/DiscountUtil.java new file mode 100644 index 0000000..457a7ed --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/DiscountUtil.java @@ -0,0 +1,51 @@ +package com.nuvole.util; + +import cn.hutool.core.convert.Convert; +import cn.hutool.core.util.NumberUtil; +import org.apache.commons.lang.StringUtils; + +import java.util.HashMap; +import java.util.Map; + +/** + * @ClassName DiscountUtil + * @Author cy + * @Date 2023/5/25 + * @Description + * @Version 1.0 + **/ +public class DiscountUtil { + /** + * @param totalMoney 鎬婚噾棰� + * @param discount 鎶樻墸 + * @return + */ + public static Map<String, Long> getDiscount(long totalMoney, String discount) { + if (StringUtils.isBlank(discount)) { + return null; + } + HashMap<String, Long> map = new HashMap<>(); + if ("10".equals(discount)) { + map.put("disCountMoney", 0l); + map.put("payMoney", totalMoney); + return map; + } + Double disc = NumberUtil.div(Convert.toDouble(discount), Convert.toDouble(10)); //鎶樻墸 + //鎶樻墸浼樻儬鍚庡簲浠橀噾棰� + Long payMoney = Convert.toLong(Math.ceil(NumberUtil.mul(Convert.toDouble(totalMoney), disc))); // 鎵撴姌鍚庨噾棰濓紙鍚戜笂鍙栨暣锛� + + // 浼樻儬閲戦 + Long disCountMoney = 0l; + if (Convert.toDouble(totalMoney) >= payMoney) { + disCountMoney = totalMoney - payMoney; + } else { + disCountMoney = totalMoney; + payMoney = 0L; + } +// map.put("totalMoney", totalMoney); + map.put("disCountMoney", disCountMoney); + map.put("payMoney", payMoney); + return map; + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/DistanceUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/DistanceUtil.java new file mode 100644 index 0000000..95fd615 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/DistanceUtil.java @@ -0,0 +1,44 @@ +package com.nuvole.util; + +/** + * 璁$畻鍧愭爣璺濈宸ュ叿绫� + * + * @Author: lc + * @Date: 2019/5/23 19:10 + */ +public class DistanceUtil { + + private static double EARTH_RADIUS = 6378.137; + + private static double rad(double d) { + return d * Math.PI / 180.0; + } + + /** + * 閫氳繃缁忕含搴﹁幏鍙栬窛绂�(鍗曚綅锛氱背)锛堣吘璁潗鏍囷級 + * + * @Author: lc + * @Date: 2019/5/23 19:14 + */ + public static double getDistance(double lat1, double lng1, double lat2, double lng2) { + double radLat1 = rad(lat1); + double radLat2 = rad(lat2); + double a = radLat1 - radLat2; + double b = rad(lng1) - rad(lng2); + double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + + Math.cos(radLat1) * Math.cos(radLat2) + * Math.pow(Math.sin(b / 2), 2))); + s = s * EARTH_RADIUS; + s = Math.round(s * 10000d) / 10000d; + s = s * 1000; + return s; + } + + public static void main(String[] args) { + //閲戞槑婧�-鏉ㄩ噾璺�34.844000,113.743560 + double distance = getDistance(34.844222, 113.743300, 34.844000, 113.743560); + System.out.println("璺濈" + distance + "绫�"); + } + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ExportExcel.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ExportExcel.java new file mode 100644 index 0000000..ea06dc1 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ExportExcel.java @@ -0,0 +1,79 @@ +package com.nuvole.util; +// @formatter:off +import jakarta.servlet.http.HttpServletResponse;import lombok.val;import org.apache.poi.hssf.usermodel.*; +import java.net.URLEncoder;import java.util.Date;import java.util.List;import java.util.Locale; /** + * .-~~~~~~~~~-._ _.-~~~~~~~~~-. + * __.' @Author ~. .~ 浠g爜鏃燘ug `.__ + * .'// liu.q \./ (绉樼睄) \\`. + * .'// [916000612@qq.com] | 娆茬粌绁炲姛 寮曞垁鑷 \\`. + * .'// .-~"""""""~~~~-._ | _,-~~~~"""""""~-. \\`. + * .'//.-" 2019-07-17 `-. | .-' 16:54 "-.\\`. + * .'//______.============-.. \ | / ..-============.______\\`. + *.'______________________________\|/______________________________`. + * + * @Description : + */ +// @formatter:on + +public class ExportExcel { + public static void exportExcel(String fileName, List<String> titles, List<List<Object>> rows, HttpServletResponse response) throws Exception { + + // 澹版槑涓�涓伐浣滆杽 + HSSFWorkbook workbook = new HSSFWorkbook(); + // 鐢熸垚涓�涓〃鏍� + HSSFSheet sheet = workbook.createSheet(); + // 璁剧疆琛ㄦ牸榛樿鍒楀搴︿负15涓瓧鑺� + sheet.setDefaultColumnWidth((short) 18); + + //璁剧疆鏍囬 + HSSFRow title = sheet.createRow(0); + for (int i = 0; i < titles.size(); i++) { + HSSFCell cell = title.createCell(i); + HSSFRichTextString text = new HSSFRichTextString(titles.get(i)); + cell.setCellValue(text); + } + + //璁剧疆鏁版嵁 + HSSFCellStyle cellStyle = workbook.createCellStyle(); + for (int i = 0; i < rows.size(); i++) { + HSSFRow row = sheet.createRow(i + 1); + List<Object> clo = rows.get(i); + int index = 0; + for (Object o : clo) { + HSSFCell cell = row.createCell(index); + if (o instanceof Date) { + HSSFDataFormat format = workbook.createDataFormat(); + cellStyle.setDataFormat(format.getFormat("yyyy-mm-dd HH:mm:ss")); + cell.setCellStyle(cellStyle); + cell.setCellValue((Date) o); + } else if (o instanceof Double) { + HSSFDataFormat format = workbook.createDataFormat(); + cellStyle.setDataFormat(format.getFormat("#,##0.00")); + cell.setCellStyle(cellStyle); + cell.setCellValue(Double.valueOf(o.toString())); + } else { + HSSFDataFormat format = workbook.createDataFormat(); + cellStyle.setDataFormat(format.getFormat("@")); + cell.setCellStyle(cellStyle); + cell.setCellValue(o.toString()); + } + index++; + } + } + // 鍛婅瘔娴忚鍣ㄧ敤浠�涔堣蒋浠跺彲浠ユ墦寮�姝ゆ枃浠� + response.setHeader("content-Type", "application/vnd.ms-excel"); + + //瑙e喅 鑻规灉娴忚鍣ㄤ贡鐮侀棶棰� + val ua = CommonUtil.getRequest().getHeader("User-Agent").toLowerCase(Locale.ENGLISH); + if (ua.indexOf("macintosh") > -1 && ua.indexOf("chrome") < 0) { + fileName = new String(fileName.getBytes(), "iso8859-1"); + } else { + fileName = URLEncoder.encode(fileName, "utf-8"); + } + + // 涓嬭浇鏂囦欢鐨勯粯璁ゅ悕绉� + response.setHeader("Content-Disposition", "attachment;filename=" + fileName); + response.flushBuffer(); + workbook.write(response.getOutputStream()); + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ExpressUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ExpressUtil.java new file mode 100644 index 0000000..2438083 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ExpressUtil.java @@ -0,0 +1,84 @@ +package com.nuvole.util; + +import java.net.URLEncoder; +import java.util.HashMap; + +import com.nuvole.common.domain.result.ExpressResult; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.SecureUtil; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; +import lombok.extern.slf4j.Slf4j; + +/** + * 蹇�掗笩鐗╂祦鎺ュ彛 + * + * @Author: lc + * @Date: 2019/6/13 15:36 + */ +@Slf4j +public class ExpressUtil { + + private static String fileName = "express.properties"; + + + //鐢靛晢ID + public static String EBusinessID = ""; + //鐢靛晢鍔犲瘑绉侀挜锛屽揩閫掗笩鎻愪緵锛屾敞鎰忎繚绠★紝涓嶈娉勬紡 + public static String AppKey = ""; + //璇锋眰url, + public static String ReqURL = ""; + //蹇�掔被鍨� + public static String Type = ""; + + static { + EBusinessID = PropertyUtil.getProp(fileName, "EBusinessID"); + AppKey = PropertyUtil.getProp(fileName, "AppKey"); + ReqURL = PropertyUtil.getProp(fileName, "ReqURL"); + Type = PropertyUtil.getProp(fileName, "Type"); + } + + + /** + * 鏌ヨ璁㈠崟鐗╂祦杞ㄨ抗锛圝son鏂瑰紡 锛塠3000娆�/澶�,姣忓崟姣忓ぉ闄愭煡 5 娆�,骞跺彂涓嶈秴杩� 10 娆�/S] + * + * @Author: lc + * @Date: 2019/6/13 15:38 + */ + public static ExpressResult getOrderTracesByJson(String expressType, String expressCode) { + try { + //濡傛灉涓嶄紶蹇�掑叕鍙告爣璇嗗垯鍙栭粯璁ゅ�� + if (StrUtil.isEmpty(expressType)) { + expressType = Type; + } + String requestData = "{'OrderCode':'','ShipperCode':'" + expressType + "','LogisticCode':'" + expressCode + "'}"; + + HashMap<String, Object> params = new HashMap<>(); + params.put("RequestData", URLEncoder.encode(requestData, "UTF-8")); + params.put("EBusinessID", EBusinessID); + params.put("RequestType", "1002"); //璇锋眰鎺ュ彛鎸囦护 + String dataSign = encrypt(requestData, AppKey, "UTF-8"); + params.put("DataSign", URLEncoder.encode(dataSign, "UTF-8")); + params.put("DataType", "2"); //json鏂瑰紡 + String result = HttpUtil.post(ReqURL, params); + System.out.println(result); + return JSONUtil.toBean(result, ExpressResult.class); + } catch (Exception e) { + e.printStackTrace(); + return new ExpressResult(); + } + } + + + //鍔犲瘑 (杩涜MD5鍔犲瘑锛岀劧鍚嶣ase64缂栫爜锛屾渶鍚� 杩涜URL(utf-8)缂栫爜) + private static String encrypt(String content, String keyValue, String charset) { + if (keyValue != null) { + return Base64.encode(SecureUtil.md5(content + keyValue).toLowerCase(), charset); + } + return Base64.encode(SecureUtil.md5(content).toLowerCase(), charset); + } + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/FileTypeJudge.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/FileTypeJudge.java new file mode 100644 index 0000000..7ac0cf3 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/FileTypeJudge.java @@ -0,0 +1,117 @@ +package com.nuvole.util; + +import com.nuvole.util.enums.FileType; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +// @formatter:off +/** + * .-~~~~~~~~~-._ _.-~~~~~~~~~-. + * __.' @Author ~. .~ 浠g爜鏃燘ug `.__ + * .'// liu.q \./ (绉樼睄) \\`. + * .'// [916000612@qq.com] | 娆茬粌绁炲姛 寮曞垁鑷 \\`. + * .'// .-~"""""""~~~~-._ | _,-~~~~"""""""~-. \\`. + * .'//.-" 2019-04-24 `-. | .-' 15:56 "-.\\`. + * .'//______.============-.. \ | / ..-============.______\\`. + *.'______________________________\|/______________________________`. + * + * @Description : + */ +// @formatter:on + +public class FileTypeJudge { + + private FileTypeJudge() { + } + + /** + * 灏嗘枃浠跺ご杞崲鎴�16杩涘埗瀛楃涓� + * + * @return 16杩涘埗瀛楃涓� + */ + private static String bytesToHexString(byte[] src) { + + StringBuilder stringBuilder = new StringBuilder(); + if (src == null || src.length <= 0) { + return null; + } + for (int i = 0; i < src.length; i++) { + int v = src[i] & 0xFF; + String hv = Integer.toHexString(v); + if (hv.length() < 2) { + stringBuilder.append(0); + } + stringBuilder.append(hv); + } + return stringBuilder.toString(); + } + + /** + * 寰楀埌鏂囦欢澶� + * + * @param filePath 鏂囦欢璺緞 + * @return 鏂囦欢澶� + * @throws IOException + */ + private static String getFileContent(String filePath) throws IOException { + + byte[] b = new byte[28]; + + InputStream inputStream = null; + + try { + inputStream = new FileInputStream(filePath); + inputStream.read(b, 0, 28); + } catch (IOException e) { + e.printStackTrace(); + throw e; + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + throw e; + } + } + } + return bytesToHexString(b); + } + + private static String getFileContent(InputStream inputStream){ + InputStream is = inputStream; + byte[] b = new byte[28]; + try { + is.read(b, 0, 28); + } catch (IOException e) { + e.printStackTrace(); + } + return bytesToHexString(b); + } + + /** + * 鍒ゆ柇鏂囦欢绫诲瀷 + * + * @return 鏂囦欢绫诲瀷 + */ + public static String getType(InputStream inputStream){ + + String fileHead = getFileContent(inputStream); + + if (fileHead == null || fileHead.length() == 0) { + return null; + } + + fileHead = fileHead.toUpperCase(); + + FileType[] fileTypes = FileType.values(); + + for (FileType type : fileTypes) { + if (fileHead.startsWith(type.getValue())) { + return type.toString(); + } + } + return ""; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/FtpUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/FtpUtil.java new file mode 100644 index 0000000..f1c7ca5 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/FtpUtil.java @@ -0,0 +1,88 @@ +package com.nuvole.util; + +import cn.hutool.core.convert.Convert; +import cn.hutool.core.io.FileUtil; +import cn.hutool.extra.ftp.Ftp; +import cn.hutool.extra.ftp.FtpMode; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.net.ftp.FTP; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.ResourceLoader; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName FtpUtil + * @date 2019/4/15 14:16 + */ +@Slf4j +public class FtpUtil { + + public static Properties getFtpProp() { + Properties props = new Properties(); + InputStream in = null; + try { + ResourceLoader resourceLoader = new DefaultResourceLoader(); + in = resourceLoader.getResource("ftp.properties").getInputStream(); + props.load(in); + return props; + } catch (IOException e) { + e.printStackTrace(); + return props; + } finally { + ResourceUtil.safeClose(in); + } + + } + + public static Ftp getFtp() { + + Properties props = getFtpProp(); + String url = props.getProperty("ftp.url"); + int port = Convert.toInt(props.getProperty("ftp.port")); + String username = props.getProperty("ftp.username"); + String mixpd = props.getProperty("ftp.mixpd"); + + Ftp ftp = new Ftp(url, port, username, mixpd); + ftp.setMode(FtpMode.Passive); + ftp.getClient().setActivePortRange(50000, 55000); + ftp.getClient().setRemoteVerificationEnabled(false); + try { + ftp.getClient().setFileType(FTP.BINARY_FILE_TYPE); + } catch (IOException e) { + e.printStackTrace(); + } + return ftp; + } + + public static void upload(Ftp ftp, String sourceFilePath,String targetFilePath) { + String FileName = targetFilePath.substring(targetFilePath.lastIndexOf("/") + 1); + String targetPath = targetFilePath.substring(0, targetFilePath.lastIndexOf("/")); + ftp.upload(targetPath, FileName, new File(sourceFilePath)); + } + + public static void upload(Ftp ftp, String FileName,InputStream inputStream,String targetPath) { + ftp.upload(targetPath,FileName,inputStream); + } + + public static void download(Ftp ftp, String sourceFilePath,String targetFilePath) { + String sourceName = sourceFilePath.substring(sourceFilePath.lastIndexOf("/") + 1); + String sourcePath = sourceFilePath.substring(0, sourceFilePath.lastIndexOf("/")); + ftp.download(sourcePath, sourceName, FileUtil.file(targetFilePath)); + } + + public static void close(Ftp ftp) { + if (ftp != null) { + try { + ftp.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/GeTuiPush.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/GeTuiPush.java new file mode 100644 index 0000000..dc622cd --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/GeTuiPush.java @@ -0,0 +1,273 @@ +package com.nuvole.util; + +import com.gexin.rp.sdk.base.IAliasResult; +import com.gexin.rp.sdk.base.IPushResult; +import com.gexin.rp.sdk.base.impl.AppMessage; +import com.gexin.rp.sdk.base.impl.ListMessage; +import com.gexin.rp.sdk.base.impl.SingleMessage; +import com.gexin.rp.sdk.base.impl.Target; +import com.gexin.rp.sdk.base.notify.Notify; +import com.gexin.rp.sdk.base.payload.APNPayload; +import com.gexin.rp.sdk.exceptions.RequestException; +import com.gexin.rp.sdk.http.IGtPush; +import com.gexin.rp.sdk.template.AbstractTemplate; +import com.gexin.rp.sdk.template.TransmissionTemplate; +import com.nuvole.common.domain.emnu.CommonResultEmnu; +import com.nuvole.common.domain.result.CommonResult; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + + +/** + * 鎺ㄩ�佸伐鍏风被锛堜釜鎺級 + * + * @Author: lc + * @Date: 2020/4/26 13:41 + */ + +public class GeTuiPush { + + private static String url = "http://sdk.open.api.igexin.com/apiex.htm"; +// private static String appId = "0TrCn76GcW8T4y3wediOn9"; + private static String appId = "g1FYuSXD2x5HY2KfWswP19"; +// private static String appKey = "FUPAiYeLSo5hbPIZrRDT21"; + private static String appKey = "kkMqLLBGLd7wx0mhIbG9l5"; +// private static String masterSecret = "ne5FG9hfS77RNyGAnQF5p1"; + private static String masterSecret = "AEuOKMlvTY9aLrdjtPhzy7"; + private static IGtPush igtPush = new IGtPush(url, appKey, masterSecret); + + + /** + * 涓虹敤鎴风粦瀹氬埆鍚� + * + * @param clientId 瀹㈡埛绔韩浠絠d + * @param alias 鍒悕 + * @Author: lc + * @Date: 2020/4/26 13:36 + */ + public static CommonResult bindAlias(String clientId, String alias) { + + IAliasResult ret = null; + try { + ret = igtPush.bindAlias(appId, alias, clientId); + System.out.println("is bindAlias res:" + ret.getResponse()); + } catch (RequestException e) { + e.printStackTrace(); + } + if (ret != null) { + Map res = ret.getResponse(); + if ("ok".equals(res.get("result").toString())) { + return new CommonResult(res); + } else { + return new CommonResult(CommonResultEmnu.ERROR, res.get("error_msg").toString()); + } + } else { + return new CommonResult(CommonResultEmnu.ERROR, "缁戝畾涓帹鍒悕鏃跺嚭鐜板紓甯革紒"); + } + } + + + //娴嬭瘯 + public static void main(String[] args) { + + bindAlias("0482fa489fe285cbb8b96054f81a0b4f", "123456789"); + pushMessageToSingle("娴嬭瘯demo", "娴嬭瘯demo鍐呭", 2, "123456789"); + } + + /** + * 鍗曟帹锛堝崟涓猚lientId/鍒悕锛� + * + * @param title 鏍囬 + * @param content 鍐呭 + * @param type 绫诲瀷銆�1.璁惧id锛坈lientId锛� 2.鍒悕銆� + * @param val 绫诲瀷鍊硷紙clientId/鍒悕锛� + * @Author: lc + * @Date: 2020/4/26 13:31 + */ + public static Map pushMessageToSingle(String title, String content, int type, String val) { + + /*閫忎紶娑堟伅妯$増*/ + AbstractTemplate template = getTransmissionTemplate(title, content); + + // 鍗曟帹娑堟伅绫诲瀷 + SingleMessage message = getSingleMessage(template); + Target target = new Target(); + target.setAppId(appId); + if (type == 1) { + target.setClientId(val); + } else { + target.setAlias(val);//鍒悕闇�瑕佹彁鍓嶇粦瀹� + } + IPushResult ret = null; + try { + ret = igtPush.pushMessageToSingle(message, target); + System.out.println("is pushMessageToSingle res:" + ret.getResponse()); + } catch (RequestException e) { + e.printStackTrace(); + ret = igtPush.pushMessageToSingle(message, target, e.getRequestId()); + } + if (ret != null) { + return ret.getResponse(); + } else { + System.out.println("涓帹鍗曟潯鎺ㄩ�佹湇鍔″櫒鍝嶅簲寮傚父"); + return null; + } + } + + + /** + * 鎺ㄩ�佷竴涓垪琛� + * + * @param title 鏍囬 + * @param content 鍐呭 + * @parma type 绫诲瀷銆�1.璁惧id锛坈lientId锛� 2.鍒悕銆� + * @parma jsonArray 绫诲瀷鍊硷紙clientId/鍒悕锛� + * @Author: lc + * @Date: 2020/4/26 13:37 + */ + public static Map pushMessageToList(String title, String content, int type, List<String> list) { + /*閫忎紶娑堟伅妯$増*/ + AbstractTemplate template = getTransmissionTemplate(title, content); + + ListMessage message = new ListMessage(); + message.setData(template); + // 璁剧疆娑堟伅绂荤嚎锛屽苟璁剧疆绂荤嚎鏃堕棿 + message.setOffline(true); + // 绂荤嚎鏈夋晥鏃堕棿锛屽崟浣嶄负姣锛屽彲閫� + message.setOfflineExpireTime(24 * 1000 * 3600); + message.setPriority(1); + String taskId = igtPush.getContentId(message); + // 閰嶇疆鎺ㄩ�佺洰鏍� + List targets = new ArrayList(); + for (int i = 0; i < list.size(); i++) { + String cid = list.get(i); + Target target = new Target(); + target.setAppId(appId); + if (type == 1) { + target.setClientId(cid); + } else { + target.setAlias(cid); + } + targets.add(target); + } + + IPushResult ret = null; + try { + ret = igtPush.pushMessageToList(taskId, targets); + System.out.println("is pushMessageToList:" + ret.getResponse()); + } catch (Exception e) { + e.printStackTrace(); + } + if (ret != null) { + return ret.getResponse(); + } else { + System.out.println("涓帹鎺ㄩ�佷竴涓垪琛ㄦ湇鍔″櫒鍝嶅簲寮傚父"); + return null; + } + } + + + /** + * 鎺ㄩ�佹墍鏈夋墜鏈虹敤鎴� + * + * @param title 鏍囬 + * @param content 鍐呭 + * @Author: lc + * @Date: 2020/4/26 13:36 + */ + public static Map pushMessageToApp(String title, String content) { + /*閫忎紶娑堟伅妯$増*/ + AbstractTemplate template = getTransmissionTemplate(title, content); + + // 鍗曟帹娑堟伅绫诲瀷 + AppMessage message = new AppMessage(); + message.setData(template); + message.setOffline(true); + message.setOfflineExpireTime(24 * 1000 * 3600); //绂荤嚎鏈夋晥鏃堕棿锛屽崟浣嶄负姣锛屽彲閫� + //鍏ㄩ噺鎺ㄩ�佹椂甯屾湜鑳芥帶鍒舵帹閫侀�熷害涓嶈澶揩锛岀紦鍑忔湇鍔″櫒杩炴帴鍘嬪姏锛屽彲璁剧疆瀹氶�熸帹閫併�傚鏋滄湭璁剧疆鍒欐寜榛樿鎺ㄩ�侀�熷害鍙戦�� + message.setSpeed(100); // 璁剧疆涓�100锛屽惈涔変负涓帹鎺у埗涓嬪彂閫熷害鍦�100鏉�/绉掑乏鍙� + List<String> appIdList = new ArrayList<String>(); + appIdList.add(appId); + message.setAppIdList(appIdList); + + IPushResult ret = null; + try { + ret = igtPush.pushMessageToApp(message); + System.out.println("is pushMessageToApp res:" + ret.getResponse()); + } catch (RequestException e) { + e.printStackTrace(); + ret = igtPush.pushMessageToApp(message, e.getRequestId()); + } + if (ret != null) { + return ret.getResponse(); + } else { + System.out.println("涓帹鎺ㄩ�佹墍鏈夋墜鏈虹敤鎴锋湇鍔″櫒鍝嶅簲寮傚父"); + return null; + } + } + + /** + * 閫忎紶娑堟伅妯$増 + * + * @param title 鏍囬 + * @param content 鍐呭 + * @Author: lc + * @Date: 2020/4/26 13:46 + */ + private static TransmissionTemplate getTransmissionTemplate(String title, String content) { + TransmissionTemplate template = new TransmissionTemplate(); + /*璁剧疆APPID涓嶢PPKEY*/ + template.setAppId(appId); + template.setAppkey(appKey); + /*閫忎紶娑堟伅璁剧疆锛�1涓哄己鍒跺惎鍔ㄥ簲鐢紝瀹㈡埛绔帴鏀跺埌娑堟伅鍚庡氨浼氱珛鍗冲惎鍔ㄥ簲鐢紱2涓虹瓑寰呭簲鐢ㄥ惎鍔�*/ + template.setTransmissionType(2); + template.setTransmissionContent(content); + /*ios娑堟伅鎺ㄩ��*/ + template.setAPNInfo(getAPNPayload()); + + Notify notify = new Notify(); +// notify.setIntent("intent:#intent;action=android.intent.action.oppopush;package=cn.com.pconline.android.browser;component=cn.com.android.browser/cn.com.android.browser.push.MultivendorPushActivity;S.protocol=pconlinebrowser://information-article/8270922;end"); + notify.setIntent("intent:#Intent;action=android.intent.action.oppopush;launchFlags=0x14000000;component=com.liuqit.notebook/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title=" + title + ";S.content=" + content + ";S.payload=" + content + ";end"); + notify.setTitle(title); + notify.setContent(content); + /*绗笁鏂�*/ + template.set3rdNotifyInfo(notify); + return template; + } + + private static SingleMessage getSingleMessage(AbstractTemplate template) { + SingleMessage message = new SingleMessage(); + message.setData(template); + // 璁剧疆娑堟伅绂荤嚎锛屽苟璁剧疆绂荤嚎鏃堕棿 + message.setOffline(true); + // 绂荤嚎鏈夋晥鏃堕棿锛屽崟浣嶄负姣锛屽彲閫� + message.setOfflineExpireTime(72 * 3600 * 1000); + message.setPriority(1); + // 鍒ゆ柇瀹㈡埛绔槸鍚ifi鐜涓嬫帹閫併��1涓轰粎鍦╳ifi鐜涓嬫帹閫侊紝0涓轰笉闄愬埗缃戠粶鐜锛岄粯璁や笉闄� + message.setPushNetWorkType(0); + return message; + } + + private static APNPayload getAPNPayload() { + APNPayload payload = new APNPayload(); + //鍦ㄥ凡鏈夋暟瀛楀熀纭�涓婂姞1鏄剧ず锛岃缃负-1鏃讹紝鍦ㄥ凡鏈夋暟瀛椾笂鍑�1鏄剧ず锛岃缃负鏁板瓧鏃讹紝鏄剧ず鎸囧畾鏁板瓧 + payload.setAutoBadge("+1"); + payload.setContentAvailable(1); + //ios 12.0 浠ヤ笂鍙互浣跨敤 Dictionary 绫诲瀷鐨� sound + payload.setSound("default"); + payload.setCategory("$鐢卞鎴风瀹氫箟"); + payload.addCustomMsg("鐢卞鎴疯嚜瀹氫箟娑堟伅key", "鐢卞鎴疯嚜瀹氫箟娑堟伅value"); + + //绠�鍗曟ā寮廇PNPayload.SimpleMsg + payload.setAlertMsg(new APNPayload.SimpleAlertMsg("hello")); +// payload.setAlertMsg(getDictionaryAlertMsg()); //瀛楀吀妯″紡浣跨敤APNPayload.DictionaryAlertMsg + + //璁剧疆璇煶鎾姤绫诲瀷锛宨nt绫诲瀷锛�0.涓嶅彲鐢� 1.鎾斁body 2.鎾斁鑷畾涔夋枃鏈� + payload.setVoicePlayType(0); + + return payload; + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/GeTuiPushCall.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/GeTuiPushCall.java new file mode 100644 index 0000000..3441179 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/GeTuiPushCall.java @@ -0,0 +1,62 @@ +package com.nuvole.util; + +import cn.hutool.http.HttpUtil; +import com.nuvole.constants.ServiceConstants; +import lombok.extern.slf4j.Slf4j; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Description: + * @Company: TOO (ps锛氬叕鍙稿悕绉�) + * @author: 鍞� + * @date: 2020/5/16 涓嬪崍8:47 + * @version: V1.0.0 + */ +@Slf4j +public class GeTuiPushCall { + + /** + * 鍗曟帹锛堝崟涓猚lientId/鍒悕锛� + * + * @param title 鏍囬 + * @param content 鍐呭 + * @param type 绫诲瀷銆�1.璁惧id锛坈lientId锛� 2.鍒悕銆� + * @param val 绫诲瀷鍊硷紙clientId/鍒悕锛� + * @Author: lc + * @Date: 2020/4/26 13:31 + */ + public static String pushMessageToSingle(String title, String content, int type, String val) { + String url = ServiceConstants.SERVICE_GE_TUI_URL; + Map<String, Object> map = new HashMap<>(); + map.put("title", title); + map.put("content", content); + map.put("type", type); + map.put("val", val); + return HttpUtil.post(url, map); + } + + + /** + * 鎺ㄩ�佷竴涓垪琛� + * + * @param title 鏍囬 + * @param content 鍐呭 + * @parma type 绫诲瀷銆�1.璁惧id锛坈lientId锛� 2.鍒悕銆� + * @parma jsonArray 绫诲瀷鍊硷紙clientId/鍒悕锛� + * @Author: lc + * @Date: 2020/4/26 13:37 + */ + public static String pushMessageToList(String title, String content, int type, List<String> list) { + String url = ServiceConstants.SERVICE_GE_TUI_LIST_URL; + Map<String, Object> map = new HashMap<>(); + map.put("title", title); + map.put("content", content); + map.put("type", type); + map.put("list", list); + return HttpUtil.post(url, map); + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/HttpUtilExtra.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/HttpUtilExtra.java new file mode 100644 index 0000000..bba5674 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/HttpUtilExtra.java @@ -0,0 +1,49 @@ +package com.nuvole.util; + +import cn.hutool.core.io.IoUtil; +import com.alibaba.fastjson.JSON; +import jakarta.servlet.http.HttpServletRequest; +import org.apache.commons.text.StringEscapeUtils; + +import java.io.IOException; +import java.nio.charset.Charset; + +/** + * @ClassName HttpUtilExtra + * @Description http鎵╁睍宸ュ叿绫� + * @Author Chen Long + * @Date 2019/8/23 + * @Version 1.0 + */ +public class HttpUtilExtra { + + /** + * 鑾峰彇request body鍊� + * @param request + * @return + */ + public static String getRequestBody(HttpServletRequest request) { + try { + return IoUtil.read(request.getInputStream(), Charset.forName("UTF-8")); + } catch (IOException e) { + e.printStackTrace(); + } + return ""; + } + + /** + * request body 杞璞� + * @param request + * @param classz + * @return + */ + public static <T> T getObjByRequestBody(HttpServletRequest request, Class<T> classz) { + String body = StringEscapeUtils.unescapeHtml4(getRequestBody(request)); + return JSON.parseObject(body, classz); + } + + public static <T> T getObjByRequestBody(Class<T> classz) { + String body = StringEscapeUtils.unescapeHtml4(getRequestBody(CommonUtil.getRequest())); + return JSON.parseObject(body, classz); + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/IPUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/IPUtil.java new file mode 100644 index 0000000..a49b92a --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/IPUtil.java @@ -0,0 +1,80 @@ +package com.nuvole.util; + +import jakarta.servlet.http.HttpServletRequest; + +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.util.Enumeration; + +public class IPUtil { + + /* + * @Author : liu.q [916000612@qq.com] + * @Date : 2019-05-11 17:06 + * @Description :鑾峰彇鐢ㄦ埛鐪熷疄IP鍦板潃锛屼笉浣跨敤request.getRemoteAddr()鐨勫師鍥犳槸鏈夊彲鑳界敤鎴蜂娇鐢ㄤ簡浠g悊杞欢鏂瑰紡閬垮厤鐪熷疄IP鍦板潃,鍙槸锛屽鏋滈�氳繃浜嗗绾у弽鍚戜唬鐞嗙殑璇濓紝X-Forwarded-For鐨勫�煎苟涓嶆涓�涓紝鑰屾槸涓�涓睮P鍊� + */ + public static String getIpAddr(HttpServletRequest request) { + String ip = request.getHeader("x-forwarded-for"); + if (ip != null && ip.length() != 0 && !"unknown".equalsIgnoreCase(ip)) { + // 澶氭鍙嶅悜浠g悊鍚庝細鏈夊涓猧p鍊硷紝绗竴涓猧p鎵嶆槸鐪熷疄ip + if (ip.indexOf(",") != -1) { + ip = ip.split(",")[0]; + } + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("X-Real-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + return ip; + } + + + /** + * 鑾峰彇鏈湴IP鍦板潃锛堝眬鍩熺綉锛� + * + * @Author: lc + * @Date: 2019/11/8 11:59 + */ + public static String getLocalHostIp() { + try { + InetAddress candidateAddress = null; + // 閬嶅巻鎵�鏈夌殑缃戠粶鎺ュ彛 + for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces(); ifaces.hasMoreElements(); ) { + NetworkInterface iface = (NetworkInterface) ifaces.nextElement(); + // 鍦ㄦ墍鏈夌殑鎺ュ彛涓嬪啀閬嶅巻IP + for (Enumeration inetAddrs = iface.getInetAddresses(); inetAddrs.hasMoreElements(); ) { + InetAddress inetAddr = (InetAddress) inetAddrs.nextElement(); + if (!inetAddr.isLoopbackAddress()) {// 鎺掗櫎loopback绫诲瀷鍦板潃 + if (inetAddr.isSiteLocalAddress()) { + // 濡傛灉鏄痵ite-local鍦板潃 + return inetAddr.toString().replace("/", ""); + } else if (candidateAddress == null) { + //site-local绫诲瀷鐨勫湴鍧�鏈鍙戠幇锛屽厛璁板綍鍊欓�夊湴鍧� + candidateAddress = inetAddr; + } + } + } + } + if (candidateAddress != null) { + return candidateAddress.toString().replace("/", ""); + } + } catch (Exception e) { + e.printStackTrace(); + } + return ""; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/IdGenerator.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/IdGenerator.java new file mode 100644 index 0000000..12f6a64 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/IdGenerator.java @@ -0,0 +1,30 @@ +package com.nuvole.util; + +import cn.hutool.core.lang.Snowflake; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.RandomUtil; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName IdGenerator + * @Description id鐢熸垚鍣� + * @date 2019/4/18 11:33 + */ +public class IdGenerator { + + private static Snowflake snowflake; + + public static Long getId() { + return snowflake.nextId(); + } + + static { + snowflake = IdUtil.createSnowflake(RandomUtil.randomInt(0, 31), RandomUtil.randomInt(0, 31)); + } + + public static String getUUID() { + + return IdUtil.simpleUUID(); + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ImageUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ImageUtil.java new file mode 100644 index 0000000..51a8ea0 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ImageUtil.java @@ -0,0 +1,96 @@ +package com.nuvole.util; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; + +//// @formatter:off +//import javax.imageio.*;import javax.imageio.metadata.IIOMetadata;import javax.imageio.stream.ImageOutputStream;import java.awt.*;import java.awt.image.BufferedImage;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream; /** +// * .-~~~~~~~~~-._ _.-~~~~~~~~~-. +// * __.' @Author ~. .~ 浠g爜鏃燘ug `.__ +// * .'// liu.q \./ (绉樼睄) \\`. +// * .'// [916000612@qq.com] | 娆茬粌绁炲姛 寮曞垁鑷 \\`. +// * .'// .-~"""""""~~~~-._ | _,-~~~~"""""""~-. \\`. +// * .'//.-" 2019-04-24 `-. | .-' 12:53 "-.\\`. +// * .'//______.============-.. \ | / ..-============.______\\`. +// *.'______________________________\|/______________________________`. +// * +// * @Description : +// */ +//// @formatter:on +// +public class ImageUtil { + public static void main(String[] args) throws Exception { + byte[] imageBytes = getImageBytes("C:\\Users\\cy\\Pictures\\钀ヤ笟鎵х収\\111.jpg"); + System.out.println(imageBytes.length); + } + public static byte[] getImageBytes(String imagePath) throws Exception { + // 璇诲彇鍥剧墖鏂囦欢 + BufferedImage bufferedImage = ImageIO.read(new File(imagePath)); + + // 灏嗗浘鐗囧啓鍏ュ瓧鑺傛祦 + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ImageIO.write(bufferedImage, "jpg", baos); + + // 杩斿洖瀛楄妭鏁扮粍 + return baos.toByteArray(); + } +// +// /* +// * @Author : liu.q [916000612@qq.com] +// * @Date : 2019-04-24 12:55 +// * @param OldInputStream : 鍘熷浘 +// * @param w : 瀹� +// * @param h : 楂� +// * @param quality : 璐ㄩ噺 +// * @return : InputStream 鍘嬬缉鍚庣殑鍥� +// * @Description : +// */ +// public static InputStream ImgCompress(InputStream OldInputStream,String suffix,int w, int h, float quality) { +// try { +// /** 澶勭悊瀹介珮 */ +// BufferedImage bufferedImage = ImageIO.read(OldInputStream); +// int new_w = bufferedImage.getWidth(null); +// int new_h = bufferedImage.getHeight(null); +// if(new_w<=w || new_h<=h){//鍘熷浘瀹介珮灏忎簬瑕佸帇缂╃殑瀹介珮灏变笉鍘嬬缉浜嗐�� +// return OldInputStream; +// } +// double bili; +// if(w<=0 || h<=0){ +// if(w>0){ +// bili=(double)w/new_w; +// new_h = (int) (new_h*bili); +// new_w=w; +// }else{ +// if(h>0){ +// bili=(double)h/new_h; +// new_w = (int) (new_w*bili); +// new_h=h; +// } +// } +// }else{ +// new_w=w; +// new_h=h; +// } +// +// BufferedImage image_to_save = new BufferedImage(new_w, new_h,bufferedImage.getType()); +// image_to_save.getGraphics().drawImage(bufferedImage.getScaledInstance(new_w, new_h, Image.SCALE_SMOOTH), 0,0, null); +// ImageWriter imageWriter = ImageIO.getImageWritersBySuffix(suffix).next(); +// IIOMetadata imageMetaData = imageWriter.getDefaultImageMetadata(new ImageTypeSpecifier(image_to_save), null); +// //璐ㄩ噺鍘嬬缉 +// if (quality >= 0 && quality <= 1f) { +// ImageWriteParam jpegParams = imageWriter.getDefaultWriteParam(); +// jpegParams.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); +// jpegParams.setCompressionQuality(quality); +// } +// //鍐欏叆鍥剧墖 +// imageWriter.write(imageMetaData,new IIOImage(image_to_save, null, null), null); +// imageWriter.dispose(); +// +// return imageWriter; +// } catch (IOException ex) { +// ex.printStackTrace(); +// } +// } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/JGPushCallUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/JGPushCallUtil.java new file mode 100644 index 0000000..bf70a57 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/JGPushCallUtil.java @@ -0,0 +1,31 @@ +package com.nuvole.util; + +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; +import com.nuvole.constants.ServiceConstants; +import lombok.extern.slf4j.Slf4j; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Description: + * @Company: TOO (ps锛氬叕鍙稿悕绉�) + * @author: 鍞� + * @date: 2019/12/2 涓嬪崍3:47 + * @version: V1.0.0 + */ +@Slf4j +public class JGPushCallUtil { + + public static String push(String content,String title,String userid,String businessid,String businesstype) { + String path = ServiceConstants.SERVICE_JG_PUSH_URL; + Map<String,Object> param = new HashMap<>(5); + param.put("content",content); + param.put("title",title); + param.put("userid",userid); + param.put("businessid",businessid); + param.put("businesstype",businesstype); + return HttpUtil.post(path,param); + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/JGPushUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/JGPushUtil.java new file mode 100644 index 0000000..6551b0c --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/JGPushUtil.java @@ -0,0 +1,84 @@ +package com.nuvole.util; + +import cn.hutool.core.convert.Convert; +import cn.jiguang.common.ClientConfig; +import cn.jiguang.common.resp.APIConnectionException; +import cn.jiguang.common.resp.APIRequestException; +import cn.jpush.api.JPushClient; +import cn.jpush.api.push.PushResult; +import cn.jpush.api.push.model.Platform; +import cn.jpush.api.push.model.PushPayload; +import cn.jpush.api.push.model.audience.Audience; +import cn.jpush.api.push.model.notification.AndroidNotification; +import cn.jpush.api.push.model.notification.IosNotification; +import cn.jpush.api.push.model.notification.Notification; + +import java.util.HashMap; +import java.util.Map; + +/** + * Createed by PKZ + * Date 2019/5/28 14:46 + * Description:鏋佸厜鎺ㄩ�� + */ +public class JGPushUtil { + private static String MASTER_SECRET="142cc44b9a7031b1b461530a"; + private static String APP_KEY="382144e6869af95cb99ba6f3"; +/* + private static String MASTER_SECRET="7d926843009a59d013100ad9"; + private static String APP_KEY="050c7ed3f0218d5c96a9c73c"; +*/ + //鏋佸厜鎺ㄩ�� + private static PushPayload buildPushObject_ios_audienceMore_messageWithExtras(String content,String title,String userid,String businessid,String businesstype) { + Map m=new HashMap(); + m.put("id",businessid); + m.put("type",businesstype); + return PushPayload.newBuilder() + .setPlatform(Platform.all())//鎺ㄩ�佹墍鏈夊钩鍙� + .setAudience(Audience.alias(userid))//鍒悕鎺ㄩ�� + //.setAudience(Audience.all())//鍏ㄩ儴鎺ㄩ�� + /* .setMessage(Message.newBuilder()//鍙戦�侀�忎紶娑堟伅 + .setMsgContent(content) + .setTitle(title) + .addExtra("from", "JPush") + .addExtra("businessid",businessid) + .addExtra("businesstype",businesstype) + .build())*/ + .setNotification( + Notification.newBuilder() + .addPlatformNotification(AndroidNotification.newBuilder().setAlert(content).setTitle(title).addExtras(m).build()) + .addPlatformNotification(IosNotification.newBuilder().setAlert(content).addExtras(m).build()) + .build() + )//鍙戦�侀�氱煡 + .build(); + } + /** + * Createed by PKZ + * Date 2019/5/28 15:01 + * Description锛氭瀬鍏夋帹閫� + * @param content 鎺ㄩ�佸唴瀹� + * @param title 鏍囬 + * @param userid 鎺ㄩ�佸埆鍚� + * @param businessid 涓氬姟id + * @param businesstype 涓氬姟绫诲瀷锛�1锛氭壂鐮佹敮浠樿鍗曪級 + **/ + public static String push(String content,String title,String userid,String businessid,String businesstype){ + PushPayload payload=buildPushObject_ios_audienceMore_messageWithExtras(content,title,userid,businessid,businesstype); + JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, ClientConfig.getInstance()); + PushResult result=new PushResult(); + try { + result= jpushClient.sendPush(payload); + } catch (APIConnectionException e) { + e.printStackTrace(); + } catch (APIRequestException e) { + e.printStackTrace(); + } + return Convert.toStr(result.statusCode); + } + + public static void main(String[] args) { + + push("鏀粯瀹濇敹娆炬垚鍔�2鍏�","鏀粯瀹濇敹娆炬垚鍔�2鍏�","1255396878833553408","1139417207521021952","1" + ); + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/JWTUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/JWTUtil.java new file mode 100644 index 0000000..9724866 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/JWTUtil.java @@ -0,0 +1,187 @@ +package com.nuvole.util; + +import cn.hutool.core.convert.Convert; +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; + +import java.util.Date; +import java.util.Map; + +/** + * @ClassName JWTUtil + * @Description JWT宸ュ叿绫� + * @Author Chen Long + * @Date 2019/8/20 + * @Version 1.0 + */ +public class JWTUtil { + + /** + * PC绫诲瀷JWT + */ + public static final String JWT_TYPE_PC = "PC"; + + /** + * 瀹㈡埛缁忕悊绫诲瀷jwt + */ + public static final String JWT_TYPE_MANAGER_WX_MINI = "MANAGER_WX_MINI"; + /** + * APP绫诲瀷JWT + */ + public static final String JWT_TYPE_APP = "APP"; + + /** + * SCANPAY JWT + */ + public static final String JWT_TYPE_SCANPAY = "SCANPAY"; + + /** + * PC绫诲瀷JWT瓒呮椂鏃堕暱 + */ + public static final long JWT_TYPE_PC_EXPIRE = 2 * 60 * 60 * 1000; + + /** + * 瀹㈡埛缁忕悊灏忕▼搴忕被鍨婮WT瓒呮椂鏃堕暱 + */ + public static final long JWT_TYPE_MANAGER_WX_MINI_EXPIRE = 7 * 24 * 60 * 60 * 1000; + + + /** + * APP绫诲瀷JWT瓒呮椂鏃堕暱 + */ + public static final long JWT_TYPE_APP_EXPIRE = 2 * 60 * 60 * 1000; + + /** + * SCANPAY JWT瓒呮椂鏃堕暱 + */ + public static final long JWT_TYPE_SCANPAY_EXPIRE = 2 * 60 * 60 * 1000; + + /** + * 鑷畾涔夊墠缂� + */ + private static final String JWT_SIGN_PREFIX = "o6t48fVSqCUCu"; + /** + * 鍔犲瘑瀵嗛挜 + */ + private static final String JWT_SECRET = "sHyPanQN8wAt3sKBix9Fla7iGvwWs4hfE4YhluMYvbtBdX6sOiEeGU4lHhVgdrsO"; + + + /** + * 鍒涘缓 JWT + * + * @param jwtType + * @param claims + * @return + * @Description jwt鑽疯浇 + * iss: jwt绛惧彂鑰� + * sub: jwt鎵�闈㈠悜鐨勭敤鎴� + * aud: 鎺ユ敹jwt鐨勪竴鏂� + * exp: jwt鐨勮繃鏈熸椂闂达紝杩欎釜杩囨湡鏃堕棿蹇呴』瑕佸ぇ浜庣鍙戞椂闂� + * nbf: 瀹氫箟鍦ㄤ粈涔堟椂闂翠箣鍓嶏紝璇wt閮芥槸涓嶅彲鐢ㄧ殑. + * iat: jwt鐨勭鍙戞椂闂� + * jti: jwt鐨勫敮涓�韬唤鏍囪瘑锛屼富瑕佺敤鏉ヤ綔涓轰竴娆℃�oken,浠庤�屽洖閬块噸鏀炬敾鍑汇�� + */ + public static String generateJwt(String jwtType, Map<String, Object> claims) { + + //绛惧彂鏃堕棿 + long nowMillis = System.currentTimeMillis(); + //瓒呮椂鏃堕棿 + long expMillis = 0; + if (jwtType.equalsIgnoreCase(JWT_TYPE_PC)) { + expMillis = nowMillis + JWT_TYPE_PC_EXPIRE; + } else if (jwtType.equalsIgnoreCase(JWT_TYPE_APP)) { + expMillis = nowMillis + JWT_TYPE_APP_EXPIRE; + } else if (jwtType.equalsIgnoreCase(JWT_TYPE_SCANPAY)) { + expMillis = nowMillis + JWT_TYPE_SCANPAY_EXPIRE; + } else if (jwtType.equalsIgnoreCase(JWT_TYPE_MANAGER_WX_MINI)) { + expMillis = nowMillis + JWT_TYPE_MANAGER_WX_MINI_EXPIRE; + } + + for (Map.Entry<String, Object> entry : claims.entrySet()) { + entry.setValue(AESUtil.encode( + Convert.toStr( + entry.getValue()))); + + } + + String compactJws = Jwts.builder() + .setClaims(claims) + .setIssuedAt(new Date(nowMillis)) + .setExpiration(new Date(expMillis)) + .signWith(SignatureAlgorithm.HS512, JWT_SECRET) + .compact(); + + return JWT_SIGN_PREFIX + compactJws; + } + + /** + * 鏍¢獙jwt鏄惁鍚堟硶 + * + * @param jwt + * @return + */ + public static boolean checkJWT(String jwt) { + try { + getClaims(jwt); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 鑾峰彇claims + * + * @param jwt + * @return + */ + public static Claims getClaims(String jwt) { + jwt = jwt.substring(JWT_SIGN_PREFIX.length()); + Claims claims; + claims = Jwts.parser() + .setSigningKey(JWT_SECRET) + .parseClaimsJws(jwt) + .getBody(); + return claims; + } + + /** + * 鑾峰彇claims sub + * + * @param jwt + * @return + */ + public static String getSubOfClaims(String jwt) { + return getValOfClaims(jwt, "sub"); + } + + /** + * 鑾峰彇claims roles + * + * @param jwt + * @return + */ + public static String getRolesOfClaims(String jwt) { + return getValOfClaims(jwt, "roles"); + } + + /** + * @param jwt + * @param key + * @Method getValOfClaims + * @Description 鏍规嵁key鑾峰彇claims鍊� + * @Return java.lang.String + * @Author Chen Long + * @Date 2019/8/27 + * @Version 1.0 + */ + public static String getValOfClaims(String jwt, String key) { + return AESUtil.decode( + Convert.toStr( + getClaims(jwt).get(key))); + } + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/LaBaPushUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/LaBaPushUtil.java new file mode 100644 index 0000000..eb6fef1 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/LaBaPushUtil.java @@ -0,0 +1,104 @@ +package com.nuvole.util; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSONObject; +import com.nuvole.hnnx.hnnxPay.NXHttpClientUtils; +import com.nuvole.hnnx.hnnxPay.SignatureSigner; +import com.nuvole.util.enums.LaPushEnum; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @ClassName LaBaPushUtil + * @Author cy + * @Date 2023/12/7 + * @Description + * @Version 1.0 + **/ +@Slf4j +public class LaBaPushUtil { + private static final String DEVICE_ID = "202312080001"; + + private static String ACCESSKEYSECRET = "AtR4g5sa24fdy6GII3hts75_CSYH"; + private static String accessKeyId = "IOT_ACCOUNT_TEST_CSYH"; + + private static SignatureSigner signable = new SignatureSigner(); + //鐢熶骇鐜 + private static String scUrl = "https://voice.tysmartpos.com/api/bank/pushmsg"; + //娴嬭瘯鐜 + private static String csUrl = "https://voicetest.tysmartpos.com/api/bank/pushmsg"; + +// public static void main(String[] args) { +// String deviceId = "202312080001"; +//// String 010859416327 = "202312080001"; +//// push(deviceId, LaPushEnum.YINHANG, 111); +// pushMessageToSingle(deviceId, LaPushEnum.ZFB, 222); +////// push(deviceId, LaPushEnum.WX, 333); +// pushMessageToSingle(deviceId, LaPushEnum.CANCLE, 444); +// } + + public static void pushMessageToSingle(String deviceId, LaPushEnum pushType, long money) { + if (StringUtils.isEmpty(deviceId)){ + return; + } + Map<String, String> parameters = new HashMap<>(); + parameters.put("accessKeyId", accessKeyId); + parameters.put("requestId", String.valueOf(System.currentTimeMillis())); + //璇锋眰鏃堕棿鎴筹紝鏍煎紡濡傦細1593532800000 + parameters.put("timestamp", String.valueOf(System.currentTimeMillis())); + //璁惧缂栧彿 + parameters.put("deviceId", deviceId); + + String moneyYuan = NXHttpClientUtils.convertToYuan(money).toString(); + parameters.put("content", pushType.getName() + moneyYuan + "鍏�"); + String signStr = signable.laBaSign(parameters, ACCESSKEYSECRET); + parameters.put("sign", signStr); + String jsonBody = JSONObject.toJSONString(parameters); + + String result = null; + log.info("澶╁柣浜戦煶鍝嶈姹傚弬鏁帮細{}", jsonBody); + HttpResponse response = HttpRequest.post(csUrl) + .contentType("application/json") + .body(jsonBody) + .execute(); + // 鑾峰彇鍝嶅簲缁撴灉 + result = response.body(); + log.info("澶╁柣浜戦煶鍝嶆帹閫佽繑鍥炲�硷細{}", result); + return; + } + + public static void pushMessageToList(LaPushEnum pushType, long money, List<String> deviceIdList) { + Map<String, String> parameters = new HashMap<>(); + parameters.put("accessKeyId", accessKeyId); + parameters.put("requestId", String.valueOf(System.currentTimeMillis())); + //璇锋眰鏃堕棿鎴筹紝鏍煎紡濡傦細1593532800000 + parameters.put("timestamp", String.valueOf(System.currentTimeMillis())); + String moneyYuan = NXHttpClientUtils.convertToYuan(money).toString(); + parameters.put("content", pushType.getName() + moneyYuan + "鍏�"); + + deviceIdList.forEach(deviceId -> { + //璁惧缂栧彿 + parameters.put("deviceId", deviceId); + String signStr = signable.laBaSign(parameters, ACCESSKEYSECRET); + parameters.put("sign", signStr); + String jsonBody = JSONObject.toJSONString(parameters); + + String result = null; + log.info("澶╁煙鍠囧彮鎺ㄩ�佽姹傚弬鏁帮細{}", jsonBody); + HttpResponse response = HttpRequest.post(csUrl) + .contentType("application/json") + .body(jsonBody) + .execute(); + // 鑾峰彇鍝嶅簲缁撴灉 + result = response.body(); + log.info("澶╁煙鍠囧彮鎺ㄩ�佽繑鍥炲�硷細{}", result); + }); + return; + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/OSSUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/OSSUtil.java new file mode 100644 index 0000000..7284c83 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/OSSUtil.java @@ -0,0 +1,252 @@ +package com.nuvole.util; + +import cn.hutool.core.io.FileUtil; +import com.amazonaws.auth.AWSCredentialsProvider; +import com.amazonaws.auth.AWSStaticCredentialsProvider; +import com.amazonaws.auth.BasicAWSCredentials; +import com.amazonaws.client.builder.AwsClientBuilder; +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.AmazonS3ClientBuilder; +import com.amazonaws.services.s3.model.*; +import org.apache.commons.lang.StringUtils; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.ResourceLoader; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.*; +import java.net.URL; +import java.time.Instant; +import java.util.Date; +import java.util.Properties; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName SFtpUtil + * @date 2019/7/24 20:53 + */ +public class OSSUtil { + + private static String bucketName = null; + private static String endpoint = null; + private static String endpointNet = null; + private static String region = null; + private static String accessKey = null; + private static String secretKey = null; + + private static AmazonS3 amazonS3NetClient = null; + + public static Properties getYdOssProp() { + Properties props = new Properties(); + InputStream in = null; + try { + ResourceLoader resourceLoader = new DefaultResourceLoader(); + in = resourceLoader.getResource("ydOss.properties").getInputStream(); + props.load(in); + return props; + } catch (IOException e) { + e.printStackTrace(); + return props; + } finally { + ResourceUtil.safeClose(in); + } + } +// private static AmazonS3 client = null; + + public static AmazonS3 ossInit() { + Properties props = getYdOssProp(); + bucketName = props.getProperty("ydOss.bucketName"); + endpoint = props.getProperty("ydOss.endpoint"); + region = props.getProperty("ydOss.region"); + accessKey = props.getProperty("ydOss.accessKey"); + secretKey = props.getProperty("ydOss.secretKey"); + // 鍒涘缓 AmazonS3 瀹炰緥銆� + AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration(endpoint, region); + BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); + AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials); + AmazonS3 client = AmazonS3ClientBuilder.standard() + .withEndpointConfiguration(endpointConfiguration) + .withCredentials(credentialsProvider).build(); + return client; + } + + /** + * 鑾峰彇澶栫綉oss鍦板潃 + * + * @return + */ + public static AmazonS3 ossNetInit() { + if (amazonS3NetClient != null) { + return amazonS3NetClient; + } + Properties props = getYdOssProp(); + bucketName = props.getProperty("ydOss.bucketName"); + endpointNet = props.getProperty("ydOss.endpointNet"); + region = props.getProperty("ydOss.region"); + accessKey = props.getProperty("ydOss.accessKey"); + secretKey = props.getProperty("ydOss.secretKey"); + // 鍒涘缓 AmazonS3 瀹炰緥銆� + AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration(endpointNet, region); + BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); + AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials); + amazonS3NetClient = AmazonS3ClientBuilder.standard() + .withEndpointConfiguration(endpointConfiguration) + .withCredentials(credentialsProvider).build(); + return amazonS3NetClient; + } + + // 涓婁紶鏂囦欢銆� + public static void upload(AmazonS3 client, String fileName, InputStream inputStream, String targetPath) { + if (targetPath.startsWith("/")) { + targetPath = targetPath.substring(1); + } + String objectName = targetPath + "/" + fileName; + objectName = objectName.replace("//", "/"); + mkdirFolder(client, targetPath); + + ObjectMetadata objectMetadata = new ObjectMetadata(); + try { + // 璁剧疆瀵硅薄锛圤bject锛夊ぇ灏忋�� + objectMetadata.setContentLength(inputStream.available()); + // 璁剧疆涓婁紶鍐呭绫诲瀷銆� +// objectMetadata.setContentType("text/plain"); + } catch (IOException e) { + e.printStackTrace(); + } + + // 涓婁紶鍚屾椂璁剧疆璁块棶鏉冮檺锛屼緥濡�'Private'绉佹湁鏉冮檺銆� + PutObjectRequest request = new PutObjectRequest(bucketName, objectName, inputStream, objectMetadata); + request.setCannedAcl(CannedAccessControlList.Private); + PutObjectResult putObjectResult = client.putObject(request); +// PutObjectResult putObjectResult = client.putObject(bucketName, objectName, inputStream, null); + if (putObjectResult == null) { + return; + } + try { +// return getShareUrl(objectName); + return; + } catch (Exception e) { + e.printStackTrace(); + } + return; + } + + + public static void upload(AmazonS3 client, String sourceFilePath, String targetFilePath, boolean isDelSourceFile) { + String targetPath = targetFilePath.substring(0, targetFilePath.lastIndexOf("/")); + System.out.println("涓婁紶 鏈湴璺緞" + sourceFilePath+" 涓婁紶鍒� " + targetFilePath); + File file = new File(sourceFilePath); + FileInputStream fileInputStream = null; + try { + fileInputStream = new FileInputStream(file); + } catch (FileNotFoundException e) { + e.printStackTrace(); + return; + } + upload(client, file.getName(), fileInputStream, targetPath); + + if (isDelSourceFile) { + FileUtil.del(sourceFilePath); + } + return; + } + + public static void upload(AmazonS3 client, String FileName, BufferedImage bufferedImage, String targetPath) + throws IOException { + if (FileName.lastIndexOf(".") <= -1) { + return; + } + String ext = FileName.substring(FileName.lastIndexOf(".") + 1); + String sourceFilePath = System.getProperty("user.dir") + ResourceUtil.createFileName(ext); + File tmpFile = FileUtil.touch(sourceFilePath); + ImageIO.write(bufferedImage, "png", tmpFile); + System.out.println("targetPath" + targetPath); + upload(client, sourceFilePath, targetPath + FileName, true); + } + + public static void download(AmazonS3 client, String sourceFilePath, String targetFilePath) { + if (StringUtils.isEmpty(sourceFilePath)){ + return; + } + if (sourceFilePath.startsWith("/")){ + sourceFilePath = sourceFilePath.substring(1); + } + // 灏嗘枃浠讹紙Object锛変笅杞藉埌鏂囦欢涓紝骞惰繑鍥炴枃浠讹紙Object锛夌殑鍏冩暟鎹�� + GetObjectRequest request = new GetObjectRequest(bucketName, sourceFilePath); + ObjectMetadata meta = client.getObject(request, FileUtil.touch(targetFilePath)); + } + + /** + * 鍒涘缓鏂囦欢澶� + * + * @return + */ + private static boolean mkdirFolder(AmazonS3 client, String directory) { + String folder = String.copyValueOf(directory.toCharArray()); + if (directory.startsWith("/")) { + folder = folder.substring(1); + } + if (!folder.endsWith("/")) { + folder = folder + "/"; + } + PutObjectResult putObjectResult = client.putObject(bucketName, folder, new ByteArrayInputStream(new byte[0]), null); + return putObjectResult != null; + } + + /** + * 鑾峰彇瀵硅薄鐨勫垎浜摼鎺� + * + * @param objectName + * @return + */ + public static String getShareUrl(String objectName) { + ossNetInit(); + // 鐢熸垚鍙瑙堢殑澶栭摼銆� + GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucketName, objectName); + + // 璁剧疆杩囨湡鏃堕棿锛屽綋鍒拌揪璇ユ椂闂寸偣鏃讹紝URL 灏变細杩囨湡锛屽叾浠栦汉涓嶅啀鑳借闂瀵硅薄锛圤bject锛夈�� + Date expiration = new Date(); + // 璁剧疆 30 鍒嗛挓鍚庤繃鏈熴�� + long expTimeMillis = Instant.now().toEpochMilli(); + expTimeMillis += 1000 * 60 * 10; + expiration.setTime(expTimeMillis); + + request.setExpiration(expiration); + + // 璁剧疆杩斿洖澶� + // 璁剧疆涓� "inline" 鏃跺湪娴忚鍣ㄤ腑灞曠ず锛岃缃负 "attachment" 鏃朵互鏂囦欢褰㈠紡涓嬭浇銆� + // 姝ゅ璁剧疆涓� "attachment;filename=\"filename.jpg\"" 锛岃繕鍙互璁╀笅杞界殑鏂囦欢鍚嶅瓧閲嶅懡鍚嶄负 "filename.jpg"銆� + ResponseHeaderOverrides headerOverrides = new ResponseHeaderOverrides(); + headerOverrides.setContentDisposition("inline"); + request.setResponseHeaders(headerOverrides); + + URL url = amazonS3NetClient.generatePresignedUrl(request); + return url.toString(); + } + + public static void close(AmazonS3 client) { + if (client != null) { + client.shutdown(); + } + } + + public static void main(String[] args) { + // 鍒涘缓 AmazonS3 瀹炰緥銆� + endpoint = "https://eos-beijing-7.cmecloud.cn"; + region = "beijing7"; + accessKey = "EDVFWAO1INQKHGJ78MK0"; + secretKey = "rQSMQ02h6oQPMaZyXR85XxLVhZh92jrwXFRkX6FX"; + bucketName = "ecosphere"; + AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration(endpoint, region); + BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); + AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials); + AmazonS3 amazonS3 = AmazonS3ClientBuilder.standard() + .withEndpointConfiguration(endpointConfiguration) + .withCredentials(credentialsProvider).build(); + OSSUtil.download(amazonS3, "/ecosphereBase/2024/1/3/5894af65566a44a791baa4246bd5910a.csv", "C:\\Users\\cy\\Desktop\\鏂板缓鏂囦欢澶筡\b.csv"); + OSSUtil.close(amazonS3); + } + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/PageUtils.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/PageUtils.java new file mode 100644 index 0000000..b417030 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/PageUtils.java @@ -0,0 +1,41 @@ +package com.nuvole.util; + +/** + * @Description: + * @Company: TOO (ps锛氬叕鍙稿悕绉�) + * @author: 鍞� + * @date: 2020/2/18 涓嬪崍12:49 + * @version: V1.0.0 + */ +public class PageUtils { + + public static String orderParser(String sortName, String sortOrder, String... prefix) { + + // Determine sortOrder equals 'asc' or 'desc' + if (!(sortOrder.equals("asc") || sortOrder.equals("desc"))) { + throw new IllegalArgumentException("Illegal sortOrder parameter"); + } + + // 鍒ゆ柇鍒楀悕绉扮殑鍚堟硶鎬э紝闃叉SQL娉ㄥ叆銆傚彧鑳芥槸銆愬瓧姣嶏紝鏁板瓧锛屼笅鍒掔嚎銆� + if (!sortName.matches("[A-Za-z0-9_]+")) { + throw new IllegalArgumentException("Illegal sortName parameter"); + } + + StringBuilder sb = new StringBuilder(); + // 瀛樺湪鍓嶇紑 + if (prefix.length != 0) { + sb.append(prefix[0] + "."); + } + + sb.append(CommonUtil.camel2Underline("`" + sortName + "`") + " " + sortOrder); + + return sb.toString(); + } + + public static void main(String[] args) { +// System.out.println(orderParser("createTime", "asc")); +// System.out.println(orderParser("createTime", "asc", "abc")); +// System.out.println(orderParser("createTime,if((1=1),sleep(1),sleep(0))", "asc", "abc")); + System.out.println(orderParser("createTime", "asc,if((1=1),sleep(1),sleep(0))", "abc")); + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/PayUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/PayUtil.java new file mode 100644 index 0000000..9bab008 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/PayUtil.java @@ -0,0 +1,149 @@ +package com.nuvole.util; + +import cn.hutool.crypto.SecureUtil; +import jakarta.servlet.http.HttpServletRequest; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName PayUtil + * @date 2019/7/30 21:51 + */ +public class PayUtil { + + public static Map getSignMap(Object f, String appKey) { + TreeMap<String, String> map = new TreeMap<String,String>(); + Field[] fields = f.getClass().getDeclaredFields(); + for (int i = 0, len = fields.length; i < len; i++) { + String varName = fields[i].getName(); + try { + boolean accessFlag = fields[i].isAccessible(); + //fields[i].setAccessible(true); + Object o = fields[i].get(f); + if (!"0".equals(String.valueOf(o)) && !"null".equals(String.valueOf(o)) && !String.valueOf(o).isEmpty()) { + map.put(varName, String.valueOf(o)); + } + System.out.println("浼犲叆鐨勫璞′腑鍖呭惈涓�涓涓嬬殑鍙橀噺锛�" + varName + " = " + o); + //fields[i].setAccessible(accessFlag); + } catch (IllegalArgumentException ex) { + ex.printStackTrace(); + } catch (IllegalAccessException ex) { + ex.printStackTrace(); + } + } + map.remove("serialVersionUID"); + if (map.containsKey("validtime") && map.get("validtime").equals("null")) { + map.remove("validtime"); + } + map.put("sign", sign(map, appKey)); + return map; + } + + public static String sign(TreeMap<String, String> params, String appkey) { + if (params.containsKey("sign"))// 绛惧悕鏄庢枃缁勮涓嶅寘鍚玸ign瀛楁 + params.remove("sign"); + params.put("key", appkey); + StringBuilder sb = new StringBuilder(512); + for (Map.Entry<String, String> entry : params.entrySet()) { + if (entry.getValue() != null && entry.getValue().length() > 0) { + sb.append(entry.getKey()).append("=").append(entry.getValue()).append("&"); + } + } + if (sb.length() > 0) { + sb.deleteCharAt(sb.length() - 1); + } + String sign = SecureUtil.md5(sb.toString()); + params.remove("key"); + return sign; + } + public static Map<String,String> notify(HttpServletRequest request){ + InputStream inStream = null; + ByteArrayOutputStream outSteam=null; + Map<String, String> params =null; + try { + inStream = request.getInputStream(); + outSteam = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int len = 0; + while ((len = inStream.read(buffer)) != -1) { + outSteam.write(buffer, 0, len); + } + String resultxml = new String(outSteam.toByteArray(), "utf-8"); + params = xmlStrToMap(resultxml); + } catch (IOException e) { + e.printStackTrace(); + }finally { + try { + outSteam.close(); + inStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return params; + } + public static String getNotifyParam(HttpServletRequest request) { + InputStream inStream = null; + ByteArrayOutputStream outSteam = null; + String resultStr = null; + try { + inStream = request.getInputStream(); + outSteam = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int len = 0; + while ((len = inStream.read(buffer)) != -1) { + outSteam.write(buffer, 0, len); + } + resultStr = new String(outSteam.toByteArray(), "utf-8"); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + outSteam.close(); + inStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return resultStr; + } + + /** + * Xml瀛楃涓茶浆鎹负Map + * + * @param xmlStr + * @return + */ + public static Map<String, String> xmlStrToMap(String xmlStr) { + Map<String, String> map = new HashMap<String, String>(); + Document doc; + try { + doc = DocumentHelper.parseText(xmlStr); + Element root = doc.getRootElement(); + List children = root.elements(); + if (children != null && children.size() > 0) { + for (int i = 0; i < children.size(); i++) { + Element child = (Element) children.get(i); + map.put(child.getName(), child.getTextTrim()); + } + } + } catch (DocumentException e) { + e.printStackTrace(); + } + return map; + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/Pinyin.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/Pinyin.java new file mode 100644 index 0000000..53e25b3 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/Pinyin.java @@ -0,0 +1,80 @@ +package com.nuvole.util; + +// @formatter:off +import net.sourceforge.pinyin4j.PinyinHelper;import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; /** + * .-~~~~~~~~~-._ _.-~~~~~~~~~-. + * __.' @Author ~. .~ 浠g爜鏃燘ug `.__ + * .'// liu.q \./ (绉樼睄) \\`. + * .'// [916000612@qq.com] | 娆茬粌绁炲姛 寮曞垁鑷 \\`. + * .'// .-~"""""""~~~~-._ | _,-~~~~"""""""~-. \\`. + * .'//.-" 2019-04-10 `-. | .-' 17:35 "-.\\`. + * .'//______.============-.. \ | / ..-============.______\\`. + *.'______________________________\|/______________________________`. + * + * @Description : + */ +// @formatter:on + +public class Pinyin { + /** + * 娴嬭瘯main鏂规硶 + * + * @param args + */ + public static void main(String[] args) { + System.out.println(ToFirstChar("姹夊瓧杞崲涓烘嫾闊�").toUpperCase()); //杞负棣栧瓧姣嶅ぇ鍐� + System.out.println(ToPinyin("姹夊瓧杞崲涓烘嫾闊�")); + } + + /** + * 鑾峰彇瀛楃涓叉嫾闊崇殑绗竴涓瓧姣� + * + * @param chinese + * @return + */ + public static String ToFirstChar(String chinese) { + String pinyinStr = ""; + char[] newChar = chinese.toCharArray(); //杞负鍗曚釜瀛楃 + HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat(); + defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); + defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); + for (int i = 0; i < newChar.length; i++) { + if (newChar[i] > 128) { + try { + pinyinStr += PinyinHelper.toHanyuPinyinStringArray(newChar[i], defaultFormat)[0].charAt(0); + } catch (BadHanyuPinyinOutputFormatCombination e) { + e.printStackTrace(); + } + } else { + pinyinStr += newChar[i]; + } + } + return pinyinStr; + } + + /** + * 姹夊瓧杞负鎷奸煶 + * + * @param chinese + * @return + */ + public static String ToPinyin(String chinese) { + String pinyinStr = ""; + char[] newChar = chinese.toCharArray(); + HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat(); + defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); + defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); + for (int i = 0; i < newChar.length; i++) { + if (newChar[i] > 128) { + try { + pinyinStr += PinyinHelper.toHanyuPinyinStringArray(newChar[i], defaultFormat)[0]; + } catch (BadHanyuPinyinOutputFormatCombination e) { + e.printStackTrace(); + } + } else { + pinyinStr += newChar[i]; + } + } + return pinyinStr; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/PropertyUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/PropertyUtil.java new file mode 100644 index 0000000..03f9edb --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/PropertyUtil.java @@ -0,0 +1,35 @@ +package com.nuvole.util; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.ResourceLoader; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +/** + * 璇诲彇閰嶇疆鏂囦欢 + * + * @Author: lc + * @Date: 2019/6/13 15:31 + */ +@Slf4j +public class PropertyUtil { + + public static String getProp(String fileName, String k) { + Properties props = new Properties(); + InputStream in = null; + try { + ResourceLoader resourceLoader = new DefaultResourceLoader(); + in = resourceLoader.getResource(fileName).getInputStream(); + props.load(in); + return props.getProperty(k); + } catch (IOException e) { + e.printStackTrace(); + return ""; + } finally { + ResourceUtil.safeClose(in); + } + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ResourceUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ResourceUtil.java new file mode 100644 index 0000000..608fc44 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ResourceUtil.java @@ -0,0 +1,164 @@ +package com.nuvole.util; + +import cn.hutool.core.convert.Convert; + +import java.io.Closeable; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Calendar; +import java.util.HashMap; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName FileUtil + * @date 2019/4/15 13:06 + */ +public class ResourceUtil { + + public static void safeClose(Closeable closeable) { + if (closeable != null) { + try { + closeable.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + // 鐢熸垚ftp 鏂囦欢涓婁紶璺緞 + public static String createFilePath() { + Calendar ca = Calendar.getInstance(); + String year = Convert.toStr(ca.get(Calendar.YEAR)); + String mon = Convert.toStr(ca.get(Calendar.MONTH) + 1); + String day = Convert.toStr(ca.get(Calendar.DAY_OF_MONTH)); + return "/" + year + "/" + mon + "/" + day + "/"; + } + + /** + * 鐢熸垚鏂囦欢鍚� + * @author ChenLong + * @date 2019/4/26 11:22 + * @version 1.0 + * @param ext 鏂囦欢鎵╁睍鍚� 锛坉oc,xls绛夛級 + * @return : java.lang.String + */ + public static String createFileName(String ext) { + Calendar ca = Calendar.getInstance(); + String year = Convert.toStr(ca.get(Calendar.YEAR)); + String mon = Convert.toStr(ca.get(Calendar.MONTH) + 1); + String day = Convert.toStr(ca.get(Calendar.DAY_OF_MONTH)); + return "/" + year + "/" + mon + "/" + day + "/" + IdGenerator.getUUID() + "." + ext; + } + + /** + * 鐢熸垚鏂囦欢澶� + * @author ChenLong + * @date 2019/4/26 11:22 + * @version 1.0 + * @return : java.lang.String + */ + public static String createFileFolder() { + Calendar ca = Calendar.getInstance(); + String year = Convert.toStr(ca.get(Calendar.YEAR)); + String mon = Convert.toStr(ca.get(Calendar.MONTH) + 1); + String day = Convert.toStr(ca.get(Calendar.DAY_OF_MONTH)); + return "/" + year + "/" + mon + "/" + day + "/"; + } + + + // @formatter:off + /** 鐚尓淇濅綉 姘告棤bug + * _._ _..._ .-', _.._(`)) + * '-. ` ' /-._.-' ',/ + * ) \ '. + * / _ _ | \ + * | a a / | + * \ .-. ; + * '-('' ).-' ,' ; + * '-; | .' + * \ \ / + * | 7 .__ _.-\ \ + * | | | ``/ /` / + * /,_| | /,_/ / + * /,_/ '`-' + * + * @Author : liu.q [916000612@qq.com] + * @Date : 2019-04-24 15:32 + * @Description : 鑾峰彇鏂囦欢鐪熷疄绫诲瀷 + */ + // @formatter:on + // 缂撳瓨鏂囦欢澶翠俊鎭�-鏂囦欢澶翠俊鎭� + public static final HashMap<String, String> mFileTypes = new HashMap<String, String>(); + + static { + // images + mFileTypes.put("FFD8FF", "jpg"); + mFileTypes.put("89504E47", "png"); + mFileTypes.put("47494638", "gif"); + mFileTypes.put("49492A00", "tif"); + mFileTypes.put("424D", "bmp"); + // + mFileTypes.put("41433130", "dwg"); // CAD + mFileTypes.put("38425053", "psd"); + mFileTypes.put("7B5C727466", "rtf"); // 鏃ヨ鏈� + mFileTypes.put("3C3F786D6C", "xml"); + mFileTypes.put("68746D6C3E", "html"); + mFileTypes.put("44656C69766572792D646174653A", "eml"); // 閭欢 + mFileTypes.put("D0CF11E0", "doc"); + mFileTypes.put("D0CF11E0", "xls");//excel2003鐗堟湰鏂囦欢 + mFileTypes.put("5374616E64617264204A", "mdb"); + mFileTypes.put("252150532D41646F6265", "ps"); + mFileTypes.put("255044462D312E", "pdf"); + mFileTypes.put("504B0304", "docx"); + mFileTypes.put("504B0304", "xlsx");//excel2007浠ヤ笂鐗堟湰鏂囦欢 + mFileTypes.put("52617221", "rar"); + mFileTypes.put("57415645", "wav"); + mFileTypes.put("41564920", "avi"); + mFileTypes.put("2E524D46", "rm"); + mFileTypes.put("000001BA", "mpg"); + mFileTypes.put("000001B3", "mpg"); + mFileTypes.put("6D6F6F76", "mov"); + mFileTypes.put("3026B2758E66CF11", "asf"); + mFileTypes.put("4D546864", "mid"); + mFileTypes.put("1F8B08", "gz"); + } + + public static String getFileType(FileInputStream is) { + String value = null; + try { + byte[] b = new byte[4]; + /* + * int read() 浠庢杈撳叆娴佷腑璇诲彇涓�涓暟鎹瓧鑺傘�俰nt read(byte[] b) 浠庢杈撳叆娴佷腑灏嗘渶澶� b.length + * 涓瓧鑺傜殑鏁版嵁璇诲叆涓�涓� byte 鏁扮粍涓�� int read(byte[] b, int off, int len) + * 浠庢杈撳叆娴佷腑灏嗘渶澶� len 涓瓧鑺傜殑鏁版嵁璇诲叆涓�涓� byte 鏁扮粍涓�� + */ + is.read(b, 0, b.length); + + StringBuilder builder = new StringBuilder(); + if (b == null || b.length <= 0) { + return null; + } + String hv; + for (int i = 0; i < b.length; i++) { + // 浠ュ崄鍏繘鍒讹紙鍩烘暟 16锛夋棤绗﹀彿鏁存暟褰㈠紡杩斿洖涓�涓暣鏁板弬鏁扮殑瀛楃涓茶〃绀哄舰寮忥紝骞惰浆鎹负澶у啓 + hv = Integer.toHexString(b[i] & 0xFF).toUpperCase(); + if (hv.length() < 2) { + builder.append(0); + } + builder.append(hv); + } + value = builder.toString(); + } catch (Exception e) { + } finally { + if (null != is) { + try { + is.close(); + } catch (IOException e) { + } + } + } + return value; + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ResultHandler.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ResultHandler.java new file mode 100644 index 0000000..11b9c49 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/ResultHandler.java @@ -0,0 +1,151 @@ +package com.nuvole.util; + +import com.nuvole.common.domain.emnu.CommonResultEmnu; +import com.nuvole.common.domain.result.CommonResult; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.LinkedList; +import java.util.List; +import java.util.function.Supplier; + +/** + * 鍔熻兘鎻忚堪锛欳ommonResult宸ュ叿 + * @author xuekang + * @date 2024-04-16 10:59 + * @version 1.0 + * @param <E> data绫诲瀷 + */ +public class ResultHandler<E> { + /** CommonResult */ + private final CommonResult<E> result; + /** 璁剧疆绌哄鐞嗗嚱鏁� */ + private Supplier<E> nullProcess; + /** 璁剧疆data绌哄鐞嗗嚱鏁� */ + private Supplier<E> dataNullProcess; + /** 閿欒鐮佸鐞嗗嚱鏁� */ + private List<ErrorProcess<E>> errorProcessList; + + public ResultHandler(CommonResult<E> result) { + this.result = result; + } + + public ResultHandler(CommonResult<E> result, ResultHandler<E> resultHandler) { + this.result = result; + this.nullProcess = resultHandler.nullProcess; + this.dataNullProcess = resultHandler.dataNullProcess; + this.errorProcessList = resultHandler.errorProcessList; + } + + /** + * 璁剧疆绌哄鐞嗗嚱鏁� + * @param nullProcess 绌哄鐞嗗嚱鏁� + * @return ResultHandler + */ + public ResultHandler<E> setNullProcess(Supplier<E> nullProcess) { + this.nullProcess = nullProcess; + return this; + } + + /** + * 璁剧疆data绌哄鐞嗗嚱鏁� + * @param dataNullProcess data 绌哄鐞嗗嚱鏁� + * @return ResultHandler + */ + public ResultHandler<E> setDataNullProcess(Supplier<E> dataNullProcess) { + this.dataNullProcess = dataNullProcess; + return this; + } + + /** + * 閿欒鐮佸鐞嗗嚱鏁� + * @param code 閿欒鐮� + * @param errorProcessList 鍑芥暟 + * @return ResultHandler + */ + public ResultHandler<E> appendError(Integer code, Supplier<E> errorProcessList) { + if (this.errorProcessList == null) { + this.errorProcessList = new LinkedList<>(); + } + this.errorProcessList.add(new ErrorProcess<>(code, errorProcessList)); + return this; + } + + /** + * CommonResult宸ュ叿 + * @param result CommonResult + * @return ResultHandler + * @param <T> data绫诲瀷 + */ + public static <T>ResultHandler<T> getInstance(CommonResult<T> result) { + return new ResultHandler<>(result); + } + + /** + * 鑾峰彇 + * @param result CommonResult + * @param resultHandler ResultHandler + * @return ResultHandler + * @param <T> date绫诲瀷 + */ + public static <T>ResultHandler<T> getInstance(CommonResult<T> result, ResultHandler<T> resultHandler) { + return new ResultHandler<>(result, resultHandler); + } + + /** + * 鑾峰彇data + * @return data + */ + public E getDate() { + if (result == null) { + if (nullProcess != null) { + return nullProcess.get(); + } + return null; + } + Integer code = result.getCode(); + if (code.equals(CommonResultEmnu.OK.getCode())) { + E data = result.getData(); + if (data == null && dataNullProcess != null) { + return this.dataNullProcess.get(); + } + return data; + } + if (errorProcessList == null) { + return null; + } + for (ErrorProcess<E> process : this.errorProcessList) { + if (code.equals(process.getCode())) { + return process.getSupplier().get(); + } + } + return null; + } + + public static void main(String[] args) { +// Maps.EntryTransformer<BaseServiceClient, String, CommonResult<String>> getAllManagerByOrgCode = BaseServiceClient::getAllManagerByOrgCode; +// ClientUtil.getDate(BaseServiceClient.class, BaseServiceClient::getAllManagerByOrgCode, null); + ResultHandler.getInstance(new CommonResult<>()) + .setNullProcess(() -> { + throw new RuntimeException(""); + }) + .setDataNullProcess(() -> "") + .appendError(1, () -> "") + .getDate(); + } + + /** + * 鍔熻兘鎻忚堪锛氶敊璇鐞嗛�昏緫 + * @author xuekang + * @date 2024-04-16 13:26 + * @version 1.0 + */ + @Data + @AllArgsConstructor + private static class ErrorProcess<E> { + /** 閿欒鐮� */ + private Integer code; + /** 澶勭悊鍑芥暟 */ + private Supplier<E> supplier; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/SftpUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/SftpUtil.java new file mode 100644 index 0000000..9e5ec93 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/SftpUtil.java @@ -0,0 +1,124 @@ +package com.nuvole.util; + +import cn.hutool.core.io.FileUtil; +import cn.hutool.extra.ssh.JschUtil; +import cn.hutool.extra.ssh.Sftp; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.ResourceLoader; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName SFtpUtil + * @date 2019/7/24 20:53 + */ +public class SftpUtil { + + public static Properties getFtpProp() { + Properties props = new Properties(); + InputStream in = null; + try { + ResourceLoader resourceLoader = new DefaultResourceLoader(); + in = resourceLoader.getResource("sftp.properties").getInputStream(); + props.load(in); + return props; + } catch (IOException e) { + e.printStackTrace(); + return props; + } finally { + ResourceUtil.safeClose(in); + } + } + + public static Sftp getSftp() { + Properties props = getFtpProp(); + String url = props.getProperty("ftp.url"); + String username = props.getProperty("ftp.username"); + String mixpd = props.getProperty("ftp.mixpd"); + return JschUtil.createSftp(url, 22, username, mixpd); + } + + public static void upload(Sftp sftp, String sourceFilePath, String targetFilePath, boolean isDelSourceFile) { + System.out.println("begin upload"); + String targetPath = targetFilePath.substring(0, targetFilePath.lastIndexOf("/")); + System.out.println("begin mkDirs"); + sftp.mkDirs(targetPath); + System.out.println("end mkDirs"); + sftp.put(sourceFilePath, targetFilePath); + System.out.println("upload finish"); + if (isDelSourceFile) { + FileUtil.del(sourceFilePath); + } + + } + + public static void main(String[] args) { +// String url = "116.198.40.76"; +// String username = "mysftp"; +// String mixpd = "Bjjmy_2020"; +// Sftp sftp = JschUtil.createSftp(url, 22, username, mixpd); +// String sourceFilePath = "D:/tmp/2023/8/9/84cd0f68c1764e10a2f9307e7bd3333a/Excel娴嬭瘯.zip"; +// String targetFilePath = "/ecosphereShopKf/goodsUploadMsgFile/2023/8/9/84cd0f68c1764e10a2f9307e7bd3333a/Excel娴嬭瘯.zip"; +// upload(sftp, sourceFilePath, targetFilePath); + String paramsStr = "鏉愯川#304涓嶉攬閽浜у湴#閮戝窞"; + String[] paramsArr = paramsStr.split("\\|"); + for (String paramKV : paramsArr) { + String[] paramKVArr = paramKV.split("#"); + if (paramKVArr.length != 2) { + System.out.println(paramKVArr.length); + } + if (paramKVArr[0].length() > 20 || paramKVArr[1].length() > 300) { + System.out.println(paramKVArr[0].length()); + } + } + + } + + public static void upload(Sftp sftp, String FileName, InputStream inputStream, String targetPath) { + if (FileName.lastIndexOf(".") <= -1) { + return; + } + String ext = FileName.substring(FileName.lastIndexOf(".") + 1); + String sourceFilePath = System.getProperty("user.dir") + ResourceUtil.createFileName(ext); + System.out.println("begin "); + System.out.println("tmpFile.getPath(): "); + File tmpFile = FileUtil.touch(sourceFilePath); + FileUtil.writeFromStream(inputStream, tmpFile.getPath()); + System.out.println("tmpFile: " + tmpFile); + upload(sftp, sourceFilePath, targetPath + FileName, true); + } + + public static void upload(Sftp sftp, String FileName, BufferedImage bufferedImage, String targetPath) + throws IOException { + if (FileName.lastIndexOf(".") <= -1) { + return; + } + String ext = FileName.substring(FileName.lastIndexOf(".") + 1); + String sourceFilePath = System.getProperty("user.dir") + ResourceUtil.createFileName(ext); + File tmpFile = FileUtil.touch(sourceFilePath); + ImageIO.write(bufferedImage, "png", tmpFile); + System.out.println("targetPath" + targetPath); + upload(sftp, sourceFilePath, targetPath + FileName, true); + } + + public static void download(Sftp sftp, String sourceFilePath, String targetFilePath) { + sftp.download(sourceFilePath, FileUtil.touch(targetFilePath)); + } + + public static void del(Sftp sftp, String targetFilePath) { + sftp.delFile(targetFilePath); + } + + public static void close(Sftp sftp) { + if (sftp != null) { + sftp.close(); + } + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/TableExportCallUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/TableExportCallUtil.java new file mode 100644 index 0000000..8fe1610 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/TableExportCallUtil.java @@ -0,0 +1,35 @@ +package com.nuvole.util; + +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSON; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.mysql.fabric.xmlrpc.base.Params; +import com.nuvole.constants.ServiceConstants; +import lombok.extern.slf4j.Slf4j; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Description: 澶栫綉鎺ュ彛瀵煎嚭宸ュ叿 + * @Company: TOO (ps锛氬叕鍙稿悕绉�) + * @author: 鍞� + * @date: 2019/11/22 涓婂崍10:20 + * @version: V1.0.0 + */ +@Slf4j +public class TableExportCallUtil { + + + public static String getResult(String url, String sign, Long time, HashMap params) { + String path = ServiceConstants.SERVICE_EXPORT_TABLE_URL; + Map<String,Object> param = new HashMap<>(4); + param.put("url",url); + param.put("sign",sign); + param.put("time",time); + + param.put("params", new JSONObject(params)); + return HttpUtil.get(path,param); + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/TencentMapUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/TencentMapUtil.java new file mode 100644 index 0000000..b461ad0 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/TencentMapUtil.java @@ -0,0 +1,99 @@ +package com.nuvole.util; + +import cn.hutool.crypto.SecureUtil; +import cn.hutool.http.HttpUtil; +import lombok.extern.slf4j.Slf4j; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.TreeMap; + +/** + * 鑵捐鍦板浘宸ュ叿绫� + * + * @Author: lc + * @Date: 2019/6/28 14:57 + */ +@Slf4j +public class TencentMapUtil { + + //鑵捐鍦板浘绉橀挜 + public static String k = "5DUBZ-M5AKR-MZQWH-WPFLA-N4MNT-KBF44"; + + //鑵捐鍦板浘浣嶇疆灞曠ず鍦板潃 + public static String mapUrl = "https://apis.map.qq.com/tools/poimarker"; + + //閫嗗湴鍧�瑙f瀽鍦板潃 + public static String locationUrl = "https://apis.map.qq.com/ws/geocoder/v1"; + + //绛惧悕鏍¢獙sk + public static String SK = "jCtZhEfr0u6FR8DrBqOI3XnUlZ7NTN0"; + + + /** + * 缁忕含搴﹁В鏋愬湴鍧� + * + * @param lat 绾害 + * @param lng 绾害 + * @Author: lc + * @Date: 2019/6/28 15:13 + */ + public static String getLocation(String lat, String lng) { + //缁勮鏁版嵁 + Map<String, Object> r = new HashMap<>(); + String url = "/ws/geocoder/v1?"; + r.put("location", lat + "," + lng); + r.put("key", k); + String sign = SecureUtil.md5(url + coverMap2String(r) + SK); + r.put("sig", sign); + String result = HttpUtil.get(locationUrl, r); + + return result; + } + + /** + * 鐢辨枃瀛楀湴鍧�鍒扮粡绾害鐨勮浆鎹㈣兘鍔涳紝骞跺悓鏃舵彁渚涚粨鏋勫寲鐨勭渷甯傚尯鍦板潃淇℃伅銆� + * @param address + * @return + */ + public static String geocoder(String address) { + //缁勮鏁版嵁 + Map<String, Object> r = new HashMap<>(); + String url = "/ws/geocoder/v1?"; + r.put("address", address); + r.put("key", k); + String sign = SecureUtil.md5(url + coverMap2String(r) + SK); + r.put("sig", sign); + String result = HttpUtil.get(locationUrl, r); + + return result; + } + + /** + * 灏嗗弬鏁版寜key杩涜瀛楀吀鍗囧簭鎺掑垪key1=value1 + */ + public static String coverMap2String(Map<String, Object> data) { + TreeMap<String, Object> tree = new TreeMap<>(); + Iterator<Map.Entry<String, Object>> it = data.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry<String, Object> en = it.next(); + tree.put(en.getKey(), en.getValue()); + } + it = tree.entrySet().iterator(); + StringBuffer sf = new StringBuffer(512); + while (it.hasNext()) { + Map.Entry<String, Object> en = it.next(); + sf.append(en.getKey() + "=" + en.getValue() + + "&"); + } + return sf.substring(0, sf.length() - 1); + } + + + public static void main(String[] args) { + System.out.println("is result:" + getLocation("34.799145", "113.649445")); + } + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/TreeUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/TreeUtil.java new file mode 100644 index 0000000..e02deba --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/TreeUtil.java @@ -0,0 +1,105 @@ +package com.nuvole.util; + +import cn.hutool.core.convert.Convert; + +import java.util.*; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName TreeUtil + * @Description tree宸ュ叿绫� + * @date 2019/4/23 15:50 + */ +public class TreeUtil { + + public static <T> List<Map> convert2Tree(List<T> list) { + return convert2Tree(list, null, "children"); + } + + public static <T> List<Map> convert2Tree(List<T> list, String childrenKey) { + return convert2Tree(list, null, childrenKey); + } + + public static <T> List<Map> convert2Tree(List<T> list, Map<String, String> mapping) { + return convert2Tree(list, mapping, "children"); + } + + /** + * 瀵硅薄鏁扮粍鏍煎紡鍖栦负tree缁撴瀯锛屽璞′腑蹇呴』鍏锋湁{id,pid}灞炴�� + * + * @param list + * @param mapping {"label":"name"} 灏嗘暟鎹簱鏌ヨlist涓殑label灞炴�ф浛鎹负name灞炴�� + * @param childrenKey 鑷妭鐐筴ey鍚嶇О 榛樿涓篶hildren + * @return : java.util.List<java.util.Map> + * @author ChenLong + * @date 2019/4/23 18:44 + * @version 1.0 + */ + public static <T> List<Map> convert2Tree(List<T> list, Map<String, String> mapping, String childrenKey) { + if (list == null || list.size() <= 0) { + return new ArrayList<Map>(); + } + + Map root = new HashMap(); + root.put(childrenKey, new ArrayList<Map>()); + + LinkedHashMap<String, Map> dataSet = new LinkedHashMap<String, Map>(); + for (T obj : list) { + Map map; + if (obj instanceof Map) { + map = new HashMap(){{ + putAll((Map) obj); + }}; + } else { + map = TypeConvertUtil.obj2Map(obj); + } + //缁撴灉杞崲 + if (mapping != null) { + for (String key : mapping.keySet()) { + if (map.containsKey(key)) { + map.put(mapping.get(key), map.get(key)); + //绉婚櫎鍘熸湁灞炴�� + map.remove(key); + } + } + } + dataSet.put(Convert.toStr(map.get("id")), map); + } + + //缁勮鏍� + for (String key : dataSet.keySet()) { + Object parentId = ((dataSet.get(key)).get("pid")); + if(parentId == null){ + /* 澧炲姞涓�绉嶅ぇ灏忓啓绫诲瀷 + * @author dqh + * @date 2024-04-12 + **/ + parentId = ((dataSet.get(key)).get("PId")); + } + String pid = Convert.toStr(parentId); + if (pid.equals("0")) { + ((List<Map>) root.get(childrenKey)).add((Map) dataSet.get(key)); + } else { + Map pNode = (Map) dataSet.get(pid); + if (pNode != null) { + if (pNode.get(childrenKey) == null) { + List children = new ArrayList<Map>(); + pNode.put(childrenKey, children); + } + ((List<Map>) pNode.get(childrenKey)).add((Map) dataSet.get(key)); + } else { + ((List<Map>) root.get(childrenKey)).add((Map) dataSet.get(key)); + } + } + } + + if (root.get(childrenKey) != null) { + return (List<Map>) root.get(childrenKey); + } else { + return new ArrayList<Map>(); + } + + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/TypeConvertUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/TypeConvertUtil.java new file mode 100644 index 0000000..a5d6894 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/TypeConvertUtil.java @@ -0,0 +1,36 @@ +package com.nuvole.util; + +import org.springframework.cglib.beans.BeanMap; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName TypeConvertUtil + * @Description 绫诲瀷杞崲宸ュ叿绫� + * @date 2019/4/23 15:54 + */ +public class TypeConvertUtil { + + /** + * object杞琺ap + * @author ChenLong + * @date 2019/4/23 18:35 + * @version 1.0 + * @param obj 闇�杞崲瀵硅薄 + * @return : java.util.Map + */ + public static Map obj2Map(Object obj) { + HashMap map = new HashMap(); + if (obj != null) { + BeanMap beanMap = BeanMap.create(obj); + for (Object key : beanMap.keySet()) { + map.put(key + "", beanMap.get(key)); + } + } + return map; + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/VerifyImgUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/VerifyImgUtil.java new file mode 100644 index 0000000..801d77a --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/VerifyImgUtil.java @@ -0,0 +1,153 @@ +package com.nuvole.util; +// @formatter:off + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.security.SecureRandom; +import java.util.Base64; +import java.util.HashMap; +import java.util.Map; + +/** + * .-~~~~~~~~~-._ _.-~~~~~~~~~-. + * __.' @Author ~. .~ 浠g爜鏃燘ug `.__ + * .'// liu.q \./ (绉樼睄) \\`. + * .'// [916000612@qq.com] | 娆茬粌绁炲姛 寮曞垁鑷 \\`. + * .'// .-~"""""""~~~~-._ | _,-~~~~"""""""~-. \\`. + * .'//.-" 2019-06-24 `-. | .-' 15:43 "-.\\`. + * .'//______.============-.. \ | / ..-============.______\\`. + * .'______________________________\|/______________________________`. + * + * @Description : + */ +// @formatter:on + +public class VerifyImgUtil { + private static int T_WIDTH = 320; //婧愭枃浠跺搴� + private static int T_HEIGHT = 180; //婧愭枃浠堕珮搴� + + + /* + * @Author : liu.q [916000612@qq.com] + * @Date : 2019-06-24 15:46 + * @Description : 闅忔満鐢熸垚鎶犲浘鍧愭爣 + */ + public static Map<String, Integer> generateCutoutCoordinates(int w, int h) { + Map<String, Integer> result = new HashMap(); + int x = new SecureRandom().nextInt(T_WIDTH - w); + int y = new SecureRandom().nextInt(T_HEIGHT - h); + while (x < w + 10) { + x = new SecureRandom().nextInt(275); + } + result.put("x", x); + result.put("y", y); + return result; + } + + /* + * @Author : liu.q [916000612@qq.com] + * @Date : 2019-06-24 16:22 + * @Description :鐢熸垚婊戝潡 + */ + public static Map<String, BufferedImage> initSlidingBlock(BufferedImage sourceImg, int[][] templateImgData, int x, int y, int w, int h) throws Exception { + // 鏀寔alpha閫氶亾鐨剅gb鍥惧儚 + BufferedImage newTemplateImg = new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR); + + for (int i = 0; i < templateImgData.length; i++) { + for (int j = 0; j < templateImgData[0].length; j++) { + int rgb = templateImgData[i][j]; + if (rgb == 1) { + int rgb_ori = sourceImg.getRGB(x + i, y + j); + int r = (0xff & rgb_ori); + int g = (0xff & (rgb_ori >> 8)); + int b = (0xff & (rgb_ori >> 16)); + rgb_ori = r + (g << 8) + (b << 16) + (255 << 24); + newTemplateImg.setRGB(i, j, rgb_ori); + + //鍒涘缓閬僵灞� + BufferedImage cover = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB); + Graphics2D coverG2 = (Graphics2D) cover.getGraphics(); + coverG2.setColor(Color.BLACK); + coverG2.fillRect(0, 0, 10, 10); + coverG2.dispose(); + Graphics2D bgG2 = (Graphics2D) sourceImg.getGraphics(); + //寮�鍚�忔槑搴� + bgG2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.5f)); + //鎻忕粯 + bgG2.drawImage(cover, i + x, y + j, 1, 1, null); + //缁撴潫閫忔槑搴� + bgG2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); + bgG2.dispose(); + } + if (rgb == 0) { + //涓嶇敤鎼悊 + } + if (rgb == 2) { + //绉掕竟 + newTemplateImg.setRGB(i, j, 16777215); + sourceImg.setRGB(x + i, y + j, 16777215); + } + } + } + Map<String, BufferedImage> result = new HashMap<>(); + result.put("newTemplateImg", newTemplateImg); + result.put("newSourceImg", sourceImg); + return result; + } + + + /* + * @Author : liu.q [916000612@qq.com] + * @Date : 2019-06-21 15:37 + * @Description : 鑾峰彇base64 + */ + public static String getBase64(BufferedImage bi) { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + String res = ""; + try { + ImageIO.write(bi, "png", outputStream); + res = Base64.getEncoder().encodeToString(outputStream.toByteArray()); + res = "data:image/png;base64," + res; + outputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + return res; + } + + /* + * @Author : liu.q [916000612@qq.com] + * @Date : 2019-06-24 17:22 + * @Description : 鐢熸垚鎶犲浘鍥惧舰鐭╅樀 + */ + public static int[][] getTemplateData(BufferedImage bi) { + int[][] data = new int[bi.getWidth()][bi.getHeight()]; + for (int i = 0; i < bi.getWidth(); i++) { + for (int j = 0; j < bi.getHeight(); j++) { + int rgb = bi.getRGB(i, j); + int leftRgb = -1, rightRgb = -1, upRgb = -1, downRgb = -1; + if (j > 0) + leftRgb = bi.getRGB(i, j - 1); + if (j < bi.getHeight() - 1) + rightRgb = bi.getRGB(i, j + 1); + if (i > 0) + upRgb = bi.getRGB(i - 1, j); + if (i < bi.getWidth() - 1) + downRgb = bi.getRGB(i + 1, j); + if (rgb == -1 && (i == 0 || i == bi.getWidth() - 1 || j == 0 || j == bi.getHeight() - 1)) { + data[i][j] = 2; //杈� + } else if (rgb == -1 && (leftRgb != -1 || rightRgb != -1 || upRgb != -1 || downRgb != -1)) { + data[i][j] = 2;//杈� + } else if (rgb == -1) { + data[i][j] = 1;//鍐呭鍖哄煙 + } else { + data[i][j] = 0;//閫忔槑鍖哄煙 + } + } + } + return data; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/WriterUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/WriterUtil.java new file mode 100644 index 0000000..8d1a425 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/WriterUtil.java @@ -0,0 +1,130 @@ +package com.nuvole.util; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.file.FileWriter; + +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class WriterUtil { + + private static String path = "F:\\data\\"; + + + /* @Test + public void test() { + login("nodata", 1122L, "鐢�", "172.16.60.222", "https://www.baidu.com"); + member(11222L, "nodata", Convert.toShort(1), "12121"); + }*/ + + /** + * 鍐欏叆鍟嗗煄鐧诲綍鏁版嵁 + * + * @param code 鏈哄櫒鐮� + * @param memberId 浼氬憳id + * @param sex 鎬у埆 + * @param ip ip鍦板潃 + * @param address 鐧诲綍鍦板潃 + * @Author: lc + * @Date: 2019/10/23 15:13 + */ + public static void login(String code, Long memberId, String sex, String ip, String address) { +// String day = DateUtil.today(); +// FileWriter writer = new FileWriter(path + "login\\" + day + ".txt"); +// String time = CodeUtil.getTimeCode(); +// writer.append(time + " " + code + " " + memberId + " " + sex + " " + ip + " " + address + "\n"); + } + + + /** + * 鍐欏叆浼氬憳娉ㄥ唽/淇敼鏁版嵁 + * + * @param memberId 浼氬憳id + * @param area 鍦板尯 + * @param type 鎿嶄綔绫诲瀷銆�1.鏂板 2.瀹屽杽銆� + * @param birthday 鐢熸棩 + * @Author: lc + * @Date: 2019/10/23 15:13 + */ + public static void member(Long memberId, String area, Short type, String birthday) { +// String day = DateUtil.today(); +// FileWriter writer = new FileWriter(path + "member\\" + day + ".txt"); +// String time = CodeUtil.getTimeCode(); +// writer.append(time + " " + memberId + " " + area + " " + type + " " + birthday + "\n"); + } + + + /** + * 鍐欏叆璁㈠崟鏁版嵁 + * + * @param orderId 璁㈠崟id + * @param orderType 璁㈠崟绫诲瀷銆�1.鍟嗗煄 2.鍟嗘埛銆� + * @param payMoney 鏀粯閲戦 + * @param memberId 浼氬憳id + * @param orderState 璁㈠崟鐘舵�併��1.寰呮敮浠� 2.宸插畬鎴� 3.宸查��娆� 4.鏀粯澶辫触銆� + * @param payType 鏀粯娓犻亾銆�1.鏀粯瀹� 2.寰俊 3.浜戦棯浠樸�� + * @param payWay 鏀粯鏂瑰紡銆�1.鎵爜 2.绾夸笂 銆� + * @param useScore 浣跨敤绉垎 + * @param couponId 浣跨敤浼樻儬鍒竔d + * @param couponMoney 浼樻儬鍒搁噾棰� + * @param areaId 鍟嗘埛鎵�灞炲尯鍩焛d + * @Author: lc + * @Date: 2019/10/23 15:13 + */ + public static void order(Long orderId, String orderType, Long payMoney, Long memberId, Short orderState, Short payType, Short payWay, Long useScore, Long couponId, Long couponMoney, String areaId) { +// String day = DateUtil.today(); +// FileWriter writer = new FileWriter(path + "order\\" + day + ".txt"); +// String time = CodeUtil.getTimeCode(); +// writer.append(time + " " + orderId + " " + orderType + " " + payMoney + " " + memberId + " " + orderState + " " + +// payType + " " + payWay + " " + useScore + " " + couponId + " " + couponMoney + " " + areaId + "\n"); + } + + + /** + * 鍐欏叆鍟嗗搧鏁版嵁 + * + * @param goodsSpuId 鍟嗗搧SpuId + * @param goodsSkuId 鍟嗗搧SkuId + * @param money 閲戦 + * @param state 鐘舵�併��1.鏂板 2.涓婃灦 3.涓嬫灦 4.鍑哄敭銆� + * @Author: lc + * @Date: 2019/10/23 15:13 + */ + public static void goods(Long goodsSpuId, Long goodsSkuId, Long money, Short state) { +// String day = DateUtil.today(); +// FileWriter writer = new FileWriter(path + "goods\\" + day + ".txt"); +// String time = CodeUtil.getTimeCode(); +// writer.append(time + " " + goodsSpuId + " " + goodsSkuId + " " + money + " " + state + "\n"); + } + + + /** + * 鍐欏叆鍟嗗搧閿�鍞� + * + * @param goodsSpuId 鍟嗗搧SpuId锛堣鏍硷級 + * @param goodsSkuId 鍟嗗搧SkuId锛堝睘鎬э級 + * @Author: lc + * @Date: 2019/10/23 15:13 + */ + public static void goodsSell(Long goodsSpuId, Long goodsSkuId) { +// String day = DateUtil.today(); +// FileWriter writer = new FileWriter(path + "goodsSell\\" + day + ".txt"); +// String time = CodeUtil.getTimeCode(); +// writer.append(time + " " + goodsSpuId + " " + goodsSkuId + "\n"); + } + + /** + * 鎵ц鎵嬪姩鍥炶皟鐨勮鍗昳d + * @param builder + * @throws IOException + */ + public static void callBackGoodsInfo(StringBuilder builder) throws IOException { + String fileName = new SimpleDateFormat("yyyyMMdd").format(new Date()) + ".csv"; + String day = DateUtil.today(); + FileWriter writer = new FileWriter(path + "鍥炶皟璁㈠崟" +fileName ); + writer.append(String.valueOf(builder)); + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/WxCallUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/WxCallUtil.java new file mode 100644 index 0000000..e2fc008 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/WxCallUtil.java @@ -0,0 +1,185 @@ +package com.nuvole.util; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.http.HttpUtil; +import com.nuvole.common.domain.wx.PushMsg; +import com.nuvole.constants.ServiceConstants; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.commons.httpclient.params.HttpMethodParams; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Description: 澶栫綉鎺ュ彛璇锋眰宸ュ叿绫伙紙寰俊锛� + * @Author: liujun + * @Date: 2019-07-25 11:59 + **/ +@Slf4j +public class WxCallUtil { + + /** + * 鑾峰彇涓存椂鐧诲綍鍑瘉code + * + * @param jsCode + * @return + */ + public static String getOpenidSessionKey(String jsCode) { + String url = ServiceConstants.SERVICE_JSCODE2SESSION_URL; + Map<String, Object> paramMap = new HashMap<>(1); + paramMap.put("jsCode", jsCode); + return HttpUtil.get(url, paramMap); + } + + /** + * 鑾峰彇AccessToken + * + * @return + */ + public static String getAccessToken() { + String url = ServiceConstants.SERVICE_TOKEN_URL; + String result = HttpUtil.get(url); + log.info("getAccessToken 杩斿洖鍊硷細 {}", result); + return result; + } + + /** + * 鑾峰彇 jsapi_ticket + * + * @return + */ + public static String getJsapTicket(String accessToken) { + String url = ServiceConstants.SERVICE_JSAPITICKET_URL; + Map<String, Object> paramMap = new HashMap<>(1); + paramMap.put("accessToken", accessToken); + return HttpUtil.get(url, paramMap); + } + + /** + * 寰俊鍏紬鍙疯幏鍙朼ccess_token + * + * @param code + * @return + */ + public static String getWechatAccessToken(String code) { + String url = ServiceConstants.SERVICE_ACCESS_TOKEN_URL; + Map<String, Object> paramMap = new HashMap<>(1); + paramMap.put("code", code); + return HttpUtil.get(url, paramMap); + } + + /** + * 寰俊鍏紬鍙疯幏鍙栫敤鎴蜂俊鎭� + * + * @param accessToken + * @param openId + * @return + */ + public static String getWechatUserInfo(String accessToken, String openId) { + String url = ServiceConstants.SERVICE_USERINFO_URL; + Map<String, Object> paramMap = new HashMap<>(2); + paramMap.put("accessToken", accessToken); + paramMap.put("openId", openId); + return HttpUtil.get(url, paramMap); + } + + /** + * 鑾峰彇灏忕▼搴忕爜锛堝墠鎻愭槸宸插彂甯冿級 + * + * @param accessToken + * @param scene + * @param width + * @param page + * @return + */ + public static byte[] getQRcode(String accessToken, String scene, int width, String page) { + byte[] result = null; + String url = ServiceConstants.SERVICE_WXACODEUNLIMIT_URL; + if (false) { + HttpClient client = new HttpClient(); + PostMethod method = new PostMethod(url); + HttpMethodParams paramMap = new HttpMethodParams(); + paramMap.setParameter("accessToken", accessToken); + paramMap.setParameter("scene", scene); + paramMap.setParameter("width", width); + paramMap.setParameter("page", page); + method.setParams(paramMap); + try { + int statusCode = client.executeMethod(method); + if (statusCode != HttpStatus.SC_OK) { + log.info("Method failed: " + method.getStatusLine()); + } else { + // 杩斿洖鍝嶅簲娑堟伅 + result = method.getResponseBodyAsString().getBytes(method.getResponseCharSet()); + } + method.releaseConnection(); + } catch (IOException e) { + e.printStackTrace(); + } + } else { + RestTemplate rest = new RestTemplate(); + try { + Map<String, Object> param = new HashMap<>(); + url = url + "?accessToken=" + accessToken + "&scene=" + scene + "&width=" + width + "&page=" + page; + MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); + HttpEntity requestEntity = new HttpEntity(param, headers); + ResponseEntity<byte[]> entity = rest.exchange(url, HttpMethod.POST, requestEntity, byte[].class, + new Object[0]); + result = entity.getBody(); + /*BASE64Encoder encoder = new BASE64Encoder(); + String imageStr = encoder.encode(result); + imageStr = HtmlUtils.htmlEscape(imageStr); + BASE64Decoder decoder = new BASE64Decoder(); + result = decoder.decodeBuffer(imageStr);*/ + } catch (Exception e) { + log.error("璋冪敤灏忕▼搴忕敓鎴愬井淇℃案涔呭皬绋嬪簭鐮乁RL鎺ュ彛寮傚父", e); + } + } + return result; + } + + /** + * 寰俊鎺ㄩ�佹秷鎭� + * + * @param openId + * @param formId + * @param templateId + * @param page + * @param items + */ + public static void push(String openId, String formId, String templateId, String page, List<String> items) { + String url = ServiceConstants.SERVICE_TEMPLATE_SEND_URL; + Map<String, Object> paramMap = new HashMap<>(5); + paramMap.put("openId", openId); + paramMap.put("formId", formId); + paramMap.put("templateId", templateId); + paramMap.put("page", page); + paramMap.put("items", CommonUtil.listToString(items)); + HttpUtil.get(url, paramMap); + } + + + /* * + * 寰俊灏忕▼搴忚闃呮秷鎭帹閫� + * + * @author lc + * @date 2020/1/2 14:28 + */ + public static void pushSend(PushMsg pushMsg, String accessToken) { + String url = ServiceConstants.SERVICE_SUBSCRIBER_SEND_URL; + Map<String, Object> paramMap = BeanUtil.beanToMap(pushMsg); + paramMap.put("accessToken", accessToken); + HttpUtil.get(url, paramMap); + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/WxUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/WxUtil.java new file mode 100644 index 0000000..04e1bf3 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/WxUtil.java @@ -0,0 +1,284 @@ +package com.nuvole.util; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; +import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; +import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage; +import cn.binarywang.wx.miniapp.config.WxMaInMemoryConfig; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSONObject; +import com.nuvole.common.domain.dto.AppDTO; +import com.nuvole.common.domain.wx.PushMsg; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +import org.springframework.beans.BeanUtils; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.HtmlUtils; + +import java.util.*; + +/** + * 灏忕▼搴忓伐鍏风被 + * + * @author liujun + * @Date 2019/5/27 16:40 + */ +@Slf4j +public class WxUtil { + + /** + * 鑾峰彇涓存椂鐧诲綍鍑瘉code + * + * @param appid AppID(灏忕▼搴廔D) + * @param secret AppSecret(灏忕▼搴忓瘑閽�) + * @param jsCode 鐧诲綍鏃惰幏鍙栫殑Code + * @return + */ + public static String getOpenidSessionKey(String appid, String secret, String jsCode) { + String url = "https://api.weixin.qq.com/sns/jscode2session"; + Map<String, Object> paramMap = new HashMap<>(3); + paramMap.put("appid", appid); + paramMap.put("secret", secret); + paramMap.put("js_code", jsCode); + paramMap.put("grant_type", "authorization_code"); + return HttpUtil.get(url, paramMap); + } + + /** + * 鑾峰彇AccessToken + * + * @param appid AppID(灏忕▼搴廔D) + * @param secret AppSecret(灏忕▼搴忓瘑閽�) + * @return + */ + public static String getAccessToken(String appid, String secret) { + String url = "https://api.weixin.qq.com/cgi-bin/token"; + Map<String, Object> paramMap = new HashMap<>(3); + paramMap.put("appid", appid); + paramMap.put("secret", secret); + paramMap.put("grant_type", "client_credential"); + String s = HttpUtil.get(url, paramMap); + log.info("鑾峰彇AccessToken 鍙傛暟= 銆媋ppid:{},secret:{}", appid, secret); + log.info("鑾峰彇AccessToken = 銆媨}", s); + return s; + } + + /** + * 鑾峰彇AccessToken + * + * @param accessToken getAccessToken鏂规硶鑾峰彇鐨刟ccess_token + * @return + */ + public static String getJsapTicket(String accessToken) { + String url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket"; + Map<String, Object> paramMap = new HashMap<>(3); + paramMap.put("type", "jsapi"); + paramMap.put("access_token", accessToken); + return HttpUtil.get(url, paramMap); + } + + /** + * Createed by PKZ Date 2019/6/18 17:11 Description锛氬井淇″叕浼楀彿鑾峰彇access_token + **/ + public static String getWechatAccessToken(String appid, String secret, String code) { + String url = "https://api.weixin.qq.com/sns/oauth2/access_token"; + Map<String, Object> paramMap = new HashMap<>(3); + paramMap.put("appid", appid); + paramMap.put("secret", secret); + paramMap.put("code", code); + paramMap.put("grant_type", "authorization_code"); + return HttpUtil.get(url, paramMap); + } + + /** + * Createed by PKZ Date 2019/6/18 17:13 Description锛氬井淇″叕浼楀彿鑾峰彇鐢ㄦ埛淇℃伅 + **/ + public static String getWechatUserInfo(String access_token, String openid) { + String url = "https://api.weixin.qq.com/sns/userinfo"; + Map<String, Object> paramMap = new HashMap<>(3); + paramMap.put("access_token", access_token); + paramMap.put("openid", openid); + paramMap.put("lang", "zh_CN"); + return HttpUtil.get(url, paramMap); + } + + /** + * 璇ユ帴鍙g敤浜庡皢 code 鎹㈠彇鐢ㄦ埛鎵嬫満鍙� + * + * @param access_token + * @param code + * @return + */ + public static String getUserPhoneNumber(String access_token, String code) { + String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + access_token; + Map<String, Object> paramMap = new HashMap<>(1); + paramMap.put("code", code); + String result = HttpUtil.post(url, JSONUtil.toJsonStr(paramMap)); + log.info("getUserPhoneNumber=>{}", result); + JSONObject resultInfo = JSONObject.parseObject(result); + if (resultInfo.getIntValue("errcode") == 0) { + return resultInfo.getJSONObject("phone_info").getString("purePhoneNumber"); + } + return null; + } + + /** + * 鑾峰彇 URL Link + * + * @param access_token + * @return + */ + public static String generateUrllink(String access_token) { + String url = "https://api.weixin.qq.com/wxa/generate_urllink?access_token=" + access_token; + Map<String, Object> paramMap = new HashMap<>(1); + String result = HttpUtil.post(url, JSONUtil.toJsonStr(paramMap)); + log.info("generateUrllink=>{}", result); + JSONObject resultInfo = JSONObject.parseObject(result); + if (resultInfo.getIntValue("errcode") == 0) { + return resultInfo.getString("url_link"); + } + return null; + } + + + /* + * @Author : liu.q [916000612@qq.com] + * + * @Date : 2019-06-27 09:49 + * + * @Description :鑾峰彇灏忕▼搴忕爜锛堝墠鎻愭槸宸插彂甯冿級 + * + * @secne 鍙傛暟 + * + * @width 鐮佸 + * + * @page 鐮佽烦杞矾寰� + */ + public static byte[] getQRcode(String access_token, String scene, int width, String page) { + RestTemplate rest = new RestTemplate(); + byte[] result = null; + try { + String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + access_token; + Map<String, Object> param = new HashMap<>(); + param.put("scene", scene); +// param.put("access_token", access_token); //access_token鎺ュ湪url鍚� + param.put("page", page); + param.put("width", width); + param.put("auto_color", true); + Map<String, Object> line_color = new HashMap<>(); + line_color.put("r", 54); + line_color.put("g", 56); + line_color.put("b", 115); + param.put("line_color", line_color); + MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); + AppDTO sto = new AppDTO(); + AppDTO s = new AppDTO(); + sto.setMap(param); + sto.setPro(url); + BeanUtils.copyProperties(sto, s); +// String result22 = HttpUtil.post(url, JSONUtil.toJsonStr(param)); +// log.info("getUserPhoneNumber=>{}",result22); + HttpEntity requestEntity = new HttpEntity(s.getMap(), headers); + ResponseEntity<byte[]> entity = rest.exchange(s.getPro(), HttpMethod.POST, requestEntity, byte[].class, + new Object[0]); + result = entity.getBody(); + if (entity.getHeaders().getContentType().isCompatibleWith(MediaType.APPLICATION_JSON)) { + log.error(new String(result)); + return null; + } + System.out.println(entity.toString()); + + String imageStr = Base64.getEncoder().encodeToString(result); + imageStr = HtmlUtils.htmlEscape(imageStr); + result = Base64.getDecoder().decode(imageStr); + } catch (Exception e) { + e.printStackTrace(); + log.error("璋冪敤灏忕▼搴忕敓鎴愬井淇℃案涔呭皬绋嬪簭鐮乁RL鎺ュ彛寮傚父", e); + } + return result; + } + + /** + * 鎺ㄩ�佹秷鎭� + * + * @param appId + * @param secret + * @param openId + * @param formId + * @param templateId + * @param page + * @param items + */ + public static void push(String appId, String secret, String openId, String formId, String templateId, String page, + List<String> items) { + // 1,閰嶇疆灏忕▼搴忎俊鎭� + WxMaInMemoryConfig wxConfig = new WxMaInMemoryConfig(); + // 灏忕▼搴廰ppid + wxConfig.setAppid(appId); + // 灏忕▼搴廇ppSecret + wxConfig.setSecret(secret); + WxMaService wxMaService = new WxMaServiceImpl(); + wxMaService.setWxMaConfig(wxConfig); + // 2,璁剧疆妯$増淇℃伅锛坘eyword1锛氱被鍨嬶紝keyword2锛氬唴瀹癸級 + List<WxMaTemplateData> templateDataList = new ArrayList<>(items.size()); + for (int i = 0; i < items.size(); i++) { + WxMaTemplateData data = new WxMaTemplateData("keyword" + (i + 1), items.get(i)); + templateDataList.add(data); + } + // 3锛岃缃帹閫佹秷鎭� + WxMaTemplateMessage templateMessage = WxMaTemplateMessage.builder().toUser(openId).formId(formId) + .templateId(templateId).data(templateDataList).page(page).build(); + // 4锛屽彂璧锋帹閫� + try { + wxMaService.getMsgService().sendTemplateMsg(templateMessage); + } catch (WxErrorException e) { + log.info("浠诲姟澶辫触锛�" + e.getMessage()); + } + } + + /* * + * 灏忕▼搴�-璁㈤槄娑堟伅-鎺ㄩ�佹秷鎭� + * + * @author lc + * @date 2019/12/30 9:52 + */ + public static String pushSend(PushMsg pushMsg, String accessToken) { + String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + accessToken; + try { + System.out.println("is :" + JSONUtil.toJsonStr(pushMsg)); + String result = HttpUtil.post(url, JSONUtil.toJsonStr(pushMsg)); + log.info("is push result:" + result); + return result; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /* * + * 鍏紬鍙�-妯℃澘娑堟伅 + * + */ + public static String h5PubpushSend(PushMsg pushMsg, String accessToken) { + String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken; + try { + System.out.println("is :" + JSONUtil.toJsonStr(pushMsg)); + String result = HttpUtil.post(url, JSONUtil.toJsonStr(pushMsg)); + log.info("is push result:" + result); + return result; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/XssUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/XssUtil.java new file mode 100644 index 0000000..df204d5 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/XssUtil.java @@ -0,0 +1,37 @@ +package com.nuvole.util; + +import cn.hutool.core.util.StrUtil; +import org.apache.commons.text.StringEscapeUtils; +import org.owasp.validator.html.AntiSamy; +import org.owasp.validator.html.Policy; +import org.owasp.validator.html.PolicyException; +import org.owasp.validator.html.ScanException; + +import java.io.InputStream; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName XSSUtil + * @date 2019/7/16 18:13 + */ +public class XssUtil { + + public static String clearXss(String val) { + if (StrUtil.isBlank(val)) { + return val; + } + try { + InputStream is = XssUtil.class.getResourceAsStream("/antisamy.xml"); + AntiSamy antiSamy = new AntiSamy(); + Policy policy = Policy.getInstance(is); + return StringEscapeUtils.unescapeHtml4(antiSamy.scan(val, policy).getCleanHTML()); + } catch (PolicyException e) { + e.printStackTrace(); + } catch (ScanException e) { + e.printStackTrace(); + } + return val; + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/FileType.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/FileType.java new file mode 100644 index 0000000..27c7f55 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/FileType.java @@ -0,0 +1,187 @@ +package com.nuvole.util.enums; +// @formatter:off +/** + * .-~~~~~~~~~-._ _.-~~~~~~~~~-. + * __.' @Author ~. .~ 浠g爜鏃燘ug `.__ + * .'// liu.q \./ (绉樼睄) \\`. + * .'// [916000612@qq.com] | 娆茬粌绁炲姛 寮曞垁鑷 \\`. + * .'// .-~"""""""~~~~-._ | _,-~~~~"""""""~-. \\`. + * .'//.-" 2019-04-24 `-. | .-' 15:58 "-.\\`. + * .'//______.============-.. \ | / ..-============.______\\`. + *.'______________________________\|/______________________________`. + * + * @Description : + */ +// @formatter:on + +public enum FileType { + + /** + * JEPG. + */ + JPEG("FFD8FF"), + + /** + * PNG. + */ + PNG("89504E47"), + + /** + * GIF. + */ + GIF("47494638"), + + /** + * TIFF. + */ + TIFF("49492A00"), + + /** + * Windows Bitmap. + */ + BMP("424D"), + + /** + * CAD. + */ + DWG("41433130"), + + /** + * Adobe Photoshop. + */ + PSD("38425053"), + + /** + * Rich Text Format. + */ + RTF("7B5C727466"), + + /** + * XML. + */ + XML("3C3F786D6C"), + + /** + * HTML. + */ + HTML("68746D6C3E"), + + /** + * Email [thorough only]. + */ + EML("44656C69766572792D646174653A"), + + /** + * Outlook Express. + */ + DBX("CFAD12FEC5FD746F"), + + /** + * Outlook (pst). + */ + PST("2142444E"), + + /** + * MS Word/Excel. + */ + XLS_DOC("D0CF11E0"), + + /** + * MS Access. + */ + MDB("5374616E64617264204A"), + + /** + * WordPerfect. + */ + WPD("FF575043"), + + /** + * Postscript. + */ + EPS("252150532D41646F6265"), + + /** + * Adobe Acrobat. + */ + PDF("255044462D312E"), + + /** + * Quicken. + */ + QDF("AC9EBD8F"), + + /** + * Windows Password. + */ + PWL("E3828596"), + + /** + * ZIP Archive. + */ + ZIP("504B0304"), + + /** + * RAR Archive. + */ + RAR("52617221"), + + /** + * Wave. + */ + WAV("57415645"), + + /** + * AVI. + */ + AVI("41564920"), + + /** + * Real Audio. + */ + RAM("2E7261FD"), + + /** + * Real Media. + */ + RM("2E524D46"), + + /** + * MPEG (mpg). + */ + MPG("000001BA"), + + /** + * Quicktime. + */ + MOV("6D6F6F76"), + + /** + * Windows Media. + */ + ASF("3026B2758E66CF11"), + + /** + * MIDI. + */ + MID("4D546864"); + + private String value = ""; + + /** + * Constructor. + * + * @param type + */ + private FileType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/LaPushEnum.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/LaPushEnum.java new file mode 100644 index 0000000..2714d36 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/LaPushEnum.java @@ -0,0 +1,41 @@ +package com.nuvole.util.enums; + +/** + * 鎾姤绫诲瀷: + * 01-XX閾惰鏀舵鎴愬姛 + * 02-鏀粯瀹濇敹娆炬垚鍔� + * 03-寰俊鏀舵鎴愬姛 + * 10-鍙栨秷鏀粯 + */ +public enum LaPushEnum { + YINHANG("01", "XX閾惰鏀舵鎴愬姛"), + ZFB("02", "鏀粯瀹濇敹娆炬垚鍔�"), + WX("03", "寰俊鏀舵鎴愬姛"), + YSF("04", "浜戦棯浠樻敹娆炬垚鍔�"), + KJZF("05", "蹇嵎鏀粯鏀舵鎴愬姛"), + CANCLE("10", "鍙栨秷鏀粯"); + + private String code; + private String name; + + private LaPushEnum(String code, String name) { + this.code = code; + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/QdlPayScene.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/QdlPayScene.java new file mode 100644 index 0000000..0d54fd9 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/QdlPayScene.java @@ -0,0 +1,37 @@ +package com.nuvole.util.enums; + +/** + * 鏀粯鍦烘櫙 + */ +public enum QdlPayScene { + + H5("H5", "寰俊鍏紬鍙�"), + APP("APP", "寰俊灏忕▼搴�"), + ZFB_APP("ZFB-APP", "鏀粯瀹濆皬绋嬪簭"), + EXTERNAL_APP("EXTERNAL-APP", + "绔妯″紡锛堟寚瀹氭敮浠樺伐鍏风洿鎺ヨ烦杞� paymentUrl锛屾湭鎸囧畾宸ュ叿浣跨敤鍏徃鎻愪緵閫夋嫨宸ュ叿椤甸潰涔熻烦杞� paymentUrl锛�"); + + private String code; + private String name; + + private QdlPayScene(String code, String name) { + this.code = code; + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/QdlTradeStatus.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/QdlTradeStatus.java new file mode 100644 index 0000000..079822d --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/QdlTradeStatus.java @@ -0,0 +1,49 @@ +package com.nuvole.util.enums; + +public enum QdlTradeStatus { + SUCCESS("SUCCESS", "浜ゆ槗鎴愬姛", "涓嬪崟銆侀��娆�"), + FAIL("FAIL", "浜ゆ槗澶辫触", "涓嬪崟銆侀��娆�"), + WAITFORPAY("WAITFORPAY", "璁㈠崟涓棿鐘舵�� 涓嬪崟锛氱瓑寰呮敮浠� 閫�娆撅細澶勭悊涓�", "涓嬪崟銆侀��娆�"), + CLOSE("CLOSE", "璁㈠崟瓒呮椂鍏抽棴", "涓嬪崟"), + REFUNDED("REFUNDED", "宸插叏閮ㄩ��娆�", "閫�娆�"), + REFUNDING("REFUNDING", "閮ㄥ垎閫�娆�", "閫�娆�"), + REVOKED("REVOKED", "璁㈠崟宸叉挙閿�", "鎾ら攢"), + REVOKING("REVOKING", "璁㈠崟鎾ら攢涓�", "鎾ら攢"); + + private String code; + private String name; + /** + * 浣滅敤鍩� + */ + private String scope; + + private QdlTradeStatus(String code, String name, String scope) { + this.code = code; + this.name = name; + this.scope = scope; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/QdlTradeType.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/QdlTradeType.java new file mode 100644 index 0000000..32226f0 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/enums/QdlTradeType.java @@ -0,0 +1,35 @@ +package com.nuvole.util.enums; + +public enum QdlTradeType { + BESTPAY("BESTPAY", "缈兼敮浠樼敤鎴�"), + TENPAY("TENPAY", "寰俊鐢ㄦ埛"), + QUICKPASS("QUICKPASS", "浜戦棯浠樼敤鎴�"), + WEBANKPAY("WEBANKPAY", "寰矑璐风敤鎴�"), + ALIPAY("ALIPAY", "鏀粯瀹濈敤鎴�"), + REAL_TIME("REAL_TIME", "鍥炶皟閫氱煡绫诲瀷 鍗虫椂鍒拌处"), + REAL_TIME_PRO("REAL_TIME_PRO", "鍥炶皟閫氱煡绫诲瀷 楂樼骇鍗虫椂鍒拌处"), + REFUND("REFUND", "鍥炶皟閫氱煡绫诲瀷 閫�娆�"); + private String code; + private String name; + + private QdlTradeType(String code, String name) { + this.code = code; + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/oss/YiDongOss.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/oss/YiDongOss.java new file mode 100644 index 0000000..0e21559 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/oss/YiDongOss.java @@ -0,0 +1,126 @@ +package com.nuvole.util.oss; + +import com.amazonaws.AmazonServiceException; +import com.amazonaws.SdkClientException; +import com.amazonaws.auth.AWSCredentialsProvider; +import com.amazonaws.auth.AWSStaticCredentialsProvider; +import com.amazonaws.auth.BasicAWSCredentials; +import com.amazonaws.client.builder.AwsClientBuilder; +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.AmazonS3ClientBuilder; +import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest; +import com.amazonaws.services.s3.model.PutObjectResult; +import com.amazonaws.services.s3.model.ResponseHeaderOverrides; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.InputStream; +import java.net.URL; +import java.time.Instant; +import java.util.Date; + +public class YiDongOss { + // 濉啓瑕佷笂浼犲埌鐨勫瓨鍌ㄦ《鍚嶇О锛屼緥濡�'example-bucket'銆� + private static final String bucketName = "ecosphere"; + // 濉啓瀛樺偍妗讹紙Bucket锛夋墍鍦ㄥ湴鍩熷搴旂殑 endpoint 鍜� Region銆� + private static final String endpoint = "https://eos.zhengzhou-4.cmecloud.cn"; + private static final String region = "zhengzhou4"; + // 濉啓 EOS 璐﹀彿鐨勮璇佷俊鎭紝鎴栬�呭瓙璐﹀彿鐨勮璇佷俊鎭�� + private static final String accessKey = "1PMC6XN2QVDEN6M6IWQB"; + private static final String secretKey = "tfbfDxHZGUIl7s3kb2fJyHCLtpZLydbzEhlTRmIy"; + private static AmazonS3 client = null; + + static { + // 鍒涘缓 AmazonS3 瀹炰緥銆� + AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration(endpoint, region); + BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); + AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials); + client = AmazonS3ClientBuilder.standard() + .withEndpointConfiguration(endpointConfiguration) + .withCredentials(credentialsProvider).build(); + } + + + public static void main(String[] args) throws Exception { + try { + String filePath = "C:\\Users\\cy\\Pictures\\閾佺獥娉�.jpg"; + File uploadFile = new File(filePath); + String fileName = uploadFile.getName(); + String foldName = "2023/12/19/"; +// mkdirFolder(client, bucketName,foldName); +// uploadFile(client, bucketName, foldName + fileName, new FileInputStream(uploadFile)); + String shareUrl = getShareUrl(foldName + fileName); + } catch (AmazonServiceException e) { + // 涓婁紶澶辫触銆� +// System.out.println("鍙戠敓寮傚父 AmazonServiceException锛岄�氬父鍘熷洜鏄姹傚唴瀹归敊璇��"); + System.out.println("Error Code: " + e.getErrorCode()); + } catch (SdkClientException e) { + System.out.println("Error Message: " + e.getMessage()); + } finally { + if (client != null) { + client.shutdown(); + } + } + } + + // 涓婁紶鏂囦欢銆� + public static String upload(String fileName, InputStream inputStream, String targetPath) { + String objectName = targetPath + "/" + fileName; + mkdirFolder(targetPath); + PutObjectResult putObjectResult = client.putObject(bucketName, objectName, inputStream, null); + if (putObjectResult == null) { + return null; + } + try { + return getShareUrl(objectName); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * 鍒涘缓鏂囦欢澶� + * + * @return + */ + private static boolean mkdirFolder(String directory) { + PutObjectResult putObjectResult = client.putObject(bucketName, directory, new ByteArrayInputStream(new byte[0]), null); + return putObjectResult != null; + } + + /** + * 鑾峰彇瀵硅薄鐨勫垎浜摼鎺� + * + * @param objectName + * @return + */ + public static String getShareUrl(String objectName) throws Exception { + // 鐢熸垚鍙瑙堢殑澶栭摼銆� + GeneratePresignedUrlRequest request = + new GeneratePresignedUrlRequest(bucketName, objectName); + + // 璁剧疆杩囨湡鏃堕棿锛屽綋鍒拌揪璇ユ椂闂寸偣鏃讹紝URL 灏变細杩囨湡锛屽叾浠栦汉涓嶅啀鑳借闂瀵硅薄锛圤bject锛夈�� + Date expiration = new Date(); +// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); +// expiration = simpleDateFormat.parse("2024/12/20 23:59:59"); + // 璁剧疆 7 澶╁悗杩囨湡銆� + long expTimeMillis = Instant.now().toEpochMilli(); + expTimeMillis += 1000 * 60 * 60 * 24 * 7; + expiration.setTime(expTimeMillis); + + request.setExpiration(expiration); + + // 璁剧疆杩斿洖澶� + // 璁剧疆涓� "inline" 鏃跺湪娴忚鍣ㄤ腑灞曠ず锛岃缃负 "attachment" 鏃朵互鏂囦欢褰㈠紡涓嬭浇銆� + // 姝ゅ璁剧疆涓� "attachment;filename=\"filename.jpg\"" 锛岃繕鍙互璁╀笅杞界殑鏂囦欢鍚嶅瓧閲嶅懡鍚嶄负 "filename.jpg"銆� + ResponseHeaderOverrides headerOverrides = new ResponseHeaderOverrides(); + headerOverrides.setContentDisposition("inline"); + request.setResponseHeaders(headerOverrides); + + URL url = client.generatePresignedUrl(request); + System.out.println(url); + return url.toString(); + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/CallBackUrl.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/CallBackUrl.java new file mode 100644 index 0000000..740cea8 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/CallBackUrl.java @@ -0,0 +1,64 @@ +package com.nuvole.util.pay.allinPay; + +/** + * 鏀粯鍥炶皟鍦板潃 + * + * @Author: lc + * @Date: 2019/8/27 14:57 + */ + +public class CallBackUrl { + + /** + * 鍟嗗煄缁熶竴鏀粯涓嬪崟鍥炶皟鍦板潃 + */ + public static String unifiedStoreGoodsPayUrl = "/v1/shop/web/payBack/storeGoodsPayBack"; + + /** + * 鍟嗗煄缁熶竴鏀粯涓嬪崟鍥炶皟鍦板潃 + */ + public static String storeShareFundRecordPayUrl = "/v1/shop/web/payBack/storeShareFundRecordCallBack"; + + /** + * 鍟嗗煄蹇嵎鏀粯涓嬪崟鍥炶皟鍦板潃 + */ + public static String shortcutStoreGoodsPayUrl = "/v1/shop/web/payBack/shortcutStoreGoodsPayBack"; + + /** + * 绾皬绋嬪簭鏀粯鍥炶皟鍦板潃 + */ + public static String xcxGoodsPayUrl = "/v1/shop/web/payBack/xcxGoodsPayBack"; + + /** + * 鏀堕摱瀹濅笅锛屽井淇℃敮浠楥鎵獴鎵爜浠�2.0鍥炶皟url + */ + public static String sybWxC2BPayUrl = "v1/web/payBack/sybScanPayGoodsPayBack"; + /** + * H5鎵爜鏀粯--閾惰鍗″揩鎹锋敮浠� 鍥炶皟 + */ + public static String sybKJPayUrl = "v1/web/payBack/scanPayGoodsSybPayBack"; + + /** + * psv涓烘敮浠樺疂鏃讹紝鏀粯瀹濇敮浠� C鎵獴鎵爜浠樺洖璋� + */ + public static String zfbC2BPayUrl = "v1/web/payBack/scanPayGoodsSybPayBack"; + + /** + * psv涓哄井淇℃椂锛屾敮浠樺疂鏀粯 C鎵獴鎵爜浠樺洖璋� + */ + public static String wxC2BPayUrl = "v1/web/payBack/scanPayGoodsPayBack"; + + + /** + * psv涓轰簯鍟嗛�氭椂锛� 鍟嗘埛绾夸笂寰俊鏀粯鍥炶皟 sc 鍟嗗煄 + */ + public static String ystScPayUrl = "v1/web/payBack/wechatMerchantBack"; + /** + * 鎻愮幇绛剧害閫氱煡(鎺ユ敹) + */ + public static String ystTxSignUrl = "v1/web/payBack/signAcctNotify"; + + + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/syb/SybPayCode.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/syb/SybPayCode.java new file mode 100644 index 0000000..10882ff --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/syb/SybPayCode.java @@ -0,0 +1,89 @@ +package com.nuvole.util.pay.allinPay.syb; + + +/** + * 閫氳仈浜ゆ槗鐘舵�佺爜锛堝揩鎹锋敮浠橈級 + * + * @author: lc + * @date锛� 鏃ユ湡锛�2018骞�11鏈�26鏃� 鏃堕棿锛氫笅鍗�1:45:46 + */ + +public class SybPayCode { + + //鍏朵綑3寮�澶寸殑閿欒,璇疯鍙杄rrmsg + + /** + * 浜ゆ槗鎴愬姛 + */ + public static final String PAY_MSG_0000 = "0000"; + + /** + * 闇�鑾峰彇鐭俊楠岃瘉鐮�,杩涜涓嬩竴姝ョ‘璁ゆ搷浣� + */ + public static final String PAY_MSG_1999 = "1999"; + + /** + * 浜ゆ槗宸插彈鐞嗭紙璇锋煡璇㈢粨鏋滐級 + */ + public static final String PAY_MSG_2000 = "2000"; + + /** + * 浜ゆ槗宸插彈鐞嗭紙璇锋煡璇㈢粨鏋滐級 + */ + public static final String PAY_MSG_2018 = "2000"; + + /** + * 浜ゆ槗寮傚父,璇锋煡璇氦鏄� + */ + public static final String PAY_MSG_3054 = "3054"; + + /** + * 浜ゆ槗寮傚父,璇锋煡璇氦鏄� + */ + public static final String PAY_MSG_3004 = "3004"; + + /** + * 鍘熶氦鏄撲笉鍏佽鎾ら攢鎴栭��璐� + */ + public static final String PAY_MSG_3012 = "3012"; + + /** + * 鍘熶氦鏄撲笉瀛樺湪 + */ + public static final String PAY_MSG_3035 = "3035"; + /** + * 鍘熶氦鏄撲笉瀛樺湪 + */ + public static final String PAY_MSG_1001 = "1001"; + /** + * 鍗忚涓嶅瓨鍦� + */ + public static final String PAY_MSG_3045 = "3045"; + + /** + * 鍗′俊鎭垨鎵嬫満鍙风爜閿欒 + */ + public static final String PAY_MSG_3046 = "3046"; + + /** + * 璇烽噸鏂拌幏鍙栭獙璇佺爜 + */ + public static final String PAY_MSG_3057 = "3057"; + + /** + * 鐭俊楠岃瘉鐮侀敊璇� + */ + public static final String PAY_MSG_3058 = "3058"; + + /** + * 鐭俊楠岃瘉鐮佸彂閫佸け璐� + */ + public static final String PAY_MSG_3059 = "3059"; + + /** + * 鍏朵粬閿欒 + */ + public static final String PAY_MSG_3999 = "3999"; + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/syb/SybPayUrl.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/syb/SybPayUrl.java new file mode 100644 index 0000000..5a1ec3a --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/syb/SybPayUrl.java @@ -0,0 +1,164 @@ +package com.nuvole.util.pay.allinPay.syb; + +/** + * 閫氳仈鏀粯鍦板潃锛堟敹閾跺疂锛� + * + * @Author: lc + * @Date: 2019/8/27 14:57 + */ + +public class SybPayUrl { + + + /** + * 鍟嗘埛璁㈠崟鏌ヨ鎺ュ彛 + */ + public static final String MERCHANT_PAY_RESULT = "https://vsp.allinpay.com/apiweb/tranx/queryorder"; + + /** + * 缁熶竴涓嬪崟鎺ュ彛 + */ + public static String UNIFIED_ORDER_URL = "https://vsp.allinpay.com/apiweb/unitorder/pay"; + + /** + * 閫氳仈鏀粯B鎵獵涓嬪崟鎺ュ彛鍦板潃 + */ + public static String ORDER_B_SWEEP_C_URL = "https://vsp.allinpay.com/apiweb/unitorder/scanqrpay"; + + //鏀堕摱瀹濊繘浠舵帴鍙e墠缂� +// private static String SYB_PREFIX = "https://vsp.allinpay.com/cusapi"; + private static String SYB_PREFIX = "https://syb-test.allinpay.com/vsppcusapi"; + /** + * 鏀堕摱鍖呭晢鎴疯繘浠禪RL + */ + public static String SYB_MERCHANT_ADD_URL = SYB_PREFIX + "/merchantapi/add"; + /** + * 鍟嗘埛瀹℃牳鐘舵�佹煡璇� + */ + public static String SYB_MERCHANT_ADD_QUERYSTATUS_URL = SYB_PREFIX + "/merchantapi/querystatus"; + /** + * 鍚堣鎬х姸鎬佹煡璇㈡帴鍙� + */ + public static String SYB_MERCHANT_ADD_QUERYCUSRGC_URL = SYB_PREFIX + "/merchantapi/querycusrgc"; + /** + * 鍚堣鎬у鏍歌ˉ褰曠粺涓�h5鎺ュ彛 + */ + public static String SYB_MERCHANT_ADD_REPAIRCUSRGC_URL = SYB_PREFIX + "/merchantapi/repaircusrgc"; + + /** + * 寰俊/鏀粯瀹濊璇佺姸鎬佹煡璇� + */ + public static String SYB_MERCHANT_ADD_QUERYWXVERIFYSTATE_URL = SYB_PREFIX + "/merchantapi/querywxverifystate"; + + /** + * 璁よ瘉缁熶竴H5 + */ + public static String SYB_MERCHANT_ADD_WXVERIFY_URL = SYB_PREFIX + "/merchantapi/wxverify"; + + /** + * 鏃犵焊鍖栬繘浠跺崗璁绾︾姸鎬佹煡璇� + */ + public static String SYB_MERCHANT_ADD_QUERYELECTSIGN_URL = SYB_PREFIX + "/merchantapi/queryelectsign"; + + /** + * 鏃犵焊鍖栬繘浠跺崗璁噸鍙戞帴鍙� + */ + public static String SYB_MERCHANT_ADD_ELECTSIGN_URL = SYB_PREFIX + "/merchantapi/electsign"; + /** + * 鏃犵焊鍖栬繘浠剁數瀛愬崗璁甎RL鎺ュ彛鏌ヨ + */ + public static String SYB_MERCHANT_ADD_QUERYELECTURL_URL = SYB_PREFIX + "/merchantapi/queryelecturl"; + /** + * 鏀堕摱瀹濇枃浠朵笂浼燯RL + */ + public static String SYB_FILE_UPLOAD_URL = SYB_PREFIX + "/sybupfile"; + + + /** + * 鏍规嵁鎺堟潈鐮�(浠樻鐮�)鑾峰彇鐢ㄦ埛ID 鍦板潃 + */ + public static final String SERVICE_AUTHCODE2USERID_URL = "https://vsp.allinpay.com/apiweb/unitorder/authcodetouserid"; + + /** + * 閫氳仈鏌ヨ鏀粯缁撴灉鎺ュ彛 + */ + public static String PAY__RESULT_B_SWEEP_C_URL = "https://vsp.allinpay.com/apiweb/unitorder/query"; + + /** + * 鍔ㄦ�丆鎵獴鏀粯鍥炶皟鍦板潃 + */ + public static String ACTIVE_C_SWEEP_B_URL_SYB = "/v1/web/payBack/activeCsweepBBack"; + public static String ACTIVE_C_SWEEP_B_URL_WX = "/v1/web/payBack/activeCsweepBBackWx"; + + /** + * 閫氳仈瀵归潰浠樻�诲叕鍙搁噸瀹氬悜鍦板潃 + */ + public static String F2F_HEAD_BACK_URL = "https://syb.allinpay.com/sappweb/usertrans/cuspay"; + + /** + * 閾惰仈浜戦棯浠樻巿鏉僽serid + */ + public static final String UNION_AUTH_URL = "https://vsp.allinpay.com/apiweb/unitorder/authcodetouserid"; + + /** + * 閾惰仈浜戦棯浠樻敮浠� + */ + public static final String UNION_PAY_URL = "https://vsp.allinpay.com/apiweb/unitorder/pay"; + + + /** + * 閫氳仈鎺ュ彛鍦板潃 + */ + public static String ALLINPAY_URL = "https://vsp.allinpay.com"; +// public static String ALLINPAY_URL = "https://syb-test.allinpay.com"; + + /** + * 鐢宠绛剧害锛堥�氳仈蹇嵎鏀粯锛� + */ + public static String AGREEAPPLY_URL = ALLINPAY_URL + "/apiweb/qpay/agreeapply"; + + /** + * 鐢宠纭锛堥�氳仈蹇嵎鏀粯锛� + */ + public static String AGREECONFIRM_URL = ALLINPAY_URL + "/apiweb/qpay/agreeconfirm"; + + /** + * 鏀粯鐢宠閲嶅彂楠岃瘉鐭俊锛堥�氳仈蹇嵎鏀粯锛� + */ + public static String AGREEMS_URL = ALLINPAY_URL + "/apiweb/qpay/agreesms"; + + /** + * 鏀粯鐢宠锛堥�氳仈蹇嵎鏀粯锛� + */ + public static String PAYAPPLYAGREE_URL = ALLINPAY_URL + "/apiweb/qpay/payapplyagree"; + + /** + * 鏀粯纭锛堥�氳仈蹇嵎鏀粯锛� + */ + public static String PAYAGREECONFIRM_URL = ALLINPAY_URL + "/apiweb/qpay/payagreeconfirm"; + + /** + * 閲嶅彂鏀粯鐭俊锛堥�氳仈蹇嵎鏀粯锛� + */ + public static String PAYSMSAGREE_URL = ALLINPAY_URL + "/apiweb/qpay/paysmsagree"; + + /** + * 鏌ヨ绛剧害淇℃伅锛堥�氳仈蹇嵎鏀粯锛� + */ + public static String AGREEQUERY_URL = ALLINPAY_URL + "/apiweb/qpay/agreequery"; + + /** + * 閾惰鍗¤В缁戯紙閫氳仈蹇嵎鏀粯锛� + */ + public static String UNBIND_URL = ALLINPAY_URL + "/apiweb/qpay/unbind"; + + /** + * 鏌ヨ浜ゆ槗缁撴灉 + */ + public static String QUERY_URL = ALLINPAY_URL + "/apiweb/qpay/query"; + + /** + * 鍟嗗煄鍥炶皟閫氱煡 + */ + public static String SHOP_CALL_BACK = "http://10.94.2.161:9010/service-shop/v1/shop/web/payBack/storeGoodsPayBack"; +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/syb/SybPayUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/syb/SybPayUtil.java new file mode 100644 index 0000000..66437d3 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/syb/SybPayUtil.java @@ -0,0 +1,1628 @@ +package com.nuvole.util.pay.allinPay.syb; + +import cn.hutool.core.convert.Convert; +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.digest.DigestUtil; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.nuvole.common.domain.emnu.CommonResultEmnu; +import com.nuvole.common.domain.result.CommonResult; +import com.nuvole.constants.PropertiesConstants; +import com.nuvole.constants.ServiceConstants; +import com.nuvole.util.IdGenerator; +import com.nuvole.util.pay.allinPay.syb.param.MerchantAddParam; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang.StringUtils; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.entity.mime.content.FileBody; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.bouncycastle.asn1.ASN1EncodableVector; +import org.bouncycastle.asn1.ASN1Integer; +import org.bouncycastle.asn1.DERSequence; +import org.bouncycastle.jcajce.spec.SM2ParameterSpec; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Field; +import java.math.BigInteger; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.security.*; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.X509EncodedKeySpec; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 閫氳仈鏀粯宸ュ叿绫伙紙鏀堕摱瀹濓級 + * + * @Author: lc + * @Date: 2019/8/27 14:57 + */ + +public class SybPayUtil { + + //鐗堟湰鍙� + private static final String version = "11"; + + //鏀粯淇℃伅 + private static final String k = PropertiesConstants.TL_PAY_K; + private static final String appId = PropertiesConstants.TL_PAY_APPID; + private static final String orgCode = PropertiesConstants.TL_PAY_ORGCODE; + + + //娴嬭瘯鐢ㄤ笅鍒楀弬鏁� + //蹇嵎鏀粯娴嬭瘯鐜鍙傛暟 + private static final String tlk = "allinpay888"; + private static final String tlappId = "00000051"; + private static final String tlCusId = "990581007426001"; + //蹇嵎鏀粯姝e紡鐜鎵�鐢ㄦ祴璇曞弬鏁� + /* private static final String tlk = "a0ea3fa20dbd7bb4d5abf1d59d63bae8"; + private static final String tlappId = "00000003"; + private static final String tlCusId = "990440148166000";*/ + + /**绠楁硶甯搁噺:SM3withSM2*/ + private static final String ALGORITHM_SM3SM2_BCPROV = "SM3withSM2"; + /** 绠楁硶甯搁噺:SM3鍔犲瘑闀垮害 */ + private final static int SM3withSM2_RS_LEN=32; + + /** + * 缁熶竴鏀粯 + * + * @param orgid:閫氳仈鏈烘瀯鍙� + * @param cusid:閫氳仈鍟嗘埛鍙� + * @param appid:閫氳仈appid + * @param sub_appid:寰俊鏀粯APPID, + * @param acct:鐢ㄦ埛鏍囪瘑锛堝井淇penid锛� + * @param trxamt:浜ゆ槗閲戦(鍒�) + * @param reqsn:鍟嗘埛浜ゆ槗鍗曞彿 + * @param paytype:浜ゆ槗鏂瑰紡锛圵01:寰俊 A01:鏀粯瀹濓級 + * @param notify_url:浜ゆ槗缁撴灉閫氱煡鍦板潃 + * @param key:鍟嗘埛瀵瑰簲鐨刱ey + * @param asinfo:鍒嗚处淇℃伅锛屽彲浠ヤ负绌� + * @param body:鏍囬 + * @param remark:澶囨敞 + * @Author: lc + * @Date: 2019/8/27 15:25 + */ + public static String unifiedOrder(String orgid, String cusid, String appid, String sub_appid, String acct, Integer trxamt, + String reqsn, String paytype, String notify_url, String key, String asinfo, String body, String remark) { + //缁勮鏁版嵁 + Map paramMap = new HashMap<String, String>(); + if (StrUtil.isNotEmpty(orgid)) { + paramMap.put("orgid", orgid); + } + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("trxamt", Convert.toStr(trxamt)); + paramMap.put("reqsn", reqsn); + paramMap.put("paytype", paytype); + paramMap.put("randomstr", IdGenerator.getUUID()); + if (StrUtil.isNotEmpty(body)) { + paramMap.put("body", body); + } + if (StrUtil.isNotEmpty(remark)) { + paramMap.put("remark", remark); + } + if (StrUtil.isNotEmpty(acct)) { + paramMap.put("acct", acct); + } + paramMap.put("notify_url", notify_url); + + paramMap.put("signtype", "RSA"); + + if (StrUtil.isNotEmpty(asinfo)) { + paramMap.put("asinfo", asinfo); + } + if (StrUtil.isNotEmpty(sub_appid)) { + paramMap.put("sub_appid", sub_appid); + } + + + paramMap.put("signtype", "RSA"); + String signStr = coverMap2String(paramMap); +// String sign = DigestUtil.md5Hex(signStr).toUpperCase(Locale.ENGLISH); +// paramMap.put("sign", sign); + String sign = null; + try { + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + + + paramMap.remove("key"); +// System.out.println("is param:" + JSONUtil.parseObj(paramMap)); + String result = ""; + if (ServiceConstants.SERVICE_TYPE) { //璧版湇鍔¤皟鐢� + String url = ServiceConstants.SERVICE_UNIFIED_URL; + result = HttpUtil.post(url, paramMap); + } else { + result = HttpUtil.post(SybPayUrl.UNIFIED_ORDER_URL, paramMap); + } + System.out.println("is result:" + result); + return result; + } + + /** + * 鏍规嵁鎺堟潈鐮�(浠樻鐮�)鑾峰彇鐢ㄦ埛ID + * 浣跨敤鍦烘櫙锛� + * 閫氳繃寰俊浠樻鐮佹崲鍙杘penid + * 閫氳繃閾惰仈userAuth鐨刢ode(闈炰粯娆剧爜)鎹㈠彇userid + * + * @param orgid:闆嗗洟/浠g悊鍟嗗晢鎴峰彿 + * @param cusid:閫氳仈鍟嗘埛鍙� + * @param appid:閫氳仈appid + * @param key:鍟嗘埛瀵瑰簲鐨刱ey + * @param authCode:鏀粯鎺堟潈鐮侊紙寰俊銆佹敮浠樺疂鐨勬巿鏉冪爜锛� + * @param authType:鎺堟潈鐮佺被鍨� 01-寰俊浠樻鐮� 02-閾惰仈userAuth + * @param identify:浜戦棯浠楿A鏍囪瘑 褰揳uthtype=02鏃堕�夐�� + * @param subAppid:寰俊鏀粯appid 閽堝01鏈夋晥 + */ + public static String authCode2Userid(String orgid, String cusid, String appid, String key, String authCode, String authType, String identify, String subAppid) { + + Map paramMap = new HashMap<String, String>(); + if (StrUtil.isNotEmpty(orgid)) { + paramMap.put("orgid", orgid); + } + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("authcode", authCode); + paramMap.put("authtype", authType); + if (StringUtils.isNotBlank(identify)) { + paramMap.put("identify", identify); + } + if (StringUtils.isNotBlank(subAppid)) { + paramMap.put("sub_appid", subAppid); + } + paramMap.put("randomstr", IdGenerator.getUUID()); + + paramMap.put("signtype", "RSA"); + String signStr = coverMap2String(paramMap); + String sign = null; + try { + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + paramMap.remove("key"); + System.out.println("鏍规嵁鎺堟潈鐮�(浠樻鐮�)鑾峰彇鐢ㄦ埛ID -->" + JSONUtil.toJsonStr(paramMap)); + String result = ""; + + //璧版湇鍔¤皟鐢� + if (ServiceConstants.SERVICE_TYPE) { + String url = ServiceConstants.SERVICE_AUTHCODE2USERID_URL; + result = HttpUtil.post(url, paramMap); + } else { + result = HttpUtil.post(SybPayUrl.SERVICE_AUTHCODE2USERID_URL, paramMap); + } + return result; + } + + /** + * B鎵獵鏀粯锛堝晢鎴锋壂鐢ㄦ埛锛� + * + * @param orgid:閫氳仈鏈烘瀯鍙� + * @param cusid:閫氳仈鍟嗘埛鍙� + * @param appid:閫氳仈appid + * @param key:鍟嗘埛瀵瑰簲鐨刱ey + * @param trxamt:浜ゆ槗閲戦(鍒�) + * @param reqsn:鍟嗘埛浜ゆ槗鍗曞彿 + * @param body:璁㈠崟鏍囬, + * @param remark:璁㈠崟澶囨敞 + * @param authcode:鏀粯鎺堟潈鐮侊紙寰俊銆佹敮浠樺疂鐨勬巿鏉冪爜锛� + * @param limit_pay:鏀粯闄愰 + * @Author: lc + * @Date: 2019/8/27 15:25 + */ + public static String orderBsweepC(String orgid, String cusid, String appid, String key, Integer trxamt, String reqsn, String body, String remark, String authcode, String limit_pay) { + + Map paramMap = new HashMap<String, String>(); + if (StrUtil.isNotEmpty(orgid)) { + paramMap.put("orgid", orgid); + } + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("trxamt", Convert.toStr(trxamt)); + paramMap.put("reqsn", reqsn); + + if (StrUtil.isNotEmpty(body)) { + paramMap.put("body", body); + } + if (StrUtil.isNotEmpty(remark)) { + paramMap.put("remark", remark); + } + paramMap.put("authcode", authcode); + + + if (StrUtil.isNotEmpty(body)) { + paramMap.put("body", body); + } + if (StrUtil.isNotEmpty(remark)) { + paramMap.put("remark", remark); + } + if (StrUtil.isNotEmpty(limit_pay)) { + paramMap.put("limit_pay", limit_pay); + } + + paramMap.put("signtype", "RSA"); + String signStr = coverMap2String(paramMap); + String sign = null; + try { + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + paramMap.remove("key"); + System.out.println("is tl b sweep c param -->" + JSONUtil.toJsonStr(paramMap)); + String result = ""; + + //璧版湇鍔¤皟鐢� + if (ServiceConstants.SERVICE_TYPE) { + String url = ServiceConstants.SERVICE_B_SWEEP_C_URL; + result = HttpUtil.post(url, paramMap); + } else { + result = HttpUtil.post(SybPayUrl.ORDER_B_SWEEP_C_URL, paramMap); + } + Map resultMap = JSON.parseObject(result); + if (null != resultMap && resultMap.size() > 0) { + //杩斿洖鐮�2000绛夊緟缁撴灉纭姣忛殧10绉掓墽琛岀粨鏋滄煡璇紝鏈�澶�4娆� + if ("2000".equals(resultMap.get("trxstatus") + "")) { + int index = 0; + final int count = 4; + do { + index++; + try { + result = getPayResult(orgid, cusid, appid, key, reqsn); + resultMap = JSON.parseObject(result); + Thread.sleep(10 * 1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } while (index < count && "2000".equals(resultMap.get("trxstatus") + "")); + } + } + return result; + } + + /** + * 鏌ヨ浜ゆ槗鏀粯缁撴灉 + * + * @param orgid 閫氳仈鏈烘瀯鍙� + * @param cusid 閫氳仈鍟嗘埛鍙� + * @param appid 閫氳仈appid + * @param key 鍟嗘埛瀵瑰簲鐨刱ey + * @param reqsn 鍟嗘埛浜ゆ槗鍗曞彿 + * @Author: lc + * @Date: 2019/8/27 15:25 + */ + public static String getPayResult(String orgid, String cusid, String appid, String key, String reqsn) { + //缁勮鏁版嵁 + Map paramMap = new HashMap(); + if (StrUtil.isNotEmpty(orgid)) { + paramMap.put("orgid", orgid); + } + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("reqsn", reqsn); + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("signtype", "RSA"); + String signStr = coverMap2String(paramMap); + String sign = null; + try { + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + paramMap.remove("key"); + String result = ""; + //璧版湇鍔¤皟鐢� + if (ServiceConstants.SERVICE_TYPE) { + String url = ServiceConstants.SERVICE_PAY_RESULT_URL; + result = HttpUtil.post(url, paramMap); + } else { + result = HttpUtil.post(SybPayUrl.PAY__RESULT_B_SWEEP_C_URL, paramMap); + } + System.out.println("is tl b sweep c 鏌ヨ浜ゆ槗缁撴灉 param -->" + JSONUtil.toJsonStr(paramMap)); + return result; + } + + private static String checkCardUrl = "https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?_input_charset=utf-8&cardBinCheck=true&cardNo="; + + /** + * 绛剧害鐢宠 + * + * @param key 绉橀挜 + * @param cusid 閫氳仈鍒嗛厤鐨勫晢鎴峰彿 + * @param appid 閫氳仈鍒嗛厤鐨刟ppid + * @param meruserid 鍟嗘埛鐢ㄦ埛鍙�(浼氬憳id) + * @param accttype 00:鍊熻鍗�02:鍑嗚捶璁板崱/璐疯鍗� + * @param acctno 閾惰鍗″彿 + * @param idno 璇佷欢鍙� + * @param acctname 鎴峰悕 + * @param mobile 鎵嬫満鍙风爜 + * @param validdate 鏈夋晥鏈烳Myy淇$敤鍗′笉鑳戒负绌� + * @param cvv2 Cvv2 淇$敤鍗′笉鑳戒负绌� + * @param signtype 鍔犲瘑鏂瑰紡 + * @Author: lc + * @Date: 2019/8/27 15:25 + */ + public static String agreeapply(String key, String cusid, String appid, + String meruserid, String accttype, String acctno, + String idno, String acctname, String mobile, String validdate, String cvv2 + , String signtype) { + Map paramMap = new HashMap(); + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + + paramMap.put("version", version); + paramMap.put("randomstr", IdGenerator.getUUID()); + +// 鍟嗘埛鐢ㄦ埛鍙� + paramMap.put("meruserid", meruserid); + //鍟嗘埛鐢ㄦ埛鍙� 00:鍊熻鍗� 02:鍑嗚捶璁板崱/璐疯鍗� + paramMap.put("accttype", accttype); + // 閾惰鍗″彿 + paramMap.put("acctno", acctno); + // 璇佷欢绫诲瀷 0:韬唤璇� 2:鎶ょ収 5:娓境閫氳璇� 6:鍙版咕閫氳璇� + paramMap.put("idtype", 0); + //璇佷欢鍙� + paramMap.put("idno", idno); + // 鎴峰悕 + paramMap.put("acctname", acctname); + // 鎵嬫満鍙风爜 + paramMap.put("mobile", mobile); + if ("02".equals(accttype)) { + paramMap.put("validdate", validdate); + paramMap.put("cvv2", cvv2); + } + paramMap.put("signtype", "RSA"); + + String signStr = null; + String sign = null; + try { + signStr = coverMap2String(paramMap); + System.out.println("signStr==>" + signStr); + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + + System.out.println("is agreeapply url:" + SybPayUrl.AGREEAPPLY_URL); + System.out.println("is agreeapply param:" + JSONUtil.toJsonStr(paramMap)); + System.out.println("is agreeapply sign:" + sign); + + String result = HttpUtil.post(SybPayUrl.AGREEAPPLY_URL, paramMap); + System.out.println("is agreeapply result:" + result); + return result; + } + + /** + * 閲嶅彂绛剧害鐭俊 + * + * @param key 绉橀挜 + * @param cusid 閫氳仈鍒嗛厤鐨勫晢鎴峰彿 + * @param appid 閫氳仈鍒嗛厤鐨刟ppid + * @param meruserid 鍟嗘埛鐢ㄦ埛鍙�(浼氬憳id) + * @param accttype 00:鍊熻鍗�02:鍑嗚捶璁板崱/璐疯鍗� + * @param acctno 閾惰鍗″彿 + * @param idno 璇佷欢鍙� + * @param acctname 鎴峰悕 + * @param mobile 鎵嬫満鍙风爜 + * @param validdate 鏈夋晥鏈烳Myy淇$敤鍗′笉鑳戒负绌� + * @param cvv2 Cvv2 淇$敤鍗′笉鑳戒负绌� + * @Author: lc + * @Date: 2019/8/27 15:25 + */ + public static String agreems(String key, String cusid, String appid, + String meruserid, String accttype, String acctno, String idno, + String acctname, String mobile, String validdate, String cvv2, String signtype) { + Map paramMap = new HashMap(); + if (PropertiesConstants.PAY_TYPE == 1) { + paramMap.put("appid", tlappId); +// paramMap.put("key", tlk); + key = tlk; + } else { + paramMap.put("appid", appid); +// paramMap.put("key", key); + } + paramMap.put("cusid", tlCusId); +// paramMap.put("version", version); + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("meruserid", meruserid); + paramMap.put("accttype", accttype); + paramMap.put("acctno", acctno); + paramMap.put("idno", idno); + paramMap.put("mobile", mobile); + paramMap.put("acctname", acctname); + if ("02".equals(accttype)) { + paramMap.put("validdate", validdate); + paramMap.put("cvv2", cvv2); + } + String signStr = coverMap2String(paramMap); + String sign = null; + if ("RSA".equals(signtype)) { + try { + sign = SybPayUtil.rsaSign(key, sign, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + paramMap.put("key", key); + sign = DigestUtil.md5Hex(signStr).toUpperCase(Locale.ENGLISH); + paramMap.remove("key"); + } + paramMap.put("sign", sign); + System.out.println("is agreeapply url:" + SybPayUrl.AGREEMS_URL); + System.out.println("is agreeapply param:" + JSONUtil.toJsonStr(paramMap)); + String result = HttpUtil.post(SybPayUrl.AGREEMS_URL, paramMap); + System.out.println("is agreeapply result:" + result); + return result; + } + + /** + * 瑙i櫎缁戝畾 + * + * @param key 绉橀挜 + * @param cusid 閫氳仈鍒嗛厤鐨勫晢鎴峰彿 + * @param appid 閫氳仈鍒嗛厤鐨刟ppid + * @param agreeid 鍗忚id + * @Author: lc + * @Date: 2019/8/27 15:25 + */ + public static String unbind(String key, String cusid, String appid, + String agreeid) { + Map paramMap = new HashMap(); + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("signtype", "RSA"); + paramMap.put("agreeid", agreeid); + + String signStr = coverMap2String(paramMap); + String sign = null; + try { + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + + System.out.println("is unbind url:" + SybPayUrl.UNBIND_URL); + System.out.println("is unbind param:" + JSONUtil.toJsonStr(paramMap)); + String result = HttpUtil.post(SybPayUrl.UNBIND_URL, paramMap); + System.out.println("is unbind result:" + result); + return result; + } + + /** + * 绛剧害鐢宠纭 + * + * @param key 绉橀挜 + * @param cusid 閫氳仈鍒嗛厤鐨勫晢鎴峰彿 + * @param appid 閫氳仈鍒嗛厤鐨刟ppid + * @param meruserid 鍟嗘埛鐢ㄦ埛鍙�(浼氬憳id) + * @param accttype 00:鍊熻鍗�02:鍑嗚捶璁板崱/璐疯鍗� + * @param acctno 閾惰鍗″彿 + * @param idno 璇佷欢鍙� + * @param acctname 鎴峰悕 + * @param mobile 鎵嬫満鍙风爜 + * @param validdate 鏈夋晥鏈烳Myy淇$敤鍗′笉鑳戒负绌� + * @param cvv2 Cvv2 淇$敤鍗′笉鑳戒负绌� + * @param code 鐭俊楠岃瘉鐮� + * @param thpinfo 閫忎紶淇℃伅锛堢绾︾敵璇锋帴鍙h繑鍥烇級 + * @Author: lc + * @Date: 2019/8/27 15:25 + */ + public static String agreeconfirm(String key, String cusid, String appid, + String meruserid, String accttype, String acctno, + String idno, String acctname, String mobile, String validdate, + String cvv2, String code, String thpinfo, String signtype) { + Map paramMap = new HashMap(); + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("randomstr", IdGenerator.getUUID()); + + paramMap.put("meruserid", meruserid); + paramMap.put("accttype", accttype); + paramMap.put("acctno", acctno); + paramMap.put("idtype", "0"); + paramMap.put("idno", idno); + paramMap.put("acctname", acctname); + paramMap.put("mobile", mobile); + paramMap.put("smscode", code); + if (StrUtil.isNotEmpty(thpinfo)) { + paramMap.put("thpinfo", thpinfo); + } + if ("02".equals(accttype)) { + paramMap.put("validdate", validdate); + paramMap.put("cvv2", cvv2); + } + paramMap.put("signtype", "RSA"); + + String signStr = null; + String sign = null; + if ("RSA".equals(signtype)) { + try { + signStr = coverMap2String(paramMap); + System.out.println("signStr==>" + signStr); + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + paramMap.put("key", key); + signStr = coverMap2String(paramMap); + sign = DigestUtil.md5Hex(signStr).toUpperCase(Locale.ENGLISH); + paramMap.remove("key"); + } + paramMap.put("sign", sign); + + System.out.println("is agreeconfirm url:" + SybPayUrl.AGREEAPPLY_URL); + System.out.println("is agreeconfirm param:" + JSONUtil.toJsonStr(paramMap)); + System.out.println("is agreeconfirm sign:" + sign); + + + String result = HttpUtil.post(SybPayUrl.AGREECONFIRM_URL, paramMap); + System.out.println("is agreeconfirm result:" + result); + return result; + } + + /** + * 鏀粯鐢宠 + * + * @param key 绉橀挜 + * @param cusid 閫氳仈鍒嗛厤鐨勫晢鎴峰彿 + * @param appid 閫氳仈鍒嗛厤鐨刟ppid + * @param orderid 璁㈠崟id + * @param agreeid 鍗忚id + * @param amount 閲戦锛堝崟浣嶅垎锛� + * @param subject 璁㈠崟鐨勫睍绀烘爣棰� + * @param notifyurl 浜ゆ槗缁撴灉閫氱煡鍦板潃 + * @Author: lc + * @Date: 2019/8/27 15:25 + */ + public static String payapplyagree(String key, String cusid, String appid, + String orderid, String agreeid, String amount, + String subject, String notifyurl) { + Map paramMap = new HashMap(); + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("signtype", "RSA"); + paramMap.put("reqsn", orderid); + paramMap.put("agreeid", agreeid); + paramMap.put("amount", amount); + paramMap.put("currency", "CNY"); + paramMap.put("subject", subject); + paramMap.put("notifyurl", notifyurl); + + String signStr = null; + String sign = null; + try { + signStr = coverMap2String(paramMap); + System.out.println("signStr==>" + signStr); + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + System.out.println("is payapplyagree url:" + SybPayUrl.PAYAPPLYAGREE_URL); + System.out.println("is payapplyagree param:" + JSONUtil.toJsonStr(paramMap)); + String result = HttpUtil.post(SybPayUrl.PAYAPPLYAGREE_URL, paramMap); + System.out.println("is payapplyagree result:" + result); + return result; + } + + /** + * 鏀粯纭 + * + * @param key 绉橀挜 + * @param cusid 閫氳仈鍒嗛厤鐨勫晢鎴峰彿 + * @param appid 閫氳仈鍒嗛厤鐨刟ppid + * @param orderid 璁㈠崟id + * @param agreeid 鍗忚id + * @param smscode 鐭俊鏀粯楠岃瘉鐮� + * @param thpinfo 閫忎紶淇℃伅锛堟敮浠樼敵璇锋帴鍙h繑鍥烇級 + * @Author: lc + * @Date: 2019/8/27 15:25 + */ + public static String payagreeconfirm(String key, String cusid, String appid, + String orderid, String agreeid, String smscode, String thpinfo) { + Map paramMap = new HashMap(); + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("signtype", "RSA"); + paramMap.put("reqsn", orderid); + paramMap.put("agreeid", agreeid); + paramMap.put("smscode", smscode); + if (StrUtil.isNotEmpty(thpinfo)) { + paramMap.put("thpinfo", thpinfo); + } + String signStr = coverMap2String(paramMap); + String sign = null; + try { + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + + paramMap.put("sign", sign); + System.out.println("is payagreeconfirm url:" + SybPayUrl.PAYAGREECONFIRM_URL); + System.out.println("is payagreeconfirm param:" + JSONUtil.toJsonStr(paramMap)); + String result = HttpUtil.post(SybPayUrl.PAYAGREECONFIRM_URL, paramMap); + System.out.println("is payagreeconfirm result:" + result); + return result; + } + + /** + * 閲嶅彂鏀粯鐭俊 + * + * @param key 绉橀挜 + * @param cusid 閫氳仈鍒嗛厤鐨勫晢鎴峰彿 + * @param appid 閫氳仈鍒嗛厤鐨刟ppid + * @param orderid 璁㈠崟id + * @param agreeid 鍗忚id + * @param thpinfo 浜ゆ槗閫忎紶淇℃伅锛堟敮浠樼敵璇锋帴鍙h繑鍥烇級 + * @Author: lc + * @Date: 2019/8/27 15:25 + */ + public static String paysmsagree(String key, String cusid, String appid, String orderid, String agreeid, String thpinfo) { + Map paramMap = new HashMap(); + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("signtype", "RSA"); + paramMap.put("orderid", orderid); + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("agreeid", agreeid); + + if (StrUtil.isNotEmpty(thpinfo)) { + paramMap.put("thpinfo", thpinfo); + } + String signStr = coverMap2String(paramMap); + String sign = null; + try { + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + System.out.println("is paysmsagree url:" + SybPayUrl.PAYSMSAGREE_URL); + System.out.println("is paysmsagree param:" + JSONUtil.toJsonStr(paramMap)); + String result = HttpUtil.post(SybPayUrl.PAYSMSAGREE_URL, paramMap); + System.out.println("is paysmsagree result:" + result); + return result; + } + + /** + * 鏌ヨ浜ゆ槗缁撴灉 + * + * @param key 绉橀挜 + * @param cusid 閫氳仈鍒嗛厤鐨勫晢鎴峰彿 + * @param appid 閫氳仈鍒嗛厤鐨刟ppid + * @param orderid 璁㈠崟id + * @param transactionId 骞冲彴璁㈠崟 + */ + public static String query(String key, String cusid, String appid, + String orderid, String transactionId) { + Map paramMap = new HashMap(); + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("reqsn", orderid); + //鏀堕摱瀹濅氦鏄撳崟鍙� + paramMap.put("trxid", transactionId); + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("signtype", "RSA"); + + String signStr = coverMap2String(paramMap); + String sign = null; + try { + sign = SybPayUtil.rsaSign(key, signStr, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + + paramMap.put("sign", sign); + String result = HttpUtil.post(SybPayUrl.QUERY_URL, paramMap); + System.out.println("is query result:" + result); + return result; + } + + /** + * 灏哅ap涓殑鏁版嵁杞崲鎴愭寜鐓ey鐨刟scii鐮佹帓搴忓悗鐨刱ey1=value1&key2=value2鐨勫舰寮� + * + * @param data + * @return + */ + private static String coverMap2String(Map<String, String> data) { + TreeMap<String, String> tree = new TreeMap<String, String>(); + Iterator<Map.Entry<String, String>> it = data.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry<String, String> en = it.next(); + tree.put(en.getKey(), en.getValue()); + } + it = tree.entrySet().iterator(); + StringBuffer sf = new StringBuffer(512); + while (it.hasNext()) { + Map.Entry<String, String> en = it.next(); + String value = en.getValue(); + if (StringUtils.isBlank(value)) { + continue; + } + sf.append(en.getKey() + "=" + Convert.toStr(value) + + "&"); + } + return sf.substring(0, sf.length() - 1); + } + + public static String getMerchantPayResult(String appId, String cusId, String key, String id, Date createTime, String orgId) { + //缁勮鏁版嵁 + Map paramMap = new HashMap(); + if (PropertiesConstants.PAY_TYPE == 1) { + paramMap.put("appid", tlappId); + } else { + paramMap.put("appid", appId); + } + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("cusid", cusId); + paramMap.put("resendnotify", "0"); + paramMap.put("signtype", "MD5"); + paramMap.put("orderid", id); + paramMap.put("orgid", orgId); + DateFormat format = new SimpleDateFormat("MMdd"); + paramMap.put("trxdate", format.format(createTime)); + paramMap.put("key", key); + String signStr = coverMap2String(paramMap); + String sign = DigestUtil.md5Hex(signStr).toUpperCase(Locale.ENGLISH); + paramMap.put("sign", sign); + paramMap.remove("key"); + String result = ""; + System.out.println(paramMap.toString()); + //璧版湇鍔¤皟鐢� + if (ServiceConstants.SERVICE_TYPE) { + String url = ServiceConstants.MERCHANT_PAY_RESULT; + result = HttpUtil.post(url, paramMap); + } else { + result = HttpUtil.post(SybPayUrl.MERCHANT_PAY_RESULT, paramMap); + } + System.out.println(result); + return result; + } + + /** + * 鍟嗗煄鏀粯鎵嬪姩鍥炶皟 + * + * @param cusorderid + * @param trxid + * @param trxstatus + */ + public static void callBack(String cusorderid, String trxid, String trxstatus) { + String url = SybPayUrl.SHOP_CALL_BACK; + HashMap paramMap = new HashMap(); + paramMap.put("cusorderid", cusorderid); + paramMap.put("trxid", trxid); + paramMap.put("trxstatus", trxstatus); + HttpUtil.get(url, paramMap); + } + + public static PrivateKey getPrivateKeyFromPKCS8(String algorithm, + byte[] encodedKey) throws Exception { + + KeyFactory keyFactory = KeyFactory.getInstance(algorithm); + + return keyFactory.generatePrivate(new PKCS8EncodedKeySpec(encodedKey)); + } + + public static String rsaSign(String content, String privateKey, + String charset) throws Exception { + PrivateKey priKey = getPrivateKeyFromPKCS8("RSA", + org.apache.commons.codec.binary.Base64.decodeBase64(privateKey.getBytes())); + return rsaSign(content, priKey, charset); + } + + public static String rsaSign(String content, byte[] privateKey, + String charset) throws Exception { + PrivateKey priKey = getPrivateKeyFromPKCS8("RSA", privateKey); + return rsaSign(content, priKey, charset); + } + + public static String rsaSign(String content, PrivateKey priKey, + String charset) throws Exception { + Signature signature = Signature + .getInstance("SHA1WithRSA"); + signature.initSign(priKey); + if (charset == null || "".equals(charset)) { + signature.update(content.getBytes()); + } else { + signature.update(content.getBytes(charset)); + } + byte[] signed = signature.sign(); + String signStr = new String(Base64.encodeBase64(signed)); + System.out.println("鏄庢枃锛�" + content); + System.out.println("瀵嗘枃锛�" + signStr); + return signStr; + } + + /** + * 鍒ゆ柇鏄惁浣嶄俊鐢ㄥ崱 + * + * @param cardNo + * @return true 淇$敤鍗� false 鍌ㄨ搫鍗� null 鍗″彿涓嶆纭� + */ + public static Boolean checkCardType(String cardNo) { + String resp = HttpUtil.get(checkCardUrl + cardNo, 30000); + System.out.println(resp); + try { + JSONObject jsonObject = JSONObject.parseObject(resp); + if (jsonObject.getBooleanValue("validated")) { + return "CC".equals(jsonObject.getString("cardType")); + } + return null; + } catch (Exception e) { + return null; + } + } + + /** + * 鍟嗘埛杩涗欢 + * + * @param merchantAddParam + * @param key 鍟嗘埛瀵瑰簲鐨刱ey + * @return + */ + public static CommonResult merchantAdd(MerchantAddParam merchantAddParam, String key) { + CommonResult validResult + = validMerchantAddParam(merchantAddParam); + if (validResult.getStatus() == CommonResult.STATUS_ERR) { + return validResult; + } + Map paramMap = new HashMap<String, String>(); + Field[] merchantAddFields = MerchantAddParam.class.getDeclaredFields(); + try { + for (Field field : merchantAddFields) { + String fieldName = field.getName(); + field.setAccessible(true); + Object o = field.get(merchantAddParam); + if (o != null) { + paramMap.put(fieldName, o); + } + } + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("signtype", "RSA"); + paramMap.put("version", version); + + String signStr = coverMap2String(paramMap); + String sign = null; + try { + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + paramMap.remove("key"); + System.out.println("鍟嗘埛杩涗欢鍙傛暟 -->" + JSONUtil.toJsonStr(paramMap)); + System.out.println("鍟嗘埛杩涗欢鍙傛暟 signStr -->" + signStr); + String result = ""; + result = HttpUtil.post(SybPayUrl.SYB_MERCHANT_ADD_URL, paramMap); + System.out.println("鍟嗘埛杩涗欢杩斿洖鍊� -->" + result); + Map resultMap = JSON.parseObject(result); + String retcode = Convert.toStr(resultMap.get("retcode")); + if ("success".equalsIgnoreCase(retcode)) { + + return new CommonResult(result); + } else { + return new CommonResult(CommonResultEmnu.ERROR, Convert.toStr(resultMap.get("retmsg"))); + } + } + + /*** + * 鍟嗘埛瀹℃牳鐘舵�佹煡璇� + * @param + * @param merchantid 涓氬姟绯荤粺鐨刬d + * @return + */ + public static CommonResult<Map<String, String>> merchantAddStatusQuery(String orgid, String cusid, String appid, String key, String merchantid) { + Map paramMap = new HashMap<String, String>(); + paramMap.put("orgid", orgid); + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("signtype", "RSA"); + paramMap.put("merchantid", merchantid); + + String signStr = coverMap2String(paramMap); + String sign = null; + try { + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + paramMap.remove("key"); + System.out.println("鍟嗘埛杩涗欢 鍟嗘埛瀹℃牳鐘舵�� 鏌ヨ鍙傛暟 -->" + JSONUtil.toJsonStr(paramMap)); + String result = ""; + result = HttpUtil.post(SybPayUrl.SYB_MERCHANT_ADD_QUERYSTATUS_URL, paramMap); + System.out.println("鍟嗘埛杩涗欢 鍟嗘埛瀹℃牳鐘舵�� 杩斿洖鍊� -->" + result); + Map resultMap = JSON.parseObject(result); + String retcode = Convert.toStr(resultMap.get("retcode")); + if ("success".equalsIgnoreCase(retcode)) { + return new CommonResult(resultMap); + } else { + return new CommonResult(CommonResultEmnu.ERROR, Convert.toStr(resultMap.get("retmsg"))); + } + } + + /** + * 2.20 寰俊/鏀粯瀹濊璇佺姸鎬佹煡璇� + * + * @param orgid + * @param cusid + * @param appid + * @param key + * @param chnltype 娓犻亾绫诲瀷 浣跨敤涓枃澶у啓缂╁啓 寰俊锛歐XP 鏀粯瀹�:ALP + * @param pid 浜у搧绫诲瀷 P0001銆丳0002銆丳0003 ==> 鏀堕摱瀹濄�佸綋闈粯銆佺綉涓婃敹閾� + * @return + */ + public static CommonResult<Map<String, String>> merchantAddQueryWxVerifyState(String orgid, String cusid, String appid, String key, String chnltype, String pid) { + Map paramMap = new HashMap<String, String>(); + paramMap.put("orgid", orgid); + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("signtype", "RSA"); + paramMap.put("chnltype", chnltype); + + if (StringUtils.isNotBlank(pid)) { + paramMap.put("pid", pid); + } + String signStr = coverMap2String(paramMap); + String sign = null; + try { + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + paramMap.remove("key"); + System.out.println("寰俊/鏀粯瀹濊璇佺姸鎬佹煡璇� 鏌ヨ鍙傛暟 -->" + JSONUtil.toJsonStr(paramMap)); + String result = ""; + result = HttpUtil.post(SybPayUrl.SYB_MERCHANT_ADD_QUERYWXVERIFYSTATE_URL, paramMap); + System.out.println("寰俊/鏀粯瀹濊璇佺姸鎬佹煡璇� 杩斿洖鍊� -->" + result); + Map resultMap = JSON.parseObject(result); + String retcode = Convert.toStr(resultMap.get("retcode")); + if ("success".equalsIgnoreCase(retcode)) { + return new CommonResult(resultMap); + } else { + return new CommonResult(CommonResultEmnu.ERROR, Convert.toStr(resultMap.get("retmsg"))); + } + } + + /*** + * 鐢ㄤ簬瀵瑰弬鏁扮鍚嶏紝鐢熸垚鍙闂殑鏀堕摱鍖卽rl + * 鍚堣鎬у鏍歌ˉ褰曠粺涓�h5鎺ュ彛 銆� 璁よ瘉缁熶竴H5 鍏辩敤 + * @param + * @return + */ + public static String merchantAddUrlSign(String orgid, String cusid, String appid, String key, String urlPrefix, String userid, String notifyurl, String pagetype) { + Map paramMap = new HashMap<String, String>(); + paramMap.put("orgid", orgid); + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("signtype", "RSA"); + + if (StringUtils.isNotBlank(userid)) { + paramMap.put("userid", userid); + } + if (StringUtils.isNotBlank(notifyurl)) { + paramMap.put("notifyurl", notifyurl); + } + if (StringUtils.isNotBlank(pagetype)) { + paramMap.put("pagetype", pagetype); + } + + String signStr = coverMap2String(paramMap); + String sign = null; + try { + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + paramMap.remove("key"); + System.out.println("url绛惧悕 鏌ヨ鍙傛暟 -->" + JSONUtil.toJsonStr(paramMap)); + String result = urlPrefix + "?" + signStr + "&sign=" + sign; + return result; + } + + + /*** + * 鏃犵焊鍖栬繘浠跺崗璁绾︾姸鎬佹煡璇� + * @param electsigntype 01/03 01琛ㄧず鏀堕摱瀹濅笟鍔″崗璁� 03琛ㄧず缁撶畻濮旀墭鍗忚锛堝晢鎴锋�ц川鏄紒涓氫笖缁撶畻璐︽埛瀵圭锛� + * @return + */ + public static CommonResult<Map<String, String>> merchantElectSignQuery(String orgid, String cusid, String appid, String key, String electsigntype) { + Map paramMap = new HashMap<String, String>(); + paramMap.put("orgid", orgid); + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("signtype", "RSA"); + paramMap.put("electsigntype", electsigntype); + + String signStr = coverMap2String(paramMap); + String sign = null; + try { + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + paramMap.remove("key"); + System.out.println("鏃犵焊鍖栬繘浠跺崗璁绾︾姸鎬佹煡璇� 鏌ヨ鍙傛暟 -->" + JSONUtil.toJsonStr(paramMap)); + String result = ""; + result = HttpUtil.post(SybPayUrl.SYB_MERCHANT_ADD_QUERYELECTSIGN_URL, paramMap); + System.out.println("鏃犵焊鍖栬繘浠跺崗璁绾︾姸鎬佹煡璇� 杩斿洖鍊� -->" + result); + Map resultMap = JSON.parseObject(result); + String retcode = Convert.toStr(resultMap.get("retcode")); + if ("success".equalsIgnoreCase(retcode)) { + return new CommonResult(resultMap); + } else { + return new CommonResult(CommonResultEmnu.ERROR, Convert.toStr(resultMap.get("retmsg"))); + } + } + + /** + * 鍚堣鎬х姸鎬佹煡璇㈡帴鍙� + * 鍟嗘埛鍚堣鎬х姸鎬佹煡璇紝鏍规嵁閫氳仈鍟嗘埛鍙锋煡璇㈠晢鎴峰搴斿悎瑙勬�х姸鎬� + * + * @param orgid + * @param cusid + * @param appid + * @param key + * @return + */ + public static CommonResult<Map<String, String>> merchantAddQueryCusrGc(String orgid, String cusid, String appid, String key) { + Map paramMap = new HashMap<String, String>(); + paramMap.put("orgid", orgid); + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("signtype", "RSA"); + + String signStr = coverMap2String(paramMap); + String sign = null; + try { + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + paramMap.remove("key"); + System.out.println("鍚堣鎬х姸鎬佹煡璇㈡帴鍙� 鏌ヨ鍙傛暟 -->" + JSONUtil.toJsonStr(paramMap)); + String result = ""; + result = HttpUtil.post(SybPayUrl.SYB_MERCHANT_ADD_QUERYCUSRGC_URL, paramMap); + System.out.println("鍚堣鎬х姸鎬佹煡璇㈡帴鍙� 杩斿洖鍊� -->" + result); + Map resultMap = JSON.parseObject(result); + String retcode = Convert.toStr(resultMap.get("retcode")); + if ("success".equalsIgnoreCase(retcode)) { + return new CommonResult(resultMap); + } else { + return new CommonResult(CommonResultEmnu.ERROR, Convert.toStr(resultMap.get("retmsg"))); + } + } + + /*** + * 鏃犵焊鍖栬繘浠跺崗璁噸鍙戞帴鍙� + * @return + */ + public static CommonResult<Map<String, String>> merchantElectSign(String orgid, String cusid, String appid, String key) { + Map paramMap = new HashMap<String, String>(); + paramMap.put("orgid", orgid); + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("signtype", "RSA"); + + String signStr = coverMap2String(paramMap); + String sign = null; + try { + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + paramMap.remove("key"); + System.out.println("鏃犵焊鍖栬繘浠跺崗璁噸鍙戞帴鍙� 鏌ヨ鍙傛暟 -->" + JSONUtil.toJsonStr(paramMap)); + String result = ""; + result = HttpUtil.post(SybPayUrl.SYB_MERCHANT_ADD_ELECTSIGN_URL, paramMap); + System.out.println("鏃犵焊鍖栬繘浠跺崗璁噸鍙戞帴鍙� 杩斿洖鍊� -->" + result); + Map resultMap = JSON.parseObject(result); + String retcode = Convert.toStr(resultMap.get("retcode")); + if ("success".equalsIgnoreCase(retcode)) { + return new CommonResult(resultMap); + } else { + return new CommonResult(CommonResultEmnu.ERROR, Convert.toStr(resultMap.get("retmsg"))); + } + + } + + /** + * 鏃犵焊鍖栬繘浠剁數瀛愬崗璁甎RL鎺ュ彛鏌ヨ + * + * @param orgid + * @param cusid + * @param appid + * @param key + * @return + */ + public static CommonResult merchantQueryElecturl(String orgid, String cusid, String appid, String key, String redirecturl) { + Map paramMap = new HashMap<String, String>(); + paramMap.put("orgid", orgid); + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("signtype", "RSA"); + paramMap.put("redirecturl", redirecturl); + + String signStr = coverMap2String(paramMap); + String sign = null; + try { + sign = SybPayUtil.rsaSign(signStr, key, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + paramMap.remove("key"); + System.out.println("鏃犵焊鍖栬繘浠剁數瀛愬崗璁甎RL鎺ュ彛鏌ヨ 鏌ヨ鍙傛暟 -->" + JSONUtil.toJsonStr(paramMap)); + String result = ""; + result = HttpUtil.post(SybPayUrl.SYB_MERCHANT_ADD_QUERYELECTURL_URL, paramMap); + System.out.println("鏃犵焊鍖栬繘浠剁數瀛愬崗璁甎RL鎺ュ彛鏌ヨ 杩斿洖鍊� -->" + result); + Map resultMap = JSON.parseObject(result); + String retcode = Convert.toStr(resultMap.get("retcode")); + if ("success".equalsIgnoreCase(retcode)) { + return new CommonResult(result); + } else { + return new CommonResult(CommonResultEmnu.ERROR, Convert.toStr(resultMap.get("retmsg"))); + } + } + + + private static CommonResult validMerchantAddParam(MerchantAddParam merchantAddParam) { + if (merchantAddParam == null) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS); + } + if (StringUtils.isBlank(merchantAddParam.getRandomstr())) { + merchantAddParam.setRandomstr(IdGenerator.getUUID()); + } + if (StringUtils.isBlank(merchantAddParam.getSigntype())) { + merchantAddParam.setSigntype("RSA"); + } + // *鍟嗘埛鎬ц川 + //1.浼佷笟 3.涓綋鎴� 4.涓汉 6.浜嬩笟鍗曚綅 + String comproperty = merchantAddParam.getComproperty(); + if (StringUtils.isBlank(comproperty)) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鍟嗘埛鎬ц川闇�瑕佸~鍐�"); + } + //鍟嗘埛鎬ц川涓轰紒涓� +// if ("1".equals(comproperty)) { +// if (StringUtils.isBlank(merchantAddParam.getPubacctinfo())) { +// return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鍟嗘埛鎬ц川涓轰紒涓氭椂闇�瑕佸~鍐欏鍏处鎴蜂俊鎭�"); +// } +// } + //鍟嗘埛鎬ц川涓轰釜浜烘椂蹇呭~ + if ("4".equals(comproperty)) { + if (StringUtils.isBlank(merchantAddParam.getLegalpic())) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鍟嗘埛鎬ц川闈炰釜浜烘椂闇�瑕佷笂浼犵粡钀ヨ�呮墜鎸佽韩浠借瘉鐓х墖"); + } + } + if (!"4".equals(comproperty)) { + if (StringUtils.isBlank(merchantAddParam.getCorpbusname())) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鍟嗘埛鎬ц川闈炰釜浜烘椂闇�瑕佸~鍐欒惀涓氭墽鐓у悕绉�"); + } + if (StringUtils.isBlank(merchantAddParam.getCreditcode())) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鍟嗘埛鎬ц川闈炰釜浜烘椂闇�瑕佸~鍐欑粺涓�绀句細淇$敤浠g爜璇�"); + } + if (StringUtils.isBlank(merchantAddParam.getCreditcodeexpire())) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鍟嗘埛鎬ц川闈炰釜浜烘椂闇�瑕佸~鍐欑ぞ浼氫俊鐢ㄤ唬鐮佽瘉鏈夋晥鏈�"); + } + if (StringUtils.isBlank(merchantAddParam.getCorpbuspic())) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鍟嗘埛鎬ц川闈炰釜浜烘椂闇�瑕佸~鍐欒惀涓氭墽鐓х収鐗�"); + } + + if (StringUtils.isBlank(merchantAddParam.getBusconactperson())) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鍟嗘埛鎬ц川闈炰釜浜烘椂闇�瑕佸~鍐欎笟鍔¤仈绯讳汉濮撳悕"); + } + if (StringUtils.isBlank(merchantAddParam.getBusconacttel())) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鍟嗘埛鎬ц川闈炰釜浜烘椂闇�瑕佸~鍐欎笟鍔¤仈绯讳汉鐢佃瘽"); + } + } + + //鍟嗘埛鎬ц川涓轰紒涓氥�佷釜浣撴埛鏃跺繀濉� + if ("1".equals(comproperty) || "3".equals(comproperty)) { + if (StringUtils.isBlank(merchantAddParam.getHoldername())) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鍟嗘埛鎬ц川涓轰紒涓氥�佷釜浣撴埛鏃堕渶瑕佸~鍐欐帶鑲¤偂涓滃鍚�"); + } + if (StringUtils.isBlank(merchantAddParam.getHolderidno())) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鍟嗘埛鎬ц川涓轰紒涓氥�佷釜浣撴埛鏃堕渶瑕佸~鍐欐帶鑲¤偂涓滆韩浠借瘉"); + } + if (StringUtils.isBlank(merchantAddParam.getHolderexpire())) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鍟嗘埛鎬ц川涓轰紒涓氥�佷釜浣撴埛鏃堕渶瑕佸~鍐欐帶鑲¤偂涓滄湁鏁堟湡"); + } + if (StringUtils.isBlank(merchantAddParam.getRegisterfund())) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鍟嗘埛鎬ц川涓轰紒涓氥�佷釜浣撴埛鏃堕渶瑕佸~鍐欐敞鍐岃祫鏈�"); + } + if (StringUtils.isBlank(merchantAddParam.getStafftotal())) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鍟嗘埛鎬ц川涓轰紒涓氥�佷釜浣撴埛鏃堕渶瑕佸~鍐欏憳宸ヤ汉鏁�"); + } + if (StringUtils.isBlank(merchantAddParam.getOperatelimit())) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鍟嗘埛鎬ц川涓轰紒涓氥�佷釜浣撴埛鏃堕渶瑕佸~鍐欑粡钀ュ尯鍩�"); + } + if (StringUtils.isBlank(merchantAddParam.getInspect())) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鍟嗘埛鎬ц川涓轰紒涓氥�佷釜浣撴埛鏃堕渶瑕佸~鍐欑粡钀ュ湴娈�"); + } + + } +// if (StringUtils.isBlank(merchantAddParam.getAddfacusid())) { +// return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "鎵�鍦ㄦ満鏋勮祫閲戝綊闆嗘椂锛岃瀛楁涓嶈兘涓虹┖"); +// } + + // 缁撶畻璐︽埛 0-瀵圭 1-瀵瑰叕 + String accttype = merchantAddParam.getAccttype(); + if (StringUtils.isBlank(accttype)) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "缁撶畻璐︽埛绫诲瀷涓嶈兘涓虹┖"); + } + if ("0".equals(accttype)) { + if (StringUtils.isBlank(merchantAddParam.getSettidno())) { + return new CommonResult(CommonResultEmnu.INVALID_PARAMS, "缁撶畻璐︽埛瀵圭鏃讹紝缁撶畻浜鸿韩浠借瘉鍙蜂笉鑳戒负绌�"); + } + } + return new CommonResult(); + } + + public static CommonResult<Map> uploadfile(String orgid, String cusid, String appid, String key, String ftpFilePath) throws Exception { + Map paramMap = new HashMap(); + paramMap.put("orgid", orgid); + paramMap.put("cusid", cusid); + paramMap.put("appid", appid); + paramMap.put("version", version); + + paramMap.put("randomstr", IdGenerator.getUUID()); + paramMap.put("signtype", "RSA"); + paramMap.put("filetype", "jpg"); + + String signStr = coverMap2String(paramMap); + String sign = null; + try { + sign = SybPayUtil.rsaSign(key, signStr, "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } + paramMap.put("sign", sign); + + System.out.println("涓婁紶鏂囦欢鍙傛暟 -->" + JSONUtil.toJsonStr(paramMap)); + String result = dorequest(SybPayUrl.SYB_FILE_UPLOAD_URL, paramMap, ftpFilePath); + System.out.println("涓婁紶鏂囦欢 杩斿洖鍊� -->" + result); + CommonResult<Map> mapCommonResult = handleResult(result); + return mapCommonResult; + } + + /** + * 鍙仛retcode 鍒ゆ柇 涓嶅仛涓氬姟鐘舵�佸垽鏂� + * + * @param result + * @return + */ + private static CommonResult<Map> handleResult(String result) { + Map resultMap = JSONObject.parseObject(result, Map.class); + String retcode = Convert.toStr(resultMap.get("retcode")); + if ("success".equalsIgnoreCase(retcode)) { + return new CommonResult(resultMap); + } else { + return new CommonResult(CommonResultEmnu.ERROR, Convert.toStr(resultMap.get("retmsg"))); + } + } + + private static String dorequest(String url, Map<String, String> params, String path) { + CloseableHttpClient httpClient = null; + CloseableHttpResponse response = null; + try { + httpClient = HttpClients.createDefault(); + // 鎶婁竴涓櫘閫氬弬鏁板拰鏂囦欢涓婁紶缁欎笅闈㈣繖涓湴鍧� 鏄竴涓猻ervlet + HttpPost httpPost = new HttpPost(url); + // 鎶婃枃浠惰浆鎹㈡垚娴佸璞ileBody + FileBody bin = new FileBody(new File(path)); + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.addPart("filecontent", bin); + for (Map.Entry<String, String> entry : params.entrySet()) { + builder.addTextBody(entry.getKey(), entry.getValue()); + } + httpPost.setEntity(builder.build()); + // 鍙戣捣璇锋眰 骞惰繑鍥炶姹傜殑鍝嶅簲 + response = httpClient.execute(httpPost); + // 鑾峰彇鍝嶅簲瀵硅薄 + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { + String result = EntityUtils.toString(resEntity, Charset.forName("UTF-8")); + return result; + } + // 閿�姣� + EntityUtils.consume(resEntity); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (response != null) { + response.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + try { + if (httpClient != null) { + httpClient.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + return null; + } + + /** + * 楠岀 + * @param param 鍙傛暟 + * @param appKey appKey + * @param signType 鍔犲瘑绫诲瀷 + * @return 缁撴灉 + */ + public static boolean validSign(TreeMap<String, String> param, + String appKey, String signType) { + if (param == null || param.isEmpty()) { + return false; + } + if (!param.containsKey("sign")) { + return false; + } + String sign = param.remove("sign"); + if ("MD5".equals(signType)) {// 濡傛灉鏄痬d5鍒欓渶瑕佹妸md5鐨刱ey鍔犲叆鍒版帓搴� + param.put("key", appKey); + } + String paramStr = content(param); + byte[] paramByteArr = getByteUtf8(paramStr); + if ("MD5".equals(signType)) { + return sign.equalsIgnoreCase( + md5(paramByteArr)); + } else if("SM2".equals(signType)){ + PublicKey publicKey; + try { + publicKey = pubKeySM2FromBase64Str(appKey); + } catch (GeneralSecurityException e) { + return false; + } + return verifySM3SM2(publicKey, decodeBase64(sign), paramByteArr); + }else { + return rsaVerifyPublicKey(paramStr, sign, appKey); + } + } + + /** + * 鍏挜楠岀 + * @param content 鍐呭 + * @param sign 绛惧悕 + * @param publicKey 鍏挜key + * @return 缁撴灉 + */ + private static boolean rsaVerifyPublicKey(String content, String sign, + String publicKey) { + + PublicKey pubKey; + try { + pubKey = getPublicKeyFromX509("RSA", + Base64.decodeBase64(publicKey.getBytes())); + } catch (GeneralSecurityException e) { + e.printStackTrace(); + return false; + } + return rsaVerifyPublicKey(content, sign, pubKey); + } + + /** + * 鍏挜楠岀 + * @param content 鍐呭 + * @param sign 绛惧悕 + * @param pubKey 鍏挜 + * @return 缁撴灉 + */ + public static boolean rsaVerifyPublicKey(String content, String sign, + PublicKey pubKey) { + Signature signature; + try { + signature = Signature + .getInstance("SHA1WithRSA"); + } catch (NoSuchAlgorithmException e) { + return false; + } + try { + signature.initVerify(pubKey); + } catch (InvalidKeyException e) { + return false; + } + try { + signature.update(getByteUtf8(content)); + } catch (SignatureException e) { + return false; + } + try { + return signature.verify(decodeBase64(sign)); + } catch (SignatureException e) { + return false; + } + } + + /** + * 鎷兼帴楠岀/鍔犵鍐呭 + * @param param 鍙傛暟 + * @return 楠岀/鍔犵瀛楃涓� + */ + private static String content(TreeMap<String, String> param) { + //noinspection DuplicatedCode + StringBuilder sb = new StringBuilder(); + for (Map.Entry<String, String> entry : param.entrySet()) { + if (entry.getValue() != null && entry.getValue().length() > 0) { + sb.append(entry.getKey()).append("=") + .append(entry.getValue()).append("&"); + } + } + if (sb.length() > 0) { + sb.deleteCharAt(sb.length() - 1); + } + return sb.toString(); + } + + /** + * md5 + * + * @param b 鍔犲瘑瀛楃闆� + * @return 鍔犲瘑瀛楃涓� + */ + public static String md5(byte[] b) { + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + md.reset(); + md.update(b); + byte[] hash = md.digest(); + StringBuilder outStrBuf = new StringBuilder(32); + for (byte value : hash) { + int v = value & 0xFF; + if (v < 16) { + outStrBuf.append('0'); + } + outStrBuf.append(Integer.toString(v, 16).toLowerCase()); + } + return outStrBuf.toString(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + return new String(b); + } + } + + /** + * 鍒濆鍖栧叕閽� + * @param algorithm 鎸囧畾鍏挜绠楁硶 + * @return 鍏挜 + * @throws GeneralSecurityException 鍒濆鍖栧紓甯� + */ + public static PublicKey getPublicKeyFromX509(String algorithm, + byte[] encodedKey) throws GeneralSecurityException { + KeyFactory keyFactory = KeyFactory.getInstance(algorithm); + + return keyFactory.generatePublic(new X509EncodedKeySpec(encodedKey)); + } + + /** + * 鍒濆鍖栧叕閽� + * @param keyStr 鍏挜瀛楃涓� + * @return 鍏挜 + * @throws GeneralSecurityException 鍒濆鍖栧紓甯� + */ + public static PublicKey pubKeySM2FromBase64Str(String keyStr) throws GeneralSecurityException { +// KeyFactory keyFactory = KeyFactory.getInstance("EC"); +// return keyFactory.generatePublic(new X509EncodedKeySpec(decodeBase64(keyStr))); + return getPublicKeyFromX509("EC", decodeBase64(keyStr)); + } + + /** + * base64瀛楄妭鏁扮粍 + * @param str 瀛楃涓� + * @return 瀛楄妭鏁扮粍 + */ + private static byte[] decodeBase64(String str) { + return Base64.decodeBase64(str.getBytes(StandardCharsets.UTF_8)); + } + + /** + * 杞琤yte + * @param str 瀛楃涓� + * @return 瀛楄妭鏁扮粍 + */ + private static byte[] getByteUtf8(String str) { + if (str == null) { + return new byte[0]; + } + return str.getBytes(StandardCharsets.UTF_8); + } + + /** 楠岃瘉绛惧悕-SM3WithSM2*/ + private static boolean verifySM3SM2(final PublicKey publicKey,final byte[] signData, final byte[] srcData) { + SM2ParameterSpec parameterSpec = new SM2ParameterSpec(getByteUtf8("Allinpay")); + Signature verifier; + try { + verifier = Signature.getInstance(ALGORITHM_SM3SM2_BCPROV, "BC"); + } catch (NoSuchAlgorithmException | NoSuchProviderException e) { + return false; + } + try { + verifier.setParameter(parameterSpec); + verifier.initVerify(publicKey); + verifier.update(srcData); + return verifier.verify(bytePlain2ByteAsn1(signData)); + } catch (GeneralSecurityException e) { + return false; + } + } + + /** + * 灏嗘櫘閫氬瓧鑺傛暟缁勮浆鎹负ASN1瀛楄妭鏁扮粍 閫傜敤浜嶴M3withSM2楠岀鏃堕獙绛炬槑鏂囪浆鎹� + */ + private static byte[] bytePlain2ByteAsn1(byte[] data) { + if (data.length != SM3withSM2_RS_LEN * 2) { + throw new RuntimeException("err data. "); + } + BigInteger r = new BigInteger(1, Arrays.copyOfRange(data, 0, SM3withSM2_RS_LEN)); + BigInteger s = new BigInteger(1, Arrays.copyOfRange(data, SM3withSM2_RS_LEN, SM3withSM2_RS_LEN * 2)); + ASN1EncodableVector v = new ASN1EncodableVector(); + v.add(new ASN1Integer(r)); + v.add(new ASN1Integer(s)); + try { + return new DERSequence(v).getEncoded("DER"); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/syb/param/MerchantAddParam.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/syb/param/MerchantAddParam.java new file mode 100644 index 0000000..dbd4437 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/syb/param/MerchantAddParam.java @@ -0,0 +1,375 @@ +package com.nuvole.util.pay.allinPay.syb.param; + +import lombok.Data; + +/** + * @ClassName MerchantAdd + * @Author cy + * @Date 2023/6/13 + * @Description 鍟嗘埛杩涗欢鍙傛暟 + * @Version 1.0 + **/ +@Data +public class MerchantAddParam { + /** + *鏈烘瀯鍙� + *閫氳仈鍒嗛厤鐨勪唬鐞嗗晢鍙�* + * + */ + private String orgid; + /** + *鍟嗘埛鍙� + *閫氳仈鍒嗛厤鐨勫晢鎴峰彿* + *聽绛変簬orgid + */ + private String cusid; + /** + *搴旂敤ID + *閫氳仈鍒嗛厤鐨勪唬鐞嗗晢APPID* + * + */ + private String appid; + /** + *闅忔満瀛楃涓� + *鍟嗘埛鑷鐢熸垚鐨勯殢鏈哄瓧绗︿覆* + * + */ + private String randomstr; + /** + *浠g悊鍟嗗晢鎴峰彿 + *聽浠g悊鍟嗗钩鍙板晢鎴峰彿* + *聽浠g悊鍟嗙郴缁熷晢鎴峰敮涓�璇嗗埆鍙� + */ + private String merchantid; + /** + *鍟嗘埛鍚嶇О + ** + * + */ + private String merchantname; + /** + *鍟嗘埛绠�绉� + ** + *鏃犳墽鐓у晢鎴疯鎸夌収瀹為檯鍦烘墍鐨勭粡钀ラ棬搴楀悕绉板~鍐� + */ + private String shortname; + /** + *瀹㈡湇鐢佃瘽 + ** + * + */ + private String servicephone; + /** + *鎵�灞炶涓� + *璇﹁闄勫綍* + * + */ + private String mccid; + /** + *鍟嗘埛鎬ц川 + *1.浼佷笟 3.涓綋鎴� 4.涓汉 6.浜嬩笟鍗曚綅 + */ + private String comproperty; + /** + * 钀ヤ笟鎵х収鍚嶇О + * 鍟嗘埛鎬ц川闈炰釜浜烘椂闇�瑕佸~鍐� + */ + private String corpbusname; + /** + * 缁熶竴绀句細淇$敤浠g爜璇� + * 鍟嗘埛鎬ц川闈炰釜浜烘椂闇�瑕佸~鍐� + */ + private String creditcode; + /** + * 绀句細淇$敤浠g爜璇佹湁鏁堟湡 + * 鍟嗘埛鎬ц川闈炰釜浜烘椂闇�瑕佸~鍐� + */ + private String creditcodeexpire; + /** + * 娉曚汉濮撳悕 + * * + */ + private String legal; + /** + * 娉曚汉浠h〃璇佷欢绫诲瀷 + * 01銆�04銆�05* + * 01韬唤璇� + */ + private String legalidtype; + /** + * 娉曚汉浠h〃璇佷欢鍙� + */ + private String legalidno; + /** + * 娉曚汉韬唤璇佹湁鏁堟湡 + * * + * 聽yyyy-mm-dd鎴栭暱鏈� + */ + private String legalidexpire; + /** + * 娉ㄥ唽鍦板潃 + * * + * 聽娉ㄥ唽鍦板潃闇�鍖呭惈鐪佸競 + */ + private String address; + /** + * 鍟嗘埛璐熻矗浜� + * * + * 璐㈠姟鑱旂郴浜猴紙鏀剁煭淇$敤锛� + */ + private String contactperson; + /** + * 鍟嗘埛璐熻矗浜虹數璇� + * * + * 璐㈠姟鑱旂郴浜虹數璇� + */ + private String contactphone; + /** + * 缁撶畻鏂瑰紡 + * 1* + * 0-鍟嗘埛鑷富鎻愮幇 + */ + private String clearmode; + /** + * 璐︽埛鍙� + * * + */ + private String acctid; + /** + * 璐︽埛鍚� + * * + */ + private String acctname; + /** + * 璐︽埛绫诲瀷 + * 0|1* + * 0-瀵圭 + */ + private String accttype; + /** + * 鍗℃姌绫诲瀷 + * 00|01* + * 00-鍊熻鍗� + */ + private String accttp; + /** + * 鎵�灞為摱琛� + * 瑙侀檮褰�* + */ + private String bankcode; + /** + * 鏀粯琛屽彿 + * 瑙侀檮褰�* + */ + private String cnapsno; + /** + * 鍥炶皟url + * 杩涗欢鎴愬姛鐨勫洖璋冮�氱煡url* + */ + private String notifyurl; + /** + * 钀ヤ笟鎵х収鐓х墖 + * 鍟嗘埛鎬ц川闈炰釜浜烘椂闇�瑕佸~鍐� + */ + private String corpbuspic; + /** + * 娉曚汉韬唤璇佽倴鍍忛潰 + * 鐓х墖url* + * 聽浜哄儚闈� + */ + private String legalidpicfront; + /** + * 娉曚汉韬唤璇佸浗寰介潰 + * 鐓х墖url* + * 聽鍥藉窘闈� + */ + private String legalidpicback; + /** + * 缁忚惀鑰呮墜鎸佽韩浠借瘉鐓х墖 + * 鐓х墖url* + * 聽鍟嗘埛鎬ц川涓轰釜浜烘椂蹇呭~ + */ + private String legalpic; + /** + * 鍟嗘埛闂ㄥご鐓х墖 + * 鐓х墖url* + */ + private String storepic; + /** + * 缁忚惀鍐呮櫙鐓х墖 + * 鐓х墖url* + */ + private String storeinnerpic; + /** + * 缁忚惀鍦烘墍璇佹槑鏂囦欢 + * 涓嶉檺浜庤惀涓氬満鎵�绉熻祦鍗忚鎴栬�呬骇鏉冭瘉鏄庛�侀泦涓粡钀ュ満鎵�绠$悊鏂瑰嚭鍏风殑璇佹槑鏂囦欢绛� + * <p> + * 鍟嗘埛鎬ц川涓汉鏃堕渶瑕佸~鍐� + */ + private String bizplacepic; + /** + * 鎷撳睍浜� + * * + */ + private String expanduser; + /** + * 闂ㄥ簵淇℃伅 + * 闂ㄥ簵鍒楄〃鐨刯son鏁扮粍* + */ + private String subbranchlist; + /** + * 鏀粯浜у搧淇℃伅鍒楄〃 + * 浜у搧鍒楄〃鐨刯son鏁扮粍* + */ + private String prodlist; + + /** + * 鏀粯鎵�灞炵埗瀹㈡埛 + * 鎵�鍦ㄦ満鏋勮祫閲戝綊闆嗘椂锛岃瀛楁涓嶈兘涓虹┖ + */ + private String addfacusid; + /** + * 缁撶畻浜鸿韩浠借瘉鍙� + * 缁撶畻璐︽埛瀵圭鏃讹紝缁撶畻浜鸿韩浠借瘉鍙蜂笉鑳戒负绌� + */ + private String settidno; + /** + * 鎺ц偂鑲′笢濮撳悕 + * 鍟嗘埛鎬ц川涓轰紒涓氥�佷釜浣撴埛鏃跺繀濉� + */ + private String holdername; + /** + * 鎺ц偂鑲′笢韬唤璇� + * 鍟嗘埛鎬ц川涓轰紒涓氥�佷釜浣撴埛鏃跺繀濉� + */ + private String holderidno; + /** + * 鎺ц偂鑲′笢鏈夋晥鏈� + * 鍟嗘埛鎬ц川涓轰紒涓氥�佷釜浣撴埛鏃跺繀濉� + */ + private String holderexpire; + /** + * 娉ㄥ唽璧勬湰 + * 1: 娉ㄥ唽璧勬湰<10涓囧厓 + * 2: 10涓囧厓<娉ㄥ唽璧勬湰<20涓囧厓 + * 3: 20涓囧厓<娉ㄥ唽璧勬湰<50涓囧厓 + * 4: 50涓囧厓<娉ㄥ唽璧勬湰<100涓囧厓 + * 5: 娉ㄥ唽璧勬湰>100涓囧厓 + */ + private String registerfund; + /** + * 鍛樺伐浜烘暟 + * *鍟嗘埛鎬ц川涓轰紒涓氥�佷釜浣撴埛鏃跺繀濉� + * 1: 鍛樺伐鏁伴噺<10 + * 2: 10<鍛樺伐鏁伴噺<20 + * 3: 20<鍛樺伐鏁伴噺<50 + * 4: 50<鍛樺伐鏁伴噺<100 + * 5: 鍛樺伐鏁伴噺>100 + */ + private String stafftotal; + /** + * 缁忚惀鍖哄煙 + * 鍟嗘埛鎬ц川涓轰紒涓氥�佷釜浣撴埛鏃跺繀濉� + * 1锛氬煄鍖� + * 2: 閮婂尯 + * 3锛氳竟杩滃湴鍖� + */ + private String operatelimit; + /** + * 缁忚惀鍦版 + * 鍟嗘埛鎬ц川涓轰紒涓氥�佷釜浣撴埛鏃跺繀濉� + * 1锛氬晢涓氬尯 + * 2锛氬伐涓氬尯 + * 3锛氫綇瀹呭尯 + */ + private String inspect; + + /**瀵瑰叕璐︽埛淇℃伅 + *鍟嗘埛鎬ц川涓轰紒涓氾紝缁撶畻璐︽埛瀵圭鏃跺繀濉紝浣滀负鍟嗘埛淇℃伅鎵╁睍瀛楁锛屼笌缁撶畻淇℃伅鏃犲叧 + */ + private String pubacctinfo; + /**涓氬姟鑱旂郴浜哄鍚� + *闈炰釜浜虹被鍟嗘埛蹇呭~ + */ + private String busconactperson; + /**涓氬姟鑱旂郴浜虹數璇� + *闈炰釜浜虹被鍟嗘埛蹇呭~ + */ + private String busconacttel; + + /**缃戠珯url鎴栦笅杞藉湴鍧�鎴栧钩鍙板悕绉� + *寮�閫氱綉鍏筹紙鍚獴2B銆丄PP锛夈�佸揩鎹枫�佷簯闂粯APP鎴栫嚎涓婂満鏅繀濉� + */ + private String cusurl = ""; + + /**缃戠珯鍚嶇О/搴旂敤鍚嶇О + *寮�閫氱綉鍏筹紙鍚獴2B銆丄PP锛夈�佸揩鎹枫�佷簯闂粯APP鎴栫嚎涓婂満鏅繀濉� + */ + private String webname = ""; + + + /** + *绾夸笂绾夸笅涓氬姟鍦烘櫙 + *0聽 绾夸笅* + *涓虹┖鏃堕粯璁や负绾夸笅鍦烘櫙 + */ + private String offlag; + /** + *娉曚汉淇℃伅json瀛楃涓� + ** + *json鍐呰鎯呰涓嬭鏄� + */ + private String legaldetail; + /** + *鍙楃泭浜轰俊鎭痡son瀛楃涓� + ** + *娉細鏆備负闈炲繀濉紝5鏈�18鏃ョ敓鏁堜负蹇呭~ + */ + private String bnfdetail; + /** + *绋庡姟鐧昏璇︽儏json瀛楃涓� + *聽鍦ㄥ晢鎴锋�ц川涓轰紒涓氾紝閫夋嫨闈炰笁璇佸悎涓�鏃讹紝绋庡姟鐧昏璇佷俊鎭繀濉�* + *json鍐呰鎯呰涓嬭鏄� + */ + private String taxdetail; + /** + *缁忚惀鍐呭 + ** + * + */ + private String busdetail; + /** + *绛惧悕绫诲瀷 + ** + *RSA/SM2 + */ + private String signtype; + /** + *缁忚惀鍦板潃 + ** + *鍟嗘埛缁忚惀鍦板潃 + */ + private String busaddress; + /** + *鎵�鍦ㄥ尯 + ** + *瑙侀檮褰� + */ + private String districtcode; + + /** + * 鐢靛瓙鍗忚绛剧害鍥炶皟鍦板潃 姝ゅ瓧娈典负绌烘椂閫氱煡鍒拌繘浠跺洖璋僽rl + */ + private String electnotify; + + /** + * 鍥剧墖json瀛楃涓� + */ + private String picurljson; + /** + * 搴旂敤鍦烘櫙 01-PC缃戠珯 02-APP/鍏紬鍙�/灏忕▼搴忥紙鍙閫夛級 + */ + private String appscenario; + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/ConsumeApply.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/ConsumeApply.java new file mode 100644 index 0000000..7c29a84 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/ConsumeApply.java @@ -0,0 +1,60 @@ +package com.nuvole.util.pay.allinPay.yunst; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; + +import java.util.ArrayList; + +/** + * 娑堣垂鐢宠鍏敤鍙傛暟 + * + * @Author: lc + * @Date: 2019/10/14 17:03 + */ +@Data +@Builder +@ApiModel(value = "娑堣垂鐢宠鍏敤鍙傛暟") +public class ConsumeApply { + + @ApiModelProperty("娑堣垂鐢ㄦ埛鐨刡izUserId锛堜粯娆炬柟锛�") + private String payerId; + + @ApiModelProperty("娑堣垂鍟嗘埛鐨刡izUserId锛堟敹娆炬柟锛夊钩鍙拌嚜韬紝鍙傛暟鍊间负锛�#yunBizUserId_B2C#銆�") + private String recieverId; + + @ApiModelProperty("璁㈠崟鍙凤紙鏀粯璁㈠崟锛�") + private String bizOrderNo; + + @ApiModelProperty("璁㈠崟閲戦锛堝垎锛�") + private Long amount; + + @ApiModelProperty("鎵嬬画璐癸紙鍒嗭級") + private Long fee; + + @ApiModelProperty("浜ゆ槗楠岀鏂瑰紡銆�0.鏃犻獙璇侊紙娓犻亾楠岃瘉锛� 1.鐭俊楠岃瘉鐮� 2.鏀粯瀵嗙爜銆�") + private Long validateType; + + @ApiModelProperty("鍓嶅彴閫氱煡鍦板潃锛堝墠鍙颁氦鏄撳繀浼狅級") + private String frontUrl; + + @ApiModelProperty("鍚庡彴閫氱煡鍦板潃锛堝繀浼狅級") + private String backUrl; + + @ApiModelProperty("璁㈠崟杩囨湡鏃堕棿锛堝彲涓嶄紶锛�") + private String orderExpireDatetime; + + @ApiModelProperty("鎵╁睍鍙傛暟 鎺ュ彛灏嗗師鏍疯繑鍥烇紝鏈�澶� 50 涓瓧绗︼紙鍙笉浼狅級") + private String extendInfo; + + @ApiModelProperty("浜ゆ槗鍐呭鎽樿鏈�澶� 20 涓瓧绗︼紙鍙笉浼狅級") + private String summary; + + @ApiModelProperty("鍒嗚处瑙勫垯锛屽垎璐﹀眰绾ф暟<=3锛屽垎璐︽�讳細鍛樻暟<=10 " + + "[{bizUserId:鍞竴缂栧彿锛堝鏋滄槸骞冲彴濉�#yunBizUserId_B2C#锛� accountSetNo锛氬笎鎴烽泦缂栧彿" + + "amount锛氶噾棰濓紙鍒嗭級fee锛氭墜缁垂锛堝垎锛塺emark锛氬娉� splitRuleList锛氬垎璐﹀垪琛▆]") + private ArrayList splitRule; + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/MerchantApply.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/MerchantApply.java new file mode 100644 index 0000000..c7b526b --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/MerchantApply.java @@ -0,0 +1,61 @@ +package com.nuvole.util.pay.allinPay.yunst; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; + +/** + * 璁剧疆浼佷笟浼氬憳鍙傛暟 + * + * @Author: lc + * @Date: 2019/10/14 17:03 + */ +@Data +@Builder +@ApiModel(value = "璁剧疆浼佷笟浼氬憳鍙傛暟锛坹锛氬繀浼� n锛氶潪蹇呬紶锛�") +public class MerchantApply { + + @ApiModelProperty("浼佷笟鍚嶇О锛坹锛�") + private String companyName; + + @ApiModelProperty("璁よ瘉绫诲瀷[1 涓夎瘉 2 涓�璇乚 榛樿1") + private Long authType; + + @ApiModelProperty("缁熶竴绀句細淇$敤(涓�璇�)璁よ瘉绫诲瀷2鏃跺繀浼�") + private String uniCredit; + + @ApiModelProperty("钀ヤ笟鎵х収鍙�(涓夎瘉)璁よ瘉绫诲瀷涓� 1 鏃跺繀浼�") + private String businessLicense; + + @ApiModelProperty("缁勭粐鏈烘瀯(涓夎瘉)璁よ瘉绫诲瀷涓� 1 鏃跺繀浼�") + private String organizationCode; + + @ApiModelProperty("绋庡姟鐧昏璇�(涓夎瘉)璁よ瘉绫诲瀷涓� 1 鏃跺繀浼�") + private String taxRegister; + + @ApiModelProperty("娉曚汉濮撳悕锛坹锛�") + private String legalName; + + @ApiModelProperty("娉曚汉璇佷欢绫诲瀷[1.韬唤璇� 2.鎶ょ収 3.鍐涘畼璇� 4.鍥炰埂璇� 5.鍙拌優璇� 6.璀﹀畼璇� 7.澹叺璇� 99.鍏朵粬璇佷欢]锛坹锛�") + private Long identityType; + + @ApiModelProperty("娉曚汉璇佷欢鍙风爜锛坹锛�") + private String legalIds; + + @ApiModelProperty("娉曚汉鎵嬫満鍙风爜锛坹锛�") + private String legalPhone; + + @ApiModelProperty("浼佷笟瀵瑰叕璐︽埛锛坹锛�") + private String accountNo; + + @ApiModelProperty("寮�鎴烽摱琛屽悕绉帮紙y锛�") + private String parentBankName; + + @ApiModelProperty("寮�鎴疯鏀鍚嶇О锛坹锛�") + private String bankName; + + @ApiModelProperty("鏀粯琛屽彿锛坹锛�") + private String unionBank; + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/SignContractApply.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/SignContractApply.java new file mode 100644 index 0000000..70409a4 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/SignContractApply.java @@ -0,0 +1,30 @@ +package com.nuvole.util.pay.allinPay.yunst; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +/** + * @Description: + * @Company: TOO (ps锛氬叕鍙稿悕绉�) + * @author: 鍞� + * @date: 2020/4/15 涓嬪崍10:39 + * @version: V1.0.0 + */ + +@Data +@ApiModel("鐢靛瓙绛剧害璇锋眰鍙傛暟") +@Builder +public class SignContractApply { + + @ApiModelProperty(value = "鍟嗘埛绯荤粺鐢ㄦ埛鏍囪瘑") + private String bizUserId; + + @ApiModelProperty(value = "绛捐鍚庤烦杞繑鍥炵殑椤� 闈㈠湴鍧�") + private String jumpUrl; + + @ApiModelProperty(value = "鍚庡彴閫氱煡鍦板潃") + private String backUrl; + + @ApiModelProperty(value = "缁堢璁块棶绫诲瀷1锛氭墜鏈� 2锛歱c") + private Long source; +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/YunStParam.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/YunStParam.java new file mode 100644 index 0000000..3f581e7 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/YunStParam.java @@ -0,0 +1,26 @@ +package com.nuvole.util.pay.allinPay.yunst; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.NoArgsConstructor; + +/** + * 浜戝晢閫氬叕鍏卞弬鏁� + * + * @Author: lc + * @Date: 2019/10/15 14:13 + */ +@NoArgsConstructor +@ApiModel(value = "鍏叡鍙傛暟锛堥�氳仈浜戝晢閫氾級") +public class YunStParam { + + @ApiModelProperty("琛屼笟浠g爜") + public static String industryCode = "1910"; + + @ApiModelProperty("琛屼笟鍚嶇О") + public static String industryName = "鍏朵粬"; + + @ApiModelProperty("璁块棶缁堢绫诲瀷銆� 1锛歮obile 2锛歅C 銆�") + public static Long source = 2L; + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/YunStResult.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/YunStResult.java new file mode 100644 index 0000000..076e7c6 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/YunStResult.java @@ -0,0 +1,33 @@ +package com.nuvole.util.pay.allinPay.yunst; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 鎺ュ彛杩斿洖鍊硷紙閫氳仈浜戝晢閫氾級 + * + * @Author: lc + * @Date: 2019/10/14 16:37 + */ +@Data +@ApiModel(value = "鎺ュ彛杩斿洖鍊硷紙閫氳仈浜戝晢閫氾級") +public class YunStResult { + + @ApiModelProperty("鏈嶅姟璋冪敤鏄惁鎴愬姛锛屸�淥K鈥濊〃绀烘垚鍔燂紝鈥渆rror鈥濊〃绀哄け璐ャ��") + private String status; + + @ApiModelProperty("杩斿洖鍐呭锛� JSON 瀵硅薄锛�") + private String signedValue; + + @ApiModelProperty("绛惧悕") + private String sign; + + @ApiModelProperty("閿欒浠g爜") + private String errorCode; + + @ApiModelProperty("閿欒淇℃伅") + private String message; + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/YunStUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/YunStUtil.java new file mode 100644 index 0000000..d8c6f0f --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/YunStUtil.java @@ -0,0 +1,1092 @@ +package com.nuvole.util.pay.allinPay.yunst; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import com.allinpay.yunst.sdk.YunClient; +import com.allinpay.yunst.sdk.bean.YunConfig; +import com.allinpay.yunst.sdk.bean.YunRequest; +import com.allinpay.yunst.sdk.util.RSAUtil; +import com.nuvole.common.domain.dto.AppDTO; +import com.nuvole.util.IPUtil; +import lombok.extern.slf4j.Slf4j; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import java.util.Date; +import java.util.HashMap; + +/** + * 鏀粯宸ュ叿绫伙紙閫氳仈浜戝晢閫氾級 + * + * @Author: lc + * @Date: 2019/10/12 11:49 + */ +@Slf4j +public class YunStUtil { + + private Logger logger = LoggerFactory.getLogger(YunStUtil.class); + + //娴嬭瘯 + /*@Before + public void initConfig() { + final String serverUrl = "http://116.228.64.55:6900/service/soa"; + final String sysId = "1906061744156467038"; + final String pwd = "123456"; + final String alias = "1906061744156467038"; + final String path = "C:/Users/Administrator/Desktop/yunst/1906061744156467038/1906061744156467038.pfx"; + final String tlCertPath = "C:/Users/Administrator/Desktop/yunst/1906061744156467038/TLCert-test.cer"; + final String version = "2.0"; + final YunConfig config = new YunConfig(serverUrl, sysId, pwd, alias, version, path, tlCertPath); + YunClient.configure(config); + } + + @Test + public void test() { + + String bizUserId = "lc201910171030"; //鐢ㄦ埛鍞竴鏍囪瘑 4806722d-3c3a-4137-bc6f-5982e2759dd5 + String acct = "oZN135B20y8KIUFMl4GaeRyuFyQ3"; //寰俊灏忕▼搴弌penid + String bizOrderNo = "123456789987654322"; //璁㈠崟缂栧彿 + + YunStResult yunStResult = new YunStResult(); + + System.out.println("is Enter the test.............................鍒涘缓浼氬憳"); + Long memberType = 3L; + Long source = 2L; + //鍒涘缓浼氬憳 + yunStResult = createMember(bizUserId, memberType, source); + if ("OK".equals(yunStResult.getStatus())) { + log.info("is ok:-------------->"); + log.info(yunStResult.getSignedValue()); + } else { + log.info("is error:-------------->"); + log.info(yunStResult.getErrorCode()); + log.info(yunStResult.getMessage()); + } + + System.out.println("is The end of the test.......................鍒涘缓浼氬憳"); + + + System.out.println("is Enter the test.............................鍙戦�侀獙璇佺爜"); + String phone = "17803846500"; + Long verificationCodeType = 9L; + //鍒涘缓浼氬憳 + yunStResult = sendVerificationCode(bizUserId, phone, verificationCodeType); + if ("OK".equals(yunStResult.getStatus())) { + log.info("is ok:-------------->"); + log.info(yunStResult.getSignedValue()); + } else { + log.info("is error:-------------->"); + log.info(yunStResult.getErrorCode()); + log.info(yunStResult.getMessage()); + } + + System.out.println("is The end of the test.......................鍙戦�侀獙璇佺爜"); + + + System.out.println("is Enter the test.............................缁戝畾鎵嬫満"); + String verificationCode = "544343"; + //鍒涘缓浼氬憳 + yunStResult = bindPhone(bizUserId, phone, verificationCode); + if ("OK".equals(yunStResult.getStatus())) { + log.info("is ok:-------------->"); + log.info(yunStResult.getSignedValue()); + } else { + log.info("is error:-------------->"); + log.info(yunStResult.getErrorCode()); + log.info(yunStResult.getMessage()); + } + + System.out.println("is The end of the test.......................缁戝畾鎵嬫満"); + + System.out.println("is Enter the test.............................涓汉瀹炲悕璁よ瘉"); + //鍒涘缓浼氬憳 + yunStResult = setRealName(bizUserId, "鐜嬭帀", 1L, "410521199209010565"); + if ("OK".equals(yunStResult.getStatus())) { + log.info("is ok:-------------->"); + log.info(yunStResult.getSignedValue()); + } else { + log.info("is error:-------------->"); + log.info(yunStResult.getErrorCode()); + log.info(yunStResult.getMessage()); + } + + System.out.println("is The end of the test.......................涓汉瀹炲悕璁よ瘉"); + + System.out.println("is Enter the test.............................缁戝畾浼氬憳鏀粯璐︽埛"); + + //缁戝畾浼氬憳鏀粯璐︽埛 + String acctType = "weChatMiniProgram"; + YunStResult yunStResult1 = applyBindAcct(bizUserId, acctType, acct); + if ("OK".equals(yunStResult1.getStatus())) { + log.info("is ok:-------------->"); + log.info(yunStResult1.getSignedValue()); + } else { + log.info("is error:-------------->"); + log.info(yunStResult1.getErrorCode()); + log.info(yunStResult1.getMessage()); + } + System.out.println("is The end of the test.......................缁戝畾浼氬憳鏀粯璐︽埛"); + + + System.out.println("is Enter the test.............................涓汉瀹炲悕璁よ瘉"); + + //缁戝畾浼氬憳鏀粯璐︽埛 + String name = "寮犱笁"; + Long identityType = 1L; + String identityNo = "41000000000000000000"; + + yunStResult = setRealName(bizUserId, name, identityType, identityNo); + if ("OK".equals(yunStResult.getStatus())) { + log.info("is ok:-------------->"); + log.info(yunStResult.getSignedValue()); + } else { + log.info("is error:-------------->"); + log.info(yunStResult.getErrorCode()); + log.info(yunStResult.getMessage()); + } + System.out.println("is The end of the test.......................涓汉瀹炲悕璁よ瘉"); + + + System.out.println("is Enter the test.............................璇锋眰缁戝畾閾惰鍗�"); + + //缁戝畾浼氬憳鏀粯璐︽埛 + String cardNo = "6228481111111111111"; + String phone = "17803846500"; + + yunStResult = applyBindBankCard(bizUserId, cardNo, phone, name, identityType, identityNo); + if ("OK".equals(yunStResult.getStatus())) { + log.info("is ok:-------------->"); + log.info(yunStResult.getSignedValue()); + } else { + log.info("is error:-------------->"); + log.info(yunStResult.getErrorCode()); + log.info(yunStResult.getMessage()); + } + System.out.println("is The end of the test.......................璇锋眰缁戝畾閾惰鍗�"); + + + System.out.println("is Enter the test.............................娑堣垂鐢宠"); + + + //缁戝畾浼氬憳鏀粯璐︽埛 + String recieverId = "123456"; + Long validateType = 0L; //浜ゆ槗楠岀鏂瑰紡銆�0.鏃犻獙璇� 1.鐭俊楠岃瘉鐮� 2.鏀粯瀵嗙爜銆� + String backUrl = "https://www.baudi.com"; //鍚庡彴鍥炶皟鍦板潃 + ConsumeApply consumeApply = new ConsumeApply() {{ + setPayerId(bizUserId); + setRecieverId(recieverId); + setBizOrderNo(bizOrderNo); + setAmount(1L); + setFee(0L); + setValidateType(validateType); + setBackUrl(backUrl); + setSummary("鍟嗗搧浜ゆ槗"); + }}; + String vspCusid = "552651058145DRF"; + String subAppid = "00143623"; + Long amount = 1L; + yunStResult = wechatMiniprogramPay(consumeApply, vspCusid, subAppid, amount, acct); + if ("OK".equals(yunStResult.getStatus())) { + log.info("is ok:-------------->"); + log.info(yunStResult.getSignedValue()); + } else { + log.info("is error:-------------->"); + log.info(yunStResult.getErrorCode()); + log.info(yunStResult.getMessage()); + } + + System.out.println("is The end of the test.......................娑堣垂鐢宠"); + + }*/ + + /** + * 灏忕▼搴忔敮浠� + */ + /* @Test + public void wechatPay() { + log.info("<-------------------------this is createMember operation 鍒涘缓浼氬憳 ------------------------->"); + //鍒涘缓浼氬憳 + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + //String shBizUserId = "shanghu001"; //鏅�氫細鍛樹細鍛橈紙鏀舵鏂癸紝宸插疄鍚嶏級 + Long memberType = 3L; + Long source = 1L; + YunStResult result; + result = createMember(bizUserId, memberType, source); + logger.info("createMember result: status={},message={},signedValue={}", new Object[]{result.getStatus(), result.getMessage(), result.getSignedValue()}); + + log.info("<-------------------------this is applyBindAcct operation 浼氬憳缁戝畾鏀粯璐︽埛鐢ㄦ埛鏍囪瘑------------------------->"); + //浼氬憳缁戝畾鏀粯璐︽埛鐢ㄦ埛鏍囪瘑锛堟敮浠樿处鎴风粦瀹氬皬绋嬪簭openId锛� + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String acctType = "weChatMiniProgram"; + String acct = "tm001001"; + result = applyBindAcct(bizUserId, acctType, acct); + logger.info("applyBindAcct result: status={}", new Object[]{result.getStatus()}); + + log.info("<-------------------------this is wechatMiniprogramPay operation 娑堣垂鐢宠------------------------->"); + //娑堣垂鐢宠 + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String recieverId = "shanghu001"; + Long validateType = 0L; //浜ゆ槗楠岀鏂瑰紡銆�0.鏃犻獙璇� 1.鐭俊楠岃瘉鐮� 2.鏀粯瀵� + String bizOrderNo = "201200401111212"; + String backUrl = "https:localhost:8080"; //鍚庡彴鍥炶皟鍦板潃 + String acct = "tm001001"; + ConsumeApply consumeApply = ConsumeApply.builder() + .payerId(bizUserId) + .recieverId(recieverId) + .bizOrderNo(bizOrderNo) + .amount(1L) + .fee(0L) + .validateType(validateType) + .backUrl(backUrl) + .summary("鍟嗗搧浜ゆ槗").build(); + String vspCusid = "552651058145DRF"; + String subAppid = "00143623"; + Long amount = 1L; + result = wechatMiniprogramPay(consumeApply, vspCusid, subAppid, amount, acct); + //todo 娴嬭瘯瀛愬晢鎴峰彿鏈彁渚� 閫氳仈鏈弽棣� + logger.info("consumeApply result: status={}, signedValue={}", new Object[]{result.getStatus(), result.getSignedValue()}); + + log.info("<-------------------------this is callBack operation 璁㈠崟缁撴灉閫氱煡------------------------->"); + //璁㈠崟缁撴灉閫氱煡 + }*/ + + + /** + * 鏀堕摱瀹濆揩鎹锋敮浠� + * + */ + /*@Test + public void quickPay() throws Exception { + log.info("<-------------------------this is createMember operation 鍒涘缓浼氬憳------------------------->"); + //鍒涘缓浼氬憳 + String bizUserId = "tz20200401113"; //鏅�氫細鍛� + String shBizUserId = "shanghu001"; //鏅�氫細鍛樹細鍛橈紙鏀舵鏂癸紝宸插疄鍚嶏級 + Long memberType = 3L; + Long source = 1L; + YunStResult result; + result = createMember(bizUserId, memberType, source); + logger.info("createMember result: status={},message={},signedValue={}", new Object[]{result.getStatus(), result.getMessage(), result.getSignedValue()}); + + log.info("<-------------------------this is sendVerificationCode operation 鍙戦�侀獙璇佺爜------------------------->"); + //鍙戦�侀獙璇佺爜 + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String phone = "17803846500"; + Long verificationCodeType = 9L; + result = sendVerificationCode(bizUserId, phone, verificationCodeType); + logger.info("sendVerificationCode result: status={},message={},signedValue={}",new Object[]{result.getStatus(),result.getMessage(),result.getSignedValue()}); + + log.info("<-------------------------this is bindPhone operation 缁戝畾鎵嬫満------------------------->"); + //缁戝畾鎵嬫満 + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String verificationCode = "544343"; + result = bindPhone(bizUserId, phone, verificationCode); + logger.info("bindPhone result: status={}",new Object[]{result.getStatus()}); + + log.info("<-------------------------this is certification operation 瀹炲悕璁よ瘉------------------------->"); + //瀹炲悕璁よ瘉 + String bizUserId = "tz20200401113"; //鏅�氫細鍛� + String name = "鍞愬畻鏃�"; + Long identityType = 1L; + String identityNo = "511521199408143656"; + result = setRealName(bizUserId, name, identityType, identityNo); + logger.info("certification result: status={}",new Object[]{result.getStatus()}); + + log.info("<-------------------------this is applyBindBankCard operation 鐢宠缁戝畾鐨勯摱琛屽崱------------------------->"); + //鐢宠缁戝畾鐨勯摱琛屽崱锛堥渶鐢ㄧ湡瀹炲鍚嶏紝鎵嬫満锛岃韩浠借瘉锛岄摱琛屽崱锛� + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String cardNo = "6217853100025227554"; //4缁撳熬鍗″彿杩斿洖濮撳悕涓嶅尮閰� + String phone = "17723341354"; + String name = "鍞愬畻鏃�"; + Long identityType = 1L; + String identityNo = "511521199408143656"; + result = applyBindBankCard(bizUserId, cardNo, phone, name, identityType, identityNo); + logger.info("applyBindBankCard result: status={} , signedValue= {}", new Object[]{result.getStatus()}); + + log.info("<-------------------------this is bindBankCard operation 纭缁戝畾閾惰鍗�------------------------->"); + //纭缁戝畾閾惰鍗� + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String phone = "17803846500"; + String tranceNum = "123"; //娴佹按鍙�(璇锋眰缁戝畾閾惰鍗℃帴鍙h繑鍥�) + String transDate = "2019-10-12"; //鐢宠鏃堕棿(璇锋眰缁戝畾閾惰鍗℃帴鍙h繑鍥�) + String verificationCode = "123"; + //todo "errorCode":"9000","message":"纭瓒呮椂鎴栬姹傚彿閿欒锛岃閲嶆柊璋冪敤缁戝崱鐢宠鎺ュ彛" 閫氳仈鏈弽棣� + result = bindBankCard(bizUserId,tranceNum,transDate,phone,verificationCode); + logger.info("bindBankCard result: status={}", new Object[]{result.getStatus()}); + + log.info("<-------------------------this is unbindBankCard operation 瑙i櫎閾惰鍗$粦瀹�------------------------->"); + //瑙i櫎閾惰鍗$粦瀹�(闇�瑕佹椂璋冪敤) + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String cardNo = "6230943800000203604"; + result = unbindBankCard(bizUserId,cardNo); + logger.info("unbindBankCard result: status={},message={}",new Object[]{result.getStatus(),result.getMessage()}); + + log.info("<-------------------------this is quickPayVsp operation 娑堣垂鐢宠(鐭俊楠岃瘉)------------------------->"); + String recieverId = "shanghu001"; + Long validateType = 1L; //浜ゆ槗楠岀鏂瑰紡銆�0.鏃犻獙璇� 1.鐭俊楠岃瘉鐮� 2.鏀粯瀵� + String bizOrderNo = "201200401111212"; + Long amount = 1L; + Long fee = 1L; + String backUrl = "http://localhost:8080"; + ConsumeApply consumeApply = ConsumeApply.builder() + .payerId("tz20200401111") + .recieverId("shanghu001") + .validateType(1L) + .bizOrderNo("201200401111212") + .amount(1L) + .fee(1L) + .backUrl("http://localhost:8080").build(); + result = quickPayVsp(consumeApply,cardNo); + log.info("consumeApply result: status = {},message = {}",new Object[]{result.getStatus(),result.getMessage()}); + + log.info("<-------------------------this is pay operation 纭鏀粯(鐭俊+鍚庡彴楠岃瘉)------------------------->"); + + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String bizOrderNo = "201200401111212"; + String tradeNo = "123"; + String verificationCode = "123"; + result = pay(bizUserId,bizOrderNo,tradeNo,verificationCode); + log.info("pay result: status={},signedValue={}",new Object[]{result.getStatus(),result.getSignedValue()}); + + log.info("<-------------------------this is getOrderDetail 鏌ヨ璁㈠崟鐘舵��(纭鏀粯杩斿洖澶勭悊涓椂璋冪敤)------------------------->"); + String bizOrderNo = "201200401111212"; + result = getOrderDetail(bizOrderNo); + log.info("getOrderDetail result: status={},signedValue={}",new Object[]{result.getStatus(),result.getSignedValue()}); + + }*/ + + /** + * 闈㈡壂闈㈡敮浠�(B鎵玞) + * + */ + /*@Test + public void bussToCustPay(){ + log.info("<-------------------------this is createMember operation 鍒涘缓浼氬憳------------------------->"); + //鍒涘缓浼氬憳 + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String shBizUserId = "shanghu001"; //鏅�氫細鍛樹細鍛橈紙鏀舵鏂癸紝宸插疄鍚嶏級 + Long memberType = 3L; + Long source = 1L; + YunStResult result; + result = createMember(bizUserId, memberType, source); + logger.info("createMember result: status={},message={},signedValue={}", new Object[]{result.getStatus(), result.getMessage(), result.getSignedValue()}); + + log.info("<-------------------------this is applyBindAcct operation 浼氬憳缁戝畾鏀粯璐︽埛鐢ㄦ埛鏍囪瘑(寰俊/鏀粯瀹�/浜戦棯浠榦penId)------------------------->"); + //浼氬憳缁戝畾鏀粯璐︽埛鐢ㄦ埛鏍囪瘑(寰俊/鏀粯瀹�/浜戦棯浠榦penId) + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String acctType = "weChatMiniProgram"; + String acct = "tm001001"; + result = applyBindAcct(bizUserId, acctType, acct); + logger.info("applyBindAcct result: status={}", new Object[]{result.getStatus(),result.getSignedValue()}); + + log.info("<-------------------------this is quickPayVsp operation 娑堣垂鐢宠(鏀粯鏂瑰紡:鏀堕摱瀹濆埛鍗℃敮浠�(琚壂)_闆嗗洟鈥斺�旀敮鎸佸井淇°�佹敮浠樺疂銆侀摱鑱斻�佹墜鏈篞Q)------------------------->"); + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String shBizUserId = "shanghu001"; //鏅�氫細鍛樹細鍛橈紙鏀舵鏂癸紝宸插疄鍚嶏級 + ConsumeApply consumeApply = ConsumeApply.builder() + .payerId(bizUserId) + .recieverId(shBizUserId) + .bizOrderNo("123231231") + .amount(1L) + .fee(1L) + .validateType(0L) + .backUrl("localhost") + .build(); + Long amount = 1L; + String authcode = "124316162322111111"; //姝ゅ闇�鐢ㄧ湡瀹炰粯娆剧爜 + String vspCusid = "zsh111111"; + result = doCodePay(consumeApply,vspCusid,amount,authcode); + + log.info("<-------------------------this is getOrderDetail 鏌ヨ璁㈠崟鐘舵��(纭鏀粯杩斿洖澶勭悊涓椂璋冪敤)------------------------->"); + result = getOrderDetail("12312323"); + log.info("getOrderDetail result: status={},signedValue={}",new Object[]{result.getStatus(),result.getSignedValue()}); + + }*/ + + /** + * 闈㈠闈粯娆綾鎵玝 + */ + /* @Test + public void custToBussPay(){ + log.info("<-------------------------this is createMember operation 鍒涘缓浼氬憳------------------------->"); + //鍒涘缓浼氬憳 + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String shBizUserId = "shanghu001"; //鏅�氫細鍛樹細鍛橈紙鏀舵鏂癸紝宸插疄鍚嶏級 + Long memberType = 3L; + Long source = 1L; + YunStResult result; + result = createMember(bizUserId, memberType, source); + logger.info("createMember result: status={},message={},signedValue={}", new Object[]{result.getStatus(), result.getMessage(), result.getSignedValue()}); + + log.info("<-------------------------this is applyBindAcct operation 浼氬憳缁戝畾鏀粯璐︽埛鐢ㄦ埛鏍囪瘑(寰俊/鏀粯瀹�/浜戦棯浠榦penId)------------------------->"); + //浼氬憳缁戝畾鏀粯璐︽埛鐢ㄦ埛鏍囪瘑(寰俊/鏀粯瀹�/浜戦棯浠榦penId) + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String acctType = "weChatMiniProgram"; + String acct = "tm001001"; + result = applyBindAcct(bizUserId, acctType, acct); + logger.info("applyBindAcct result: status={}", new Object[]{result.getStatus(),result.getSignedValue()}); + + log.info("<-------------------------this is quickPayVsp operation 娑堣垂鐢宠(鏀粯鏂瑰紡:鏀堕摱瀹濆埛鍗℃敮浠�(姝f壂)_)------------------------->"); + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + ConsumeApply consumeApply = ConsumeApply.builder() + .payerId(bizUserId) + .recieverId(shBizUserId) + .bizOrderNo("1232312311") + .amount(1L) + .fee(1L) + .validateType(0L) + .backUrl("localhost") + .build(); + Long amount = 1L; + String vspCusid = "zsh111111"; + result = doScanPay(consumeApply,vspCusid,amount,"SCAN_WEIXIN"); //姝e紡鐜悗鍔燺ORG + log.info("quickPayVsp result: status={},signedValue={}",new Object[]{result.getStatus(),result.getSignedValue()}); + + log.info("<-------------------------this is getOrderDetail 鏌ヨ璁㈠崟鐘舵��(鍏ラ噾绫讳氦鏄�(浣跨敤閾惰璐︽埛璧勯噾杩涜鏀粯)锛屽彧鏈夎鍗曟敮浠樻垚鍔熸儏鍐典笅鎵嶄細閫氱煡)------------------------->"); + result = getOrderDetail("12312323"); + log.info("getOrderDetail result: status={},signedValue={}",new Object[]{result.getStatus(),result.getSignedValue()}); + }*/ + + /** + * 浼佷笟鍗栧浼氬憳 + */ + /*@Test + public void createOrgMember(){ + log.info("<-------------------------this is createOrgMember operation 鍒涘缓浼佷笟浼氬憳------------------------->"); + String bizUserId = "sh20200401111"; //浼佷笟浼氬憳 + Long memberType = 2L; + Long source = 2L; //pc绔� + YunStResult result; + result = createMember(bizUserId, memberType, source); + logger.info("createMember result: status={},message={},signedValue={}", new Object[]{result.getStatus(), result.getMessage(), result.getSignedValue()}); + + log.info("<-------------------------this is createOrgMember operation 鍒涘缓浼佷笟浼氬憳------------------------->"); + String bizUserId = "sh20200401111"; //浼佷笟浼氬憳 + String backUrl = "localhost"; //閫氱煡鍦板潃 + Boolean isAuth = true; + MerchantApply merchantApply = MerchantApply.builder() + .companyName("company") + .authType(2L) + .uniCredit("112") + .legalName("寮犱笁") + .identityType(1L) + .legalIds("122212121") //RSA鍔犲瘑 + .legalPhone("13360881231") + .accountNo("13360881231") //RSA鍔犲瘑 + .parentBankName("宸ュ晢閾惰") + .bankName("涓浗宸ュ晢閾惰鑲′唤鏈夐檺鍏徃鍖椾含妯辨鍥敮琛�") //闇�鏄埗绾х洿杩為摱琛� + .unionBank("111111111111")//12浣嶆暟瀛� + .build(); + result = setCompanyInfo(bizUserId,backUrl,isAuth,merchantApply); + + log.info("<-------------------------this is sendVerificationCode operation 鍙戦�侀獙璇佺爜------------------------->"); + //鍙戦�侀獙璇佺爜 + String bizUserId = "tz20200401111"; //浼佷笟浼氬憳 + String phone = "17803846500"; + Long verificationCodeType = 9L; + result = sendVerificationCode(bizUserId, phone, verificationCodeType); + logger.info("sendVerificationCode result: status={},message={},signedValue={}",new Object[]{result.getStatus(),result.getMessage(),result.getSignedValue()}); + + log.info("<-------------------------this is bindPhone operation 缁戝畾鎵嬫満------------------------->"); + //缁戝畾鎵嬫満 + String bizUserId = "tz20200401111"; //浼佷笟閫氫細鍛� + String verificationCode = "544343"; + result = bindPhone(bizUserId, phone, verificationCode); + logger.info("bindPhone result: status={}",new Object[]{result.getStatus()}); + + log.info("<-------------------------this is signContract operation 浼氬憳鐢靛瓙绛剧害------------------------->"); + + SignContractApply signContractApply = SignContractApply.builder() + .bizUserId("tz20200401113") + .jumpUrl("http://www.baidu.com") + .backUrl("localhost") + .source(2L) + .build(); + String webParamUrl = "http://116.228.64.55:6900/yungateway/member/signContract.html?"; + String signUrl = signContract(signContractApply,webParamUrl); //浠ュ墠鍙� H5 椤甸潰褰㈠紡杩涜璇锋眰 + System.out.println("signUrl is " + signUrl); + }*/ + + /** + * 涓汉鍗栧浼氬憳 + * + */ + /*@Test + public void createSellerMember(){ + log.info("<-------------------------this is createOrgMember operation 鍒涘缓涓汉浼氬憳------------------------->"); + String bizUserId = "sh20200401111"; //浼佷笟浼氬憳 + Long memberType = 3L; + Long source = 2L; //pc绔� + YunStResult result; + result = createMember(bizUserId, memberType, source); + logger.info("createMember result: status={},message={},signedValue={}", new Object[]{result.getStatus(), result.getMessage(), result.getSignedValue()}); + + log.info("<-------------------------this is sendVerificationCode operation 鍙戦�侀獙璇佺爜------------------------->"); + //鍙戦�侀獙璇佺爜 + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String phone = "17803846500"; + Long verificationCodeType = 9L; + result = sendVerificationCode(bizUserId, phone, verificationCodeType); + logger.info("sendVerificationCode result: status={},message={},signedValue={}",new Object[]{result.getStatus(),result.getMessage(),result.getSignedValue()}); + + log.info("<-------------------------this is bindPhone operation 缁戝畾鎵嬫満------------------------->"); + //缁戝畾鎵嬫満 + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String verificationCode = "544343"; + result = bindPhone(bizUserId, phone, verificationCode); + logger.info("bindPhone result: status={}",new Object[]{result.getStatus()}); + + log.info("<-------------------------this is certification operation 瀹炲悕璁よ瘉------------------------->"); + //瀹炲悕璁よ瘉 + String bizUserId = "tz20200401113"; //鏅�氫細鍛� + String name = "鍞愬畻鏃�"; + Long identityType = 1L; + String identityNo = "511521199408143656"; + result = setRealName(bizUserId, name, identityType, identityNo); + logger.info("certification result: status={}",new Object[]{result.getStatus()}); + + log.info("<-------------------------this is applyBindBankCard operation 鐢宠缁戝畾鐨勯摱琛屽崱------------------------->"); + //鐢宠缁戝畾鐨勯摱琛屽崱锛堥渶鐢ㄧ湡瀹炲鍚嶏紝鎵嬫満锛岃韩浠借瘉锛岄摱琛屽崱锛� + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String cardNo = "6217853100025227554"; //4缁撳熬鍗″彿杩斿洖濮撳悕涓嶅尮閰� + String phone = "17723341354"; + String name = "鍞愬畻鏃�"; + Long identityType = 1L; + String identityNo = "511521199408143656"; + result = applyBindBankCard(bizUserId, cardNo, phone, name, identityType, identityNo); + logger.info("applyBindBankCard result: status={} , signedValue= {}", new Object[]{result.getStatus()}); + + log.info("<-------------------------this is bindBankCard operation 纭缁戝畾閾惰鍗�------------------------->"); + //纭缁戝畾閾惰鍗� + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String phone = "17803846500"; + String tranceNum = "123"; //娴佹按鍙�(璇锋眰缁戝畾閾惰鍗℃帴鍙h繑鍥�) + String transDate = "2019-10-12"; //鐢宠鏃堕棿(璇锋眰缁戝畾閾惰鍗℃帴鍙h繑鍥�) + String verificationCode = "123"; + //todo "errorCode":"9000","message":"纭瓒呮椂鎴栬姹傚彿閿欒锛岃閲嶆柊璋冪敤缁戝崱鐢宠鎺ュ彛" 閫氳仈鏈弽棣� + result = bindBankCard(bizUserId,tranceNum,transDate,phone,verificationCode); + logger.info("bindBankCard result: status={}", new Object[]{result.getStatus()}); + + log.info("<-------------------------this is queryBankCard operation 鏌ヨ缁戝畾閾惰鍗�------------------------->"); + String bizUserId = "tz20200401111"; + String cardNo = null; //涓虹┖鍒欐煡璇㈡墍鏈夐摱琛屽崱 + result = queryBankCard(bizUserId,cardNo); + + + log.info("<-------------------------this is unbindBankCard operation 瑙i櫎閾惰鍗$粦瀹�------------------------->"); + //瑙i櫎閾惰鍗$粦瀹�(闇�瑕佹椂璋冪敤) + String bizUserId = "tz20200401111"; //鏅�氫細鍛� + String cardNo = "6230943800000203604"; + result = unbindBankCard(bizUserId,cardNo); + logger.info("unbindBankCard result: status={},message={}",new Object[]{result.getStatus(),result.getMessage()}); + + log.info("<-------------------------this is signContract operation 浼氬憳鐢靛瓙绛剧害------------------------->"); + + SignContractApply signContractApply = SignContractApply.builder() + .bizUserId("tz20200401113") + .jumpUrl("http://www.baidu.com") + .backUrl("localhost") + .source(2L) + .build(); + String webParamUrl = "http://116.228.64.55:6900/yungateway/member/signContract.html?"; + String signUrl = signContract(signContractApply,webParamUrl); //浠ュ墠鍙� H5 椤甸潰褰㈠紡杩涜璇锋眰 + System.out.println("signUrl is " + signUrl); + }*/ + + + /** + * 浼氬憳鐢靛瓙绛剧害 + * + * @param signContractApply + * @return + * + */ + public static String signContract(SignContractApply signContractApply, String webParamUrl) { + final YunRequest request = new YunRequest("MemberService", "signContract"); + request.put("bizUserId", signContractApply.getBizUserId()); + request.put("jumpUrl", signContractApply.getJumpUrl()); + request.put("backUrl", signContractApply.getBackUrl()); + request.put("source", signContractApply.getSource()); + try { + webParamUrl += YunClient.encodeOnce(request); + return webParamUrl; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + + /** + * 鍒涘缓浼氬憳 + * + * @param bizUserId 鐢ㄦ埛鏍囪瘑锛堢敤鎴蜂富閿甶d锛� + * @param memberType 浼氬憳绫诲瀷 [2.浼佷笟浼氬憳 3.涓汉浼氬憳] + * @param source 璁块棶缁堢绫诲瀷[1.mobile 2.pc] + * @Author: lc + * @Date: 2019/10/14 16:12 + */ + public static YunStResult createMember(String bizUserId, Long memberType, Long source) { + final YunRequest request = new YunRequest("MemberService", "createMember"); + request.put("bizUserId", bizUserId); + request.put("memberType", memberType); + request.put("source", source); + try { + return JSONUtil.toBean(YunClient.request(request), YunStResult.class); + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + + /** + * 浼氬憳缁戝畾鏀粯璐︽埛鐢ㄦ埛鏍囪瘑 + * + * @param bizUserId 鐢ㄦ埛鏍囪瘑锛堢敤鎴蜂富閿甶d锛� + * @param acctType 鏀粯璐︽埛绫诲瀷銆恮eChatPublic锛氬井淇″叕浼楀彿 weChatMiniProgram锛氬井淇″皬绋嬪簭 aliPayService锛氭敮浠樺疂鐢熸椿鍙枫�� + * @param acct 鏀粯璐︽埛鐢ㄦ埛鏍囪瘑銆愬井淇″叕浼楀彿openid/寰俊灏忕▼搴弌penid/鏀粯瀹濈敓娲诲彿user_id 銆� + * @Author: lc + * @Date: 2019/10/14 16:12 + */ + public static YunStResult applyBindAcct(String bizUserId, String acctType, String acct) { + final YunRequest request = new YunRequest("MemberService", "applyBindAcct"); + request.put("bizUserId", bizUserId); + request.put("operationType", "set"); + request.put("acctType", acctType); + request.put("acct", acct); + try { + return JSONUtil.toBean(YunClient.request(request), YunStResult.class); + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * 鍙戦�佺煭淇¢獙璇佺爜 + * + * @param bizUserId 鐢ㄦ埛鏍囪瘑锛堢敤鎴蜂富閿甶d锛� + * @param phone 鎵嬫満鍙风爜 + * @param verificationCodeType 楠岃瘉鐮佺被鍨媅9-缁戝畾鎵嬫満 6-瑙g粦鎵嬫満] + * @Author: lc + * @Date: 2019/10/14 16:12 + */ + public static YunStResult sendVerificationCode(String bizUserId, String phone, Long verificationCodeType) { + final YunRequest request = new YunRequest("MemberService", "sendVerificationCode"); + request.put("bizUserId", bizUserId); + request.put("phone", phone); + request.put("verificationCodeType", verificationCodeType); + try { + return JSONUtil.toBean(YunClient.request(request), YunStResult.class); + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + + /** + * 缁戝畾鎵嬫満 + * + * @param bizUserId 鐢ㄦ埛鏍囪瘑锛堢敤鎴蜂富閿甶d锛� + * @param phone 鎵嬫満鍙风爜 + * @param verificationCode 楠岃瘉鐮� + * @Author: lc + * @Date: 2019/10/14 16:12 + */ + public static YunStResult bindPhone(String bizUserId, String phone, String verificationCode) { + final YunRequest request = new YunRequest("MemberService", "bindPhone"); + request.put("bizUserId", bizUserId); + request.put("phone", phone); + request.put("verificationCode", verificationCode); + try { + return JSONUtil.toBean(YunClient.request(request), YunStResult.class); + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + + /** + * 涓汉瀹炲悕璁よ瘉 + * + * @param bizUserId 鐢ㄦ埛鏍囪瘑锛堢敤鎴蜂富閿甶d锛� + * @param name 濮撳悕 + * @param identityType 璇佷欢绫诲瀷銆�1.韬唤璇� 2.鎶ょ収 3.鍐涘畼璇� 4.鍥炰埂璇� 5.鍙拌優璇� 6.璀﹀畼璇� 7.澹叺璇� 99.鍏朵粬璇佷欢銆� + * @param identityNo 璇佷欢鍙风爜 + * @Author: lc + * @Date: 2019/10/14 16:12 + */ + public static YunStResult setRealName(String bizUserId, String name, Long identityType, String identityNo) { + final YunRequest request = new YunRequest("MemberService", "setRealName"); + try { + request.put("bizUserId", bizUserId); + request.put("name", name); + request.put("identityType", identityType); + request.put("identityNo", RSAUtil.encrypt(identityNo)); + return JSONUtil.toBean(YunClient.request(request), YunStResult.class); + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + + /** + * 璇锋眰缁戝畾閾惰鍗� + * + * @param bizUserId 鐢ㄦ埛鏍囪瘑锛堢敤鎴蜂富閿甶d锛� + * @param cardNo 閾惰鍗″彿 + * @param phone 閾惰棰勭暀鎵嬫満 + * @param name 濮撳悕 + * @param identityType 璇佷欢绫诲瀷銆�1.韬唤璇� 2.鎶ょ収 3.鍐涘畼璇� 4.鍥炰埂璇� 5.鍙拌優璇� 6.璀﹀畼璇� 7.澹叺璇� 99.鍏朵粬璇佷欢銆� + * @param identityNo 璇佷欢鍙风爜 + * @Author: lc + * @Date: 2019/10/14 16:12 + */ + public static YunStResult applyBindBankCard(String bizUserId, String cardNo, String phone, String name, Long identityType, String identityNo) { + final YunRequest request = new YunRequest("MemberService", "applyBindBankCard"); + try { + request.put("bizUserId", bizUserId); + request.put("cardNo", RSAUtil.encrypt(cardNo)); + request.put("cardNo", YunClient.encrypt(cardNo)); + request.put("phone", phone); + request.put("name", name); + request.put("cardCheck", 7L); //榛樿7L蹇嵎鏀粯 + request.put("identityType", identityType); + request.put("identityNo", RSAUtil.encrypt(identityNo)); + return JSONUtil.toBean(YunClient.request(request), YunStResult.class); + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + + /** + * 纭缁戝畾閾惰鍗� + * + * @param bizUserId 鐢ㄦ埛鏍囪瘑锛堢敤鎴蜂富閿甶d锛� + * @param tranceNum 娴佹按鍙� + * @param transDate 鐢宠鏃堕棿 + * @param phone 閾惰棰勭暀鎵嬫満 + * @param verificationCode 鎵嬫満楠岃瘉鐮� + * @Author: lc + * @Date: 2019/10/14 16:12 + */ + public static YunStResult bindBankCard(String bizUserId, String tranceNum, String transDate, String phone, String verificationCode) { + final YunRequest request = new YunRequest("MemberService", "bindBankCard"); + try { + request.put("bizUserId", bizUserId); + request.put("tranceNum", tranceNum); + request.put("transDate", transDate); + request.put("phone", phone); + request.put("verificationCode", verificationCode); + return JSONUtil.toBean(YunClient.request(request), YunStResult.class); + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + public static YunStResult queryBankCard(String bizUserId, String cardNo){ + final YunRequest request = new YunRequest("MemberService","queryBankCard"); + try { + if (StrUtil.isNotEmpty(cardNo)){ + RSAUtil.encrypt(cardNo); + }; + request.put("bizUserId",bizUserId); + request.put("cardNo",cardNo); + return JSONUtil.toBean(YunClient.request(request),YunStResult.class); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * 瑙i櫎缁戝畾閾惰鍗� + * + * @param bizUserId 鐢ㄦ埛鏍囪瘑锛堢敤鎴蜂富閿甶d锛� + * @param cardNo 閾惰鍗″彿 + * @Author: lc + * @Date: 2019/10/14 16:12 + */ + public static YunStResult unbindBankCard(String bizUserId, String cardNo) { + final YunRequest request = new YunRequest("MemberService", "unbindBankCard"); + try { + request.put("bizUserId", bizUserId); + request.put("cardNo", RSAUtil.encrypt(cardNo)); + return JSONUtil.toBean(YunClient.request(request), YunStResult.class); + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + + /** + * 璁剧疆浼佷笟浼氬憳淇℃伅锛堟殏鏃朵笉鐢級 + * + * @param bizUserId:鐢ㄦ埛鏍囪瘑锛堢敤鎴蜂富閿甶d锛� + * @param backUrl:浼佷笟浼氬憳瀹℃牳缁撴灉閫氱煡url + * @param isAuth:鏄惁杩涜绾夸笂璁よ瘉 + * @Author: lc + * @Date: 2019/10/14 16:12 + */ + public static YunStResult setCompanyInfo(String bizUserId, String backUrl, Boolean isAuth, MerchantApply merchantApply) { + final YunRequest request = new YunRequest("MemberService", "setCompanyInfo"); + try { + merchantApply.setLegalIds(RSAUtil.encrypt(merchantApply.getLegalIds())); + merchantApply.setAccountNo(RSAUtil.encrypt(merchantApply.getAccountNo())); + request.put("companyBasicInfo", merchantApply); + request.put("bizUserId", bizUserId); + request.put("backUrl", backUrl); + request.put("isAuth", isAuth); + return JSONUtil.toBean(YunClient.request(request), YunStResult.class); + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + + /** + * 娑堣垂鐢宠锛堟敹閾跺疂蹇嵎鏀粯锛� + * + * @param consumeApply:娑堣垂鍏叡瀹炰綋 + * @param bankCardNo:閾惰鍗″彿 + * @Author: lc + * @Date: 2019/10/14 16:12 + */ + public static YunStResult quickPayVsp(ConsumeApply consumeApply, String bankCardNo) throws Exception { + final YunRequest request = new YunRequest("OrderService", "consumeApply"); + + HashMap<String, Object> params = new HashMap<>(); + params.put("limitPay", "no_credit"); + params.put("bankCardNo", RSAUtil.encrypt(bankCardNo)); + + // 缁勮鏀粯鏂瑰紡 + HashMap<String, Object> payMethod = new HashMap<>(); + payMethod.put("QUICKPAY_VSP", params); + + request.put("payerId", consumeApply.getPayerId()); + request.put("recieverId", consumeApply.getRecieverId()); + request.put("bizOrderNo", consumeApply.getBizOrderNo()); + request.put("amount", consumeApply.getAmount()); + request.put("fee", consumeApply.getFee()); + request.put("validateType", consumeApply.getValidateType()); + request.put("backUrl", consumeApply.getBackUrl()); + request.put("orderExpireDatetime", consumeApply.getOrderExpireDatetime()); + request.put("payMethod", payMethod); + request.put("industryCode", YunStParam.industryCode); + request.put("industryName", YunStParam.industryName); + request.put("source", YunStParam.source); + request.put("summary", consumeApply.getSummary()); + request.put("extendInfo", consumeApply.getExtendInfo()); + request.put("splitRule", consumeApply.getSplitRule()); + try { + return JSONUtil.toBean(YunClient.request(request), YunStResult.class); + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + + /** + * 纭鏀粯锛堝悗鍙�+鐭俊楠岃瘉鐮佺‘璁わ級 + * + * @param bizUserId 鐢ㄦ埛鏍囪瘑锛堢敤鎴蜂富閿甶d锛� + * @param bizOrderNo 璁㈠崟缂栧彿锛堟敮浠樿鍗曪級 + * @param tradeNo 浜ゆ槗缂栧彿 + * @param verificationCode 鐭俊楠岃瘉鐮� + * @Author: lc + * @Date: 2019/10/14 16:12 + */ + public static YunStResult pay(String bizUserId, String bizOrderNo, String tradeNo, String verificationCode) { + ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); +// HttpServletRequest req = requestAttributes.getRequest(); +// String ipAddress = IPUtil.getIpAddr(req); //姝e紡鐜浼犵敤鎴穒p + final YunRequest request = new YunRequest("OrderService", "pay"); + try { + request.put("bizUserId", bizUserId); + request.put("bizOrderNo", bizOrderNo); + request.put("tradeNo", tradeNo); + request.put("verificationCode", verificationCode); + request.put("bizOrderNo", bizOrderNo); + request.put("consumerIp", IPUtil.getLocalHostIp()); //ip鍦板潃 + return JSONUtil.toBean(YunClient.request(request), YunStResult.class); + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + + /** + * 鏌ヨ璁㈠崟鐘舵�� + * + * @param bizOrderNo 璁㈠崟缂栧彿锛堟敮浠樿鍗曪級 + * @Author: lc + * @Date: 2019/10/14 16:12 + */ + public static YunStResult getOrderDetail(String bizOrderNo) { + final YunRequest request = new YunRequest("OrderService", "getOrderDetail"); + try { + request.put("bizOrderNo", bizOrderNo); + return JSONUtil.toBean(YunClient.request(request), YunStResult.class); + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + + /** + * 娑堣垂鐢宠锛堝井淇″皬绋嬪簭锛� + * + * @param consumeApply:娑堣垂鍏叡瀹炰綋 + * @param vspCusid:鏀堕摱瀹濆瓙鍟嗘埛鍙� + * @param subAppid:寰俊灏忕▼搴忔敮浠榓ppid鍙傛暟 + * @param amount:鏀粯閲戦锛屽崟浣嶏細鍒� + * @param acct:寰俊JS鏀粯openid鈥斺�斿井淇″垎閰� + * @Author: lc + * @Date: 2019/10/14 16:12 + */ + public static YunStResult wechatMiniprogramPay(ConsumeApply consumeApply, String vspCusid, String subAppid, Long amount, String acct) { + final YunRequest request = new YunRequest("OrderService", "consumeApply"); + + HashMap<String, Object> params = new HashMap<>(); + params.put("vspCusid", vspCusid); + params.put("subAppid", subAppid); //姝e紡鐜璇峰繀浼� + params.put("limitPay", "no_credit"); + params.put("amount", amount); + params.put("acct", acct); + + // 缁勮鏀粯鏂瑰紡 + HashMap<String, Object> payMethod = new HashMap<>(); + //payMethod.put("WECHATPAY_MINIPROGRAM", params); //娴嬭瘯 + payMethod.put("WECHATPAY_MINIPROGRAM_ORG", params); //姝e紡闆嗗洟鐗� + + request.put("payerId", consumeApply.getPayerId()); + request.put("recieverId", consumeApply.getRecieverId()); + request.put("bizOrderNo", consumeApply.getBizOrderNo()); + request.put("amount", consumeApply.getAmount()); + request.put("fee", consumeApply.getFee()); + request.put("validateType", consumeApply.getValidateType()); + request.put("backUrl", consumeApply.getBackUrl()); + request.put("orderExpireDatetime", consumeApply.getOrderExpireDatetime()); + request.put("payMethod", payMethod); + request.put("industryCode", YunStParam.industryCode); + request.put("industryName", YunStParam.industryName); + request.put("source", YunStParam.source); + request.put("summary", consumeApply.getSummary()); + request.put("extendInfo", consumeApply.getExtendInfo()); + request.put("splitRule", consumeApply.getSplitRule()); + try { + return JSONUtil.toBean(YunClient.request(request), YunStResult.class); + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + + /** + * 娑堣垂鐢宠锛圔鎵獵 鐢ㄦ埛琚壂锛� + * + * @param consumeApply:娑堣垂鍏叡瀹炰綋 + * @param vspCusid:鏀堕摱瀹濆瓙鍟嗘埛鍙� + * @param amount:鏀粯閲戦锛屽崟浣嶏細鍒� + * @param authcode:鏀粯鎺堟潈鐮侊紙鐢ㄦ埛鍑虹ず鐨勪簩缁寸爜锛� + * @Author: lc + * @Date: 2019/10/14 16:12 + */ + public static YunStResult doCodePay(ConsumeApply consumeApply, String vspCusid, Long amount, String authcode) { + final YunRequest request = new YunRequest("OrderService", "consumeApply"); + + HashMap<String, Object> params = new HashMap<>(); + params.put("amount", amount); + params.put("vspCusid", vspCusid); + params.put("authcode", authcode); + params.put("limitPay", "no_credit"); + + // 缁勮鏀粯鏂瑰紡 + HashMap<String, Object> payMethod = new HashMap<>(); + payMethod.put("CODEPAY_VSP", params); + //payMethod.put("CODEPAY_VSP_ORG", params); //姝e紡闆嗗洟鐗� + + request.put("payerId", consumeApply.getPayerId()); + request.put("recieverId", consumeApply.getRecieverId()); + request.put("bizOrderNo", consumeApply.getBizOrderNo()); + request.put("amount", consumeApply.getAmount()); + request.put("fee", consumeApply.getFee()); + request.put("validateType", consumeApply.getValidateType()); + request.put("backUrl", consumeApply.getBackUrl()); + request.put("orderExpireDatetime", consumeApply.getOrderExpireDatetime()); + request.put("payMethod", payMethod); + request.put("industryCode", YunStParam.industryCode); + request.put("industryName", YunStParam.industryName); + request.put("source", YunStParam.source); + request.put("summary", consumeApply.getSummary()); + request.put("extendInfo", consumeApply.getExtendInfo()); + request.put("splitRule", consumeApply.getSplitRule()); + try { + return JSONUtil.toBean(YunClient.request(request), YunStResult.class); + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + + /** + * 娑堣垂鐢宠锛圕鎵獴 鐢ㄦ埛涓绘壂锛� + * + * @param consumeApply:娑堣垂鍏叡瀹炰綋 + * @param vspCusid:鏀堕摱瀹濆瓙鍟嗘埛鍙� + * @param amount:鏀粯閲戦锛屽崟浣嶏細鍒� + * @param acctType:鏀粯璐︽埛绫诲瀷銆怱CAN_WEIXIN_ORG锛氬井淇� SCAN_ALIPAY_ORG锛氭敮浠樺疂 SCAN_UNIONPAY_ORG锛氶摱鑱斾簯闂粯銆� 娴嬭瘯鐜涓嶅甫_ORG + * @Author: lc + * @Date: 2019/10/14 16:12 + */ + public static YunStResult doScanPay(ConsumeApply consumeApply, String vspCusid, Long amount, String acctType) { + final YunRequest request = new YunRequest("OrderService", "consumeApply"); + + HashMap<String, Object> params = new HashMap<>(); + params.put("vspCusid", vspCusid); + params.put("amount", amount); + params.put("limitPay", "no_credit"); + + // 缁勮鏀粯鏂瑰紡 + HashMap<String, Object> payMethod = new HashMap<>(); + payMethod.put(acctType, params); + + request.put("payerId", consumeApply.getPayerId()); + request.put("recieverId", consumeApply.getRecieverId()); + request.put("bizOrderNo", consumeApply.getBizOrderNo()); + request.put("amount", consumeApply.getAmount()); + request.put("fee", consumeApply.getFee()); + request.put("validateType", consumeApply.getValidateType()); + request.put("backUrl", consumeApply.getBackUrl()); + request.put("orderExpireDatetime", consumeApply.getOrderExpireDatetime()); + request.put("payMethod", payMethod); + request.put("industryCode", YunStParam.industryCode); + request.put("industryName", YunStParam.industryName); + request.put("source", YunStParam.source); + request.put("summary", consumeApply.getSummary()); + request.put("extendInfo", consumeApply.getExtendInfo()); + request.put("splitRule", consumeApply.getSplitRule()); + try { + return JSONUtil.toBean(YunClient.request(request), YunStResult.class); + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } +} diff --git "a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/\347\263\273\347\273\237\345\257\271\346\216\245\344\272\221\345\225\206\351\200\232\346\216\245\345\217\243\346\265\201\347\250\213.txt" "b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/\347\263\273\347\273\237\345\257\271\346\216\245\344\272\221\345\225\206\351\200\232\346\216\245\345\217\243\346\265\201\347\250\213.txt" new file mode 100644 index 0000000..9156970 --- /dev/null +++ "b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunst/\347\263\273\347\273\237\345\257\271\346\216\245\344\272\221\345\225\206\351\200\232\346\216\245\345\217\243\346\265\201\347\250\213.txt" @@ -0,0 +1,24 @@ +lc(20191015) + +涓�.涓汉浼氬憳涔板绾夸笂鏀粯锛� + +1.浣跨敤寰俊灏忕▼搴忥細 鍒涘缓浼氬憳 --銆嬩細鍛樼粦瀹氭敮浠樿处鎴风敤鎴锋爣璇嗭紙鏀粯璐︽埛缁戝畾灏忕▼搴弌penId锛�--銆嬫秷璐圭敵璇� --銆嬭鍗曠粨鏋滈�氱煡 --銆嬪畬鎴愩�� + +2.浣跨敤鏀堕摱瀹濆揩鎹锋敮浠橈細鍒涘缓浼氬憳 --銆嬪彂閫侀獙璇佺爜 --銆嬬粦瀹氭墜鏈� --銆嬩釜浜哄疄鍚嶈璇� --銆嬭姹傜粦瀹氶摱琛屽崱 --銆嬬‘璁ょ粦瀹氶摱琛屽崱 --銆嬭В缁戦摱琛屽崱锛堥渶瑕佹椂璋冪敤锛� --銆� + 娑堣垂鐢宠锛堢煭淇¢獙璇佺爜鏂瑰紡锛� --銆嬬‘璁ゆ敮浠橈紙鍚庡彴+鐭俊楠岃瘉鐮佺‘璁わ級--銆嬫煡璇㈣鍗曠姸鎬侊紙鏍规嵁纭鏀粯鎺ュ彛杩斿洖澶勭悊涓啀璋冪敤锛屾垚鍔�/澶辫触涓嶈皟鐢級--銆嬪畬鎴愩�� + +浜�.涓汉浼氬憳涔板绾夸笅鏀粯 +3.绾夸笅闈㈠闈粯锛圔鎵玞锛夛細鍒涘缓浼氬憳 --銆嬩細鍛樼粦瀹氭敮浠樿处鎴风敤鎴锋爣璇嗭紙鏀粯璐︽埛缁戝畾寰俊/鏀粯瀹�/浜戦棯浠榦penId锛� --銆嬫秷璐圭敵璇凤紙鏀粯鏂瑰紡锛氭敹閾跺疂鍒峰崱鏀粯锛堣鎵級_闆嗗洟鈥斺�旀敮鎸佸井淇°�佹敮浠樺疂銆侀摱鑱斻�佹墜鏈篞Q锛� + --銆嬭鍗曠粨鏋滈�氱煡锛堟敮浠樻帴鍙h繑鍥炲鐞嗕腑鍐嶈皟鐢紝鎴愬姛/澶辫触涓嶈皟鐢級 --銆嬪畬鎴愩�� + +4.绾夸笅闈㈠闈粯锛坈鎵玝锛夛細鍒涘缓浼氬憳 --銆嬩細鍛樼粦瀹氭敮浠樿处鎴风敤鎴锋爣璇嗭紙鏀粯璐︽埛缁戝畾寰俊/鏀粯瀹�/浜戦棯浠榦penId锛� --銆嬫秷璐圭敵璇凤紙寰俊/鏀粯鍖�/閾惰仈鎵爜鏀粯(姝f壂) _闆嗗洟锛� + --銆嬭鍗曠粨鏋滈�氱煡锛堟敮浠樻帴鍙h繑鍥炲鐞嗕腑鍐嶈皟鐢紝鎴愬姛/澶辫触涓嶈皟鐢級 --銆嬪畬鎴� + +涓�.浼佷笟鍗栧浼氬憳锛堥偖鏀挎満鏋勶級 +1.鏀舵鏂癸細鍒涘缓浼氬憳 --銆� 璁剧疆浼佷笟浼氬憳淇℃伅 --銆嬩紒涓氫細鍛樺鏍哥粨鏋滈�氱煡 --銆嬪彂閫佺煭淇¢獙璇佺爜锛堢被鍨嬬粦瀹氭墜鏈猴級 --銆嬬粦瀹氭墜鏈� --銆嬭В缁戞墜鏈猴紙闇�瑕佹椂璋冪敤锛� --銆嬩細鍛樼數瀛愬崗璁绾� --銆嬪畬鎴愩�� + + +鍥�.涓汉鍗栧浼氬憳锛堥偖鏀垮晢鎴凤級 +1.鏀舵鏂� 鍒涘缓浼氬憳 -> 鍙戦�佺煭淇¢獙璇佺爜 -> 缁戝畾鎵嬫満 -> 瑙g粦鎵嬫満 ->涓汉瀹炲悕璁よ瘉 -> 璇锋眰缁戝畾閾惰鍗� -> 纭缁戝畾閾惰鍗� -> 鏌ヨ缁戝畾閾惰鍗� -> + 瑙g粦缁戝畾閾惰鍗� -> 浼氬憳鐢靛瓙鍗忚绛剧害 + diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/ApiPost.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/ApiPost.java new file mode 100644 index 0000000..cca01b7 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/ApiPost.java @@ -0,0 +1,82 @@ +package com.nuvole.util.pay.allinPay.yunstNew; + +import cn.hutool.crypto.SecureUtil; + +import cn.hutool.http.HttpUtil; + +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSON; +import com.nuvole.util.pay.allinPay.yunstNew.po.ResultVo; +import com.nuvole.util.pay.allinPay.yunstNew.po.YstPayUrl; + + +import java.util.*; + +/** + * Created by chenZhimin + * Date锛�2020/8/24 + * time锛�10:09 + */ +public class ApiPost { + + public static ResultVo apiPost(String url, Object obj) { + System.out.println(url); + System.out.println(getSignBody(obj)); + ResultVo result=new ResultVo(); + try { + JSONObject data= JSONUtil.xmlToJson(HttpUtil.post(url,getSignBody(obj))); + result=JSON.parseObject(JSON.toJSONString(data.get("ResultVo")),ResultVo.class); + System.out.println("wwwwwwwwwwwwww"+result); + } catch (Exception e) { + System.out.println("wwwwwwwwwwwwww"+e); + result.setCode("0"); + result.setMsg("鎺ュ彛璇锋眰澶辫触"); + result.setData(""); + } + return result; + } + + /** + * 缁勮甯︾鍚嶆暟鎹� + * @param body + * @return + */ + + public static String getSignBody(Object body) { + Map map= JSON.parseObject(JSON.toJSONString(body)); + String version=YstPayUrl.version; + String terMerchantId= YstPayUrl.terMerchantId; + map.put("version",version); + map.put("terMerchantId",terMerchantId); + String orgSign=createLinkStringByGet(map)+"&key="+YstPayUrl.ked; + System.out.println("orgSign--------"+orgSign); + String sign=SecureUtil.md5(orgSign); + map.put("sign",sign.toUpperCase()); + return JSON.toJSONString(map); + } + + /** + 銆�銆�* 鎶婃暟缁勬墍鏈夊厓绱犳帓搴忥紝骞舵寜鐓р�滃弬鏁�=鍙傛暟鍊尖�濈殑妯″紡鐢ㄢ��&鈥濆瓧绗︽嫾鎺ユ垚瀛楃涓� + 銆�銆�* @param params 闇�瑕佹帓搴忓苟鍙備笌瀛楃鎷兼帴鐨勫弬鏁扮粍 + 銆�銆�* @return 鎷兼帴鍚庡瓧绗︿覆 + 銆�銆�* @throws UnsupportedEncodingExceptio + 銆�銆�*/ + + public static String createLinkStringByGet(Map<String, String> params) { + List<String> keys = new ArrayList<String>(params.keySet()); + Collections.sort(keys); + String prestr = ""; + for (int i = 0; i < keys.size(); i++) { + String key = keys.get(i); + Object value = params.get(key); + if (i == keys.size() - 1) {//鎷兼帴鏃讹紝涓嶅寘鎷渶鍚庝竴涓�&瀛楃 + prestr = prestr + key + "=" + value; + } else { + prestr = prestr + key + "=" + value + "&"; + } + } + return prestr; + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/YunStUtilNew.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/YunStUtilNew.java new file mode 100644 index 0000000..4843cfe --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/YunStUtilNew.java @@ -0,0 +1,168 @@ +package com.nuvole.util.pay.allinPay.yunstNew; + +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSON; +import com.nuvole.util.pay.allinPay.yunst.YunStUtil; +import com.nuvole.util.pay.allinPay.yunstNew.po.*; + +import com.nuvole.util.pay.allinPay.yunstNew.po.payment.PaymentOrder; +import com.nuvole.util.pay.allinPay.yunstNew.po.payment.PaymentSubOrder; + +import lombok.extern.slf4j.Slf4j; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.*; + +/** + * Created by chenZhimin + * Date锛�2020/8/24 + * time锛�10:45 + */ +@Slf4j +public class YunStUtilNew { + + private Logger logger = LoggerFactory.getLogger(YunStUtil.class); + + //v1/shop/web/payBackYst 鍥炶皟鎺ュ彛 + + + /** + * 娴嬭瘯浼氬憳鍒涘缓 + */ + + public void createSellerMember(){ + CreateMember merber=new CreateMember(); + merber.setExternalUserid("wl01"); + merber.setMerchantName("璁板繂涓嶆斁鍋�"); + // merber.setPhone("17839927203"); Acct浼犲皬绋嬪簭 opeinid灏辫 锛屼笉鐢ㄤ紶鎵嬫満鍙� + merber.setAcctType("weChatMiniProgram"); + merber.setAcct("oZN135DrmaB3iCAvbZq_ShTM7FFQ"); + String bizUserId= createSellerMember(merber); + System.out.println(bizUserId); + //1341541084 + + //{"ResultVo":{"msg":"鍒涘缓鎴愬姛","code":1,"data":{"freezeAmount":"","allAmount":"","externalUserid":"czm01","terUuid":"","companyName":"","memUuid":"","memberType":"","bizUserId":1336179677,"status":"","fileId":""}}} + } + /** + * 璋冪敤鎵樼浠f敹鎺ュ彛 + */ + + public void orderPayer(){ + OrderPay pay=new OrderPay(); + pay.setAmount("0.01"); + pay.setMerOrderNo("11ab_02");//璁㈠崟鍙� + pay.setOrderType("5"); + pay.setPayerExId("czm02");//涔板璐﹀彿 + pay.setSource("1"); + pay.setType("2"); + pay.setAcct("oZN135DrmaB3iCAvbZq_ShTM7FFQ"); //寰俊openId 涔板 + List list=new ArrayList(); + SubOrder order=new SubOrder(); + order.setAmount("0.01"); + order.setRecieverExId("yjp01"); + order.setSubMerOrderNo("11ab_02"); + list.add(order); + /* SubOrder order2=new SubOrder(); + order2.setAmount("0.01"); + order2.setRecieverExId("1348216174"); + order2.setSubMerOrderNo("dd02"); + order2.setBody("鍒嗚处璁㈠崟02"); + list.add(order2);*/ + pay.setSubOrder(JSON.toJSONString(list)); + ResultVo result=orderPayer(pay); + System.out.println("22222222222222222---"+JSON.toJSONString(result)); + //wwwwwwwwwwwwwwResultVo(msg=璋冪敤鎴愬姛, code=1, data={"validateType":"","orderStatus":"","payWhereabouts":"","payInterfaceOutTradeNo":"","couponAmount":"","subBizOrderNo":{"subBizOrderNo":159834506278770},"termno":"","oriOrderNo":"","bizOrderNo":15983450627877,"refundWhereabouts":"","weChatAPPInfo":"","amount":"","orderNo":1298179292374536192,"tradeNo":"","merOrderNo":"11ab","traceno":"","errorMessage":"","freezenAmount":"","extendInfo":"","oriBizOrderNo":"","accttype":"","subMerOrderNo":{"subMerOrderNo":"11ab_01"},"url":"","bizUserId":1329222217,"feeAmount":"","buyerBizUserId":"","payFailMessage":"","allAmount":"","totalNum":"","cusid":"","bizBatchNo":"","payInterfacetrxcode":"","payCode":"","payStatus":"","payInfo":"{\"appId\":\"wx044ba657d536fa6a\",\"timeStamp\":\"1598345063\",\"nonceStr\":\"2f86b439742f4918b26093d76c599e51\",\"package\":\"prepay_id=wx251644234244923f718ac7e4abcb810000\",\"signType\":\"RSA\",\"paySign\":\"t0qNpWWHVx+sjNYNtiH/sYrULcXV/l88Ke2tKDH0XKHy8bAOW01EaM5Xye04+SrpJJkW/5IyVaAMXOt9mp0Bp1k+sWNYRkSozq+gKLWGTm8/zk1Pu/+exruEgnvK08o4UihXIkPD44zdR/AuYEe9YHwfV+3qrm0n+z5mch9JEdzeETuH6GVyFxBoJXL60GziVha3TSDrmsP02gdrBeyUTWjE0kYkLFoZztlxv7cAbqCKMiWQaIJ+dN/l4Nmx6k3zZgupErVLFjY9Rdas90SnOtB2HEAmBs62T82sVV7CaeMEBAxL9bkrGxMWtFYriPuPKqAsZAMmFrc+3Bs3QmQ0LQ==\"}","payDatetime":"","acct":""}) + } + + /** + * 璋冪敤鎵樼浠d粯鎺ュ彛 + */ + @Test + public void paymentPayerOrder(){ + PaymentOrder pay=new PaymentOrder(); + pay.setExternalUserid("czm02");//鍟嗘埛浠f敹璁㈠崟璇锋眰浼氬憳id + pay.setMerOrderNo("11ab_02_df"); //鍟嗘埛浠d粯鏀粯璁㈠崟鍙� + pay.setOldMerOrderNo("11ab_02"); //鍟嗘埛鍘熷浠f敹涓昏鍗曞彿 + pay.setOrderType("6"); + pay.setSource("1"); //1 pc绔� 2 寰俊绔� + pay.setExtendInfo("浠d粯澶囨敞"); + List list=new ArrayList(); + PaymentSubOrder order=new PaymentSubOrder(); + order.setSubMerOrderNo("df_dd01"); //鍟嗘埛浠d粯鏀粯瀛愯鍗曞彿 + order.setSubOldMerOrderNo("11ab_02"); + list.add(order); + /* SubOrder order2=new SubOrder(); + order2.setAmount("0.01"); + order2.setRecieverExId("1348216174"); + order2.setSubMerOrderNo("dd02"); + order2.setBody("鍒嗚处璁㈠崟02"); + list.add(order2);*/ + pay.setSubOrder(JSON.toJSONString(list)); + ResultVo result=orderPayer(pay); + System.out.println("22222222222222222---"+JSON.toJSONString(result)); + //wwwwwwwwwwwwwwResultVo(msg=璋冪敤鎴愬姛, code=1, data={"validateType":"","orderStatus":"","payWhereabouts":"","payInterfaceOutTradeNo":"","couponAmount":"","subBizOrderNo":{"subBizOrderNo":159834506278770},"termno":"","oriOrderNo":"","bizOrderNo":15983450627877,"refundWhereabouts":"","weChatAPPInfo":"","amount":"","orderNo":1298179292374536192,"tradeNo":"","merOrderNo":"11ab","traceno":"","errorMessage":"","freezenAmount":"","extendInfo":"","oriBizOrderNo":"","accttype":"","subMerOrderNo":{"subMerOrderNo":"11ab_01"},"url":"","bizUserId":1329222217,"feeAmount":"","buyerBizUserId":"","payFailMessage":"","allAmount":"","totalNum":"","cusid":"","bizBatchNo":"","payInterfacetrxcode":"","payCode":"","payStatus":"","payInfo":"{\"appId\":\"wx044ba657d536fa6a\",\"timeStamp\":\"1598345063\",\"nonceStr\":\"2f86b439742f4918b26093d76c599e51\",\"package\":\"prepay_id=wx251644234244923f718ac7e4abcb810000\",\"signType\":\"RSA\",\"paySign\":\"t0qNpWWHVx+sjNYNtiH/sYrULcXV/l88Ke2tKDH0XKHy8bAOW01EaM5Xye04+SrpJJkW/5IyVaAMXOt9mp0Bp1k+sWNYRkSozq+gKLWGTm8/zk1Pu/+exruEgnvK08o4UihXIkPD44zdR/AuYEe9YHwfV+3qrm0n+z5mch9JEdzeETuH6GVyFxBoJXL60GziVha3TSDrmsP02gdrBeyUTWjE0kYkLFoZztlxv7cAbqCKMiWQaIJ+dN/l4Nmx6k3zZgupErVLFjY9Rdas90SnOtB2HEAmBs62T82sVV7CaeMEBAxL9bkrGxMWtFYriPuPKqAsZAMmFrc+3Bs3QmQ0LQ==\"}","payDatetime":"","acct":""}) + } + /** + * 鍒涘缓涓汉鍟嗘埛 + */ + public void orderPayerSh(){ + Map map=new HashMap(); + map.put("externalUserid","yjp01"); + map.put("merchantName","涓汉鍟嗘埛鍙�"); + map.put("legalName","鍙跺缓楣�"); + map.put("phone","17321156857"); + map.put("identityType","1"); + map.put("legalIds","410221199004193031"); + map.put("acctType","aliPayService"); + map.put("acct","yjp"); + ResultVo result=ApiPost.apiPost(YstPayUrl.CREATE_SHOP_MEMBER,map); + System.out.println("22222222222222222---"+result); + // {"ResultVo":{"msg":"鍒涘缓鎴愬姛","code":1,"data":{"freezeAmount":"","allAmount":"","externalUserid":"yjp01","terUuid":"","companyName":"","memUuid":"","memberType":"","bizUserId":1325044892,"status":"","fileId":""}}} + + } + + + + + /** + * 浼氬憳鍒涘缓锛氭父瀹㈡ā寮� + * + * //涔板涔板娉ㄥ唽娴佺▼锛氫細鍛樺垱寤猴細娓稿妯″紡 + * if (storeMemberInfo != null && StrUtil.isEmpty(storeMemberInfo.getYunstuserid())) { + * CreateMember merber=new CreateMember(); + * merber.setExternalUserid(Convert.toStr(storeMemberInfo.getId())); + * merber.setMerchantName(storeMemberInfo.getMemberName()); + * merber.setAcct(storeMemberInfo.getWechatOpenid()); + * String yunStUserId=YunStUtilNew.createSellerMember(merber); + * if(!StrUtil.isEmpty(yunStUserId)){ + * storeMemberInfo.setYunstuserid(yunStUserId); + * } + * } + */ + + public static String createSellerMember(CreateMember merber){ + String bizUserId=""; + merber.setAcctType("weChatMiniProgram"); + + ResultVo result=ApiPost.apiPost(YstPayUrl.CREATE_SELLER_MEMBER,merber); + + if(("1").equals(result.getCode())){ + Map map= (Map) JSONUtil.parse(result.getData()); + bizUserId=map.get("bizUserId").toString(); + } + return bizUserId; + } + /** + * 鎵樼浠f敹/鎵樼浠d粯 + */ + + public static ResultVo orderPayer(Object pay){ + + ResultVo result=ApiPost.apiPost(YstPayUrl.ORDER_PAYER,pay); + return result; + } + + + } diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/CreateMember.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/CreateMember.java new file mode 100644 index 0000000..e9daa40 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/CreateMember.java @@ -0,0 +1,18 @@ +package com.nuvole.util.pay.allinPay.yunstNew.po; + +import lombok.Data; + +/** + * Created by chenlong + * Date锛�2020/8/24 + * time锛�10:57 + */ +@Data +public class CreateMember { + String externalUserid; + String merchantName; + String phone; + String acctType; + String acct; + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/OrderPay.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/OrderPay.java new file mode 100644 index 0000000..86675d1 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/OrderPay.java @@ -0,0 +1,73 @@ +package com.nuvole.util.pay.allinPay.yunstNew.po; + + + +import lombok.Data; +import com.alibaba.fastjson.JSONArray; + +/** + * Created by chenlong + * Date锛�2020/8/24 + * time锛�14:30 + */ +@Data +public class OrderPay { + /** + * 鏀粯骞冲彴鐢ㄦ埛鏍囪瘑锛宼ype=2锛�11浼犺緭寰俊openid + */ + String acct; + /** + * 鍗曚綅鍏� + */ + String amount; + /** + * type=3鏃朵紶鍏ワ紝鐢ㄦ埛浠樻浜岀淮鐮� + */ + String authCode; + /** + * 鍟嗘埛appid锛屽鏋滄病鏈変紶杈撶殑鏃跺�欏氨浣跨敤骞冲彴绔厤缃殑鍙傛暟 + */ + String exAppId; + /** + * 涓昏鍗曞娉� + */ + String extendInfo; + + /** + * 鍟嗘埛浠f敹鏀粯涓昏鍗曞彿 + */ + String merOrderNo; + /** + * 涓昏鍗曡繃鏈熸椂闂达紝type=14蹇呬紶 + */ + String orderExpireDatetime; + /** + * 璁㈠崟浜ゆ槗绫诲瀷锛岄粯璁ゅ~鍐�5锛堟墭绠′唬鏀讹級 + */ + String orderType="5"; + + /** + * 涓夋柟骞冲彴浠樻浜轰細鍛樺彿 + */ + String payerExId; + /** + * 缁堢璁块棶绫诲瀷锛�1 绉诲姩绔� 2 PC绔� + */ + String source; + /** + *瀛愯鍗曚俊鎭紝璇︽儏璇疯瀛愯鍗曚俊鎭� + */ + String subOrder; + /** + * 涓昏鍗曟憳瑕� + */ + String summary; + /** + * 鏀粯娓犻亾锛� + */ + + String type; + + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/PayBack.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/PayBack.java new file mode 100644 index 0000000..bc3f0fd --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/PayBack.java @@ -0,0 +1,61 @@ +package com.nuvole.util.pay.allinPay.yunstNew.po; + +import io.swagger.annotations.ApiImplicitParam; +import lombok.Data; + +/** + * Created by chenlong + * Date锛�2020/8/25 + * time锛�14:34 + */ +@Data +public class PayBack { + /** + * 鍟嗘埛涓昏鍗曞彿 + */ + public String merOrderNo; + /** + * 绯荤粺涓昏鍗曞彿 + */ + public String bizOrderNo; + /** + * 鍟嗘埛鍘熷涓昏鍗曞彿锛岄��娆剧殑鏃跺�欏繀浼� + */ + public String oriMerOrderNo; + + /** + * 绯荤粺鍘熷涓昏鍗曞彿锛岄��娆剧殑鏃跺�欏繀浼� + */ + public String oriBizOrderNo; + /** + * 璁㈠崟绫诲瀷 1锛氭秷璐� 2锛氬厖鍊� 3锛氭彁鐜� 4锛氶��璐� 5锛氫唬鏀� 6锛氫唬浠� + */ + public String orderType; + + /** + *涓昏鍗曚氦鏄撴敮浠樼姸鎬侊紝閽堝浜庢病鏈夊瓙璁㈠崟鐨勪氦鏄擄紝success:鎴愬姛锛宲ending:杩涜涓紝fail:澶辫触锛宻uccess_collection锛氫唬浠樻垚鍔燂紝collection_pending锛氫唬浠樿繘琛屼腑 + */ + public String transStatus; + /** + 浜ゆ槗璇锋眰鏃堕棿 yyyyMMddhhssmm + */ + public String payReqDataTime; + /** + * 浜ゆ槗瀹屾垚鏃堕棿 yyyyMMddhhssmm + * + */ + public String payDataTime; + /** + *浠f敹瀛愯鍗曢��璐ф椂浠f敹瀛愯鍗曞崟鍙� + * + */ + public String subOriMerOrderNo; + /** + * 鏀粯鏂瑰紡 + */ + public String paymethod; + /** + * 瀛愯鍗曪紝璇︽儏鏌ョ湅瀛愯鍗曚俊鎭� + */ + public String subOrder; +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/PayBackChild.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/PayBackChild.java new file mode 100644 index 0000000..4518a58 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/PayBackChild.java @@ -0,0 +1,32 @@ +package com.nuvole.util.pay.allinPay.yunstNew.po; + +import lombok.Data; + +/** + * Created by chenlong + * Date锛�2020/8/25 + * time锛�14:41 + */ +@Data +public class PayBackChild { + /** + * 浜ゆ槗鏀粯鐘舵�侊紝success锛堟秷璐规垚鍔�/鍒嗚处鎴愬姛銆愪唬浠樻垚鍔熴�戯級锛宲ending锛堣繘琛屼腑锛夛紝fail锛堜氦鏄撳け璐ワ級锛宻uccess_collection锛堟敹娆炬垚鍔�/浠f敹鎴愬姛)锛宑ollection_pending锛堟敹娆捐繘琛屼腑/浠f敹杩涜涓級 + */ + public String transStatus; + /** + * 鍟嗘埛瀛愯鍗曞彿 + */ + public String subMerOrderNo; + /** + * 绯荤粺瀛愯鍗曞彿 + */ + public String subBizOrderNo; + /** + *鍟嗘埛鍘熷瀛愯鍗曞彿锛岄��娆剧殑鏃跺�欏繀浼� + */ + public String subOldMerOrderNo; + /** + *绯荤粺鍘熷鍙鍗曞彿锛岄��娆剧殑鏃跺�欏繀浼� + */ + public String subOriBizOrderNo; +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/ResultVo.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/ResultVo.java new file mode 100644 index 0000000..e8897e8 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/ResultVo.java @@ -0,0 +1,15 @@ +package com.nuvole.util.pay.allinPay.yunstNew.po; + +import lombok.Data; + +/** + * Created by chenlong + * Date锛�2020/8/25 + * time锛�13:32 + */ +@Data +public class ResultVo { + public String msg; + public String code; + public String data; +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/SplitRule.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/SplitRule.java new file mode 100644 index 0000000..c6254e2 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/SplitRule.java @@ -0,0 +1,32 @@ +package com.nuvole.util.pay.allinPay.yunstNew.po; + +import lombok.Data; + +/** + * Created by chenzhimin + * Date锛�2020/9/8 + * time锛�20:27 + * 鍒嗚处瑙勫垯 + */ +@Data +public class SplitRule { + + /** + * 骞冲彴鏂瑰湪閫氬晢浜戠郴缁熺殑id 鏄� + */ + public String terMerchantId; + /** + * 鍒嗚处鏀舵浜猴紝濉啓鍟嗘埛骞冲彴鐨勪細鍛榠d 鏄� + */ + public String externalUserid; + /** + * 鍗曚綅鍏� 鏄� + */ + public String amount; + + /** + * 鍒嗚处瑙勫垯 鍚� + */ + public String splitRule; + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/SubOrder.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/SubOrder.java new file mode 100644 index 0000000..ecdf9a7 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/SubOrder.java @@ -0,0 +1,40 @@ +package com.nuvole.util.pay.allinPay.yunstNew.po; +import com.alibaba.fastjson.JSONArray; +import lombok.Data; + + + +/** + * Created by chenlong + * Date锛�2020/8/24 + * time锛�16:23 + */ +@Data +public class SubOrder { + /** + * 瀛愯鍗曚氦鏄撻噾棰濓紝鍗曚綅涓哄厓 鏄� + */ + String amount; + /** + * 璁㈠崟璇︽儏 鍚� + */ + String body; + /** + * 鍟嗘埛鏀舵鏂筰d 鏄� + */ + String recieverExId; + /** + * 鍒嗚处瑙勫垯锛岃涓嬫柟鍒嗚处瑙勫垯,鏈�澶氫笁灞傦紝鏈�澶�10浜哄垎璐︼紝涓嶄紶杈撹涓轰笉鍒嗚处锛屽叏閮ㄤ唬浠� 鍚� + */ + JSONArray splitRule; + /** + * 瀛愯鍗曡嚜鍔ㄥ垎璐︽椂闂达紝涓嶄紶灏变竴鐩存寕璧凤紝鐩村埌涓诲姩璋冧唬浠樺畬鎴愬垎璐︼紝鏁存暟锛屽崟浣嶏紝澶� 鍚� + */ + String spTime; + /** + * 鍟嗘埛瀛愭敮浠樿鍗曞彿 鏄� + */ + String subMerOrderNo; + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/YstPayUrl.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/YstPayUrl.java new file mode 100644 index 0000000..b4425dc --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/YstPayUrl.java @@ -0,0 +1,35 @@ +package com.nuvole.util.pay.allinPay.yunstNew.po; + +/** + * Created by chenlong + * Date锛�2020/8/25 + * time锛�14:01 + */ +public class YstPayUrl { + //骞冲彴鏂瑰湪琛屼笟鐗堥�氬晢浜戠郴缁熶腑鐨刬d + public static final String terMerchantId="1212908434073104385"; + //鐗堟湰鍙� + public static final String version="1.0"; + //MD5鍔犵key + public static final String ked="test"; + + + + public static final String url="https://tsytest.allinpaysc.com/api"; + + /** + * 浼氬憳鍒涘缓锛氭父瀹㈡ā寮� + */ + public static final String CREATE_SELLER_MEMBER =url+ "/terrace-service/terrace/creat/tourists/member"; + + /** + * 璋冪敤鎵樼浠f敹鎺ュ彛锛堝井淇″皬绋嬪簭鏀粯闆嗗洟妯″紡锛坱ype:2锛夛級 /鎵樼浠d粯 + */ + public static final String ORDER_PAYER =url+ "/order-service/trans/order"; + /** + *浼氬憳鍒涘缓锛氬晢鎴凤紙涓汉浼氬憳锛� + */ + public static final String CREATE_SHOP_MEMBER =url+"/terrace-service/terrace/creat/personal/member"; + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/payment/PaymentOrder.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/payment/PaymentOrder.java new file mode 100644 index 0000000..fb94d31 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/payment/PaymentOrder.java @@ -0,0 +1,52 @@ +package com.nuvole.util.pay.allinPay.yunstNew.po.payment; + +import lombok.Data; + +/** + * Created by chenzhimin + * Date锛�2020/9/8 + * time锛�20:15 + */ +@Data +public class PaymentOrder { + /** + 浠d粯涓昏鍗曞娉� + */ + public String extendInfo; + /** + * 鍟嗘埛浠f敹璁㈠崟璇锋眰浼氬憳id + */ + public String externalUserid; + + /** + * 鍟嗘埛浠d粯鏀粯璁㈠崟鍙� + */ + public String merOrderNo; + + /** + * 鍟嗘埛鍘熷浠f敹涓昏鍗曞彿锛圤ldMerOrderNo鍜孫riBizOrderNo蹇呬紶涓�涓級 + */ + public String oldMerOrderNo; + + /** + * 璁㈠崟绫诲瀷绫诲瀷锛岄粯璁ゅ~鍐�6锛堟墭绠′唬浠橈級 + * + */ + public String orderType; + /** + *绯荤粺鍘熷浠f敹涓昏鍗曞彿锛圤ldMerOrderNo鍜孫riBizOrderNo蹇呬紶涓�涓級 + */ + public String oriBizOrderNo; + + /** + * 1 绉诲姩 2 pc绔� + */ + public String source; + + + /** + * 瀛愯鍗曚俊鎭紝璇︽儏璇疯瀛愯鍗曚俊鎭紝涓嶄紶杈撶殑璇濆叏閮ㄤ唬浠橈紝鍏ㄩ儴浠d粯鐨勬椂鍊欏彧浼犺緭绯荤粺璁㈠崟鍙风殑鏃跺�欏晢鎴峰瓙璁㈠崟鍙锋槗鑱旈�氱郴缁熶笉鑷繁鐢熸垚 + */ + public String subOrder; + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/payment/PaymentSplitRule.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/payment/PaymentSplitRule.java new file mode 100644 index 0000000..6a9797b --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/payment/PaymentSplitRule.java @@ -0,0 +1,32 @@ +package com.nuvole.util.pay.allinPay.yunstNew.po.payment; + +import lombok.Data; + +/** + * Created by chenzhimin + * Date锛�2020/9/8 + * time锛�20:27 + * 鍒嗚处瑙勫垯 + */ +@Data +public class PaymentSplitRule { + + /** + * 骞冲彴鏂瑰湪閫氬晢浜戠郴缁熺殑id + */ + public String terMerchantId; + /** + * 鍒嗚处鏀舵浜猴紝濉啓鍟嗘埛骞冲彴鐨勪細鍛榠d + */ + public String externalUserid; + /** + * 鍗曚綅鍏� 鏄� + */ + public String amount; + + /** + * 鍒嗚处瑙勫垯 鍚� + */ + public String splitRule; + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/payment/PaymentSubOrder.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/payment/PaymentSubOrder.java new file mode 100644 index 0000000..9d05703 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/pay/allinPay/yunstNew/po/payment/PaymentSubOrder.java @@ -0,0 +1,31 @@ +package com.nuvole.util.pay.allinPay.yunstNew.po.payment; + +import com.alibaba.fastjson.JSONArray; +import lombok.Data; + +/** + * Created by chenzhimin + * Date锛�2020/9/8 + * time锛�20:21 + */ +@Data +public class PaymentSubOrder { + /** + * 鏇存柊鍒嗚处瑙勫垯锛岃涓嬫柟鍒嗚处瑙勫垯,鏈�澶氫笁灞傦紝鏈�澶�10浜哄垎璐︼紝涓嶄紶杈撶殑璇濇寜鐓у師鏉ヨ缃殑淇℃伅鍒嗚处 鍚� + */ + String splitRule; + /** + * 鍟嗘埛浠d粯鏀粯瀛愯鍗曞彿 鏄� + */ + String subMerOrderNo; + /** + * 鍟嗘埛鍘熷浠f敹鏀粯瀛愯鍗曞彿锛坰ubOldMerOrderNo鍜宻ubOriBizOrderNo蹇呬紶涓�涓級 鍚� + */ + String subOldMerOrderNo; + /** + * 绯荤粺鍘熷浠f敹鏀粯瀛愯鍗曞彿锛坰ubOldMerOrderNo鍜宻ubOriBizOrderNo蹇呬紶涓�涓級 鍚� + */ + String subOriBizOrderNo; + + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sc/client/domain/ScClient.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sc/client/domain/ScClient.java new file mode 100644 index 0000000..ed0c277 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sc/client/domain/ScClient.java @@ -0,0 +1,36 @@ +package com.nuvole.util.sc.client.domain; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 浼氬憳淇℃伅杩斿洖绫伙紙瀹㈢绯荤粺锛� + * + * @Author: lc + * @Date: 2019/7/11 17:50 + */ +@Data +@ApiModel(value = "浼氬憳淇℃伅杩斿洖绫伙紙瀹㈢绯荤粺锛�") +public class ScClient { + + @ApiModelProperty(value = "瀹㈡埛绛夌骇") + private String cust_lev; + + @ApiModelProperty(value = "鏍囩瀹㈢兢锛堥�楀彿鍒嗛殧褰㈠紡锛�") + private String labelsstr; + + @ApiModelProperty(value = "瀹㈡埛缁忕悊缂栧彿") + private String tlrno; + + @ApiModelProperty(value = "鏈烘瀯缂栧彿锛堝搴斾細鍛樿〃閲岀殑user_org_code锛�") + private String inst_no; + + @ApiModelProperty(value = "瀹㈡埛濮撳悕") + private String cust_name; + + @ApiModelProperty(value = "鎵嬫満鍙�") + private String tel; + + +} \ No newline at end of file diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sc/client/domain/ScGroup.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sc/client/domain/ScGroup.java new file mode 100644 index 0000000..eeed407 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sc/client/domain/ScGroup.java @@ -0,0 +1,25 @@ +package com.nuvole.util.sc.client.domain; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 瀹㈢兢杩斿洖鍊硷紙瀹㈢绯荤粺锛� + * + * @Author: lc + * @Date: 2019/11/2 12:41 + */ +@Data +@ApiModel(value = "瀹㈢兢杩斿洖鍊硷紙瀹㈢绯荤粺锛�") +public class ScGroup { + + @ApiModelProperty(value = "瀹㈢兢鍚嶇О") + private String label_name; + + @ApiModelProperty(value = "瀹㈢兢缂栧彿") + private String label_no; + + @ApiModelProperty(value = "涓婄骇鏍囩") + private String parent_label; +} \ No newline at end of file diff --git "a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sc/client/\345\233\233\345\267\235\345\256\242\347\256\241\347\263\273\347\273\237\346\216\245\345\217\243\346\226\207\346\241\243.docx" "b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sc/client/\345\233\233\345\267\235\345\256\242\347\256\241\347\263\273\347\273\237\346\216\245\345\217\243\346\226\207\346\241\243.docx" new file mode 100644 index 0000000..5488d21 --- /dev/null +++ "b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sc/client/\345\233\233\345\267\235\345\256\242\347\256\241\347\263\273\347\273\237\346\216\245\345\217\243\346\226\207\346\241\243.docx" Binary files differ diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sc/sms/ScSMSUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sc/sms/ScSMSUtil.java new file mode 100644 index 0000000..b48feb2 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sc/sms/ScSMSUtil.java @@ -0,0 +1,57 @@ +package com.nuvole.util.sc.sms; + + +import cn.hutool.core.util.StrUtil; +import com.nuvole.common.domain.emnu.SMSResultEmnu; +import com.nuvole.common.domain.result.SMSResult; +import com.wisentsoft.service.sms.gsmp.GsmpCPSrv; + +/** + * 鐭俊锛堝洓宸濈渷锛� + * + * @Author: lc + * @Date: 2019/6/1 11:09 + */ +public class ScSMSUtil { + private static String ip = "10.1.210.7"; + private static int port = 13013; + private static String cpUser = "950013"; + private static String cpPass = "950013"; + private static int timeout = 30; + private static String cpSrvId = "SCYYPDX950013"; + private static GsmpCPSrv gsmpCPSrv; + + static { + try { + if (gsmpCPSrv == null) { + gsmpCPSrv = new GsmpCPSrv(ScSMSUtil.ip, ScSMSUtil.port, ScSMSUtil.cpUser, ScSMSUtil.cpPass, ScSMSUtil.timeout, "/yypdx.log", false); + gsmpCPSrv.start(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 鍙戦�佺煭淇� + * + * @param mobile 鎵嬫満鍙风爜 + * @param message 鍙戦�佹秷鎭枃鏈� + * @return + * @throws Exception + */ + public static SMSResult sendSMS(String mobile, String message) { + + try { + String result = gsmpCPSrv.submitMTSMS(mobile, message, cpSrvId); + if (StrUtil.isEmpty(result)) { + return new SMSResult(SMSResultEmnu.ERROR, "鍙戦�佸け璐ワ紒"); + } + + return new SMSResult(SMSResultEmnu.OK); + } catch (Exception e) { + e.printStackTrace(); + return new SMSResult(SMSResultEmnu.ERROR, "鍙戦�佸紓甯革紒"); + } + } +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sms/SMSCallUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sms/SMSCallUtil.java new file mode 100644 index 0000000..7a2c439 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sms/SMSCallUtil.java @@ -0,0 +1,67 @@ +package com.nuvole.util.sms; + +import cn.hutool.core.util.RandomUtil; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSONObject; +import com.nuvole.common.domain.emnu.SMSResultEmnu; +import com.nuvole.common.domain.result.SMSResult; +import com.nuvole.constants.ServiceConstants; +import com.nuvole.util.sc.sms.ScSMSUtil; + +import java.util.HashMap; +import java.util.Map; + +/** + * 鍙戦�佺煭淇★紙缁熶竴璋冨害绫伙級 + * + * @Author: lc + * @Date: 2019/6/1 11:09 + */ +public class SMSCallUtil { + + /** + * 鐭俊鎺ュ彛绫诲瀷锛�1.浜戠墖 2.鍥涘窛鐪佸唴閮ㄦ帴鍙o級 + */ + private final static int SMS_TYPE = 1; + + /** + * 鍙戦�佺煭淇� + * + * @param mobile 鎵嬫満鍙风爜瀛楃涓� 澶氫釜鍙风爜浠ラ�楀彿鍒嗗壊 + * @param message 鐭俊鍐呭 + * @Author: lc + * @Date: 2019/6/1 11:27 + */ + public static SMSResult sendSMS(String mobile, String message) { + + //璧板缃戞湇鍔¤皟鐢� + if (ServiceConstants.SERVICE_TYPE) { + Map map = new HashMap() {{ + put("mobile", mobile); + put("message", message); + put("smsType", SMS_TYPE); + }}; + String result = HttpUtil.get(ServiceConstants.SERVICE_SMS_URL, map); + JSONObject jsonObject = JSONObject.parseObject(result); + if (!"0".equals(jsonObject.getString("code"))) { + return new SMSResult(SMSResultEmnu.ERROR, jsonObject.getString("msg")); + } + return new SMSResult(SMSResultEmnu.OK); + } else { + switch (SMS_TYPE) { + case 1: + return YpSMSUtil.sendSMS(mobile, message); + case 2: + return ScSMSUtil.sendSMS(mobile, message); + default: + break; + } + return new SMSResult(SMSResultEmnu.ERROR); + } + } + + public static void main(String[] args) { + System.out.println(sendSMS("17803846500", SMSTemplate.getVaildCodeMsg(RandomUtil.randomNumbers(6)))); + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sms/SMSHistory.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sms/SMSHistory.java new file mode 100644 index 0000000..74cb7f1 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sms/SMSHistory.java @@ -0,0 +1,29 @@ +package com.nuvole.util.sms; + + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 鐭俊鍙戦�佽褰� + * + * @Author: lc + * @Date: 2019/6/1 14:20 + */ +@Data +public class SMSHistory { + + @ApiModelProperty(value = "鎵嬫満鍙�") + private String mobile; + + @ApiModelProperty(value = "鏈�鍚庡彂閫佹椂闂�") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date lastTime; + + @ApiModelProperty(value = "娆℃暟") + private Integer num; + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sms/SMSTemplate.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sms/SMSTemplate.java new file mode 100644 index 0000000..81f84c3 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sms/SMSTemplate.java @@ -0,0 +1,84 @@ +package com.nuvole.util.sms; + + +/** + * 鐭俊妯℃澘 + * + * @Author: lc + * @Date: 2019/6/1 14:20 + */ +public class SMSTemplate { + + /** + * 鐭俊楠岃瘉鐮佽褰曟爣璇� + */ + public static final String SMS_MOILE_HISTORY_K = "SMS_MOILE_HISTORY_K:"; + + /** + * 楠岃瘉鐮佽褰曟湁鏁堟湡锛�1澶╋級 + */ + public static final Long SMS_MOILE_HISTORY_TIME = Long.valueOf(1); + + /** + * 楠岃瘉鐮佷竴灏忔椂鍙彂閫佹鏁帮紙娆★級 + */ + public static final int SMS_SEND_NUM_HOUR = 5; + + /** + * 楠岃瘉鐮佷竴澶╁彲鍙戦�佹鏁帮紙娆★級 + */ + public static final int SMS_SEND_NUM_DAY = 10; + + + /** + * 楠岃瘉鐮佹湁鏁堟湡锛堝垎閽燂級 + */ + public static final int CODE_VALIDITY_TIME = 5; + + /** + * 鐭俊楠岃瘉鐮�-鍟嗘埛閲嶇疆瀵嗙爜-鏍囪瘑 + */ + public static final String SHOP_RESET_MIX_PD_CODE = "SHOP_RESET_MIX_PD_CODE"; + + /** + * 鐭俊楠岃瘉鐮�-寰俊绔慨鏀规墜鏈哄彿-鏍囪瘑 + */ + public static final String WECHAT_SET_MOBILE = "WECHAT_SET_MOBILE"; + /** + * 鐭俊楠岃瘉鐮�-H5鍏紬鍙风鏀粯鏃讹紝娉ㄥ唽骞剁櫥闄� 鏍囪瘑 + */ + public static final String WECHAT_H5PAY_MOBILE = "WECHAT_H5PAY_MOBILE"; + /** + * 鐭俊楠岃瘉鐮�-H5鐗堝皬绋嬪簭鐧诲綍锛屾敞鍐屽苟鐧婚檰 鏍囪瘑 + */ + public static final String H5_MIN_MOBILE = "H5_MIN_MOBILE"; + + /** + * 鐭俊楠岃瘉鐮�-瀹㈡埛缁忕悊app閲嶇疆瀵嗙爜-鏍囪瘑 + */ + public static final String MANAGER_RESET_MIX_PD_CODE = "MANAGER_RESET_MIX_PD_CODE"; + + /** + * 鐭俊妯℃澘1 + */ +// private static String SEND_MSG = "銆愭槗閭摵銆戞偍鐨勯獙璇佺爜鏄�#code#銆傚闈炴湰浜烘搷浣滐紝璇峰拷鐣ユ湰鐭俊"; + private static String SEND_MSG = "銆愰噾鏄庢簮銆戦獙璇佺爜锛�#code#(30鍒嗛挓鍐呮湁鏁�)銆傝灏藉揩瀹屾垚楠岃瘉銆�"; + + //棰嗗彇淇濋櫓鐭俊楠岃瘉浜斿垎閽熸湁鏁堟爣璇� + public static final String INSURANCE_SMS_MOBILE = "INSURANCE_SMS_MOBILE"; + + //棰嗕繚鐭俊涓�鍒嗛挓鏈夋晥鏍囪瘑 + public static final String INSURANCE_SMS_MOBILE_REPLACE = "INSURANCE_SMS_MOBILE_REPLACE"; + + /** + * 鑾峰彇鐭俊鍐呭1 + * + * @Author: lc + * @Date: 2019/6/1 14:23 + */ + public static String getVaildCodeMsg(String code) { + String msg = SEND_MSG; + return msg.replaceAll("#code#", code); + } + +} diff --git a/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sms/YpSMSUtil.java b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sms/YpSMSUtil.java new file mode 100644 index 0000000..7e5ae09 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/java/com/nuvole/util/sms/YpSMSUtil.java @@ -0,0 +1,63 @@ +package com.nuvole.util.sms; + +import cn.hutool.core.util.RandomUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSONObject; +import com.nuvole.common.domain.emnu.SMSResultEmnu; +import com.nuvole.common.domain.result.SMSResult; + +import java.util.HashMap; +import java.util.Map; + +/** + * 鐭俊锛堜簯鐗囷級 + * + * @Author: lc + * @Date: 2019/6/1 11:09 + */ +public class YpSMSUtil { + + + private static String YP_SMS_K = "faf531146ca1e38abacd3862fb3fc32b"; + private static String YP_SMS_URL = "https://sms.yunpian.com/v2/sms/single_send.json"; + + + /** + * 鍙戦�佺煭淇� + * + * @param mobile 鎵嬫満鍙风爜瀛楃涓� 澶氫釜鍙风爜浠ラ�楀彿鍒嗗壊 + * @param message 鐭俊鍐呭 + * @Author: lc + * @Date: 2019/6/1 11:27 + */ + public static SMSResult sendSMS(String mobile, String message) { + + if (StrUtil.isEmpty(mobile)) { + return new SMSResult(SMSResultEmnu.ERROR, "鎵嬫満鍙蜂笉鑳戒负绌猴紒"); + } + if (StrUtil.isEmpty(message)) { + return new SMSResult(SMSResultEmnu.ERROR, "鐭俊鍐呭涓嶈兘涓虹┖锛�"); + } + try { + Map<String, Object> param = new HashMap<>(); + param.put("apikey", YP_SMS_K); + param.put("mobile", mobile); + param.put("text", message); + String msg = HttpUtil.post(YP_SMS_URL, param); + JSONObject jsonObject = JSONObject.parseObject(msg); + if (!"0".equals(jsonObject.getString("code"))) { + return new SMSResult(SMSResultEmnu.ERROR, jsonObject.getString("msg")); + } + return new SMSResult(SMSResultEmnu.OK); + } catch (Exception e) { + e.printStackTrace(); + return new SMSResult(SMSResultEmnu.ERROR, "鍙戦�佸紓甯革紒"); + } + } + + public static void main(String[] args) { + System.out.println(sendSMS("17803846500", SMSTemplate.getVaildCodeMsg(RandomUtil.randomNumbers(6)))); + } + +} diff --git a/ecosphere/ecosphere-common/src/main/resources/antisamy.xml b/ecosphere/ecosphere-common/src/main/resources/antisamy.xml new file mode 100644 index 0000000..ac55f3b --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/resources/antisamy.xml @@ -0,0 +1,2789 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> + + +<!-- +W3C rules retrieved from: +http://www.w3.org/TR/html401/struct/global.html +--> + + +<anti-samy-rules xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="antisamy.xsd"> + + <directives> + <directive name="omitXmlDeclaration" value="true"/> + <directive name="omitDoctypeDeclaration" value="true"/> + <directive name="maxInputSize" value="200000"/> + <directive name="useXHTML" value="true"/> + <directive name="formatOutput" value="true"/> + <directive name="nofollowAnchors" value="true" /> + <directive name="validateParamAsEmbed" value="true" /> + + <!-- + remember, this won't work for relative URIs - AntiSamy doesn't + know anything about the URL or your web structure + --> + <directive name="embedStyleSheets" value="false"/> + <directive name="connectionTimeout" value="5000"/> + <directive name="maxStyleSheetImports" value="3"/> + + <!-- Allows the use of dynamic attributes (i.e. HTML5 "data-") --> + <directive name="allowDynamicAttributes" value="true" /> + </directives> + + <common-regexps> + + <!-- + From W3C: + This attribute assigns a class name or set of class names to an + element. Any number of elements may be assigned the same class + name or names. Multiple class names must be separated by white + space characters. + --> + + <!-- The 16 colors defined by the HTML Spec (also used by the CSS Spec) --> + <regexp name="colorName" value="(aqua|black|blue|fuchsia|gray|grey|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow)"/> + + <!-- HTML/CSS Spec allows 3 or 6 digit hex to specify color --> + <regexp name="colorCode" value="(#([0-9a-fA-F]{6}|[0-9a-fA-F]{3}))"/> + + <regexp name="anything" value=".*"/> + <regexp name="numberOrPercent" value="(\d)+(%{0,1})"/> + <regexp name="paragraph" value="([\p{L}\p{N},'\.\s\-_\(\)\?]|&[0-9]{2};)*"/> + <regexp name="htmlId" value="[a-zA-Z0-9\:\-_\.]+"/> + <regexp name="htmlTitle" value="[\p{L}\p{N}\s\-_',:\[\]!\./\\\(\)&]*"/> <!-- force non-empty with a '+' at the end instead of '*' --> + <regexp name="htmlClass" value="[a-zA-Z0-9\s,\-_]+"/> + + <regexp name="onsiteURL" value="^(?![\p{L}\p{N}\\\.\#@\$%\+&;\-_~,\?=/!]*(&colon))[\p{L}\p{N}\\\.\#@\$%\+&;\-_~,\?=/!]*"/> + <regexp name="anchoredURL" value="#(\w)+"/> + <regexp name="offsiteURL" value="(\s)*((ht|f)tp(s?)://|mailto:)[\p{L}\p{N}]+[\p{L}\p{N}\p{Zs}\.\#@\$%\+&;:\-_~,\?=/!\(\)]*(\s)*"/> + + <regexp name="boolean" value="(true|false)"/> + <regexp name="singlePrintable" value="[a-zA-Z0-9]{1}"/> <!-- \w allows the '_' character --> + + <!-- This is for elements (ex: elemName { ... }) --> + <regexp name="cssElementSelector" value="[a-zA-Z0-9\-_]+|\*"/> + + <!-- This is to list out any element names that are *not* valid --> + <regexp name="cssElementExclusion" value=""/> + + <!-- This if for classes (ex: .className { ... }) --> + <regexp name="cssClassSelector" value="\.[a-zA-Z0-9\-_]+"/> + + <!-- This is to list out any class names that are *not* valid --> + <regexp name="cssClassExclusion" value=""/> + + <!-- This is for ID selectors (ex: #myId { ... } --> + <regexp name="cssIDSelector" value="#[a-zA-Z0-9\-_]+"/> + + <!-- This is to list out any IDs that are *not* valid - FIXME: What should the default be to avoid div hijacking? *? --> + <regexp name="cssIDExclusion" value=""/> + + <!-- This is for pseudo-element selector (ex. foo:pseudo-element { ... } --> + <regexp name="cssPseudoElementSelector" value=":[a-zA-Z0-9\-_]+"/> + + <!-- This is to list out any psuedo-element names that are *not* valid --> + <regexp name="cssPsuedoElementExclusion" value=""/> + + <!-- This is for attribute selectors (ex. foo[attr=value] { ... } --> + <regexp name="cssAttributeSelector" value="\[[a-zA-Z0-9\-_]+((=|~=|\|=){1}[a-zA-Z0-9\-_]+){1}\]"/> + + <!-- This is to list out any attribute names that are *not* valid --> + <regexp name="cssAttributeExclusion" value=""/> + + <!-- This is for resources referenced from CSS (such as background images and other imported stylesheets) --> + <regexp name="cssOnsiteUri" value="url\(([\p{L}\p{N}\\/\.\?=\#&;\-_~]+|\#(\w)+)\)"/> + <regexp name="cssOffsiteUri" value="url\((\s)*((ht|f)tp(s?)://)[\p{L}\p{N}]+[~\p{L}\p{N}\p{Zs}\-_\.@#$%&;:,\?=/\+!]*(\s)*\)"/> + + <!-- This if for CSS Identifiers --> + <regexp name="cssIdentifier" value="[a-zA-Z0-9\-_]+"/> + + <!-- This is for comments within CSS (ex. /* comment */) --> + <regexp name="cssCommentText" value="[\p{L}\p{N}\-_,\/\\\.\s\(\)!\?\=\$#%\^&:"']+"/> + + <regexp name="integer" value="(-|\+)?[0-9]+"/> + <regexp name="positiveInteger" value="(\+)?[0-9]+"/> + <regexp name="number" value="(-|\+)?([0-9]+(\.[0-9]+)?)"/> + <regexp name="angle" value="(-|\+)?([0-9]+(\.[0-9]+)?)(deg|grads|rad)"/> + <regexp name="time" value="([0-9]+(\.[0-9]+)?)(ms|s)"/> + <regexp name="frequency" value="([0-9]+(\.[0-9]+)?)(hz|khz)"/> + <regexp name="length" value="((-|\+)?0|(-|\+)?([0-9]+(\.[0-9]+)?)(em|ex|px|in|cm|mm|pt|pc))"/> + <regexp name="positiveLength" value="((\+)?0|(\+)?([0-9]+(\.[0-9]+)?)(em|ex|px|in|cm|mm|pt|pc))"/> + <regexp name="percentage" value="(-|\+)?([0-9]+(\.[0-9]+)?)%"/> + <regexp name="positivePercentage" value="(\+)?([0-9]+(\.[0-9]+)?)%"/> + + <regexp name="absolute-size" value="(xx-small|x-small|small|medium|large|x-large|xx-large)"/> + <regexp name="relative-size" value="(larger|smaller)"/> + + <!-- Used for CSS Color specifications (complex regexp expresses integer values of 0-255) --> + <regexp name="rgbCode" value="rgb\(([1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5]),([1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5]),([1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\)"/> + + <!-- CSS2 Allowed System Color Values --> + <regexp name="systemColor" value="(activeborder|activecaption|appworkspace|background|buttonface|buttonhighlight|buttonshadow|buttontext|captiontext|graytext|highlight|highlighttext|inactiveborder|inactivecaption|inactivecaptiontext|infobackground|infotext|menu|menutext|scrollbar|threeddarkshadow|threedface|threedhighlight|threedlightshadow|threedshadow|window|windowframe|windowtext)"/> + + <!-- This is where we specify what Flash src to allow --> + <regexp name="flashSites" value="http://(download\.macromedia\.com/pub|www\.macromedia\.com/(go|shockwave)|c\.brightcove\.com/services|gamevideos\.1up\.com/swf|www\.youtube\.com/v|vimeo\.com|www\.gametrailers\.com|videomedia\.ign\.com/ev|image\.com\.com/gamespot|www\.hulu\.com/embed|embed\.break\.com|player\.ordienetworks\.com/flash|www\.adultswim\.com/video/vplayer|www\.dailymotion\.com/swf|www\.ustream\.tv/flash/video|cdn-i\.dmdentertainment\.com|media\.mtvnservices\.com|www\.justin\.tv/widgets|www\.viddler\.com/(player|simple_on_site)|static\.twitter\.com/flash|www\.gamepro\.com/bin|www\.divshare\.com/flash|www\.facebook\.com/v)/.*"/> + </common-regexps> + + <!-- + + Tag.name = a, b, div, body, etc. + Tag.action = filter: remove tags, but keep content, validate: keep content as long as it passes rules, remove: remove tag and contents + Attribute.name = id, class, href, align, width, etc. + Attribute.onInvalid = what to do when the attribute is invalid, e.g., remove the tag (removeTag), remove the attribute (removeAttribute), filter the tag (filterTag) + Attribute.description = What rules in English you want to tell the users they can have for this attribute. Include helpful things so they'll be able to tune their HTML + + --> + + <!-- + Some attributes are common to all (or most) HTML tags. There aren't many that qualify for this. You have to make sure there's no + collisions between any of these attribute names with attribute names of other tags that are for different purposes. + --> + + <common-attributes> + + + <!-- Common to all HTML tags --> + + <attribute name="id" description="The 'id' of any HTML attribute should not contain anything besides letters and numbers"> + <regexp-list> + <regexp name="htmlId"/> + </regexp-list> + </attribute> + + <attribute name="classid"> + <regexp-list> + <regexp name="anything" /> + </regexp-list> + </attribute> + + <attribute name="codebase"> + <regexp-list> + <regexp name="flashSites" /> + </regexp-list> + </attribute> + + <attribute name="class" description="The 'class' of any HTML attribute is usually a single word, but it can also be a list of class names separated by spaces"> + <regexp-list> + <regexp name="htmlClass"/> + </regexp-list> + </attribute> + + <attribute name="lang" description="The 'lang' attribute tells the browser what language the element's attribute values and content are written in"> + <regexp-list> + <regexp value="[a-zA-Z]{2,20}"/> + </regexp-list> + </attribute> + <attribute name="title" description="The 'title' attribute provides text that shows up in a 'tooltip' when a user hovers their mouse over the element"> + <regexp-list> + <regexp name="htmlTitle"/> + </regexp-list> + </attribute> + + <attribute name="alt" description="The 'alt' attribute provides alternative text to users when its visual representation is not available"> + <regexp-list> + <regexp name="paragraph"/> + </regexp-list> + </attribute> + + <attribute name="data-" description="Allows the HTML5 'data-' attribute to be added to elements"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <!-- the "style" attribute will be validated by an inline stylesheet scanner, so no need to define anything here - i hate having to special case this but no other choice --> + <attribute name="style" description="The 'style' attribute provides the ability for users to change many attributes of the tag's contents using a strict syntax"/> + + <attribute name="media"> + <regexp-list> + <regexp value="[a-zA-Z0-9,\-\s]+"/> + </regexp-list> + + <literal-list> + <literal value="screen"/> + <literal value="tty"/> + <literal value="tv"/> + <literal value="projection"/> + <literal value="handheld"/> + <literal value="print"/> + <literal value="braille"/> + <literal value="aural"/> + <literal value="all"/> + </literal-list> + + </attribute> + + + <!-- Anchor related --> + + <!-- onInvalid="filterTag" has been removed as per suggestion at OWASP SJ 2007 - just "name" is valid --> + <attribute name="href"> + <regexp-list> + <regexp name="onsiteURL"/> + <regexp name="anchoredURL"/> + <regexp name="offsiteURL"/> + </regexp-list> + </attribute> + + <attribute name="name"> + <regexp-list> + + <regexp value="[a-zA-Z0-9-\_\$]+"/> + + <!-- + have to allow the $ for .NET controls - although, + will users be supplying input that has server-generated + .NET control names? methinks not, but i want to pass my + test cases + --> + + </regexp-list> + </attribute> + + + <attribute name="shape" description="The 'shape' attribute defines the shape of the selectable area"> + <literal-list> + <literal value="default"/> + <literal value="rect"/> + <literal value="circle"/> + <literal value="poly"/> + </literal-list> + </attribute> + + + + <!-- Table attributes --> + + <attribute name="border"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + <attribute name="cellpadding"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + <attribute name="cellspacing"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + <attribute name="colspan"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + <attribute name="rowspan"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + <attribute name="background"> + <regexp-list> + <regexp name="onsiteURL"/> + </regexp-list> + </attribute> + + <attribute name="bgcolor"> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + </regexp-list> + </attribute> + + <attribute name="abbr"> + <regexp-list> + <regexp name="paragraph"/> + </regexp-list> + </attribute> + + <attribute name="headers" description="The 'headers' attribute is a space-separated list of cell IDs"> + <regexp-list> + <regexp value="[a-zA-Z0-9\s*]*"/> + </regexp-list> + </attribute> + + <attribute name="charoff"> + <regexp-list> + <regexp value="numberOrPercent"/> + </regexp-list> + </attribute> + + <attribute name="char"> + <regexp-list> + <regexp value=".{0,1}"/> + </regexp-list> + </attribute> + + + <attribute name="axis" description="The 'headers' attribute is a comma-separated list of related header cells"> + <regexp-list> + <regexp value="[a-zA-Z0-9\s*,]*"/> + </regexp-list> + </attribute> + + <attribute name="nowrap" description="The 'nowrap' attribute tells the browser not to wrap text that goes over one line"> + <regexp-list> + <regexp name="anything"/> + <!-- <regexp value="(nowrap){0,1}"/> --> + </regexp-list> + </attribute> + + + <!-- Common positioning attributes --> + + <attribute name="width"> + <regexp-list> + <regexp name="numberOrPercent"/> + </regexp-list> + </attribute> + + <attribute name="height"> + <regexp-list> + <regexp name="numberOrPercent"/> + </regexp-list> + </attribute> + + <attribute name="align" description="The 'align' attribute of an HTML element is a direction word, like 'left', 'right' or 'center'"> + <literal-list> + <literal value="center"/> + <literal value="middle"/> + <literal value="left"/> + <literal value="right"/> + <literal value="justify"/> + <literal value="char"/> + </literal-list> + </attribute> + + <attribute name="valign" description="The 'valign' attribute of an HTML attribute is a direction word, like 'baseline','bottom','middle' or 'top'"> + <literal-list> + <literal value="baseline"/> + <literal value="bottom"/> + <literal value="middle"/> + <literal value="top"/> + </literal-list> + </attribute> + + + + <!-- Intrinsic JavaScript Events --> + + <attribute name="onFocus" description="The 'onFocus' event is executed when the control associated with the tag gains focus"> + <literal-list> + <literal value="javascript:void(0)"/> + <literal value="javascript:history.go(-1)"/> + </literal-list> + </attribute> + + <attribute name="onBlur" description="The 'onBlur' event is executed when the control associated with the tag loses focus"> + <literal-list> + <literal value="javascript:void(0)"/> + <literal value="javascript:history.go(-1)"/> + </literal-list> + </attribute> + + <attribute name="onClick" description="The 'onClick' event is executed when the control associated with the tag is clicked"> + <literal-list> + <literal value="javascript:void(0)"/> + <literal value="javascript:history.go(-1)"/> + </literal-list> + </attribute> + + <attribute name="onDblClick" description="The 'onDblClick' event is executed when the control associated with the tag is clicked twice immediately"> + <literal-list> + <literal value="javascript:void(0)"/> + <literal value="javascript:history.go(-1)"/> + </literal-list> + </attribute> + + <attribute name="onMouseDown" description="The 'onMouseDown' event is executed when the control associated with the tag is clicked but not yet released"> + <literal-list> + <literal value="javascript:void(0)"/> + <literal value="javascript:history.go(-1)"/> + </literal-list> + </attribute> + + <attribute name="onMouseUp" description="The 'onMouseUp' event is executed when the control associated with the tag is clicked after the button is released"> + <literal-list> + <literal value="javascript:void(0)"/> + <literal value="javascript:history.go(-1)"/> + </literal-list> + </attribute> + + <attribute name="onMouseOver" description="The 'onMouseOver' event is executed when the user's mouse hovers over the control associated with the tag"> + <literal-list> + <literal value="javascript:void(0)"/> + <literal value="javascript:history.go(-1)"/> + </literal-list> + </attribute> + + <attribute name="scope" description="The 'scope' attribute defines what's covered by the header cells"> + <literal-list> + <literal value="row"/> + <literal value="col"/> + <literal value="rowgroup"/> + <literal value="colgroup"/> + </literal-list> + </attribute> + + + + <!-- If you want users to be able to mess with tabindex, uncomment this --> + <!-- + <attribute name="tabindex" description="..."> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + --> + + + <!-- Input/form related common attributes --> + + <attribute name="disabled"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="readonly"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="accesskey"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="size"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + + <attribute name="autocomplete"> + <literal-list> + <literal value="on"/> + <literal value="off"/> + </literal-list> + </attribute> + + <attribute name="rows"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + <attribute name="cols"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + </common-attributes> + + + <!-- + This requires normal updates as browsers continue to diverge from the W3C and each other. As long as the browser wars continue + this is going to continue. I'm not sure war is the right word for what's going on. Doesn't somebody have to win a war after + a while? Even wars of attrition, surely? + --> + + <global-tag-attributes> + <!-- Not valid in base, head, html, meta, param, script, style, and title elements. --> + <attribute name="id"/> + <attribute name="style"/> + <attribute name="title"/> + <attribute name="class"/> + <!-- Not valid in base, br, frame, frameset, hr, iframe, param, and script elements. --> + <attribute name="lang"/> + </global-tag-attributes> + + <!-- Declare "dynamic" tag attributes here. The directive "allowDynamicAttributes" must be set to true --> + <dynamic-tag-attributes> + <attribute name="data-"/> <!-- HTML5 "data-" tag --> + </dynamic-tag-attributes> + + <tags-to-encode> + <tag>g</tag> + <tag>grin</tag> + </tags-to-encode> + + <tag-rules> + + <!-- You can mess with this stuff if you know what you're doing --> + + <tag name="html" action="validate"/> + + <tag name="body" action="validate"> + <attribute name="bgcolor"/> + </tag> + + <tag name="meta" action="filter"/> + + <tag name="head" action="validate"/> + + <!-- since we're validating the style sheets this is safe to have - switch to "truncate" if the user's html will appear in the html body --> + <tag name="title" action="truncate"/> + + + <!-- Tags related to JavaScript --> + + <tag name="script" action="remove"/> + <tag name="noscript" action="validate"/> <!-- although no javascript can fire inside a noscript tag, css is still a viable attack vector --> + + + + <!-- Frame & related tags --> + + <tag name="iframe" action="remove"/> + <tag name="frameset" action="remove"/> + <tag name="frame" action="remove"/> + + + + <!-- Form related tags --> + + <tag name="label" action="validate"> + <attribute name="for"> + <regexp-list> + <regexp name="htmlId"/> + </regexp-list> + </attribute> + </tag> + + + <!-- + If you wish to enable any of the form related tags, change the tag's action below from "filter" or "remove" to "validate". The attributes have been + hardened so this is safe to do, if it's something you want to allow. Beware the <><ing possibilities! + --> + + <tag name="form" action="validate"> + + <attribute name="action"> + <regexp-list> + <regexp name="onsiteURL"/> + <regexp name="offsiteURL"/> + </regexp-list> + </attribute> + + <attribute name="name"/> + + <attribute name="autocomplete"/> + + <attribute name="method"> + <literal-list> + <literal value="post"/> + <literal value="get"/> + </literal-list> + </attribute> + + </tag> + + <tag name="button" action="validate"> + <attribute name="name"/> + <attribute name="value"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="disabled"/> + <attribute name="accesskey"/> + <attribute name="type"> + <literal-list> + <literal value="submit"/> + <literal value="reset"/> + <literal value="button"/> + </literal-list> + </attribute> + </tag> + + <tag name="input" action="validate"> + + <attribute name="name"/> + + <attribute name="size"/> + + <attribute name="maxlength"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + <attribute name="autocomplete"/> + + <attribute name="checked"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="alt"/> + + <attribute name="src"> + <regexp-list> + <regexp name="onsiteURL"/> + <regexp name="offsiteURL"/> + </regexp-list> + </attribute> + + <attribute name="usemap"> + <regexp-list> + <regexp name="onsiteURL"/> + <regexp name="anchoredURL"/> + </regexp-list> + </attribute> + + <attribute name="type"> + <literal-list> + <literal value="hidden"/> + <literal value="text"/> + <literal value="password"/> + <literal value="radio"/> + <literal value="checkbox"/> + <literal value="submit"/> + <literal value="button"/> + <literal value="image"/> + <literal value="file"/> + <literal value="reset"/> + </literal-list> + </attribute> + + <attribute name="value"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="disabled"/> + <attribute name="readonly"/> + <attribute name="accesskey"/> + + <attribute name="border"/> + + </tag> + + <tag name="select" action="validate"> + + <attribute name="name"/> + <attribute name="disabled"/> + + <attribute name="multiple"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="size"/> + + </tag> + + <tag name="option" action="validate"> + + <attribute name="disabled"/> + + <attribute name="value"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="label"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="selected"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + </tag> + + <tag name="textarea" action="validate"> + <attribute name="rows"/> + <attribute name="cols"/> + <attribute name="name"/> + <attribute name="disabled"/> + <attribute name="readonly"/> + <attribute name="accesskey"/> + </tag> + + + + + <!-- All formatting tags --> + + <tag name="h1" action="validate"/> + <tag name="h2" action="validate"/> + <tag name="h3" action="validate"/> + <tag name="h4" action="validate"/> + <tag name="h5" action="validate"/> + <tag name="h6" action="validate"/> + + <tag name="p" action="validate"> + <attribute name="align"/> + </tag> + + <tag name="i" action="validate"/> + <tag name="b" action="validate"/> + <tag name="u" action="validate"/> + <tag name="strong" action="validate"/> + + <tag name="em" action="validate"/> + <tag name="small" action="validate"/> + <tag name="big" action="validate"/> + <tag name="pre" action="validate"/> + <tag name="code" action="validate"/> + <tag name="cite" action="validate"/> + <tag name="samp" action="validate"/> + <tag name="sub" action="validate"/> + <tag name="sup" action="validate"/> + <tag name="strike" action="validate"/> + <tag name="center" action="validate"/> + <tag name="blockquote" action="validate"/> + + <tag name="hr" action="validate"/> + <tag name="br" action="validate"/> + + <tag name="col" action="validate"/> + + <tag name="font" action="validate"> + <attribute name="color"> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + </regexp-list> + </attribute> + + <attribute name="face"> + <regexp-list> + <regexp value="[\w;, \-]+"/> + </regexp-list> + </attribute> + + <attribute name="size"> + <regexp-list> + <regexp value="(\+|-){0,1}(\d)+"/> + </regexp-list> + </attribute> + </tag> + + + <!-- Anchor and anchor related tags --> + + <tag name="a" action="validate"> + + <!-- onInvalid="filterTag" has been removed as per suggestion at OWASP SJ 2007 - just "name" is valid --> + <attribute name="href"/> + <attribute name="onFocus"/> + <attribute name="onBlur"/> + <attribute name="nohref"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + <attribute name="rel"> + <literal-list> + <literal value="nofollow"/> + </literal-list> + </attribute> + <attribute name="name"/> + + </tag> + + <tag name="map" action="validate"/> + + <!-- base tag removed per demo - this could be enabled with literal-list values you allow --> + <!-- + <tag name="base" action="validate"> + <attribute name="href"/> + </tag> + --> + + + + <!-- Stylesheet Tags --> + + <tag name="style" action="validate"> + <attribute name="type"> + <literal-list> + <literal value="text/css"/> + </literal-list> + </attribute> + <attribute name="media"/> + </tag> + + <tag name="span" action="validate"/> + + <tag name="div" action="validate"> + <attribute name="align"/> + </tag> + + + <!-- Image & image related tags --> + + <tag name="img" action="validate"> + <attribute name="src" onInvalid="removeTag"> + <regexp-list> + <regexp name="onsiteURL"/> + <regexp name="offsiteURL"/> + </regexp-list> + </attribute> + <attribute name="name"/> + <attribute name="alt"/> + <attribute name="height"/> + <attribute name="width"/> + <attribute name="border"/> + <attribute name="align"/> + + <attribute name="hspace"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + <attribute name="vspace"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + </tag> + + <!-- no way to do this safely without hooking up the same code to @import to embed the remote stylesheet (malicious user could change offsite resource to be malicious after validation --> + <!-- <attribute name="href" onInvalid="removeTag"/> --> + + <tag name="link" action="validate"> + + <!-- <attribute name="href" onInvalid="removeTag"/> --> + + <attribute name="media"/> + + <attribute name="type" onInvalid="removeTag"> + <literal-list> + <literal value="text/css"/> + <literal value="application/rss+xml"/> + <literal value="image/x-icon"/> + </literal-list> + </attribute> + + <attribute name="rel"> + <literal-list> + <literal value="stylesheet"/> + <literal value="shortcut icon"/> + <literal value="search"/> + <literal value="copyright"/> + <literal value="top"/> + <literal value="alternate"/> + </literal-list> + </attribute> + </tag> + + + + + + <!-- List tags --> + + <tag name="ul" action="validate"/> + <tag name="ol" action="validate"/> + <tag name="li" action="validate"/> + + + + + <!-- Dictionary tags --> + + <tag name="dd" action="truncate"/> + <tag name="dl" action="truncate"/> + <tag name="dt" action="truncate"/> + + + + + <!-- Table tags (tbody, thead, tfoot)--> + + <tag name="thead" action="validate"> + <attribute name="align"/> + <attribute name="char"/> + <attribute name="charoff"/> + <attribute name="valign"/> + </tag> + + <tag name="tbody" action="validate"> + <attribute name="align"/> + <attribute name="char"/> + <attribute name="charoff"/> + <attribute name="valign"/> + </tag> + + <tag name="tfoot" action="validate"> + <attribute name="align"/> + <attribute name="char"/> + <attribute name="charoff"/> + <attribute name="valign"/> + </tag> + + <tag name="table" action="validate"> + <attribute name="height"/> + <attribute name="width"/> + <attribute name="border"/> + <attribute name="bgcolor"/> + <attribute name="cellpadding"/> + <attribute name="cellspacing"/> + <attribute name="background"/> + <attribute name="align"/> + <attribute name="noresize"> + <literal-list> + <literal value="noresize"/> + <literal value=""/> + </literal-list> + </attribute> + </tag> + + <tag name="td" action="validate"> + <attribute name="background"/> + <attribute name="bgcolor"/> + <attribute name="abbr"/> + <attribute name="axis"/> + <attribute name="headers"/> + <attribute name="scope"/> + <attribute name="nowrap"/> + <attribute name="height"/> + <attribute name="width"/> + <attribute name="align"/> + <attribute name="char"/> + <attribute name="charoff"/> + <attribute name="valign"/> + <attribute name="colspan"/> + <attribute name="rowspan"/> + </tag> + + <tag name="th" action="validate"> + <attribute name="abbr"/> + <attribute name="axis"/> + <attribute name="headers"/> + <attribute name="scope"/> + <attribute name="nowrap"/> + <attribute name="bgcolor"/> + <attribute name="height"/> + <attribute name="width"/> + <attribute name="align"/> + <attribute name="char"/> + <attribute name="charoff"/> + <attribute name="valign"/> + <attribute name="colspan"/> + <attribute name="rowspan"/> + </tag> + + <tag name="tr" action="validate"> + <attribute name="height"/> + <attribute name="width"/> + <attribute name="align"/> + <attribute name="valign"/> + <attribute name="char"/> + <attribute name="charoff"/> + <attribute name="background"/> + </tag> + + <tag name="colgroup" action="validate"> + + <attribute name="span"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + <attribute name="width"/> + <attribute name="align"/> + <attribute name="char"/> + <attribute name="charoff"/> + <attribute name="valign"/> + </tag> + + <tag name="col" action="validate"> + <attribute name="align"/> + <attribute name="char"/> + <attribute name="charoff"/> + <attribute name="valign"/> + <attribute name="span"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + <attribute name="width"/> + </tag> + + <tag name="fieldset" action="validate"/> + <tag name="legend" action="validate"/> + + + <!-- tags for popular Flash embeds --> + + <tag name="object" action="validate"> + <attribute name="id" /> + <attribute name="classid" /> + <attribute name="codebase" /> + <attribute name="type" onInvalid="removeTag"> + <literal-list> + <literal value="application/x-shockwave-flash" /> + </literal-list> + </attribute> + <attribute name="data" onInvalid="removeTag"> + <regexp-list> + <regexp name="flashSites" /> + </regexp-list> + </attribute> + <attribute name="align" /> + <attribute name="height" /> + <attribute name="width" /> + <attribute name="alt" /> + <attribute name="bgcolor"> + <regexp-list> + <regexp name="colorCode" /> + </regexp-list> + </attribute> + </tag> + + <!-- with validateParamAsEmbed=true, this tag rule also covers <param> name/value pairs --> + <tag name="embed" action="validate"> + <attribute name="src" onInvalid="removeTag"> + <regexp-list> + <regexp name="flashSites" /> + </regexp-list> + </attribute> + <attribute name="movie" onInvalid="removeTag"> + <regexp-list> + <regexp name="flashSites" /> + </regexp-list> + </attribute> + <attribute name="pluginspage"> + <regexp-list> + <regexp name="flashSites" /> + </regexp-list> + </attribute> + <attribute name="bgcolor"> + <regexp-list> + <regexp name="colorCode" /> + </regexp-list> + </attribute> + <attribute name="base"> + <literal-list> + <literal value="http://admin.brightcove.com" /> + </literal-list> + </attribute> + <attribute name="type"> + <literal-list> + <literal value="application/x-shockwave-flash" /> + </literal-list> + </attribute> + <attribute name="name"> + <regexp-list> + <regexp name="anything" /> + </regexp-list> + </attribute> + <attribute name="flashvars"> + <regexp-list> + <regexp name="anything" /><!-- we could put something complex in here, but this is prolly fine for now--> + </regexp-list> + </attribute> + <attribute name="align" /> + <attribute name="height" /> + <attribute name="width" /> + <attribute name="allowfullscreen"> + <regexp-list> + <regexp name="boolean" /> + </regexp-list> + </attribute> + <attribute name="quality"> + <literal-list> + <literal value="high" /> + </literal-list> + </attribute> + <attribute name="allowscriptaccess"> + <literal-list> + <literal value="always" /> + <literal value="samedomain" /> + </literal-list> + </attribute> + <attribute name="seamlesstabbing"> + <regexp-list> + <regexp name="boolean" /> + </regexp-list> + </attribute> + <attribute name="swliveconnect"> + <regexp-list> + <regexp name="boolean" /> + </regexp-list> + </attribute> + <attribute name="wmode"> + <literal-list> + <literal value="transparent" /> + <literal value="window" /> + </literal-list> + </attribute> + <attribute name="allownetworking"> + <literal-list> + <literal value="all" /> + </literal-list> + </attribute> + </tag> + + </tag-rules> + + + <!-- CSS validation processing rules --> + + <css-rules> + + <property name="azimuth" description="This property is most likely to be implemented by mixing the same signal into different channels at differing volumes."> + <literal-list> + <literal value="left-side"/> + <literal value="far-left"/> + <literal value="left"/> + <literal value="center-left"/> + <literal value="center"/> + <literal value="center-right"/> + <literal value="right"/> + <literal value="far-right"/> + <literal value="right-side"/> + <literal value="behind"/> + <literal value="leftwards"/> + <literal value="rightwards"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="angle"/> + </regexp-list> + </property> + + <property name="background" description="The 'background' property is a shorthand property for setting the individual background properties (i.e., 'background-color', 'background-image', 'background-repeat', 'background-attachment' and 'background-position') at the same place in the style sheet."> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="background-color"/> + <shorthand name="background-image"/> + <shorthand name="background-repeat"/> + <shorthand name="background-attachment"/> + <shorthand name="background-position"/> + </shorthand-list> + </property> + + <property name="background-attachment" description="If a background image is specified, this property specifies whether it is fixed with regard to the viewport ('fixed') or scrolls along with the document ('scroll')."> + <literal-list> + <literal value="scroll"/> + <literal value="fixed"/> + <literal value="inherit"/> + </literal-list> + </property> + + <property name="background-color" description="This property sets the background color of an element, either a <color> value or the keyword 'transparent', to make the underlying colors shine through."> + <literal-list> + <literal value="transparent"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + </property> + + <property name="background-image" description="This property sets the background image of an element."> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="cssOffsiteUri"/> + <regexp name="cssOnsiteUri"/> + </regexp-list> + </property> + + <property name="background-position" description="If a background image has been specified, this property specifies its initial position."> + <literal-list> + <literal value="top"/> + <literal value="center"/> + <literal value="bottom"/> + <literal value="left"/> + <literal value="center"/> + <literal value="right"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="percentage"/> + <regexp name="length"/> + </regexp-list> + </property> + + <property name="background-repeat" description="If a background image is specified, this property specifies whether the image is repeated (tiled), and how."> + <literal-list> + <literal value="repeat"/> + <literal value="repeat-x"/> + <literal value="repeat-y"/> + <literal value="no-repeat"/> + <literal value="inherit"/> + </literal-list> + </property> + + <!-- Begin simple properties --> + <property name="border-collapse" default="collapse" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="collapse"/> + <literal value="separate"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="border-color" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="transparent"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + </property> + <property name="border-top-color" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + </property> + <property name="border-right-color" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + </property> + <property name="border-bottom-color" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + </property> + <property name="border-left-color" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + </property> + <property name="bottom" default="auto" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="caption-side" default="top" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="top"/> + <literal value="bottom"/> + <literal value="left"/> + <literal value="right"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="clear" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="left"/> + <literal value="right"/> + <literal value="both"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="color" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + </property> + <property name="cue-after" default="none" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="cssOffsiteUri"/> + <regexp name="cssOnsiteUri"/> + </regexp-list> + </property> + <property name="cue-before" default="none" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="cssOffsiteUri"/> + <regexp name="cssOnsiteUri"/> + </regexp-list> + </property> + <property name="direction" default="ltr" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="ltr"/> + <literal value="rtl"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="display" default="inline" description=""> + <category-list> + <category value="all"/> + </category-list> + <literal-list> + <literal value="inline"/> + <literal value="block"/> + <literal value="list-item"/> + <literal value="run-in"/> + <literal value="compact"/> + <literal value="marker"/> + <literal value="table"/> + <literal value="inline-table"/> + <literal value="table-row-group"/> + <literal value="table-header-group"/> + <literal value="table-footer-group"/> + <literal value="table-row"/> + <literal value="table-column-group"/> + <literal value="table-column"/> + <literal value="table-cell"/> + <literal value="table-caption"/> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="elevation" default="level" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="below"/> + <literal value="level"/> + <literal value="above"/> + <literal value="higher"/> + <literal value="lower"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="angle"/> + </regexp-list> + </property> + <property name="empty-cells" default="show" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="show"/> + <literal value="hide"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="float" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="left"/> + <literal value="right"/> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="font-size" default="medium" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="absolute-size"/> + <regexp name="relative-size"/> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="font-size-adjust" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </property> + <property name="font-stretch" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="wider"/> + <literal value="narrower"/> + <literal value="ultra-condensed"/> + <literal value="extra-condensed"/> + <literal value="condensed"/> + <literal value="semi-condensed"/> + <literal value="semi-expanded"/> + <literal value="expanded"/> + <literal value="extra-expanded"/> + <literal value="ultra-expanded"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="font-style" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="italic"/> + <literal value="oblique"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="font-variant" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="small-caps"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="font-weight" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="bold"/> + <literal value="bolder"/> + <literal value="lighter"/> + <literal value="100"/> + <literal value="200"/> + <literal value="300"/> + <literal value="400"/> + <literal value="500"/> + <literal value="600"/> + <literal value="700"/> + <literal value="800"/> + <literal value="900"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="height" default="auto" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="left" default="auto" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="letter-spacing" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + </regexp-list> + </property> + <property name="line-height" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="number"/> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="list-style-image" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="cssOffsiteUri"/> + <regexp name="cssOnsiteUri"/> + </regexp-list> + </property> + <property name="list-style-position" default="outside" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inside"/> + <literal value="outside"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="list-style-type" default="disc" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="disc"/> + <literal value="circle"/> + <literal value="square"/> + <literal value="decimal"/> + <literal value="decimal-leading-zero"/> + <literal value="lower-roman"/> + <literal value="upper-roman"/> + <literal value="lower-greek"/> + <literal value="lower-alpha"/> + <literal value="lower-latin"/> + <literal value="upper-alpha"/> + <literal value="upper-latin"/> + <literal value="hebrew"/> + <literal value="armenian"/> + <literal value="georgian"/> + <literal value="cjk-ideographic"/> + <literal value="hiragana"/> + <literal value="katakana"/> + <literal value="hiragana-iroha"/> + <literal value="katakana-iroha"/> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="marker-offset" default="auto" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + </regexp-list> + </property> + <property name="max-height" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="max-width" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="min-height" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="min-width" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="orphans" default="2" description=""> + <category-list> + <category value="visual"/> + <category value="paged"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="integer"/> + </regexp-list> + </property> + <property name="outline-color" default="invert" description=""> + <category-list> + <category value="visual"/> + <category value="interactive"/> + </category-list> + <literal-list> + <literal value="invert"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + </property> + <property name="overflow" default="visible" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="visible"/> + <literal value="hidden"/> + <literal value="scroll"/> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="page-break-after" default="auto" description=""> + <category-list> + <category value="visual"/> + <category value="paged"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="always"/> + <literal value="avoid"/> + <literal value="left"/> + <literal value="right"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="page-break-before" default="auto" description=""> + <category-list> + <category value="visual"/> + <category value="paged"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="always"/> + <literal value="avoid"/> + <literal value="left"/> + <literal value="right"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="page-break-inside" default="auto" description=""> + <category-list> + <category value="visual"/> + <category value="paged"/> + </category-list> + <literal-list> + <literal value="avoid"/> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="pause-after" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="time"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="pause-before" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="time"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="pitch" default="medium" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="x-low"/> + <literal value="low"/> + <literal value="medium"/> + <literal value="high"/> + <literal value="x-high"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="frequency"/> + </regexp-list> + </property> + <property name="pitch-range" default="50" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </property> + <property name="position" default="static" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="static"/> + <!-- possible to perform phishing attacks with the following --> + <!-- + <literal value="relative"/> + <literal value="absolute"/> + <literal value="fixed"/> + --> + <literal value="inherit"/> + </literal-list> + </property> + <property name="richness" default="50" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </property> + <property name="right" default="auto" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="size" default="auto" description=""> + <category-list> + <category value="visual"/> + <category value="paged"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="portrait"/> + <literal value="landscape"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + </regexp-list> + </property> + <property name="speak" default="normal" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="none"/> + <literal value="spell-out"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="speak-header" default="once" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="once"/> + <literal value="always"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="speak-numeral" default="continuous" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="digits"/> + <literal value="continuous"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="speak-punctuation" default="none" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="code"/> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="speech-rate" default="medium" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="x-slow"/> + <literal value="slow"/> + <literal value="medium"/> + <literal value="fast"/> + <literal value="x-fast"/> + <literal value="faster"/> + <literal value="slower"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </property> + <property name="stress" default="50" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </property> + <property name="table-layout" default="auto" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="fixed"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="text-indent" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="text-transform" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="capitalize"/> + <literal value="uppercase"/> + <literal value="lowercase"/> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="top" default="auto" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="unicode-bidi" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="embed"/> + <literal value="bidi-override"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="vertical-align" default="baseline" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="baseline"/> + <literal value="sub"/> + <literal value="super"/> + <literal value="top"/> + <literal value="text-top"/> + <literal value="middle"/> + <literal value="bottom"/> + <literal value="text-bottom"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="percentage"/> + <regexp name="length"/> + </regexp-list> + </property> + <property name="visibility" default="inherit" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="visible"/> + <literal value="hidden"/> + <literal value="collapse"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="volume" default="medium" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="silent"/> + <literal value="x-soft"/> + <literal value="soft"/> + <literal value="medium"/> + <literal value="loud"/> + <literal value="x-loud"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="number"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="white-space" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="pre"/> + <literal value="nowrap"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="widows" default="2" description=""> + <category-list> + <category value="visual"/> + <category value="paged"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="integer"/> + </regexp-list> + </property> + <property name="width" default="auto" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="word-spacing" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + </regexp-list> + </property> + + <!-- end simple properties --> + + <!-- begin medium properties --> + <property name="border-style" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + <literal value="none"/> + <literal value="hidden"/> + <literal value="dotted"/> + <literal value="dashed"/> + <literal value="solid"/> + <literal value="double"/> + <literal value="groove"/> + <literal value="ridge"/> + <literal value="inset"/> + <literal value="outset"/> + </literal-list> + </property> + <property name="border-top-style" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + </property> + <property name="border-right-style" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="border-bottom-style" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="border-left-style" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="border-top-width" default="medium" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-width"/> + </shorthand-list> + </property> + <property name="border-right-width" default="medium" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-width"/> + </shorthand-list> + </property> + <property name="border-bottom-width" default="medium" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-width"/> + </shorthand-list> + </property> + <property name="border-left-width" default="medium" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-width"/> + </shorthand-list> + </property> + <property name="border-width" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + <literal value="thin"/> + <literal value="medium"/> + <literal value="thick"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + </regexp-list> + </property> + <property name="margin" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + <literal value="auto"/> + </literal-list> + <regexp-list> + <regexp name="positiveLength"/> + <regexp name="positivePercentage"/> + </regexp-list> + </property> + <property name="margin-top" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="margin"/> + </shorthand-list> + </property> + <property name="margin-right" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="margin"/> + </shorthand-list> + </property> + <property name="margin-bottom" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="margin"/> + </shorthand-list> + </property> + <property name="margin-left" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="margin"/> + </shorthand-list> + </property> + <property name="outline-style" default="none" description=""> + <category-list> + <category value="visual"/> + <category value="interactive"/> + </category-list> + + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="outline-width" default="medium" description=""> + <category-list> + <category value="visual"/> + <category value="interactive"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-width"/> + </shorthand-list> + </property> + <property name="padding" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="padding-top" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="padding"/> + </shorthand-list> + </property> + <property name="padding-right" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="padding"/> + </shorthand-list> + </property> + <property name="padding-bottom" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="padding"/> + </shorthand-list> + </property> + <property name="padding-left" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="padding"/> + </shorthand-list> + </property> + <!-- end medium properties --> + + <!-- begin hard properties --> + <property name="border" description=""> + <category-list> + <category value="visual"/> + </category-list> + + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + <shorthand-list> + <shorthand name="border-width"/> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="border-top" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + <shorthand-list> + <shorthand name="border-top-width"/> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="border-right" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + <shorthand-list> + <shorthand name="border-top-width"/> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="border-bottom" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + <shorthand-list> + <shorthand name="border-top-width"/> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="border-left" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + <shorthand-list> + <shorthand name="border-top-width"/> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="cue" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="cue-before"/> + <shorthand name="cue-after"/> + </shorthand-list> + </property> + <property name="list-style" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="list-style-type"/> + <shorthand name="list-style-position"/> + <shorthand name="list-style-image"/> + </shorthand-list> + </property> + <property name="marks" default="none" description=""> + <category-list> + <category value="visual"/> + <category value="paged"/> + </category-list> + <literal-list> + <literal value="crop"/> + <literal value="cross"/> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="outline" description=""> + <category-list> + <category value="visual"/> + <category value="interactive"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="outline-color"/> + <shorthand name="outline-style"/> + <shorthand name="outline-width"/> + </shorthand-list> + </property> + <property name="pause" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="time"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="text-decoration" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="underline"/> + <literal value="overline"/> + <literal value="line-through"/> + <literal value="blink"/> + <literal value="inherit"/> + </literal-list> + </property> + <!-- end hard properties --> + <!-- begin manual properties --> + <property name="border-spacing" default="0" description="The lengths specify the distance that separates adjacent cell borders. If one length is specified, it gives both the horizontal and vertical spacing. If two are specified, the first gives the horizontal spacing and the second the vertical spacing. Lengths may not be negative."> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + </regexp-list> + </property> + <property name="clip" default="auto" description="The 'clip' property applies to elements that have a 'overflow' property with a value other than 'visible'."> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + </regexp-list> + </property> + <property name="counter-increment" default="none" description="The 'counter-increment' property accepts one or more names of counters (identifiers), each one optionally followed by an integer."> + <category-list> + <category value="all"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="cssIdentifier"/> + <regexp name="integer"/> + </regexp-list> + </property> + <property name="clip" default="auto" description="The 'clip' property applies to elements that have a 'overflow' property with a value other than 'visible'."> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + </regexp-list> + </property> + <property name="cursor" default="auto" description="This property specifies the type of cursor to be displayed for the pointing device."> + <category-list> + <category value="visual"/> + <category value="interactive"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + <literal value="crosshair"/> + <literal value="default"/> + <literal value="pointer"/> + <literal value="move"/> + <literal value="e-resize"/> + <literal value="ne-resize"/> + <literal value="nw-resize"/> + <literal value="n-resize"/> + <literal value="se-resize"/> + <literal value="sw-resize"/> + <literal value="s-resize"/> + <literal value="w-resize| text"/> + <literal value="wait"/> + <literal value="help"/> + </literal-list> + <regexp-list> + <regexp name="cssOffsiteUri"/> + <regexp name="cssOnsiteUri"/> + </regexp-list> + </property> + + <property name="text-shadow" default="none" description="This property accepts a comma-separated list of shadow effects to be applied to the text of the element."> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + <regexp name="length"/> + </regexp-list> + </property> + + <property name="font" description="The 'font' property is, except as described below, a shorthand property for setting 'font-style', 'font-variant', 'font-weight', 'font-size', 'line-height', and 'font-family', at the same place in the style sheet."> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="/"/> + <literal value="caption"/> + <literal value="icon"/> + <literal value="menu"/> + <literal value="message-box"/> + <literal value="small-caption"/> + <literal value="status-bar"/> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="font-style"/> + <shorthand name="font-variant"/> + <shorthand name="font-weight"/> + <shorthand name="font-size"/> + <shorthand name="line-height"/> + <shorthand name="font-family"/> + </shorthand-list> + </property> + + <property name="font-family" description="This property specifies a prioritized list of font family names and/or generic family names."> + <category-list> + <category value="visual"/> + </category-list> + <!-- allowing only generic font families --> + <literal-list> + <literal value="serif"/> + <literal value="arial"/> + <literal value="lucida console"/> + <literal value="sans-serif"/> + <literal value="cursive"/> + <literal value="verdana"/> + <literal value="fantasy"/> + <literal value="monospace"/> + </literal-list> + + + <regexp-list> + <regexp value="[\w,\-'" ]+"/> + </regexp-list> + + </property> + <property name="page" description="The 'page' property can be used to specify a particular type of page where an element should be displayed."> + <category-list> + <category value="visual"/> + <category value="paged"/> + </category-list> + <literal-list> + <literal value="auto"/> + </literal-list> + <regexp-list> + <regexp name="cssIdentifier"/> + </regexp-list> + </property> + <property name="play-during" default="auto" description="Similar to the 'cue-before' and 'cue-after' properties, this property specifies a sound to be played as a background while an element's content is spoken."> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="mix"/> + <literal value="repeat"/> + <literal value="none"/> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="cssOffsiteUri"/> + <regexp name="cssOnsiteUri"/> + </regexp-list> + </property> + <property name="text-align" description="This property describes how inline content of a block is aligned."> + <category-list> + <category value="visual"/> + </category-list> + <!-- For safety, ignoring string alignment which can be used to line table cells on characters --> + <literal-list> + <literal value="left"/> + <literal value="right"/> + <literal value="center"/> + <literal value="justify"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="voice-family" description="The value is a comma-separated, prioritized list of voice family names (compare with 'font-family')."> + <category-list> + <category value="aural"/> + </category-list> + <!-- Allowing only generic voice family --> + <literal-list> + <literal value="male"/> + <literal value="female"/> + <literal value="child"/> + <literal value="inherit"/> + </literal-list> + </property> + <!-- end manual properties --> + </css-rules> + + + <allowed-empty-tags> + <literal-list> + <literal value="br"/> + <literal value="hr"/> + <literal value="a"/> + <literal value="img"/> + <literal value="link"/> + <literal value="iframe"/> + <literal value="script"/> + <literal value="object"/> + <literal value="applet"/> + <literal value="frame"/> + <literal value="base"/> + <literal value="param"/> + <literal value="meta"/> + <literal value="input"/> + <literal value="textarea"/> + <literal value="embed"/> + <literal value="basefont"/> + <literal value="col"/> + <literal value="div"/> + </literal-list> + </allowed-empty-tags> + +</anti-samy-rules> diff --git a/ecosphere/ecosphere-common/src/main/resources/poscom.properties b/ecosphere/ecosphere-common/src/main/resources/poscom.properties new file mode 100644 index 0000000..626fba1 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/resources/poscom.properties @@ -0,0 +1,6 @@ +##鍟嗘埛缂栫爜 +memberCode=6A6229EEB35D992DD541598313373233 +##璇锋眰APIKEY +apiKey=4SC9154KRE0K7PA8X29FHUHVK0ZP6KNS +##妯℃澘缂栧彿 +templetId=2c0071f98c9a4bc2b11ff7fdeae9e649 diff --git a/ecosphere/ecosphere-common/src/main/resources/yunsdk.properties b/ecosphere/ecosphere-common/src/main/resources/yunsdk.properties new file mode 100644 index 0000000..76a4254 --- /dev/null +++ b/ecosphere/ecosphere-common/src/main/resources/yunsdk.properties @@ -0,0 +1,11 @@ +#通联通商云系统配置参数 +#生产环境 +#serverUrl=https://fintech.allinpay.com/service/soa +#测试环境 +serverUrl=http://116.228.64.55:6900/service/soa +sysId=1906061744156467038 +alias=1906061744156467038 +pwd=123456 +version=2.0 +path=C:/Users/Administrator/Desktop/yunst/1906061744156467038/1906061744156467038.pfx +tlCertPath=C:/Users/Administrator/Desktop/yunst/1906061744156467038/TLCert-test.cer \ No newline at end of file diff --git a/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/FileUtilTest.java b/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/FileUtilTest.java new file mode 100644 index 0000000..16a46ab --- /dev/null +++ b/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/FileUtilTest.java @@ -0,0 +1,19 @@ +package com.nuvole.util; + +import cn.hutool.core.io.FileUtil; +import org.junit.Test; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName FileUtilTest + * @date 2019/8/2 17:40 + */ +public class FileUtilTest { + + @Test + public void testTouch() { + FileUtil.touch("d://test1/test.txt"); + } + +} diff --git a/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/IdTest.java b/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/IdTest.java new file mode 100644 index 0000000..83b155b --- /dev/null +++ b/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/IdTest.java @@ -0,0 +1,106 @@ +package com.nuvole.util; + +import org.junit.Test; + +import java.util.*; + +public class IdTest { + + @Test + public void test() { + List<Long> list = new ArrayList<>(); + for (int i = 0; i < 1000; i++) { + Long id = IdGenerator.getId(); + System.out.println(i + ":======銆�" + id); + list.add(id); + } + for (int i = 0; i < 100000; i++) { + Long id = IdGenerator.getId(); + System.out.println(i + ":======銆�" + id); + list.add(id); + } + System.out.println(cheakIsRepeat(list)); + } + + + @Test + public void test1() { + List<Long> list = new ArrayList<>(); + Thread thread=new Thread(new Runnable() { + @Override + public void run() { + for (int i = 0; i < 10000; i++) { + Long id = IdGenerator.getId(); + System.out.println(i + ":======銆�" + id); + list.add(id); + } + } + }); + + + Thread thread2=new Thread(new Runnable() { + @Override + public void run() { + for (int i = 0; i < 10000; i++) { + Long id = IdGenerator.getId(); + System.out.println(i + ":======銆�" + id); + list.add(id); + } + } + }); + + thread.start(); + thread2.start(); + + + Map<Long,Integer> map = findRepetition(list); + if(map!=null){ + for (Map.Entry<Long,Integer> entry : map.entrySet()){ + if(entry.getValue()>1){ + System.out.println("鍏冪礌 "+entry.getKey()+" 閲嶅鍑虹幇"+entry.getValue()+"娆�"); + }else{ + } + } + } + } + + + private Map<Long, Integer> findRepetition(List<Long> arr){ + try{ + Thread.sleep(1000L); + }catch (Exception e){ + e.printStackTrace(); + } + Map<Long, Integer> map = new HashMap<>(); + if(arr == null || arr.size() <= 0){ + return null; + } + for(int i = 0; i < arr.size(); i ++){ + if(map.containsKey(arr.get(i))){ + map.put(arr.get(i), map.get(arr.get(i))+1); + }else{ + map.put(arr.get(i), 1); + } + } + return map; + } + + + public static boolean cheakIsRepeat(List<Long> list) { + try{ + Thread.sleep(1000L); + }catch (Exception e){ + e.printStackTrace(); + } + HashSet<Long> hashSet = new HashSet<Long>(); + for (int i = 0; i < list.size(); i++) { + hashSet.add(list.get(i)); + } + if (hashSet.size() == list.size()) { + return true; + } else { + return false; + } + } + +} diff --git a/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/JWTUtilTest.java b/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/JWTUtilTest.java new file mode 100644 index 0000000..1453cb9 --- /dev/null +++ b/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/JWTUtilTest.java @@ -0,0 +1,28 @@ +package com.nuvole.util; + +import org.junit.Test; + +import java.util.HashMap; + +/** + * @ClassName JWTUtilTest + * @Description TODO + * @Author Chen Long + * @Date 2019/8/21 + * @Version 1.0 + */ +public class JWTUtilTest { + + @Test + public void generateJwt() { + HashMap<String, Object> claims = new HashMap<>(); + claims.put("sub", "zhangsan"); + System.out.println(JWTUtil.generateJwt(JWTUtil.JWT_TYPE_PC, claims)); + } + + @Test + public void checkJWT() { + System.out.println(JWTUtil.checkJWT("o6t48fVSqCUCueyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyMWU2OTU4NWE5OGQ3MjRlMTE4YWZmMTYzZDM4NWQyOSIsImlhdCI6MTU2NjQzOTQ4NywiZXhwIjoxNTY2NDM5NDg4fQ.2PqL9bDqdtmIEvIOTN3ME5pATxST5aHWwirRhrMi4jews4YqlDkKGsc0Xj-UFxEa1pIW2sSws2KqmzeJpDPI6w")); + } + +} diff --git a/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/JsonTest.java b/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/JsonTest.java new file mode 100644 index 0000000..1678947 --- /dev/null +++ b/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/JsonTest.java @@ -0,0 +1,19 @@ +package com.nuvole.util; + +import com.alibaba.fastjson.JSON; +import com.nuvole.common.domain.dataFile.DataFile; +import org.junit.Test; + +import java.util.List; + +public class JsonTest { + + @Test + public void TestParse(){ + String image = "[{\"uid\":1562829586751,\"path\":\"/ecosphereBase/2019/7/11/8cc0253719484a768668c35175d57694.jpg\",\"name\":\"90346996.jpg\",\"url\":\"https://echftp.yqzhfw.com/ecosphereBase/2019/7/11/8cc0253719484a768668c35175d57694.jpg\"}]"; + List<DataFile> dataFiles = JSON.parseArray(image, DataFile.class); + System.out.println(dataFiles.get(0).getPath()); + System.out.println(dataFiles.size()); + } + +} diff --git a/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/MapTest.java b/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/MapTest.java new file mode 100644 index 0000000..f7f0442 --- /dev/null +++ b/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/MapTest.java @@ -0,0 +1,23 @@ +package com.nuvole.util; + +import org.junit.Test; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName MapText + * @date 2019/5/8 18:31 + */ +public class MapTest { + + @Test + public void testMap() { + Map<String, String> h = new LinkedHashMap<>(); + h.put("name", "test"); + System.out.println(h.get("NAME")); + } + +} diff --git a/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/MixPdTest.java b/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/MixPdTest.java new file mode 100644 index 0000000..f12e11f --- /dev/null +++ b/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/MixPdTest.java @@ -0,0 +1,20 @@ +package com.nuvole.util; + +import cn.hutool.crypto.SecureUtil; +import org.junit.Test; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName MixPdTest + * @date 2019/5/7 14:37 + */ +public class MixPdTest { + + @Test + public void generateMixPd() throws Exception { + String a = "zhangsan1122671457474842950"; + System.out.println(SecureUtil.md5(a)); + } + +} diff --git a/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/TreeUtilTest.java b/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/TreeUtilTest.java new file mode 100644 index 0000000..047ae38 --- /dev/null +++ b/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/TreeUtilTest.java @@ -0,0 +1,82 @@ +package com.nuvole.util; + +import com.alibaba.fastjson.JSON; +import lombok.extern.slf4j.Slf4j; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.HashMap; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName TreeUtilTest + * @date 2019/4/23 19:04 + */ +@Slf4j +public class TreeUtilTest { + @Test + public void convert2Tree() throws Exception { + + ArrayList list = new ArrayList(); + //list.add(new Node(1L, 0L, "1", "")); + list.add(new Node(2L, 1L, "1.1", "")); + list.add(new Node(3L, 1L, "1.2", "")); + list.add(new Node(4L, 3L, "1.2.1", "")); + + HashMap<String, String> mapping = new HashMap<>(); + mapping.put("byReplace", "label"); + + log.info(JSON.toJSONString(TreeUtil.convert2Tree(list ,""))); + log.info(JSON.toJSONString(TreeUtil.convert2Tree(list ,mapping))); + + } + + class Node{ + + public Node(Long id,Long pid,String name,String byReplace) { + this.id = id; + this.pid = pid; + this.name = name; + this.byReplace = byReplace; + } + + private Long id; + private Long pid; + private String name; + private String byReplace; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getPid() { + return pid; + } + + public void setPid(Long pid) { + this.pid = pid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getByReplace() { + return byReplace; + } + + public void setByReplace(String byReplace) { + this.byReplace = byReplace; + } + } + +} \ No newline at end of file diff --git a/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/XssUtilTest.java b/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/XssUtilTest.java new file mode 100644 index 0000000..f7cb456 --- /dev/null +++ b/ecosphere/ecosphere-common/src/test/java/com/nuvole/util/XssUtilTest.java @@ -0,0 +1,31 @@ +package com.nuvole.util; + +import org.apache.commons.lang.CharEncoding; +import org.junit.Test; + +/** + * @author ChenLong + * @version 1.0 + * @ClassName XssUtilTest + * @date 2019/7/16 18:42 + */ +public class XssUtilTest { + + @Test + public void clearXss() throws Exception { + String val = "<p style=\"text-align: center;\"><strong>qqq<em>qxxxx<span style=\"text-decoration: underline;\">ffffff<span style=\"text-decoration: line-through;\">fffff</span></span></em></strong></p>\n" + + "<p style=\"text-align: center;\"><strong><em><span style=\"text-decoration: underline;\"><span style=\"text-decoration: line-through;\"><img src=\"https://echftp.yqzhfw.com/ecosphereBaseDev/2019/7/16/0262f69df57f4f68acf763cacd362879.jpg\" alt=\"lalalal\" width=\"1920\" height=\"1080\" /></span></span></em></strong></p>"; + System.out.println(XssUtil.clearXss(val)); + } + + @Test + public void test() throws Exception { + String b = "aaaa"; + byte[] a = b.getBytes(CharEncoding.ISO_8859_1); + System.out.println("is a:" + a); + String s2 = XssUtil.clearXss(new String(a, CharEncoding.ISO_8859_1)); + System.out.println("s2:" + s2); + System.out.println("s2 byte:" + s2.getBytes(CharEncoding.ISO_8859_1)); + } + +} \ No newline at end of file diff --git a/ecosphere/ecosphere-common/src/test/resources/antisamy.xml b/ecosphere/ecosphere-common/src/test/resources/antisamy.xml new file mode 100644 index 0000000..ac55f3b --- /dev/null +++ b/ecosphere/ecosphere-common/src/test/resources/antisamy.xml @@ -0,0 +1,2789 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> + + +<!-- +W3C rules retrieved from: +http://www.w3.org/TR/html401/struct/global.html +--> + + +<anti-samy-rules xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="antisamy.xsd"> + + <directives> + <directive name="omitXmlDeclaration" value="true"/> + <directive name="omitDoctypeDeclaration" value="true"/> + <directive name="maxInputSize" value="200000"/> + <directive name="useXHTML" value="true"/> + <directive name="formatOutput" value="true"/> + <directive name="nofollowAnchors" value="true" /> + <directive name="validateParamAsEmbed" value="true" /> + + <!-- + remember, this won't work for relative URIs - AntiSamy doesn't + know anything about the URL or your web structure + --> + <directive name="embedStyleSheets" value="false"/> + <directive name="connectionTimeout" value="5000"/> + <directive name="maxStyleSheetImports" value="3"/> + + <!-- Allows the use of dynamic attributes (i.e. HTML5 "data-") --> + <directive name="allowDynamicAttributes" value="true" /> + </directives> + + <common-regexps> + + <!-- + From W3C: + This attribute assigns a class name or set of class names to an + element. Any number of elements may be assigned the same class + name or names. Multiple class names must be separated by white + space characters. + --> + + <!-- The 16 colors defined by the HTML Spec (also used by the CSS Spec) --> + <regexp name="colorName" value="(aqua|black|blue|fuchsia|gray|grey|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow)"/> + + <!-- HTML/CSS Spec allows 3 or 6 digit hex to specify color --> + <regexp name="colorCode" value="(#([0-9a-fA-F]{6}|[0-9a-fA-F]{3}))"/> + + <regexp name="anything" value=".*"/> + <regexp name="numberOrPercent" value="(\d)+(%{0,1})"/> + <regexp name="paragraph" value="([\p{L}\p{N},'\.\s\-_\(\)\?]|&[0-9]{2};)*"/> + <regexp name="htmlId" value="[a-zA-Z0-9\:\-_\.]+"/> + <regexp name="htmlTitle" value="[\p{L}\p{N}\s\-_',:\[\]!\./\\\(\)&]*"/> <!-- force non-empty with a '+' at the end instead of '*' --> + <regexp name="htmlClass" value="[a-zA-Z0-9\s,\-_]+"/> + + <regexp name="onsiteURL" value="^(?![\p{L}\p{N}\\\.\#@\$%\+&;\-_~,\?=/!]*(&colon))[\p{L}\p{N}\\\.\#@\$%\+&;\-_~,\?=/!]*"/> + <regexp name="anchoredURL" value="#(\w)+"/> + <regexp name="offsiteURL" value="(\s)*((ht|f)tp(s?)://|mailto:)[\p{L}\p{N}]+[\p{L}\p{N}\p{Zs}\.\#@\$%\+&;:\-_~,\?=/!\(\)]*(\s)*"/> + + <regexp name="boolean" value="(true|false)"/> + <regexp name="singlePrintable" value="[a-zA-Z0-9]{1}"/> <!-- \w allows the '_' character --> + + <!-- This is for elements (ex: elemName { ... }) --> + <regexp name="cssElementSelector" value="[a-zA-Z0-9\-_]+|\*"/> + + <!-- This is to list out any element names that are *not* valid --> + <regexp name="cssElementExclusion" value=""/> + + <!-- This if for classes (ex: .className { ... }) --> + <regexp name="cssClassSelector" value="\.[a-zA-Z0-9\-_]+"/> + + <!-- This is to list out any class names that are *not* valid --> + <regexp name="cssClassExclusion" value=""/> + + <!-- This is for ID selectors (ex: #myId { ... } --> + <regexp name="cssIDSelector" value="#[a-zA-Z0-9\-_]+"/> + + <!-- This is to list out any IDs that are *not* valid - FIXME: What should the default be to avoid div hijacking? *? --> + <regexp name="cssIDExclusion" value=""/> + + <!-- This is for pseudo-element selector (ex. foo:pseudo-element { ... } --> + <regexp name="cssPseudoElementSelector" value=":[a-zA-Z0-9\-_]+"/> + + <!-- This is to list out any psuedo-element names that are *not* valid --> + <regexp name="cssPsuedoElementExclusion" value=""/> + + <!-- This is for attribute selectors (ex. foo[attr=value] { ... } --> + <regexp name="cssAttributeSelector" value="\[[a-zA-Z0-9\-_]+((=|~=|\|=){1}[a-zA-Z0-9\-_]+){1}\]"/> + + <!-- This is to list out any attribute names that are *not* valid --> + <regexp name="cssAttributeExclusion" value=""/> + + <!-- This is for resources referenced from CSS (such as background images and other imported stylesheets) --> + <regexp name="cssOnsiteUri" value="url\(([\p{L}\p{N}\\/\.\?=\#&;\-_~]+|\#(\w)+)\)"/> + <regexp name="cssOffsiteUri" value="url\((\s)*((ht|f)tp(s?)://)[\p{L}\p{N}]+[~\p{L}\p{N}\p{Zs}\-_\.@#$%&;:,\?=/\+!]*(\s)*\)"/> + + <!-- This if for CSS Identifiers --> + <regexp name="cssIdentifier" value="[a-zA-Z0-9\-_]+"/> + + <!-- This is for comments within CSS (ex. /* comment */) --> + <regexp name="cssCommentText" value="[\p{L}\p{N}\-_,\/\\\.\s\(\)!\?\=\$#%\^&:"']+"/> + + <regexp name="integer" value="(-|\+)?[0-9]+"/> + <regexp name="positiveInteger" value="(\+)?[0-9]+"/> + <regexp name="number" value="(-|\+)?([0-9]+(\.[0-9]+)?)"/> + <regexp name="angle" value="(-|\+)?([0-9]+(\.[0-9]+)?)(deg|grads|rad)"/> + <regexp name="time" value="([0-9]+(\.[0-9]+)?)(ms|s)"/> + <regexp name="frequency" value="([0-9]+(\.[0-9]+)?)(hz|khz)"/> + <regexp name="length" value="((-|\+)?0|(-|\+)?([0-9]+(\.[0-9]+)?)(em|ex|px|in|cm|mm|pt|pc))"/> + <regexp name="positiveLength" value="((\+)?0|(\+)?([0-9]+(\.[0-9]+)?)(em|ex|px|in|cm|mm|pt|pc))"/> + <regexp name="percentage" value="(-|\+)?([0-9]+(\.[0-9]+)?)%"/> + <regexp name="positivePercentage" value="(\+)?([0-9]+(\.[0-9]+)?)%"/> + + <regexp name="absolute-size" value="(xx-small|x-small|small|medium|large|x-large|xx-large)"/> + <regexp name="relative-size" value="(larger|smaller)"/> + + <!-- Used for CSS Color specifications (complex regexp expresses integer values of 0-255) --> + <regexp name="rgbCode" value="rgb\(([1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5]),([1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5]),([1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\)"/> + + <!-- CSS2 Allowed System Color Values --> + <regexp name="systemColor" value="(activeborder|activecaption|appworkspace|background|buttonface|buttonhighlight|buttonshadow|buttontext|captiontext|graytext|highlight|highlighttext|inactiveborder|inactivecaption|inactivecaptiontext|infobackground|infotext|menu|menutext|scrollbar|threeddarkshadow|threedface|threedhighlight|threedlightshadow|threedshadow|window|windowframe|windowtext)"/> + + <!-- This is where we specify what Flash src to allow --> + <regexp name="flashSites" value="http://(download\.macromedia\.com/pub|www\.macromedia\.com/(go|shockwave)|c\.brightcove\.com/services|gamevideos\.1up\.com/swf|www\.youtube\.com/v|vimeo\.com|www\.gametrailers\.com|videomedia\.ign\.com/ev|image\.com\.com/gamespot|www\.hulu\.com/embed|embed\.break\.com|player\.ordienetworks\.com/flash|www\.adultswim\.com/video/vplayer|www\.dailymotion\.com/swf|www\.ustream\.tv/flash/video|cdn-i\.dmdentertainment\.com|media\.mtvnservices\.com|www\.justin\.tv/widgets|www\.viddler\.com/(player|simple_on_site)|static\.twitter\.com/flash|www\.gamepro\.com/bin|www\.divshare\.com/flash|www\.facebook\.com/v)/.*"/> + </common-regexps> + + <!-- + + Tag.name = a, b, div, body, etc. + Tag.action = filter: remove tags, but keep content, validate: keep content as long as it passes rules, remove: remove tag and contents + Attribute.name = id, class, href, align, width, etc. + Attribute.onInvalid = what to do when the attribute is invalid, e.g., remove the tag (removeTag), remove the attribute (removeAttribute), filter the tag (filterTag) + Attribute.description = What rules in English you want to tell the users they can have for this attribute. Include helpful things so they'll be able to tune their HTML + + --> + + <!-- + Some attributes are common to all (or most) HTML tags. There aren't many that qualify for this. You have to make sure there's no + collisions between any of these attribute names with attribute names of other tags that are for different purposes. + --> + + <common-attributes> + + + <!-- Common to all HTML tags --> + + <attribute name="id" description="The 'id' of any HTML attribute should not contain anything besides letters and numbers"> + <regexp-list> + <regexp name="htmlId"/> + </regexp-list> + </attribute> + + <attribute name="classid"> + <regexp-list> + <regexp name="anything" /> + </regexp-list> + </attribute> + + <attribute name="codebase"> + <regexp-list> + <regexp name="flashSites" /> + </regexp-list> + </attribute> + + <attribute name="class" description="The 'class' of any HTML attribute is usually a single word, but it can also be a list of class names separated by spaces"> + <regexp-list> + <regexp name="htmlClass"/> + </regexp-list> + </attribute> + + <attribute name="lang" description="The 'lang' attribute tells the browser what language the element's attribute values and content are written in"> + <regexp-list> + <regexp value="[a-zA-Z]{2,20}"/> + </regexp-list> + </attribute> + <attribute name="title" description="The 'title' attribute provides text that shows up in a 'tooltip' when a user hovers their mouse over the element"> + <regexp-list> + <regexp name="htmlTitle"/> + </regexp-list> + </attribute> + + <attribute name="alt" description="The 'alt' attribute provides alternative text to users when its visual representation is not available"> + <regexp-list> + <regexp name="paragraph"/> + </regexp-list> + </attribute> + + <attribute name="data-" description="Allows the HTML5 'data-' attribute to be added to elements"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <!-- the "style" attribute will be validated by an inline stylesheet scanner, so no need to define anything here - i hate having to special case this but no other choice --> + <attribute name="style" description="The 'style' attribute provides the ability for users to change many attributes of the tag's contents using a strict syntax"/> + + <attribute name="media"> + <regexp-list> + <regexp value="[a-zA-Z0-9,\-\s]+"/> + </regexp-list> + + <literal-list> + <literal value="screen"/> + <literal value="tty"/> + <literal value="tv"/> + <literal value="projection"/> + <literal value="handheld"/> + <literal value="print"/> + <literal value="braille"/> + <literal value="aural"/> + <literal value="all"/> + </literal-list> + + </attribute> + + + <!-- Anchor related --> + + <!-- onInvalid="filterTag" has been removed as per suggestion at OWASP SJ 2007 - just "name" is valid --> + <attribute name="href"> + <regexp-list> + <regexp name="onsiteURL"/> + <regexp name="anchoredURL"/> + <regexp name="offsiteURL"/> + </regexp-list> + </attribute> + + <attribute name="name"> + <regexp-list> + + <regexp value="[a-zA-Z0-9-\_\$]+"/> + + <!-- + have to allow the $ for .NET controls - although, + will users be supplying input that has server-generated + .NET control names? methinks not, but i want to pass my + test cases + --> + + </regexp-list> + </attribute> + + + <attribute name="shape" description="The 'shape' attribute defines the shape of the selectable area"> + <literal-list> + <literal value="default"/> + <literal value="rect"/> + <literal value="circle"/> + <literal value="poly"/> + </literal-list> + </attribute> + + + + <!-- Table attributes --> + + <attribute name="border"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + <attribute name="cellpadding"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + <attribute name="cellspacing"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + <attribute name="colspan"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + <attribute name="rowspan"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + <attribute name="background"> + <regexp-list> + <regexp name="onsiteURL"/> + </regexp-list> + </attribute> + + <attribute name="bgcolor"> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + </regexp-list> + </attribute> + + <attribute name="abbr"> + <regexp-list> + <regexp name="paragraph"/> + </regexp-list> + </attribute> + + <attribute name="headers" description="The 'headers' attribute is a space-separated list of cell IDs"> + <regexp-list> + <regexp value="[a-zA-Z0-9\s*]*"/> + </regexp-list> + </attribute> + + <attribute name="charoff"> + <regexp-list> + <regexp value="numberOrPercent"/> + </regexp-list> + </attribute> + + <attribute name="char"> + <regexp-list> + <regexp value=".{0,1}"/> + </regexp-list> + </attribute> + + + <attribute name="axis" description="The 'headers' attribute is a comma-separated list of related header cells"> + <regexp-list> + <regexp value="[a-zA-Z0-9\s*,]*"/> + </regexp-list> + </attribute> + + <attribute name="nowrap" description="The 'nowrap' attribute tells the browser not to wrap text that goes over one line"> + <regexp-list> + <regexp name="anything"/> + <!-- <regexp value="(nowrap){0,1}"/> --> + </regexp-list> + </attribute> + + + <!-- Common positioning attributes --> + + <attribute name="width"> + <regexp-list> + <regexp name="numberOrPercent"/> + </regexp-list> + </attribute> + + <attribute name="height"> + <regexp-list> + <regexp name="numberOrPercent"/> + </regexp-list> + </attribute> + + <attribute name="align" description="The 'align' attribute of an HTML element is a direction word, like 'left', 'right' or 'center'"> + <literal-list> + <literal value="center"/> + <literal value="middle"/> + <literal value="left"/> + <literal value="right"/> + <literal value="justify"/> + <literal value="char"/> + </literal-list> + </attribute> + + <attribute name="valign" description="The 'valign' attribute of an HTML attribute is a direction word, like 'baseline','bottom','middle' or 'top'"> + <literal-list> + <literal value="baseline"/> + <literal value="bottom"/> + <literal value="middle"/> + <literal value="top"/> + </literal-list> + </attribute> + + + + <!-- Intrinsic JavaScript Events --> + + <attribute name="onFocus" description="The 'onFocus' event is executed when the control associated with the tag gains focus"> + <literal-list> + <literal value="javascript:void(0)"/> + <literal value="javascript:history.go(-1)"/> + </literal-list> + </attribute> + + <attribute name="onBlur" description="The 'onBlur' event is executed when the control associated with the tag loses focus"> + <literal-list> + <literal value="javascript:void(0)"/> + <literal value="javascript:history.go(-1)"/> + </literal-list> + </attribute> + + <attribute name="onClick" description="The 'onClick' event is executed when the control associated with the tag is clicked"> + <literal-list> + <literal value="javascript:void(0)"/> + <literal value="javascript:history.go(-1)"/> + </literal-list> + </attribute> + + <attribute name="onDblClick" description="The 'onDblClick' event is executed when the control associated with the tag is clicked twice immediately"> + <literal-list> + <literal value="javascript:void(0)"/> + <literal value="javascript:history.go(-1)"/> + </literal-list> + </attribute> + + <attribute name="onMouseDown" description="The 'onMouseDown' event is executed when the control associated with the tag is clicked but not yet released"> + <literal-list> + <literal value="javascript:void(0)"/> + <literal value="javascript:history.go(-1)"/> + </literal-list> + </attribute> + + <attribute name="onMouseUp" description="The 'onMouseUp' event is executed when the control associated with the tag is clicked after the button is released"> + <literal-list> + <literal value="javascript:void(0)"/> + <literal value="javascript:history.go(-1)"/> + </literal-list> + </attribute> + + <attribute name="onMouseOver" description="The 'onMouseOver' event is executed when the user's mouse hovers over the control associated with the tag"> + <literal-list> + <literal value="javascript:void(0)"/> + <literal value="javascript:history.go(-1)"/> + </literal-list> + </attribute> + + <attribute name="scope" description="The 'scope' attribute defines what's covered by the header cells"> + <literal-list> + <literal value="row"/> + <literal value="col"/> + <literal value="rowgroup"/> + <literal value="colgroup"/> + </literal-list> + </attribute> + + + + <!-- If you want users to be able to mess with tabindex, uncomment this --> + <!-- + <attribute name="tabindex" description="..."> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + --> + + + <!-- Input/form related common attributes --> + + <attribute name="disabled"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="readonly"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="accesskey"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="size"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + + <attribute name="autocomplete"> + <literal-list> + <literal value="on"/> + <literal value="off"/> + </literal-list> + </attribute> + + <attribute name="rows"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + <attribute name="cols"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + </common-attributes> + + + <!-- + This requires normal updates as browsers continue to diverge from the W3C and each other. As long as the browser wars continue + this is going to continue. I'm not sure war is the right word for what's going on. Doesn't somebody have to win a war after + a while? Even wars of attrition, surely? + --> + + <global-tag-attributes> + <!-- Not valid in base, head, html, meta, param, script, style, and title elements. --> + <attribute name="id"/> + <attribute name="style"/> + <attribute name="title"/> + <attribute name="class"/> + <!-- Not valid in base, br, frame, frameset, hr, iframe, param, and script elements. --> + <attribute name="lang"/> + </global-tag-attributes> + + <!-- Declare "dynamic" tag attributes here. The directive "allowDynamicAttributes" must be set to true --> + <dynamic-tag-attributes> + <attribute name="data-"/> <!-- HTML5 "data-" tag --> + </dynamic-tag-attributes> + + <tags-to-encode> + <tag>g</tag> + <tag>grin</tag> + </tags-to-encode> + + <tag-rules> + + <!-- You can mess with this stuff if you know what you're doing --> + + <tag name="html" action="validate"/> + + <tag name="body" action="validate"> + <attribute name="bgcolor"/> + </tag> + + <tag name="meta" action="filter"/> + + <tag name="head" action="validate"/> + + <!-- since we're validating the style sheets this is safe to have - switch to "truncate" if the user's html will appear in the html body --> + <tag name="title" action="truncate"/> + + + <!-- Tags related to JavaScript --> + + <tag name="script" action="remove"/> + <tag name="noscript" action="validate"/> <!-- although no javascript can fire inside a noscript tag, css is still a viable attack vector --> + + + + <!-- Frame & related tags --> + + <tag name="iframe" action="remove"/> + <tag name="frameset" action="remove"/> + <tag name="frame" action="remove"/> + + + + <!-- Form related tags --> + + <tag name="label" action="validate"> + <attribute name="for"> + <regexp-list> + <regexp name="htmlId"/> + </regexp-list> + </attribute> + </tag> + + + <!-- + If you wish to enable any of the form related tags, change the tag's action below from "filter" or "remove" to "validate". The attributes have been + hardened so this is safe to do, if it's something you want to allow. Beware the <><ing possibilities! + --> + + <tag name="form" action="validate"> + + <attribute name="action"> + <regexp-list> + <regexp name="onsiteURL"/> + <regexp name="offsiteURL"/> + </regexp-list> + </attribute> + + <attribute name="name"/> + + <attribute name="autocomplete"/> + + <attribute name="method"> + <literal-list> + <literal value="post"/> + <literal value="get"/> + </literal-list> + </attribute> + + </tag> + + <tag name="button" action="validate"> + <attribute name="name"/> + <attribute name="value"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="disabled"/> + <attribute name="accesskey"/> + <attribute name="type"> + <literal-list> + <literal value="submit"/> + <literal value="reset"/> + <literal value="button"/> + </literal-list> + </attribute> + </tag> + + <tag name="input" action="validate"> + + <attribute name="name"/> + + <attribute name="size"/> + + <attribute name="maxlength"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + <attribute name="autocomplete"/> + + <attribute name="checked"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="alt"/> + + <attribute name="src"> + <regexp-list> + <regexp name="onsiteURL"/> + <regexp name="offsiteURL"/> + </regexp-list> + </attribute> + + <attribute name="usemap"> + <regexp-list> + <regexp name="onsiteURL"/> + <regexp name="anchoredURL"/> + </regexp-list> + </attribute> + + <attribute name="type"> + <literal-list> + <literal value="hidden"/> + <literal value="text"/> + <literal value="password"/> + <literal value="radio"/> + <literal value="checkbox"/> + <literal value="submit"/> + <literal value="button"/> + <literal value="image"/> + <literal value="file"/> + <literal value="reset"/> + </literal-list> + </attribute> + + <attribute name="value"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="disabled"/> + <attribute name="readonly"/> + <attribute name="accesskey"/> + + <attribute name="border"/> + + </tag> + + <tag name="select" action="validate"> + + <attribute name="name"/> + <attribute name="disabled"/> + + <attribute name="multiple"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="size"/> + + </tag> + + <tag name="option" action="validate"> + + <attribute name="disabled"/> + + <attribute name="value"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="label"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + + <attribute name="selected"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + </tag> + + <tag name="textarea" action="validate"> + <attribute name="rows"/> + <attribute name="cols"/> + <attribute name="name"/> + <attribute name="disabled"/> + <attribute name="readonly"/> + <attribute name="accesskey"/> + </tag> + + + + + <!-- All formatting tags --> + + <tag name="h1" action="validate"/> + <tag name="h2" action="validate"/> + <tag name="h3" action="validate"/> + <tag name="h4" action="validate"/> + <tag name="h5" action="validate"/> + <tag name="h6" action="validate"/> + + <tag name="p" action="validate"> + <attribute name="align"/> + </tag> + + <tag name="i" action="validate"/> + <tag name="b" action="validate"/> + <tag name="u" action="validate"/> + <tag name="strong" action="validate"/> + + <tag name="em" action="validate"/> + <tag name="small" action="validate"/> + <tag name="big" action="validate"/> + <tag name="pre" action="validate"/> + <tag name="code" action="validate"/> + <tag name="cite" action="validate"/> + <tag name="samp" action="validate"/> + <tag name="sub" action="validate"/> + <tag name="sup" action="validate"/> + <tag name="strike" action="validate"/> + <tag name="center" action="validate"/> + <tag name="blockquote" action="validate"/> + + <tag name="hr" action="validate"/> + <tag name="br" action="validate"/> + + <tag name="col" action="validate"/> + + <tag name="font" action="validate"> + <attribute name="color"> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + </regexp-list> + </attribute> + + <attribute name="face"> + <regexp-list> + <regexp value="[\w;, \-]+"/> + </regexp-list> + </attribute> + + <attribute name="size"> + <regexp-list> + <regexp value="(\+|-){0,1}(\d)+"/> + </regexp-list> + </attribute> + </tag> + + + <!-- Anchor and anchor related tags --> + + <tag name="a" action="validate"> + + <!-- onInvalid="filterTag" has been removed as per suggestion at OWASP SJ 2007 - just "name" is valid --> + <attribute name="href"/> + <attribute name="onFocus"/> + <attribute name="onBlur"/> + <attribute name="nohref"> + <regexp-list> + <regexp name="anything"/> + </regexp-list> + </attribute> + <attribute name="rel"> + <literal-list> + <literal value="nofollow"/> + </literal-list> + </attribute> + <attribute name="name"/> + + </tag> + + <tag name="map" action="validate"/> + + <!-- base tag removed per demo - this could be enabled with literal-list values you allow --> + <!-- + <tag name="base" action="validate"> + <attribute name="href"/> + </tag> + --> + + + + <!-- Stylesheet Tags --> + + <tag name="style" action="validate"> + <attribute name="type"> + <literal-list> + <literal value="text/css"/> + </literal-list> + </attribute> + <attribute name="media"/> + </tag> + + <tag name="span" action="validate"/> + + <tag name="div" action="validate"> + <attribute name="align"/> + </tag> + + + <!-- Image & image related tags --> + + <tag name="img" action="validate"> + <attribute name="src" onInvalid="removeTag"> + <regexp-list> + <regexp name="onsiteURL"/> + <regexp name="offsiteURL"/> + </regexp-list> + </attribute> + <attribute name="name"/> + <attribute name="alt"/> + <attribute name="height"/> + <attribute name="width"/> + <attribute name="border"/> + <attribute name="align"/> + + <attribute name="hspace"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + + <attribute name="vspace"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + </tag> + + <!-- no way to do this safely without hooking up the same code to @import to embed the remote stylesheet (malicious user could change offsite resource to be malicious after validation --> + <!-- <attribute name="href" onInvalid="removeTag"/> --> + + <tag name="link" action="validate"> + + <!-- <attribute name="href" onInvalid="removeTag"/> --> + + <attribute name="media"/> + + <attribute name="type" onInvalid="removeTag"> + <literal-list> + <literal value="text/css"/> + <literal value="application/rss+xml"/> + <literal value="image/x-icon"/> + </literal-list> + </attribute> + + <attribute name="rel"> + <literal-list> + <literal value="stylesheet"/> + <literal value="shortcut icon"/> + <literal value="search"/> + <literal value="copyright"/> + <literal value="top"/> + <literal value="alternate"/> + </literal-list> + </attribute> + </tag> + + + + + + <!-- List tags --> + + <tag name="ul" action="validate"/> + <tag name="ol" action="validate"/> + <tag name="li" action="validate"/> + + + + + <!-- Dictionary tags --> + + <tag name="dd" action="truncate"/> + <tag name="dl" action="truncate"/> + <tag name="dt" action="truncate"/> + + + + + <!-- Table tags (tbody, thead, tfoot)--> + + <tag name="thead" action="validate"> + <attribute name="align"/> + <attribute name="char"/> + <attribute name="charoff"/> + <attribute name="valign"/> + </tag> + + <tag name="tbody" action="validate"> + <attribute name="align"/> + <attribute name="char"/> + <attribute name="charoff"/> + <attribute name="valign"/> + </tag> + + <tag name="tfoot" action="validate"> + <attribute name="align"/> + <attribute name="char"/> + <attribute name="charoff"/> + <attribute name="valign"/> + </tag> + + <tag name="table" action="validate"> + <attribute name="height"/> + <attribute name="width"/> + <attribute name="border"/> + <attribute name="bgcolor"/> + <attribute name="cellpadding"/> + <attribute name="cellspacing"/> + <attribute name="background"/> + <attribute name="align"/> + <attribute name="noresize"> + <literal-list> + <literal value="noresize"/> + <literal value=""/> + </literal-list> + </attribute> + </tag> + + <tag name="td" action="validate"> + <attribute name="background"/> + <attribute name="bgcolor"/> + <attribute name="abbr"/> + <attribute name="axis"/> + <attribute name="headers"/> + <attribute name="scope"/> + <attribute name="nowrap"/> + <attribute name="height"/> + <attribute name="width"/> + <attribute name="align"/> + <attribute name="char"/> + <attribute name="charoff"/> + <attribute name="valign"/> + <attribute name="colspan"/> + <attribute name="rowspan"/> + </tag> + + <tag name="th" action="validate"> + <attribute name="abbr"/> + <attribute name="axis"/> + <attribute name="headers"/> + <attribute name="scope"/> + <attribute name="nowrap"/> + <attribute name="bgcolor"/> + <attribute name="height"/> + <attribute name="width"/> + <attribute name="align"/> + <attribute name="char"/> + <attribute name="charoff"/> + <attribute name="valign"/> + <attribute name="colspan"/> + <attribute name="rowspan"/> + </tag> + + <tag name="tr" action="validate"> + <attribute name="height"/> + <attribute name="width"/> + <attribute name="align"/> + <attribute name="valign"/> + <attribute name="char"/> + <attribute name="charoff"/> + <attribute name="background"/> + </tag> + + <tag name="colgroup" action="validate"> + + <attribute name="span"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + <attribute name="width"/> + <attribute name="align"/> + <attribute name="char"/> + <attribute name="charoff"/> + <attribute name="valign"/> + </tag> + + <tag name="col" action="validate"> + <attribute name="align"/> + <attribute name="char"/> + <attribute name="charoff"/> + <attribute name="valign"/> + <attribute name="span"> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </attribute> + <attribute name="width"/> + </tag> + + <tag name="fieldset" action="validate"/> + <tag name="legend" action="validate"/> + + + <!-- tags for popular Flash embeds --> + + <tag name="object" action="validate"> + <attribute name="id" /> + <attribute name="classid" /> + <attribute name="codebase" /> + <attribute name="type" onInvalid="removeTag"> + <literal-list> + <literal value="application/x-shockwave-flash" /> + </literal-list> + </attribute> + <attribute name="data" onInvalid="removeTag"> + <regexp-list> + <regexp name="flashSites" /> + </regexp-list> + </attribute> + <attribute name="align" /> + <attribute name="height" /> + <attribute name="width" /> + <attribute name="alt" /> + <attribute name="bgcolor"> + <regexp-list> + <regexp name="colorCode" /> + </regexp-list> + </attribute> + </tag> + + <!-- with validateParamAsEmbed=true, this tag rule also covers <param> name/value pairs --> + <tag name="embed" action="validate"> + <attribute name="src" onInvalid="removeTag"> + <regexp-list> + <regexp name="flashSites" /> + </regexp-list> + </attribute> + <attribute name="movie" onInvalid="removeTag"> + <regexp-list> + <regexp name="flashSites" /> + </regexp-list> + </attribute> + <attribute name="pluginspage"> + <regexp-list> + <regexp name="flashSites" /> + </regexp-list> + </attribute> + <attribute name="bgcolor"> + <regexp-list> + <regexp name="colorCode" /> + </regexp-list> + </attribute> + <attribute name="base"> + <literal-list> + <literal value="http://admin.brightcove.com" /> + </literal-list> + </attribute> + <attribute name="type"> + <literal-list> + <literal value="application/x-shockwave-flash" /> + </literal-list> + </attribute> + <attribute name="name"> + <regexp-list> + <regexp name="anything" /> + </regexp-list> + </attribute> + <attribute name="flashvars"> + <regexp-list> + <regexp name="anything" /><!-- we could put something complex in here, but this is prolly fine for now--> + </regexp-list> + </attribute> + <attribute name="align" /> + <attribute name="height" /> + <attribute name="width" /> + <attribute name="allowfullscreen"> + <regexp-list> + <regexp name="boolean" /> + </regexp-list> + </attribute> + <attribute name="quality"> + <literal-list> + <literal value="high" /> + </literal-list> + </attribute> + <attribute name="allowscriptaccess"> + <literal-list> + <literal value="always" /> + <literal value="samedomain" /> + </literal-list> + </attribute> + <attribute name="seamlesstabbing"> + <regexp-list> + <regexp name="boolean" /> + </regexp-list> + </attribute> + <attribute name="swliveconnect"> + <regexp-list> + <regexp name="boolean" /> + </regexp-list> + </attribute> + <attribute name="wmode"> + <literal-list> + <literal value="transparent" /> + <literal value="window" /> + </literal-list> + </attribute> + <attribute name="allownetworking"> + <literal-list> + <literal value="all" /> + </literal-list> + </attribute> + </tag> + + </tag-rules> + + + <!-- CSS validation processing rules --> + + <css-rules> + + <property name="azimuth" description="This property is most likely to be implemented by mixing the same signal into different channels at differing volumes."> + <literal-list> + <literal value="left-side"/> + <literal value="far-left"/> + <literal value="left"/> + <literal value="center-left"/> + <literal value="center"/> + <literal value="center-right"/> + <literal value="right"/> + <literal value="far-right"/> + <literal value="right-side"/> + <literal value="behind"/> + <literal value="leftwards"/> + <literal value="rightwards"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="angle"/> + </regexp-list> + </property> + + <property name="background" description="The 'background' property is a shorthand property for setting the individual background properties (i.e., 'background-color', 'background-image', 'background-repeat', 'background-attachment' and 'background-position') at the same place in the style sheet."> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="background-color"/> + <shorthand name="background-image"/> + <shorthand name="background-repeat"/> + <shorthand name="background-attachment"/> + <shorthand name="background-position"/> + </shorthand-list> + </property> + + <property name="background-attachment" description="If a background image is specified, this property specifies whether it is fixed with regard to the viewport ('fixed') or scrolls along with the document ('scroll')."> + <literal-list> + <literal value="scroll"/> + <literal value="fixed"/> + <literal value="inherit"/> + </literal-list> + </property> + + <property name="background-color" description="This property sets the background color of an element, either a <color> value or the keyword 'transparent', to make the underlying colors shine through."> + <literal-list> + <literal value="transparent"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + </property> + + <property name="background-image" description="This property sets the background image of an element."> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="cssOffsiteUri"/> + <regexp name="cssOnsiteUri"/> + </regexp-list> + </property> + + <property name="background-position" description="If a background image has been specified, this property specifies its initial position."> + <literal-list> + <literal value="top"/> + <literal value="center"/> + <literal value="bottom"/> + <literal value="left"/> + <literal value="center"/> + <literal value="right"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="percentage"/> + <regexp name="length"/> + </regexp-list> + </property> + + <property name="background-repeat" description="If a background image is specified, this property specifies whether the image is repeated (tiled), and how."> + <literal-list> + <literal value="repeat"/> + <literal value="repeat-x"/> + <literal value="repeat-y"/> + <literal value="no-repeat"/> + <literal value="inherit"/> + </literal-list> + </property> + + <!-- Begin simple properties --> + <property name="border-collapse" default="collapse" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="collapse"/> + <literal value="separate"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="border-color" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="transparent"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + </property> + <property name="border-top-color" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + </property> + <property name="border-right-color" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + </property> + <property name="border-bottom-color" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + </property> + <property name="border-left-color" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + </property> + <property name="bottom" default="auto" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="caption-side" default="top" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="top"/> + <literal value="bottom"/> + <literal value="left"/> + <literal value="right"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="clear" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="left"/> + <literal value="right"/> + <literal value="both"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="color" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + </property> + <property name="cue-after" default="none" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="cssOffsiteUri"/> + <regexp name="cssOnsiteUri"/> + </regexp-list> + </property> + <property name="cue-before" default="none" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="cssOffsiteUri"/> + <regexp name="cssOnsiteUri"/> + </regexp-list> + </property> + <property name="direction" default="ltr" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="ltr"/> + <literal value="rtl"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="display" default="inline" description=""> + <category-list> + <category value="all"/> + </category-list> + <literal-list> + <literal value="inline"/> + <literal value="block"/> + <literal value="list-item"/> + <literal value="run-in"/> + <literal value="compact"/> + <literal value="marker"/> + <literal value="table"/> + <literal value="inline-table"/> + <literal value="table-row-group"/> + <literal value="table-header-group"/> + <literal value="table-footer-group"/> + <literal value="table-row"/> + <literal value="table-column-group"/> + <literal value="table-column"/> + <literal value="table-cell"/> + <literal value="table-caption"/> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="elevation" default="level" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="below"/> + <literal value="level"/> + <literal value="above"/> + <literal value="higher"/> + <literal value="lower"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="angle"/> + </regexp-list> + </property> + <property name="empty-cells" default="show" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="show"/> + <literal value="hide"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="float" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="left"/> + <literal value="right"/> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="font-size" default="medium" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="absolute-size"/> + <regexp name="relative-size"/> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="font-size-adjust" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </property> + <property name="font-stretch" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="wider"/> + <literal value="narrower"/> + <literal value="ultra-condensed"/> + <literal value="extra-condensed"/> + <literal value="condensed"/> + <literal value="semi-condensed"/> + <literal value="semi-expanded"/> + <literal value="expanded"/> + <literal value="extra-expanded"/> + <literal value="ultra-expanded"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="font-style" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="italic"/> + <literal value="oblique"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="font-variant" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="small-caps"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="font-weight" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="bold"/> + <literal value="bolder"/> + <literal value="lighter"/> + <literal value="100"/> + <literal value="200"/> + <literal value="300"/> + <literal value="400"/> + <literal value="500"/> + <literal value="600"/> + <literal value="700"/> + <literal value="800"/> + <literal value="900"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="height" default="auto" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="left" default="auto" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="letter-spacing" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + </regexp-list> + </property> + <property name="line-height" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="number"/> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="list-style-image" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="cssOffsiteUri"/> + <regexp name="cssOnsiteUri"/> + </regexp-list> + </property> + <property name="list-style-position" default="outside" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inside"/> + <literal value="outside"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="list-style-type" default="disc" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="disc"/> + <literal value="circle"/> + <literal value="square"/> + <literal value="decimal"/> + <literal value="decimal-leading-zero"/> + <literal value="lower-roman"/> + <literal value="upper-roman"/> + <literal value="lower-greek"/> + <literal value="lower-alpha"/> + <literal value="lower-latin"/> + <literal value="upper-alpha"/> + <literal value="upper-latin"/> + <literal value="hebrew"/> + <literal value="armenian"/> + <literal value="georgian"/> + <literal value="cjk-ideographic"/> + <literal value="hiragana"/> + <literal value="katakana"/> + <literal value="hiragana-iroha"/> + <literal value="katakana-iroha"/> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="marker-offset" default="auto" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + </regexp-list> + </property> + <property name="max-height" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="max-width" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="min-height" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="min-width" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="orphans" default="2" description=""> + <category-list> + <category value="visual"/> + <category value="paged"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="integer"/> + </regexp-list> + </property> + <property name="outline-color" default="invert" description=""> + <category-list> + <category value="visual"/> + <category value="interactive"/> + </category-list> + <literal-list> + <literal value="invert"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + </property> + <property name="overflow" default="visible" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="visible"/> + <literal value="hidden"/> + <literal value="scroll"/> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="page-break-after" default="auto" description=""> + <category-list> + <category value="visual"/> + <category value="paged"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="always"/> + <literal value="avoid"/> + <literal value="left"/> + <literal value="right"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="page-break-before" default="auto" description=""> + <category-list> + <category value="visual"/> + <category value="paged"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="always"/> + <literal value="avoid"/> + <literal value="left"/> + <literal value="right"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="page-break-inside" default="auto" description=""> + <category-list> + <category value="visual"/> + <category value="paged"/> + </category-list> + <literal-list> + <literal value="avoid"/> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="pause-after" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="time"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="pause-before" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="time"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="pitch" default="medium" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="x-low"/> + <literal value="low"/> + <literal value="medium"/> + <literal value="high"/> + <literal value="x-high"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="frequency"/> + </regexp-list> + </property> + <property name="pitch-range" default="50" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </property> + <property name="position" default="static" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="static"/> + <!-- possible to perform phishing attacks with the following --> + <!-- + <literal value="relative"/> + <literal value="absolute"/> + <literal value="fixed"/> + --> + <literal value="inherit"/> + </literal-list> + </property> + <property name="richness" default="50" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </property> + <property name="right" default="auto" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="size" default="auto" description=""> + <category-list> + <category value="visual"/> + <category value="paged"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="portrait"/> + <literal value="landscape"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + </regexp-list> + </property> + <property name="speak" default="normal" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="none"/> + <literal value="spell-out"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="speak-header" default="once" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="once"/> + <literal value="always"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="speak-numeral" default="continuous" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="digits"/> + <literal value="continuous"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="speak-punctuation" default="none" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="code"/> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="speech-rate" default="medium" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="x-slow"/> + <literal value="slow"/> + <literal value="medium"/> + <literal value="fast"/> + <literal value="x-fast"/> + <literal value="faster"/> + <literal value="slower"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </property> + <property name="stress" default="50" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="number"/> + </regexp-list> + </property> + <property name="table-layout" default="auto" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="fixed"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="text-indent" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="text-transform" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="capitalize"/> + <literal value="uppercase"/> + <literal value="lowercase"/> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="top" default="auto" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="unicode-bidi" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="embed"/> + <literal value="bidi-override"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="vertical-align" default="baseline" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="baseline"/> + <literal value="sub"/> + <literal value="super"/> + <literal value="top"/> + <literal value="text-top"/> + <literal value="middle"/> + <literal value="bottom"/> + <literal value="text-bottom"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="percentage"/> + <regexp name="length"/> + </regexp-list> + </property> + <property name="visibility" default="inherit" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="visible"/> + <literal value="hidden"/> + <literal value="collapse"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="volume" default="medium" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="silent"/> + <literal value="x-soft"/> + <literal value="soft"/> + <literal value="medium"/> + <literal value="loud"/> + <literal value="x-loud"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="number"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="white-space" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="pre"/> + <literal value="nowrap"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="widows" default="2" description=""> + <category-list> + <category value="visual"/> + <category value="paged"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="integer"/> + </regexp-list> + </property> + <property name="width" default="auto" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="word-spacing" default="normal" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="normal"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + </regexp-list> + </property> + + <!-- end simple properties --> + + <!-- begin medium properties --> + <property name="border-style" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + <literal value="none"/> + <literal value="hidden"/> + <literal value="dotted"/> + <literal value="dashed"/> + <literal value="solid"/> + <literal value="double"/> + <literal value="groove"/> + <literal value="ridge"/> + <literal value="inset"/> + <literal value="outset"/> + </literal-list> + </property> + <property name="border-top-style" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + </property> + <property name="border-right-style" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="border-bottom-style" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="border-left-style" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="border-top-width" default="medium" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-width"/> + </shorthand-list> + </property> + <property name="border-right-width" default="medium" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-width"/> + </shorthand-list> + </property> + <property name="border-bottom-width" default="medium" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-width"/> + </shorthand-list> + </property> + <property name="border-left-width" default="medium" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-width"/> + </shorthand-list> + </property> + <property name="border-width" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + <literal value="thin"/> + <literal value="medium"/> + <literal value="thick"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + </regexp-list> + </property> + <property name="margin" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + <literal value="auto"/> + </literal-list> + <regexp-list> + <regexp name="positiveLength"/> + <regexp name="positivePercentage"/> + </regexp-list> + </property> + <property name="margin-top" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="margin"/> + </shorthand-list> + </property> + <property name="margin-right" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="margin"/> + </shorthand-list> + </property> + <property name="margin-bottom" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="margin"/> + </shorthand-list> + </property> + <property name="margin-left" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="margin"/> + </shorthand-list> + </property> + <property name="outline-style" default="none" description=""> + <category-list> + <category value="visual"/> + <category value="interactive"/> + </category-list> + + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="outline-width" default="medium" description=""> + <category-list> + <category value="visual"/> + <category value="interactive"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="border-width"/> + </shorthand-list> + </property> + <property name="padding" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="padding-top" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="padding"/> + </shorthand-list> + </property> + <property name="padding-right" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="padding"/> + </shorthand-list> + </property> + <property name="padding-bottom" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="padding"/> + </shorthand-list> + </property> + <property name="padding-left" default="0" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="padding"/> + </shorthand-list> + </property> + <!-- end medium properties --> + + <!-- begin hard properties --> + <property name="border" description=""> + <category-list> + <category value="visual"/> + </category-list> + + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + <shorthand-list> + <shorthand name="border-width"/> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="border-top" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + <shorthand-list> + <shorthand name="border-top-width"/> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="border-right" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + <shorthand-list> + <shorthand name="border-top-width"/> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="border-bottom" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + <shorthand-list> + <shorthand name="border-top-width"/> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="border-left" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + </regexp-list> + <shorthand-list> + <shorthand name="border-top-width"/> + <shorthand name="border-style"/> + </shorthand-list> + </property> + <property name="cue" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="cue-before"/> + <shorthand name="cue-after"/> + </shorthand-list> + </property> + <property name="list-style" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="list-style-type"/> + <shorthand name="list-style-position"/> + <shorthand name="list-style-image"/> + </shorthand-list> + </property> + <property name="marks" default="none" description=""> + <category-list> + <category value="visual"/> + <category value="paged"/> + </category-list> + <literal-list> + <literal value="crop"/> + <literal value="cross"/> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="outline" description=""> + <category-list> + <category value="visual"/> + <category value="interactive"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="outline-color"/> + <shorthand name="outline-style"/> + <shorthand name="outline-width"/> + </shorthand-list> + </property> + <property name="pause" description=""> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="time"/> + <regexp name="percentage"/> + </regexp-list> + </property> + <property name="text-decoration" default="none" description=""> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="underline"/> + <literal value="overline"/> + <literal value="line-through"/> + <literal value="blink"/> + <literal value="inherit"/> + </literal-list> + </property> + <!-- end hard properties --> + <!-- begin manual properties --> + <property name="border-spacing" default="0" description="The lengths specify the distance that separates adjacent cell borders. If one length is specified, it gives both the horizontal and vertical spacing. If two are specified, the first gives the horizontal spacing and the second the vertical spacing. Lengths may not be negative."> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + </regexp-list> + </property> + <property name="clip" default="auto" description="The 'clip' property applies to elements that have a 'overflow' property with a value other than 'visible'."> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + </regexp-list> + </property> + <property name="counter-increment" default="none" description="The 'counter-increment' property accepts one or more names of counters (identifiers), each one optionally followed by an integer."> + <category-list> + <category value="all"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="cssIdentifier"/> + <regexp name="integer"/> + </regexp-list> + </property> + <property name="clip" default="auto" description="The 'clip' property applies to elements that have a 'overflow' property with a value other than 'visible'."> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="length"/> + </regexp-list> + </property> + <property name="cursor" default="auto" description="This property specifies the type of cursor to be displayed for the pointing device."> + <category-list> + <category value="visual"/> + <category value="interactive"/> + </category-list> + <literal-list> + <literal value="auto"/> + <literal value="inherit"/> + <literal value="crosshair"/> + <literal value="default"/> + <literal value="pointer"/> + <literal value="move"/> + <literal value="e-resize"/> + <literal value="ne-resize"/> + <literal value="nw-resize"/> + <literal value="n-resize"/> + <literal value="se-resize"/> + <literal value="sw-resize"/> + <literal value="s-resize"/> + <literal value="w-resize| text"/> + <literal value="wait"/> + <literal value="help"/> + </literal-list> + <regexp-list> + <regexp name="cssOffsiteUri"/> + <regexp name="cssOnsiteUri"/> + </regexp-list> + </property> + + <property name="text-shadow" default="none" description="This property accepts a comma-separated list of shadow effects to be applied to the text of the element."> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="none"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="colorName"/> + <regexp name="colorCode"/> + <regexp name="rgbCode"/> + <regexp name="systemColor"/> + <regexp name="length"/> + </regexp-list> + </property> + + <property name="font" description="The 'font' property is, except as described below, a shorthand property for setting 'font-style', 'font-variant', 'font-weight', 'font-size', 'line-height', and 'font-family', at the same place in the style sheet."> + <category-list> + <category value="visual"/> + </category-list> + <literal-list> + <literal value="/"/> + <literal value="caption"/> + <literal value="icon"/> + <literal value="menu"/> + <literal value="message-box"/> + <literal value="small-caption"/> + <literal value="status-bar"/> + <literal value="inherit"/> + </literal-list> + <shorthand-list> + <shorthand name="font-style"/> + <shorthand name="font-variant"/> + <shorthand name="font-weight"/> + <shorthand name="font-size"/> + <shorthand name="line-height"/> + <shorthand name="font-family"/> + </shorthand-list> + </property> + + <property name="font-family" description="This property specifies a prioritized list of font family names and/or generic family names."> + <category-list> + <category value="visual"/> + </category-list> + <!-- allowing only generic font families --> + <literal-list> + <literal value="serif"/> + <literal value="arial"/> + <literal value="lucida console"/> + <literal value="sans-serif"/> + <literal value="cursive"/> + <literal value="verdana"/> + <literal value="fantasy"/> + <literal value="monospace"/> + </literal-list> + + + <regexp-list> + <regexp value="[\w,\-'" ]+"/> + </regexp-list> + + </property> + <property name="page" description="The 'page' property can be used to specify a particular type of page where an element should be displayed."> + <category-list> + <category value="visual"/> + <category value="paged"/> + </category-list> + <literal-list> + <literal value="auto"/> + </literal-list> + <regexp-list> + <regexp name="cssIdentifier"/> + </regexp-list> + </property> + <property name="play-during" default="auto" description="Similar to the 'cue-before' and 'cue-after' properties, this property specifies a sound to be played as a background while an element's content is spoken."> + <category-list> + <category value="aural"/> + </category-list> + <literal-list> + <literal value="mix"/> + <literal value="repeat"/> + <literal value="none"/> + <literal value="auto"/> + <literal value="inherit"/> + </literal-list> + <regexp-list> + <regexp name="cssOffsiteUri"/> + <regexp name="cssOnsiteUri"/> + </regexp-list> + </property> + <property name="text-align" description="This property describes how inline content of a block is aligned."> + <category-list> + <category value="visual"/> + </category-list> + <!-- For safety, ignoring string alignment which can be used to line table cells on characters --> + <literal-list> + <literal value="left"/> + <literal value="right"/> + <literal value="center"/> + <literal value="justify"/> + <literal value="inherit"/> + </literal-list> + </property> + <property name="voice-family" description="The value is a comma-separated, prioritized list of voice family names (compare with 'font-family')."> + <category-list> + <category value="aural"/> + </category-list> + <!-- Allowing only generic voice family --> + <literal-list> + <literal value="male"/> + <literal value="female"/> + <literal value="child"/> + <literal value="inherit"/> + </literal-list> + </property> + <!-- end manual properties --> + </css-rules> + + + <allowed-empty-tags> + <literal-list> + <literal value="br"/> + <literal value="hr"/> + <literal value="a"/> + <literal value="img"/> + <literal value="link"/> + <literal value="iframe"/> + <literal value="script"/> + <literal value="object"/> + <literal value="applet"/> + <literal value="frame"/> + <literal value="base"/> + <literal value="param"/> + <literal value="meta"/> + <literal value="input"/> + <literal value="textarea"/> + <literal value="embed"/> + <literal value="basefont"/> + <literal value="col"/> + <literal value="div"/> + </literal-list> + </allowed-empty-tags> + +</anti-samy-rules> diff --git a/ecosphere/pom.xml b/ecosphere/pom.xml new file mode 100644 index 0000000..3df0d96 --- /dev/null +++ b/ecosphere/pom.xml @@ -0,0 +1,293 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.dromara</groupId> + <artifactId>ruoyi-cloud-plus</artifactId> + <version>${revision}</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <modules> + <module>ecosphere-common</module> +<!-- <module>ecosphere-base-rest</module>--> + </modules> + + <artifactId>ecosphere</artifactId> + <packaging>pom</packaging> + + <description> + ruoyi-modules涓氬姟妯″潡 + </description> + + <dependencies> + <!-- 鑷畾涔夎礋杞藉潎琛�(澶氬洟闃熷紑鍙戜娇鐢�) --> +<!-- <dependency>--> +<!-- <groupId>org.dromara</groupId>--> +<!-- <artifactId>ruoyi-common-loadbalancer</artifactId>--> +<!-- </dependency>--> + + <!-- ELK 鏃ュ織鏀堕泦 --> +<!-- <dependency>--> +<!-- <groupId>org.dromara</groupId>--> +<!-- <artifactId>ruoyi-common-logstash</artifactId>--> +<!-- </dependency>--> + + <!-- skywalking 鏃ュ織鏀堕泦 --> +<!-- <dependency>--> +<!-- <groupId>org.dromara</groupId>--> +<!-- <artifactId>ruoyi-common-skylog</artifactId>--> +<!-- </dependency>--> + + <!-- prometheus 鐩戞帶 --> +<!-- <dependency>--> +<!-- <groupId>org.dromara</groupId>--> +<!-- <artifactId>ruoyi-common-prometheus</artifactId>--> +<!-- </dependency>--> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + </dependency> + + <dependency> + <groupId>cn.hutool</groupId> + <artifactId>hutool-crypto</artifactId> +<!-- <version>4.5.3</version>--> + </dependency> + + <dependency> + <groupId>cn.hutool</groupId> + <artifactId>hutool-core</artifactId> +<!-- <version>4.5.3</version>--> + </dependency> + + <dependency> + <groupId>cn.hutool</groupId> + <artifactId>hutool-extra</artifactId> +<!-- <version>4.5.3</version>--> + </dependency> + + <dependency> + <groupId>cn.hutool</groupId> + <artifactId>hutool-poi</artifactId> +<!-- <version>4.5.3</version>--> + </dependency> + + <dependency> + <groupId>cn.hutool</groupId> + <artifactId>hutool-http</artifactId> +<!-- <version>4.5.3</version>--> + </dependency> + <dependency> + <groupId>cn.hutool</groupId> + <artifactId>hutool-json</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.poi</groupId> + <artifactId>poi-ooxml-schemas</artifactId> + <version>4.0.1</version> + </dependency> + + <dependency> + <groupId>org.apache.poi</groupId> + <artifactId>poi-ooxml</artifactId> + <version>4.0.1</version> + </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-aop</artifactId> + <version>1.5.19.RELEASE</version> + </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + <version>1.5.19.RELEASE</version> + </dependency> + + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <version>5.1.47</version> + </dependency> + + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <version>1.16.18</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>com.alibaba</groupId> + <artifactId>fastjson</artifactId> + <version>1.2.83</version> + </dependency> + + <dependency> + <groupId>commons-net</groupId> + <artifactId>commons-net</artifactId> + <version>3.6</version> + </dependency> + + <dependency> + <groupId>com.jcraft</groupId> + <artifactId>jsch</artifactId> + <version>0.1.54</version> + </dependency> + + <dependency> + <groupId>org.owasp.esapi</groupId> + <artifactId>esapi</artifactId> + <version>2.1.0.1</version> + </dependency> + + <dependency> + <groupId>io.jsonwebtoken</groupId> + <artifactId>jjwt</artifactId> + </dependency> + + <dependency> + <groupId>com.auth0</groupId> + <artifactId>java-jwt</artifactId> + </dependency> + </dependencies> + + <dependencyManagement> + <dependencies> + + <dependency> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-dependencies</artifactId> + <version>Finchley.RELEASE</version> + <type>pom</type> + <scope>import</scope> + </dependency> + + <dependency> + <groupId>org.owasp.antisamy</groupId> + <artifactId>antisamy</artifactId> + <version>1.5.8</version> + </dependency> + + <dependency> + <groupId>io.springfox</groupId> + <artifactId>springfox-swagger2</artifactId> + <version>2.9.2</version> + </dependency> + + <dependency> + <groupId>com.github.pagehelper</groupId> + <artifactId>pagehelper-spring-boot-starter</artifactId> + <version>1.2.3</version> + </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + <version>2.0.3.RELEASE</version> + </dependency> + + <dependency> + <groupId>com.alibaba</groupId> + <artifactId>druid-spring-boot-starter</artifactId> + <version>1.1.10</version> + </dependency> + + <dependency> + <groupId>com.github.xiaoymin</groupId> + <artifactId>swagger-bootstrap-ui</artifactId> + <version>1.8.9</version> + </dependency> + + <dependency> + <groupId>commons-beanutils</groupId> + <artifactId>commons-beanutils</artifactId> + <version>1.9.3</version> + </dependency> + + <dependency> + <groupId>cglib</groupId> + <artifactId>cglib</artifactId> + <version>3.2.10</version> + </dependency> + + <dependency> + <groupId>com.belerweb</groupId> + <artifactId>pinyin4j</artifactId> + <version>2.5.1</version> + </dependency> + + <dependency> + <groupId>com.nuvole</groupId> + <artifactId>ecosphere-common</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>com.nuvole</groupId> + <artifactId>ecosphere-base-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>com.nuvole</groupId> + <artifactId>ecosphere-shop-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-amqp</artifactId> + <version>2.0.3.RELEASE</version> + </dependency> + + <dependency> + <groupId>com.github.ulisesbocchio</groupId> + <artifactId>jasypt-spring-boot-starter</artifactId> + <version>2.1.0</version> + </dependency> + + <dependency> + <groupId>io.jsonwebtoken</groupId> + <artifactId>jjwt</artifactId> + <version>0.9.1</version> + </dependency> + + <dependency> + <groupId>com.auth0</groupId> + <artifactId>java-jwt</artifactId> + <version>3.4.0</version> + </dependency> + + </dependencies> + </dependencyManagement> + <properties> +<!-- <revision>2.1.2</revision>--> + <spring-cloud-alibaba.version>2022.0.0.0</spring-cloud-alibaba.version> + <sentinel.version>1.8.6</sentinel.version> + <seata.version>1.7.1</seata.version> + <nacos.client.version>2.2.1</nacos.client.version> + <dubbo.version>3.2.7</dubbo.version> + <spring.context.support.version>1.0.11</spring.context.support.version> + </properties> + + <pluginRepositories> + <pluginRepository> + <id>public</id> + <name>nexus-jmy</name> + <url>http://116.198.39.83:7100/repository/maven-public/</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> +</project> -- Gitblit v1.9.1