mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 10:38:42 +08:00 
			
		
		
		
	🐛 修复几个问题
1.修复微信公众号无法模板消息行业:其他 2.修复第三方平台无法上传标准模板的代码到小程序 3.修复小程序代码模板类型类字段拼写错误
This commit is contained in:
		| @ -2,6 +2,9 @@ package me.chanjar.weixin.mp.bean.template; | |||||||
|  |  | ||||||
| import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||||
| import lombok.Getter; | import lombok.Getter; | ||||||
|  | import org.jetbrains.annotations.Nullable; | ||||||
|  |  | ||||||
|  | import java.util.Objects; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 模版消息行业枚举. |  * 模版消息行业枚举. | ||||||
| @ -195,15 +198,19 @@ public enum WxMpTemplateIndustryEnum { | |||||||
|    * |    * | ||||||
|    * @param firstClass  主行业名称 |    * @param firstClass  主行业名称 | ||||||
|    * @param secondClass 副行业名称 |    * @param secondClass 副行业名称 | ||||||
|    * @return . |    * @return 如果找不到, 返回null | ||||||
|    */ |    */ | ||||||
|  |   @Nullable | ||||||
|   public static WxMpTemplateIndustryEnum findByClass(String firstClass, String secondClass) { |   public static WxMpTemplateIndustryEnum findByClass(String firstClass, String secondClass) { | ||||||
|     for (WxMpTemplateIndustryEnum industryEnum : WxMpTemplateIndustryEnum.values()) { |     for (WxMpTemplateIndustryEnum industryEnum : WxMpTemplateIndustryEnum.values()) { | ||||||
|       if (industryEnum.firstClass.equals(firstClass) && industryEnum.secondClass.contains(secondClass)) { |       if (industryEnum.firstClass.equals(firstClass) && industryEnum.secondClass.contains(secondClass)) { | ||||||
|         return industryEnum; |         return industryEnum; | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |     if (Objects.equals(firstClass, "其他") && Objects.equals(secondClass, "其他")) { | ||||||
|  |       //微信返回的其他行业实际上为"其他",而非"其它",此处兼容处理 | ||||||
|  |       return OTHER; | ||||||
|  |     } | ||||||
|     return null; |     return null; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | |||||||
| @ -3,7 +3,6 @@ package me.chanjar.weixin.open.api; | |||||||
| import cn.binarywang.wx.miniapp.api.WxMaService; | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||||
| import cn.binarywang.wx.miniapp.bean.WxMaAuditMediaUploadResult; | import cn.binarywang.wx.miniapp.bean.WxMaAuditMediaUploadResult; | ||||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||||
| import me.chanjar.weixin.open.bean.ma.WxMaOpenCommitExtInfo; |  | ||||||
| import me.chanjar.weixin.open.bean.ma.WxMaScheme; | import me.chanjar.weixin.open.bean.ma.WxMaScheme; | ||||||
| import me.chanjar.weixin.open.bean.message.WxOpenMaSubmitAuditMessage; | import me.chanjar.weixin.open.bean.message.WxOpenMaSubmitAuditMessage; | ||||||
| import me.chanjar.weixin.open.bean.result.*; | import me.chanjar.weixin.open.bean.result.*; | ||||||
| @ -379,14 +378,18 @@ public interface WxOpenMaService extends WxMaService { | |||||||
|   /** |   /** | ||||||
|    * 1、为授权的小程序帐号上传小程序代码 |    * 1、为授权的小程序帐号上传小程序代码 | ||||||
|    * |    * | ||||||
|    * @param templateId  代码模板ID |    * @param templateId    代码模板ID | ||||||
|    * @param userVersion 用户定义版本 |    * @param userVersion   用户定义版本 | ||||||
|    * @param userDesc    用户定义版本描述 |    * @param userDesc      用户定义版本描述 | ||||||
|    * @param extInfo     第三方自定义的配置 |    * @param extJsonObject 为了方便第三方平台的开发者引入 extAppid 的开发调试工作,引入ext.json配置文件概念,该参数则是用于控制ext.json配置文件的内容。 | ||||||
|  |    *                      如果是普通模板可以使用 WxMaOpenCommitExtInfo 类构造参数, | ||||||
|  |    *                      如果是标准模板可支持的参数为:{"extAppid":'', "ext": {}, "window": {}} 所以可以使用 WxMaOpenCommitStandardExt 构造参数 | ||||||
|    * @return the wx open result |    * @return the wx open result | ||||||
|    * @throws WxErrorException the wx error exception |    * @throws WxErrorException the wx error exception | ||||||
|  |    * @see me.chanjar.weixin.open.bean.ma.WxMaOpenCommitStandardExt | ||||||
|  |    * @see me.chanjar.weixin.open.bean.ma.WxMaOpenCommitExtInfo | ||||||
|    */ |    */ | ||||||
|   WxOpenResult codeCommit(Long templateId, String userVersion, String userDesc, WxMaOpenCommitExtInfo extInfo) throws WxErrorException; |   WxOpenResult codeCommit(Long templateId, String userVersion, String userDesc, Object extJsonObject) throws WxErrorException; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 获取体验小程序的体验二维码 |    * 获取体验小程序的体验二维码 | ||||||
| @ -617,6 +620,7 @@ public interface WxOpenMaService extends WxMaService { | |||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 为小程序开通小商店组件 |    * 为小程序开通小商店组件 | ||||||
|  |    * | ||||||
|    * @return |    * @return | ||||||
|    */ |    */ | ||||||
|   WxOpenResult registerShopComponent() throws WxErrorException; |   WxOpenResult registerShopComponent() throws WxErrorException; | ||||||
| @ -630,6 +634,7 @@ public interface WxOpenMaService extends WxMaService { | |||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 小程序审核 提审素材上传接口 |    * 小程序审核 提审素材上传接口 | ||||||
|  |    * | ||||||
|    * @return |    * @return | ||||||
|    */ |    */ | ||||||
|   WxMaAuditMediaUploadResult uploadMedia(File file) throws WxErrorException; |   WxMaAuditMediaUploadResult uploadMedia(File file) throws WxErrorException; | ||||||
|  | |||||||
| @ -16,7 +16,6 @@ import me.chanjar.weixin.common.error.WxErrorException; | |||||||
| import me.chanjar.weixin.open.api.WxOpenComponentService; | import me.chanjar.weixin.open.api.WxOpenComponentService; | ||||||
| import me.chanjar.weixin.open.api.WxOpenMaBasicService; | import me.chanjar.weixin.open.api.WxOpenMaBasicService; | ||||||
| import me.chanjar.weixin.open.api.WxOpenMaService; | import me.chanjar.weixin.open.api.WxOpenMaService; | ||||||
| import me.chanjar.weixin.open.bean.ma.WxMaOpenCommitExtInfo; |  | ||||||
| import me.chanjar.weixin.open.bean.ma.WxMaQrcodeParam; | import me.chanjar.weixin.open.bean.ma.WxMaQrcodeParam; | ||||||
| import me.chanjar.weixin.open.bean.ma.WxMaScheme; | import me.chanjar.weixin.open.bean.ma.WxMaScheme; | ||||||
| import me.chanjar.weixin.open.bean.message.WxOpenMaSubmitAuditMessage; | import me.chanjar.weixin.open.bean.message.WxOpenMaSubmitAuditMessage; | ||||||
| @ -185,13 +184,13 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public WxOpenResult codeCommit(Long templateId, String userVersion, String userDesc, WxMaOpenCommitExtInfo extInfo) throws WxErrorException { |   public WxOpenResult codeCommit(Long templateId, String userVersion, String userDesc, Object extJsonObject) throws WxErrorException { | ||||||
|     JsonObject params = new JsonObject(); |     JsonObject params = new JsonObject(); | ||||||
|     params.addProperty("template_id", templateId); |     params.addProperty("template_id", templateId); | ||||||
|     params.addProperty("user_version", userVersion); |     params.addProperty("user_version", userVersion); | ||||||
|     params.addProperty("user_desc", userDesc); |     params.addProperty("user_desc", userDesc); | ||||||
|     //注意:ext_json必须是字符串类型 |     //注意:ext_json必须是字符串类型 | ||||||
|     params.addProperty("ext_json", GSON.toJson(extInfo)); |     params.addProperty("ext_json", GSON.toJson(extJsonObject)); | ||||||
|     String response = post(API_CODE_COMMIT, GSON.toJson(params)); |     String response = post(API_CODE_COMMIT, GSON.toJson(params)); | ||||||
|     return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); |     return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -6,6 +6,8 @@ import lombok.Data; | |||||||
| import java.io.Serializable; | import java.io.Serializable; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  |  * 小程序代码模板 | ||||||
|  |  * | ||||||
|  * @author <a href="https://github.com/charmingoh">Charming</a> |  * @author <a href="https://github.com/charmingoh">Charming</a> | ||||||
|  * @since 2018-04-26 17:10 |  * @since 2018-04-26 17:10 | ||||||
|  */ |  */ | ||||||
| @ -37,7 +39,7 @@ public class WxOpenMaCodeTemplate implements Serializable { | |||||||
|    * 模板类型 0对应普通模板,1对应标准模板 |    * 模板类型 0对应普通模板,1对应标准模板 | ||||||
|    */ |    */ | ||||||
|   @SerializedName(value = "templateType", alternate = "template_type") |   @SerializedName(value = "templateType", alternate = "template_type") | ||||||
|   private Integer template_type; |   private Integer templateType; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 开发者上传草稿时间 / 被添加为模版的时间 |    * 开发者上传草稿时间 / 被添加为模版的时间 | ||||||
|  | |||||||
| @ -19,6 +19,29 @@ import java.util.Map; | |||||||
|  * https://developers.weixin.qq.com/miniprogram/dev/devtools/ext.html#%E5%B0%8F%E7%A8%8B%E5%BA%8F%E6%A8%A1%E6%9D%BF%E5%BC%80%E5%8F%91 |  * https://developers.weixin.qq.com/miniprogram/dev/devtools/ext.html#%E5%B0%8F%E7%A8%8B%E5%BA%8F%E6%A8%A1%E6%9D%BF%E5%BC%80%E5%8F%91 | ||||||
|  * </p> |  * </p> | ||||||
|  * |  * | ||||||
|  |  * <p> | ||||||
|  |  * ext_json补充说明 | ||||||
|  |  * 文档地址:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/commit.html | ||||||
|  |  * 为了便于第三方平台使用同一个小程序模板为不同的小程序提供服务,第三方可以将自定义信息放置在 ext_json 中,在模板小程序中,可以使用 wx.getExtConfigSync 接口获取自定义信息,从而区分不同的小程序。详见:小程序模板开发 | ||||||
|  |  * ext_json 中的参数可选,参数详见小程序配置;但是,如果是模板id为标准模板库的模板id,则ext_json可支持的参数为:{"extAppid":'', "ext": {}, "window": {}} | ||||||
|  |  * ext_json 中有限支持 pages,支持配置模板页面的子集(ext_json 中不可新增页面)。 | ||||||
|  |  * ext_json 中有限支持 subPackages,支持配置模板分包及其页面的子集(ext_json 中配置的分包必须已声明于模板中,且不可新增分包页面)。 | ||||||
|  |  * ext_json支持plugins配置,该配置会覆盖模板中的app.json中的plugins配置。关于plugin的使用详情请参考使用插件。 | ||||||
|  |  * 如果代码中已经有配置,则配置的合并规则为: | ||||||
|  |  * ext整体替换 | ||||||
|  |  * pages整体替换 | ||||||
|  |  * extPages中找到对应页面,同级覆盖page.json | ||||||
|  |  * window同级覆盖 | ||||||
|  |  * extAppid直接加到app.json | ||||||
|  |  * networkTimeout同级覆盖 | ||||||
|  |  * customOpen整体替换 | ||||||
|  |  * tabbar同级覆盖 | ||||||
|  |  * functionPages整体替换 | ||||||
|  |  * subPackages整体替换 | ||||||
|  |  * navigateToMiniProgaramAppIdList:整体替换 | ||||||
|  |  * plugins整体替换 | ||||||
|  |  * </p> | ||||||
|  |  * | ||||||
|  * @author yqx |  * @author yqx | ||||||
|  * @date 2018/9/13 |  * @date 2018/9/13 | ||||||
|  */ |  */ | ||||||
|  | |||||||
| @ -0,0 +1,56 @@ | |||||||
|  | package me.chanjar.weixin.open.bean.ma; | ||||||
|  |  | ||||||
|  | import com.google.gson.annotations.SerializedName; | ||||||
|  | import lombok.Data; | ||||||
|  |  | ||||||
|  | import java.io.Serializable; | ||||||
|  | import java.util.Map; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 微信第三方平台上传代码到小程序代码标准模板时的参数 | ||||||
|  |  * ext_json补充说明 | ||||||
|  |  * 文档地址:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/commit.html | ||||||
|  |  * 为了便于第三方平台使用同一个小程序模板为不同的小程序提供服务,第三方可以将自定义信息放置在 ext_json 中,在模板小程序中,可以使用 wx.getExtConfigSync 接口获取自定义信息,从而区分不同的小程序。详见:小程序模板开发 | ||||||
|  |  * ext_json 中的参数可选,参数详见小程序配置;但是,如果是模板id为标准模板库的模板id,则ext_json可支持的参数为:{"extAppid":'', "ext": {}, "window": {}} | ||||||
|  |  * ext_json 中有限支持 pages,支持配置模板页面的子集(ext_json 中不可新增页面)。 | ||||||
|  |  * ext_json 中有限支持 subPackages,支持配置模板分包及其页面的子集(ext_json 中配置的分包必须已声明于模板中,且不可新增分包页面)。 | ||||||
|  |  * ext_json支持plugins配置,该配置会覆盖模板中的app.json中的plugins配置。关于plugin的使用详情请参考使用插件。 | ||||||
|  |  * 如果代码中已经有配置,则配置的合并规则为: | ||||||
|  |  * ext整体替换 | ||||||
|  |  * pages整体替换 | ||||||
|  |  * extPages中找到对应页面,同级覆盖page.json | ||||||
|  |  * window同级覆盖 | ||||||
|  |  * extAppid直接加到app.json | ||||||
|  |  * networkTimeout同级覆盖 | ||||||
|  |  * customOpen整体替换 | ||||||
|  |  * tabbar同级覆盖 | ||||||
|  |  * functionPages整体替换 | ||||||
|  |  * subPackages整体替换 | ||||||
|  |  * navigateToMiniProgaramAppIdList:整体替换 | ||||||
|  |  * plugins整体替换 | ||||||
|  |  * </p> | ||||||
|  |  * | ||||||
|  |  * @author <a href="https://www.sacoc.cn">广州跨界</a> | ||||||
|  |  * @since 2021/08/12 | ||||||
|  |  */ | ||||||
|  | @Data | ||||||
|  | public class WxMaOpenCommitStandardExt implements Serializable { | ||||||
|  |  | ||||||
|  |   private static final long serialVersionUID = 4595618023108631477L; | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * 授权小程序Appid,可填入商户小程序AppID,以区分不同商户 | ||||||
|  |    */ | ||||||
|  |   @SerializedName("create_time") | ||||||
|  |   private String extAppId; | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * 开发自定义的数据字段 | ||||||
|  |    */ | ||||||
|  |   private Map<String, Object> ext; | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * 授权小程序Appid,可填入商户小程序AppID,以区分不同商户 | ||||||
|  |    */ | ||||||
|  |   private Map<String, Object> window; | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user
	 hywr
					hywr