Sfoglia il codice sorgente

服务验证码消息推送

hu 2 mesi fa
parent
commit
1238835d59

+ 26 - 11
src/custom/restcontroller/webmanage/sale/serviceorder/serviceorder.java

@@ -19,6 +19,7 @@ import common.data.*;
 import org.apache.commons.lang.StringUtils;
 import org.apache.cxf.configuration.security.DNConstraintsType;
 import restcontroller.R;
+import restcontroller.webmanage.executorService.Executor;
 import restcontroller.webmanage.sale.serviceorder.tools.HttpURLRest;
 import restcontroller.webmanage.sale.serviceorder.tools.VerificationManage;
 import restcontroller.webmanage.sale.workorder.workorder;
@@ -775,7 +776,6 @@ public class serviceorder extends Controller {
         }else{
             //return getErrReturnObject().setErrMsg("工单创建人信息有误").toString();
         }
-
         if(usertype==99){
             customerphone=userrows.get(0).getString("phonenumber");
         }else{
@@ -784,22 +784,37 @@ public class serviceorder extends Controller {
             }
         }
 
+
         if (!Pattern.matches("^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$", customerphone)) {
             return getErrReturnObject().setErrMsg("手机格式有误").toString();
         }
         String verificationCode = createVerificationCode();
-        Sms sms = new Sms();
-        sms.sendout(Sms.SmsType.PassWord,customerphone, Parameter.getString("chuanglan_sms_model_password"), new String[]{verificationCode});
-        message_map.put(customerphone, new VerificationManage(verificationCode));
+        dbConnect.runSqlUpdate("update sa_workorder set verificationcode='"+verificationCode+"' where sa_workorderid="+sa_workorderid);
+        Rows wxserviceRows = dbConnect.runSqlQuery("select t2.userid from sys_wechatapp_openids t1 inner join sys_users t2 on t1.userid=t2.userid where t2.phonenumber='"+customerphone+"'");
         Row row = new Row();
-        if (!BaseClass.isdebug() && !Arrays.asList(Parameter.getString("system_invalidate_phonenumber").split(",")).contains(customerphone)) {
-            row.put("code", 1);
-            row.put("msg", "手机验证码已发送,请注意查收!");
-        }else{
-            row.put("code", 1);
-            row.put("msg", "手机验证码为:"+verificationCode);
+        if(wxserviceRows.isEmpty()){
+            ArrayList<Long> userids = wxserviceRows.toArrayList("userid",new ArrayList<>());
+            JSONObject extradata = new JSONObject();
+            extradata.put("extraUserList", userids);
+            Executor.sendEml(this, "verificationcode_push", sa_workorderid,siteid, extradata);
+            if (!BaseClass.isdebug() && !Arrays.asList(Parameter.getString("system_invalidate_phonenumber").split(",")).contains(customerphone)) {
+                row.put("code", 1);
+                row.put("msg", "验证码已发送,请注意查收!");
+            }
+        }else {
+            if(StringUtils.isNotBlank("customerphone")){
+                Sms sms = new Sms();
+                sms.sendout(Sms.SmsType.PassWord,customerphone, Parameter.getString("chuanglan_sms_model_password"), new String[]{verificationCode});
+                message_map.put(customerphone, new VerificationManage(verificationCode));
+            }
+            if (!BaseClass.isdebug() && !Arrays.asList(Parameter.getString("system_invalidate_phonenumber").split(",")).contains(customerphone)) {
+                row.put("code", 1);
+                row.put("msg", "手机验证码已发送,请注意查收!");
+            }else{
+                row.put("code", 1);
+                row.put("msg", "手机验证码为:"+verificationCode);
+            }
         }
-
         return getSucReturnObject().setData(row).toString();
     }