alisms_1027

This commit is contained in:
dengbw
2021-10-27 11:04:23 +08:00
parent 0d52d7acf5
commit d5f4ced1e8
7 changed files with 140 additions and 18 deletions
+1 -1
View File
@@ -107,7 +107,7 @@
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w100">户等级:</label>
<label class="am-para-label w100">户等级:</label>
<div class="am-para-inline w100">
<select name="level" v-model="params.level">
<option value=''>请选择</option>
+111
View File
@@ -18,6 +18,117 @@ class Licheb extends HD_Controller
$this->load->model('receiver/receiver_customers_visit_model', 'mdCustomersVisit');
}
/**
* Notes:给销售发送待回访短信
* Created on: 2021/10/19 17:15
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/licheb/visit_sales_sms
* https://api.liche.cn/plan/licheb/visit_sales_sms
*/
public function visit_sales_sms()
{
$params = $this->input->get();
$hour = date('H');
if ($hour != '09' && !$params['sd']) {
echo '[9]点过后才会开始执行发短信给销售[' . $hour . ']';
return;
}
$size = 100;//每次最多处理多少条
$rds = intval($this->input->get('rds'));
$redis = &load_cache('redis');
$redisKey = 'visit_sales_sms_id';
$day = date('Y-m-d');
$re_v = $this->mdCustomersVisit->get(array('day' => $day));//查找当天是否有数据
if (!$re_v || $rds) {
$redis->delete($redisKey);
}
$id = $redis->get($redisKey);
!$id && $id = 0;
$log = array();
$this->load->model('app/licheb/app_licheb_users_model', 'mdUsers');
$where = array('id >' => $id, 'status' => 1, 'group_id' => 1);
$res_u = $this->mdUsers->select($where, 'id asc', 1, $size, 'id,biz_id,mobile');
if (!$res_u) {
echo '执行到当前销售id' . $id . '暂无数据';
return;
}
foreach ($res_u as $key => $value) {
$id = $value['id'];
$biz_id = $value['biz_id'];
$where_v = array("a.biz_id in ($biz_id)" => null, 'a.admin_id' => $id, 'b.contact' => 1, 'b.status' => 1, 'b.day=' => $day);
$visit_count = $this->mdCustomersVisit->count_visit($where_v);
if ($visit_count) {//发送短信
send_alisms(array('mobile' => $value['mobile'], 'template' => 'SMS_226936607', 'param' => ['count' => $visit_count]));
$log[] = array('id' => $id, 'mobile' => $value['mobile'], 'count' => $visit_count);
}
}
$redis->save($redisKey, $id);//保存最后销售id
echo '<br>执行到当前销售id' . $redis->get($redisKey);
echo '<br>成功新增:<br>';
if ($log) {
echo json_encode($log, JSON_UNESCAPED_UNICODE);
echo '<br>';
}
echo '数据库获取:<br>';
echo json_encode($res_u, JSON_UNESCAPED_UNICODE);
}
/**
* Notes:给店长发送待分配短信
* Created on: 2021/10/19 17:15
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/licheb/customer_manager_sms
* https://api.liche.cn/plan/licheb/customer_manager_sms
*/
public function customer_manager_sms()
{
$params = $this->input->get();
$hour = date('H');
if ($hour != '09' && !$params['sd']) {
echo '[9]点过后才会开始执行发短信给销售[' . $hour . ']';
return;
}
$size = 100;//每次最多处理多少条
$rds = intval($this->input->get('rds'));
$redis = &load_cache('redis');
$redisKey = 'customer_manager_sms_id';
$day = date('Y-m-d');
$re_v = $this->mdCustomersVisit->get(array('day' => $day));//查找当天是否有数据
if (!$re_v || $rds) {
$redis->delete($redisKey);
}
$id = $redis->get($redisKey);
!$id && $id = 0;
$log = array();
$this->load->model('app/licheb/app_licheb_users_model', 'mdUsers');
$where = array('id >' => $id, 'status' => 1, 'group_id' => 2);
$res_u = $this->mdUsers->select($where, 'id asc', 1, $size, 'id,biz_id,mobile');
if (!$res_u) {
echo '执行到当前店长id' . $id . '暂无数据';
return;
}
foreach ($res_u as $key => $value) {
$id = $value['id'];
$biz_id = $value['biz_id'];
$where_c = array("biz_id in ($biz_id)" => null, 'status>=' => 0, 'admin_id' => 0);
$Customers_count = $this->mdCustomers->count($where_c);
if ($Customers_count) {//发送短信
send_alisms(array('mobile' => $value['mobile'], 'template' => 'SMS_226970475', 'param' => ['count' => $Customers_count]));
$log[] = array('id' => $id, 'mobile' => $value['mobile'], 'count' => $Customers_count);
}
}
$redis->save($redisKey, $id);//保存最后销售id
echo '<br>执行到当前店长id' . $redis->get($redisKey);
echo '<br>成功新增:<br>';
if ($log) {
echo json_encode($log, JSON_UNESCAPED_UNICODE);
echo '<br>';
}
echo '数据库获取:<br>';
echo json_encode($res_u, JSON_UNESCAPED_UNICODE);
}
/**
* Notes:增加客户待回访
* Created on: 2021/10/19 17:15
+2
View File
@@ -31,6 +31,8 @@ class Plan extends CI_Controller
//$plan[] = array('url' => base_url(array('plan', 'bobing', 'mj_day')), 'interval' => 30);//马甲跑今日分数
$plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_visit')), 'interval' => 1);//增加客户待回访
$plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_level')), 'interval' => 1);//更新客户等级
$plan[] = array('url' => base_url(array('plan', 'licheb', 'visit_sales_sms')), 'interval' => 1);//给销售发送待回访短信
$plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_manager_sms')), 'interval' => 1);//给店长发送待分配短信
$this->plan = $plan;
}
+6 -2
View File
@@ -516,10 +516,14 @@ class Customers extends Wxapp
}
//写日志
$this->load->library('receiver/customers_entity');
$customers = $this->customers_model->get_map_by_ids($id_arr, 'id,rid');
//$customers = $this->customers_model->get_map_by_ids($id_arr, 'id,rid');
foreach ($id_arr as $val) {
$log = "分配客户";
$this->customers_entity->add_log($val, $uid, $uname, $log);
//发送短信
$re = $this->customers_model->get(['id' => $val]);
$num = $re['mobile'] ? substr($re['mobile'], -4) : 0;
send_alisms(array('mobile' => $admin['mobile'], 'template' => 'SMS_226945702', 'param' => ['num' => $num]));
}
throw new Exception('分配成功', API_CODE_SUCCESS);
}
@@ -540,7 +544,7 @@ class Customers extends Wxapp
$size = $params['size'];
!$page && $page = 1;
!$size && $size = 10;
$where = array('a.biz_id' => $biz_id, 'b.contact=' => 1, 'b.status=' => 1);
$where = array('a.biz_id' => $biz_id, 'b.contact' => 1, 'b.status' => 1);
$group_id == 1 && $where['a.admin_id'] = $this->session['uid'];
$count = $this->mdCustomersVisit->count_visit($where);
$lists = [];
+1 -1
View File
@@ -41,7 +41,7 @@ class Sms extends Wxapp{
$mc->save($key, $code, 600);
}
if($mobile!='15359333655'){//测试号码
send_sms($mobile,$code);
send_sms($mobile,$code,'狸车宝');
}
$msg = '发送成功';
//$msg = $code;
+1 -1
View File
@@ -221,7 +221,7 @@ class User extends Wxapp
['title' => '交付确认', 'icon' => 'icon-jiaofu', 'total' => $del_count, 'page' => '/pages/order/filterList/index?key=5&ismy=1'],
];
//客户代办事项
$where_v = array('a.biz_id' => $biz_id, 'b.contact=' => 1, 'b.status=' => 1);
$where_v = array('a.biz_id' => $biz_id, 'b.contact' => 1, 'b.status' => 1);
$group_id == 1 && $where_v['a.admin_id'] = $uid;
$visit_count = $this->mdCustomersVisit->count_visit($where_v);
if ($group_id == 1) {
+18 -13
View File
@@ -371,10 +371,9 @@ if (!function_exists('get_client_ip')) {
* 阿里短信
*/
if (!function_exists('send_sms')) {
function send_sms($mobile, $code)
function send_sms($mobile, $code, $sign = '狸车')
{
require_once COMMPATH . '/third_party/alisms/alisms.php';
$sign = '狸车';
$template = 'SMS_218630210';
$alisms = new AliSms();
$alisms->sendSms($mobile, array('code' => $code), $template, $sign);
@@ -382,14 +381,19 @@ if (!function_exists('send_sms')) {
}
}
if (!function_exists('send_sms')) {
function send_sms_content($mobile, $content)
if (!function_exists('send_alisms')) {
function send_alisms($json)
{
require_once COMMPATH . '/third_party/alisms/alisms.php';
$sign = '狸车';
$template = 'SMS_218630210';
if (!$json['mobile'] || !$json['template']) {
return false;
}
$mobile = $json['mobile'];
$template = $json['template'];
$sign = $json['sign'] ? $json['sign'] : '狸车宝';
$templateParam = $json['param'];
$alisms = new AliSms();
$alisms->sendSms($mobile, array('content' => $content), $template, $sign);
$alisms->sendSms($mobile, $templateParam, $template, $sign);
return true;
}
}
@@ -1044,13 +1048,14 @@ if (!function_exists('create_contract_no')) {
}
if(!function_exists('getMonth')){
function getMonth($season){
if (!function_exists('getMonth')) {
function getMonth($season)
{
$times = array();
$firstday = date('Y-m-d H:i:s', mktime(0, 0, 0,$season*3-3+1,1,date('Y')));
$sm = date('m',mktime(0,0,0,$season*3-3+1,1,date('Y')))+1;
$firstday = date('Y-m-d H:i:s', mktime(0, 0, 0, $season * 3 - 3 + 1, 1, date('Y')));
$sm = date('m', mktime(0, 0, 0, $season * 3 - 3 + 1, 1, date('Y'))) + 1;
$seconday = date("Y-{$sm}-01");
$lastday = date('Y-m-d H:i:s', mktime(23,59,59,$season*3,date('t',mktime(0, 0 , 0,$season*3,1,date('Y'))),date('Y')));
return [$firstday,$seconday,$lastday];
$lastday = date('Y-m-d H:i:s', mktime(23, 59, 59, $season * 3, date('t', mktime(0, 0, 0, $season * 3, 1, date('Y'))), date('Y')));
return [$firstday, $seconday, $lastday];
}
}