Browse Source

微信账号绑定成员

eganwu 1 năm trước cách đây
mục cha
commit
f505cf2a7e

+ 5 - 0
src/custom/restcontroller/R.java

@@ -6523,6 +6523,11 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID20240524090002 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 30 - 0
src/custom/restcontroller/common/usercenter/usercenter.java

@@ -414,6 +414,36 @@ public class usercenter extends Controller {
         return getSucReturnObject().toString();
     }
 
+
+    @API(title = "微信账号绑定成员", apiversion = R.ID20240524090002.v1.class)
+    @CACHEING_CLEAN(cms = {@cm(clazz = usercenter.class, method = {"queryUserMsg"})})
+    public String WechatBindingHr() throws YosException {
+
+        Long hrid = content.getLongValue("hrid");
+        Rows rows = dbConnect.runSqlQuery("select * from sys_hr WHERE hrid="+hrid+" and siteid='" + siteid + "'");
+        if (rows.isEmpty()) {
+            return getErrReturnObject().setErrMsg("人员不存在").toString();
+        }
+        Row hrRow = rows.get(0);
+
+        if (hrRow.getLong("userid") > 0) {
+            return getErrReturnObject().setErrMsg("微信已绑定").toString();
+        }
+        UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_hr");
+        updateSQL.setSiteid(siteid);
+        updateSQL.setUniqueid(hrid);
+        updateSQL.setValue("userid", userid);
+        System.err.println(updateSQL.getSQL());
+        updateSQL.update();
+
+        if (usertype == 99) {
+            new StoreHelper().updateUserType1(this);
+        }
+
+
+        return getSucReturnObject().toString();
+    }
+
     @API(title = "微信公众号绑定", accesstoken = false)
     public String WechatServceBinding() throws YosException {
         String accesstoken = content.getStringValue("accesstoken");

+ 16 - 0
src/custom/restcontroller/webmanage/saletool/store/StoreHelper.java

@@ -86,6 +86,22 @@ public class StoreHelper extends BaseClass {
         }
     }
 
+    public void updateUserType1(Controller controller) throws YosException {
+        updateUserType(controller, 1);
+
+        ArrayList<Long> deleteroles = dbConnect.runSqlQuery("SELECT visitor_roleid from sys_wechatapp WHERE (systemclient='"
+                + controller.systemclient + "' or systemclient_auth='" + controller.systemclient + "' ) and  siteid='" + controller.siteid + "'  and isvisitor=1").toArrayList("visitor_roleid", new ArrayList<>());
+
+        if (deleteroles.size() > 0) {
+            deleteUserRole(controller, deleteroles);
+        }
+
+        Rows rows = dbConnect.runSqlQuery("select * from sys_role where issystem=1 and usertype=1 and siteid='" + controller.siteid + "'");
+        if (rows.isNotEmpty()) {
+            insertUserRole(controller, rows.get(0).getLong("roleid"));
+        }
+    }
+
     public void updateUserType99(Controller controller) throws YosException {
         updateUserType(controller, 99);