关于微信公众号开发无法支付的问题解决(2)

/** * @Company {} * @author {KevenPotter} * @description * {Do not delete this method. This method is to increase for the number of users * can not recharge by WeChat, because the formatting method before this method may result * in illegal date format, which will lead to illegal order number of the user * order Characters. This method is similar to a hard-coded effect and aims to * forcibly obtain a numeric "year, month, and day" when creating a new Date class, * rather than a wrong conversion by the previous formatting method.} * @description * {此方法请勿删除.此方法的存在是为了处理部分用户无法充值而增加的,因为此方法之前的格式化 * 方法可能会出现日期格式化非法的结果,这样将会导致用户订单的订单号出现非法字符.此方法属于 * 类似硬编码的效果,旨在当新建Date类时,强行获取数字型的"年月日",而不是由之前的格式化方法 * 进行错误的转换} * @param {No Parameter} * @returns {String} */ private createTradeNo(): string { let dateNow = new Date(); let year: number = dateNow.getFullYear(); let month: string | number = (dateNow.getMonth() + 1) < 10 ? "0" + (dateNow.getMonth() + 1) : (dateNow.getMonth() + 1); let day: string | number = dateNow.getDate() < 10 ? "0" + dateNow.getDate() : dateNow.getDate(); let hours: string | number = dateNow.getHours() < 10 ? "0" + dateNow.getHours() : dateNow.getHours(); let minutes: string | number = dateNow.getMinutes() < 10 ? "0" + dateNow.getMinutes() : dateNow.getMinutes().toString(); let seconds: string | number = dateNow.getSeconds() < 10 ? "0" + dateNow.getSeconds() : dateNow.getSeconds(); let out_trade_no: string = "" + year + month + day + hours + minutes + seconds + userId; return out_trade_no; }

这种方式类似于硬编码的方式,就是强行获取数字型年月日时分秒等值,然后转换为字符串进行传参;

(2)、从后端业务进行拦截,拦截的地方就是传参的开始,我这里采用网上比较通用的正则表达式的方式,只要是数字的就要,其他的剔除:

String regEx = "[^0-9]"; Pattern pattern = Pattern.compile(regEx); Matcher matcher = pattern.matcher(out_trade_no); String outTradeNo = matcher.replaceAll("").trim(); // 过滤后的订单

1.4  这两种方案出现之后,经过和同事商议,决定采用第二种解决方法,但不删除第一种解决策略,如果第二种方法不可以,再采用第一种解决策略。经过部署于客户反馈,微信充值问题大部分已解决(75%)。

2.  针对"页面无法正常加载,微信上方绿色进度条瞬间加载完成,无法显示正常的页面,是一片白色的屏幕"的问题解决。

2.1  首先依据客服的反馈,我们在公司的内部进行了一次测试,目的是问题的重现。总共测试了20个手机,遗憾的是全部通过,指导硬件部门有一个人也想来做一下测试,这时发生了页面白屏现象。我们后来进过对比,才发现这种情况的出现好似和微信昵称有关联。即,这个人的昵称带有特殊符号。

这时,我们项目经理指出,这应该是数据库编码出现了问题,特殊符号(emoji)无法存入。但是还需进行测验,要在内部把问题重现出来。

2.2  搭建本地测试环境,进行测试(就是改变自己的微信昵称同时加入emoji表情符号)。但是进行了大致四次的更换,还是无法重现问题。之后经过同事提醒发来了苹果手机的表情,再次进行测试,问题重现~

重现问题之后,查看日志记录,现粘贴如下:

2018-04-23 22:59:06.432 INFO 120 --- [p-nio-80-exec-1] com.hh.rest.app.service.WechatService :
xml msg:
<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[oUpF8uMuAJO_M2pxb1Q9zNjWeS6o]]></FromUserName>
<CreateTime>1524495419</CreateTime>
<MsgType><![CDATA[event]]></MsgType>
<Event><![CDATA[subscribe]]></Event>
<EventKey><![CDATA[]]></EventKey>
</xml>
2018-04-23 22:59:06.521 INFO 120 --- [p-nio-80-exec-1] com.hh.rest.app.service.WechatService : enter subscribe
{"country":"中国","qr_scene":0,"subscribe":1,"city":"朝阳","openid":"oUpF8uMuAJO_M2pxb1Q9zNjWeS6o","tagid_list":[],"sex":1,"groupid":0,
"language":"zh_CN","remark":"","subscribe_time":1524495419,"province":"北京","subscribe_scene":"ADD_SCENE_QR_CODE","nickname":"口哈哈哈",
"headimgurl":"http://thirdwx.qlogo.cn/mmopen/iaXTwdhNbibo6cBH1GClwSgkEictOnsAN8v6JY6eB1O7ibddGXXn1iceAnZlrd8OiaqdWNAL1wGqPAc3ibDNBCQFqulvXwhEzHSnwJ8/132",
"qr_scene_str":""}
2018-04-23 22:59:06.917 INFO 120 --- [p-nio-80-exec-1] com.hh.rest.app.service.WechatService : userInfoObj:
{"country":"中国","qr_scene":0,"subscribe":1,"city":"朝阳","openid":"oUpF8uMuAJO_M2pxb1Q9zNjWeS6o","tagid_list":[],"sex":1,"groupid":0,
"language":"zh_CN","remark":"","subscribe_time":1524495419,"province":"北京","subscribe_scene":"ADD_SCENE_QR_CODE","nickname":"口哈哈哈",
"headimgurl":"http://thirdwx.qlogo.cn/mmopen/iaXTwdhNbibo6cBH1GClwSgkEictOnsAN8v6JY6eB1O7ibddGXXn1iceAnZlrd8OiaqdWNAL1wGqPAc3ibDNBCQFqulvXwhEzHSnwJ8/132",
"qr_scene_str":""}
Hibernate: select userentity0_.id as id1_13_, userentity0_.balance as balance2_13_, userentity0_.coupon as coupon3_13_, userentity0_.credit as credit4_13_, userentity0_.is_admin as is_admin5_13_, userentity0_.is_agent as is_agent6_13_, userentity0_.is_partner as is_partn7_13_, userentity0_.wx_icon as wx_icon8_13_, userentity0_.wx_name as wx_name9_13_, userentity0_.wx_open_id as wx_open10_13_, userentity0_.wx_subscribe_ts as wx_subs11_13_, userentity0_.wx_subscribed as wx_subs12_13_ from user userentity0_ where userentity0_.wx_open_id=?
Hibernate: insert into user (balance, coupon, credit, is_admin, is_agent, is_partner, wx_icon, wx_name, wx_open_id, wx_subscribe_ts, wx_subscribed) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2018-04-23 22:59:06.970 WARN 120 --- [p-nio-80-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 1366, SQLState: HY000
2018-04-23 22:59:06.970 ERROR 120 --- [p-nio-80-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : Incorrect string value: '\xF0\x9F\x8D\xB4\xE5\x93...' for column 'wx_name' at row 1
2018-04-23 22:59:06.993 ERROR 120 --- [p-nio-80-exec-1] c.h.r.a.e.GlobalExceptionHandler : /rest/wechat/checkSign?signature=f3cac2272ab3f442b32d8560f024919240ab96e1×tamp=1524495419&nonce=451675791&openid=oUpF8uMuAJO_M2pxb1Q9zNjWeS6o; Error: could not execute statement; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement
2018-04-23 22:59:07.008 WARN 120 --- [p-nio-80-exec-1] .m.m.a.ExceptionHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.orm.jpa.JpaSystemException: could not execute statement; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/214f93fabbee53aea98f22be6ee965a8.html