95 lines
3.3 KiB
PHP
95 lines
3.3 KiB
PHP
<?php
|
|
defined('WXAPP_APP') OR exit('No direct script access allowed');
|
|
|
|
/**
|
|
* Created by Vim
|
|
* User: lcc
|
|
* Date: 2021/06/23
|
|
* Time: 14:08
|
|
*/
|
|
require_once APPPATH.'controllers/wxapp/Wxapp.php';
|
|
class Sms extends Wxapp{
|
|
|
|
function __construct($inputs, $app_key){
|
|
parent::__construct($inputs, $app_key);
|
|
|
|
$this->login_white = 'all';//登录白名单
|
|
$this->check_status = array();//用户状态校验
|
|
$this->check_mobile = array();//需要手机号
|
|
$this->check_headimg =array();//授权微信信息
|
|
|
|
}
|
|
|
|
/**
|
|
* 获取验证码
|
|
*/
|
|
protected function get(){
|
|
$mobile = $this->input_param('mobile');
|
|
if (!mobile_valid($mobile)) {
|
|
throw new Exception('请输入正确的手机号码', ERR_PARAMS_ERROR);
|
|
}
|
|
$user = $this->app_user_model->get(['mobile'=>$mobile,'status>'=> -1]);
|
|
if(!$user){
|
|
throw new Exception('用户不存在', API_CODE_FAIL);
|
|
}
|
|
|
|
$mc = &load_cache();
|
|
$key = "licheb_login_code_".$mobile;
|
|
if(!$code = $mc->get($key)) {
|
|
$this->load->helper('string');
|
|
$code = random_string('numeric', 6);
|
|
$mc->save($key, $code, 600);
|
|
}
|
|
if($mobile!='15359333655'){//测试号码
|
|
send_sms($mobile,$code,'好店云科技');
|
|
}
|
|
$msg = '发送成功';
|
|
//$msg = $code;
|
|
throw new Exception($msg, API_CODE_SUCCESS);
|
|
}
|
|
|
|
//发短信给客户
|
|
protected function post_customer(){
|
|
$this->load->model('receiver/receiver_customers_model','customers_model');
|
|
$uid = $this->session['uid'];
|
|
|
|
$id = $this->input_param('id');
|
|
$content = trim($this->input_param('content'));
|
|
|
|
$row = $this->customers_model->get(['id'=>$id]);
|
|
if(!$row || !$content){
|
|
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
|
}
|
|
if($row['admin_id']!=$uid){
|
|
throw new Exception('该客户不可操作', ERR_PARAMS_ERROR);
|
|
}
|
|
$mobile = $row['mobile'];
|
|
$content = '【狸车】'.$content;
|
|
b2m_send_sms($mobile,$content);
|
|
$this->load->library('receiver/customers_entity');
|
|
$this->customers_entity->add_log_visit($id,$uid,$this->session['uname'],$content,1,1);
|
|
throw new Exception('短信发送成功', API_CODE_SUCCESS);
|
|
}
|
|
//通过订单发短信
|
|
protected function post_cusorder(){
|
|
$this->load->model('receiver/order/receiver_orders_model','orders_model');
|
|
$this->load->model('receiver/receiver_customers_model','customers_model');
|
|
$uid = $this->session['uid'];
|
|
|
|
$id = $this->input_param('id');
|
|
$content = $this->input_param('content');
|
|
|
|
$order = $this->orders_model->get(['id'=>$id,'admin_id'=>$uid]);
|
|
$row = $this->customers_model->get(['id'=>$order['rid']]);
|
|
if(!$row || !$content){
|
|
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
|
}
|
|
$mobile = $row['mobile'];
|
|
$content = '【狸车】'.$content;
|
|
b2m_send_sms($mobile,$content);
|
|
$this->load->library('receiver/customers_entity');
|
|
$this->customers_entity->add_log($row['id'],$uid,$this->session['uname'],$content,1);
|
|
throw new Exception('短信发送成功', API_CODE_SUCCESS);
|
|
}
|
|
}
|