Skip to content

微信支付商家券available_day_time字段格式错误 #3574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Treyoo opened this issue May 9, 2025 · 1 comment · Fixed by #3583
Closed

微信支付商家券available_day_time字段格式错误 #3574

Treyoo opened this issue May 9, 2025 · 1 comment · Fixed by #3583
Milestone

Comments

@Treyoo
Copy link

Treyoo commented May 9, 2025

简要描述

通过sdk请求微信支付创建商家券接口/查询商家券接口,提示json序列化/反序列化异常

模块版本情况

  • WxJava 模块名: weixin-java-pay
  • WxJava 版本号: 4.7.0

详细描述

sdk内com.github.binarywang.wxpay.bean.marketing.busifavor.AvailableWeek.AvailableDayTime没有定义为数组,微信api返回的是json数组,格式不一致导致异常
微信api文档:https://pay.weixin.qq.com/doc/v3/merchant/4012534855

日志

1.调用方法com.github.binarywang.wxpay.service.MarketingBusiFavorService#createBusiFavorStocksV3
【异常信息】:无法将 JSON 输入源“/body/coupon_use_rule/coupon_available_time/available_week/available_day_time”映射到多重字段“当天可用时间段”中,此字段需要 JSON 数组对象
WxPayException(customErrorMsg=无法将 JSON 输入源“/body/coupon_use_rule/coupon_available_time/available_week/available_day_time”映射到多重字段“当天可用时间段”中,此字段需要 JSON 数组对象, returnCode=null, returnMsg=null, resultCode=null, errCode=PARAM_ERROR, errCodeDes=无法将 JSON 输入源“/body/coupon_use_rule/coupon_available_time/available_week/available_day_time”映射到多重字段“当天可用时间段”中,此字段需要 JSON 数组对象, xmlString=null)
	at com.github.binarywang.wxpay.service.impl.WxPayServiceApacheHttpImpl.convertException(WxPayServiceApacheHttpImpl.java:377)
	at com.github.binarywang.wxpay.service.impl.WxPayServiceApacheHttpImpl.postV3WithWechatpaySerial(WxPayServiceApacheHttpImpl.java:192)
	at com.github.binarywang.wxpay.service.impl.MarketingBusiFavorServiceImpl.createBusiFavorStocksV3(MarketingBusiFavorServiceImpl.java:33)


2. 调用方法com.github.binarywang.wxpay.service.MarketingBusiFavorService#getBusiFavorStocksV3
微信接口正常响应,sdk反序列化微信响应json报错:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 302 path $.coupon_use_rule.coupon_available_time.available_week.available_day_time
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
	at com.google.gson.Gson.fromJson(Gson.java:932)
	at com.google.gson.Gson.fromJson(Gson.java:897)
	at com.google.gson.Gson.fromJson(Gson.java:846)
	at com.google.gson.Gson.fromJson(Gson.java:817)
	at com.github.binarywang.wxpay.service.impl.MarketingBusiFavorServiceImpl.getBusiFavorStocksV3(MarketingBusiFavorServiceImpl.java:41)
@binarywang
Copy link
Owner

欢迎直接提交PR贡献代码,谢谢

@binarywang binarywang added this to the 4.7.6 milestone May 13, 2025
@binarywang binarywang linked a pull request May 13, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants