From 3d63719719be3ef419e156981a5196b81b277ccc Mon Sep 17 00:00:00 2001 From: liyj <1617420630@qq.com> Date: Wed, 24 Sep 2025 16:00:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E6=A8=A1=E6=9D=BF=E5=8F=82=E6=95=B0=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccountUserBindConnectServiceImpl.java | 43 +++++++++++++++---- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBindConnectServiceImpl.java b/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBindConnectServiceImpl.java index 21a9ae99..c6a57440 100644 --- a/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBindConnectServiceImpl.java +++ b/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBindConnectServiceImpl.java @@ -545,23 +545,48 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl accountUserBindConnectList= list(queryWrapper); if (!accountUserBindConnectList.isEmpty()) { AccountUserBindConnect accountUserBindConnect=accountUserBindConnectList.get(0); - JSONArray jsonArray= jsonObject.getJSONArray("List"); + JSONArray jsonArray=null; + JSONObject object= null; + try { + jsonArray= jsonObject.getJSONArray("List"); + }catch (RuntimeException runtimeException){ + log.info("单个模板"); + object=jsonObject.getJSONObject("List"); + } + UpdateWrapper updateWrapper = new UpdateWrapper<>(); if (jsonArray != null) { - JSONObject object= (JSONObject) jsonArray.get(0); + object= (JSONObject) jsonArray.get(0); String templateId= object.getStr("TemplateId");//模板id String SubscribeStatusString= object.getStr("SubscribeStatusString");//订阅结果(accept接收;reject拒收)参考地址https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message.html#%E8%AE%A2%E9%98%85%E6%B6%88%E6%81%AF%E8%AF%AD%E9%9F%B3%E6%8F%90%E9%86%92 if(SubscribeStatusString.equals("accept")){ - UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.set("bind_tmpl",templateId); - updateWrapper.eq("bind_id",accountUserBindConnect.getBind_id()); - updateWrapper.eq("bind_type",accountUserBindConnect.getBind_type()); - updateWrapper.eq("user_id",accountUserBindConnect.getUser_id()); - updateWrapper.eq("user_type",accountUserBindConnect.getUser_type()); - update(updateWrapper); + accountUserBindConnect.setBind_tmpl(templateId); + getUpdateWrapper(updateWrapper, accountUserBindConnect); + } + }else { + assert object != null; + String templateId= object.getStr("TemplateId");//模板id + String ErrorStatus=object.getStr("ErrorStatus"); + if(ErrorStatus.equals("success")){ + accountUserBindConnect.setBind_tmpl(templateId); + getUpdateWrapper(updateWrapper, accountUserBindConnect); } } + update(updateWrapper); } } + /** + * 封装相同参数的调用方法 + * @param updateWrapper + * @param accountUserBindConnect + */ + private void getUpdateWrapper(UpdateWrapper updateWrapper, + AccountUserBindConnect accountUserBindConnect) { + updateWrapper.set("bind_tmpl",accountUserBindConnect.getBind_tmpl()); + updateWrapper.eq("bind_id",accountUserBindConnect.getBind_id()); + updateWrapper.eq("bind_type",accountUserBindConnect.getBind_type()); + updateWrapper.eq("user_id",accountUserBindConnect.getUser_id()); + updateWrapper.eq("user_type",accountUserBindConnect.getUser_type()); + } }