Jelajahi Sumber

终端客户

hu 7 bulan lalu
induk
melakukan
c72bb90873

+ 1 - 1
src/custom/beans/itemclass/SQL/查询货品的营销分类.sql

@@ -1,4 +1,4 @@
-SELECT t1.itemid, t2.itemclassname,t2.itemclassfullname,t1.classtype
+SELECT t1.itemid, t2.itemclassname,t2.itemclassfullname,t1.classtype,t2.itemclassid
 from sa_itemsaleclass t1
          INNER JOIN plm_itemclass t2 ON t2.itemclassid = t1.itemclassid and t2.siteid = t1.siteid
 WHERE t1.itemid IN $itemid$

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

@@ -6631,6 +6631,21 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2025082114174203 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025082114391803 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025082115363003 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 42 - 0
src/custom/restcontroller/webmanage/sale/aftersalesmag/aftersalesmag.java

@@ -224,6 +224,48 @@ public class aftersalesmag extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
+    @API(title = "终端客户查询自己保修卡", apiversion = R.ID2025082115363003.v1.class)
+    public String querycustomerwarrantycard() throws YosException {
+        long sa_customersid=content.getLong("sa_customersid");
+        StringBuffer where = new StringBuffer(" 1=1 ");
+
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t2.itemname like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.itemno like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.sku like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t6.cardno like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+        }
+//		String hrid = content.getString("hrid");
+//        SQLFactory sqlFactory = new SQLFactory(this, "审核订单列表查询", pageSize, pageNumber, pageSorting);
+//        sqlFactory.addParameter_SQL("where", where);
+//        sqlFactory.addParameter("siteid", siteid);
+//        sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
+//        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL(false));
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_itemsku ", "sku");
+        querySQL.setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t2", "t1.itemid=t2.itemid and t1.siteid=t2.siteid","itemid","itemno","itemname","model","spec");
+        querySQL.addJoinTable(JOINTYPE.left, "plm_unit", "t3", "t3.unitid=t2.unitid and t3.siteid=t2.siteid","unitname");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t4", "t4.sa_agentsid=t1.sa_agentsid and t4.siteid=t1.siteid","agentnum");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t5", "t5.sys_enterpriseid=t4.sys_enterpriseid and t5.siteid=t4.siteid","contact","phonenumber","address");
+        querySQL.addJoinTable(JOINTYPE.inner, "sa_warrantycard", "t6", "t6.sku=t1.sku and t6.siteid=t1.siteid","cardno","begdate","enddate");
+
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("t6.sa_customersid",sa_customersid);
+        querySQL.setWhere(where.toString());
+        querySQL.setDistinct(true);
+        querySQL.setPage(pageSize, pageNumber);
+        querySQL.setOrderBy(pageSorting);
+        Rows rows = querySQL.query();
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+
     @API(title = "返退单详情", apiversion = R.ID20230104160603.v1.class)
     @CACHEING
     public String queryaftersalesmagMain() throws YosException {

+ 68 - 0
src/custom/restcontroller/webmanage/users/users.java

@@ -12,6 +12,7 @@ import common.annotation.CACHEING_CLEAN;
 import common.annotation.cm;
 import common.data.*;
 import restcontroller.R;
+import restcontroller.sale.serviceorder.serviceorder;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -295,6 +296,73 @@ public class users extends Controller {
         return query_userMain();
     }
 
+    @API(title = "通过手机号查询美大终端客户id", apiversion = R.ID2025082114391803.v1.class)
+    public String querycustomer() throws YosException {
+        String phonenumber = content.getString("phonenumber");
+        Rows rows = dbConnect.runSqlQuery("select * from sa_customers where sa_agentsid!=0 and siteid='"+siteid+"' and phonenumber='"+phonenumber+"'");
+        Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
+        return getSucReturnObject().setData(row).toString();
+    }
+
+
+    @API(title = "创建美大终端客户", apiversion = R.ID2025082114174203.v1.class)
+    @CACHEING_CLEAN(apiversions = {users.class})
+    public String inser_user() throws YosException {
+        long userid = 0;//新增时传0
+        String name = content.getString("name");
+        String phonenumber = content.getString("phonenumber");
+        String remarks = content.getString("remarks");
+        String accountno = "美大用户"+phonenumber.substring(phonenumber.length() - 4);
+
+        boolean isValidPhoneNumber = validatePhoneNumber(phonenumber);
+        if (!isValidPhoneNumber) {
+            return getErrReturnObject().setErrMsg("请输入正确的手机号").toString();
+        }
+
+        Rows rows = dbConnect.runSqlQuery("select * from sa_customers where sa_agentsid!=0 and siteid='"+siteid+"' and phonenumber='"+phonenumber+"'");
+        if(rows.isEmpty()){
+            return getSucReturnObject().setData(false).toString();
+       }
+
+
+        if (dbConnect.runSqlQuery("select *from sys_users where phonenumber='" + phonenumber + "' and userid!='" + userid + "'").isNotEmpty()) {
+            return getSucReturnObject().setData(true).toString();
+        }
+
+        ArrayList<Long> roleidslist = new ArrayList<>();
+        /*
+          根据用户类型查找新账号默认角色
+         */
+        int usertype = 99;
+        ArrayList<String> sqllist = new ArrayList<>();
+
+
+        Rows defaultrole = dbConnect.runSqlQuery("select roleid from sys_role where siteid='" + siteid + "' and usertype='" + usertype + "' and issystem=1");
+        roleidslist.addAll(defaultrole.toArrayList("roleid", new ArrayList<>()));
+
+        CreateUserFactory createUserFactory;
+        if (accountno.isEmpty()) {
+            createUserFactory = new CreateUserFactory(this, name, phonenumber, usertype, roleidslist.toArray(new Long[]{}), remarks);
+        } else {
+            String accountprefix = Parameter.getString(siteid, "accountprefix");
+            accountno = accountprefix + accountno;
+            if (dbConnect.runSqlQuery("SELECT 1 from sys_users WHERE  accountno ='" + accountno + "' ").isNotEmpty()) {
+                return getErrReturnObject().setErrMsg("当前账号【" + accountno + "】已存在").toString();
+            }
+            createUserFactory = new CreateUserFactory(this, accountno, name, phonenumber, usertype, roleidslist.toArray(new Long[]{}), remarks);
+        }
+
+        sqllist.addAll(createUserFactory.getSQL());
+        userid = createUserFactory.getUserid();
+        content.put("userid", userid);
+        sqllist.add(DataContrlLog.createLog(this,"sys_users",userid,"新增","新增用户成功").getSQL());
+
+        dbConnect.runSqlUpdate(sqllist);
+
+        return getSucReturnObject().setData(true).toString();
+    }
+
+
     @API(title = "登陆账号变更")
     @CACHEING_CLEAN(cms = {@cm(clazz = users.class, method = {"query_userList", "query_userMain"})})
     public String changeAccountno() throws YosException {