Explorar el Código

fix:“优化微信推送功能“

soobin hace 1 año
padre
commit
020e8df5c9

+ 1 - 5
src/main/java/com/szwl/controller/AlarmRecordIndexController.java

@@ -97,11 +97,7 @@ public class AlarmRecordIndexController {
             String sendContent = alarmContent;
             if (sendContent.length() > 20) {
                 // 如果超过20个字符
-                if(StringUtils.isEmpty(ifForeign) || ifForeign.equals("0")) {
-                    sendContent = "请前往后台查看详细信息";
-                } else {
-                    sendContent = "Check in the system";
-                }
+                sendContent =  sendContent.substring(0, 16) + "...";
             }
             wechatService.sendAlarmMessage(wechat.getOpenId(), clientId, name, companyType, sendContent, alarmRecordVo.getOccurrenceTime());
         }

+ 19 - 0
src/main/java/com/szwl/controller/TWechatController.java

@@ -2,8 +2,12 @@ package com.szwl.controller;
 
 
 import cn.com.crbank.ommo.exception.MyException;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
 import com.szwl.constant.ConfigConsts;
+import com.szwl.constant.ResponseCodesEnum;
 import com.szwl.model.bo.R;
+import com.szwl.model.bo.ResponseModel;
 import com.szwl.model.entity.TAdmin;
 import com.szwl.model.entity.TWechat;
 import com.szwl.model.param.WxBindParam;
@@ -294,5 +298,20 @@ public class TWechatController {
         return result;
     }
 
+    @ApiOperation(value = "获取微信授权openId")
+    @GetMapping("/getOpenId")
+    public ResponseModel<?> getOpenId(@RequestParam("adminId") Long adminId) {
+        if(adminId == null) {
+            return R.fail(ResponseCodesEnum.A0001);
+        }
+        LambdaQueryWrapper<TWechat> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(TWechat::getAdminId, adminId);
+        TWechat wechat = tWechatService.getOne(queryWrapper);
+        if(wechat != null && StringUtils.isNotEmpty(wechat.getOpenId())) {
+            return R.ok(wechat.getOpenId());
+        }
+        return R.ok();
+    }
+
 }
 

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 2 - 1
src/main/java/com/szwl/mapper/xml/TAdminMapper.xml


+ 4 - 1
src/main/java/com/szwl/model/entity/TAdmin.java

@@ -19,7 +19,7 @@ import lombok.EqualsAndHashCode;
  * </p>
  *
  * @author wuhs
- * @since 2024-04-13
+ * @since 2024-05-10
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -156,5 +156,8 @@ public class TAdmin implements Serializable {
     @ApiModelProperty(value = "支付宝支付配置ID")
     private Long alipayId;
 
+    @ApiModelProperty(value = "微信公众号订单通知,0:关闭,1:开启,默认关闭")
+    private String orderNotice;
+
 
 }

+ 11 - 1
src/main/java/com/szwl/service/impl/TWechatServiceImpl.java

@@ -61,6 +61,9 @@ public class TWechatServiceImpl extends ServiceImpl<TWechatMapper, TWechat> impl
         Map<String, WeChatTemplateMsg> sendMag = new HashMap();
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String alarmTime = format.format(new Date());
+        if(name.length() > 20) {
+            name =  name.substring(0, 16) + "...";
+        }
         if (StringUtils.isEmpty(ifForeign) || ifForeign.equals("0")) {
             // 国内
             sendMag.put("thing11", new WeChatTemplateMsg(name));
@@ -87,7 +90,11 @@ public class TWechatServiceImpl extends ServiceImpl<TWechatMapper, TWechat> impl
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String alarmTime = format.format(occurrenceTime);
         // 模版参数
-        sendMag.put("thing11", new WeChatTemplateMsg(name));
+        if(name.length() > 20) {
+            sendMag.put("thing11", new WeChatTemplateMsg(name.substring(0, 16) + "..."));
+        } else {
+            sendMag.put("thing11", new WeChatTemplateMsg(name));
+        }
         sendMag.put("character_string14", new WeChatTemplateMsg(clientId.substring(clientId.length()-6)));
         sendMag.put("thing4", new WeChatTemplateMsg("高"));
         sendMag.put("time5", new WeChatTemplateMsg(alarmTime));
@@ -183,8 +190,11 @@ public class TWechatServiceImpl extends ServiceImpl<TWechatMapper, TWechat> impl
         sendBody.put("data", sendMag);
         if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
             sendBody.put("template_id", ConfigConsts.SZ_TEMPLATE_ID);
+            sendBody.put("url", "http://szwlh.sunzee.com.cn/shenze/");
         } else {
             sendBody.put("template_id", ConfigConsts.SC_TEMPLATE_ID);
+            sendBody.put("url", "http://sevencloud.com.cn/sc/");
+
         }
         String sendUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken;
         ResponseEntity<String> forEntity = restTemplate.postForEntity(sendUrl, sendBody, String.class);