zoujiajian 3 jaren geleden
bovenliggende
commit
291561465f

+ 7 - 0
netflix-dao/src/main/java/com/cyksj/mapper/UserMapper.java

@@ -3,9 +3,11 @@ package com.cyksj.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.cyksj.model.entity.User;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 
 import java.math.BigDecimal;
+import java.util.List;
 
 /**
  * @author chan
@@ -27,4 +29,9 @@ public interface UserMapper extends BaseMapper<User> {
 
     @Update("update user set active_points = active_points - #{subPoints} where active_points > 0 and active_points >= #{subPoints} and id = #{userId}")
     Integer subActivePoints(@Param("userId") Long userId, @Param("subPoints") BigDecimal subPoints);
+
+    @Select("select s2.external_userid from (select DISTINCT user_id,unionid from `order_don` od left join user u on u.id = od.user_id where status not in ('close','noPayment')"
+            + " and goods_id = 18 and unionid !='') s inner join (select cu.unionid,ca.external_userid from `corp_user` cu left join corp_user_auth ca on ca.corp_user_id = cu.id" +
+            " where wx_corp_id = 2 and unionid != '') s2 on s2.unionid = s.unionid")
+    List<String> selectExterUserId();
 }

+ 39 - 2
netflix-web/src/main/java/com/cyksj/web/controller/manage/CmsUserController.java

@@ -180,7 +180,7 @@ public class CmsUserController{
      * 企业微信群发发送用户账号过期
      */
     private final WxCorpOps wxCorpOps;
-
+    private final static String content = "还没有自己独立的ChatGPT账号?正式推出ChatGPT独立账号!还有付费API,Chat GPT同门师兄杀手级对手Claude,轻松打败95%人类画师的Midjourney,立即体验上车https://nf.video/yinhe/web/";
     @GetMapping("/corp/send/msg")
     public Result<String> corpSendMsg() throws Exception {
         DateTime now = new DateTime();
@@ -193,7 +193,7 @@ public class CmsUserController{
             GoodsDonSku donSku = skuMapper.selectById(skuId);
             GoodsDon goodsDon = donMapper.selectById(donSku.getGoodsId());
             Set<String> exterUserIds = relations.stream().map(GroupsRelation::getExternalUserid).collect(Collectors.toSet());
-            String content = String.format("您的%s账号5天内即将到期,请尽快续费,以免影响使用,续费地址:https://nf.video/yinhe/web/ticket", goodsDon.getTitle());
+//            String content = String.format("您的%s账号5天内即将到期,请尽快续费,以免影响使用,续费地址:https://nf.video/yinhe/web/ticket", goodsDon.getTitle());
             JSONObject jsonObject = new JSONObject();
             jsonObject.putOpt("chat_type", "single");
             jsonObject.putOpt("external_userid", new String[]{"wmvj2DPQAAzWQY3xIQOQMykTASbvb_pQ"});
@@ -275,4 +275,41 @@ public class CmsUserController{
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
 
+    /**
+     * GPT
+     */
+    @GetMapping("/get/gpt/notify")
+    public Result<String> gptNotify() throws Exception {
+        String url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_msg_template?access_token=" + wxCorpOps.getAccessToken("ww9c0ccaad2e9d3822");
+        List<String> externalUserIds = userMapper.selectExterUserId();
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.putOpt("chat_type", "single");
+            jsonObject.putOpt("external_userid", externalUserIds);
+            JSONObject text = new JSONObject();
+            text.putOpt("content", content);
+            try {
+                jsonObject.putOpt("text", text);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        for (String cs : customer) {
+            jsonObject.putOpt("sender", cs);
+            HttpResponse<String> send = null;
+            try {
+                send = J11HttpC.custom()
+                        .ofPost()
+                        .url(url)
+                        .body(HttpRequest.BodyPublishers.ofString(jsonObject.toString()))
+                        .send(HttpResponse.BodyHandlers.ofString());
+                JSONObject response = Jsons.parseObject(send.body(), JSONObject.class);
+                log.info(response.toString());
+                if (response.getInt("errcode") == 0 && response.getStr("errmsg").equals("ok")) {
+                    System.out.println("发送成功");
+                }
+            } catch (Exception e) {
+            }
+        }
+        return null;
+    }
+
 }