add-admin-app_config
This commit is contained in:
@@ -10,7 +10,6 @@ class Config extends Appconf
|
||||
parent::__construct();
|
||||
$this->load->model('app/app_model');
|
||||
$this->load->model("app/appusual/app_config_model");
|
||||
$this->load->model('vipcard/Vipcard_rights_model', 'rightsM');
|
||||
}
|
||||
|
||||
//首页信息
|
||||
@@ -29,8 +28,6 @@ class Config extends Appconf
|
||||
public function get()
|
||||
{
|
||||
$id = $this->input->get('app_id');
|
||||
$this->load->model('app/app_model');
|
||||
$this->load->model("sys/sys_city_model", 'city_model');
|
||||
|
||||
$app = $this->app_model->get(array('id' => $id));
|
||||
if (!$app) {
|
||||
@@ -39,23 +36,6 @@ class Config extends Appconf
|
||||
$json = $app['jsondata'] ? json_decode($app['jsondata'], true) : array();
|
||||
$json['id'] = $id;
|
||||
$json['name'] = $app['name'];
|
||||
$where = array('status' => 1);
|
||||
$total = $this->city_model->count($where);
|
||||
$citys = array();
|
||||
if ($total) {
|
||||
$rows = $this->city_model->select($where, 'id DESC', 1, 20, 'city_id,name,firstchar');
|
||||
foreach ($rows as $item) {
|
||||
$status = intval($json['citys'][$item['city_id']]);
|
||||
$citys[] = array(
|
||||
'city_id' => $item['city_id'],
|
||||
'firstchar' => $item['firstchar'],
|
||||
'name' => $item['name'],
|
||||
'status' => $status,
|
||||
'statusion' => $status ? '开启' : '关闭',
|
||||
'default_city_id' => $json['city_id'] == $item['city_id'] ? 1 : 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$where = array('app_id' => $id);
|
||||
$select = "k,v";
|
||||
@@ -68,11 +48,8 @@ class Config extends Appconf
|
||||
}
|
||||
$json[$k] = $v;
|
||||
}
|
||||
|
||||
$this->data['type_arr'] = self::$rights_type;
|
||||
$this->data['coup_arr'] = self::$coupon_type;
|
||||
|
||||
$this->data['info'] = $json;
|
||||
$this->data['citys'] = $citys;
|
||||
$this->data['_title'] = "{$app['name']}-基础设置";
|
||||
return $this->show_view('/app/appusual/get_config', true);
|
||||
}
|
||||
@@ -83,47 +60,6 @@ class Config extends Appconf
|
||||
|
||||
}
|
||||
|
||||
public function edit_city()
|
||||
{
|
||||
if (!$this->if_ajax) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '提交出错!');
|
||||
}
|
||||
|
||||
$id = $this->input->post('id');
|
||||
$city = $this->input->post('city');
|
||||
$status = $this->input->post('status');
|
||||
$type = $this->input->post('type');
|
||||
|
||||
$this->load->model('app/app_model');
|
||||
|
||||
$app = $this->app_model->get(array('id' => $id));
|
||||
if (!$app) {
|
||||
return $this->show_json(SYS_CODE_FAIL, "id为{$id}小程序不存在");
|
||||
}
|
||||
$json = $app['jsondata'] ? json_decode($app['jsondata'], true) : array();
|
||||
if ($type == 1) {
|
||||
if ($status) {
|
||||
$json['city_id'] = $city;
|
||||
} else {
|
||||
$json['city_id'] = 0;
|
||||
}
|
||||
} else {
|
||||
if ($status) {
|
||||
!$json['citys'][$city] && $json['citys'][$city] = 1;
|
||||
} else {
|
||||
unset($json['citys'][$city]);
|
||||
if (!$json['citys']) {
|
||||
unset($json['citys']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$ret = $this->app_model->update(array('jsondata' => json_encode($json)), array('id' => $id));
|
||||
if (!$ret) {
|
||||
debug_log("[error]" . __FUNCTION__ . ":" . $this->app_model->db->last_query(), $this->log_file);
|
||||
return $this->show_json(SYS_CODE_FAIL, '操作失败');
|
||||
}
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
|
||||
}
|
||||
|
||||
//编辑单条数据
|
||||
public function edit()
|
||||
@@ -138,18 +74,9 @@ class Config extends Appconf
|
||||
}
|
||||
$json = json_decode($app['jsondata'], true);
|
||||
//是否开启自定义店铺分类
|
||||
$json_k = array('biz_cate', 'vipcard', 'rights', 'coupons', 'ebiz', 'publish', 'lock_fans', "rpackets");
|
||||
$json_k = array('publish');
|
||||
foreach ($json_k as $k) {
|
||||
switch($k){
|
||||
case 'rights':
|
||||
case 'coupons':
|
||||
case 'rpackets':
|
||||
if($input[$k] && is_array($input[$k])){
|
||||
$json[$k] = $input[$k];
|
||||
} else {
|
||||
unset($json[$k]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ($input[$k]) {
|
||||
$json[$k] = $input[$k];
|
||||
@@ -160,29 +87,6 @@ class Config extends Appconf
|
||||
}
|
||||
$this->app_model->update(array('jsondata' => json_encode($json, JSON_UNESCAPED_UNICODE)), array('id' => $input['id']));
|
||||
|
||||
$config_k = array('hotword');
|
||||
foreach($config_k as $k){
|
||||
$where = array('app_id' => $input['id'], 'k' => $k);
|
||||
$row_config = $this->app_config_model->get($where);
|
||||
if($input[$k]){
|
||||
if($row_config){
|
||||
$upd = array("v" => json_encode($input[$k], JSON_UNESCAPED_UNICODE));
|
||||
$ret = $this->app_config_model->update($upd, array('id' => $row_config['id']));
|
||||
} else {
|
||||
$add = array(
|
||||
'app_id' => $input['id'],
|
||||
'k' => $k,
|
||||
'v' => json_encode($input[$k], JSON_UNESCAPED_UNICODE),
|
||||
'admin_id' => $this->uid,
|
||||
'c_time' => time()
|
||||
);
|
||||
$ret = $this->app_config_model->add($add);
|
||||
}
|
||||
} elseif($row_config) {
|
||||
$ret = $this->app_config_model->delete(array('id' => $row_config['id']));
|
||||
}
|
||||
}
|
||||
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
|
||||
}
|
||||
|
||||
@@ -203,4 +107,4 @@ class Config extends Appconf
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,15 @@ class Main extends HD_Controller{
|
||||
|
||||
/*小程序设置 start*/
|
||||
$list = array();
|
||||
$list[] = array(
|
||||
'title' => '基础设置',
|
||||
'btns' => array(
|
||||
array('name' => '查看详情', 'url' => '/app/appusual/config/get?app_id=' . $this->app_id),
|
||||
),
|
||||
);
|
||||
$conditions[] = array('icon' => 'am-icon-home', 'list' => $list);
|
||||
|
||||
$list = [];
|
||||
// 用户数据
|
||||
$value = $this->userM->count([]);
|
||||
$list[] = array(
|
||||
@@ -33,9 +42,6 @@ class Main extends HD_Controller{
|
||||
array('name' => '查看详情', 'url' => '/app/liche/member/index'),
|
||||
),
|
||||
);
|
||||
$conditions[] = array('icon' => 'am-icon-home', 'list' => $list);
|
||||
|
||||
$list = [];
|
||||
$value = $this->subM->count(array('app_id' => $this->app_id));
|
||||
$list[] = array(
|
||||
'title' => '话题管理',
|
||||
|
||||
@@ -21,8 +21,16 @@ class Main extends HD_Controller{
|
||||
$conditions = array();
|
||||
|
||||
/*小程序设置 start*/
|
||||
$list = array();
|
||||
$list = [];
|
||||
$list[] = array(
|
||||
'title' => '基础设置',
|
||||
'btns' => array(
|
||||
array('name' => '查看详情', 'url' => '/app/appusual/config/get?app_id=' . $this->app_id),
|
||||
),
|
||||
);
|
||||
$conditions[] = array('icon' => 'am-icon-home', 'list' => $list);
|
||||
// 用户数据
|
||||
$list = [];
|
||||
$value = $this->userM->count([]);
|
||||
$list[] = array(
|
||||
'title' => '用户(人)',
|
||||
|
||||
@@ -17,18 +17,6 @@
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/appitem/hd.css?v=1581252500">
|
||||
<form id="vue-edit" class="am-form am-form-horizontal" data-auto="true" action="/app/appusual/config/edit" method="post"
|
||||
style="width: 90%;padding-top: 10px">
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">是否开启店铺自定义分类:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="checkbox" class="mui-switch mui-switch-anim" true-value="1" false-value="0" v-model="info.biz_cate" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">是否开通卡功能:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="checkbox" class="mui-switch mui-switch-anim" true-value="1" false-value="0" v-model="info.vipcard" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">小程序发布设置:</label>
|
||||
<div class="am-para-input">
|
||||
@@ -36,161 +24,11 @@
|
||||
<span class="note-text va-mid">(小程序发布审核时开启,可以隐藏一些敏感内容)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">可使用权益类型:</label>
|
||||
<div class="am-para-input">
|
||||
<div class="am-g">
|
||||
<label class="mr10" style="margin-top: 7px" v-for="(tv, tk) in type_arr">
|
||||
<input type="checkbox" :value="tk" v-model="info.rights"/>{{tv}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">可使用电子券类型:</label>
|
||||
<div class="am-para-input">
|
||||
<div class="am-g">
|
||||
<label class="mr10" style="margin-top: 7px">
|
||||
<input type="checkbox" value="1" v-model="info.coupons"/>erp电子券
|
||||
</label>
|
||||
<label class="mr10" style="margin-top: 7px">
|
||||
<input type="checkbox" value="2" v-model="info.coupons"/>线下买单抵用券
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">可用红包类型:</label>
|
||||
<div class="am-para-input">
|
||||
<div class="am-g">
|
||||
<label class="mr10" style="margin-top: 7px">
|
||||
<input type="checkbox" value="3" v-model="info.rpackets"/>线上红包
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">可使用内容功能:</label>
|
||||
<div class="am-para-input">
|
||||
<div class="am-g">
|
||||
<div class="am-g">
|
||||
<label class="mr10" style="margin-top: 7px">
|
||||
<input disabled type="checkbox" name="func[]" value="1"/>好评
|
||||
</label>
|
||||
<label class="mr10" style="margin-top: 7px">
|
||||
<input disabled type="checkbox" name="func[]" value="2"/>文章
|
||||
</label>
|
||||
<label class="mr10" style="margin-top: 7px">
|
||||
<input disabled type="checkbox" name="func[]" value="3"/>活动
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">是否开启电商:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="checkbox" name="ebiz" class="mui-switch mui-switch-anim" true-value="1" false-value="0" v-model="info.ebiz"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">是否开启分销锁粉:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="checkbox" name="lock_fans" class="mui-switch mui-switch-anim" true-value="1" false-value="0" v-model="info.lock_fans" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">系统客服:</label>
|
||||
|
||||
<div class="am-para-input">
|
||||
<a class="am-btn am-btn-primary" style="margin-top: 5px;"
|
||||
:data-modal="'/app/app/get_servicer?type=0&app_id='+info.id"
|
||||
:data-title="info.name+'客服设置'">客服设置</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group" v-if="14==info.id">
|
||||
<label class="am-para-label label-width">热门搜索设置:</label>
|
||||
<div class="am-para-input input-left">
|
||||
<div class="am-form-inline">
|
||||
<button type="button" class="am-btn am-btn-default am-btn-sm" @click="word_modal()">添加热词</button>
|
||||
<span class="f12 clr999 lh-default ml5">热门搜索,已加<strong class="text-danger"
|
||||
v-if="info.hotword">{{info.hotword.length}}</strong>个</span>
|
||||
</div>
|
||||
<div class="label-group-wrap label-group-sortable">
|
||||
<draggable class="app-simulator-inner" v-model="info.hotword" group="info.hotword"
|
||||
@start="drag=true" @end="drag=false" @sort="sort">
|
||||
<div class="label-group" v-for="(v,i) in info.hotword">
|
||||
<span class="label label-default sort-shop-list" :data-id="i" :data-name="v"
|
||||
:data-sort="v">{{v}}</span>
|
||||
<a href="javascript:void(0);" @click="rm_item(i, 'word',v)" class="label label-default"><i
|
||||
class="fa fa-remove del_word"></i></a>
|
||||
</div>
|
||||
</draggable>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group mb20">
|
||||
<label class="am-para-label">开通城市:</label>
|
||||
<div class="am-para-input">
|
||||
<div class="coms-table-bd">
|
||||
<table class="am-table am-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="10%"><span>城市ID</span></th>
|
||||
<th width="10%"><span>首字母</span></th>
|
||||
<th width="20%"><span>城市名称</span></th>
|
||||
<th width="20%"><span>状态</span></th>
|
||||
<th width=""><span>操作</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(v,k) in citys">
|
||||
<td>{{v.city_id}}</td>
|
||||
<td>{{v.firstchar}}</td>
|
||||
<td>{{v.name}}</td>
|
||||
<td>{{v.statusion}}</td>
|
||||
<td>
|
||||
<a v-if="1==v.status" data-ajax="post" data-action="/app/appusual/config/edit_city"
|
||||
:data-params-id="info.id" :data-params-city="v.city_id"
|
||||
data-params-status="0" class="am-btn am-btn-danger am-btn-xs">关闭</a>
|
||||
<a v-else data-ajax="post" data-action="/app/appusual/config/edit_city"
|
||||
:data-params-id="info.id" :data-params-city="v.city_id"
|
||||
data-params-status="1" class="am-btn am-btn-primary am-btn-xs">开启</a>
|
||||
<a v-if="1==v.default_city_id" data-ajax="post" data-action="/app/appusual/config/edit_city"
|
||||
:data-params-id="v.id" :data-params-city="v.city_id"
|
||||
data-params-type="1" data-params-status="0"
|
||||
class="am-btn am-btn-danger am-btn-xs">取消默认</a>
|
||||
<a v-else data-ajax="post" data-action="/app/appusual/config/edit_city"
|
||||
:data-params-id="v.id" :data-params-city="v.city_id"
|
||||
data-params-type="1" data-params-status="1"
|
||||
class="am-btn am-btn-primary am-btn-xs">设为默认</a>
|
||||
<a v-if="1==v.status&&13==v.id" href="javascript:;" :data-open="'app/xmfish/main/get_city?city_id='+v.city_id" class="c-btn am-btn am-btn-primary am-btn-xs">设置</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group" style="margin-bottom: 2rem">
|
||||
<div class="am-para-input">
|
||||
<button class="am-btn am-btn-success" type="button" @click="saveEdit">提交</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="word-modal" style="display: none;">
|
||||
<div class="modal-body">
|
||||
|
||||
<label class="am-para-label" style="margin-left: -60px;" >热搜词:</label>
|
||||
<div class="am-para-input">
|
||||
<div class="am-form-inline">
|
||||
<div class="am-form-group" style="width: 75%">
|
||||
<input type="text" class="hot_word" v-model="hot_word" placeholder="请输入热搜词">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
var vue_obj;
|
||||
@@ -200,22 +38,10 @@
|
||||
el: '#vue-edit',
|
||||
data: {
|
||||
info:'',
|
||||
type_arr:'',
|
||||
coup_arr:'',
|
||||
citys:'',
|
||||
hot_word:''
|
||||
},
|
||||
mounted:function() {
|
||||
var vm = this;
|
||||
vm.info = <?=json_encode($info, JSON_UNESCAPED_UNICODE)?>;
|
||||
vm.type_arr = <?=json_encode($type_arr, JSON_UNESCAPED_UNICODE)?>;
|
||||
vm.coup_arr = <?=json_encode($coup_arr, JSON_UNESCAPED_UNICODE)?>;
|
||||
vm.citys = <?=json_encode($citys, JSON_UNESCAPED_UNICODE)?>;
|
||||
if(vm.info.rights == undefined){vm.info.rights=[];}
|
||||
if(vm.info.coupons == undefined){vm.info.coupons=[];}
|
||||
if(vm.info.rpackets == undefined){vm.info.rpackets=[];}
|
||||
if(vm.info.hotword == undefined){vm.info.hotword=[];}
|
||||
console.log(vm.info);
|
||||
},
|
||||
computed: {},
|
||||
created: function () {
|
||||
@@ -223,38 +49,6 @@
|
||||
updated: function () {
|
||||
},
|
||||
methods: {
|
||||
word_modal:function(){
|
||||
var vm = this;
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: ['50%', '30%'], //宽高
|
||||
content: $('#word-modal'),
|
||||
title: '热词搜索',
|
||||
shade: false,
|
||||
btn: ['确定添加'],
|
||||
yes: function (index) {
|
||||
if(vm.hot_word){
|
||||
var sear=new RegExp(vm.hot_word);
|
||||
if(!sear.test(vm.info.hotword)){
|
||||
vm.info.hotword.push(vm.hot_word);
|
||||
vm.hot_word = '';
|
||||
}else{
|
||||
layer.msg("该热词已存在", {icon: 2});
|
||||
}
|
||||
}
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
},
|
||||
rm_item:function(i, type, word){
|
||||
var vm = this;
|
||||
if (type == 'word'){
|
||||
vm.info.hotword.splice(i,1);
|
||||
}
|
||||
},
|
||||
sort:function(){
|
||||
var vm = this;
|
||||
},
|
||||
saveEdit: function () {
|
||||
if (loading) {
|
||||
return;
|
||||
@@ -297,4 +91,4 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -38,7 +38,9 @@
|
||||
<div class="coms-layout-container theme-default">
|
||||
<div class="coms-layout-header">
|
||||
<div class="bars-nav"><i class="am-icon-bars"></i>导航</div>
|
||||
<a href="" class="logo">狸车<span style="vertical-align: -3px;font-size: 14px;">liche.cn</span></a>
|
||||
<a href="" class="logo" style="">
|
||||
<img src="/static/images/common/logo.png" style="height:40px">
|
||||
</a>
|
||||
<?php if ($menus) { ?>
|
||||
<ul class="header-nav">
|
||||
<? foreach ($menus as $v) { ?>
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
defined('WXAPP_APP') OR exit('No direct script access allowed');
|
||||
/**
|
||||
* Created by vim
|
||||
* User: lcc
|
||||
* Desc: 配置信息
|
||||
* Date: 2021/07/27
|
||||
* Time: 10:22
|
||||
*/
|
||||
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
|
||||
class Config extends Wxapp{
|
||||
function __construct($inputs, $app_key){
|
||||
parent::__construct($inputs, $app_key);
|
||||
|
||||
$this->login_white = array('get');//登录白名单
|
||||
$this->check_status = array();//用户状态校验
|
||||
$this->check_mobile = array();//需要手机号
|
||||
$this->check_headimg =array();//授权微信信息
|
||||
$this->load->model('app/app_model');
|
||||
}
|
||||
|
||||
protected function get(){
|
||||
$publish = $this->app_config('publish');
|
||||
$data = array(
|
||||
'publishh' => intval($publish),
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,8 @@ defined('WXAPP_APP') OR exit('No direct script access allowed');
|
||||
* Desc: 支付接口
|
||||
* Date: 2021/06/29
|
||||
* Time: 19:47
|
||||
*/ require_once APPPATH . 'controllers/wxapp/Wxapp.php';
|
||||
*/
|
||||
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
|
||||
class Payment extends Wxapp{
|
||||
|
||||
public function __construct($inputs, $app_key){
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
defined('WXAPP_APP') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Created by Vim.
|
||||
* User: lcc
|
||||
* Desc: 晓致虚拟号
|
||||
* Date: 2021/07/26
|
||||
* Time: 10:17
|
||||
*/
|
||||
require_once APPPATH.'controllers/wxapp/Wxapp.php';
|
||||
class Xz extends Wxapp{
|
||||
|
||||
private $log_file = 'call.log';
|
||||
private $log_dir = 'xiaozhi';
|
||||
function __construct($inputs, $app_key){
|
||||
parent::__construct($inputs, $app_key);
|
||||
|
||||
$this->login_white = array();//登录白名单
|
||||
|
||||
$this->load->model('receiver/receiver_customers_model','customers_model');
|
||||
$this->load->model('receiver/order/receiver_orders_model','orders_model');
|
||||
|
||||
$this->load->model('receiver/receiver_xz_model');
|
||||
}
|
||||
public function get(){
|
||||
$id = $this->input_param('id');
|
||||
$type = intval($this->input_param('type'));
|
||||
!$type && $type = 0;
|
||||
$session = $this->session;
|
||||
$admin_id = $session['uid'];
|
||||
if($type==1){ //订单
|
||||
$row = $this->orders_model->get(['id'=>$id]);
|
||||
}else{//客户
|
||||
$row = $this->customers_model->get(['id'=>$id]);
|
||||
}
|
||||
if(!$row || !$row['mobile']){
|
||||
throw new Hd_Exception('用户不存在', API_CODE_INVILD_PARAM);
|
||||
}
|
||||
$customer_mobile = $row['mobile'];
|
||||
|
||||
$redis = &load_cache('redis');
|
||||
$cache_key = "XZ_LICHEB_MOBILEB_{$customer_mobile}_{$admin_id}";
|
||||
$call_mobile = $redis->get($cache_key);
|
||||
if (!$call_mobile) {
|
||||
$this->config->load('xcall', TRUE);
|
||||
$mobile_list = $this->config->item('mobile_list', 'xcall');//晓智号码库
|
||||
require_once COMMPATH.'third_party/Xcall/Xcall.php';
|
||||
$seq_id = 'liche_'.create_order_no();
|
||||
$result = '';
|
||||
//循环绑定
|
||||
$xcall = new Xcall();
|
||||
$maxBindingTime = 30 * 60;//绑定时间
|
||||
foreach($mobile_list as $key => $val){
|
||||
$mid_mobile = $val;
|
||||
$result = $xcall -> SWbind($customer_mobile,$seq_id,$mid_mobile,$maxBindingTime);
|
||||
if($result['code']){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!$result['code']){ //绑定失败
|
||||
debug_log("xz_failed_bind:customer_mobile【{$customer_mobile}】", $this->log_file);
|
||||
debug_log("xz_result:" . json_encode($result, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
//解绑并删除最早绑定手机号
|
||||
$redis_obj = $redis->redis();
|
||||
$lists = $redis_obj->keys("XZ_LICHEB_MOBILEB_*");
|
||||
$del_cache = '';
|
||||
$temp_time = $maxBindingTime;
|
||||
foreach ($lists as $key => $val) {
|
||||
$l_c_time = $redis_obj->TTL($val);
|
||||
if ($l_c_time < $temp_time) {
|
||||
$temp_time = $l_c_time;
|
||||
$del_cache = $val;
|
||||
}
|
||||
}
|
||||
if ($del_cache) {
|
||||
$mid_mobile = $redis->get($del_cache);
|
||||
//解绑
|
||||
$s_res = $xcall -> Searchbind($mid_mobile);
|
||||
$bined_mobile = $s_res['data']['value'];//已绑定手机号
|
||||
if($bined_mobile){
|
||||
$xcall -> SWunbind($bined_mobile,$mid_mobile);//解绑
|
||||
$redis->delete($del_cache);
|
||||
}
|
||||
$result = $xcall -> SWbind($customer_mobile,$seq_id,$mid_mobile);
|
||||
}
|
||||
}
|
||||
if ($result['code']) {
|
||||
$this->data['middlenumber'] = $result['data']['virtualMobile'];
|
||||
$add_data = [
|
||||
'call_id' => $seq_id,
|
||||
'display_number' => $result['data']['virtualMobile'],
|
||||
'cf_id' => $id,
|
||||
'cf_uid' => $admin_id,
|
||||
'cf_title' => $cf_title,
|
||||
'cf_platform' => 'api',
|
||||
'json_data' => json_encode(['uname'=>$session['uname']],JSON_UNESCAPED_UNICODE),
|
||||
'c_time' => time()
|
||||
];
|
||||
$this->receiver_xz_model->add($add_data);
|
||||
$call_mobile = $result['data']['virtualMobile'];
|
||||
$redis->save($cache_key, $call_mobile, $maxBindingTime);
|
||||
} else {
|
||||
debug_log("xz_failed_bind:customer_mobile【{$customer_mobile}】", $this->log_file);
|
||||
debug_log("xz_result:" . json_encode($result, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
throw new Hd_Exception($result['msg'], API_CODE_FAIL);
|
||||
}
|
||||
}
|
||||
$data['mobile'] = $call_mobile;
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
Reference in New Issue
Block a user