<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                需求: 1、庫存低于n自動給商家發短信,通知商家進貨。 2、通過切換手機號,可以控制是給老板還是給庫管發短信 該功能用的是thinkcmf二開,用到了一個類庫,[請點擊下載](https://download.csdn.net/download/qq_33862644/10421692) - html 代碼 ~~~ <div> <br/> <b>設置庫存量,自動發送短信</b><br/> 發給給誰:<input type="text" name="cellphone" class="phone"/> 低于庫存多少發送:<input type="text" name="cellnum" class="num"/> <input type="button" value="設置" class="set_phone" name="celle"> <a href="{:url('sms/index')}">手動測試發送短信</a> </div> ~~~ ~~~ <script> $(function () { //設置短信。點擊設置按鈕 $('.set_phone').click(function () { //alert('aa'); var phone = $('.phone').val(); //手機號 var num = $('.num').val(); //庫存低於多少發短信 //發送ajax $.ajax({ method: 'post', url: "{:url('Sms/add')}", data: {cellphone: phone, cellnum: num}, success: function (msg) { if (msg.code == 1) { layer.alert(msg.msg_info); } if (msg.code == 2) { layer.alert(msg.msg_info); } } }); }); }); </script> ~~~ - 配置文件 ![](https://box.kancloud.cn/1cd468967bc309f625f3f4812c99f731_760x290.png) - 控制器 代碼 ~~~ <?php namespace app\ws\controller; use think\Controller; use think\Loader; use think\Config; use think\Db; class SmsController extends Controller{ //發送手機 public function index(){ header('Content-Type: text/plain; charset=utf-8'); //【查】發送給哪個手機,低于多少發送 $sms = Db::name('ws_sms')->where('status',1)->find(); //倒序,取最新的 //【查】出所有,狀態 == 2 && remnant_inventory < 5 $map = [ 'status' => 2, 'remnant_inventory' => ['<',$sms['num']] ]; $info = Db::name('ws_stock')->where($map)->select(); //查數據 //循環發短信 foreach($info as $key => $value){ $res = $this->sendSms($sms['phone'],$value['brand'],$value['version'],$value['remnant_inventory']); if($res->Message == 'OK'){ echo "手動發送成功"; echo "<br />"; } if($res->Code == 'isv.BUSINESS_LIMIT_CONTROL'){ $this->success('您今天發送的短信已達上線(60條)',url('Stock/index')); } } } /** * 發送短信 * @param $phone 要發送的手機號 * @param array $data 替換模板中的變量 */ public function sendSms($phone,$goods,$version,$remnant_inventory){ Loader::import('dayu.api_demo.SmsDemo'); $config = Config::get('dayu'); $demo = new \SmsDemo( "{$config['appKey']}", //需要改的 "{$config['appSecret']}" //需要改的 ); //發送短信 $response = $demo->sendSms( "{$config['sign_name']}", // 短信簽名(需要改的) "{$config['templet_code']}", // 短信模板編號(需要改的) "{$phone}", // 短信接收者(需要改的) Array( // 短信模板中變量的值(需要改的) "goods"=>"{$goods}", //品牌 "model"=>"{$version}", //型號 "num"=>"{$remnant_inventory}" //數量 ), "123" ); return $response; } /** * 【增】【改】手機號 * @return array */ public function add(){ $data = $this->request->param(); //驗證數據合法不合法 $preg = '/^1\d{10}$/'; $info = preg_match($preg,$data['cellphone'],$match); //如果有$find_id走更新,無走添加 $find = DB::name('ws_sms')->where('phone','=',$data['cellphone'])->select(); $find_id = ''; //一個標識 判斷用 foreach ($find as $value){ $find_id = $value['id']; } //手機號是11位 if($info && is_numeric($data['cellnum'])){ $add_res = ''; $update_res = ''; //更新 if($find_id){ //將存在的$find_id記錄,更新為1,其他更新為2。 $update_a = DB::name('ws_sms')->where('id','=',$find_id)->setField('status',1); //更新數量(設置的小于多少發送) $update_c = DB::name('ws_sms')->where('id','=',$find_id)->setField('num',$data['cellnum']); $update_b = DB::name('ws_sms')->where('id','<>',$find_id)->setField('status',2); //echo DB::name('ws_sms')->getLastSql(); if($update_a && $update_b && $update_c){ $update_res = true; } }else{ $save_data = [ 'phone' => $data['cellphone'], 'num' => $data['cellnum'], 'status' => 1 ]; //添加成功1條,將該條置為1。其他的狀態置為2 DB::table('cmf_ws_sms')->insert($save_data); $user_id = DB::table('cmf_ws_sms')->getLastInsID(); $add_res = DB::name('ws_sms')->where('id','<>',$user_id)->setField('status',2); } //添加成功 或 更新成功 if($add_res || $update_res){ $msg = ['code'=>1,'msg_info'=>'設置成功']; return $msg; } }else{ $msg = ['code'=>2,'msg_info'=>'設置失敗,請檢查手機號的位數']; return $msg; } } } ?> ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看