5.27
生成sign:按字典排序,有下划线靠前
String A
= "amount=" + amount
+ "&check_name=" + "NO_CHECK"
+ "&desc=" + desc
+ "&mch_appid=" + appId
+ "&mchid=" + mchId
+ "&nonce_str=" + noncestr
+ "&openid=" + openId
+ "&partner_trade_no=" + partnerTradeNo;
String stringSignTemp = A
+ "&key=" +key;
paramMap.put("sign", MD5(stringSignTemp));
BigDecimal初始化最好用String
让编号位数相同,在几千范围内可以先加1000之后减去
for (int j = 1000; j
报错:67行报空指针 实际错误在68行 -> 换行的原因
5.25
1.提现功能
资金入账,提现绑定(冻结资金),运营商审核,提现,(失败返回资金),返回信息。
1.微信提供企业向个人付款的功能。企业通过APPID+OpenID锁定目标用户,向用户付款,因此只有关注了企业公众号的用户才能付款成功。
2.企业付款的公众号可以和微信公众号相同,但公众号的收款账号和付款账号不能共享。企业付款需要下载数字证书,Java只需要商户证书文件apiclient_cert.p12。
3.登陆商户平台开通企业付款到个人
5.21
3.maven
2.swagger
1.1 swagger下拉框
@ApiOperation(value = "测试swagger下拉框")
@ApiImplicitParams({
@ApiImplicitParam(name = "type", value = "类型", dataType = "String", paramType = "query",
allowableValues = "苹果,荔枝,菠萝", allowMultiple = true)
})
@RequestMapping(value = "/select", method = {RequestMethod.GET})
public String[] mystyle(String[] type) {
return type;
}
1.2 分组配置
@Bean("质量管理")
public Docket controller1Apis() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("质量管理")
.select()
.apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
.paths(PathSelectors.regex("/quality/.*"))
.build()
.apiInfo(apiInfo())
.enable(swaggerEnabled);
}
其中“"/quality/.*”就是controller中配置的url,会根据controller里面配置的url分spec
1.3 整体配置
@Configuration
public class Swagger2Configurer {
@Resource
private ConfigUtil configUtil;
/**
* 正式环境标识
*/
private static String DEV = "prod";
@Bean
public Docket createRestApi() {
if (DEV.equals(configUtil.SPRING_PROFILES_ACTIVE)) {
ParameterBuilder aParameterBuilder = new ParameterBuilder();
aParameterBuilder
.name("Authorization")
.description("Authorization").defaultValue("Bearer ")
.modelRef(new ModelRef("string"))
.parameterType("header")
.required(true)
.build();
ParameterBuilder userParameterBuilder = new ParameterBuilder();
userParameterBuilder
.name("Account")
.description("Account").defaultValue("PC账号名字")
.modelRef(new ModelRef("string"))
.parameterType("header")
.required(true)
.build();
List aParameters = Lists.newArrayList();
aParameters.add(aParameterBuilder.build());
aParameters.add(userParameterBuilder.build());
return new Docket(DocumentationType.SWAGGER_2)
.enable(configUtil.SWAGGER_ENABLE)
.host(configUtil.SWAGGER_OPS_HOST)
.globalOperationParameters(aParameters)
.apiInfo(apiInfo())
.select()
// 检索的包下面的控制器
.apis(RequestHandlerSelectors.basePackage(configUtil.BASE_PACKAGE))
.paths(PathSelectors.any())
.build();
}
return new Docket(DocumentationType.SWAGGER_2)
.enable(configUtil.SWAGGER_ENABLE)
.host(configUtil.SWAGGER_BASE_HOST)
.apiInfo(apiInfo())
.select()
// 检索的包下面的控制器
.apis(RequestHandlerSelectors.basePackage(configUtil.BASE_PACKAGE))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("机器平台")
.termsOfServiceUrl("xxx")
.version("1.0")
.build();
}
}
1.JApiDocs
2.1获取项目根路径, 其中xxx是当前的类名
- 根据上下文获取
ServletActionContext.getServletContext().getRealPath("");
或getRequest().getSession().getServletContext().getRealPath("");
这种在普通情况下是正常可以用的,但是在定时器里就不好使了,会报空指针异常,这是就要使用下面的方法了
- 根据当前类获取
path = xxx.class.getClassLoader().getResource("/").getPath();// 这个是classes文件夹路径
path = path.replace("/WEB-INF/classes", ""); //这个是root文件夹路径
- 获取子文件夹
xxx.class.getClassLoader().getResource(“文件”).getPath(); //获取classes路径下“文件”的路径
- 无类加载器
xxx.class.getResource(“”).getPath();// 缺少类加载器,获取xxx类经编译后的xxx.class路径
2.2 配置
tip: maven导入报找不到不要紧,直接reload
public class JApiDocs {
public static void main(String[] args) {
DocsConfig config = new DocsConfig();
config.setProjectPath("/Users/xxx/Desktop/ch_-sale_-module"); // 项目根目录
config.setProjectName("xxx"); // 项目名称
config.addJavaSrcPath("/Users/mjl/Desktop/ch_-sale_-module/controller/extra/src/main/java/com/xxx/xxxx/controller/extra");//设置模块,可不写
config.setApiVersion("V1.0"); // 声明该API的版本
config.setDocsPath("/Users/mjl/Desktop/ch_-sale_-module/doc"); // 生成API 文档所在目录
config.setAutoGenerate(Boolean.TRUE); // 配置自动生成
Docs.buildHtmlDocs(config); // 执行生成文档
}
}
2.3
报错:java.nio.file.NoSuchFileException: /V1.0/apidoc.log.lck
at sun.nio.fs.UnixException.translateToIOException
解决:按照报错设置完整的文件夹绝对路径,并添加文件夹V1.0和文件apidoc.log.lck
2.4
报错:Exception in thread "main" java.lang.NoClassDefFoundError: freemarker/template/TemplateException
解决:向lib文件夹中复制“freemarker-xx.xx.jar”包